From 99910d51cb6534b660a4f065b0882bc1773a86ba Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 5 Jun 2003 20:27:43 +0000 Subject: [PATCH] A little more thinking out loud ... regular users are welcome to give feedback via area51 git-svn-id: file:///svn/phpbb/trunk@4088 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 683 ++++++++++++++++++++++--------------- 1 file changed, 413 insertions(+), 270 deletions(-) diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 7fbf6a9e0d..953052f207 100644 --- a/phpBB/adm/admin_styles.php +++ b/phpBB/adm/admin_styles.php @@ -8,10 +8,10 @@ if ( !empty($setmodules) ) } $filename = basename(__FILE__); - $module['STYLE']['EDIT_STYLE'] = $filename . "$SID&mode=newstyle"; - $module['STYLE']['EDIT_TEMPLATE'] = $filename . "$SID&mode=edittemplate"; - $module['STYLE']['EDIT_THEME'] = $filename . "$SID&mode=edittheme"; - $module['STYLE']['EDIT_IMAGESET'] = $filename . "$SID&mode=editimageset"; + $module['STYLE']['EDIT_STYLE'] = $filename . "$SID&mode=styles"; + $module['STYLE']['EDIT_TEMPLATE'] = $filename . "$SID&mode=templates"; + $module['STYLE']['EDIT_THEME'] = $filename . "$SID&mode=themes"; + $module['STYLE']['EDIT_IMAGESET'] = $filename . "$SID&mode=imagesets"; return; } @@ -30,6 +30,7 @@ if (!$auth->acl_get('a_styles')) // $mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; +$action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : ''; @@ -135,88 +136,102 @@ switch ($mode) break; - case 'edittemplate': - $tplcols = (isset($_POST['tplcols'])) ? max(60, intval($_POST['tplcols'])) : 90; - $tplrows = (isset($_POST['tplrows'])) ? max(4, intval($_POST['tplrows'])) : 30; - $tplname = (isset($_POST['tplname'])) ? $_POST['tplname'] : ''; - $tplroot = (isset($_POST['tplroot'])) ? $_POST['tplroot'] : 'subSilver'; - $str = ''; - if (isset($_POST['tpl_compile']) && !empty($_POST['decompile'])) + + + case 'templates': + + $template_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : ''; + + switch ($action) { - $str = "compile(stripslashes($_POST['decompile'])) . "\n?".">"; + case 'preview': - $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); - fwrite ($fp, $str); - fclose($fp); + break; - @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); + case 'edit': - add_log('admin', 'log_template_edit', $tplname, $tplroot); + $tplcols = (isset($_POST['tplcols'])) ? max(60, intval($_POST['tplcols'])) : 76; + $tplrows = (isset($_POST['tplrows'])) ? max(4, intval($_POST['tplrows'])) : 30; + $tplname = (isset($_POST['tplname'])) ? $_POST['tplname'] : ''; + $tplroot = (isset($_POST['tplroot'])) ? $_POST['tplroot'] : 'subSilver'; - exit; - } - else if (!empty($tplname) && isset($_POST['tpl_name'])) - { - $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); - while (!feof($fp)) - { - $str .= fread($fp, 4096); - } - @fclose($fp); + $str = ''; + if (isset($_POST['tpl_compile']) && !empty($_POST['decompile'])) + { + $str = "compile(stripslashes($_POST['decompile'])) . "\n?".">"; - $match_preg = array( - '#\$this\->_tpl_include\(\'(.*?)\'\);#', - '#echo \$this->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\];#', - '#echo \(\(isset\(\$this\->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\]\)\).*?;#', - '#if \(.*?\[\'\.\'\]\[0\]\[\'(.*?)\'\]\) \{ #', - '#\$_(.*?)_count.*?;if \(.*?\)\{#', - ); + $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); + fwrite ($fp, $str); + fclose($fp); - $replace_preg = array( - '', - '{$1}', - '{$1}', - '', - '', - ); + @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); - $str = preg_replace($match_preg, $replace_preg, $str); - $str = str_replace('', '', $str); - } - else - { - $str = (!empty($_POST['decompile'])) ? stripslashes($_POST['decompile']) : ''; - } + add_log('admin', 'log_template_edit', $tplname, $tplroot); - if (isset($_POST['tpl_download'])) - { - header("Content-Type: text/html; name=\"" . $tplname . ".html\""); - header("Content-disposition: attachment; filename=" . $tplname . ".html"); - echo $str; - exit; + exit; + } + else if (!empty($tplname) && isset($_POST['tpl_name'])) + { + $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); + while (!feof($fp)) + { + $str .= fread($fp, 4096); + } + @fclose($fp); - } + $match_preg = array( + '#\$this\->_tpl_include\(\'(.*?)\'\);#', + '#echo \$this->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\];#', + '#echo \(\(isset\(\$this\->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\]\)\).*?;#', + '#if \(.*?\[\'\.\'\]\[0\]\[\'(.*?)\'\]\) \{ #', + '#\$_(.*?)_count.*?;if \(.*?\)\{#', + ); - $tplroot_options = get_templates($tplroot); + $replace_preg = array( + '', + '{$1}', + '{$1}', + '', + '', + ); - $tplname_options = ''; - $dp = @opendir($phpbb_root_path . 'cache/templates/' . $tplroot . '/'); - while ($file = readdir($dp)) - { - if (strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $file)) - { - $tpl = substr($file, 0, strpos($file, '.')); - $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; - $tplname_options .= ''; - } - } - closedir($dp); + $str = preg_replace($match_preg, $replace_preg, $str); + $str = str_replace('', '', $str); + } + else + { + $str = (!empty($_POST['decompile'])) ? stripslashes($_POST['decompile']) : ''; + } - // - adm_page_header($user->lang['Edit_template']); + if (isset($_POST['tpl_download'])) + { + header("Content-Type: text/html; name=\"" . $tplname . ".html\""); + header("Content-disposition: attachment; filename=" . $tplname . ".html"); + echo $str; + exit; + + } + +// $tplroot_options = get_templates($tplroot); + + $tplname_options = ''; + $dp = @opendir($phpbb_root_path . 'cache/templates/' . $tplroot . '/'); + while ($file = readdir($dp)) + { + if (strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $file)) + { + $tpl = substr($file, 0, strpos($file, '.')); + $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; + $tplname_options .= ''; + } + } + closedir($dp); + + // + adm_page_header($user->lang['Edit_template']); ?> @@ -224,11 +239,7 @@ switch ($mode)

