From dbd512138e249884b6adbda7caa5731498d8802f Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 14 Aug 2003 23:32:50 +0000 Subject: [PATCH] imageset editing code a little messy, need to add update/replace capability to all three elements but that's for M-4 ... I think we may be done for M-2 git-svn-id: file:///svn/phpbb/trunk@4405 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 175 ++++++++++++++++++++++++++----- phpBB/language/en/lang_admin.php | 76 +++++++++++++- 2 files changed, 219 insertions(+), 32 deletions(-) diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 4c4d00c38b..2580c5d5ba 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -12,9 +12,10 @@ // ------------------------------------------------------------- // TODO -// BBCode support -> M-3 -// Previews of templates, imagesets, themes ... unified -> M-3 -// Add custom theme classes +// For M-3 +// BBCode support +// Replace template/s, stylesheet, images, etc. +// Previews of templates, imagesets, themes ... unified // Security review if (!empty($setmodules)) @@ -69,8 +70,7 @@ else } // Set some basic vars -$error = $cfg = $stylecfg = array(); -$tmp_path = ''; +$error = $cfg = array(); $safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false; $file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false; @@ -1191,7 +1191,7 @@ function csspreview() case 'imageset': $imglist = array( 'buttons' => array( - 'btn_post', 'btn_post_pm', 'btn_reply', 'btn_reply_pm', 'btn_locked', 'btn_profile', 'btn_pm', 'btn_delete', 'btn_ip', 'btn_quote', 'btn_search', 'btn_edit', 'btn_report', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline', 'btn_topic_watch', 'btn_topic_unwatch', + 'btn_post', 'btn_reply', 'btn_locked', 'btn_quote', 'btn_edit', 'btn_delete', 'btn_report', 'btn_post_pm', 'btn_reply_pm', 'btn_profile', 'btn_pm', 'btn_ip', 'btn_search', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline', ), 'icons' => array( 'icon_unapproved', 'icon_reported', 'icon_attach', 'icon_post', 'icon_post_new', 'icon_post_latest', 'icon_post_newest',), @@ -1201,18 +1201,21 @@ function csspreview() 'folder', 'folder_posted', 'folder_new', 'folder_new_posted', 'folder_hot', 'folder_hot_posted', 'folder_hot_new', 'folder_hot_new_posted', 'folder_locked', 'folder_locked_posted', 'folder_locked_new', 'folder_locked_new_posted', 'folder_sticky', 'folder_sticky_posted', 'folder_sticky_new', 'folder_sticky_new_posted', 'folder_announce', 'folder_announce_posted', 'folder_announce_new', 'folder_announce_new_posted',), 'polls' => array( 'poll_left', 'poll_center', 'poll_right',), - 'custom' => array(), ); switch ($action) { case 'edit': $imgname = (!empty($_POST['imgname'])) ? htmlspecialchars($_POST['imgname']) : ''; + $imgpath = (isset($_POST['imgpath'])) ? htmlspecialchars($_POST['imgpath']) : ''; + $imgsize = (!empty($_POST['imgsize'])) ? true : false; + $imgwidth = (isset($_POST['imgwidth'])) ? intval($_POST['imgwidth']) : ''; if ($id) { - $sql = 'SELECT * - FROM ' . STYLES_IMAGE_TABLE . " + $sql_select = ($imgname) ? ", $imgname" : ''; + $sql = "SELECT imageset_path, imageset_name, imageset_copyright$sql_select + FROM " . STYLES_IMAGE_TABLE . " WHERE imageset_id = $id"; $result = $db->sql_query($sql); @@ -1222,10 +1225,52 @@ function csspreview() } $db->sql_freeresult($result); + // Check to see whether the selected image exists in the table + $valid_name = false; + foreach ($imglist as $category => $img_ary) + { + if (in_array($imgname, $img_ary)) + { + $valid_name = true; + break; + } + } -// $cache->destroy('sql', STYLES_IMAGE_TABLE); + if (!$valid_name) + { + $error[] = $user->lang['NO_IMAGE']; + } + if ($update && $imgpath) + { + if (!sizeof($error)) + { + // If imgwidth and imgheight are non-zero grab the actual size + // from the image itself ... we ignore width settings for the poll center + // image + $imgwidth = $imgheight = ''; + if ($imgsize) + { + list($imgwidth, $imgheight) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath"); + $imgwidth = ($imgname != 'poll_center') ? " width=\"$imgwidth\"" : ''; + $imgheight = " height=\"$imgheight\""; + } + $imgpath = '"styles/' . $imageset_path . '/imageset/' . preg_replace('#^(.*?)/(.*?)$#', '{LANG}/\2', $imgpath) . '"' . $imgwidth . $imgheight; + + $sql = 'UPDATE ' . STYLES_IMAGE_TABLE . " + SET $imgname = '$imgpath' + WHERE imageset_id = $id"; + $db->sql_query($sql); + + $cache->destroy('sql', STYLES_IMAGE_TABLE); + + add_log('admin', 'LOG_EDIT_IMAGESET', $imageset_name); + $error[] = $user->lang['IMAGESET_UPDATED']; + + $$imgname = $imgpath; + } + } $test_ary = array(); foreach ($imglist as $category => $img_ary) @@ -1238,47 +1283,88 @@ function csspreview() } } } - - unset($matches); unset($test_ary); - - $imgwidth = (preg_match('#width="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; - $imgheight = (preg_match('#height="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0; } // Generate list of image options $img_options = ''; foreach ($imglist as $category => $img_ary) { - $img_options .= ''; + $img_options .= (sizeof($img_ary)) ? '' : ''; foreach ($img_ary as $img) { $selected = ($img == $imgname) ? ' selected="selected"' : ''; - $img_options .= ''; + $img_options .= ''; } } - // Grab list of potential images - $imagesetlist = filelist("{$phpbb_root_path}styles/$imageset_path/imageset"); + // TODO + // Check whether localised buttons exist in admins language first + // Clean up this code + $imglang = ''; + $imagesetlist = array('nolang' => array(), 'lang' => array()); + $dp = opendir("{$phpbb_root_path}styles/$imageset_path/imageset"); + while ($file = readdir($dp)) + { + if (!is_file($file) && !is_link($file) && $file{0} != '.' && strtoupper($file) != 'CVS' && !sizeof($imagesetlist['lang'])) + { + $dp2 = opendir("{$phpbb_root_path}styles/$imageset_path/imageset/$file"); + while ($file2 = readdir($dp2)) + { + $imglang = $file; + if (preg_match('#\.(gif|jpg|png)$#', $file2)) + { + $imagesetlist['lang'][] = "$file/$file2"; + } + } + closedir($dp2); + } + else if (preg_match('#\.(gif|jpg|png)$#', $file)) + { + $imagesetlist['nolang'][] = $file; + } + } + closedir($dp); $imagesetlist_options = ''; - foreach ($imagesetlist as $path => $img_ary) + foreach ($imagesetlist as $type => $img_ary) { + $imagesetlist_options .= ($type == 'lang') ? '' : ''; foreach ($img_ary as $img) { - $img = ((substr($path, 0, 1) == '/') ? substr($path, 1) : $path) . $img; + $imgvalue = preg_replace('#^.*?/(.*?)$#', '\1', $img); + $selected = (strstr($$imgname, $imgvalue)) ? ' selected="selected"' : ''; - $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; - $imagesetlist_options .= ''; + $imagesetlist_options .= ''; } } $imagesetlist_options = '' . $imagesetlist_options; unset($imagesetlist); + $imgsize_no = $imgsize_yes = ''; + if ($imgsize || preg_match('# height="[0-9]+?#', $$imgname)) + { + $imgsize_yes = ' checked="checked"'; + } + else + { + $imgsize_no = ' checked="checked"'; + } + adm_page_header($user->lang['EDIT_IMAGESET']); ?> + +

