Removing login_form hook, plugins can now use template_construct hook and add an...
[squirrelmail.git] / src / style.php
index 1e2334a700a27e5f2a80afcca9c613256710768f..303077d979b84a35be437c1431c6580b257f6b9a 100644 (file)
@@ -6,9 +6,10 @@
  * Used GET arguments:
  * <ul>
  *   <li>themeid - string, sets theme file from themes/*.php
- *   <li>templateid - string, sets template directory from templates/
+ *   <li>templatedir - string, sets template directory from templates/
  *   <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'
  * </ul>
  * @copyright &copy; 2005-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
@@ -32,21 +33,6 @@ if (!isset($fontsets) || !is_array($fontsets)) {
     $fontsets=array();
 }
 
-/**
- *  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 */
-
 /* set default colors in case color theme is not full */
 $color = array();
 $color[0]   = '#dcdcdc'; // (light gray)     TitleBar
@@ -171,11 +157,29 @@ if (! sqgetGlobalVar('fontsize',$fontsize,SQ_GET)) {
 }
 $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.
+ * 
+ * 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.
+ *            Possibly naive suggestion - template can define its own default 
+ *            template name
+ * 
+ * TODO: Fix this. :)
+ **/
 header('Content-Type: text/css');
-// output a last-modified header if we can
-if ( $lastmod = @filemtime($oTemplate->template_dir . 'stylesheet.tpl') ) {
+if ( $lastmod = @filemtime(getcwd() .'/'. $oTemplate->template_dir . '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('Expires: '. $expires);
+    header('Pragma: ');
+    header('Cache-Control: public, must-revalidate');
 }
 $oTemplate->display('stylesheet.tpl');