*
* 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
$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;
}
$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')
* 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)
}
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);
}