- fixed some problems with themes

- added support for {IMG_NAME_SRC}, {IMG_NAME_WIDTH} and {IMG_NAME_HEIGHT}
- fulltext_native has to use group by in a few more quries


git-svn-id: file:///svn/phpbb/trunk@6254 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Nils Adermann 2006-08-08 19:02:44 +00:00
parent 2ed25800c5
commit c69a6f7acd
5 changed files with 136 additions and 43 deletions

View file

@ -2904,8 +2904,6 @@ pagination_sep = \'{PAGINATION_SEP}\'
$mode . '_path' => $path, $mode . '_path' => $path,
); );
if ($mode != 'imageset')
{
switch ($mode) switch ($mode)
{ {
case 'template': case 'template':
@ -2917,16 +2915,22 @@ pagination_sep = \'{PAGINATION_SEP}\'
break; break;
case 'theme': case 'theme':
// We are only interested in the theme configuration for now
$theme_cfg = parse_cfg_file("{$phpbb_root_path}styles/$path/theme/theme.cfg");
if (isset($theme_cfg['parse_css_file']) && $theme_cfg['parse_css_file'])
{
$store_db = 1;
}
$sql_ary += array( $sql_ary += array(
'theme_storedb' => $store_db, 'theme_storedb' => $store_db,
'theme_data' => ($store_db) ? (($root_path) ? $this->db_theme_data($sql_ary, false, $root_path) : '') : '', 'theme_data' => ($store_db) ? $this->db_theme_data($sql_ary, false, $root_path) : '',
'theme_mtime' => filemtime("{$phpbb_root_path}styles/$path/theme/stylesheet.css") 'theme_mtime' => filemtime("{$phpbb_root_path}styles/$path/theme/stylesheet.css")
); );
break; break;
}
} case 'imageset':
else
{
$cfg_data = parse_cfg_file("$root_path$mode/imageset.cfg"); $cfg_data = parse_cfg_file("$root_path$mode/imageset.cfg");
$imageset_definitions = array(); $imageset_definitions = array();
@ -2947,6 +2951,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
} }
} }
unset($cfg_data); unset($cfg_data);
break;
} }
$db->sql_transaction('begin'); $db->sql_transaction('begin');

View file

@ -370,11 +370,13 @@ class fulltext_native extends search_backend
} }
$title_match = ''; $title_match = '';
$group_by = true;
// Build some display specific sql strings // Build some display specific sql strings
switch ($fields) switch ($fields)
{ {
case 'titleonly': case 'titleonly':
$title_match = 'title_match = 1'; $title_match = 'title_match = 1';
$group_by = false;
// no break // no break
case 'firstpost': case 'firstpost':
$sql_array['FROM'][TOPICS_TABLE] = 't'; $sql_array['FROM'][TOPICS_TABLE] = 't';
@ -383,6 +385,7 @@ class fulltext_native extends search_backend
case 'msgonly': case 'msgonly':
$title_match = 'title_match = 0'; $title_match = 'title_match = 0';
$group_by = false;
break; break;
} }

View file

@ -1080,8 +1080,33 @@ class user extends session
{ {
$this->theme['theme_storedb'] = 1; $this->theme['theme_storedb'] = 1;
$stylesheet = file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/stylesheet.css");
// Match CSS imports
$matches = array();
preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches);
if (sizeof($matches))
{
$content = '';
foreach ($matches[0] as $idx => $match)
{
if ($content = @file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/" . $matches[1][$idx]))
{
$content = trim($content);
}
else
{
$content = '';
}
$stylesheet = str_replace($match, $content, $stylesheet);
}
unset ($content);
}
$stylesheet = str_replace('./', 'styles/' . $this->theme['theme_path'] . '/theme/', $stylesheet);
$sql_ary = array( $sql_ary = array(
'theme_data' => implode('', file("{$phpbb_root_path}styles/" . $this->theme['theme_path'] . '/theme/stylesheet.css')), 'theme_data' => $stylesheet,
'theme_mtime' => time(), 'theme_mtime' => time(),
'theme_storedb' => 1 'theme_storedb' => 1
); );

View file

@ -470,7 +470,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
'U_SEARCH_WORDS' => append_sid("{$phpbb_root_path}search.$phpEx", "keywords=$u_hilit" . (($author) ? '&author=' . urlencode($author) : '') . (($author_id) ? '&author_id=' . $author_id : '') . $u_show_results)) 'U_SEARCH_WORDS' => $u_search)
); );
if ($sql_where) if ($sql_where)

View file

@ -74,7 +74,7 @@ if ($id && $sid)
if ($user) if ($user)
{ {
$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.*, t.template_path
FROM {$table_prefix}styles s, {$table_prefix}styles_template t, {$table_prefix}styles_theme c, {$table_prefix}styles_imageset i FROM {$table_prefix}styles s, {$table_prefix}styles_template t, {$table_prefix}styles_theme c, {$table_prefix}styles_imageset i
WHERE s.style_id = $id WHERE s.style_id = $id
AND t.template_id = s.template_id AND t.template_id = s.template_id
@ -110,6 +110,66 @@ if ($id && $sid)
$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']);
$matches = array();
preg_match_all('#\{IMG_([A-Za-z0-9_]*?)_(WIDTH|HEIGHT|SRC)\}#', $theme['theme_data'], $matches);
$imgs = $find = $replace = array();
if (isset($matches[0]) && sizeof($matches[0]))
{
foreach ($matches[1] as $i => $img)
{
$img = strtolower($img);
if (!isset($theme[$img]))
{
continue;
}
if (!isset($imgs[$img]))
{
// Do not include dimensions?
if (strpos($theme[$img], '*') === false)
{
$imgsrc = trim($theme[$img]);
$width = $height = null;
}
else
{
list($imgsrc, $height, $width) = explode('*', $theme[$img]);
}
$imgs[$img] = array(
'src' => $phpbb_root_path . 'styles/' . $theme['imageset_path'] . '/imageset/' . str_replace('{LANG}', $user['user_lang'], $imgsrc),
'width' => $width,
'height' => $height,
);
}
switch ($matches[2][$i])
{
case 'SRC':
$replace = $imgs[$img]['src'];
break;
case 'WIDTH':
$replace = $imgs[$img]['width'];
break;
case 'HEIGHT':
$replace = $imgs[$img]['height'];
break;
default:
continue;
}
$find = $matches[0][$i];
}
if (sizeof($find))
{
$theme['theme_data'] = str_replace($find, $replace, $theme['theme_data']);
}
}
echo $theme['theme_data']; echo $theme['theme_data'];
} }