فهرست منبع

Added ability for template authors to include additional stylesheets. This allows them to add additional CSS defs while maintaining SQM default defintions.

stevetruckstuff 19 سال پیش
والد
کامیت
8ca0997cc8

+ 27 - 3
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;
+  }
 }
 
 ?>

+ 0 - 1
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 "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\">\n";

+ 8 - 0
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);
+}
+ 
 ?>

+ 23 - 0
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: <?php echo $color[9]; ?>;
+}
+
+.table_errorBox  {
+    width:100%;
+    padding:0;
+    border-spacing:0;
+    border:0;
+    text-align:center;
+    margin-left:auto;
+    margin-right:auto;
+    background: <?php echo $color[5]; ?>;
+}
+
 /* page_header.tpl definitions */
 .sqm_currentFolder	{
     background: <?php echo $color[9]; ?>;

+ 13 - 2
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  (
+                                );
 ?>

+ 0 - 488
templates/default_advanced/stylesheet.tpl

@@ -1,488 +0,0 @@
-<?php
-/**
- * SquirrelMail CSS template
- *
- * Template is used by style.php script to generate css file used by
- * SquirrelMail scripts.
- *
- * Available constants
- *
- * Color codes used by selected theme:
- * <ul>
- *   <li>SQM_BACKGROUND - background color
- *   <li>SQM_BACKGROUND_LEFT - background of folder tree
- *   <li>SQM_TEXT_STANDARD - text color
- *   <li>SQM_TEXT_STANDARD_LEFT - text color of folder tree
- *   <li>SQM_LINK - color of links
- *   <li>SQM_LINK_LEFT - color of links in folder tree
- *   <li>SQM_TEXT_SPECIAL - color of special folder links in folder tree
- *   <li>todo: other constants should be documented here
- * </ul>
- *
- * Optional template variables
- * <ul>
- *   <li>fontfamily - string with list of fonts used by selected style.
- *   <li>fontsize - integer with selected font size value.
- * </ul>
- * Variables are set to empty string, when value is not set.
- *
- * @copyright &copy; 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 {
-<?php
-if($fontfamily) echo '  font-family: '.$fontfamily.";\n";
-?>
-}
-body, small {
-<?php
-if($fontsize) echo '  font-size: '.($fontsize-2)."pt;\n";
-?>
-}
-td, th {
-<?php
-if($fontsize) echo '  font-size: '.$fontsize."pt;\n";
-?>
-}
-textarea, pre {
-font-family: monospace;
-<?php
-if($fontsize) echo '  font-size: '.($fontsize-1)."pt;\n";
-?>
-}
-
-/* page body formatting */
-body {
-    color:  <?php echo SQM_TEXT_STANDARD; ?>;
-    background-color: <?php echo SQM_BACKGROUND; ?>;
-}
-body.sqm_leftMain {
-    color:  <?php echo SQM_TEXT_STANDARD_LEFT; ?>;
-    background-color: <?php echo SQM_BACKGROUND_LEFT; ?>;
-    text-align: left;
-}
-
-/* right links */
-a:link, a:visited, a:hover, a:active {
-    color: <?php echo SQM_LINK; ?>;
-}
-
-/* left links */
-.sqm_leftMain a:link, .sqm_leftMain a:visited, .sqm_leftMain a:hover, .sqm_leftMain a:active {
-    color:  <?php echo SQM_LINK_LEFT; ?>;
-}
-.leftunseen, .leftspecial, .leftspecial a:link, .leftspecial a:visited, .leftspecial a:hover, .leftspecial a:active {
-    color:  <?php echo SQM_TEXT_SPECIAL; ?>;
-}
-.leftrecent {
-    font-weight:bold;
-}
-.leftnoselect a:link, .leftnoselect a:visited, .leftnoselect a:hover, .leftnoselect a:active {
-    color:  <?php echo SQM_TEXT_HIGHLIGHT; ?>;
-}
-
-/* highlighted texts */
-.highlight {
-    color:  <?php echo SQM_TEXT_HIGHLIGHT; ?>;
-}
-
-/* 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: <?php echo SQM_TEXT_HIGHLIGHT; ?>;
-}
-.dtree a.nodeSel {
-    color: <?php echo SQM_TEXT_HIGHLIGHT; ?>;
-}
-.dtree .clip {
-    overflow: hidden;
-}
-
-/* formating of error template */
-.thead_caption {
-    font-weight: bold;
-    text-align: center;
-}
-
-.error_list {
-}
-.error_table {
-    color: <?php echo $color[14]; ?>;
-    border: 2px solid <?php echo $color[0]; ?>;
-    background-color: <?php echo $color[3]; ?>;
-    width: 100%;
-}
-.error_thead {
-    background-color: <?php echo $color[10]; ?>;
-}
-.error_thead_caption {
-    background-color: <?php echo $color[10]; ?>;
-}
-.error_row {
-    color: <?php echo $color[14]; ?>;
-}
-.error_val {
-    color: <?php echo $color[8]; ?>;
-    width: 80%;
-    border: 2px solid <?php echo $color[0]; ?>;
-
-}
-.error_key {
-    width: 20%;
-    border: 2px solid <?php echo $color[0]; ?>;
-    color: <?php echo $color[14]; ?>;
-    font-weight: bold;
-    font-style: italic;
-    background-color: <?php echo $color[0]; ?>;
-}
-
-/* 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 <?php echo $color[0]; ?>;
-    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: <?php echo $color[0]; ?>;
-    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: <?php echo $color[9]; ?>;
-    width:70%;
-    padding:0;
-}
-.sqm_motd td {
-    text-align:center;
-    background: <?php echo $color[4]; ?>;
-    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: <?php echo $color[9]; ?>;
-    padding:1;
-    width:100%;
-}
-.sqm_emptyFolder td {
-    text-align:center;
-    background: <?php echo $color[4]; ?>;
-    padding-top:15px;
-    padding-bottom:15px;
-}
-
-/* page_header.tpl definitions */
-.sqm_currentFolder	{
-    background: <?php echo $color[9]; ?>;
-    padding:2px;
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-}
-.sqm_headerSignout	{
-    background: <?php echo $color[9]; ?>;
-    padding:2px;
-    text-align: <?php echo SQM_ALIGN_RIGHT; ?>;
-    font-weight:bold;
-}
-.sqm_topNavigation	{
-    padding:2px;
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-}
-.sqm_providerInfo	{
-    padding:2px;
-    text-align: <?php echo SQM_ALIGN_RIGHT; ?>;
-}
-
-/* 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: <?php echo $color[9]; ?>;
-}
-
-.table_messageList	{
-    width:100%;
-    padding:0;
-    border-spacing:0;
-    border:0;
-    text-align:center;
-    margin-left:auto;
-    margin-right:auto;
-    background: <?php echo $color[5]; ?>;
-}
-
-.table_messageList	a	{
-    white-space:nowrap;
-}
-
-.table_messageList	tr.headerRow	{
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-    white-space:nowrap;
-    font-weight:bold;
-}
-.table_messageList td.spacer {
-    height:1px;
-    background: <?php echo $color[0]; ?>;
-}
-
-.table_messageList	tr		{
-    vertical-align:top;
-}
-.table_messageList	tr.even	{
-    background: <?php echo $color[12]; ?>;
-}
-.table_messageList	tr.odd	{
-    background: <?php echo $color[4]; ?>;
-}
-.table_messageList	tr.mouse_over	{
-    background: <?php echo $color[5]; ?>;
-}
-.table_messageList	tr.clicked	{
-    background: <?php echo (!empty($color[16])) ? $color[16] : $color[2]; ?>;
-}
-
-.table_messageList	td	{
-    white-space:nowrap;
-}
-.table_messageList	td.col_check	{
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-}
-.table_messageList	td.col_subject	{
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-}
-.table_messageList	td.col_flags	{
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-}
-.table_messageList	td.col_date	{
-    text-align:center;
-}
-.table_messageList	td.col_text	{
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-}
-
-.unread		{
-    font-weight:bold;
-}
-.deleted	{
-    color: <?php echo $color[9]; ?>;
-}
-.flagged	{
-    color: <?php echo $color[2]; ?>;
-}
-.high_priority	{
-    color: <?php echo $color[1]; ?>;
-}
-.low_priority	{
-    color: <?php echo $color[8]; ?>;
-}
-
-.col_checked	{
-}
-
-.links_paginator			{
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-}
-
-.message_count				{
-    text-align:right;
-    font-size:8pt;
-}
-
-.message_list_controls {
-    background: <?php echo $color[0]; ?>;
-}
-
-.message_control_button {
-    padding:0px;
-    margin:0px;
-}
-.message_control_buttons {
-    text-align: <?php echo SQM_ALIGN_LEFT; ?>;
-    font-size:10px;		/* replaces <small> tags to allow greater control of fonts w/ using an id. */
-}
-.message_control_delete {
-    text-align: <?php echo SQM_ALIGN_RIGHT; ?>;
-    font-size:10px;		/* replaces <small> tags to allow greater control of fonts w/ using an id. */
-}
-.message_control_move {
-    text-align: <?php echo SQM_ALIGN_RIGHT; ?>;
-    font-size:10px;		/* replaces <small> tags to allow greater control of fonts w/ using an id. */
-}
-
-.spacer	{
-    height:5px;
-    background: <?php echo $color[4]; ?>;
-}
-
-

