/**
* 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";
}
*/
$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;
sqimap_logout($imapConnection);
$oTemplate->display('footer.tpl');
-?>
\ No newline at end of file
+?>
/* 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));
}
<?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'
/**
* 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);
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);
-}