From daabc84e082ae687af12095bfa0bb1335f0407c7 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Sat, 12 Jul 2003 20:55:38 +0000 Subject: And an ittle bit more, just a weeny bit ... git-svn-id: file:///svn/phpbb/trunk@4226 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_styles.php | 528 +++++++++++++++++++++++++++++++-------------- 1 file changed, 364 insertions(+), 164 deletions(-) (limited to 'phpBB/adm/admin_styles.php') diff --git a/phpBB/adm/admin_styles.php b/phpBB/adm/admin_styles.php index 48add918fe..bedc705daa 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=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"; + $module['STYLE']['MANAGE_STYLE'] = $filename . "$SID&mode=styles"; + $module['STYLE']['MANAGE_TEMPLATE'] = $filename . "$SID&mode=templates"; + $module['STYLE']['MANAGE_THEME'] = $filename . "$SID&mode=themes"; + $module['STYLE']['MANAGE_IMAGESET'] = $filename . "$SID&mode=imagesets"; return; } @@ -136,12 +136,12 @@ switch ($mode) break; } - adm_page_header($user->lang['EDIT_STYLE']); + adm_page_header($user->lang['MANAGE_STYLE']); ?> -

lang['EDIT_STYLE']; ?>

+

lang['MANAGE_STYLE']; ?>

-

lang['EDIT_STYLE_EXPLAIN']; ?>

+

lang['MANAGE_STYLE_EXPLAIN']; ?>

"> @@ -186,17 +186,69 @@ switch ($mode) break; + + + case 'imagesets': - $imgroot = (isset($_POST['imgroot'])) ? $_POST['imgroot'] : $config['default_style']; - if (isset($_POST['img_addconfig'])) + + + adm_page_header($user->lang['MANAGE_IMAGESET']); + +?> +

lang['MANAGE_IMAGESET']; ?>

+ +

lang['MANAGE_IMAGESET_EXPLAIN']; ?>

+ +">
+ + + + +sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) { + do + { + $row_class = ($row_class != 'row1') ? 'row1' : 'row2'; + +?> + + + + +sql_fetchrow($result)); } - else if (isset($_POST['img_addlocal'])) + else { } + $db->sql_freeresult($result); + + +?> + + + +
Imageset name 
"> ">Deactivate | ">Delete | ">Export | ">Preview 
 
