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
|
@ -74,10 +74,23 @@ if (!empty($_GET['id']) && !empty($_GET['sid']))
|
||||||
}
|
}
|
||||||
$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,6 +98,7 @@ 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',
|
||||||
|
@ -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