$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:
$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 (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;
}
}
// 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;
}
-
-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'];
}
/* 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
- $template_themes = $oTemplate->get_alternative_stylesheets();
+ $template_themes = $oTemplate->get_alternative_stylesheets(true);
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;
- $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) {
}
+ /**
+ * 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);
}
$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;
}
- $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)