X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Fstyle.php;h=6b01063446ddb2dcb4fb7e4178f8617a8071d5ec;hp=2f510033e9356c54734f6262003660468e2018a9;hb=1f2f93e6751d2c1b957aa7d197269b5c49df5d72;hpb=6373ad1237c82a561fec8264457e3a3a845f7e87 diff --git a/src/style.php b/src/style.php index 2f510033..6b010634 100644 --- a/src/style.php +++ b/src/style.php @@ -1,28 +1,32 @@ *
  • themeid - string, sets theme file from themes/*.php - *
  • templateid - 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' * - * @copyright © 2005-2006 The SquirrelMail Project Team + * @copyright © 2005-2007 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail */ -/** @ignore */ -define('SM_PATH','../'); +/** This is the style page */ +define('PAGE_NAME', 'style'); -/* SquirrelMail required files. */ -require_once(SM_PATH . 'functions/global.php'); -require_once(SM_PATH . 'functions/strings.php'); -require_once(SM_PATH . 'config/config.php'); +/** + * Include the SquirrelMail initialization file. + */ +require('../include/init.php'); /* safety check for older config.php */ if (!isset($fontsets) || !is_array($fontsets)) { @@ -30,25 +34,12 @@ if (!isset($fontsets) || !is_array($fontsets)) { } -/* template init */ -/** start block copy from right_main.php */ -include_once(SM_PATH . 'class/template/template.class.php'); - /** - * get template name and set used template directory - * - * Existing file check has been moved into the template object, so it is - * not neccesary to do file_exists() here. - * */ -if (sqgetGlobalVar('templateid',$templateid,SQ_GET)) { - $sTplDir = SM_PATH.'templates/'.basename($templateid).'/'; -} else { - $sTplDir = SM_PATH.'templates/default/'; -} - -$oTemplate = new Template($sTplDir); -/** end block copy */ - + * The following code should no longer be neccesary, but it will remain for the + * time being, just in case. + * + * TODO: Remove if no longer needed. + **/ /* set default colors in case color theme is not full */ $color = array(); $color[0] = '#dcdcdc'; // (light gray) TitleBar @@ -69,27 +60,6 @@ $color[14] = '#ff0000'; // (red) Color for quoted text -- >> 2 or mo $color[15] = '#002266'; // (dark blue) Unselectable folders $color[16] = '#ff9933'; // (orange) Highlight color -/** get theme from GET */ -if (sqgetGlobalVar('themeid',$themeid,SQ_GET) && - file_exists(SM_PATH . 'themes/'.basename($themeid,'.php').'.php')) { - include_once(SM_PATH . 'themes/'.basename($themeid,'.php').'.php'); -} elseif (file_exists($theme[$theme_default]['PATH'])) { - include_once($theme[$theme_default]['PATH']); -} - -/** - * Get text direction - */ -if (sqgetGlobalVar('dir',$text_direction,SQ_GET) && - $text_direction == 'rtl') { - $align = array('left' => 'right', 'right' => 'left'); -} else { - $align = array('left' => 'left', 'right' => 'right'); -} - -/**/ -$oTemplate->assign('color', $color); - /** * set color constants in order to use simple names instead of color array * 0 - SQM_TEXT_DISABLED, SQM_TITLE_BACKGROUND, SQM_BUTTON_BACKGROUND_DISABLED, @@ -158,27 +128,98 @@ define('SQM_ERROR_TEXT',$color[2]); define('SQM_ALIGN_LEFT', $align['left']); define('SQM_ALIGN_RIGHT', $align['right']); +// END TODO + if (sqgetGlobalVar('fontset',$fontset,SQ_GET) && isset($fontsets[$fontset])) { $fontfamily=$fontsets[$fontset]; } else { $fontfamily=''; } -$oTemplate->assign('fontfamily', $fontfamily); if (! sqgetGlobalVar('fontsize',$fontsize,SQ_GET)) { $fontsize = 0; } else { $fontsize = (int) $fontsize; } -$oTemplate->assign('fontsize', $fontsize); -header('Content-Type: text/css'); -// output a last-modified header if we can -if ( $lastmod = @filemtime($oTemplate->template_dir . 'stylesheet.tpl') ) { +$oTemplate->header('Content-Type: text/css'); +/** + * GOTCHA #1: When sending the headers for caching, we must send Expires, + * Last-Modified, Pragma, and Cache-Control headers. If we don't PHP + * 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) + * + * Comment re gotcha #3: If we only define basic font prefs here, we really + * only need to refresh the cache if one of the font prefs changes. + * Possibly some type of "force nocache flag could be set if a font pref is + * changed? + * + * Response: Perhaps, if that can be implemented great, but I think the + * user prefs solution would definitely work: catch the font setting change + * in a custom save() routine from user prefs and away we go. + * + * TODO: Fix this. :) + */ + +if ( $lastmod = @filemtime(SM_PATH . $oTemplate->get_template_file_directory() + . 'css/stylesheet.tpl') ) { $gmlastmod = gmdate('D, d M Y H:i:s', $lastmod) . ' GMT'; - header('Last-Modified: ' . $gmlastmod); + $expires = gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT'; + $oTemplate->header('Last-Modified: ' . $gmlastmod); + $oTemplate->header('Expires: '. $expires); + $oTemplate->header('Pragma: '); + $oTemplate->header('Cache-Control: public, must-revalidate'); } -$oTemplate->display('stylesheet.tpl'); +// Steve, why did you remove this? Is it irrelevant now? If so, let's +// remove the rest of the references to it here (note that it is being +// used above in the filetime() statement) and elsewhere +// $oTemplate->display('css/stylesheet.tpl'); +// don't show version as a security measure +//$oTemplate->header('X-Powered-By: SquirrelMail/' . SM_VERSION, FALSE); +$oTemplate->header('X-Powered-By: SquirrelMail', FALSE); + +/** + * Additional styles are now handled by adding stylesheets to + * templates/