+sql_query($sql); @@ -280,7 +332,7 @@ switch ($mode) array( + 'confirm_body.html', 'faq_body.html', 'index_body.html', 'message_body.html', 'viewonline_body.html', + ), + 'includes' => array( + 'overall_footer.html', 'overall_header.html', 'simple_footer.html', 'simple_header.html', 'searchbox.html', 'jumpbox.html', + ), + 'forum' => array( + 'viewforum_body.html', 'viewforum_subforum.html', + ), + 'topic' => array( + 'viewtopic_attach_body.html', 'viewtopic_body.html', 'viewtopic_print.html', + ), + 'group' => array( + 'gcp_body.html', 'gcp_pending_info.html', 'gcp_user_body.html', + ), + 'user' => array( + 'ucp_agreement.html', 'ucp_footer.html', 'ucp_header.html', 'ucp_main.html', 'ucp_pm_body.html', 'ucp_pm_popup.html', 'ucp_pm_preview.html', 'ucp_pm_read.html', 'ucp_prefs.html', 'ucp_profile.html', 'ucp_register.html', 'ucp_remind.html', + ), + 'profile' => array( + 'memberlist_body.html', 'memberlist_email.html', 'memberlist_im.html', 'memberlist_view.html', + ), + 'mod' => array( + 'mcp_forum.html', 'mcp_foruminfo.html', 'mcp_front.html', 'mcp_header.html', 'mcp_jumpbox.html', 'mcp_move.html', 'mcp_post.html', 'mcp_queue.html', 'mcp_reports.html', 'mcp_topic.html', 'mcp_viewlogs.html', 'report_body.html', + ), + 'search' => array( + 'search_body.html', 'search_results_posts.html', 'search_results_topics.html', + ), + 'posting' => array( + 'posting_attach_body.html', 'posting_body.html', 'posting_poll_body.html', 'posting_preview.html', 'posting_smilies.html', 'posting_topic_review.html', + ), + 'login' => array( + 'login_body.html', 'login_forum.html', + ), + 'custom' => array(), + ); + + $tpldata = ''; + if ($template_id) { - $str = "compile(stripslashes($_POST['decompile'])) . "\n?".">"; + $sql = 'SELECT * + FROM ' . STYLES_TPL_TABLE . " + WHERE template_id = $template_id"; + $result = $db->sql_query($sql); - $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'w+'); - fwrite ($fp, $str); - fclose($fp); + if (!(extract($db->sql_fetchrow($result)))) + { + trigger_error($user->lang['NO_TEMPLATE']); + } + $db->sql_freeresult($result); - @chmod($phpbb_root_path . 'templates/cache/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 0644); - add_log('admin', 'log_template_edit', $tplname, $tplroot); + $test_ary = array(); + foreach ($tpllist as $category => $tpl_ary) + { + $test_ary = array_merge($test_ary, $tpl_ary); + } - exit; - } - else if (!empty($tplname) && isset($_POST['tpl_name'])) - { - $fp = fopen($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $tplname . '.html.' . $phpEx, 'r'); - while (!feof($fp)) + $dp = @opendir($phpbb_root_path . 'styles/templates/' . $template_path); + while ($file = readdir($dp)) { - $str .= fread($fp, 4096); + if (!strstr($file, 'bbcode.') && strstr($file, '.html') && is_file($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $file)) + { + if (!in_array($file, $test_ary)) + { + $tpllist['custom'][] = $file; + } + } + } + closedir($dp); + unset($matches); + unset($test_ary); + + + + if ($tplname) + { + $fp = fopen($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $tplname, 'r');// . '.html' + while (!feof($fp)) + { + $tpldata .= fread($fp, 4096); + } + @fclose($fp); + + /* $match_preg = array( + '#\$this\->_tpl_include\(\'(.*?)\'\);#', + '#echo \$this->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\];#', + '#echo \(\(isset\(\$this\->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\]\)\).*?;#', + '#if \(.*?\[\'\.\'\]\[0\]\[\'(.*?)\'\]\) \{ #', + '#\$_(.*?)_count.*?;if \(.*?\)\{#', + '#\<\?php #', + '# \?\>#', + ); + + $replace_preg = array( + '', + '{$1}', + '{$1}', + '', + '', + '', + '' + ); + + */ + + // $tpldata = preg_replace($match_preg, $replace_preg, $tpldata); + + preg_match_all('##', $tpldata, $included_tpls); + $included_tpls = $included_tpls[1]; } - @fclose($fp); - - $match_preg = array( - '#\$this\->_tpl_include\(\'(.*?)\'\);#', - '#echo \$this->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\];#', - '#echo \(\(isset\(\$this\->_tpldata\[\'\.\'\]\[0\]\[\'(.*?)\'\]\)\).*?;#', - '#if \(.*?\[\'\.\'\]\[0\]\[\'(.*?)\'\]\) \{ #', - '#\$_(.*?)_count.*?;if \(.*?\)\{#', - ); - - $replace_preg = array( - '', - '{$1}', - '{$1}', - '', - '', - ); - - $str = preg_replace($match_preg, $replace_preg, $str); - $str = str_replace('', '', $str); - } - else - { - $str = (!empty($_POST['decompile'])) ? stripslashes($_POST['decompile']) : ''; } - if (isset($_POST['tpl_download'])) +/* if (isset($_POST['tpl_download'])) { header("Content-Type: text/html; name=\"" . $tplname . ".html\""); header("Content-disposition: attachment; filename=" . $tplname . ".html"); @@ -363,14 +479,33 @@ switch ($mode) exit; } +*/ + + + // Generate list of template options + $tpl_options = ''; + ksort($tpllist); + foreach ($tpllist as $category => $tpl_ary) + { + if (sizeof($tpl_ary)) + { + sort($tpl_ary); + $tpl_options .= ''; + + foreach ($tpl_ary as $tpl_file) + { + $selected = ($tpl_file == $tplname) ? ' selected="selected"' : ''; + $tpl_options .= ''; + } + } + } -// $tplroot_options = get_templates($tplroot); $tplname_options = ''; - $dp = @opendir($phpbb_root_path . 'cache/templates/' . $tplroot . '/'); + $dp = @opendir($phpbb_root_path . 'styles/templates/' . $template_path); while ($file = readdir($dp)) { - if (strstr($file, '.html.' . $phpEx) && is_file($phpbb_root_path . 'cache/templates/' . $tplroot . '/' . $file)) + if (strstr($file, '.html') && is_file($phpbb_root_path . 'styles/templates/' . $template_path . '/' . $file)) { $tpl = substr($file, 0, strpos($file, '.')); $selected = ($tplname == $tpl) ? ' selected="selected"' : ''; @@ -379,6 +514,8 @@ switch ($mode) } closedir($dp); + + // adm_page_header($user->lang['Edit_template']); @@ -388,22 +525,26 @@ switch ($mode)

