From 03568fd176501c6a6c629590ab701eadef5841aa Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 24 Aug 2009 15:12:40 +0000 Subject: [PATCH] Add INC (working name) to template syntax git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10051 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/CHANGELOG.html | 2 ++ phpBB/docs/coding-guidelines.html | 7 ++++++- phpBB/includes/functions_template.php | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index d6aaf9e38f..a8b68e587d 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -281,6 +281,8 @@
  • [Feature] Separate PM Reply and PM Reply to all in prosilver.
  • [Feature] Place debug notices during captcha rendering in the error log - useful for debugging output already started errors.
  • [Feature] Ability to define constant PHPBB_USE_BOARD_URL_PATH to use board url for images/avatars/ranks/imageset...
  • +
  • [Feature] Added INC command to template syntax.
  • +

    1.ii. Changes since 3.0.4

    diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 37b9629362..03b2949eba 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -1174,7 +1174,12 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <!-- DEFINE $SOME_VAR = 'my_file.html' --> <!-- INCLUDE {$SOME_VAR} --> - +

    Also added in 3.0.6 is the ability to increment an variable on use. This can be used for instances like tabindexes, where the amount of entries is not statically known. +The INC command will print the current state of a defined var and then increment it by one (postincrement).

    +
    +<!-- DEFINE $SOME_VAR = 1 -->
    +<!-- INC $SOME_VAR -->
    +

    PHP

    A contentious decision has seen the ability to include PHP within the template introduced. This is achieved by enclosing the PHP within relevant tags:

    diff --git a/phpBB/includes/functions_template.php b/phpBB/includes/functions_template.php index 1d3a4d74f8..23b09a87f7 100644 --- a/phpBB/includes/functions_template.php +++ b/phpBB/includes/functions_template.php @@ -191,6 +191,10 @@ class template_compile $compile_blocks[] = 'compile_tag_define($block_val[2], false) . ' ?>'; break; + case 'INC': + $compile_blocks[] = 'compile_tag_counter($block_val[2], true) . ' ?>'; + break; + case 'INCLUDE': $temp = array_shift($include_blocks); @@ -626,6 +630,22 @@ class template_compile return (($match[1]) ? $this->generate_block_data_ref(substr($match[1], 0, -1), true, true) . '[\'' . $match[2] . '\']' : '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[2] . '\']') . ' = ' . $match[4] . ';'; } + + /** + * Compile INC tags + * @access private + */ + function compile_tag_counter($tag_args) + { + preg_match('#^\$(?=[A-Z])([A-Z0-9_\-]*)$#', $tag_args, $match); + if (empty($match[1])) + { + return ''; + } + + return 'echo $this->_tpldata[\'DEFINE\'][\'.\'][\'' . $match[1] . '\']++'; + } + /** * Compile INCLUDE tag * @access private