diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 513921b1cd..48add918fe 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -1,8 +1,8 @@ acl_get('a_styles') ) + if (!$auth->acl_get('a_styles')) { return; } @@ -37,7 +37,156 @@ $action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : switch ($mode) { - case 'editimageset': + + case 'styles': + + $style_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : ''; + + switch ($action) + { + case 'preview': + break; + + case 'edit': + + if (isset($_POST['update'])) + { + } + + if ($style_id) + { + $sql = 'SELECT * + FROM ' . STYLES_TABLE . " + WHERE style_id = $style_id"; + $result = $db->sql_query($sql); + + if ($style_data = $db->sql_fetchrow($result)) + { + } + $db->sql_freeresult($result); + } + + $style_options = array(); + $field_ary = array(STYLES_CSS_TABLE => 'theme', STYLES_TPL_TABLE => 'template', STYLES_IMAGE_TABLE => 'imageset'); + foreach ($field_ary as $table => $field) + { + $sql = "SELECT {$field}_id, {$field}_name + FROM $table + ORDER BY {$field}_id"; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $selected = ($row[$field . '_id'] == $style_data[$field . '_id']) ? ' selected="selected"' : ''; + ${$field . '_options'} .= ''; + } + $db->sql_freeresult($result); + } + + + // Output the page + adm_page_header($user->lang['EDIT_STYLE']); + +?> + +
lang['EDIT_STYLE_EXPLAIN']; ?>
+ +Selected Style:
+ + + +lang['EDIT_STYLE']); + +?> +lang['EDIT_STYLE_EXPLAIN']; ?>
+ + +&mode=editimageset"> -Template set:
+Template set:
Here you can create, edit, delete and download imagesets.
@@ -116,7 +265,7 @@ switch ($mode)lang['Edit_template_explain']; ?>
@@ -243,9 +392,9 @@ switch ($mode)Template: | +Template: | -Columns: Rows: | +Columns: Rows: |
lang['Edit_template_explain']; ?>
@@ -336,23 +485,46 @@ switch ($mode) case 'themes': - $theme_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : ''; - switch ($action) { case 'preview': - break; case 'edit': + // General parameters + $theme_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : ''; + $class = (isset($_POST['classname'])) ? htmlspecialchars($_POST['classname']) : ''; + + $txtcols = (isset($_POST['txtcols'])) ? max(40, intval($_POST['txtcols'])) : 76; + $txtrows = (isset($_POST['txtrows'])) ? max(5, intval($_POST['txtrows'])) : 10; + $showcss = (!empty($_POST['showcss'])) ? true : ((!empty($_POST['hidecss'])) ? false : ((!empty($_GET['showcss'])) ? true : false)); + + // List of default classes, categorised + $base_classes = array( + 'text' => array( + 'body', 'p', 'a', 'h1', 'h2', 'h3', 'tabletitle', 'cattitle', 'topictitle', 'topicauthor', 'topicdetails', 'postdetails', 'postbody', 'posthilit', 'postauthor', 'genmed', 'gensmall', 'copyright', + ), + 'tables' => array( + 'table', 'th', 'cat', 'catdiv', 'td', 'row1', 'row2', 'row3', 'spacer', 'hr', + ), + 'forms' => array( + 'form', 'input', 'select', 'textarea', 'post', 'btnlite', 'btnmain', 'btnbbcode', + ), + 'bbcode' => array( + 'b', 'u', 'i', 'color', 'size', 'code', 'quote', 'flash', 'syntaxbg', 'syntaxcomment', 'syntaxdefault', 'syntaxhtml', 'syntaxkeyword', 'syntaxstring', + ), + 'custom' => array(), + ); + + + // We want to submit the updates if (isset($_POST['update'])) { } - - $class = (isset($_POST['classname'])) ? htmlspecialchars($_POST['classname']) : ''; - + + // Do we want to edit an existing theme? if ($theme_id) { $sql = 'SELECT * @@ -360,141 +532,66 @@ switch ($mode) WHERE theme_id = $theme_id"; $result = $db->sql_query($sql); - if ($theme_data = $db->sql_fetchrow($result)) + if (!(extract($db->sql_fetchrow($result)))) { + trigger_error($user->lang['NO_THEME']); } $db->sql_freeresult($result); - } + - $user->lang = array_merge($user->lang, array( - 'SELECT_CLASS' => 'Select class', - - 'style_cat_text' => 'Text classes', - 'style_body' => 'Body', - 'style_p' => 'Paragraphs', - 'style_h1' => 'Header 1', - 'style_h2' => 'Header 2', - 'style_h3' => 'Header 3', - - 'style_postdetails' => 'Post Information', - 'style_postbody' => 'Post Text', - 'style_postauthor' => 'Post Author', - - 'style_topictitle' => 'Topic titles', - 'style_topicauthor' => 'Topic Author', - 'style_topicdetails' => 'Topic Details', - - 'style_gen' => 'General Text', - 'style_genmed' => 'Medium Text', - 'style_gensmall' => 'Small Text', - - 'style_copyright' => 'Copyright Text', - - - 'style_cat_tables' => 'Table classes', - 'style_cat' => 'Category Header Cell', - 'style_cattitle' => 'Category Header Text', - 'style_th' => 'Table Header Cell', - 'style_td' => 'Table Data Cell', - - 'style_cat_bbcode' => 'BBCode classes', - 'style_b' => 'Bold', - 'style_u' => 'Underline', - 'style_i' => 'Italics', - 'style_color' => 'Colour', - 'style_size' => 'Size', - 'style_code' => 'Code', - 'style_quote' => 'Quote', - 'style_flash' => 'Flash', - 'style_syntaxbg' => 'Syntax Background', - 'style_syntaxcomment' => 'Syntax Comments', - 'style_syntaxdefault' => 'Syntax Default', - 'style_syntaxhtml' => 'Syntax HTML', - 'style_syntaxkeyword' => 'Syntax Keyword', - 'style_syntaxstring' => 'Syntax String', - - )); - - $base_classes = array( - 'text' => array( - 'body', - 'p', - 'h1', - 'h2', - 'h3', - 'gen', - 'genmed', - 'gensmall', - 'topictitle', - 'topicauthor', - 'topicdetails', - 'postdetails', - 'postbody', - 'postauthor', - 'copyright' - ), - 'tables' => array( - 'th', - 'td', - 'cat', - 'cattitle', - ), - 'bbcode' => array( - 'b', - 'u', - 'i', - 'color', - 'size', - 'code', - 'quote', - 'flash', - 'syntaxbg', - 'syntaxcomment', - 'syntaxdefault', - 'syntaxhtml', - 'syntaxkeyword', - 'syntaxstring', - ) - ); - - $class_options = ''; - foreach ($base_classes as $category => $class_ary) - { - $class_options .= ''; - foreach ($class_ary as $class_name) - { - $selected = ($class_name == $class) ? ' selected="selected"' : ''; - $class_options .= ''; - } - } - - if (!empty($class)) - { - //TEMP - if (!($fp = fopen($phpbb_root_path . 'templates/' . $theme_data['css_external'], 'rb'))) + // Grab template data + if (!($fp = fopen($phpbb_root_path . 'styles/themes/' . $css_external, 'rb'))) { die("ERROR"); } - $stylesheet = fread($fp, filesize($phpbb_root_path . 'templates/' . $theme_data['css_external'])); + $stylesheet = fread($fp, filesize($phpbb_root_path . 'styles/themes/' . $css_external)); fclose($fp); $stylesheet = str_replace(array("\t", "\n"), " ", $stylesheet); + // Pull out list of "custom" tags + if (preg_match_all('#([a-z\.:]+?) {.*?}#si', $stylesheet, $matches)) + { + $test_ary = array(); + foreach ($base_classes as $category => $class_ary) + { + $test_ary = array_merge($test_ary, $class_ary); + } + + $matches = preg_replace('#^\.#', '', $matches[1]); + foreach ($matches as $value) + { + if (!in_array($value, $test_ary)) + { + $base_classes['custom'][] = $value; + } + } + unset($matches); + unset($test_ary); + } + } + + + // Do we have a class set? If so, we need to extract and set the relevant data + if (!empty($class)) + { + // Here we pull out the appropriate class entry then proceed to pull it apart, + // setting appropriate variables to their respective values. We only match + // certain css elements, the rest are "hidden" and can be accessed by exposing + // the raw css if (preg_match('#^.*?' . $class . ' {(.*?)}#m', $stylesheet, $matches)) { - $stylesheet = &$matches[1]; + $css_element = &$matches[1]; + // We categorise the elements which comprise the css class so that we set + // any appropriate additional data, e.g. sizes require the scale type to be set, + // images require the relevant image be pulled and selected in the dropdown, etc. $match_elements = array( - 'colors' => array('background-color', 'color', 'border-color', - ), - 'sizes' => array('font-size', 'line-height', 'border-width', - ), - 'images' => array('background-image', - ), - 'repeat' => array('background-repeat', - ), - 'other' => array('font-weight', 'font-family', 'font-style', 'text-decoration', 'border-style', - ), + 'colors' => array('background-color', 'color',), + 'sizes' => array('font-size', 'line-height',), + 'images' => array('background-image',), + 'repeat' => array('background-repeat',), + 'other' => array('font-weight', 'font-family', 'font-style', 'text-decoration',), ); foreach ($match_elements as $type => $match_ary) @@ -504,7 +601,7 @@ switch ($mode) $$match = ''; $var = str_replace('-', '', $match); - if (preg_match('#\b' . $match . ': (.*?);#s', $stylesheet, $matches)) + if (preg_match('# ' . $match . ': (.*?);#s', $css_element, $matches)) { switch ($type) { @@ -525,6 +622,7 @@ switch ($mode) { $$var = trim($matches[1]); } + $$var = str_replace('./', $theme_data['theme_name'] . '/', $$var); break; case 'repeat': @@ -539,19 +637,35 @@ switch ($mode) } } } + // End of class element variable setting + + + // Generate list of class options + $class_options = ''; + foreach ($base_classes as $category => $class_ary) + { + $class_options .= ''; + foreach ($class_ary as $class_name) + { + $selected = ($class_name == $class) ? ' selected="selected"' : ''; + $class_options .= ''; + } + } + // Grab list of potential images for class backgrounds - $imglist = filelist($phpbb_root_path . 'templates'); + $imglist = filelist($phpbb_root_path . 'styles/themes'); $bg_imglist = ''; foreach ($imglist as $img) { $img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file']; - $selected = (preg_match('#templates/' . preg_quote($img) . '#', $backgroundimage)) ? ' selected="selected"' : ''; + $selected = (preg_match('#' . preg_quote($img) . '#', $backgroundimage)) ? ' selected="selected"' : ''; $bg_imglist .= ''; } $bg_imglist = '' . $bg_imglist; + unset($imglist); // Output the page @@ -572,22 +686,51 @@ function swatch(field) -lang['Edit_theme_explain']; ?>
+lang['EDIT_THEME_EXPLAIN']; ?>
-Selected Theme:
- - - lang['EDIT_THEME']); ?> -lang['Edit_theme_explain']; ?>
- -Selected Theme: subSilver
+lang['THEMES_EXPLAIN']; ?>
"> | -">Recreate | ">Delete | ">Export | ">Preview | +">Recache | ">Delete | ">Export | ">Preview | |
+ | Create new theme: |
However, if the tables get out of sync for some reason or you change the minimum, maximum or disallowed list of words the tables need updating. This facility allows you to do just that.
Please be aware this procedure can take a long time, particularly on large databases. During this period your forum will be automatically shut down to prevent people posting. You can cancel the procedure at any time. Please remember this is an intensive operation and should only be carried out when absolutely necessarily. Do not run this script too often!
', 'SEARCH_INDEX_CANCEL' => 'Re-indexing of search system has been cancelled. Please note this will result in searches returning incomplete results. You can re-index the posts again at any stage.', 'SEARCH_INDEXING_COMPLETE' => 'Re-indexing of search system has been completed. You can re-index the posts again at any stage.',