lang['Edit_template_explain']; ?>

-
"> - -

lang['Select_template']; ?>:  

- - +">
@@ -248,206 +259,62 @@ switch ($mode) sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $theme_name = $row['theme_name']; - - $css_data = (!empty($_POST['css_data'])) ? htmlentities($_POST['css_data']) : ''; - $css_external = (!empty($_POST['css_data'])) ? $_POST['css_data'] : ''; - - $sql = "UPDATE " > STYLES_CSS_TABLE . " - SET css_data = '$css_data', css_external = '$css_external' - WHERE theme_id = $theme_id"; - $db->sql_query($sql); - - add_log('admin', 'log_theme_edit', $theme_name); - - message_die(MESSAGE, $user->lang['Success_theme_update']); - } + case 'export': + break; } - adm_page_header($user->lang['Edit_theme']); + adm_page_header($user->lang['EDIT_TEMPLATE']); - $sql = "SELECT theme_id, theme_name - FROM " . STYLES_CSS_TABLE; +?> +

lang['Edit_template']; ?>

+ +

lang['Edit_template_explain']; ?>

+ +">
+ + + + +sql_query($sql); - $theme_options = ''; if ($row = $db->sql_fetchrow($result)) { do { - $theme_options .= (($theme_options != '') ? ', ' : '') . ''; + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + +?> + + + + +sql_fetchrow($result)); } + else + { + } $db->sql_freeresult($result); - $css_data = ''; - $css_external = ''; - if ($theme_id) - { - $sql = "SELECT css_data, css_external - FROM " . STYLES_CSS_TABLE . " - WHERE theme_id = $theme_id"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $css_data = preg_replace('/\t{1,}/i', ' ', $row['css_data']); - $css_external = $row['css_external']; - } - } - - $user->lang = array_merge($user->lang, array( - 'SELECT_CLASS' => 'Select class', - 'style_body' => 'Body', - 'style_p' => 'Paragraphs', - 'style_th' => 'Table Header Cell', - 'style_td' => 'Table Data Cell', - 'style_postdetails' => 'Post Information', - 'style_postbody' => 'Post text', - 'style_gen' => 'General Text', - 'style_genmed' => 'Medium Text', - 'style_gensmall' => 'Small Text', - 'style_copyright' => 'Copyright Text', - - )); - - $base_classes = array( - 'body', - 'p', - 'th', - 'td', - 'postdetails', - 'postbody', - 'gen', - 'gensmall', - 'copyright' - ); - - $class_options = ''; - foreach ($base_classes as $class) - { - $class_options .= ''; - } - - - $imglist = filelist($phpbb_root_path . 'templates'); - - $bg_imglist = ''; - foreach ($imglist as $img) - { - $img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file']; - -// $selected = ' selected="selected"'; - $bg_imglist .= ''; - } - $bg_imglist = '' . $bg_imglist; - ?> - - - -

lang['Edit_theme']; ?>

- -

lang['Edit_theme_explain']; ?>

- -">
Template name 
"> ">BBCode | ">Delete | ">Export | ">Preview 
- - - - +
lang['SELECT_CLASS']; ?>:  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterValue
Background image:
Repeat background:
Background color: [ Web-safe Colour Swatch ]
Foreground color: [ Web-safe Colour Swatch ]
Font:
Font size:
Font Bold: lang['YES']; ?>   lang['NO']; ?>
Font Italic: lang['YES']; ?>   lang['NO']; ?>
Font Underline: lang['YES']; ?>   lang['NO']; ?>
Line spacing:
  
 
@@ -465,27 +332,303 @@ function swatch(field) + case 'themes': + + $theme_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : ''; + + switch ($action) + { + case 'preview': + + break; + + case 'edit': + + if (isset($_POST['update'])) + { + } + + + $class = (isset($_POST['classname'])) ? htmlspecialchars($_POST['classname']) : ''; + + if ($theme_id) + { + $sql = 'SELECT * + FROM ' . STYLES_CSS_TABLE . " + WHERE theme_id = $theme_id"; + $result = $db->sql_query($sql); + + if ($theme_data = $db->sql_fetchrow($result)) + { + } + $db->sql_freeresult($result); + } + + $user->lang = array_merge($user->lang, array( + 'SELECT_CLASS' => 'Select class', + + 'style_cat_general' => 'General classes', + 'style_cat_bbcode' => 'BBCode classes', + 'style_body' => 'Body', + 'style_p' => 'Paragraphs', + 'style_th' => 'Table Header Cell', + 'style_td' => 'Table Data Cell', + 'style_postdetails' => 'Post Information', + 'style_postbody' => 'Post text', + 'style_gen' => 'General Text', + 'style_genmed' => 'Medium Text', + 'style_gensmall' => 'Small Text', + 'style_copyright' => 'Copyright Text', + + '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( + 'general' => array( + 'body', + 'p', + 'th', + 'td', + 'postdetails', + 'postbody', + 'gen', + 'gensmall', + 'copyright' + ), + '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 .= ''; + } + } + + // Grab list of potential images for class backgrounds + $imglist = filelist($phpbb_root_path . 'templates'); + + $bg_imglist = ''; + foreach ($imglist as $img) + { + $img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file']; + + // $selected = ' selected="selected"'; + $bg_imglist .= ''; + } + $bg_imglist = '' . $bg_imglist; + + + // Output the page + adm_page_header($user->lang['EDIT_THEME']); + +?> + + + + +

lang['Edit_theme']; ?>

+ +

lang['Edit_theme_explain']; ?>

+ +

Selected Theme:

+ +
"> + + + + + + +
lang['SELECT_CLASS']; ?>:  
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterValue
Background
Color:
This is a hex-triplet of the form RRGGBB
[ Web-safe Colour Swatch ]
Image:
Repeat background:
Text
Color:
This is a hex-triplet of the form RRGGBB
[ Web-safe Colour Swatch ]
Font:
You can specify multiple fonts seperated by commas
Size:
Bold: lang['YES']; ?>   lang['NO']; ?>
Italic: lang['YES']; ?>   lang['NO']; ?>
Underline: lang['YES']; ?>   lang['NO']; ?>
Line spacing:
Borders
Color:
This is a hex-triplet of the form RRGGBB
[ Web-safe Colour Swatch ]
Width:
Style:
    
+ +lang['EDIT_THEME']); + +?> +

lang['Edit_theme']; ?>

+ +

lang['Edit_theme_explain']; ?>

+ +

Selected Theme: subSilver

+ +
"> + + + + +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); + + +?> + + + +
Theme name 
"> ">Recreate | ">Delete | ">Export | ">Preview 
 
+ +sql_query($sql); - $tplroot_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($tplroot == $row['template_path']) ? ' selected="selected"' : ''; - $tplroot_options .= ''; - } - return $tplroot_options; } ?> \ No newline at end of file