Use paths for user/template themes rather than u_ and t_ prefixes.
authorstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 9 Oct 2006 20:56:38 +0000 (20:56 +0000)
committerstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 9 Oct 2006 20:56:38 +0000 (20:56 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11893 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/page_header.php
include/load_prefs.php
include/options/display.php

index e6a6cf3d8c70d34c391ba61ba9ec269a3a95605e..74456be4db92cc2675bd6c986e2f92c22d95aabf 100644 (file)
@@ -50,7 +50,7 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE
 
     $used_fontset = (!empty($chosen_fontset) ? $chosen_fontset : $default_fontset);
     $used_fontsize = (!empty($chosen_fontsize) ? $chosen_fontsize : $default_fontsize);
 
     $used_fontset = (!empty($chosen_fontset) ? $chosen_fontset : $default_fontset);
     $used_fontsize = (!empty($chosen_fontsize) ? $chosen_fontsize : $default_fontsize);
-    $used_theme = !isset($chosen_theme) && $user_theme_default != 'none' ?  'u_'.$user_themes[$user_theme_default]['PATH'] : $chosen_theme_path;
+    $used_theme = !isset($chosen_theme) && $user_theme_default != 'none' ?  $user_themes[$user_theme_default]['PATH'].'/default.css' : $chosen_theme_path;
     
     /**
      * Stylesheets are loaded in the following order:
     
     /**
      * Stylesheets are loaded in the following order:
@@ -70,27 +70,19 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE
     $aUserStyles = array();
 
     // 2. Option user-defined stylesheet from preferences.
     $aUserStyles = array();
 
     // 2. Option user-defined stylesheet from preferences.
-// FIXME: the following user pref ("sUserStyle"; rename as necessary) will have to be populated by the display prefs screen from a widget similar to the color themes widget (which it replaces) where its values should be full relative paths (from SM_PATH) to the selected css "themes" (either in template css/alternates dir or SM_PATH/css/alternates dir)
-// FIXME: uhhh, getPref() is not available yet here.  (at least on login page) Ugh.  Nor has load_prefs been included yet -- how do we fix this?
-//    $aUserStyles[] = getPref($data_dir, $username, 'sUserStyle', '');
-// Steve, can you please document what u_ means?  Will it work with the
-// new template inheritance system and auto-detection of alternate sheets?
-/**
- * Stylesheets beginning with a "u_" == user provided stylesheets, e.g. those
- * in SM_PATH/css/.  Template provided stylesheets (TEMPLATE_DIR/css/alternatives/)
- * should begin with 't_'.  This was the initial path I took to get it working 
- * since I wasn't sure what mods to the Template class would be used to handle
- * template-provided alt stylesheets.
- * 
- * TODO: Re-evaluate this naming convetion.
- */
-#    var_dump($used_theme);
     if (!empty($used_theme)) {
     if (!empty($used_theme)) {
-        if (substr($used_theme, 0, 2) == 'u_') {
-            $aUserStyles[] = substr($used_theme, 2) .'/default.css';
-        } elseif (substr($used_theme, 0, 2) == 't_') {
-            $aUserStyles[] = SM_PATH . $oTemplate->get_template_file_directory().'css/alternates/'.substr($used_theme, 2);
-#            $aUserStyles[] = substr($used_theme, 2);
+        /**
+         * User styles just point to a directory, so we need to include all .css
+         * files in that directory.  Template themes point to a specific stylesheet,
+         * so we simply include it. 
+         */
+        if (is_dir($used_theme)) {
+            $styles = list_files($used_theme, '.css');
+            foreach ($styles as $sheet) { 
+                $aUserStyles[] = $used_theme .'/'.$sheet;
+            }
+        } else {
+            $aUserStyles[] = $used_theme;
         }
     }
 
         }
     }
 
index 63187aa888786cc76d9226b8e3aa29302c2d791a..df1ab405af208def3afe0e452b36007d45872cba 100644 (file)
@@ -65,54 +65,23 @@ $chosen_theme_path = empty($chosen_theme) ?
 // Make sure the chosen theme is a legitimate one.
 // need to adjust $chosen_theme path with SM_PATH 
 $chosen_theme_path = preg_replace("/(\.\.\/){1,}/", SM_PATH, $chosen_theme_path);
 // Make sure the chosen theme is a legitimate one.
 // need to adjust $chosen_theme path with SM_PATH 
 $chosen_theme_path = preg_replace("/(\.\.\/){1,}/", SM_PATH, $chosen_theme_path);
-$k = 0;
-while (!$found_theme && $k < count($user_themes)) {
-    if ('u_'.$user_themes[$k]['PATH'] == $chosen_theme_path)
-        $found_theme = true;
-    $k++;
-}
-$template_themes = $oTemplate->get_alternative_stylesheets();
-while (!$found_theme && (list($path, $name) = each($template_themes))) {
-    if ('t_'.$path == $chosen_theme_path)
+while (!$found_theme && (list($index, $data) = each($user_themes))) {
+    if ($data['PATH'] == $chosen_theme_path)
         $found_theme = true;
 }
         $found_theme = true;
 }
-    
-if (!$found_theme || $chosen_theme == 'none') {
-    $chosen_theme_path = NULL;
-}
-
-/* ----- SB: Holding on to the following code incase I need to reference later.  
-       Will remove eventually. :)
-   
-$theme = ( !isset($theme) ? array() : $theme );
-$color = ( !isset($color) ? array() : $color );
-
-$chosen_theme = getPref($data_dir, $username, 'chosen_theme');
-$found_theme = false;
 
 
-// need to adjust $chosen_theme path with SM_PATH 
-$chosen_theme = preg_replace("/(\.\.\/){1,}/", SM_PATH, $chosen_theme);
-
-for ($i = 0; $i < count($theme); ++$i){
-    if ($theme[$i]['PATH'] == $chosen_theme) {
-        $found_theme = true;
-        break;
+if (!$found_theme) {
+    $template_themes = $oTemplate->get_alternative_stylesheets(true);
+    while (!$found_theme && (list($path, $name) = each($template_themes))) {
+        if ($path == $chosen_theme_path)
+            $found_theme = true;
     }
 }
 
     }
 }
 
-$chosen_theme = (!$found_theme ? '' : $chosen_theme);
-
-if (isset($chosen_theme) && $found_theme && (file_exists($chosen_theme))) {
-    @include_once($chosen_theme);
-} else {
-    if (isset($theme) && isset($theme[$theme_default]) && file_exists($theme[$theme_default]['PATH'])) {
-        @include_once($theme[$theme_default]['PATH']);
-        $chosen_theme = $theme[$theme_default]['PATH'];
-    }
+if (!$found_theme || $chosen_theme == 'none') {
+    $chosen_theme_path = NULL;
 }
 
 }
 
------- */
-
 // user's icon theme, if using icons
 $icon_theme = getPref($data_dir, $username, 'icon_theme');
 $default_icon_theme = $icon_themes[$icon_theme_def]['PATH'];
 // user's icon theme, if using icons
 $icon_theme = getPref($data_dir, $username, 'icon_theme');
 $default_icon_theme = $icon_themes[$icon_theme_def]['PATH'];
index a519de42f35a1a06b6b17e021a0a8ef05efe4944..6f1309e3f025b28c982af2c314a4c5e6071a4931 100644 (file)
@@ -72,36 +72,23 @@ function load_optpage_data_display() {
     }
 
     /* Load the theme option. */
     }
 
     /* 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.
-PL: No need for the prefixes.  Just use full paths, no?
-
-SB: Don't think so.  If the user chooses a template theme than changes the 
-    path to the template, it would error out, right?  Or should we worry about
-    that?
-     * 
-     * 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
     $theme_values = array();
     
     // Always provide the template default first.
     $theme_values['none'] = 'Template Default Theme';
 
     // List alternate themes provided by templates first
-    $template_themes = $oTemplate->get_alternative_stylesheets();
+    $template_themes = $oTemplate->get_alternative_stylesheets(true);
     asort($template_themes);
     foreach ($template_themes as $sheet=>$name) {
     asort($template_themes);
     foreach ($template_themes as $sheet=>$name) {
-        $theme_values['t_'.$sheet] = 'Template Theme - '.htmlspecialchars($name);
+        $theme_values[$sheet] = 'Template Theme - '.htmlspecialchars($name);
     }
     // Next, list user-provided styles
     asort($user_themes);
     foreach ($user_themes as $style) {
         if ($style['PATH'] == 'none')
             continue;
     }
     // Next, list user-provided styles
     asort($user_themes);
     foreach ($user_themes as $style) {
         if ($style['PATH'] == 'none')
             continue;
-        $theme_values['u_'.$style['PATH']] = 'User Theme - '.htmlspecialchars($style['NAME']);
+        $theme_values[$style['PATH']] = 'User Theme - '.htmlspecialchars($style['NAME']);
     }
 
     if (count($user_themes) + count($template_themes) > 1) {
     }
 
     if (count($user_themes) + count($template_themes) > 1) {
@@ -447,6 +434,10 @@ function save_option_template($option) {
 
     }
 
 
     }
 
+    /**
+     * TODO: If the template changes and we are using a template provided theme
+     * ($user_theme), do we want to reset $user_theme?
+     */
     /* Save the option like normal. */
     save_option($option);
 }
     /* Save the option like normal. */
     save_option($option);
 }
@@ -488,14 +479,16 @@ function css_theme_save ($option) {
     $found = false;
     reset($user_themes);
     while (!$found && (list($index, $data) = each($user_themes))) {
     $found = false;
     reset($user_themes);
     while (!$found && (list($index, $data) = each($user_themes))) {
-        if ('u_'.$data['PATH'] == $option->new_value)
+        if ($data['PATH'] == $option->new_value)
             $found = true;
     }
     
             $found = true;
     }
     
-    $template_themes = $oTemplate->get_alternative_stylesheets();
-    foreach ($template_themes as $path=>$name) {
-        if ('t_'.$path == $option->new_value)
-            $found = true;
+    if (!$found) {
+        $template_themes = $oTemplate->get_alternative_stylesheets(true);
+        while (!$found && (list($path, $name) = each($template_themes))) {
+            if ($path == $option->new_value)
+                $found = true;
+        }
     }
     
     if (!$found)
     }
     
     if (!$found)