avoid E_STRICT errors
[squirrelmail.git] / src / style.php
index 2c5575a4bbb8f00d4b837d52e1e46b9442f7c8b1..9b9202b9755262c6d7f7da05c546b66b88350408 100644 (file)
  *   <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
+ * @copyright &copy; 2005-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  */
 
-/**
- * Set the location in order to skip unneeded validation and other includes
- * in the SquirrelMail initialisation file.
- */
-$sInitLocation = 'style';
+/** This is the style page */
+define('PAGE_NAME', 'style');
 
 /**
  * Include the SquirrelMail initialization file.
@@ -36,6 +33,13 @@ if (!isset($fontsets) || !is_array($fontsets)) {
     $fontsets=array();
 }
 
+
+/**
+ * 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
@@ -56,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,
@@ -145,21 +128,22 @@ 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);
 
+$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 
@@ -180,9 +164,18 @@ IDEA: So ask the Template class object to return the mtime or better yet, the fu
  *            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. :)
- **/
-header('Content-Type: text/css');
+ */
+
 if ( $lastmod = @filemtime(SM_PATH . $oTemplate->get_template_file_directory() 
                          . 'css/stylesheet.tpl') ) {
     $gmlastmod = gmdate('D, d M Y H:i:s', $lastmod) . ' GMT';
@@ -192,5 +185,37 @@ if ( $lastmod = @filemtime(SM_PATH . $oTemplate->get_template_file_directory()
     header('Pragma: ');
     header('Cache-Control: public, must-revalidate');
 }
-$oTemplate->display('css/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');
+
+/**
+ * Additional styles are now handled by adding stylesheets to 
+ * templates/<template>/css/, so here, we simply define some 
+ * basic styles based on user prefs.
+ */
+?>
+/* older css template */
+body, td, th, dd, dt, h1, h2, h3, h4, h5, h6, p, ol, ul, li {
+<?php
+if($fontfamily) echo '  font-family: '.$fontfamily.";\n";
+?>
+}
+body, small {
+<?php
+if($fontsize) echo '  font-size: '.($fontsize-2)."pt;\n";
+?>
+}
+td, th {
+<?php
+if($fontsize) echo '  font-size: '.$fontsize."pt;\n";
+?>
+}
+textarea, pre {
+font-family: monospace;
+<?php
+if($fontsize) echo '  font-size: '.($fontsize-1)."pt;\n";
+?>
+}