diff options
| author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-08-06 15:45:13 +0000 |
|---|---|---|
| committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-08-06 15:45:13 +0000 |
| commit | b723058fb08cd225f5ff440ac648a3c5dc33b35b (patch) | |
| tree | 757a95deab50d86806eb5a18c4eb9f4ee673e650 /phpBB/includes/template.php | |
| parent | 76ace1d15461d98b693d7e7c905c0f5b9533c622 (diff) | |
| download | forums-b723058fb08cd225f5ff440ac648a3c5dc33b35b.tar forums-b723058fb08cd225f5ff440ac648a3c5dc33b35b.tar.gz forums-b723058fb08cd225f5ff440ac648a3c5dc33b35b.tar.bz2 forums-b723058fb08cd225f5ff440ac648a3c5dc33b35b.tar.xz forums-b723058fb08cd225f5ff440ac648a3c5dc33b35b.zip | |
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
Diffstat (limited to 'phpBB/includes/template.php')
| -rw-r--r-- | phpBB/includes/template.php | 70 |
1 files changed, 61 insertions, 9 deletions
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index d7de109602..51935ba9df 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -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) { |
