From 30afda900cc74730fc8cf32912ba054a75e9dfb0 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Fri, 11 Jul 2003 15:46:22 +0000 Subject: okay, after some conflicting advice :D and some jiggling here's the latest theme related update ... this stuff is enough to drive you batty git-svn-id: file:///svn/phpbb/trunk@4219 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 614 ++++++++++++++++++++++++++++++--------------- 1 file changed, 416 insertions(+), 198 deletions(-) (limited to 'phpBB/adm') 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) + - - - - - + - - - +

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.

+ +
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:
+ + - - + + - - + -
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 -- cgit v1.2.1