aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_template.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-08-25 09:48:44 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-08-25 09:48:44 +0000
commitb47b35a07d47435ecb35aa386783c42721bb4764 (patch)
treec6f2802bf1445252e02d286b5492aafc9bc4149d /phpBB/includes/functions_template.php
parent17f40511bf4df9dd46cd13cbd2c7802c49575783 (diff)
downloadforums-b47b35a07d47435ecb35aa386783c42721bb4764.tar
forums-b47b35a07d47435ecb35aa386783c42721bb4764.tar.gz
forums-b47b35a07d47435ecb35aa386783c42721bb4764.tar.bz2
forums-b47b35a07d47435ecb35aa386783c42721bb4764.tar.xz
forums-b47b35a07d47435ecb35aa386783c42721bb4764.zip
This is an enhancement for revision r10051 (INC template variable)
Within the mentioned revision INC was only able to be applied to defined template variables. I extended it now to work on all supported variables (template vars, defines, loops, defines in loops) I also added a DEC template variable to logically complete this. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10054 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_template.php')
-rw-r--r--phpBB/includes/functions_template.php28
1 files changed, 19 insertions, 9 deletions
diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php
index 23b09a87f7..f22a48bddb 100644
--- a/phpBB/includes/functions_template.php
+++ b/phpBB/includes/functions_template.php
@@ -192,9 +192,13 @@ class template_compile
break;
case 'INC':
- $compile_blocks[] = '<?php ' . $this->compile_tag_counter($block_val[2], true) . ' ?>';
+ $compile_blocks[] = '<?php ' . $this->compile_tag_counter($block_val[2], '++') . ' ?>';
break;
-
+
+ case 'DEC':
+ $compile_blocks[] = '<?php ' . $this->compile_tag_counter($block_val[2], '--') . ' ?>';
+ break;
+
case 'INCLUDE':
$temp = array_shift($include_blocks);
@@ -632,20 +636,26 @@ class template_compile
/**
- * Compile INC tags
+ * Compile INC/DEC tags
+ * INC/DEC tags support defined template variables as well as normal template variables
* @access private
*/
- function compile_tag_counter($tag_args)
+ function compile_tag_counter($tag_args, $operation = '++')
{
- preg_match('#^\$(?=[A-Z])([A-Z0-9_\-]*)$#', $tag_args, $match);
- if (empty($match[1]))
+ preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Z])([A-Z0-9\-_]+)#s', $tag_args, $varrefs);
+
+ if (empty($varrefs[0]))
{
return '';
}
-
- return 'echo $this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[1] . '\']++';
+
+ // Build token
+ $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']');
+
+ // Increase or decrease token ;)
+ return "echo {$token}{$operation};";
}
-
+
/**
* Compile INCLUDE tag
* @access private