Misc template changs
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 28 Sep 2006 14:55:00 +0000 (14:55 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 28 Sep 2006 14:55:00 +0000 (14:55 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11759 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/left_main.php
src/signout.php
src/style.php

index ed5ed23d7c8af5a02158e243c194bfa64a66b941..4e8e7089104d65e6e455c563433cd5f4631b0815 100644 (file)
@@ -53,7 +53,7 @@ if (!empty($left_refresh) &&
 /**
  * Include extra javascript files needed by template
  */
-$js_includes = $oTemplate->getJavascriptIncludes();
+$js_includes = $oTemplate->get_javascript_includes(TRUE);
 foreach ($js_includes as $js_file) {
     $xtra .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
 }
@@ -192,8 +192,10 @@ $oTemplate->assign('mailboxes', $mailbox_structure);
  */
 $settings = array();
 #$settings['imapConnection'] = $imapConnection;
+//FIXME: I think this is already included in all templates by init.php
 $settings['iconThemePath'] = $icon_theme_path;
-$settings['templateDirectory'] = $sTplDir;
+//FIXME: I think this is already included in all templates by init.php
+$settings['templateID'] = $sTemplateID;
 $settings['unreadNotificationEnabled'] = $unseen_notify!=1;
 $settings['unreadNotificationAllFolders'] = $unseen_notify == 3;
 $settings['unreadNotificationDisplayTotal'] = $unseen_type == 2;
@@ -207,4 +209,4 @@ $oTemplate->display('left_main.tpl');
 
 sqimap_logout($imapConnection);
 $oTemplate->display('footer.tpl');
-?>
\ No newline at end of file
+?>
index 621f8b9ac1b995d3e7676fe8472cd03707e1da87..15a7b644400362d9e4b550fb06cf09eb939ffdcb 100644 (file)
@@ -49,16 +49,17 @@ if ($signout_page) {
 /* After a reload of signout.php, $oTemplate might not exist anymore.
  * Recover, so that we don't get all kinds of errors in that situation. */
 if ( !isset($oTemplate) || !is_object($oTemplate) ) {
-    require_once(SM_PATH . 'class/template/template.class.php');
-    $aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
+    require_once(SM_PATH . 'class/template/Template.class.php');
+    $aTemplateSet = (!isset($aTemplateSet) || !is_array($aTemplateSet) 
+                     ? array() : $aTemplateSet);
     $templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
 
-    $sTplDir = !isset($aTemplateSet[$templateset_default]['PATH']) ? SM_PATH . 'templates/default/' : $aTemplateSet[$templateset_default]['PATH'];
-    $icon_theme_path = !$use_icons ? NULL : $sTplDir . 'images/';
-    $oTemplate = new Template($sTplDir);
+    $sTemplateID = !isset($aTemplateSet[$templateset_default]['ID']) ? 'default' : $aTemplateSet[$templateset_default]['ID'];
+    $icon_theme_path = !$use_icons ? NULL : Template::calculate_template_images_directory($sTemplateID);
+    $oTemplate = Template::construct_template($sTemplateID);
 
     // We want some variables to always be available to the template
-    $always_include = array('sTplDir', 'icon_theme_path');
+    $always_include = array('sTemplateID', 'icon_theme_path');
     foreach ($always_include as $var) {
         $oTemplate->assign($var, (isset($$var) ? $$var : NULL));
     }
index 303077d979b84a35be437c1431c6580b257f6b9a..2c5575a4bbb8f00d4b837d52e1e46b9442f7c8b1 100644 (file)
@@ -1,12 +1,15 @@
 <?php
+
 /**
  * Style sheet script
  *
- * Script processes GET arguments and generates CSS output from stylesheet.tpl.
+ * Script processes GET arguments and generates CSS output from stylesheet.tpl,
+ * which is defined in each template set.
+ *
  * Used GET arguments:
  * <ul>
  *   <li>themeid - string, sets theme file from themes/*.php
- *   <li>templatedir - string, sets template directory from templates/
+ *   <li>templateid - string, sets template set ID
  *   <li>fontset - string, sets selected set of fonts from $fontsets array.
  *   <li>fontsize - integer, sets selected font size
  *   <li>dir - string, sets text direction variables. Possible values 'rtl' or 'ltr'
@@ -160,20 +163,28 @@ $oTemplate->assign('fontsize', $fontsize);
 /**
  * GOTCHA #1: When sending the headers for caching, we must send Expires,
  *            Last-Modified, Pragma, and Cache-Control headers.  If we don't PHP 
- *            weill makeup values that will break the cacheing.
+ *            will makeup values that will break the cacheing.
  * 
  * GOTCHA #2: If the current template does not contain a template named
  *            stylesheet.tpl, this cacheing will break because filemtime() won't
  *            work.  This is a problem e.g. with the default_advanced template
  *            that inherits CSS properties from the default template but
  *            doesn't contain stylesheet.tpl itself.
+IDEA: So ask the Template class object to return the mtime or better yet, the full file path (at least from SM_PATH) by using $oTemplate->get_template_file_path(stylesheet.tpl) but this is still a problem if the default template also does not have such a file (in which case, we fall back to SM's css/deafult css file (so in that case, go get that file's mtime!)
  *            Possibly naive suggestion - template can define its own default 
  *            template name
  * 
+ * GOTCHA #3: If the user changes user prefs for things like font size then
+ *            the mtime should be updated to the time of that change, and not
+ *            that of the stylesheet.tpl file.  IDEA: can this be a value kept
+ *            in user prefs (always compare to actual file mtime before sending
+ *            to the browser)
+ *
  * TODO: Fix this. :)
  **/
 header('Content-Type: text/css');
-if ( $lastmod = @filemtime(getcwd() .'/'. $oTemplate->template_dir . 'stylesheet.tpl') ) {
+if ( $lastmod = @filemtime(SM_PATH . $oTemplate->get_template_file_directory() 
+                         . 'css/stylesheet.tpl') ) {
     $gmlastmod = gmdate('D, d M Y H:i:s', $lastmod) . ' GMT';
     $expires = gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT';
     header('Last-Modified: ' . $gmlastmod);
@@ -181,12 +192,5 @@ if ( $lastmod = @filemtime(getcwd() .'/'. $oTemplate->template_dir . 'stylesheet
     header('Pragma: ');
     header('Cache-Control: public, must-revalidate');
 }
-$oTemplate->display('stylesheet.tpl');
+$oTemplate->display('css/stylesheet.tpl');
 
-/**
- * Include any additional stylesheets provided by the template
- */
-$template_css = $oTemplate->getAdditionalStyleSheets();
-foreach ($template_css as $stylesheet) {
-    $oTemplate->display($stylesheet);
-}