summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-02-06 03:47:36 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-02-06 03:47:36 +0000
commit80d4df3a4a6fefcf69de5245934b4b0bfc0f8e20 (patch)
tree7035bf37330fabce2996f6a867c77ea00295b216
parent196ef392ab1dc32154ec8dbe49340d4aefb0d082 (diff)
Convert all item->type == "album" to item->is_album()
Convert all item->type == "photo" to item->is_photo()
-rw-r--r--core/controllers/move.php2
-rw-r--r--core/controllers/permissions.php4
-rw-r--r--core/controllers/quick.php6
-rw-r--r--core/helpers/access.php2
-rw-r--r--core/helpers/album.php2
-rw-r--r--core/helpers/core_menu.php4
-rw-r--r--core/helpers/graphics.php4
-rw-r--r--core/helpers/photo.php2
-rw-r--r--core/libraries/ORM_MPTT.php2
-rw-r--r--core/models/item.php10
-rw-r--r--core/views/quick_pane.html.php2
-rw-r--r--modules/media_rss/helpers/media_rss.php2
12 files changed, 21 insertions, 21 deletions
diff --git a/core/controllers/move.php b/core/controllers/move.php
index 26c507f9..069de771 100644
--- a/core/controllers/move.php
+++ b/core/controllers/move.php
@@ -39,7 +39,7 @@ class Move_Controller extends Controller {
// If the target has no cover item, make this it.
if ($target->album_cover_item_id == null) {
$target->album_cover_item_id =
- $source->type == "album" ? $source->album_cover_item_id : $source->id;
+ $source->is_album() ? $source->album_cover_item_id : $source->id;
$target->save();
graphics::generate($target);
}
diff --git a/core/controllers/permissions.php b/core/controllers/permissions.php
index 8ffb63de..f99124dd 100644
--- a/core/controllers/permissions.php
+++ b/core/controllers/permissions.php
@@ -22,7 +22,7 @@ class Permissions_Controller extends Controller {
$item = ORM::factory("item", $id);
access::required("edit", $item);
- if ($item->type != "album") {
+ if (!$item->is_album()) {
access::forbidden();
}
@@ -38,7 +38,7 @@ class Permissions_Controller extends Controller {
$item = ORM::factory("item", $id);
access::required("edit", $item);
- if ($item->type != "album") {
+ if (!$item->is_album()) {
access::forbidden();
}
diff --git a/core/controllers/quick.php b/core/controllers/quick.php
index 6fd0ae62..77a39bf5 100644
--- a/core/controllers/quick.php
+++ b/core/controllers/quick.php
@@ -80,9 +80,9 @@ class Quick_Controller extends Controller {
$parent = $item->parent();
access::required("edit", $parent);
- if ($item->type == "photo") {
+ if ($item->is_photo()) {
$parent->album_cover_item_id = $item->id;
- } else if ($item->type == "album") {
+ } else if ($item->is_album()) {
$parent->album_cover_item_id = $item->album_cover_item_id;
}
@@ -100,7 +100,7 @@ class Quick_Controller extends Controller {
$parent = $item->parent();
- if ($item->type == "album") {
+ if ($item->is_album()) {
$msg = t("Deleted album <b>%title</b>", array("title" => $item->title));
} else {
$msg = t("Deleted photo <b>%title</b>", array("title" => $item->title));
diff --git a/core/helpers/access.php b/core/helpers/access.php
index 23db5782..60e8557d 100644
--- a/core/helpers/access.php
+++ b/core/helpers/access.php
@@ -188,7 +188,7 @@ class access_Core {
if (!$album->loaded) {
throw new Exception("@todo INVALID_ALBUM $album->id");
}
- if ($album->type != "album") {
+ if (!$album->is_album()) {
throw new Exception("@todo INVALID_ALBUM_TYPE not an album");
}
$access = model_cache::get("access_intent", $album->id, "item_id");
diff --git a/core/helpers/album.php b/core/helpers/album.php
index 223a057d..c45b9bd8 100644
--- a/core/helpers/album.php
+++ b/core/helpers/album.php
@@ -33,7 +33,7 @@ class album_Core {
* @return Item_Model
*/
static function create($parent, $name, $title, $description=null, $owner_id=null) {
- if (!$parent->loaded || $parent->type != "album") {
+ if (!$parent->loaded || !$parent->is_album()) {
throw new Exception("@todo INVALID_PARENT");
}
diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php
index 4720a00d..bb87c760 100644
--- a/core/helpers/core_menu.php
+++ b/core/helpers/core_menu.php
@@ -38,12 +38,12 @@ class core_menu_Core {
->label(t("Options"))
->append(Menu::factory("dialog")
->id("edit_item")
- ->label($item->type == "album" ? t("Edit album") : t("Edit photo"))
+ ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
->url(url::site("form/edit/{$item->type}s/$item->id"))));
// @todo Move album options menu to the album quick edit pane
// @todo Create resized item quick edit pane menu
- if ($item->type == "album") {
+ if ($item->is_album()) {
$options_menu
->append(Menu::factory("dialog")
->id("add_item")
diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php
index cd112e1b..4c8f3bb1 100644
--- a/core/helpers/graphics.php
+++ b/core/helpers/graphics.php
@@ -68,7 +68,7 @@ class graphics_Core {
* @param Item_Model $item
*/
static function generate($item) {
- if ($item->type == "album") {
+ if ($item->is_album()) {
$cover = $item->album_cover();
if (!$cover) {
return;
@@ -82,7 +82,7 @@ class graphics_Core {
if ($item->thumb_dirty) {
$ops["thumb"] = $item->thumb_path();
}
- if ($item->resize_dirty && $item->type != "album") {
+ if ($item->resize_dirty && !$item->is_album()) {
$ops["resize"] = $item->resize_path();
}
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index a2958aec..349e8760 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -35,7 +35,7 @@ class photo_Core {
*/
static function create($parent, $filename, $name, $title,
$description=null, $owner_id=null) {
- if (!$parent->loaded || $parent->type != "album") {
+ if (!$parent->loaded || !$parent->is_album()) {
throw new Exception("@todo INVALID_PARENT");
}
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php
index 4fa0a77a..bcbdde4e 100644
--- a/core/libraries/ORM_MPTT.php
+++ b/core/libraries/ORM_MPTT.php
@@ -204,7 +204,7 @@ class ORM_MPTT_Core extends ORM {
* @return ORM_MTPP
*/
function move_to($target) {
- if ($target->type != "album") {
+ if (!$target->is_album()) {
throw new Exception("@todo INVALID_MOVE_TYPE $target->type");
}
diff --git a/core/models/item.php b/core/models/item.php
index f78d50b3..e29f3245 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -173,7 +173,7 @@ class Item_Model extends ORM_MPTT {
*/
public function thumb_path() {
return VARPATH . "thumbs/" . $this->relative_path() .
- ($this->type == "album" ? "/.album.jpg" : "");
+ ($this->is_album() ? "/.album.jpg" : "");
}
/**
@@ -184,7 +184,7 @@ class Item_Model extends ORM_MPTT {
return ($full_uri ?
url::abs_file("var/thumbs/" . $this->relative_path()) :
url::file("var/thumbs/" . $this->relative_path())) .
- ($this->type == "album" ? "/.album.jpg" : "");
+ ($this->is_album() ? "/.album.jpg" : "");
}
/**
@@ -193,7 +193,7 @@ class Item_Model extends ORM_MPTT {
*/
public function resize_path() {
return VARPATH . "resizes/" . $this->relative_path() .
- ($this->type == "album" ? "/.album.jpg" : "");
+ ($this->is_album() ? "/.album.jpg" : "");
}
/**
@@ -204,7 +204,7 @@ class Item_Model extends ORM_MPTT {
return ($full_uri ?
url::abs_file("var/resizes/" . $this->relative_path()) :
url::file("var/resizes/" . $this->relative_path())) .
- ($this->type == "album" ? "/.album.jpg" : "");
+ ($this->is_album() ? "/.album.jpg" : "");
}
/**
@@ -259,7 +259,7 @@ class Item_Model extends ORM_MPTT {
* @return Item_Model or null if there's no cover
*/
public function album_cover() {
- if ($this->type != "album") {
+ if (!$this->is_album()) {
return null;
}
diff --git a/core/views/quick_pane.html.php b/core/views/quick_pane.html.php
index 78a6c1ce..b5f40d94 100644
--- a/core/views/quick_pane.html.php
+++ b/core/views/quick_pane.html.php
@@ -6,7 +6,7 @@
</span>
</a>
-<? if ($item->type == "photo" && graphics::can("rotate")): ?>
+<? if ($item->is_album() && graphics::can("rotate")): ?>
<a class="clockwise" href="<?= url::site("quick/rotate/$item->id/cw?csrf=" . access::csrf_token()) ?>"
title="<?= t("Rotate 90 degrees clockwise") ?>">
<span>
diff --git a/modules/media_rss/helpers/media_rss.php b/modules/media_rss/helpers/media_rss.php
index 9522727d..3f98277f 100644
--- a/modules/media_rss/helpers/media_rss.php
+++ b/modules/media_rss/helpers/media_rss.php
@@ -20,7 +20,7 @@
class media_rss_Core {
static function item_feed($item) {
- $id = $item->type == "album" ? $item->id : $item->parent_id;
+ $id = $item->is_album() ? $item->id : $item->parent_id;
return url::site("media_rss/albums/$id");
}