From 3cecf1cd9ce349ec808573368678712e46035faf Mon Sep 17 00:00:00 2001 From: stevetruckstuff Date: Tue, 28 Mar 2006 22:17:44 +0000 Subject: [PATCH] Added ability for template authors to include additional stylesheets. This allows them to add additional CSS defs while maintaining SQM default defintions. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11004 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- class/template/template.class.php | 30 +- functions/page_header.php | 1 - src/style.php | 8 + templates/default/stylesheet.tpl | 23 + templates/default/template.php | 15 +- templates/default_advanced/stylesheet.tpl | 488 ------------------ .../default_advanced/stylesheet_advanced.tpl | 75 +++ templates/default_advanced/template.php | 13 +- 8 files changed, 158 insertions(+), 495 deletions(-) delete mode 100644 templates/default_advanced/stylesheet.tpl create mode 100644 templates/default_advanced/stylesheet_advanced.tpl diff --git a/class/template/template.class.php b/class/template/template.class.php index 9b413a32..15163375 100755 --- a/class/template/template.class.php +++ b/class/template/template.class.php @@ -65,6 +65,14 @@ class Template */ var $provided_js_files = array(); + /** + * Additional stylesheets provided by the template. This allows template + * authors (namely me to begin with :p) to provide additional CSS sheets + * to templates while using the default template set stylesheet for other + * definitions. + */ + var $additional_css_sheets = array(); + /** * Constructor * @@ -78,9 +86,7 @@ class Template $this->templates_provided = is_array($templates_provided) ? $templates_provided : array(); $this->required_js_files = is_array($required_js_files) ? $required_js_files : array(); $this->provided_js_files = is_array($provided_js_files) ? $provided_js_files: array(); - -# echo 'Template Dir: '.$this->template_dir.': '; -# var_dump($this->templates_provided); + $this->additional_css_sheets = is_array($additional_css_sheets) ? $additional_css_sheets : array(); } @@ -236,6 +242,24 @@ class Template return $paths; } + + /** + * Return any additional stylsheets provided by the template. Used when + * generating page headers. + * + * @return array $paths + */ + function getAdditionalStyleSheets () { + $paths = array(); + foreach ($this->additional_css_sheets as $css) { + $css = basename($css); + if (strtolower($css) == 'stylesheet.tpl') { + continue; + } + $paths[] = $css; + } + return $paths; + } } ?> diff --git a/functions/page_header.php b/functions/page_header.php index ea4dc071..5b4789cc 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -71,7 +71,6 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE .(!empty($used_fontsize) ? '&fontsize='.$used_fontsize : '') .(!empty($text_direction) ? '&dir='.$text_direction : '')."\">\n"; - // load custom style sheet (deprecated) if ( ! empty($theme_css) ) { echo "\n"; diff --git a/src/style.php b/src/style.php index 2f510033..2ef46dca 100644 --- a/src/style.php +++ b/src/style.php @@ -181,4 +181,12 @@ if ( $lastmod = @filemtime($oTemplate->template_dir . 'stylesheet.tpl') ) { } $oTemplate->display('stylesheet.tpl'); +/** + * Include any additional stylesheets provided by the template + */ +$template_css = $oTemplate->getAdditionalStyleSheets(); +foreach ($template_css as $stylesheet) { + $oTemplate->display($stylesheet); +} + ?> diff --git a/templates/default/stylesheet.tpl b/templates/default/stylesheet.tpl index 83ec53cc..5a2b9936 100644 --- a/templates/default/stylesheet.tpl +++ b/templates/default/stylesheet.tpl @@ -300,6 +300,29 @@ img { padding-bottom:15px; } +/* error_box.tpl definitions */ +.table_errorBoxWrapper { + width:100%; + padding:0; + border-spacing:0; + border:0; + text-align:center; + margin-left:auto; + margin-right:auto; + background: ; +} + +.table_errorBox { + width:100%; + padding:0; + border-spacing:0; + border:0; + text-align:center; + margin-left:auto; + margin-right:auto; + background: ; +} + /* page_header.tpl definitions */ .sqm_currentFolder { background: ; diff --git a/templates/default/template.php b/templates/default/template.php index 2219709d..97c08b82 100644 --- a/templates/default/template.php +++ b/templates/default/template.php @@ -17,15 +17,16 @@ */ $templates_provided = array ( 'empty_folder.tpl', + 'error_box.tpl', 'error_message.tpl', 'footer.tpl', 'left_main.tpl', 'login.tpl', 'message_list.tpl', + 'motd.tpl', + 'note.tpl', 'page_header.tpl', 'paginator.tpl', - 'note.tpl', - 'motd.tpl', 'stylesheet.tpl' ); @@ -46,4 +47,14 @@ $required_js_files = array ( $provided_js_files = array ( 'default.js' ); + +/** + * Additional CSS stylesheets may be provided by template authors. + * stylesheet.tpl will always be included in all pages. Any additional + * stylesheets provided by this template should be listed here. These + * stylesheets will be automatically included on each page. They should be + * located in the template root directory. + */ +$additional_css_sheets = array ( + ); ?> \ No newline at end of file diff --git a/templates/default_advanced/stylesheet.tpl b/templates/default_advanced/stylesheet.tpl deleted file mode 100644 index 5ee1559e..00000000 --- a/templates/default_advanced/stylesheet.tpl +++ /dev/null @@ -1,488 +0,0 @@ - - *
  • SQM_BACKGROUND - background color - *
  • SQM_BACKGROUND_LEFT - background of folder tree - *
  • SQM_TEXT_STANDARD - text color - *
  • SQM_TEXT_STANDARD_LEFT - text color of folder tree - *
  • SQM_LINK - color of links - *
  • SQM_LINK_LEFT - color of links in folder tree - *
  • SQM_TEXT_SPECIAL - color of special folder links in folder tree - *
  • todo: other constants should be documented here - * - * - * Optional template variables - * - * Variables are set to empty string, when value is not set. - * - * @copyright © 2005-2006 The SquirrelMail Project Team - * @license http://opensource.org/licenses/gpl-license.php GNU Public License - * @version $Id$ - * @package squirrelmail - * @subpackage templates - */ - -/* retrieve the template vars */ -extract($t); - -?> -/* older css template */ -body, td, th, dd, dt, h1, h2, h3, h4, h5, h6, p, ol, ul, li { - -} -body, small { - -} -td, th { - -} -textarea, pre { -font-family: monospace; - -} - -/* page body formatting */ -body { - color: ; - background-color: ; -} -body.sqm_leftMain { - color: ; - background-color: ; - text-align: left; -} - -/* right links */ -a:link, a:visited, a:hover, a:active { - color: ; -} - -/* left links */ -.sqm_leftMain a:link, .sqm_leftMain a:visited, .sqm_leftMain a:hover, .sqm_leftMain a:active { - color: ; -} -.leftunseen, .leftspecial, .leftspecial a:link, .leftspecial a:visited, .leftspecial a:hover, .leftspecial a:active { - color: ; -} -.leftrecent { - font-weight:bold; -} -.leftnoselect a:link, .leftnoselect a:visited, .leftnoselect a:hover, .leftnoselect a:active { - color: ; -} - -/* highlighted texts */ -.highlight { - color: ; -} - -/* left_main.tpl definitions */ -.sqm_wrapperTable { - border:0; - padding:0; - margin-left:auto; - margin-right:auto; - border-spacing:0; - width:99% - text-align:center; -} -sqm_leftMain table { - border:0; - padding:0; - margin:0; - border-spacing:0; - margin-left:auto; - margin-right:auto; -} -.sqm_folderHeader { - font-size:18px; - font-weight:bold; - text-align:center; -} -.sqm_clock { -} -.sqm_lastRefreshTime { - white-space: nowrap; -} -.sqm_refreshButton { -} - -.dtree { - font-size:11px; - white-space:nowrap; -} -.dtree p { - margin-top:12px; - margin-bottom:2px; - padding-bottom:4px; - text-align:center; - overflow: hidden; -} -.dtree a:hover { - text-decoration: underline; -} -.dtree a { - text-decoration:none; -} -.dtree img { - border:0; - vertical-align: middle; -} -.dtree a.node, .dtree a.nodeSel { - white-space: nowrap; - padding: 1px 2px 1px 2px; -} -.dtree a.node:hover, .dtree a.nodeSel:hover { - color: ; -} -.dtree a.nodeSel { - color: ; -} -.dtree .clip { - overflow: hidden; -} - -/* formating of error template */ -.thead_caption { - font-weight: bold; - text-align: center; -} - -.error_list { -} -.error_table { - color: ; - border: 2px solid ; - background-color: ; - width: 100%; -} -.error_thead { - background-color: ; -} -.error_thead_caption { - background-color: ; -} -.error_row { - color: ; -} -.error_val { - color: ; - width: 80%; - border: 2px solid ; - -} -.error_key { - width: 20%; - border: 2px solid ; - color: ; - font-weight: bold; - font-style: italic; - background-color: ; -} - -/* form fields */ -input.sqmtextfield{ -} -input.sqmpwfield { -} -input.sqmcheckbox { -} -input.sqmradiobox { -} -input.sqmhiddenfield { -} -input.sqmsubmitfield { -} -input.sqmresetfield { -} -input.sqmtextarea { -} - -/* basic definitions */ -.table_empty { - width:100%; - border:0; - margin:0; - padding:0; - border-spacing:0; -} - -.table_standard { - width:100%; - border:1px solid ; - padding:0; - margin:0; - border-spacing:0; -} - -em { - font-weight:bold; - font-style:normal; -} - -small { - font-size:80%; -} -img { - border:0; -} - -/* login.tpl definitions */ -#sqm_login table { - border:0; - margin:0; - padding:0; - border-spacing:0; - margin-left:auto; - margin-right:auto; -} -#sqm_login td { - padding:2px; -} - -.sqm_loginImage { - margin-left:auto; - margin-right:auto; - padding:2px; -} -.sqm_loginTop { - text-align:center; - font-size:80%; -} -.sqm_loginOrgName { - font-weight:bold; - text-align:center; - background: ; - width:350px; - border:0; -} -.sqm_loginFieldName { - text-align:right; - width:30%; -} -.sqm_loginFieldInput { - text-align:left; -} -.sqm_loginSubmit { - text-align:center; -} - -/* note.tpl defs */ -.sqm_noteWrapper { - text-align:center; - width:100%; -} -.sqm_note { - margin-left:auto; - margin-right:auto; - font-weight:bold; - text-align:center; -} - -/* motd.tpl defs */ -.sqm_motdWrapper { - text-align:center; - width:100%; - margin:1px; -} -.sqm_motd { - margin-left:auto; - margin-right:auto; - text-align:center; - background: ; - width:70%; - padding:0; -} -.sqm_motd td { - text-align:center; - background: ; - padding:5px; -} - -/* empty_folder.tpl defs */ -.sqm_emptyFolderWrapper { - text-align:center; - width:100%; -} -.sqm_emptyFolder { - margin-left:auto; - margin-right:auto; - text-align:center; - background: ; - padding:1; - width:100%; -} -.sqm_emptyFolder td { - text-align:center; - background: ; - padding-top:15px; - padding-bottom:15px; -} - -/* page_header.tpl definitions */ -.sqm_currentFolder { - background: ; - padding:2px; - text-align: ; -} -.sqm_headerSignout { - background: ; - padding:2px; - text-align: ; - font-weight:bold; -} -.sqm_topNavigation { - padding:2px; - text-align: ; -} -.sqm_providerInfo { - padding:2px; - text-align: ; -} - -/* message_list.tpl definitions */ -.table_messageListWrapper { - width:100%; - padding:0; - border-spacing:0; - border:0; - text-align:center; - margin-left:auto; - margin-right:auto; - background: ; -} - -.table_messageList { - width:100%; - padding:0; - border-spacing:0; - border:0; - text-align:center; - margin-left:auto; - margin-right:auto; - background: ; -} - -.table_messageList a { - white-space:nowrap; -} - -.table_messageList tr.headerRow { - text-align: ; - white-space:nowrap; - font-weight:bold; -} -.table_messageList td.spacer { - height:1px; - background: ; -} - -.table_messageList tr { - vertical-align:top; -} -.table_messageList tr.even { - background: ; -} -.table_messageList tr.odd { - background: ; -} -.table_messageList tr.mouse_over { - background: ; -} -.table_messageList tr.clicked { - background: ; -} - -.table_messageList td { - white-space:nowrap; -} -.table_messageList td.col_check { - text-align: ; -} -.table_messageList td.col_subject { - text-align: ; -} -.table_messageList td.col_flags { - text-align: ; -} -.table_messageList td.col_date { - text-align:center; -} -.table_messageList td.col_text { - text-align: ; -} - -.unread { - font-weight:bold; -} -.deleted { - color: ; -} -.flagged { - color: ; -} -.high_priority { - color: ; -} -.low_priority { - color: ; -} - -.col_checked { -} - -.links_paginator { - text-align: ; -} - -.message_count { - text-align:right; - font-size:8pt; -} - -.message_list_controls { - background: ; -} - -.message_control_button { - padding:0px; - margin:0px; -} -.message_control_buttons { - text-align: ; - font-size:10px; /* replaces tags to allow greater control of fonts w/ using an id. */ -} -.message_control_delete { - text-align: ; - font-size:10px; /* replaces tags to allow greater control of fonts w/ using an id. */ -} -.message_control_move { - text-align: ; - font-size:10px; /* replaces tags to allow greater control of fonts w/ using an id. */ -} - -.spacer { - height:5px; - background: ; -} - - diff --git a/templates/default_advanced/stylesheet_advanced.tpl b/templates/default_advanced/stylesheet_advanced.tpl new file mode 100644 index 00000000..1c7bbb71 --- /dev/null +++ b/templates/default_advanced/stylesheet_advanced.tpl @@ -0,0 +1,75 @@ + + *
  • SQM_BACKGROUND - background color + *
  • SQM_BACKGROUND_LEFT - background of folder tree + *
  • SQM_TEXT_STANDARD - text color + *
  • SQM_TEXT_STANDARD_LEFT - text color of folder tree + *
  • SQM_LINK - color of links + *
  • SQM_LINK_LEFT - color of links in folder tree + *
  • SQM_TEXT_SPECIAL - color of special folder links in folder tree + *
  • todo: other constants should be documented here + * + * + * Optional template variables + *
      + *
    • fontfamily - string with list of fonts used by selected style. + *
    • fontsize - integer with selected font size value. + *
    + * Variables are set to empty string, when value is not set. + * + * @copyright © 2005-2006 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package squirrelmail + * @subpackage templates + */ + +/* retrieve the template vars */ +extract($t); +?> + +/* Advanced Tree definitions */ +.dtree { + font-size:11px; + white-space:nowrap; +} +.dtree p { + margin-top:12px; + margin-bottom:2px; + padding-bottom:4px; + text-align:center; + overflow: hidden; +} +.dtree a:hover { + text-decoration: underline; +} +.dtree a { + text-decoration:none; +} +.dtree img { + border:0; + vertical-align: middle; +} +.dtree a.node, .dtree a.nodeSel { + white-space: nowrap; + padding: 1px 2px 1px 2px; +} +.dtree a.node:hover, .dtree a.nodeSel:hover { + color: ; +} +.dtree a.nodeSel { + color: ; +} +.dtree .clip { + overflow: hidden; +} \ No newline at end of file diff --git a/templates/default_advanced/template.php b/templates/default_advanced/template.php index 625dfdbd..0cee1c38 100644 --- a/templates/default_advanced/template.php +++ b/templates/default_advanced/template.php @@ -17,7 +17,7 @@ */ $templates_provided = array ( 'left_main.tpl', - 'stylesheet.tpl' + 'stylesheet_advanced.tpl' ); /** @@ -38,4 +38,15 @@ $required_js_files = array ( $provided_js_files = array ( 'dtree.js' ); + +/** + * Additional CSS stylesheets may be provided by template authors. + * stylesheet.tpl will always be included in all pages. Any additional + * stylesheets provided by this template should be listed here. These + * stylesheets will be automatically included on each page. They should be + * located in the template root directory. + */ +$additional_css_sheets = array ( + 'stylesheet_advanced.tpl' + ); ?> \ No newline at end of file -- 2.25.1