Merge PR #839 branch 'p/ticket/10743' into develop

* p/ticket/10743:
  [ticket/10743] Renaming user->theme
  [ticket/10743] Changing obtain_cfg_items
This commit is contained in:
Oleg Pudeyev 2012-06-11 20:33:11 -04:00
commit 436ade19fc
5 changed files with 47 additions and 61 deletions

View file

@ -130,7 +130,7 @@ class bbcode
if (empty($this->template_filename)) if (empty($this->template_filename))
{ {
$this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
$style_resource_locator = new phpbb_style_resource_locator(); $style_resource_locator = new phpbb_style_resource_locator();
$style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());

View file

@ -321,19 +321,11 @@ class phpbb_cache_service
/** /**
* Obtain cfg file data * Obtain cfg file data
*/ */
function obtain_cfg_items($theme) function obtain_cfg_items($style)
{ {
global $config, $phpbb_root_path; global $config, $phpbb_root_path;
$parsed_items = array( $parsed_array = $this->driver->get('_cfg_' . $style['style_path']);
'theme' => array(),
'template' => array(),
'imageset' => array()
);
foreach ($parsed_items as $key => $parsed_array)
{
$parsed_array = $this->driver->get('_cfg_' . $key . '_' . $theme[$key . '_path']);
if ($parsed_array === false) if ($parsed_array === false)
{ {
@ -341,7 +333,7 @@ class phpbb_cache_service
} }
$reparse = false; $reparse = false;
$filename = $phpbb_root_path . 'styles/' . $theme[$key . '_path'] . '/' . $key . '/' . $key . '.cfg'; $filename = $phpbb_root_path . 'styles/' . $style['style_path'] . '/style.cfg';
if (!file_exists($filename)) if (!file_exists($filename))
{ {
@ -359,12 +351,9 @@ class phpbb_cache_service
$parsed_array = parse_cfg_file($filename); $parsed_array = parse_cfg_file($filename);
$parsed_array['filetime'] = @filemtime($filename); $parsed_array['filetime'] = @filemtime($filename);
$this->driver->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array); $this->driver->put('_cfg_' . $style['style_path'], $parsed_array);
} }
$parsed_items[$key] = $parsed_array; return $parsed_array;
}
return $parsed_items;
} }
/** /**

View file

@ -4772,9 +4772,9 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'T_ASSETS_VERSION' => $config['assets_version'], 'T_ASSETS_VERSION' => $config['assets_version'],
'T_ASSETS_PATH' => "{$web_path}assets", 'T_ASSETS_PATH' => "{$web_path}assets",
'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme', 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme',
'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template',
'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template',
'T_IMAGES_PATH' => "{$web_path}images/", 'T_IMAGES_PATH' => "{$web_path}images/",
'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/",
'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/",
@ -4782,16 +4782,16 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/",
'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/",
'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/",
'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'],
'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'],
'T_STYLESHEET_NAME' => $user->theme['style_name'], 'T_STYLESHEET_NAME' => $user->style['style_name'],
'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js?assets_version=" . $config['assets_version'], 'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js?assets_version=" . $config['assets_version'],
'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false,
'T_THEME_NAME' => rawurlencode($user->theme['style_path']), 'T_THEME_NAME' => rawurlencode($user->style['style_path']),
'T_THEME_LANG_NAME' => $user->data['user_lang'], 'T_THEME_LANG_NAME' => $user->data['user_lang'],
'T_TEMPLATE_NAME' => $user->theme['style_path'], 'T_TEMPLATE_NAME' => $user->style['style_path'],
'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->theme['style_parent_tree']) && $user->theme['style_parent_tree']) ? $user->theme['style_parent_tree'] : $user->theme['style_path']), 'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->style['style_parent_tree']) && $user->style['style_parent_tree']) ? $user->style['style_parent_tree'] : $user->style['style_path']),
'T_IMAGES' => 'images', 'T_IMAGES' => 'images',
'T_SMILIES' => $config['smilies_path'], 'T_SMILIES' => $config['smilies_path'],
'T_AVATAR' => $config['avatar_path'], 'T_AVATAR' => $config['avatar_path'],

View file

@ -89,8 +89,8 @@ class phpbb_style
*/ */
public function set_style() public function set_style()
{ {
$style_name = $this->user->theme['style_path']; $style_name = $this->user->style['style_path'];
$style_dirs = ($this->user->theme['style_parent_id']) ? array_reverse(explode('/', $this->user->theme['style_parent_tree'])) : array(); $style_dirs = ($this->user->style['style_parent_id']) ? array_reverse(explode('/', $this->user->style['style_parent_tree'])) : array();
$paths = array($this->get_style_path($style_name)); $paths = array($this->get_style_path($style_name));
foreach ($style_dirs as $dir) foreach ($style_dirs as $dir)
{ {

View file

@ -27,7 +27,7 @@ class phpbb_user extends phpbb_session
{ {
var $lang = array(); var $lang = array();
var $help = array(); var $help = array();
var $theme = array(); var $style = array();
var $date_format; var $date_format;
var $timezone; var $timezone;
var $dst; var $dst;
@ -159,11 +159,11 @@ class phpbb_user extends phpbb_session
FROM ' . STYLES_TABLE . " s FROM ' . STYLES_TABLE . " s
WHERE s.style_id = $style_id"; WHERE s.style_id = $style_id";
$result = $db->sql_query($sql, 3600); $result = $db->sql_query($sql, 3600);
$this->theme = $db->sql_fetchrow($result); $this->style = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
// User has wrong style // User has wrong style
if (!$this->theme && $style_id == $this->data['user_style']) if (!$this->style && $style_id == $this->data['user_style'])
{ {
$style_id = $this->data['user_style'] = $config['default_style']; $style_id = $this->data['user_style'] = $config['default_style'];
@ -176,20 +176,17 @@ class phpbb_user extends phpbb_session
FROM ' . STYLES_TABLE . " s FROM ' . STYLES_TABLE . " s
WHERE s.style_id = $style_id"; WHERE s.style_id = $style_id";
$result = $db->sql_query($sql, 3600); $result = $db->sql_query($sql, 3600);
$this->theme = $db->sql_fetchrow($result); $this->style = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
if (!$this->theme) if (!$this->style)
{ {
trigger_error('Could not get style data', E_USER_ERROR); trigger_error('Could not get style data', E_USER_ERROR);
} }
// Now parse the cfg file and cache it // Now parse the cfg file and cache it
$parsed_items = $cache->obtain_cfg_items($this->theme); $parsed_items = $cache->obtain_cfg_items($this->style);
// We are only interested in the theme configuration for now
$parsed_items = $parsed_items['theme'];
$check_for = array( $check_for = array(
'pagination_sep' => (string) ', ' 'pagination_sep' => (string) ', '
@ -197,12 +194,12 @@ class phpbb_user extends phpbb_session
foreach ($check_for as $key => $default_value) foreach ($check_for as $key => $default_value)
{ {
$this->theme[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value; $this->style[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value;
settype($this->theme[$key], gettype($default_value)); settype($this->style[$key], gettype($default_value));
if (is_string($default_value)) if (is_string($default_value))
{ {
$this->theme[$key] = htmlspecialchars($this->theme[$key]); $this->style[$key] = htmlspecialchars($this->style[$key]);
} }
} }