From 3e6ee6cac3f0661ac3d2ffc516bb5d3be5f8f14f Mon Sep 17 00:00:00 2001 From: pdontthink Date: Thu, 28 Sep 2006 14:55:00 +0000 Subject: [PATCH] Misc template changs git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11759 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/left_main.php | 8 +++++--- src/signout.php | 13 +++++++------ src/style.php | 28 ++++++++++++++++------------ 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/left_main.php b/src/left_main.php index ed5ed23d..4e8e7089 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -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 .= '' ."\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 +?> diff --git a/src/signout.php b/src/signout.php index 621f8b9a..15a7b644 100644 --- a/src/signout.php +++ b/src/signout.php @@ -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)); } diff --git a/src/style.php b/src/style.php index 303077d9..2c5575a4 100644 --- a/src/style.php +++ b/src/style.php @@ -1,12 +1,15 @@ *
  • themeid - string, sets theme file from themes/*.php - *
  • templatedir - string, sets template directory from templates/ + *
  • templateid - string, sets template set ID *
  • fontset - string, sets selected set of fonts from $fontsets array. *
  • fontsize - integer, sets selected font size *
  • 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); -} -- 2.25.1