mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
recursive add/import of icons/smilies/paks, reset topic/post icon_id's when deleting icons
git-svn-id: file:///svn/phpbb/trunk@3416 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
1cafc63b2f
commit
3e605446ff
1 changed files with 103 additions and 17 deletions
|
@ -71,6 +71,8 @@ switch ($mode)
|
||||||
// Clear some arrays
|
// Clear some arrays
|
||||||
$_images = $_paks = array();
|
$_images = $_paks = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Grab file list of paks and images
|
// Grab file list of paks and images
|
||||||
if ($action == 'edit' || $action == 'add' || $action == 'import')
|
if ($action == 'edit' || $action == 'add' || $action == 'import')
|
||||||
{
|
{
|
||||||
|
@ -99,14 +101,34 @@ if ($action == 'edit' || $action == 'add' || $action == 'import')
|
||||||
switch ($action)
|
switch ($action)
|
||||||
{
|
{
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
|
||||||
$db->sql_query('DELETE FROM ' . $table . '
|
$db->sql_query('DELETE FROM ' . $table . '
|
||||||
WHERE ' . $fields . '_id = ' . intval($_GET['id']));
|
WHERE ' . $fields . '_id = ' . intval($_GET['id']));
|
||||||
|
|
||||||
|
switch ($mode)
|
||||||
|
{
|
||||||
|
case 'emoticons':
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'icons':
|
||||||
|
// Reset appropriate icon_ids
|
||||||
|
$db->sql_query('UPDATE ' . TOPICS_TABLE . '
|
||||||
|
SET icon_id = 0
|
||||||
|
WHERE icon_id = ' . intval($_GET['id']));
|
||||||
|
$db->sql_query('UPDATE ' . POSTS_TABLE . '
|
||||||
|
SET icon_id = 0
|
||||||
|
WHERE icon_id = ' . intval($_GET['id']));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
trigger_error($user->lang[$lang . '_DELETED']);
|
trigger_error($user->lang[$lang . '_DELETED']);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
case 'add':
|
case 'add':
|
||||||
|
|
||||||
$order_list = '';
|
$order_list = '';
|
||||||
|
$existing_imgs = array();
|
||||||
$result = $db->sql_query('SELECT *
|
$result = $db->sql_query('SELECT *
|
||||||
FROM ' . $table . '
|
FROM ' . $table . '
|
||||||
ORDER BY ' . $fields . '_order DESC');
|
ORDER BY ' . $fields . '_order DESC');
|
||||||
|
@ -114,6 +136,8 @@ switch ($action)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
$existing_imgs[] = $row[$fields . '_url'];
|
||||||
|
|
||||||
if ($row[$fields . '_id'] == $id)
|
if ($row[$fields . '_id'] == $id)
|
||||||
{
|
{
|
||||||
$after = TRUE;
|
$after = TRUE;
|
||||||
|
@ -129,7 +153,7 @@ switch ($action)
|
||||||
}
|
}
|
||||||
|
|
||||||
$after_txt = ($mode == 'emoticons') ? $row['code'] : $row['icons_url'];
|
$after_txt = ($mode == 'emoticons') ? $row['code'] : $row['icons_url'];
|
||||||
$order_list = '<option value="' . ($row[$fields . '_order'] + 1) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], htmlspecialchars($after_txt)) . '</option>' . $order_list;
|
$order_list = '<option value="' . ($row[$fields . '_order']) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -> ' . htmlspecialchars($after_txt)) . '</option>' . $order_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ($row = $db->sql_fetchrow($result));
|
while ($row = $db->sql_fetchrow($result));
|
||||||
|
@ -138,8 +162,14 @@ switch ($action)
|
||||||
|
|
||||||
$order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . $user->lang['FIRST'] . '</option>' . $order_list;
|
$order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . $user->lang['FIRST'] . '</option>' . $order_list;
|
||||||
|
|
||||||
|
$imglist = filelist($phpbb_root_path . $img_path, '');
|
||||||
|
|
||||||
$filename_list = '';
|
$filename_list = '';
|
||||||
foreach ($_images as $img)
|
foreach ($imglist as $img)
|
||||||
|
{
|
||||||
|
$img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file'];
|
||||||
|
|
||||||
|
if (!in_array($img, $existing_imgs))
|
||||||
{
|
{
|
||||||
if ((isset($data) && $img == $data[$fields . '_url']) ||
|
if ((isset($data) && $img == $data[$fields . '_url']) ||
|
||||||
(!isset($data) && !isset($edit_img)))
|
(!isset($data) && !isset($edit_img)))
|
||||||
|
@ -154,6 +184,9 @@ switch ($action)
|
||||||
|
|
||||||
$filename_list .= '<option value="' . $img . '"' . htmlspecialchars($img) . $selected . '>' . $img . '</option>';
|
$filename_list .= '<option value="' . $img . '"' . htmlspecialchars($img) . $selected . '>' . $img . '</option>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
unset($existing_imgs);
|
||||||
|
unset($imglist);
|
||||||
|
|
||||||
page_header($user->lang[$lang]);
|
page_header($user->lang[$lang]);
|
||||||
|
|
||||||
|
@ -341,6 +374,20 @@ function update_image_dimensions()
|
||||||
if ($_POST['current'] == 'delete')
|
if ($_POST['current'] == 'delete')
|
||||||
{
|
{
|
||||||
$db->sql_query('TRUNCATE ' . $table);
|
$db->sql_query('TRUNCATE ' . $table);
|
||||||
|
|
||||||
|
switch ($mode)
|
||||||
|
{
|
||||||
|
case 'emoticons':
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'icons':
|
||||||
|
// Reset all icon_ids
|
||||||
|
$db->sql_query('UPDATE ' . TOPICS_TABLE . '
|
||||||
|
SET icon_id = 0');
|
||||||
|
$db->sql_query('UPDATE ' . POSTS_TABLE . '
|
||||||
|
SET icon_id = 0');
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -432,11 +479,15 @@ function update_image_dimensions()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$paklist = filelist($phpbb_root_path . $img_path, '', 'pak');
|
||||||
|
|
||||||
$pak_options = '';
|
$pak_options = '';
|
||||||
if (count($_paks))
|
if (count($paklist))
|
||||||
{
|
{
|
||||||
foreach ($_paks as $pak)
|
foreach ($paklist as $pak)
|
||||||
{
|
{
|
||||||
|
$pak = substr($pak['path'], 1) . (($pak['path'] != '') ? '/' : '') . $pak['file'];
|
||||||
|
|
||||||
$pak_options .= '<option>' . htmlspecialchars($pak) . '</option>';
|
$pak_options .= '<option>' . htmlspecialchars($pak) . '</option>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,7 +551,8 @@ function update_image_dimensions()
|
||||||
case 'send':
|
case 'send':
|
||||||
|
|
||||||
$result = $db->sql_query('SELECT *
|
$result = $db->sql_query('SELECT *
|
||||||
FROM ' . $table);
|
FROM ' . $table . "
|
||||||
|
ORDER BY {$fields}_order");
|
||||||
if ($row = $db->sql_fetchrow($result))
|
if ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
|
@ -665,4 +717,38 @@ function update_image_dimensions()
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------
|
||||||
|
// FUNCTIONS
|
||||||
|
//
|
||||||
|
function filelist($rootdir, $dir = '', $type = 'gif|jpg|png')
|
||||||
|
{
|
||||||
|
static $images = array();
|
||||||
|
|
||||||
|
$dh = opendir($rootdir . $dir);
|
||||||
|
|
||||||
|
while ($fname = readdir($dh))
|
||||||
|
{
|
||||||
|
if (is_file($rootdir . $dir . '/' . $fname) &&
|
||||||
|
preg_match('#\.' . $type . '$#i', $fname) &&
|
||||||
|
filesize($rootdir . $dir . '/' . $fname))
|
||||||
|
{
|
||||||
|
$images[] = array('path' => $dir, 'file' => $fname);
|
||||||
|
}
|
||||||
|
else if ($fname != '.' && $fname != '..' &&
|
||||||
|
!is_file($rootdir . $dir . '/' . $fname) &&
|
||||||
|
!is_link($rootdir . $dir . '/' . $fname))
|
||||||
|
{
|
||||||
|
filelist($rootdir, $dir . '/'. $fname, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dh);
|
||||||
|
|
||||||
|
return $images;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// FUNCTIONS
|
||||||
|
// ---------
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue