[geeklog-cvs] geeklog: Renumber config arrays with numerical index when entrie...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Nov 29 04:45:35 EST 2009
changeset 7491:0c79d91761c6
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/0c79d91761c6
user: Dirk Haun <dirk at haun-online.de>
date: Sat Nov 28 23:23:23 2009 +0100
description:
Renumber config arrays with numerical index when entries are removed
diffstat:
system/classes/config.class.php | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diffs (32 lines):
diff -r 0d33295fe66f -r 0c79d91761c6 system/classes/config.class.php
--- a/system/classes/config.class.php Sat Nov 28 21:58:11 2009 +0100
+++ b/system/classes/config.class.php Sat Nov 28 23:23:23 2009 +0100
@@ -813,11 +813,28 @@
{
if (is_array($input_val)) {
$r = array();
+ $is_num = true;
+ $max_key = -1;
foreach ($input_val as $key => $val) {
if ($key !== 'placeholder') {
$r[$key] = $this->_validate_input($val);
+ if (is_numeric($key)) {
+ if ($key > $max_key) {
+ $max_key = $key;
+ }
+ } else {
+ $is_num = false;
+ }
}
}
+ if ($is_num && ($max_key >= 0) && ($max_key + 1 != count($r))) {
+ // re-number keys
+ $r2 = array();
+ foreach ($r as $val) {
+ $r2[] = $val;
+ }
+ $r = $r2;
+ }
} else {
$r = COM_stripslashes($input_val);
if ($r == 'b:0' OR $r == 'b:1') {
More information about the geeklog-cvs
mailing list