diff options
author | Kriss Andsten <kriss@sverok.se> | 2010-12-22 07:55:26 +0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-12-22 08:22:25 +0800 |
commit | addd384bbdca6a9f066403c1d2919f3e863e072e (patch) | |
tree | 4360a3db4e1b03e58c9d859286892713ef3dba4a /modules/gallery/helpers | |
parent | 48640005a4edac955d9087f62fed1ab5f756b686 (diff) |
Minor changes to satisfy the G3 code standards.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/item.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index dbad59b9..f38d9888 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -208,20 +208,25 @@ class item_Core { return $model; } - + + /** + * Return an item by path. + * @param string $path + * @return object item + */ static function find_by_path($path) { - $path = trim($path, '/'); + $path = trim($path, "/"); // The root path name is NULL, not '', hence this workaround. if ($path == '') { - return ORM::factory("item", 1); + return ORM::factory("item", item::root()); } $paths = explode("/", $path); $count = count($paths); foreach (ORM::factory("item") - ->where('name', '=', $paths[$count - 1]) - ->where('level', '=', $count + 1) + ->where("name", "=", $paths[$count - 1]) + ->where("level", "=", $count + 1) ->find_all() as $item) { if (urldecode($item->relative_path()) == $path) { return $item; |