indvdum@0: $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value indvdum@0: * if it's a root-level variable, it'll be like this: indvdum@0: * --> $this->_tpldata[.][0][varname] == value indvdum@0: */ indvdum@0: var $_tpldata = array('.' => array(0 => array())); indvdum@0: var $_rootref; indvdum@0: indvdum@0: // Root dir and hash of filenames for each template handle. indvdum@0: var $root = ''; indvdum@0: var $cachepath = ''; indvdum@0: var $files = array(); indvdum@0: var $filename = array(); indvdum@0: var $files_inherit = array(); indvdum@0: var $files_template = array(); indvdum@0: var $inherit_root = ''; indvdum@0: var $orig_tpl_storedb; indvdum@0: var $orig_tpl_inherits_id; indvdum@0: indvdum@0: // this will hash handle names to the compiled/uncompiled code for that handle. indvdum@0: var $compiled_code = array(); indvdum@0: indvdum@0: /** indvdum@0: * Set template location indvdum@0: * @access public indvdum@0: */ indvdum@0: function set_template() indvdum@0: { indvdum@0: global $phpbb_root_path, $user; indvdum@0: indvdum@0: if (file_exists($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template')) indvdum@0: { indvdum@0: $this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'; indvdum@0: $this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_'; indvdum@0: indvdum@0: if ($this->orig_tpl_storedb === null) indvdum@0: { indvdum@0: $this->orig_tpl_storedb = $user->theme['template_storedb']; indvdum@0: } indvdum@0: indvdum@0: if ($this->orig_tpl_inherits_id === null) indvdum@0: { indvdum@0: $this->orig_tpl_inherits_id = $user->theme['template_inherits_id']; indvdum@0: } indvdum@0: indvdum@0: $user->theme['template_storedb'] = $this->orig_tpl_storedb; indvdum@0: $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; indvdum@0: indvdum@0: if ($user->theme['template_inherits_id']) indvdum@0: { indvdum@0: $this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template'; indvdum@0: } indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR); indvdum@0: } indvdum@0: indvdum@0: $this->_rootref = &$this->_tpldata['.'][0]; indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Set custom template location (able to use directory outside of phpBB) indvdum@0: * @access public indvdum@0: */ indvdum@0: function set_custom_template($template_path, $template_name, $fallback_template_path = false) indvdum@0: { indvdum@0: global $phpbb_root_path, $user; indvdum@0: indvdum@0: // Make sure $template_path has no ending slash indvdum@0: if (substr($template_path, -1) == '/') indvdum@0: { indvdum@0: $template_path = substr($template_path, 0, -1); indvdum@0: } indvdum@0: indvdum@0: $this->root = $template_path; indvdum@0: $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; indvdum@0: indvdum@0: if ($fallback_template_path !== false) indvdum@0: { indvdum@0: if (substr($fallback_template_path, -1) == '/') indvdum@0: { indvdum@0: $fallback_template_path = substr($fallback_template_path, 0, -1); indvdum@0: } indvdum@0: indvdum@0: $this->inherit_root = $fallback_template_path; indvdum@0: $this->orig_tpl_inherits_id = true; indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $this->orig_tpl_inherits_id = false; indvdum@0: } indvdum@0: indvdum@0: // the database does not store the path or name of a custom template indvdum@0: // so there is no way we can properly store custom templates there indvdum@0: $this->orig_tpl_storedb = false; indvdum@0: indvdum@0: $this->_rootref = &$this->_tpldata['.'][0]; indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Sets the template filenames for handles. $filename_array indvdum@0: * should be a hash of handle => filename pairs. indvdum@0: * @access public indvdum@0: */ indvdum@0: function set_filenames($filename_array) indvdum@0: { indvdum@0: if (!is_array($filename_array)) indvdum@0: { indvdum@0: return false; indvdum@0: } indvdum@0: foreach ($filename_array as $handle => $filename) indvdum@0: { indvdum@0: if (empty($filename)) indvdum@0: { indvdum@0: trigger_error("template->set_filenames: Empty filename specified for $handle", E_USER_ERROR); indvdum@0: } indvdum@0: indvdum@0: $this->filename[$handle] = $filename; indvdum@0: $this->files[$handle] = $this->root . '/' . $filename; indvdum@0: indvdum@0: if ($this->inherit_root) indvdum@0: { indvdum@0: $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Destroy template data set indvdum@0: * @access public indvdum@0: */ indvdum@0: function destroy() indvdum@0: { indvdum@0: $this->_tpldata = array('.' => array(0 => array())); indvdum@0: $this->_rootref = &$this->_tpldata['.'][0]; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Reset/empty complete block indvdum@0: * @access public indvdum@0: */ indvdum@0: function destroy_block_vars($blockname) indvdum@0: { indvdum@0: if (strpos($blockname, '.') !== false) indvdum@0: { indvdum@0: // Nested block. indvdum@0: $blocks = explode('.', $blockname); indvdum@0: $blockcount = sizeof($blocks) - 1; indvdum@0: indvdum@0: $str = &$this->_tpldata; indvdum@0: for ($i = 0; $i < $blockcount; $i++) indvdum@0: { indvdum@0: $str = &$str[$blocks[$i]]; indvdum@0: $str = &$str[sizeof($str) - 1]; indvdum@0: } indvdum@0: indvdum@0: unset($str[$blocks[$blockcount]]); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: // Top-level block. indvdum@0: unset($this->_tpldata[$blockname]); indvdum@0: } indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Display handle indvdum@0: * @access public indvdum@0: */ indvdum@0: function display($handle, $include_once = true) indvdum@0: { indvdum@0: global $user, $phpbb_hook; indvdum@0: indvdum@0: if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once, $this)) indvdum@0: { indvdum@0: if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__))) indvdum@0: { indvdum@0: return $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__)); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: if (defined('IN_ERROR_HANDLER')) indvdum@0: { indvdum@0: if ((E_NOTICE & error_reporting()) == E_NOTICE) indvdum@0: { indvdum@0: error_reporting(error_reporting() ^ E_NOTICE); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: if ($filename = $this->_tpl_load($handle)) indvdum@0: { indvdum@0: ($include_once) ? include_once($filename) : include($filename); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: eval(' ?>' . $this->compiled_code[$handle] . 'display($handle, $include_once); indvdum@0: $contents = ob_get_clean(); indvdum@0: indvdum@0: if ($return_content) indvdum@0: { indvdum@0: return $contents; indvdum@0: } indvdum@0: indvdum@0: $this->assign_var($template_var, $contents); indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Load a compiled template if possible, if not, recompile it indvdum@0: * @access private indvdum@0: */ indvdum@0: function _tpl_load(&$handle) indvdum@0: { indvdum@0: global $user, $phpEx, $config; indvdum@0: indvdum@0: if (!isset($this->filename[$handle])) indvdum@0: { indvdum@0: trigger_error("template->_tpl_load(): No file specified for handle $handle", E_USER_ERROR); indvdum@0: } indvdum@0: indvdum@0: // reload these settings to have the values they had when this object was initialised indvdum@0: // using set_template or set_custom_template, they might otherwise have been overwritten indvdum@0: // by other template class instances in between. indvdum@0: $user->theme['template_storedb'] = $this->orig_tpl_storedb; indvdum@0: $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; indvdum@0: indvdum@0: $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx; indvdum@0: $this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0; indvdum@0: indvdum@0: $recompile = false; indvdum@0: if (!file_exists($filename) || @filesize($filename) === 0 || defined('DEBUG_EXTRA')) indvdum@0: { indvdum@0: $recompile = true; indvdum@0: } indvdum@0: else if ($config['load_tplcompile']) indvdum@0: { indvdum@0: // No way around it: we need to check inheritance here indvdum@0: if ($user->theme['template_inherits_id'] && !file_exists($this->files[$handle])) indvdum@0: { indvdum@0: $this->files[$handle] = $this->files_inherit[$handle]; indvdum@0: $this->files_template[$handle] = $user->theme['template_inherits_id']; indvdum@0: } indvdum@0: $recompile = (@filemtime($filename) < filemtime($this->files[$handle])) ? true : false; indvdum@0: } indvdum@0: indvdum@0: // Recompile page if the original template is newer, otherwise load the compiled version indvdum@0: if (!$recompile) indvdum@0: { indvdum@0: return $filename; indvdum@0: } indvdum@0: indvdum@0: global $db, $phpbb_root_path; indvdum@0: indvdum@0: if (!class_exists('template_compile')) indvdum@0: { indvdum@0: include($phpbb_root_path . 'includes/functions_template.' . $phpEx); indvdum@0: } indvdum@0: indvdum@0: // Inheritance - we point to another template file for this one. Equality is also used for store_db indvdum@0: if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($this->files[$handle])) indvdum@0: { indvdum@0: $this->files[$handle] = $this->files_inherit[$handle]; indvdum@0: $this->files_template[$handle] = $user->theme['template_inherits_id']; indvdum@0: } indvdum@0: indvdum@0: $compile = new template_compile($this); indvdum@0: indvdum@0: // If we don't have a file assigned to this handle, die. indvdum@0: if (!isset($this->files[$handle])) indvdum@0: { indvdum@0: trigger_error("template->_tpl_load(): No file specified for handle $handle", E_USER_ERROR); indvdum@0: } indvdum@0: indvdum@0: // Just compile if no user object is present (happens within the installer) indvdum@0: if (!$user) indvdum@0: { indvdum@0: $compile->_tpl_load_file($handle); indvdum@0: return false; indvdum@0: } indvdum@0: indvdum@0: if (isset($user->theme['template_storedb']) && $user->theme['template_storedb']) indvdum@0: { indvdum@0: $rows = array(); indvdum@0: $ids = array(); indvdum@0: // Inheritance indvdum@0: if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id']) indvdum@0: { indvdum@0: $ids[] = $user->theme['template_inherits_id']; indvdum@0: } indvdum@0: $ids[] = $user->theme['template_id']; indvdum@0: indvdum@0: foreach ($ids as $id) indvdum@0: { indvdum@0: $sql = 'SELECT * indvdum@0: FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' indvdum@0: WHERE template_id = ' . $id . " indvdum@0: AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "' indvdum@0: OR template_included " . $db->sql_like_expression($db->any_char . $this->filename[$handle] . ':' . $db->any_char) . ')'; indvdum@0: indvdum@0: $result = $db->sql_query($sql); indvdum@0: while ($row = $db->sql_fetchrow($result)) indvdum@0: { indvdum@0: $rows[$row['template_filename']] = $row; indvdum@0: } indvdum@0: $db->sql_freeresult($result); indvdum@0: } indvdum@0: indvdum@0: if (sizeof($rows)) indvdum@0: { indvdum@0: foreach ($rows as $row) indvdum@0: { indvdum@0: $file = $this->root . '/' . $row['template_filename']; indvdum@0: $force_reload = false; indvdum@0: if ($row['template_id'] != $user->theme['template_id']) indvdum@0: { indvdum@0: // make sure that we are not overlooking a file not in the db yet indvdum@0: if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file)) indvdum@0: { indvdum@0: $file = $this->inherit_root . '/' . $row['template_filename']; indvdum@0: $this->files[$row['template_filename']] = $file; indvdum@0: $this->files_inherit[$row['template_filename']] = $file; indvdum@0: $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; indvdum@0: } indvdum@0: else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id']) indvdum@0: { indvdum@0: // Ok, we have a situation. There is a file in the subtemplate, but nothing in the DB. We have to fix that. indvdum@0: $force_reload = true; indvdum@0: $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; indvdum@0: } indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $this->files_template[$row['template_filename']] = $user->theme['template_id']; indvdum@0: } indvdum@0: indvdum@0: if ($force_reload || $row['template_mtime'] < filemtime($file)) indvdum@0: { indvdum@0: if ($row['template_filename'] == $this->filename[$handle]) indvdum@0: { indvdum@0: $compile->_tpl_load_file($handle, true); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $this->files[$row['template_filename']] = $file; indvdum@0: $this->filename[$row['template_filename']] = $row['template_filename']; indvdum@0: $compile->_tpl_load_file($row['template_filename'], true); indvdum@0: unset($this->compiled_code[$row['template_filename']]); indvdum@0: unset($this->files[$row['template_filename']]); indvdum@0: unset($this->filename[$row['template_filename']]); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: if ($row['template_filename'] == $this->filename[$handle]) indvdum@0: { indvdum@0: $this->compiled_code[$handle] = $compile->compile(trim($row['template_data'])); indvdum@0: $compile->compile_write($handle, $this->compiled_code[$handle]); indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: // Only bother compiling if it doesn't already exist indvdum@0: if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . '.' . $phpEx)) indvdum@0: { indvdum@0: $this->filename[$row['template_filename']] = $row['template_filename']; indvdum@0: $compile->compile_write($row['template_filename'], $compile->compile(trim($row['template_data']))); indvdum@0: unset($this->filename[$row['template_filename']]); indvdum@0: } indvdum@0: } indvdum@0: } indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: $file = $this->root . '/' . $row['template_filename']; indvdum@0: indvdum@0: if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file)) indvdum@0: { indvdum@0: $file = $this->inherit_root . '/' . $row['template_filename']; indvdum@0: $this->files[$row['template_filename']] = $file; indvdum@0: $this->files_inherit[$row['template_filename']] = $file; indvdum@0: $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id']; indvdum@0: } indvdum@0: // Try to load from filesystem and instruct to insert into the styles table... indvdum@0: $compile->_tpl_load_file($handle, true); indvdum@0: return false; indvdum@0: } indvdum@0: indvdum@0: return false; indvdum@0: } indvdum@0: indvdum@0: $compile->_tpl_load_file($handle); indvdum@0: return false; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Assign key variable pairs from an array indvdum@0: * @access public indvdum@0: */ indvdum@0: function assign_vars($vararray) indvdum@0: { indvdum@0: foreach ($vararray as $key => $val) indvdum@0: { indvdum@0: $this->_rootref[$key] = $val; indvdum@0: } indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Assign a single variable to a single key indvdum@0: * @access public indvdum@0: */ indvdum@0: function assign_var($varname, $varval) indvdum@0: { indvdum@0: $this->_rootref[$varname] = $varval; indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Assign key variable pairs from an array to a specified block indvdum@0: * @access public indvdum@0: */ indvdum@0: function assign_block_vars($blockname, $vararray) indvdum@0: { indvdum@0: if (strpos($blockname, '.') !== false) indvdum@0: { indvdum@0: // Nested block. indvdum@0: $blocks = explode('.', $blockname); indvdum@0: $blockcount = sizeof($blocks) - 1; indvdum@0: indvdum@0: $str = &$this->_tpldata; indvdum@0: for ($i = 0; $i < $blockcount; $i++) indvdum@0: { indvdum@0: $str = &$str[$blocks[$i]]; indvdum@0: $str = &$str[sizeof($str) - 1]; indvdum@0: } indvdum@0: indvdum@0: $s_row_count = isset($str[$blocks[$blockcount]]) ? sizeof($str[$blocks[$blockcount]]) : 0; indvdum@0: $vararray['S_ROW_COUNT'] = $s_row_count; indvdum@0: indvdum@0: // Assign S_FIRST_ROW indvdum@0: if (!$s_row_count) indvdum@0: { indvdum@0: $vararray['S_FIRST_ROW'] = true; indvdum@0: } indvdum@0: indvdum@0: // Now the tricky part, we always assign S_LAST_ROW and remove the entry before indvdum@0: // This is much more clever than going through the complete template data on display (phew) indvdum@0: $vararray['S_LAST_ROW'] = true; indvdum@0: if ($s_row_count > 0) indvdum@0: { indvdum@0: unset($str[$blocks[$blockcount]][($s_row_count - 1)]['S_LAST_ROW']); indvdum@0: } indvdum@0: indvdum@0: // Now we add the block that we're actually assigning to. indvdum@0: // We're adding a new iteration to this block with the given indvdum@0: // variable assignments. indvdum@0: $str[$blocks[$blockcount]][] = $vararray; indvdum@0: } indvdum@0: else indvdum@0: { indvdum@0: // Top-level block. indvdum@0: $s_row_count = (isset($this->_tpldata[$blockname])) ? sizeof($this->_tpldata[$blockname]) : 0; indvdum@0: $vararray['S_ROW_COUNT'] = $s_row_count; indvdum@0: indvdum@0: // Assign S_FIRST_ROW indvdum@0: if (!$s_row_count) indvdum@0: { indvdum@0: $vararray['S_FIRST_ROW'] = true; indvdum@0: } indvdum@0: indvdum@0: // We always assign S_LAST_ROW and remove the entry before indvdum@0: $vararray['S_LAST_ROW'] = true; indvdum@0: if ($s_row_count > 0) indvdum@0: { indvdum@0: unset($this->_tpldata[$blockname][($s_row_count - 1)]['S_LAST_ROW']); indvdum@0: } indvdum@0: indvdum@0: // Add a new iteration to this block with the variable assignments we were given. indvdum@0: $this->_tpldata[$blockname][] = $vararray; indvdum@0: } indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Change already assigned key variable pair (one-dimensional - single loop entry) indvdum@0: * indvdum@0: * An example of how to use this function: indvdum@0: * {@example alter_block_array.php} indvdum@0: * indvdum@0: * @param string $blockname the blockname, for example 'loop' indvdum@0: * @param array $vararray the var array to insert/add or merge indvdum@0: * @param mixed $key Key to search for indvdum@0: * indvdum@0: * array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position] indvdum@0: * indvdum@0: * int: Position [the position to change or insert at directly given] indvdum@0: * indvdum@0: * If key is false the position is set to 0 indvdum@0: * If key is true the position is set to the last entry indvdum@0: * indvdum@0: * @param string $mode Mode to execute (valid modes are 'insert' and 'change') indvdum@0: * indvdum@0: * If insert, the vararray is inserted at the given position (position counting from zero). indvdum@0: * If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value). indvdum@0: * indvdum@0: * Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array) indvdum@0: * and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars) indvdum@0: * indvdum@0: * @return bool false on error, true on success indvdum@0: * @access public indvdum@0: */ indvdum@0: function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert') indvdum@0: { indvdum@0: if (strpos($blockname, '.') !== false) indvdum@0: { indvdum@0: // Nested blocks are not supported indvdum@0: return false; indvdum@0: } indvdum@0: indvdum@0: // Change key to zero (change first position) if false and to last position if true indvdum@0: if ($key === false || $key === true) indvdum@0: { indvdum@0: $key = ($key === false) ? 0 : sizeof($this->_tpldata[$blockname]); indvdum@0: } indvdum@0: indvdum@0: // Get correct position if array given indvdum@0: if (is_array($key)) indvdum@0: { indvdum@0: // Search array to get correct position indvdum@0: list($search_key, $search_value) = @each($key); indvdum@0: indvdum@0: $key = NULL; indvdum@0: foreach ($this->_tpldata[$blockname] as $i => $val_ary) indvdum@0: { indvdum@0: if ($val_ary[$search_key] === $search_value) indvdum@0: { indvdum@0: $key = $i; indvdum@0: break; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: // key/value pair not found indvdum@0: if ($key === NULL) indvdum@0: { indvdum@0: return false; indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: // Insert Block indvdum@0: if ($mode == 'insert') indvdum@0: { indvdum@0: // Make sure we are not exceeding the last iteration indvdum@0: if ($key >= sizeof($this->_tpldata[$blockname])) indvdum@0: { indvdum@0: $key = sizeof($this->_tpldata[$blockname]); indvdum@0: unset($this->_tpldata[$blockname][($key - 1)]['S_LAST_ROW']); indvdum@0: $vararray['S_LAST_ROW'] = true; indvdum@0: } indvdum@0: else if ($key === 0) indvdum@0: { indvdum@0: unset($this->_tpldata[$blockname][0]['S_FIRST_ROW']); indvdum@0: $vararray['S_FIRST_ROW'] = true; indvdum@0: } indvdum@0: indvdum@0: // Re-position template blocks indvdum@0: for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--) indvdum@0: { indvdum@0: $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1]; indvdum@0: $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i; indvdum@0: } indvdum@0: indvdum@0: // Insert vararray at given position indvdum@0: $vararray['S_ROW_COUNT'] = $key; indvdum@0: $this->_tpldata[$blockname][$key] = $vararray; indvdum@0: indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: // Which block to change? indvdum@0: if ($mode == 'change') indvdum@0: { indvdum@0: if ($key == sizeof($this->_tpldata[$blockname])) indvdum@0: { indvdum@0: $key--; indvdum@0: } indvdum@0: indvdum@0: $this->_tpldata[$blockname][$key] = array_merge($this->_tpldata[$blockname][$key], $vararray); indvdum@0: return true; indvdum@0: } indvdum@0: indvdum@0: return false; indvdum@0: } indvdum@0: indvdum@0: /** indvdum@0: * Include a separate template indvdum@0: * @access private indvdum@0: */ indvdum@0: function _tpl_include($filename, $include = true) indvdum@0: { indvdum@0: $handle = $filename; indvdum@0: $this->filename[$handle] = $filename; indvdum@0: $this->files[$handle] = $this->root . '/' . $filename; indvdum@0: if ($this->inherit_root) indvdum@0: { indvdum@0: $this->files_inherit[$handle] = $this->inherit_root . '/' . $filename; indvdum@0: } indvdum@0: indvdum@0: $filename = $this->_tpl_load($handle); indvdum@0: indvdum@0: if ($include) indvdum@0: { indvdum@0: global $user; indvdum@0: indvdum@0: if ($filename) indvdum@0: { indvdum@0: include($filename); indvdum@0: return; indvdum@0: } indvdum@0: eval(' ?>' . $this->compiled_code[$handle] . '_php_include(): File ' . htmlspecialchars($file) . ' does not exist or is empty'; indvdum@0: return; indvdum@0: } indvdum@0: include($file); indvdum@0: } indvdum@0: } indvdum@0: indvdum@0: ?>