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; } diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 183999d5f4..dbb85dc110 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -162,7 +162,7 @@ interface template /** * Retrieve variable values from an specified block * @param string $blockname Name of block to retrieve $vararray from - * @param array $vararray An array with variable names + * @param array $vararray An array with variable names, empty array gets all vars * @return array A hash of variable name => value pairs (value is null if not set) */ public function retrieve_block_vars($blockname, array $vararray);