aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaviexin <javiexin@gmail.com>2017-03-09 16:05:39 +0100
committerjaviexin <javiexin@gmail.com>2017-03-09 16:05:39 +0100
commit96a90d3f81c1fcce3834ee72b7d1b9f76aa9354c (patch)
tree0626bbd23111a20be79728d631f857615ecb9f76 /phpBB/phpbb/template/context.php
parent[ticket/15068] Add template vars retrieval from the template object (diff)
downloadphpbb-96a90d3f81c1fcce3834ee72b7d1b9f76aa9354c.tar.gz
phpbb-96a90d3f81c1fcce3834ee72b7d1b9f76aa9354c.tar.bz2
phpbb-96a90d3f81c1fcce3834ee72b7d1b9f76aa9354c.zip
[ticket/15068] Add template vars retrieval from the template object
Add possibility to retrieve full block of vars PHPBB3-15068
Diffstat (limited to 'phpBB/phpbb/template/context.php')
-rw-r--r--phpBB/phpbb/template/context.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php
index 0e5f3287aa..6975409ce3 100644
--- a/phpBB/phpbb/template/context.php
+++ b/phpBB/phpbb/template/context.php
@@ -278,7 +278,7 @@ class context
* Retrieve key variable pairs from the specified block
*
* @param string $blockname Name of block to retrieve $vararray from
- * @param array $vararray An array of variable names
+ * @param array $vararray An array of variable names, empty array retrieves all vars
* @return array of hashes with variable name as key and retrieved value or null as value
*/
public function retrieve_block_vars($blockname, array $vararray)
@@ -313,9 +313,25 @@ class context
}
$result = array();
- foreach ($vararray as $varname)
+ if ($vararray === array())
{
- $result[$varname] = isset($block[$varname]) ? $block[$varname] : null;
+ // The calculated vars that depend on the block position are excluded from the complete block returned results
+ $excluded_vars = array('S_FIRST_ROW', 'S_LAST_ROW', 'S_BLOCK_NAME', 'S_NUM_ROWS', 'S_ROW_COUNT', 'S_ROW_NUM');
+
+ foreach ($block as $varname => $varvalue)
+ {
+ if ($varname === strtoupper($varname) && !is_array($varvalue) && !in_array($varname, $excluded_vars))
+ {
+ $result[$varname] = $varvalue;
+ }
+ }
+ }
+ else
+ {
+ foreach ($vararray as $varname)
+ {
+ $result[$varname] = isset($block[$varname]) ? $block[$varname] : null;
+ }
}
return $result;
}