From: stevetruckstuff Date: Tue, 3 Oct 2006 15:30:53 +0000 (+0000) Subject: Add support for tempalte-provided themes. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=f9376f0b37df5d02614e286640e4d0b296c27a08 Add support for tempalte-provided themes. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11820 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/page_header.php b/functions/page_header.php index 9c4e9365..a30fa387 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -84,14 +84,22 @@ function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE * * 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) ? '&fontset='.$used_fontset : '') . (!empty($used_fontsize) ? '&fontsize='.$used_fontsize : ''); + + // 3.1. Load the stylesheets we have already $header_tags .= $oTemplate->fetch_external_stylesheet_links($aUserStyles); // 4. Optional rtl.css stylesheet diff --git a/include/load_prefs.php b/include/load_prefs.php index 8a68404d..d49e83b9 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -66,6 +66,21 @@ while (!$found_theme && $k < count($user_themes)) { $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; } diff --git a/include/options/display.php b/include/options/display.php index caa1ab9f..a519de42 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -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 - $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(); - 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); } -*/ - // 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') @@ -470,12 +463,11 @@ function save_option_javascript_autodetect($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 - // $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) { - 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 - // $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); }