From c1140b5c0aac2c2c1822a65ddd55151e093e2af4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 31 Dec 2008 07:13:34 +0000 Subject: Add Item_Model::url() and use it where appropriate. Cleans up some grotty looking stuff in themes. --- core/controllers/items.php | 2 +- core/models/item.php | 12 ++++++++++++ themes/default/views/album.html.php | 4 ++-- themes/default/views/photo.html.php | 4 ++-- themes/default/views/tag.html.php | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/core/controllers/items.php b/core/controllers/items.php index 60b2762f..e5f62db6 100644 --- a/core/controllers/items.php +++ b/core/controllers/items.php @@ -25,6 +25,6 @@ class Items_Controller extends REST_Controller { // differently. We could also just delegate here, but it feels more appropriate // to have a single canonical resource mapping. access::required("view", $item); - return url::redirect("{$item->type}s/$item->id"); + return url::redirect($item->url()); } } diff --git a/core/models/item.php b/core/models/item.php index a419c2f1..ffdaa7e9 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -102,6 +102,18 @@ class Item_Model extends ORM_MPTT { return $this; } + /** + * album: url::site("albums/2") + * photo: url::site("photos/3") + */ + public function url() { + if ($this->is_album()) { + return url::site("albums/$this->id"); + } else { + return url::site("photos/$this->id"); + } + } + /** * album: /var/albums/album1/album2 * photo: /var/albums/album1/album2/photo.jpg diff --git a/themes/default/views/album.html.php b/themes/default/views/album.html.php index b5995602..d36ff7c2 100644 --- a/themes/default/views/album.html.php +++ b/themes/default/views/album.html.php @@ -13,13 +13,13 @@
  • thumb_top($child) ?> - type}s/{$child->id}") ?>"> + photo -

    type}s/{$child->id}") ?>">title ?>

    +

    title ?>

    thumb_bottom($child) ?>