lang['EDIT_IMAGESET']; ?>

lang['EDIT_IMAGESET_EXPLAIN']; ?>

@@ -1287,27 +1373,58 @@ function csspreview()
"> - +
lang['SELECT_CLASS']; ?>:   lang['SELECT_IMAGE']; ?>:  
+ - + + + + + - - + + - - + + diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index 9a00589a3c..1232f02031 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -191,7 +191,7 @@ $lang += array( 'LOG_ADD_IMAGESET' => 'Added new imageset
» %s', 'LOG_EDIT_IMAGESET' => 'Edited imageset
» %s', - 'LOG_EDIT_IMAGESET_DETAILS' => 'Edited imageset
» %s', + 'LOG_EDIT_IMAGESET_DETAILS' => 'Edited imageset details
» %s', 'LOG_EXPORT_IMAGESET' => 'Exported imageset
» %s', 'LOG_DELETE_IMAGESET' => 'Deleted imageset
» %s', ); @@ -1222,11 +1222,81 @@ $lang += array( 'EDIT_IMAGESET' => 'Edit Imageset', 'EDIT_IMAGESET_EXPLAIN' => 'Here you can edit the individual images which define the imageset. You can also specify dimensions for the image. Dimensions are optional, specifying them can overcome certain rendering issues with some browsers. By not specifying them you reduce the size of the database record a little.', 'SELECTED_IMAGESET' => 'Selected imageset', + 'SELECT_IMAGE' => 'Select image', 'IMAGE' => 'Image', - 'DIMENSIONS' => 'Dimensions', - 'DIMENSIONS_EXPLAIN' => 'Dimensions are optional, set to zero to ignore.', + 'CURRENT_IMAGE' => 'Current Image', + 'SELECTED_IMAGE' => 'Selected Image', + 'DIMENSIONS' => 'Include dimensions', + 'DIMENSIONS_EXPLAIN' => 'Selecting yes here will include width/height parameters.', 'IMAGE_PARAMETER' => 'Parameter', 'IMAGE_VALUE' => 'Value', + 'LOCALISED_IMAGES' => 'Localised', + 'GLOBAL_IMAGES' => 'Global', + 'IMG_CAT_BUTTONS' => 'Localised buttons', + 'IMG_BTN_POST' => 'New topic', + 'IMG_BTN_REPLY' => 'Reply topic', + 'IMG_BTN_LOCKED' => 'Topic locked', + 'IMG_BTN_POST_PM' => 'New message', + 'IMG_BTN_REPLY_PM' => 'Reply message', + 'IMG_BTN_DELETE' => 'Delete post', + 'IMG_BTN_QUOTE' => 'Quote post', + 'IMG_BTN_PROFILE' => 'Show profile', + 'IMG_BTN_EMAIL' => 'Send email', + 'IMG_BTN_SEARCH' => 'Search posts', + 'IMG_BTN_WWW' => 'Website', + 'IMG_BTN_IP' => 'Show IP', + 'IMG_BTN_EDIT' => 'Edit post', + 'IMG_BTN_AIM' => 'AIM', + 'IMG_BTN_ICQ' => 'ICQ', + 'IMG_BTN_JABBER' => 'Jabber', + 'IMG_BTN_YIM' => 'YIM', + 'IMG_BTN_MSNM' => 'MSNM', + 'IMG_BTN_ONLINE' => 'User online', + 'IMG_BTN_OFFLINE' => 'User offline', + 'IMG_BTN_REPORT' => 'Report post', + 'IMG_BTN_PM' => 'Send message', + 'IMG_CAT_ICONS' => 'General icons', + 'IMG_ICON_UNAPPROVED' => 'Post unapproved', + 'IMG_ICON_REPORTED' => 'Post reported', + 'IMG_ICON_ATTACH' => 'Attachment', + 'IMG_ICON_POST' => 'Minipost', + 'IMG_ICON_POST_NEW' => 'New minipost', + 'IMG_ICON_POST_LATEST' => 'Last post', + 'IMG_ICON_POST_NEWEST' => 'Newest post', + 'IMG_CAT_FORUMS' => 'Forum icons', + 'IMG_FORUM' => 'Forum', + 'IMG_FORUM_NEW' => 'Forum new posts', + 'IMG_FORUM_LOCKED' => 'Forum locked', + 'IMG_FORUM_LINK' => 'Forum link', + 'IMG_SUB_FORUM' => 'Subforum', + 'IMG_SUB_FORUM_NEW' => 'Subforum new posts', + 'IMG_CAT_FOLDERS' => 'Topic icons', + 'IMG_FOLDER' => 'Topic', + 'IMG_FOLDER_NEW' => 'Topic new posts', + 'IMG_FOLDER_LOCKED' => 'Topic locked', + 'IMG_FOLDER_POSTED' => 'Topic posted to', + 'IMG_FOLDER_NEW_POSTED' => 'Topic posted to new', + 'IMG_FOLDER_LOCKED_NEW' => 'Topic locked new', + 'IMG_FOLDER_LOCKED_POSTED' => 'Topic locked posted to', + 'IMG_FOLDER_LOCKED_NEW_POSTED' => 'Topic locked posted to new', + 'IMG_FOLDER_HOT' => 'Topic hot', + 'IMG_FOLDER_HOT_NEW' => 'Topic hot new posts', + 'IMG_FOLDER_HOT_POSTED' => 'Topic hot posted to', + 'IMG_FOLDER_HOT_NEW_POSTED' => 'Topic hot posted to new', + 'IMG_FOLDER_STICKY' => 'Sticky topic', + 'IMG_FOLDER_STICKY_POSTED' => 'Sticky topic posted to', + 'IMG_FOLDER_STICKY_NEW' => 'Sticky topic new posts', + 'IMG_FOLDER_STICKY_NEW_POSTED' => 'Sticky topic posted to new', + 'IMG_FOLDER_ANNOUNCE' => 'Announcement', + 'IMG_FOLDER_ANNOUNCE_NEW' => 'Announcement new posts', + 'IMG_FOLDER_ANNOUNCE_POSTED' => 'Announcement posted to', + 'IMG_FOLDER_ANNOUNCE_NEW_POSTED' => 'Announcement posted to new', + 'IMG_CAT_POLLS' => 'Polling images', + 'IMG_POLL_LEFT' => 'Poll left end', + 'IMG_POLL_RIGHT' => 'Poll right end', + 'IMG_POLL_CENTER' => 'Poll centre', + 'IMG_CAT_CUSTOM' => 'Custom images', + 'IMAGESET_UPDATED' => 'Imageset updated successfully', 'EDIT_DETAILS_IMAGESET' => 'Edit imageset details', 'EDIT_DETAILS_IMAGESET_EXPLAIN'=> 'Here you can edit certain imageset details such as its name.',
lang['EDIT_IMAGESET']; ?>
img_lang, $$imgname)) . ' vspace="5" />' : ''; ?>' . implode('
', $error) . '' : implode('
', $error); ?>
+ + + + + + + + +
" />" name="newimg" />
lang['CURRENT_IMAGE']; ?>lang['SELECTED_IMAGE']; ?>
lang['IMAGE_PARAMETER']; ?> lang['IMAGE_VALUE']; ?>
lang['IMAGE']; ?>:lang['IMAGE']; ?>:
lang['DIMENSIONS']; ?>:
lang['DIMENSIONS_EXPLAIN']; ?>
X lang['DIMENSIONS']; ?>:
lang['DIMENSIONS_EXPLAIN']; ?>
/> lang['YES']; ?>   /> lang['NO']; ?>