1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 10:16:36 +02:00

A fair amount of additional working or semi-working stuff ... template stored db source (when appropriate), switch theme/templates between DB/filesystem (if available), import, upload templates, imagesets, themes (if available ... i.e. no safe mode), etc. still a fair amount of stuff to do but getting there ... take care using this, backup any themes/templates/imagesets before fiddling and let me know of issues

git-svn-id: file:///svn/phpbb/trunk@4343 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen
2003-08-06 15:45:13 +00:00
parent 76ace1d154
commit b723058fb0
7 changed files with 978 additions and 792 deletions

View File

@@ -1348,8 +1348,10 @@ function page_header($page_title = '')
'S_DISPLAY_MEMBERLIST' => (isset($auth)) ? $auth->acl_get('u_viewprofile') : 0,
'T_THEME_PATH' => 'styles/' . $user->theme['primary']['theme_path'] . '/theme/',
'T_STYLESHEET_LINK' => (!$user->theme['primary']['css_storedb']) ? 'styles/' . $user->theme['primary']['theme_path'] . '/theme/stylesheet.css' : "style.$phpEx?sid=$user->session_id&id=" . $user->theme['primary']['theme_id'],
'T_THEME_DATA' => (!$user->theme['primary']['css_storedb']) ? '' : $user->theme['primary']['css_data'])
'T_TEMPLATE_PATH' => 'styles/' . $user->theme['primary']['template_path'] . 'template/',
'T_IMAGESET_PATH' => 'styles/' . $user->theme['primary']['imageset_path'] . 'imageset/',
'T_STYLESHEET_LINK' => (!$user->theme['primary']['theme_storedb']) ? 'styles/' . $user->theme['primary']['theme_path'] . '/theme/stylesheet.css' : "style.$phpEx?sid=$user->session_id&id=" . $user->theme['primary']['theme_id'],
'T_THEME_DATA' => (!$user->theme['primary']['theme_storedb']) ? '' : $user->theme['primary']['theme_data'])
);
if (!empty($config['send_encoding']))
@@ -1368,15 +1370,6 @@ function page_footer()
{
global $db, $config, $template, $SID, $user, $auth, $cache, $starttime, $phpEx;
// Close our DB connection.
$db->sql_close();
// Unload cache
if (!empty($cache))
{
$cache->unload();
}
// Output page creation time
if (defined('DEBUG'))
{
@@ -1407,6 +1400,15 @@ function page_footer()
);
$template->display('body');
// Close our DB connection.
$db->sql_close();
// Unload cache
if (!empty($cache))
{
$cache->unload();
}
exit;
}

View File

@@ -165,15 +165,13 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png')
while ($fname = readdir($dh))
{
if (is_file($rootdir . $dir . '/' . $fname) &&
preg_match('#\.' . $type . '$#i', $fname) &&
filesize($rootdir . $dir . '/' . $fname))
if (is_file("$rootdir$dir/$fname") && filesize("$rootdir$dir/$fname") && preg_match('#\.' . $type . '$#i', $fname))
{
$matches[$dir][] = $fname;
}
else if ($fname{0} != '.' && is_dir($rootdir . $dir . '/' . $fname))
else if ($fname{0} != '.' && is_dir("$rootdir$dir/$fname"))
{
$matches += filelist($rootdir, $dir . '/'. $fname, $type);
$matches += filelist($rootdir, "$dir/$fname", $type);
}
}

View File

@@ -461,8 +461,6 @@ class user extends session
include($this->lang_path . '/' . $lang_set . '.' . $phpEx);
}*/
// TODO ?
// Cheat
if (!empty($_GET['style']) && $auth->acl_get('a_styles'))
{
global $SID;

View File

@@ -70,13 +70,13 @@ class template
if (file_exists($phpbb_root_path . 'styles/' . $user->theme['primary']['template_path'] . '/template'))
{
// $this->tpl = 'primary';
$this->tpl = 'primary';
$this->root = $phpbb_root_path . 'styles/' . $user->theme['primary']['template_path']. '/template';
$this->cachepath = $phpbb_root_path . 'cache/tpl_' . $user->theme['primary']['template_path'] . '_';
}
else
{
// $this->tpl = 'secondary';
$this->tpl = 'secondary';
$this->root = $phpbb_root_path . 'styles/' . $user->theme['secondary']['template_path']. '/template';
$this->cachepath = $phpbb_root_path . 'cache/tpl_' . $user->theme['secondary']['template_path'] . '_';
}
@@ -140,7 +140,7 @@ class template
// Load a compiled template if possible, if not, recompile it
function _tpl_load(&$handle)
{
global $phpEx, $user;
global $phpEx, $user, $db;
$filename = $this->cachepath . $this->filename[$handle] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx;
@@ -165,28 +165,80 @@ class template
if (!file_exists($this->files[$handle]))
{
// $this->tpl = 'secondary';
$this->tpl = 'secondary';
$this->files[$handle] = $phpbb_root_path . 'styles/' . $user->theme['secondary']['template_path'] . '/template/' . $this->filename[$handle];
}
$str = '';
if ($user->theme[$this->tpl]['template_storedb'])
{
$sql = 'SELECT * FROM ' . STYLES_TPLDATA_TABLE . '
WHERE template_id = ' . $user->theme[$this->tpl]['template_id'] . "
AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "'
OR template_included LIKE '%" . $db->sql_escape($this->filename[$handle]) . ":%')";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
{
if ($row['template_mtime'] < filemtime($phpbb_root_path . 'styles/' . $user->theme[$this->tpl]['template_path'] . '/template/' . $row['template_filename']))
{
if ($row['template_filename'] == $this->filename[$handle])
{
$this->_tpl_load_file($handle);
}
else
{
$this->files[$row['template_filename']] = $this->root . '/' . $row['template_filename'];
$this->_tpl_load_file($row['template_filename']);
unset($this->compiled_code[$row['template_filename']]);
unset($this->files[$row['template_filename']]);
}
}
if ($row['template_filename'] == $this->filename[$handle])
{
$this->compiled_code[$handle] = $this->compile(trim($row['template_data']));
$this->compile_write($handle, $this->compiled_code[$handle]);
}
else
{
// Only bother compiling if it doesn't already exist
if (!file_exists($this->cachepath . $row['template_filename'] . '.' . (($this->static_lang) ? $user->data['user_lang'] . '.' : '') . $phpEx))
{
$this->filename[$row['template_filename']] = $row['template_filename'];
$this->compile_write($row['template_filename'], $this->compile(trim($row['template_data'])));
unset($this->filename[$row['template_filename']]);
}
}
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
return false;
}
$this->_tpl_load_file($handle);
return false;
}
// Load template source from file
function _tpl_load_file($handle)
{
// Try and open template for read
if (!($fp = @fopen($this->files[$handle], 'r')))
{
trigger_error("template->_tpl_load(): File $filename does not exist or is empty", E_USER_ERROR);
}
$str = @fread($fp, filesize($this->files[$handle]));
$this->compiled_code[$handle] = $this->compile(trim(@fread($fp, filesize($this->files[$handle]))));
@fclose($fp);
// Actually compile the code now.
$this->compiled_code[$handle] = $this->compile(trim($str));
$this->compile_write($handle, $this->compiled_code[$handle]);
return false;
}
// Assign key variable pairs from an array
function assign_vars($vararray)
{