+ 75 - 0
templates/default_advanced/stylesheet_advanced.tpl

@@ -0,0 +1,75 @@
+<?php
+/**
+ * SquirrelMail CSS template for additional definitions needed by the advanced
+ * template
+ *
+ * Template is used by style.php script to generate css file used by
+ * SquirrelMail scripts.
+ *
+ * Available constants
+ *
+ * Color codes used by selected theme:
+ * <ul>
+ *   <li>SQM_BACKGROUND - background color
+ *   <li>SQM_BACKGROUND_LEFT - background of folder tree
+ *   <li>SQM_TEXT_STANDARD - text color
+ *   <li>SQM_TEXT_STANDARD_LEFT - text color of folder tree
+ *   <li>SQM_LINK - color of links
+ *   <li>SQM_LINK_LEFT - color of links in folder tree
+ *   <li>SQM_TEXT_SPECIAL - color of special folder links in folder tree
+ *   <li>todo: other constants should be documented here
+ * </ul>
+ *
+ * Optional template variables
+ * <ul>
+ *   <li>fontfamily - string with list of fonts used by selected style.
+ *   <li>fontsize - integer with selected font size value.
+ * </ul>
+ * Variables are set to empty string, when value is not set.
+ *
+ * @copyright &copy; 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: <?php echo SQM_TEXT_HIGHLIGHT; ?>;
+}
+.dtree a.nodeSel {
+    color: <?php echo SQM_TEXT_HIGHLIGHT; ?>;
+}
+.dtree .clip {
+    overflow: hidden;
+}

+ 12 - 1
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'
+                                );
 ?>