lang['Edit_template_explain']; ?>

-
"> +">
- - - + +
+ + + + - - - - - -
lang['SELECT_TEMPLATE']; ?>:  
- - - + + + + + + + + + +
 Template:   Columns:  Rows:    Columns:  Rows:  
Raw HTML
  
   
 
 
array( - 'body', 'p', 'a', 'h1', 'h2', 'h3', 'tabletitle', 'cattitle', 'topictitle', 'topicauthor', 'topicdetails', 'postdetails', 'postbody', 'posthilit', 'postauthor', 'genmed', 'gensmall', 'copyright', + 'body', 'p', 'h1', 'h2', 'h3', 'tabletitle', 'cattitle', 'topictitle', 'topicauthor', 'topicdetails', 'postdetails', 'postbody', 'posthilit', 'postauthor', 'mainmenu', 'nav', 'genmed', 'gensmall', 'copyright', ), 'tables' => array( 'table', 'th', 'cat', 'catdiv', 'td', 'row1', 'row2', 'row3', 'spacer', 'hr', @@ -517,13 +655,29 @@ switch ($mode) 'custom' => array(), ); + // 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',), + 'sizes' => array('font-size', 'line-height',), + 'images' => array('background-image',), + 'repeat' => array('background-repeat',), + 'other' => array('font-weight', 'font-family', 'font-style', 'text-decoration',), + ); + + // Used in an sprintf statement to generate appropriate output for rawcss mode + $map_elements = array( + 'colors' => '%s', + 'sizes' => '%d%s', + 'images' => 'url(\'%s\')', + 'repeat' => '%s', + 'other' => '%s', + ); - // We want to submit the updates - if (isset($_POST['update'])) - { - } - + $s_hidden_fields = ''; + // Do we want to edit an existing theme? if ($theme_id) { @@ -575,71 +729,105 @@ switch ($mode) // Do we have a class set? If so, we need to extract and set the relevant data if (!empty($class)) { + // We must generate the relevant data ... what we need depends on whether + // we are looking @ the rawcss or the simplified settings and whether we + // have just selected a class. We must also cope with switching between + // simple and rawcss mode + $css_element = array(); + if (!empty($_POST['rawcss'])) + { + $css_element = preg_replace("#;[\r\n]*#s", "\n", stripslashes($_POST['rawcss'])); + $css_element = explode("\n", $css_element); + } + else if ($showcss) + { + if (!empty($_POST['cssother'])) + { + $css_element = explode('; ', stripslashes(substr($_POST['cssother'], 0, -2))); + } + + foreach ($match_elements as $type => $match_ary) + { + foreach ($match_ary as $match) + { + $var = str_replace('-', '_', $match); + if (!empty($_POST[$var])) + { + $css_element[] = str_replace('_', '-', $var) . ': ' . (($type == 'sizes') ? sprintf($map_elements[$type], $_POST[$var], $_POST[$var . '_units']) : sprintf($map_elements[$type], $_POST[$var])); + } + } + } + } + else if (preg_match('#^.*?' . $class . ' {(.*?)}#m', $stylesheet, $matches)) + { + $css_element = explode('; ', ltrim($matches[1])); + } + // 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)) + if (sizeof($css_element) && !$showcss) { - $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',), - '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) { foreach ($match_ary as $match) { - $$match = ''; - $var = str_replace('-', '', $match); + $var = str_replace('-', '_', $match); + $$var = ''; - if (preg_match('# ' . $match . ': (.*?);#s', $css_element, $matches)) + foreach ($css_element as $key => $element) { - switch ($type) + if (preg_match('#^' . $match . ': (.*?)$#', $element, $matches)) { - case 'colors': - $$var = trim($matches[1]); - break; - - case 'sizes': - if (preg_match('#(.*?)(px|%|em|pt)#', $matches[1], $matches)) - { - ${$var . 'units'} = trim($matches[2]); - } - $$var = trim($matches[1]); - break; - - case 'images': - if (preg_match('#url\(\'(.*?)\'\)#', $matches[1], $matches)) - { + switch ($type) + { + case 'colors': $$var = trim($matches[1]); - } - $$var = str_replace('./', $theme_data['theme_name'] . '/', $$var); - break; + break; - case 'repeat': - $$var = trim($matches[1]); - break; + case 'sizes': + if (preg_match('#(.*?)(px|%|em|pt)#', $matches[1], $matches)) + { + ${$var . '_units'} = trim($matches[2]); + } + $$var = trim($matches[1]); + break; + + case 'images': + if (preg_match('#url\(\'(.*?)\'\)#', $matches[1], $matches)) + { + $$var = trim($matches[1]); + } + $$var = str_replace('./', $theme_name . '/', $$var); + break; + + case 'repeat': + $$var = trim($matches[1]); + break; + + default: + $$var = trim($matches[1]); + } - default: - $$var = trim($matches[1]); + // Remove this element from array + unset($css_element[$key]); + break; } } } } + + // Any remaining elements must be custom data so we save that + // in a hidden field + if (sizeof($css_element)) + { + $s_hidden_fields .= ''; + } } } // End of class element variable setting - // Generate list of class options $class_options = ''; foreach ($base_classes as $category => $class_ary) @@ -661,7 +849,7 @@ switch ($mode) { $img = substr($img['path'], 1) . (($img['path'] != '') ? '/' : '') . $img['file']; - $selected = (preg_match('#' . preg_quote($img) . '#', $backgroundimage)) ? ' selected="selected"' : ''; + $selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : ''; $bg_imglist .= ''; } $bg_imglist = '' . $bg_imglist; @@ -678,19 +866,36 @@ switch ($mode) function swatch(field) { - window.open('./swatch.php?form=style&name=' + field, '_swatch', 'HEIGHT=115,resizable=yes,scrollbars=no,WIDTH=636'); + window.open('./swatch.?form=style&name=' + field, '_swatch', 'HEIGHT=115,resizable=yes,scrollbars=no,WIDTH=636'); return false; } //--> -

