mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
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:
parent
ab49ea4cae
commit
7a354f9858
1 changed files with 42 additions and 8 deletions
|
@ -42,7 +42,7 @@ if (!empty($_GET['id']) && !empty($_GET['sid']))
|
||||||
|
|
||||||
$db = new $sql_db();
|
$db = new $sql_db();
|
||||||
$cache = new cache();
|
$cache = new cache();
|
||||||
|
|
||||||
// Connect to DB
|
// Connect to DB
|
||||||
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false))
|
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false))
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ if (!empty($_GET['id']) && !empty($_GET['sid']))
|
||||||
WHERE s.session_id = '" . ((!get_magic_quotes_gpc()) ? $db->sql_escape($sid) : $sid) . "'
|
WHERE s.session_id = '" . ((!get_magic_quotes_gpc()) ? $db->sql_escape($sid) : $sid) . "'
|
||||||
AND s.session_user_id = u.user_id";
|
AND s.session_user_id = u.user_id";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
if ($user = $db->sql_fetchrow($result))
|
if ($user = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$sql = "SELECT s.style_id, c.theme_data, c.theme_path, c.theme_name, c.theme_mtime, i.imageset_path, t.template_path
|
$sql = "SELECT s.style_id, c.theme_data, c.theme_path, c.theme_name, c.theme_mtime, i.imageset_path, t.template_path
|
||||||
|
@ -73,11 +73,24 @@ if (!empty($_GET['id']) && !empty($_GET['sid']))
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result2);
|
$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'));
|
$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() . "
|
$db->sql_query("UPDATE {$table_prefix}styles_theme SET theme_data = '" . $db->sql_escape($theme['theme_data']) . "', theme_mtime = " . time() . "
|
||||||
WHERE theme_id = $id");
|
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('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 3600));
|
||||||
header('Content-type: text/css');
|
header('Content-type: text/css');
|
||||||
|
|
||||||
|
|
||||||
// Parse Theme Data
|
// Parse Theme Data
|
||||||
$replace = array(
|
$replace = array(
|
||||||
'{T_THEME_PATH}' => "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme',
|
'{T_THEME_PATH}' => "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme',
|
||||||
'{T_TEMPLATE_PATH}' => "{$phpbb_root_path}styles/" . $theme['template_path'] . '/template',
|
'{T_TEMPLATE_PATH}' => "{$phpbb_root_path}styles/" . $theme['template_path'] . '/template',
|
||||||
'{T_IMAGESET_PATH}' => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset',
|
'{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_IMAGESET_LANG_PATH}' => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset/' . $user['user_lang'],
|
||||||
'{T_STYLESHEET_NAME}' => $theme['theme_name'],
|
'{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']);
|
$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();
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue