summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/libraries/ORM_MPTT.php26
-rw-r--r--core/models/item.php11
2 files changed, 37 insertions, 0 deletions
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php
index f79ea910..023960e3 100644
--- a/core/libraries/ORM_MPTT.php
+++ b/core/libraries/ORM_MPTT.php
@@ -137,6 +137,32 @@ class ORM_MPTT_Core extends ORM {
}
/**
+ * Return all of the children of the specified type, ordered by id.
+ *
+ * @chainable
+ * @param string type to return
+ * @param integer SQL limit
+ * @param integer SQL offset
+ * @param boolean flag to return all grandchildren as well
+ * @return array ORM
+ */
+ function decendents_by_type($type="photo", $limit=NULL, $offset=0, $grand_children=false) {
+ if (!isset($this->children)) {
+ if (!empty($grandchildren)) {
+ $this->where("left >=", $this->left)
+ ->where("right <=", $this->right);
+ } else {
+ $this->where("parent_id", $this->id);
+ }
+ $this->children =
+ $this->where("type", $type)
+ ->orderby("id", "ASC")
+ ->find_all($limit, $offset);
+ }
+ return $this->children;
+ }
+
+ /**
* @see ORM::reload
*/
function reload() {
diff --git a/core/models/item.php b/core/models/item.php
index 5fcd16d0..f03d1a91 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -50,6 +50,14 @@ class Item_Model extends ORM_MPTT {
}
/**
+ * album: http://example.com/gallery3/var/resizes/album1/
+ * photo: http://example.com/gallery3/var/albums/album1/photo.jpg
+ */
+ public function url($index = FALSE, $protocol = FALSE) {
+ return $this->_relative_path(url::base($index, $protocol) . "albums", "", "");
+ }
+
+ /**
* album: /var/resizes/album1/.thumb.jpg
* photo: /var/albums/album1/photo.thumb.jpg
*/
@@ -183,6 +191,9 @@ class Item_Model extends ORM_MPTT {
} catch (Exception $e) {
return null;
}
+ } else if ($column == "height" || $column == "width") {
+ $dims = getimagesize($this->file_path());
+ return $column == "width" ? $dims[0] : $dims[1];
} else {
return parent::__get($column);
}