From addd384bbdca6a9f066403c1d2919f3e863e072e Mon Sep 17 00:00:00 2001 From: Kriss Andsten Date: Wed, 22 Dec 2010 07:55:26 +0800 Subject: Minor changes to satisfy the G3 code standards. --- modules/gallery/helpers/item.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'modules/gallery/helpers') 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; -- cgit v1.2.3