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_EXPLAIN']; ?>
@@ -1287,27 +1373,58 @@ function csspreview()