diff options
| author | Meik Sievertsen <acydburn@phpbb.com> | 2005-12-27 08:50:42 +0000 |
|---|---|---|
| committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-12-27 08:50:42 +0000 |
| commit | d02f498745b43c2a74ef03c4c3772527062e7f17 (patch) | |
| tree | 6fa09577087e0de7dcbda493547944be40095f0e /phpBB/includes/template.php | |
| parent | 95e8f761ceaf21cb23eafc9d75a5f947fc3e3afd (diff) | |
| download | forums-d02f498745b43c2a74ef03c4c3772527062e7f17.tar forums-d02f498745b43c2a74ef03c4c3772527062e7f17.tar.gz forums-d02f498745b43c2a74ef03c4c3772527062e7f17.tar.bz2 forums-d02f498745b43c2a74ef03c4c3772527062e7f17.tar.xz forums-d02f498745b43c2a74ef03c4c3772527062e7f17.zip | |
- fixing alter_block_array function as suggested by david.
git-svn-id: file:///svn/phpbb/trunk@5379 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/template.php')
| -rw-r--r-- | phpBB/includes/template.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 595e2fa436..6ab44455ac 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -352,7 +352,7 @@ class template * 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, 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, 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 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 @@ -425,11 +425,18 @@ class template if ($mode == 'insert') { // 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]); + 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 for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--) { @@ -447,6 +454,11 @@ class template // Which block to change? if ($mode == 'change') { + if ($key == sizeof($this->_tpldata[$blockname])) + { + $key--; + } + $this->_tpldata[$blockname][$key] = array_merge($this->_tpldata[$blockname][$key], &$vararray); return true; } |
