mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-22 23:05:18 -04:00
Convert all item->type == "album" to item->is_album()
Convert all item->type == "photo" to item->is_photo()
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user