diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-06 16:39:18 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-06 16:39:18 +0000 |
commit | 4e107dac41f58d3ed6064809d8ee461ea8592e2c (patch) | |
tree | 06933f36bc392a6bc9623bd304581b6e690799ab /core/models | |
parent | 48acd42f9b1dfee5ba011501a1c989eb7fde0373 (diff) |
Implement fix for ticket #35. *** Requires reinstall of core ***
* Added new field in items table (path) which is sanitized version of
name.
* Added __set method on Items_module to set the path field whenever
the name field is changed.
* Made some changes to the scaffolding so missing the path column
would not kill the scaffolding.
* Changed MY_url::site so not having a 3rd parameter won't throw an error.
Diffstat (limited to 'core/models')
-rw-r--r-- | core/models/item.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/core/models/item.php b/core/models/item.php index e29f3245..e188e0a3 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -215,10 +215,10 @@ class Item_Model extends ORM_MPTT { if (empty($this->relative_path)) { foreach ($this->parents() as $parent) { if ($parent->id > 1) { - $paths[] = $parent->name; + $paths[] = $parent->path; } } - $paths[] = $this->name; + $paths[] = $this->path; $this->relative_path = implode($paths, "/"); } return $this->relative_path; @@ -242,6 +242,16 @@ class Item_Model extends ORM_MPTT { } /** + * @see ORM::__get() + */ + public function __set($column, $value) { + if ($column == "name") { + parent::__set("path", preg_replace("/[^A-Za-z0-9\.\-_]/", "_", $value)); + } + parent::__set($column, $value); + } + + /** * @see ORM::save() */ public function save() { |