aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorrxu <rxu@mail.ru>2014-02-23 22:04:35 +0800
committerrxu <rxu@mail.ru>2014-02-23 22:04:35 +0800
commitdda775c418593c254c463740636dd7fb4d352945 (patch)
tree72440f09429654c41430e3bd808b445a56c35416 /phpBB
parent4b7932e8b321771c1a5e108c229512f64032624b (diff)
downloadforums-dda775c418593c254c463740636dd7fb4d352945.tar
forums-dda775c418593c254c463740636dd7fb4d352945.tar.gz
forums-dda775c418593c254c463740636dd7fb4d352945.tar.bz2
forums-dda775c418593c254c463740636dd7fb4d352945.tar.xz
forums-dda775c418593c254c463740636dd7fb4d352945.zip
[ticket/12224] Add template wrapper method to assign block arrays
Add one more wrapper template method for the function assign_block_vars() which takes a 2-dimensional array as a parameter and calls assign_block_vars() in a loop to assign the whole block loop at once. This can make the core a little bit more expendable from the point of developing extensions as it allows to pass the data to events before it's being assigned to template. PHPBB3-12224
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/phpbb/template/base.php10
-rw-r--r--phpBB/phpbb/template/context.php16
-rw-r--r--phpBB/phpbb/template/template.php8
3 files changed, 34 insertions, 0 deletions
diff --git a/phpBB/phpbb/template/base.php b/phpBB/phpbb/template/base.php
index 6044effa1f..5bce79fd85 100644
--- a/phpBB/phpbb/template/base.php
+++ b/phpBB/phpbb/template/base.php
@@ -113,6 +113,16 @@ abstract class base implements template
/**
* {@inheritdoc}
*/
+ public function assign_block_vars_array($blockname, array $block_vars_array)
+ {
+ $this->context->assign_block_vars_array($blockname, $block_vars_array);
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')
{
return $this->context->alter_block_array($blockname, $vararray, $key, $mode);
diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php
index 65c7d094a0..af186c2215 100644
--- a/phpBB/phpbb/template/context.php
+++ b/phpBB/phpbb/template/context.php
@@ -198,6 +198,22 @@ class context
}
/**
+ * Assign key variable pairs from an array to a whole specified block loop
+ *
+ * @param string $blockname Name of block to assign $block_vars_array to
+ * @param array $block_vars_array An array of hashes of variable name => value pairs
+ */
+ public function assign_block_vars_array($blockname, array $block_vars_array)
+ {
+ foreach ($block_vars_array as $vararray)
+ {
+ $this->assign_block_vars($blockname, $vararray);
+ }
+
+ return true;
+ }
+
+ /**
* Change already assigned key variable pair (one-dimensional - single loop entry)
*
* An example of how to use this function:
diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php
index d95b0a822c..87ae7a9766 100644
--- a/phpBB/phpbb/template/template.php
+++ b/phpBB/phpbb/template/template.php
@@ -132,6 +132,14 @@ interface template
public function assign_block_vars($blockname, array $vararray);
/**
+ * Assign key variable pairs from an array to a whole specified block loop
+ * @param string $blockname Name of block to assign $block_vars_array to
+ * @param array $block_vars_array An array of hashes of variable name => value pairs
+ * @return \phpbb\template\template $this
+ */
+ public function assign_block_vars_array($blockname, array $block_vars_array);
+
+ /**
* Change already assigned key variable pair (one-dimensional - single loop entry)
*
* An example of how to use this function: