summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/item.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers/item.php')
-rw-r--r--modules/gallery/helpers/item.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 664da812..dbad59b9 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -208,7 +208,30 @@ class item_Core {
return $model;
}
-
+
+ static function find_by_path($path) {
+ $path = trim($path, '/');
+
+ // The root path name is NULL, not '', hence this workaround.
+ if ($path == '') {
+ return ORM::factory("item", 1);
+ }
+
+ $paths = explode("/", $path);
+ $count = count($paths);
+ foreach (ORM::factory("item")
+ ->where('name', '=', $paths[$count - 1])
+ ->where('level', '=', $count + 1)
+ ->find_all() as $item) {
+ if (urldecode($item->relative_path()) == $path) {
+ return $item;
+ }
+ }
+
+ return false;
+ }
+
+
/**
* Return the root Item_Model
* @return Item_Model