Add support for tempalte-provided themes.
authorstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 3 Oct 2006 15:30:53 +0000 (15:30 +0000)
committerstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 3 Oct 2006 15:30:53 +0000 (15:30 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11820 7612ce4b-ef26-0410-bec9-ea0150e637f0

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

index 9c4e9365248b1275017c579eb6c875b20bad959d..a30fa38748ed7f17a86aec68998496aaf1a2deb1 100644 (file)
@@ -84,14 +84,22 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE
  * 
  * TODO: Re-evaluate this naming convetion.
  */
  * 
  * TODO: Re-evaluate this naming convetion.
  */
-    if (!empty($used_theme) && substr($used_theme, 0, 2) == 'u_') {
-        $aUserStyles[] = substr($used_theme, 2) .'default.css';
+#    var_dump($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);
+        }
     }
 
     // 3. src/style.php
     $aUserStyles[] = $base_uri .'src/style.php?'
                    . (!empty($used_fontset) ? '&amp;fontset='.$used_fontset : '')
                    . (!empty($used_fontsize) ? '&amp;fontsize='.$used_fontsize : '');
     }
 
     // 3. src/style.php
     $aUserStyles[] = $base_uri .'src/style.php?'
                    . (!empty($used_fontset) ? '&amp;fontset='.$used_fontset : '')
                    . (!empty($used_fontsize) ? '&amp;fontsize='.$used_fontsize : '');
+
+    // 3.1.  Load the stylesheets we have already  
     $header_tags .= $oTemplate->fetch_external_stylesheet_links($aUserStyles);
 
     // 4. Optional rtl.css stylesheet
     $header_tags .= $oTemplate->fetch_external_stylesheet_links($aUserStyles);
 
     // 4. Optional rtl.css stylesheet
index 8a68404d7709727a15023d9a9c4525eaea8935de..d49e83b9a30b6e2514aa670a611d3ff3ee7396ae 100644 (file)
@@ -66,6 +66,21 @@ while (!$found_theme && $k < count($user_themes)) {
         $found_theme = true;
     $k++;
 }
         $found_theme = true;
     $k++;
 }
+/**
+ * $oTemplate is not instantiated when this is called, so we need to devise
+ * a method of fething a list of tempalte-provided alt stylesheets to validate
+ * against.  For now, we assume that it is always found.
+ * 
+ * FIXME: fix this.
+ */
+#$template_themes = $oTemplate->get_alternative_stylesheets();
+#while (!$found_theme && (list($path, $name) = each($template_themes))) {
+#    if ('t_'.$path == $chosen_theme_path)
+#        $found_theme = true;
+#}
+if (substr($chosen_theme, 0, 2) == 't_')
+    $found_theme = true;
+    
 if (!$found_theme || $chosen_theme == 'none') {
     $chosen_theme_path = NULL;
 }
 if (!$found_theme || $chosen_theme == 'none') {
     $chosen_theme_path = NULL;
 }
index caa1ab9f3e0fc01eb2221ae67ee1a4e740c1e05d..a519de42f35a1a06b6b17e021a0a8ef05efe4944 100644 (file)
@@ -91,19 +91,12 @@ SB: Don't think so.  If the user chooses a template theme than changes the
     $theme_values['none'] = 'Template Default Theme';
 
     // List alternate themes provided by templates first
     $theme_values['none'] = 'Template Default Theme';
 
     // List alternate themes provided by templates first
-    $template_themes = array();
-/*
- * 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_themes = $oTemplate->get_alternative_stylesheets();
     $template_themes = $oTemplate->get_alternative_stylesheets();
-    asort($template_provided);
-    foreach ($template_provided as $sheet=>$name) {
+    asort($template_themes);
+    foreach ($template_themes as $sheet=>$name) {
         $theme_values['t_'.$sheet] = 'Template Theme - '.htmlspecialchars($name);
     }
         $theme_values['t_'.$sheet] = 'Template Theme - '.htmlspecialchars($name);
     }
-*/
-    // Next, list styles provided in SM_PATH/css/
+    // Next, list user-provided styles
     asort($user_themes);
     foreach ($user_themes as $style) {
         if ($style['PATH'] == 'none')
     asort($user_themes);
     foreach ($user_themes as $style) {
         if ($style['PATH'] == 'none')
@@ -470,12 +463,11 @@ function save_option_javascript_autodetect($option) {
  * This function saves the user's icon theme setting
  */
 function icon_theme_save($option) {
  * This function saves the user's icon theme setting
  */
 function icon_theme_save($option) {
-    global $icon_themes, $data_dir, $username;
+    global $icon_themes;
 
 
     // Don't assume the new value is there, double check
     // and only save if found
 
 
     // Don't assume the new value is there, double check
     // and only save if found
-    //
     $found = false;
     while (!$found && (list($index, $data) = each($icon_themes))) {
         if ($data['PATH'] == $option->new_value)
     $found = false;
     while (!$found && (list($index, $data) = each($icon_themes))) {
         if ($data['PATH'] == $option->new_value)
@@ -489,21 +481,27 @@ function icon_theme_save($option) {
 }
 
 function css_theme_save ($option) {
 }
 
 function css_theme_save ($option) {
-    global $user_themes, $data_dir, $username;
+    global $user_themes, $oTemplate;
 
     // Don't assume the new value is there, double check
     // and only save if found
 
     // Don't assume the new value is there, double check
     // and only save if found
-    //
     $found = false;
     reset($user_themes);
     while (!$found && (list($index, $data) = each($user_themes))) {
         if ('u_'.$data['PATH'] == $option->new_value)
             $found = true;
     }
     $found = false;
     reset($user_themes);
     while (!$found && (list($index, $data) = each($user_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');
+    
+    $template_themes = $oTemplate->get_alternative_stylesheets();
+    foreach ($template_themes as $path=>$name) {
+        if ('t_'.$path == $option->new_value)
+            $found = true;
+    }
+    
+    if (!$found)
+        $option->new_value = 'none';
+        
+    save_option($option);
 }
 
 
 }