From 4e107dac41f58d3ed6064809d8ee461ea8592e2c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 6 Feb 2009 16:39:18 +0000 Subject: 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. --- core/helpers/MY_url.php | 8 ++++---- core/helpers/core_installer.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'core/helpers') diff --git a/core/helpers/MY_url.php b/core/helpers/MY_url.php index dd3682df..c5f2d16c 100644 --- a/core/helpers/MY_url.php +++ b/core/helpers/MY_url.php @@ -19,9 +19,9 @@ */ class url extends url_Core { static function site($uri, $protocol=false) { - list($controller, $arg1, $args) = explode("/", $uri, 3); - if ($controller == "albums" || $controller == "photos") { - $uri = ORM::factory("item", $arg1)->relative_path(); + $parts = explode("/", $uri, 3); + if ($parts[0] == "albums" || $parts[0] == "photos") { + $uri = ORM::factory("item", empty($parts[1]) ? 1 : $parts[1])->relative_path(); } return parent::site($uri, $protocol); } @@ -33,7 +33,7 @@ class url extends url_Core { $count = count(Router::$segments); foreach (ORM::factory("item") - ->where("name", Router::$segments[$count - 1]) + ->where("path", Router::$segments[$count - 1]) ->where("level", $count + 1) ->find_all() as $match) { if ($match->relative_path() == Router::$current_uri) { diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index 24b9e993..eacb08eb 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -63,6 +63,7 @@ class core_installer { `level` int(9) NOT NULL, `mime_type` varchar(64) default NULL, `name` varchar(255) default NULL, + `path` varchar(255) default NULL, `owner_id` int(9) default NULL, `parent_id` int(9) NOT NULL, `resize_height` int(9) default NULL, -- cgit v1.2.3