mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[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
This commit is contained in:
parent
cff57f9076
commit
c656bd60ef
1 changed files with 5 additions and 5 deletions
|
@ -284,7 +284,7 @@ class context
|
||||||
$blocks = explode('.', $blockname);
|
$blocks = explode('.', $blockname);
|
||||||
$blockcount = sizeof($blocks) - 1;
|
$blockcount = sizeof($blocks) - 1;
|
||||||
|
|
||||||
$block = &$this->tpldata;
|
$block = $this->tpldata;
|
||||||
for ($i = 0; $i < $blockcount; $i++)
|
for ($i = 0; $i < $blockcount; $i++)
|
||||||
{
|
{
|
||||||
if (($pos = strpos($blocks[$i], '[')) !== false)
|
if (($pos = strpos($blocks[$i], '[')) !== false)
|
||||||
|
@ -305,11 +305,11 @@ class context
|
||||||
$name = $blocks[$i];
|
$name = $blocks[$i];
|
||||||
$index = sizeof($block[$name]) - 1;
|
$index = sizeof($block[$name]) - 1;
|
||||||
}
|
}
|
||||||
$block = &$block[$name];
|
$block = $block[$name];
|
||||||
$block = &$block[$index];
|
$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
|
// Change key to zero (change first position) if false and to last position if true
|
||||||
if ($key === false || $key === true)
|
if ($key === false || $key === true)
|
||||||
|
@ -331,7 +331,7 @@ class context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return is_int($key) ? $key : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue