[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squirrelmail-cvs
Subject:    [SM-CVS] CVS: squirrelmail/include/options display.php,1.66,1.67
From:       Steve Brown <stevetruckstuff () users ! sourceforge ! net>
Date:       2006-09-30 10:37:51
Message-ID: E1GTcEB-0002Us-AJ () sc8-pr-cvs8 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/squirrelmail/squirrelmail/include/options
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv9593/include/options

Modified Files:
	display.php 
Log Message:
Add support for user-provided alternate stylesheets

Index: display.php
===================================================================
RCS file: /cvsroot/squirrelmail/squirrelmail/include/options/display.php,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -w -r1.66 -r1.67
--- display.php	29 Sep 2006 22:14:26 -0000	1.66
+++ display.php	30 Sep 2006 10:37:49 -0000	1.67
@@ -16,6 +16,11 @@
 define('SMOPT_GRP_MAILBOX', 1);
 define('SMOPT_GRP_MESSAGE', 2);
 
+/**
+ * Icon themes and user CSS themes should probably both be moved to conf.pl
+ * 
+ * TODO: move to conf.pl
+ **/
 // load icon themes if in use
 global $use_icons;
 if ($use_icons) {
@@ -32,6 +37,19 @@
     }
 }
 
+// load user-provided CSS themes
+global $css_themes;
+$dirName = SM_PATH . 'css';
+if (is_readable($dirName) && is_dir($dirName)) {
+    $d = dir($dirName);
+    while($dir = $d->read()) {
+        if ($dir != "." && $dir != "..") {
+            if (is_dir($dirName."/".$dir) && file_exists("$dirName/$dir/config.php"))
+                include("$dirName/$dir/config.php");
+        }
+    }
+}
+
 global $use_iframe;
 if (! isset($use_iframe)) $use_iframe=false;
 
@@ -51,7 +69,8 @@
 function load_optpage_data_display() {
     global $theme, $fontsets, $language, $languages,$aTemplateSet,
     $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
-    $show_alternative_names, $use_icons, $use_iframe, $sTemplateID;
+    $show_alternative_names, $use_icons, $use_iframe, $sTemplateID, 
+    $oTemplate, $css_themes;
 
     /* Build a simple array into which we will build options. */
     $optgrps = array();
@@ -86,36 +105,47 @@
     }
 
     /* Load the theme option. */
+
+    /**
+     * User themes start with a 'u_', template themes start with a 't_' to
+     * differentiate which is which.  This seems kind of hackish, but we can
+     * come up with a better solution later.
+     * 
+     * TODO: Clean me.
+     **/
     $theme_values = array();
+    
+    // Always provide the template default first.
+    $theme_values['none'] = 'Template Default Theme';
+
     // List alternate themes provided by templates first
-#    var_dump(Template::get_template_file_directory());
-    #list_files
-    foreach ($theme as $theme_key => $theme_attributes) {
-        $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
+/*
+ * Since this requires mods to the template class, I'm holding off on alternate
+ * template styles until Paul finishes template inheritence.
+ *      -- SB, 2006-09-30
+ * 
+    $template_provided = $oTemplate->get_alternative_stylesheets();
+    asort($template_provided);
+    foreach ($template_provided as $sheet=>$name) {
+        $theme_values['t_'.$sheet] = 'Template Theme - '.htmlspecialchars($name);
+    }
+*/
+    // Next, list styles provided in SM_PATH/css/
+    // FIXME, these should probably be defined in conf.pl!!
+    asort($css_themes);
+    foreach ($css_themes as $style) {
+        $theme_values['u_'.$style['PATH']] = 'User Theme - '.htmlspecialchars($style['NAME']);
     }
-    ksort($theme_values);
-    $theme_values = array_flip($theme_values);
+
     $optvals[SMOPT_GRP_GENERAL][] = array(
         'name'    => 'chosen_theme',
         'caption' => _("Theme"),
         'type'    => SMOPT_TYPE_STRLIST,
         'refresh' => SMOPT_REFRESH_ALL,
         'posvals' => $theme_values,
-        'save'    => 'save_option_theme'
+        'save'    => 'css_theme_save'
     );
 
-    $css_values = array( 'none' => _("Default" ) );
-    $css_dir = SM_PATH . 'themes/css';
-    if (is_readable($css_dir) && is_dir($css_dir)) {
-        $handle=opendir($css_dir);
-        while ($file = readdir($handle) ) {
-            if ( substr( $file, -4 ) == '.css' ) {
-                $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
-            }
-        }
-        closedir($handle);
-    }
-
     /* Icon theme selection */
     if ($use_icons) {
         global $icon_themes, $icon_theme;
@@ -492,3 +522,23 @@
        setPref($data_dir, $username, 'icon_theme', 'none');
 
 }
+
+function css_theme_save ($option) {
+    global $css_themes, $data_dir, $username;
+
+    // Don't assume the new value is there, double check
+    // and only save if found
+    //
+    $found = false;
+    reset($css_themes);
+    while (!$found && (list($index, $data) = each($css_themes))) {
+        if ('u_'.$data['PATH'] == $option->new_value)
+            $found = true;
+    }
+    if ($found)
+        setPref($data_dir, $username, 'chosen_theme', $option->new_value);
+    else
+       setPref($data_dir, $username, 'chosen_theme', 'none');
+}
+
+


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
--
squirrelmail-cvs mailing list
List Address: squirrelmail-cvs@lists.sourceforge.net
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
http://squirrelmail.org/cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic