diff options
| author | Chris Smith <toonarmy@phpbb.com> | 2008-11-22 23:53:40 +0000 |
|---|---|---|
| committer | Chris Smith <toonarmy@phpbb.com> | 2008-11-22 23:53:40 +0000 |
| commit | 416270ee77c32d9ff876dedc4b6c4a2eb7296a96 (patch) | |
| tree | 3a433621dab6ce4832d7b7d6e8868725e7fb99d5 /phpBB/includes/functions_template.php | |
| parent | efe06af91327e0eb30b98b6c848d72c66774c0e9 (diff) | |
| download | forums-416270ee77c32d9ff876dedc4b6c4a2eb7296a96.tar forums-416270ee77c32d9ff876dedc4b6c4a2eb7296a96.tar.gz forums-416270ee77c32d9ff876dedc4b6c4a2eb7296a96.tar.bz2 forums-416270ee77c32d9ff876dedc4b6c4a2eb7296a96.tar.xz forums-416270ee77c32d9ff876dedc4b6c4a2eb7296a96.zip | |
- Deprecate S_ROW_COUNT use S_ROW_NUM
- S_ROW_NUM, S_FIRST_ROW, S_LAST_ROW are now using internal template engine variables saving memory
- Other small changes
- Update of template tests
git-svn-id: file:///svn/phpbb/trunk@9087 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_template.php')
| -rw-r--r-- | phpBB/includes/functions_template.php | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index cf85927028..d13ffc04a4 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -413,7 +413,34 @@ class template_filter extends php_user_filter $varrefs = array(); if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Z])([A-Z0-9\-_]+)#s', $token, $varrefs)) { - $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$_rootref[\'' . $varrefs[3] . '\']'); + if (!empty($varrefs[1])) + { + $namespace = substr($varrefs[1], 0, -1); + $namespace = (strpos($namespace, '.') === false) ? $namespace : strrchr($namespace, '.'); + + // S_ROW_COUNT is deceptive, it returns the current row number now the number of rows + // hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM + if ($varrefs[3] == 'S_ROW_NUM' || $varrefs[3] == 'S_ROW_COUNT') + { + $token = "\$_${namespace}_i"; + } + else if ($varrefs[3] == 'S_FIRST_ROW') + { + $token = "(\$_${namespace}_i == 0)"; + } + else if ($varrefs[3] == 'S_LAST_ROW') + { + $token = "(\$_${namespace}_i == \$_${namespace}_count - 1)"; + } + else + { + $token = $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']'; + } + } + else + { + $token = ($varrefs[2]) ? '$_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$_rootref[\'' . $varrefs[3] . '\']'; + } } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) { @@ -439,7 +466,7 @@ class template_filter extends php_user_filter // Add the block reference for the last child. $varref .= "['" . $blocks[0] . "']"; } - $token = "sizeof($varref)"; + $token = "isset($varref) && sizeof($varref)"; } break; @@ -579,12 +606,29 @@ class template_filter extends php_user_filter // Strip the trailing period. $namespace = substr($namespace, 0, -1); - // Get a reference to the data block for this namespace. - $varref = $this->generate_block_data_ref($namespace, true, $defop); - // Prepend the necessary code to stick this in an echo line. + // S_ROW_COUNT is deceptive, it returns the current row number now the number of rows + // hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM + if ($varname == 'S_ROW_NUM' || $varname == 'S_ROW_COUNT') + { + $varref = "\$_${namespace}_i"; + } + else if ($varname == 'S_FIRST_ROW') + { + $varref = "(\$_${namespace}_i == 0)"; + } + else if ($varname == 'S_LAST_ROW') + { + $varref = "(\$_${namespace}_i == \$_${namespace}_count - 1)"; + } + else + { + // Get a reference to the data block for this namespace. + $varref = $this->generate_block_data_ref($namespace, true, $defop); + // Prepend the necessary code to stick this in an echo line. - // Append the variable reference. - $varref .= "['$varname']"; + // Append the variable reference. + $varref .= "['$varname']"; + } $varref = ($echo) ? "<?php echo $varref; ?>" : ((isset($varref)) ? $varref : ''); return $varref; |
