rearranged if structures in order to reach footer without extra template code
[squirrelmail.git] / src / style.php
index 7d7976bd0b07c8d817bbd3ea3370ab5660a4a897..5d75f008de8a45eecec5ae3a7f1985c1f76cd2fb 100644 (file)
@@ -6,6 +6,7 @@
  * Used GET arguments:
  * <ul>
  *   <li>themeid - string, sets theme file from themes/*.php
+ *   <li>templateid - string, sets template directory from templates/
  *   <li>fontset - string, sets selected set of fonts from $fontsets array.
  *   <li>fontsize - integer, sets selected font size
  * </ul>
@@ -22,25 +23,25 @@ define('SM_PATH','../');
 require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/strings.php');
 require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'include/load_prefs.php');
-
-/* temp setting containing list of font styles. Should go to config.php */
-$fontsets=array();
-$fontsets['sans']['NAME']='Sans';
-$fontsets['sans']['STYLE']='helvetica,arial,sans-serif';
-$fontsets['serif']['NAME']='Serif';
-$fontsets['serif']['STYLE']='serif';
-$fontsets['comicsans']['NAME']='Comic Sans';
-$fontsets['comicsans']['STYLE']='comic sans ms,sans-serif';
-$fontsets['vera']['NAME']='Vera';
-$fontsets['vera']['STYLE']='bitstream vera sans,verdana,sans-serif';
-$fontsets['tahoma']['NAME']='Tahoma';
-$fontsets['tahoma']['STYLE']='tahoma,sans-serif';
+
+/* safety check for older config.php */
+if (!isset($fontsets) || !is_array($fontsets)) {
+    $fontsets=array();
+}
+
 
 /* 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 */
+if (sqgetGlobalVar('templateid',$templateid,SQ_GET) &&
+    file_exists(SM_PATH.'templates/'.basename($templateid).'/stylesheet.tpl')) {
+    $sTplDir = SM_PATH.'templates/'.basename($templateid).'/';
+} else {
+    $sTplDir = SM_PATH.'templates/default/';
+}
+
 $oTemplate = new Template($sTplDir);
 /** end block copy */
 
@@ -73,6 +74,7 @@ if (sqgetGlobalVar('themeid',$themeid,SQ_GET) &&
 }
 
 /**
+ * TODO: tokul. $languages are not loaded here.
  * get alignment variable from language settings...
  * MOVE THIS to a central init section !!!!
  */
@@ -159,7 +161,7 @@ define('SQM_ALIGN_RIGHT', $align['right']);
 
 if (sqgetGlobalVar('fontset',$fontset,SQ_GET) &&
     isset($fontsets[$fontset])) {
-    $fontfamily=$fontsets[$fontset]['STYLE'];
+    $fontfamily=$fontsets[$fontset];
 } else {
     $fontfamily='';
 }
@@ -173,7 +175,11 @@ if (! sqgetGlobalVar('fontsize',$fontsize,SQ_GET)) {
 $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') ) {
+    $gmlastmod = gmdate('D, d M Y H:i:s', $lastmod) . ' GMT';
+    header('Last-Modified: ' . $gmlastmod);
+}
 $oTemplate->display('stylesheet.tpl');
 
-?>
\ No newline at end of file
+?>