lang['EDIT_THEME']; ?>

lang['EDIT_THEME_EXPLAIN']; ?>

"> + @@ -702,18 +907,14 @@ function swatch(field) { ?> - - - - - + - + Parameter - - - - - + - + - @@ -764,38 +961,38 @@ function swatch(field) - + - - + - + - + - @@ -806,7 +1003,7 @@ function swatch(field) ?> - +?> -
lang['SELECT_CLASS']; ?>:  
Columns:  Rows:    
Raw CSS
Theme name:lang['SHOW_RAW_CSS_EXPLAIN']; ?>
Value
Theme name:
Background
Color:
This is a hex-triplet of the form RRGGBB
Web-safe Colour Swatch
 
 
Image:
Repeat background: '------', 'none' => 'No', 'repeat-x' => 'Horizontally Only', 'repeat-y' => 'Vertically Only', 'both' => 'Both Directions') as $cssvalue => $cssrepeat) { - echo ''; + echo ''; } ?>
Font:
You can specify multiple fonts seperated by commas
Size:
Bold: /> lang['YES']; ?>   /> lang['NO']; ?> /> lang['YES']; ?>   /> lang['NO']; ?>
Italic: /> lang['YES']; ?>   /> lang['NO']; ?> /> lang['YES']; ?>   /> lang['NO']; ?>
Underline: /> lang['YES']; ?>   /> lang['NO']; ?> /> lang['YES']; ?>   /> lang['NO']; ?>
Line spacing:
            
- + + + -

Custom Class

+

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.

+

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.

- +
+ +
- + @@ -860,7 +1060,7 @@ function swatch(field) // Output list of themes - adm_page_header($user->lang['EDIT_THEME']); + adm_page_header($user->lang['THEMES']); ?>

lang['THEMES']; ?>

@@ -887,7 +1087,7 @@ function swatch(field) ?> - +
Add Custom Class
CSS class name:CSS class name:
"> ">Recache | ">Delete | ">Export | ">Preview  ">Regenerate | ">Delete | ">Export | ">Preview