summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/models/item.php57
1 files changed, 36 insertions, 21 deletions
diff --git a/core/models/item.php b/core/models/item.php
index 5ab3935c..5a9e9b2c 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -20,35 +20,22 @@
class Item_Model extends ORM_MPTT {
protected $children = 'items';
+ /**
+ * Is this item an album?
+ * @return true if it's an album
+ */
public function is_album() {
return $this->type == 'album';
}
+ /**
+ * Is this item a photo?
+ * @return true if it's a photo
+ */
public function is_photo() {
return $this->type == 'photo';
}
- private function _relative_path($prefix, $tag, $suffix) {
- $paths = array($prefix);
- foreach ($this->parents() as $parent) {
- if ($parent->id > 1) {
- $paths[] = $parent->name;
- }
- }
- $paths[] = $this->name;
- $path = implode($paths, "/");
-
- if ($tag) {
- $pi = pathinfo($path);
- $path = "{$pi['dirname']}/{$pi['filename']}{$tag}.{$pi['extension']}";
- }
-
- if ($suffix) {
- $path .= $suffix;
- }
- return $path;
- }
-
/**
* album: /var/albums/album1/album2
* photo: /var/albums/album1/album2/photo.jpg
@@ -108,4 +95,32 @@ class Item_Model extends ORM_MPTT {
return $this->_relative_path(url::base() . "var/resizes", ".resize", "");
}
}
+
+ /**
+ * Return the relative path to this item's file.
+ * @param string $prefix prefix to the path (eg "/var" or "http://foo.com/var")
+ * @param string $tag a tag to specify before the extension (eg ".thumb", ".resize")
+ * @param string $suffix suffix to add to end of the path
+ * @return a path
+ */
+ private function _relative_path($prefix, $tag, $suffix) {
+ $paths = array($prefix);
+ foreach ($this->parents() as $parent) {
+ if ($parent->id > 1) {
+ $paths[] = $parent->name;
+ }
+ }
+ $paths[] = $this->name;
+ $path = implode($paths, "/");
+
+ if ($tag) {
+ $pi = pathinfo($path);
+ $path = "{$pi['dirname']}/{$pi['filename']}{$tag}.{$pi['extension']}";
+ }
+
+ if ($suffix) {
+ $path .= $suffix;
+ }
+ return $path;
+ }
}