aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/template/context.php
diff options
context:
space:
mode:
authorjaviexin <javiexin@gmail.com>2016-12-30 18:03:09 +0100
committerjaviexin <javiexin@gmail.com>2016-12-30 18:03:09 +0100
commitc656bd60ef99218a710882b6f640fea099e9c6e2 (patch)
treee1b92a79be0b37520ad6846838c30d4c6bf0ce48 /phpBB/phpbb/template/context.php
parentcff57f9076dd160b2185895f7298d4acbc5b5bb3 (diff)
downloadforums-c656bd60ef99218a710882b6f640fea099e9c6e2.tar
forums-c656bd60ef99218a710882b6f640fea099e9c6e2.tar.gz
forums-c656bd60ef99218a710882b6f640fea099e9c6e2.tar.bz2
forums-c656bd60ef99218a710882b6f640fea099e9c6e2.tar.xz
forums-c656bd60ef99218a710882b6f640fea099e9c6e2.zip
[ticket/14944] Add possibility to search for template loop indexes by key
Adds a new function to the template interface, and implements it in the context class. The function returns the ordinal index for a specified key, with the same structure that the key for alter_block_array. Reuses same code. Remove unneeded references, do nothing for int keys. PHPBB3-14944
Diffstat (limited to 'phpBB/phpbb/template/context.php')
-rw-r--r--phpBB/phpbb/template/context.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/phpBB/phpbb/template/context.php b/phpBB/phpbb/template/context.php
index e390c5a677..1617ca3d19 100644
--- a/phpBB/phpbb/template/context.php
+++ b/phpBB/phpbb/template/context.php
@@ -284,7 +284,7 @@ class context
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
- $block = &$this->tpldata;
+ $block = $this->tpldata;
for ($i = 0; $i < $blockcount; $i++)
{
if (($pos = strpos($blocks[$i], '[')) !== false)
@@ -305,11 +305,11 @@ class context
$name = $blocks[$i];
$index = sizeof($block[$name]) - 1;
}
- $block = &$block[$name];
- $block = &$block[$index];
+ $block = $block[$name];
+ $block = $block[$index];
}
- $block = &$block[$blocks[$i]]; // Traverse the last block
+ $block = $block[$blocks[$i]]; // Traverse the last block
// Change key to zero (change first position) if false and to last position if true
if ($key === false || $key === true)
@@ -331,7 +331,7 @@ class context
}
}
- return false;
+ return is_int($key) ? $key : false;
}
/**