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']; ?>

+ +

lang['EDIT_STYLE_EXPLAIN']; ?>

+ +

Selected Style:

+ +
"> + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  
Style Name
Template set:
Theme set:
Imageset:
Active:
    
+ +lang['EDIT_STYLE']); + +?> +

lang['EDIT_STYLE']; ?>

+ +

lang['EDIT_STYLE_EXPLAIN']; ?>

+ +
"> + + + + +sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + +?> + + + + +sql_fetchrow($result)); + } + else + { + } + $db->sql_freeresult($result); + + +?> + + + +
Style name 
"> ">Deactivate | ">Delete | ">Export | ">Preview 
 
+&mode=editimageset"> -

Edit Imageset

+

Edit Imageset

-

Template set:    

+

Template set:    

Here you can create, edit, delete and download imagesets.

@@ -116,7 +265,7 @@ switch ($mode) -   +   - + @@ -152,8 +301,8 @@ switch ($mode) case 'edit': - $tplcols = (isset($_POST['tplcols'])) ? max(60, intval($_POST['tplcols'])) : 76; - $tplrows = (isset($_POST['tplrows'])) ? max(4, intval($_POST['tplrows'])) : 30; + $tplcols = (isset($_POST['tplcols'])) ? max(76, intval($_POST['tplcols'])) : 76; + $tplrows = (isset($_POST['tplrows'])) ? max(30, intval($_POST['tplrows'])) : 30; $tplname = (isset($_POST['tplname'])) ? $_POST['tplname'] : ''; $tplroot = (isset($_POST['tplroot'])) ? $_POST['tplroot'] : 'subSilver'; @@ -235,7 +384,7 @@ switch ($mode) ?> -

lang['Edit_template']; ?>

+

lang['Edit_template']; ?>

lang['Edit_template_explain']; ?>

@@ -243,9 +392,9 @@ switch ($mode) - + - +
 Template:    Template:   Columns:  Rows:    Columns:  Rows:    
@@ -253,7 +402,7 @@ switch ($mode) -     +     @@ -275,7 +424,7 @@ switch ($mode) adm_page_header($user->lang['EDIT_TEMPLATE']); ?> -

lang['Edit_template']; ?>

+

lang['Edit_template']; ?>

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']; ?>

+

lang['EDIT_THEME']; ?>

-

lang['Edit_theme_explain']; ?>

+

lang['EDIT_THEME_EXPLAIN']; ?>

-

Selected Theme:

- -
"> +">
- + +
lang['SELECT_CLASS']; ?>:   lang['SELECT_CLASS']; ?>:  
+ + + + + + + + + + + + + + + + + + + + @@ -603,15 +746,17 @@ function swatch(field) + + - + @@ -625,10 +770,10 @@ function swatch(field) @@ -648,53 +793,59 @@ function swatch(field) - - - - - - - - - - + } + +?> + + + +
Columns:  Rows:    
Raw CSS
Theme name:
Parameter Value
Theme name:
Background
Repeat background:
TextForeground
Color:
This is a hex-triplet of the form RRGGBB
Web-safe Colour Swatch
Size:
Line spacing:
Borders
Color:
This is a hex-triplet of the form RRGGBB
Web-safe Colour Swatch
 
Width:
      
+ + +

Custom Class

+ +

You can add additional classes to this theme if you wish. You must provide the actual CSS class name below, it must be the same as that you have or will use in your template. Please remember that class names may contain only alphanumeric characters, periods (.), colons (:) and number/hash/pound (#). The new class will be added to the Custom Class category in the select box above.

+ + + + - - + + - - + -
Add Custom Class
Style:CSS class name:
      
+ +
- lang['EDIT_THEME']); ?> -

lang['Edit_theme']; ?>

+

lang['THEMES']; ?>

-

lang['Edit_theme_explain']; ?>

- -

Selected Theme: subSilver

+

lang['THEMES_EXPLAIN']; ?>

"> @@ -736,7 +887,7 @@ function swatch(field) ?> - + - +
"> ">Recreate | ">Delete | ">Export | ">Preview  ">Recache | ">Delete | ">Export | ">Preview 
 Create new theme:
