mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
- fixing alter_block_array function as suggested by david.
git-svn-id: file:///svn/phpbb/trunk@5379 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
95e8f761ce
commit
d02f498745
1 changed files with 16 additions and 4 deletions
|
@ -352,7 +352,7 @@ class template
|
||||||
* alter_block_array('loop', $vararray, 2); // Insert vararray at position 2
|
* alter_block_array('loop', $vararray, 2); // Insert vararray at position 2
|
||||||
* alter_block_array('loop', $vararray, array('KEY' => 'value')); // Insert vararray at the position where the key 'KEY' has the value of 'value'
|
* alter_block_array('loop', $vararray, array('KEY' => 'value')); // Insert vararray at the position where the key 'KEY' has the value of 'value'
|
||||||
* alter_block_array('loop', $vararray, false); // Insert vararray at first position
|
* alter_block_array('loop', $vararray, false); // Insert vararray at first position
|
||||||
* alter_block_array('loop', $vararray, true); //Insert vararray at last position (assign_block_vars equivalence)
|
* alter_block_array('loop', $vararray, true); // Insert vararray at last position (assign_block_vars equivalence)
|
||||||
*
|
*
|
||||||
* alter_block_array('loop', $vararray, 2, 'change'); // Change/Merge vararray with existing array at position 2
|
* alter_block_array('loop', $vararray, 2, 'change'); // Change/Merge vararray with existing array at position 2
|
||||||
* alter_block_array('loop', $vararray, array('KEY' => 'value'), 'change'); // Change/Merge vararray with existing array at the position where the key 'KEY' has the value of 'value'
|
* alter_block_array('loop', $vararray, array('KEY' => 'value'), 'change'); // Change/Merge vararray with existing array at the position where the key 'KEY' has the value of 'value'
|
||||||
|
@ -395,7 +395,7 @@ class template
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
$key = ($key === false) ? 0 : sizeof($this->_tpldata[$blockname])-1;
|
$key = ($key === false) ? 0 : sizeof($this->_tpldata[$blockname]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get correct position if array given
|
// Get correct position if array given
|
||||||
|
@ -425,11 +425,18 @@ class template
|
||||||
if ($mode == 'insert')
|
if ($mode == 'insert')
|
||||||
{
|
{
|
||||||
// Make sure we are not exceeding the last iteration
|
// Make sure we are not exceeding the last iteration
|
||||||
if ($key > sizeof($this->_tpldata[$blockname]))
|
if ($key >= sizeof($this->_tpldata[$blockname]))
|
||||||
{
|
{
|
||||||
$key = sizeof($this->_tpldata[$blockname]);
|
$key = sizeof($this->_tpldata[$blockname]);
|
||||||
|
unset($this->_tpldata[$blockname][($key - 1)]['S_LAST_ROW']);
|
||||||
|
$vararray['S_LAST_ROW'] = true;
|
||||||
}
|
}
|
||||||
|
else if ($key === 0)
|
||||||
|
{
|
||||||
|
unset($this->_tpldata[$blockname][0]['S_FIRST_ROW']);
|
||||||
|
$vararray['S_FIRST_ROW'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Re-position template blocks
|
// Re-position template blocks
|
||||||
for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--)
|
for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--)
|
||||||
{
|
{
|
||||||
|
@ -447,6 +454,11 @@ class template
|
||||||
// Which block to change?
|
// Which block to change?
|
||||||
if ($mode == 'change')
|
if ($mode == 'change')
|
||||||
{
|
{
|
||||||
|
if ($key == sizeof($this->_tpldata[$blockname]))
|
||||||
|
{
|
||||||
|
$key--;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_tpldata[$blockname][$key] = array_merge($this->_tpldata[$blockname][$key], &$vararray);
|
$this->_tpldata[$blockname][$key] = array_merge($this->_tpldata[$blockname][$key], &$vararray);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue