diff options
author | Kevin Chabowski <kevin@kch42.de> | 2011-10-05 15:18:23 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2011-10-05 15:18:23 +0200 |
commit | 990b708dff0c9eca3d576a890e962c4dd40226c8 (patch) | |
tree | f79512536a1ee8e8fd3b239fe9f96460dfc257ae /ratatoeskr/sys/models.php | |
parent | 0f185543bb9851fddc137f81a1e2a1d21589bc83 (diff) | |
download | ratatoeskr-cms-990b708dff0c9eca3d576a890e962c4dd40226c8.tar.gz ratatoeskr-cms-990b708dff0c9eca3d576a890e962c4dd40226c8.tar.bz2 ratatoeskr-cms-990b708dff0c9eca3d576a890e962c4dd40226c8.zip |
Fixed some bugs in db.php and models.php.
Diffstat (limited to 'ratatoeskr/sys/models.php')
-rw-r--r-- | ratatoeskr/sys/models.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php index eb8f26c..0ec4111 100644 --- a/ratatoeskr/sys/models.php +++ b/ratatoeskr/sys/models.php @@ -984,7 +984,7 @@ class Style */ public static function by_id($id) { - $obj = new seld; + $obj = new self; $obj->populate_by_sqlresult(qdb("SELECT `id`, `name`, `code` FROM `PREFIX_styles` WHERE `id` = %d", $id)); return $obj; } @@ -1183,9 +1183,18 @@ class Section $this->name = $sqlrow["name"]; $this->title = Multilingual::by_id($sqlrow["title"]); $this->template = $sqlrow["template"]; - $this->styles = array_filter_empty(array_map( - function($id) { try{return Style::by_id($id);}catch(DoesNotExistError $e){ return "";} }, - array_filter_empty(explode("+", $sqlrow["styles"])))); + $this->styles = array(); + foreach(explode("+", $sqlrow["styles"]) as $style_id) + { + if(!empty($style_id)) + { + try + { + $this->styles[] = Style::by_id($style_id); + } + catch(DoesNotExistError $e) { } + } + } } /* @@ -1285,7 +1294,7 @@ class Section $this->title->save(); qdb("UPDATE `PREFIX_sections` SET `name` = '%s', `title` = %d, `template` = '%s', `styles` = '%s' WHERE `id` = %d", - $this->name, $this->title->get_id(), $this->template, $styles); + $this->name, $this->title->get_id(), $this->template, $styles, $this->id); } /* |