Tweaked so that css files included via @include file("file.css"); are brought into the main stylesheet.css before variable replacement. This greatly improves style organisation by enabling different stylesheets for the main sections of the forum

git-svn-id: file:///svn/phpbb/trunk@5343 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Tom Beddard 2005-12-17 12:05:20 +00:00
parent ab49ea4cae
commit 7a354f9858

View file

@ -74,10 +74,23 @@ if (!empty($_GET['id']) && !empty($_GET['sid']))
}
$db->sql_freeresult($result2);
if ($theme['theme_mtime'] < filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'))
$force_load = true; // Ideally this needs to be based on $config['load_tplcompile']
if ($theme['theme_mtime'] < filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css') || $force_load)
{
$theme['theme_data'] = implode('', file("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'));
// Match CSS imports
preg_match_all('/@import url\(\"(.*)\"\);/i', $theme['theme_data'], $matches);
if ($matches)
{
foreach ($matches[0] as $idx => $match)
{
$theme['theme_data'] = str_replace($match, load_css_file( $matches[1][$idx] ), $theme['theme_data']);
}
}
$db->sql_query("UPDATE {$table_prefix}styles_theme SET theme_data = '" . $db->sql_escape($theme['theme_data']) . "', theme_mtime = " . time() . "
WHERE theme_id = $id");
}
@ -85,14 +98,15 @@ if (!empty($_GET['id']) && !empty($_GET['sid']))
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
header('Content-type: text/css');
// Parse Theme Data
$replace = array(
'{T_THEME_PATH}' => "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme',
'{T_TEMPLATE_PATH}' => "{$phpbb_root_path}styles/" . $theme['template_path'] . '/template',
'{T_IMAGESET_PATH}' => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset',
'{T_TEMPLATE_PATH}' => "{$phpbb_root_path}styles/" . $theme['template_path'] . '/template',
'{T_IMAGESET_PATH}' => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset',
'{T_IMAGESET_LANG_PATH}' => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset/' . $user['user_lang'],
'{T_STYLESHEET_NAME}' => $theme['theme_name'],
'{S_USER_LANG}' => $user['user_lang']
'{S_USER_LANG}' => $user['user_lang']
);
$theme['theme_data'] = str_replace(array_keys($replace), array_values($replace), $theme['theme_data']);
@ -108,4 +122,24 @@ if (!empty($_GET['id']) && !empty($_GET['sid']))
$db->sql_close();
}
function load_css_file($filename)
{
global $phpbb_root_path, $theme;
$handle = "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/' . $filename;
if ($fp = @fopen($handle, 'r'))
{
$content = trim(@fread($fp, filesize($handle)));
@fclose($fp);
}
else
{
$content = '';
}
return $content;
}
?>