Ver Fonte

Misc template changs

pdontthink há 19 anos atrás
pai
commit
fe735f92ef
3 ficheiros alterados com 28 adições e 21 exclusões
  1. 5 3
      src/left_main.php
  2. 7 6
      src/signout.php
  3. 16 12
      src/style.php

+ 5 - 3
src/left_main.php

@@ -53,7 +53,7 @@ if (!empty($left_refresh) &&
 /**
 /**
  * Include extra javascript files needed by template
  * Include extra javascript files needed by template
  */
  */
-$js_includes = $oTemplate->getJavascriptIncludes();
+$js_includes = $oTemplate->get_javascript_includes(TRUE);
 foreach ($js_includes as $js_file) {
 foreach ($js_includes as $js_file) {
     $xtra .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
     $xtra .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
 }
 }
@@ -192,8 +192,10 @@ $oTemplate->assign('mailboxes', $mailbox_structure);
  */
  */
 $settings = array();
 $settings = array();
 #$settings['imapConnection'] = $imapConnection;
 #$settings['imapConnection'] = $imapConnection;
+//FIXME: I think this is already included in all templates by init.php
 $settings['iconThemePath'] = $icon_theme_path;
 $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['unreadNotificationEnabled'] = $unseen_notify!=1;
 $settings['unreadNotificationAllFolders'] = $unseen_notify == 3;
 $settings['unreadNotificationAllFolders'] = $unseen_notify == 3;
 $settings['unreadNotificationDisplayTotal'] = $unseen_type == 2;
 $settings['unreadNotificationDisplayTotal'] = $unseen_type == 2;
@@ -207,4 +209,4 @@ $oTemplate->display('left_main.tpl');
 
 
 sqimap_logout($imapConnection);
 sqimap_logout($imapConnection);
 $oTemplate->display('footer.tpl');
 $oTemplate->display('footer.tpl');
-?>
+?>

+ 7 - 6
src/signout.php

@@ -49,16 +49,17 @@ if ($signout_page) {
 /* After a reload of signout.php, $oTemplate might not exist anymore.
 /* 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. */
  * Recover, so that we don't get all kinds of errors in that situation. */
 if ( !isset($oTemplate) || !is_object($oTemplate) ) {
 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 );
     $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
     // 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) {
     foreach ($always_include as $var) {
         $oTemplate->assign($var, (isset($$var) ? $$var : NULL));
         $oTemplate->assign($var, (isset($$var) ? $$var : NULL));
     }
     }

+ 16 - 12
src/style.php

@@ -1,12 +1,15 @@
 <?php
 <?php
+
 /**
 /**
  * Style sheet script
  * 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:
  * Used GET arguments:
  * <ul>
  * <ul>
  *   <li>themeid - string, sets theme file from themes/*.php
  *   <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>fontset - string, sets selected set of fonts from $fontsets array.
  *   <li>fontsize - integer, sets selected font size
  *   <li>fontsize - integer, sets selected font size
  *   <li>dir - string, sets text direction variables. Possible values 'rtl' or 'ltr'
  *   <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,
  * GOTCHA #1: When sending the headers for caching, we must send Expires,
  *            Last-Modified, Pragma, and Cache-Control headers.  If we don't PHP 
  *            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
  * GOTCHA #2: If the current template does not contain a template named
  *            stylesheet.tpl, this cacheing will break because filemtime() won't
  *            stylesheet.tpl, this cacheing will break because filemtime() won't
  *            work.  This is a problem e.g. with the default_advanced template
  *            work.  This is a problem e.g. with the default_advanced template
  *            that inherits CSS properties from the default template but
  *            that inherits CSS properties from the default template but
  *            doesn't contain stylesheet.tpl itself.
  *            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 
  *            Possibly naive suggestion - template can define its own default 
  *            template name
  *            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. :)
  * TODO: Fix this. :)
  **/
  **/
 header('Content-Type: text/css');
 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';
     $gmlastmod = gmdate('D, d M Y H:i:s', $lastmod) . ' GMT';
     $expires = gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT';
     $expires = gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT';
     header('Last-Modified: ' . $gmlastmod);
     header('Last-Modified: ' . $gmlastmod);
@@ -181,12 +192,5 @@ if ( $lastmod = @filemtime(getcwd() .'/'. $oTemplate->template_dir . 'stylesheet
     header('Pragma: ');
     header('Pragma: ');
     header('Cache-Control: public, must-revalidate');
     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);
-}