@@ -768,4 +919,71 @@ function swatch(field) } + +// --------- +// FUNCTIONS +// +class template_admin extends template +{ + function compile_cache_clear($template = false) + { + global $phpbb_root_path; + + $template_list = array(); + + if (!$template) + { + $dp = opendir($phpbb_root_path . $this->cache_root); + while ($dir = readdir($dp)) + { + $template_dir = $phpbb_root_path . $this->cache_root . $dir; + if (!is_file($template_dir) && !is_link($template_dir) && $dir != '.' && $dir != '..') + { + array_push($template_list, $dir); + } + } + closedir($dp); + } + else + { + array_push($template_list, $template); + } + + foreach ($template_list as $template) + { + $dp = opendir($phpbb_root_path . $this->cache_root . $template); + while ($file = readdir($dp)) + { + unlink($phpbb_root_path . $this->cache_root . $file); + } + closedir($dp); + } + + return; + } + + function compile_cache_show($template) + { + global $phpbb_root_path; + + $template_cache = array(); + + $template_dir = $phpbb_root_path . $this->cache_root . $template; + $dp = opendir($template_dir); + while ($file = readdir($dp)) + { + if (preg_match('#\.html$#i', $file) && is_file($template_dir . '/' . $file)) + { + array_push($template_cache, $file); + } + } + closedir($dp); + + return; + } +} +// +// FUNCTIONS +// --------- + ?> \ No newline at end of file diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index 180a4c6460..0b63e84e57 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -893,6 +893,80 @@ $lang = array_merge($lang, array( 'Disallowed_already' => 'The name you entered could not be disallowed. It either already exists in the list, exists in the word censor list, or a matching username is present', + 'THEMES' => 'Themes', + 'THEMES_EXPLAIN' => 'From here you can add, edit, delete and export themes. A theme is the combination of colours and images that are applied to your templates to define the basic look of your forum. To manage templates, imagesets or styles please see the navigation menu.', + + 'EDIT_THEME' => 'Edit Theme', + 'EDIT_THEME_EXPLAIN' => 'Here you can edit the selected theme, changing colours, images, etc. You can switch between a simplified interface where you can set basic colours, etc. and a more advanced "raw CSS" mode. Using the raw mode you can style additional CSS elements such as borders, etc. You only need set the parameters you need, e.g. if you do not want a background image leave that parameter unset. You may also add additional "custom" classes should your template or style make use of them.', + 'SELECT_CLASS' => 'Select class', + 'SHOW_RAW_CSS' => 'Show CSS', + 'HIDE_RAW_CSS' => 'Hide CSS', + + 'style_cat_text' => 'Text Classes', + 'style_body' => 'Body', + 'style_p' => 'Paragraph', + 'style_h1' => 'Header 1', + 'style_h2' => 'Header 2', + 'style_h3' => 'Header 3', + 'style_tabletitle' => 'Table Title', + 'style_cattitle' => 'Category Title', + 'style_topictitle' => 'Topic Titles', + 'style_topicauthor' => 'Topic Author', + 'style_topicdetails' => 'Topic Details', + 'style_postbody' => 'Post Text', + 'style_posthilit' => 'Post Highlight Text', + 'style_postauthor' => 'Post Author', + 'style_postdetails' => 'Post Details', + 'style_a' => 'General Anchor', + 'style_genmed' => 'General Text', + 'style_gensmall' => 'Small Text', + 'style_copyright' => 'Copyright Text', + + 'style_cat_tables' => 'Tabular Classes', + 'style_table' => 'Table', + 'style_th' => 'Table Header', + 'style_td' => 'Table Data', + 'style_cat' => 'Category Header', + 'style_catdiv' => 'Category Fade', + 'style_row1' => 'Alternate Row 1', + 'style_row2' => 'Alternate Row 2', + 'style_row3' => 'Alternate Row 3', + 'style_spacer' => 'Spacer Row', + 'style_hr' => 'Horizontal Rule', + + 'style_cat_forms' => 'Form Classes', + 'style_form' => 'Form', + 'style_input' => 'Input', + 'style_select' => 'Select', + 'style_textarea' => 'Textarea', + 'style_post' => 'Text Input', + 'style_btnmain' => 'Primary Buttons', + 'style_btnlite' => 'Secondary Buttons', + 'style_button' => 'BBCode Buttons', + + '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', + + 'STYLE_ANCHOR_LINK' => 'Link', + 'STYLE_ANCHOR_ACTIVE' => 'Active', + 'STYLE_ANCHOR_VISITED' => 'Visited', + 'STYLE_ANCHOR_HOVER' => 'Hover', + + + 'Edit_style' => 'Edit Styles', 'Style' => 'Style', 'Styles_admin' => 'Styles Administration', @@ -903,7 +977,7 @@ $lang = array_merge($lang, array( 'Template' => 'Select template', 'Download' => 'Download', 'Edit_theme' => 'Edit Theme', - 'Edit_theme_explain' => 'Use this panel to edit an existing theme. Each editable class can be selected individually. Set only the parameters you need, e.g. if you do not want a border leave the border parameters blank.', + 'Edit_theme_explain' => 'Use this panel to edit an existing theme. Each editable class can be selected individually. ', 'Select_theme' => 'Select theme', 'CSS_data' => 'CSS Data', 'CSS_data_explain' => 'This CSS is output to the template and may be included within the header of each page.', @@ -930,6 +1004,9 @@ $lang = array_merge($lang, array( 'Save_Settings' => 'Save Settings', + + + 'SEARCH_INDEX_EXPLAIN' => 'phpBB2 uses a fulltext search system. This breaks down each post into seperate words and then, if the word does not already exist it stores those words in a table. In turn the post is linked to each word it contains in this table. This allows quick searching of large databases and helps reduce load on the server compared to most other methods.

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.',