diff options
-rw-r--r-- | admin/include/tabsheet.class.php | 4 | ||||
-rw-r--r-- | include/common.inc.php | 2 | ||||
-rw-r--r-- | include/functions_category.inc.php | 34 | ||||
-rw-r--r-- | include/functions_html.inc.php | 15 | ||||
-rw-r--r-- | include/template.class.php | 120 | ||||
-rw-r--r-- | include/template.php | 661 | ||||
-rw-r--r-- | install.php | 2 | ||||
-rw-r--r-- | plugins/hello_world/main.inc.php | 2 | ||||
-rw-r--r-- | upgrade.php | 12 |
9 files changed, 21 insertions, 831 deletions
diff --git a/admin/include/tabsheet.class.php b/admin/include/tabsheet.class.php index 0e8812051..d65e0c783 100644 --- a/admin/include/tabsheet.class.php +++ b/admin/include/tabsheet.class.php @@ -134,10 +134,10 @@ class tabsheet $template->assign('tabsheet_selected', $this->selected); $selected_tab = $this->get_selected(); - + if (isset($selected_tab)) { - $template->assign_vars( + $template->assign( array($this->titlename => '['.$selected_tab['caption'].']')); } diff --git a/include/common.inc.php b/include/common.inc.php index 6776b5fb1..6be8fbf0f 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -138,7 +138,7 @@ include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); include(PHPWG_ROOT_PATH . 'include/constants.php'); include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); -include(PHPWG_ROOT_PATH . 'include/template.php'); +include(PHPWG_ROOT_PATH . 'include/template.class.php'); // Database connection mysql_connect( $cfgHote, $cfgUser, $cfgPassword ) diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index e0e410c1e..50233bfb6 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -278,36 +278,6 @@ function display_select_categories($categories, { global $template; - // TODO - remove from here after old template removed - foreach ($categories as $category) - { - $selected = ''; - if (in_array($category['id'], $selecteds)) - { - $selected = ' selected="selected"'; - } - - if ($fullname) - { - $option = get_cat_display_name_cache($category['uppercats'], - null, - false); - } - else - { - $option = str_repeat(' ', - (3 * substr_count($category['global_rank'], '.'))); - $option.= '- '.$category['name']; - } - - $template->_old->assign_block_vars( - $blockname, - array('SELECTED'=>$selected, - 'VALUE'=>$category['id'], - 'OPTION'=>$option - )); - } - // TODO - remove until here after old template removed $tpl_cats = array(); foreach ($categories as $category) { @@ -326,8 +296,8 @@ function display_select_categories($categories, $tpl_cats[ $category['id'] ] = $option; } - $template->smarty->assign( $blockname, $tpl_cats); - $template->smarty->assign( $blockname.'_selected', $selecteds); + $template->assign( $blockname, $tpl_cats); + $template->assign( $blockname.'_selected', $selecteds); } function display_select_cat_wrapper($query, $selecteds, $blockname, diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index 36d56aea9..8921a0234 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -32,7 +32,7 @@ function get_icon($date, $is_child_date = false) { return ''; } - + if (isset($page['get_icon_cache'][$date])) { if (! $page['get_icon_cache'][$date] ) @@ -713,19 +713,6 @@ function set_status_header($code, $text='') trigger_action('set_status_header', $code, $text); } -/** - * set a class to display a counter - * .zero .one .plural - */ -function set_span_class($count) -{ - if ($count > 1) - { - return 'plural'; - } - return ( $count == 0 ) ? 'zero':'one'; -} - /** returns the category comment for rendering in html. * this is an event handler. don't call directly */ diff --git a/include/template.class.php b/include/template.class.php index d4f0ef680..aa1636c33 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -25,7 +25,7 @@ // +-----------------------------------------------------------------------+ -require 'smarty/libs/Smarty.class.php'; +require_once 'smarty/libs/Smarty.class.php'; // migrate lang:XXX // sed "s/{lang:\([^}]\+\)}/{\'\1\'|@translate}/g" my_template.tpl @@ -41,8 +41,6 @@ class Template { var $smarty; - var $_old; - var $output = ''; // Hash of filenames for each template handle. @@ -88,8 +86,6 @@ class Template { $this->smarty->assign('themeconf', $themeconf); } - $this->_old = & new TemplateOld($root, $theme); - $this->set_template_dir($root); } @@ -98,7 +94,6 @@ class Template { */ function set_template_dir($dir) { - $this->_old->set_rootdir($dir); $this->smarty->template_dir = $dir; $real_dir = realpath($dir); @@ -162,94 +157,12 @@ class Template { return true; } - /** - * DEPRECATED - backward compatibility only; use assign - */ - function assign_vars($vararray) - { - is_array( $vararray ) || die('assign_vars parameter not array'); - $this->assign( $vararray ); - } - - /** - * DEPRECATED - backward compatibility only; use assign - */ - function assign_var($varname, $varval) - { - !is_array( $varname ) || die('assign_var parameter name is array'); - $this->assign( $varname, $varval ); - } - - /** - * DEPRECATED - backward compatibility only - */ - function assign_block_vars($blockname, $vararray) - { - if (strstr($blockname, '.')!==false) - { - $blocks = explode('.', $blockname); - $blockcount = sizeof($blocks) - 1; - $root_var = & $this->smarty->get_template_vars(); - - $str = '$root_var'; - for ($i = 0; $i < $blockcount; $i++) - { - $str .= '[\'' . $blocks[$i] . '\']'; - eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:0;'); - $str .= '[' . $lastiteration . ']'; - } - $str .= '[\'' . $blocks[$blockcount] . '\'][] = $vararray;'; - eval($str); - } - else - $this->smarty->append( $blockname, $vararray ); - - $this->_old->assign_block_vars($blockname, $vararray); - } - - /** - * DEPRECATED - backward compatibility only - */ - function merge_block_vars($blockname, $vararray) - { - if (strstr($blockname, '.')!==false) - { - $blocks = explode('.', $blockname); - $blockcount = count($blocks); - $root_var = & $this->smarty->get_template_vars(); - - $str = '$root_var'; - for ($i = 0; $i < $blockcount; $i++) - { - $str .= '[\'' . $blocks[$i] . '\']'; - eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:-1;'); - if ($lastiteration==-1) - { - return false; - } - $str .= '[' . $lastiteration . ']'; - } - $str = $str.'=array_merge('.$str.', $vararray);'; - eval($str); - } - else - $this->smarty->append( $blockname, $vararray, true ); - - $this->_old->merge_block_vars($blockname, $vararray); - return true; - } - /** see smarty assign http://www.smarty.net/manual/en/api.assign.php */ function assign($tpl_var, $value = null) { $this->smarty->assign( $tpl_var, $value ); - - if ( is_array($tpl_var) ) - $this->_old->assign_vars( $tpl_var ); - else - $this->_old->assign_var( $tpl_var, $value ); } - + /** * Inserts the uncompiled code for $handle as the value of $varname in the * root-level. This can be used to effectively include a template in the @@ -278,7 +191,6 @@ class Template { if ( isset($old_val) ) { $old_val .= $value; - $this->_old->concat_var( $tpl_var, $value ); } else { @@ -311,28 +223,10 @@ class Template { die("Template->parse(): Couldn't load template file for handle $handle"); } - $is_new = true; - $params = array('resource_name' => $this->files[$handle], 'quiet'=>true, 'get_source'=>true); - if ( $this->smarty->_fetch_resource_info($params) ) - { - if (!preg_match('~{(/(if|section|foreach))|ldelim|\$[a-zA-Z_]+}~', @$params['source_content']) ) - $is_new = false; - } - - if ($is_new) - { - $this->smarty->assign( 'ROOT_URL', get_root_url() ); - $this->smarty->assign( 'TAG_INPUT_ENABLED', - ((is_adviser()) ? 'disabled="disabled" onclick="return false;"' : '')); - $v = $this->smarty->fetch($this->files[$handle], null, null, false); - } - else - { - $this->_old->assign_vars(array('TAG_INPUT_ENABLED' => - ((is_adviser()) ? 'disabled onclick="return false;"' : ''))); - $this->_old->set_filename( $handle, $this->files[$handle] ); - $v = $this->_old->parse($handle, true); - } + $this->smarty->assign( 'ROOT_URL', get_root_url() ); + $this->smarty->assign( 'TAG_INPUT_ENABLED', + ((is_adviser()) ? 'disabled="disabled" onclick="return false;"' : '')); + $v = $this->smarty->fetch($this->files[$handle], null, null, false); if ($return) { return $v; @@ -386,7 +280,7 @@ class Template { /** * explode variable modifier - similar to php explode - * 'Yes;No'|@explode:';' -> array('Yes', 'No') + * 'Yes;No'|@explode:';' -> array('Yes', 'No') */ /*static*/ function mod_explode($text, $delimiter=',') { diff --git a/include/template.php b/include/template.php deleted file mode 100644 index fad9db206..000000000 --- a/include/template.php +++ /dev/null @@ -1,661 +0,0 @@ -<?php -// +-----------------------------------------------------------------------+ -// | PhpWebGallery - a PHP based picture gallery | -// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | -// +-----------------------------------------------------------------------+ -// | branch : BSF (Best So Far) -// | file : $Id$ -// | last update : $Date$ -// | last modifier : $Author$ -// | revision : $Revision$ -// +-----------------------------------------------------------------------+ -// | This program is free software; you can redistribute it and/or modify | -// | it under the terms of the GNU General Public License as published by | -// | the Free Software Foundation | -// | | -// | This program is distributed in the hope that it will be useful, but | -// | WITHOUT ANY WARRANTY; without even the implied warranty of | -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | -// | General Public License for more details. | -// | | -// | You should have received a copy of the GNU General Public License | -// | along with this program; if not, write to the Free Software | -// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | -// | USA. | -// +-----------------------------------------------------------------------+ - -/** - * Template class. By Nathan Codding of the phpBB group. The interface was - * originally inspired by PHPLib templates, and the template file formats - * are quite similar. - */ - -class TemplateOld { - - var $classname = "Template"; - - // variable that holds all the data we'll be substituting into - // the compiled templates. - // ... - // This will end up being a multi-dimensional array like this : - // $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value - // if it's a root-level variable, it'll be like this: - // $this->_tpldata[.][0][varname] == value - var $_tpldata = array(); - - // Hash of filenames for each template handle. - var $files = array(); - - // Root template directory. - var $root = ""; - - // this will hash handle names to the compiled code for that handle. - var $compiled_code = array(); - - // This will hold the uncompiled code for that handle. - var $uncompiled_code = array(); - - // output - var $output = ''; - - var $themeconf = array(); - - /** - * Constructor. Simply sets the root dir. - * - */ - function TemplateOld($root = ".", $theme= "") - { - if ( $this->set_rootdir($root) ) - { - if ( !empty( $theme ) ) - { - include($root.'/theme/'.$theme.'/themeconf.inc.php'); - $this->themeconf = $themeconf; - } - } - } - - /** - * Destroys this template object. Should be called when you're done with - * it, in order to clear out the template data so you can load/parse a new - * template set. - */ - function destroy() - { - $this->_tpldata = array(); - } - - /** - * Sets the template root directory for this Template object. - */ - function set_rootdir($dir) - { - if (!is_dir($dir)) - { - return false; - } - - $this->root = $dir; - return true; - } - - /** - * Sets the template filename for handle. - */ - function set_filename($handle, $filename) - { - return $this->set_filenames( array($handle=>$filename) ); - } - - /** - * Sets the template filenames for handles. $filename_array should be a - * hash of handle => filename pairs. - */ - function set_filenames($filename_array) - { - $filename_array = trigger_event('loc_tpl_set_filenames', $filename_array, array(&$this)); - - if (!is_array($filename_array)) - { - return false; - } - - reset($filename_array); - while(list($handle, $filename) = each($filename_array)) - { - if (is_null($filename)) - { - unset( $this->files[$handle] ); - } - else - { - $this->files[$handle] = $this->make_filename($filename); - } - unset($this->compiled_code[$handle]); - unset($this->uncompiled_code[$handle]); - } - - return true; - } - - - /** - * Load the file for the handle, compile the file, and run the compiled - * code. This will print out the results of executing the template. - */ - function pparse($handle) - { - if (!$this->loadfile($handle)) - { - die("Template->pparse(): Couldn't load template file for handle $handle"); - } - - // actually compile the template now. - if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) - { - trigger_action('loc_begin_tpl_pparse', $handle, array(&$this)); - // Actually compile the code now. - $this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]); - } - - // Run the compiled code. - //echo ("<!-- ".$this->compiled_code[$handle]." -->"); - eval($this->compiled_code[$handle]); - return true; - } - - /** - * fills $output template var by default or returns the content - */ - function parse($handle, $return=false) - { - if (!$this->loadfile($handle)) - { - die("Template->pparse(): Couldn't load template file for handle $handle"); - } - - // actually compile the template now. - if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle])) - { - trigger_action('loc_begin_tpl_parse', $handle, array(&$this)); - // Actually compile the code now. - $this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle], true, '_str'); - } - - // Run the compiled code. - $_str = ''; - eval($this->compiled_code[$handle]); - if ($return) - { - return $_str; - } - $this->output.= $_str; - - return true; - } - - /** - * prints $output template var - */ - function p() - { - echo $this->output; - } - - /** - * Inserts the uncompiled code for $handle as the value of $varname in the - * root-level. This can be used to effectively include a template in the - * middle of another template. - * - * Note that all desired assignments to the variables in $handle should be - * done BEFORE calling this function. - */ - function assign_var_from_handle($varname, $handle) - { - trigger_action('loc_begin_tpl_assign_var_from_handle', $varname, $handle, array(&$this)); - $this->assign_var($varname, $this->parse($handle, true)); - return true; - } - - /** - * Concat the uncompiled code for $handle as the value of $varname in the - * root-level. This can be used to effectively include a template in the - * middle of another template. - * - * Note that all desired assignments to the variables in $handle should be - * done BEFORE calling this function. - */ - function concat_var_from_handle($varname, $handle) - { - trigger_action('loc_begin_tpl_concat_var_from_handle', $varname, $handle, array(&$this)); - $this->concat_var($varname, $this->parse($handle, true)); - return true; - } - - /** - * Block-level variable assignment. Adds a new block iteration with the - * given variable assignments. Note that this should only be called once - * per block iteration. - */ - function assign_block_vars($blockname, $vararray) - { - if (strstr($blockname, '.')) - { - // Nested block. - $blocks = explode('.', $blockname); - $blockcount = sizeof($blocks) - 1; - $str = '$this->_tpldata'; - for ($i = 0; $i < $blockcount; $i++) - { - $str .= '[\'' . $blocks[$i] . '.\']'; - eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:0;'); - $str .= '[' . $lastiteration . ']'; - } - // Now we add the block that we're actually assigning to. - // We're adding a new iteration to this block with the given - // variable assignments. - $str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;'; - - // Now we evaluate this assignment we've built up. - eval($str); - } - else - { - // Top-level block. Add a new iteration to this block with the - // variable assignments we were given. - $this->_tpldata[$blockname . '.'][] = $vararray; - } - - return true; - } - - /** - * Block-level variable merge. Merge given variables to the last block - * iteration. This can be called several times per block iteration. - */ - function merge_block_vars($blockname, $vararray) - { - $blocks = explode('.', $blockname); - $blockcount = count($blocks); - $str = '$this->_tpldata'; - for ($i = 0; $i < $blockcount; $i++) - { - $str .= '[\'' . $blocks[$i] . '.\']'; - eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:-1;'); - if ($lastiteration==-1) - { - return false; - } - $str .= '[' . $lastiteration . ']'; - } - $str = $str.'=array_merge('.$str.', $vararray);'; - eval($str); - return true; - } - - /** - * Block-level variable deletion. Deletes the last block iteration. - * if all is true - all blocks are removed - * return true if a deletion occured - */ - function delete_block_vars($blockname, $all=false) - { - $blocks = explode('.', $blockname); - $blockcount = count($blocks); - $str = '$this->_tpldata'; - for ($i = 0; $i < $blockcount; $i++) - { - $str .= '[\'' . $blocks[$i] . '.\']'; - eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:-1;'); - if ($lastiteration==-1) - { - return false; - } - if ($i==$blockcount-1) - { - break; - } - $str .= '[' . $lastiteration . ']'; - } - - if ($all==true or $lastiteration==0) - { - $str ='unset('.$str.');'; - } - else - { - $str ='unset('.$str.'['.$lastiteration.']);'; - } - eval($str); - return true; - } - - /** - * Root-level variable assignment. Adds to current assignments, overriding - * any existing variable assignment with the same name. - */ - function assign_vars($vararray) - { - reset ($vararray); - while (list($key, $val) = each($vararray)) - { - $this->_tpldata['.'][0][$key] = $val; - } - - return true; - } - - /** - * Root-level variable assignment. Adds to current assignments, overriding - * any existing variable assignment with the same name. - */ - function assign_var($varname, $varval) - { - $this->_tpldata['.'][0][$varname] = $varval; - return true; - } - - /** - * Root-level variable concatenation. Appends a string to an existing - * variable assignment with the same name. - */ - function concat_var($varname, $varval) - { - if ( isset($this->_tpldata['.'][0][$varname]) ) - { - $this->_tpldata['.'][0][$varname] .= $varval; - } - else - { - $this->_tpldata['.'][0][$varname] = $varval; - } - return true; - } - - /** - * Returns a root-level variable value - */ - function get_var($varname, $default=null) - { - if ( isset($this->_tpldata['.'][0][$varname]) ) - { - return $this->_tpldata['.'][0][$varname]; - } - return $default; - } - - /** - * Generates a full path+filename for the given filename, which can either - * be an absolute name, or a name relative to the rootdir for this - * Template object. - */ - function make_filename($filename) - { - // Check if it's an absolute or relative path. - // if (substr($filename, 0, 1) != '/') - if (preg_match('/^[a-z_][^:]/i', $filename) ) - { - $filename = $this->root.'/'.$filename; - } - - if (!file_exists($filename)) - { - die("Template->make_filename(): Error - file $filename does not exist"); - } - - return $filename; - } - - - /** - * If not already done, load the file for the given handle and populate - * the uncompiled_code[] hash with its code. Do not compile. - */ - function loadfile($handle) - { - // If the file for this handle is already loaded and compiled, do - // nothing. - if (isset($this->uncompiled_code[$handle]) - and !empty($this->uncompiled_code[$handle])) - { - return true; - } - - // If we don't have a file assigned to this handle, die. - if (!isset($this->files[$handle])) - { - die("Template->loadfile(): No file specified for handle $handle"); - } - - $filename = $this->files[$handle]; - - $str = implode("", @file($filename)); - - if (empty($str)) - { - die("Template->loadfile(): File $filename for handle $handle is empty"); - } - - $this->uncompiled_code[$handle] = trigger_event('tpl_load_file', $str, $handle, array(&$this)); - - return true; - } - - - - /** - * Compiles the given string of code, and returns the result in a string. - * - * If "do_not_echo" is true, the returned code will not be directly - * executable, but can be used as part of a variable assignment for use in - * assign_code_from_handle(). - */ - function compile($code, $do_not_echo = false, $retvar = '') - { - // PWG specific : communication between template and $lang - $code = preg_replace('/\{lang:([^}]+)\}/e', "l10n('$1')", $code); - // PWG specific : expand themeconf.inc.php variables - $code = preg_replace('/\{themeconf:([^}]+)\}/e', '$this->get_themeconf(\'$1\')', $code); - $code = preg_replace('/\{pwg_root\}/e', "get_root_url()", $code); - - // replace \ with \\ and then ' with \'. - $code = str_replace('\\', '\\\\', $code); - $code = str_replace('\'', '\\\'', $code); - - // change template varrefs into PHP varrefs - - // This one will handle varrefs WITH namespaces - $varrefs = array(); - preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code, $varrefs); - $varcount = sizeof($varrefs[1]); - for ($i = 0; $i < $varcount; $i++) - { - $namespace = $varrefs[1][$i]; - $varname = $varrefs[3][$i]; - $new = $this->generate_block_varref($namespace, $varname); - - $code = str_replace($varrefs[0][$i], $new, $code); - } - - // This will handle the remaining root-level varrefs - $code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . ( ( isset($this->_tpldata[\'.\'][0][\'\1\']) ) ? $this->_tpldata[\'.\'][0][\'\1\'] : \'\' ) . \'', $code); - - // Break it up into lines. - $code_lines = explode("\n", $code); - - $block_nesting_level = 0; - $block_names = array(); - $block_names[0] = "."; - - // Second: prepend echo ', append ' . "\n"; to each line. - $line_count = sizeof($code_lines); - for ($i = 0; $i < $line_count; $i++) - { - $code_lines[$i] = chop($code_lines[$i]); - if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m)) - { - $n[0] = $m[0]; - $n[1] = $m[1]; - - // Added: dougk_ff7-Keeps templates from bombing if begin is on - // the same line as end.. I think. :) - if ( preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n) ) - { - $block_nesting_level++; - $block_names[$block_nesting_level] = $m[1]; - if ($block_nesting_level < 2) - { - // Block is not nested. - $code_lines[$i] = '$_' . $n[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;'; - $code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; - $code_lines[$i] .= "\n" . '{'; - } - else - { - // This block is nested. - - // Generate a namespace string for this block. - $namespace = implode('.', $block_names); - // strip leading period from root level.. - $namespace = substr($namespace, 2); - // Get a reference to the data array for this block that depends on the - // current indices of all parent blocks. - $varref = $this->generate_block_data_ref($namespace, false); - // Create the for loop code to iterate over this block. - $code_lines[$i] = '$_' . $n[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; - $code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)'; - $code_lines[$i] .= "\n" . '{'; - } - - // We have the end of a block. - unset($block_names[$block_nesting_level]); - $block_nesting_level--; - $code_lines[$i] .= '} // END ' . $n[1]; - $m[0] = $n[0]; - $m[1] = $n[1]; - } - else - { - // We have the start of a block. - $block_nesting_level++; - $block_names[$block_nesting_level] = $m[1]; - if ($block_nesting_level < 2) - { - // Block is not nested. - $code_lines[$i] = '$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;'; - $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; - $code_lines[$i] .= "\n" . '{'; - } - else - { - // This block is nested. - - // Generate a namespace string for this block. - $namespace = implode('.', $block_names); - // strip leading period from root level.. - $namespace = substr($namespace, 2); - // Get a reference to the data array for this block that - // depends on the current indices of all parent blocks. - $varref = $this->generate_block_data_ref($namespace, false); - // Create the for loop code to iterate over this block. - $code_lines[$i] = '$_' . $m[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;'; - $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)'; - $code_lines[$i] .= "\n" . '{'; - } - } - } - else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m)) - { - // We have the end of a block. - unset($block_names[$block_nesting_level]); - $block_nesting_level--; - $code_lines[$i] = '} // END ' . $m[1]; - } - else - { - // We have an ordinary line of code. - if (!$do_not_echo) - { - $code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";'; - } - else - { - $code_lines[$i] = '$' . $retvar . '.= \'' . $code_lines[$i] . '\' . "\\n";'; - } - } - } - - // Bring it back into a single string of lines of code. - $code = implode("\n", $code_lines); - return $code ; - - } - - - /** - * Generates a reference to the given variable inside the given (possibly - * nested) block namespace. This is a string of the form: ' - * . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] - * . ' It's ready to be inserted into an "echo" line in one of the - * templates. NOTE: expects a trailing "." on the namespace. - */ - function generate_block_varref($namespace, $varname) - { - // Strip the trailing period. - $namespace = substr($namespace, 0, strlen($namespace) - 1); - - // Get a reference to the data block for this namespace. - $varref = $this->generate_block_data_ref($namespace, true); - // Prepend the necessary code to stick this in an echo line. - - // Append the variable reference. - $varref .= '[\'' . $varname . '\']'; - - $varref = '\' . ( ( isset(' . $varref . ') ) ? ' . $varref . ' : \'\' ) . \''; - - return $varref; - - } - - - /** - * Generates a reference to the array of data values for the given - * (possibly nested) block namespace. This is a string of the form: - * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] - * - * If $include_last_iterator is true, then [$_childN_i] will be appended - * to the form shown above. NOTE: does not expect a trailing "." on the - * blockname. - */ - function generate_block_data_ref($blockname, $include_last_iterator) - { - // Get an array of the blocks involved. - $blocks = explode(".", $blockname); - $blockcount = sizeof($blocks) - 1; - $varref = '$this->_tpldata'; - // Build up the string with everything but the last child. - for ($i = 0; $i < $blockcount; $i++) - { - $varref .= '[\'' . $blocks[$i] . '.\'][$_' . $blocks[$i] . '_i]'; - } - // Add the block reference for the last child. - $varref .= '[\'' . $blocks[$blockcount] . '.\']'; - // Add the iterator for the last child if requried. - if ($include_last_iterator) - { - $varref .= '[$_' . $blocks[$blockcount] . '_i]'; - } - - return $varref; - } - - function get_themeconf($key) - { - return isset($this->themeconf[$key]) ? $this->themeconf[$key] : ''; - } -} - -include_once(PHPWG_ROOT_PATH.'include/template.class.php'); -?> diff --git a/install.php b/install.php index b8dca9fdd..edac8ffbc 100644 --- a/install.php +++ b/install.php @@ -189,7 +189,7 @@ include(PHPWG_ROOT_PATH . 'include/constants.php'); include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); include(PHPWG_ROOT_PATH . 'admin/include/functions.php'); include(PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php'); -include(PHPWG_ROOT_PATH . 'include/template.php'); +include(PHPWG_ROOT_PATH . 'include/template.class.php'); if (isset($_GET['language'])) { diff --git a/plugins/hello_world/main.inc.php b/plugins/hello_world/main.inc.php index 33e052d75..e6a45f99a 100644 --- a/plugins/hello_world/main.inc.php +++ b/plugins/hello_world/main.inc.php @@ -26,7 +26,7 @@ function hello_world_begin_header() function hello_world_end_header() { global $template, $page; - $template->assign_var( 'PAGE_BANNER', + $template->assign( 'PAGE_BANNER', '<h1>"'.$page['page_banner'].'" from PhpWebGallery plugin!</h1>'); } diff --git a/upgrade.php b/upgrade.php index effc008f9..480e9603b 100644 --- a/upgrade.php +++ b/upgrade.php @@ -29,7 +29,7 @@ define('PHPWG_ROOT_PATH', './'); include_once(PHPWG_ROOT_PATH.'include/functions.inc.php'); include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php'); -include(PHPWG_ROOT_PATH.'include/template.php'); +include(PHPWG_ROOT_PATH.'include/template.class.php'); include(PHPWG_ROOT_PATH.'include/mysql.inc.php'); include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); @@ -71,7 +71,7 @@ flush(); function get_tables() { $tables = array(); - + $query = ' SHOW TABLES ;'; @@ -120,7 +120,7 @@ DESC '.$table.' function print_time($message) { global $last_time; - + $new_time = get_moment(); echo '<pre>['.get_elapsed_time($last_time, $new_time).']'; echo ' '.$message; @@ -194,7 +194,7 @@ if (!isset($_GET['version'])) { die('No upgrade required, the database structure is up to date'); } - + $template->assign( 'introduction', array( @@ -289,9 +289,9 @@ define(\'PHPWG_IN_UPGRADE\', true); 'Perform a maintenance check in [Administration>General>Maintenance] if you encounter any problem.' ); - + $template->assign('infos', $page['infos']); - + $query = ' UPDATE '.USER_CACHE_TABLE.' SET need_update = \'true\' |