diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-11-17 13:42:51 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-11-17 14:04:45 -0800 |
commit | 1067e68292852f524fceda4c6cf7cd5f7110b234 (patch) | |
tree | b42d9d2814a4a96bbdc63b5280cc22572402c0bb | |
parent | ade642cff4a4ca810f468723b04efc6f229916d8 (diff) |
Redesign the way that we consider page types to create buckets of page
types, and a subtype for specifics. Currently the top level bucket
collection, item, other
Here are the core subtypes so far:
collection: album, search, tag
item: movie, photo
other: login, reset, comment-fragment, comment
It's legal to create new page_subtypes whenever you want. Use the
appropriate page_type to get the coarse grain behavior that you want.
-rw-r--r-- | modules/comment/controllers/comments.php | 4 | ||||
-rw-r--r-- | modules/gallery/controllers/albums.php | 4 | ||||
-rw-r--r-- | modules/gallery/controllers/movies.php | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/photos.php | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/quick.php | 4 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 12 | ||||
-rw-r--r-- | modules/gallery/helpers/item.php | 6 | ||||
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 15 | ||||
-rw-r--r-- | modules/search/controllers/search.php | 2 | ||||
-rw-r--r-- | modules/search/helpers/search_theme.php | 2 | ||||
-rw-r--r-- | modules/tag/controllers/tags.php | 2 | ||||
-rw-r--r-- | modules/tag/helpers/tag_block.php | 2 | ||||
-rw-r--r-- | modules/user/controllers/password.php | 2 | ||||
-rw-r--r-- | themes/wind/views/page.html.php | 8 | ||||
-rw-r--r-- | themes/wind/views/paginator.html.php | 13 | ||||
-rw-r--r-- | themes/wind/views/sidebar.html.php | 8 |
16 files changed, 46 insertions, 42 deletions
diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php index 09b9c607..74e0c974 100644 --- a/modules/comment/controllers/comments.php +++ b/modules/comment/controllers/comments.php @@ -47,7 +47,7 @@ class Comments_Controller extends REST_Controller { break; case "html": - $view = new Theme_View("comments.html", "page"); + $view = new Theme_View("comments.html", "other", "comment"); $view->comments = $comments; print $view; break; @@ -130,7 +130,7 @@ class Comments_Controller extends REST_Controller { "created" => $comment->created, "text" => nl2br(html::purify($comment->text))))); } else { - $view = new Theme_View("comment.html", "fragment"); + $view = new Theme_View("comment.html", "other", "comment-fragment"); $view->comment = $comment; print $view; } diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 4e37649c..e67df6f6 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,7 +26,7 @@ class Albums_Controller extends Items_Controller { $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - $view = new Theme_View("page.html", "login"); + $view = new Theme_View("page.html", "other", "login"); $view->page_title = t("Log in to Gallery"); $view->content = new View("login_ajax.html"); $view->content->form = auth::get_login_form("login/auth_html"); @@ -64,7 +64,7 @@ class Albums_Controller extends Items_Controller { url::redirect($album->abs_url("page=$max_pages")); } - $template = new Theme_View("page.html", "album"); + $template = new Theme_View("page.html", "collection", "album"); $template->set_global("page", $page); $template->set_global("max_pages", $max_pages); $template->set_global("page_size", $page_size); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 5e78376b..2e2e837c 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -35,7 +35,7 @@ class Movies_Controller extends Items_Controller { list ($next_item) = $movie->parent()->viewable()->children(1, $position, $where); } - $template = new Theme_View("page.html", "movie"); + $template = new Theme_View("page.html", "item", "movie"); $template->set_global("item", $movie); $template->set_global("children", array()); $template->set_global("children_count", 0); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index b9adfd90..0c2ff6ee 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -35,7 +35,7 @@ class Photos_Controller extends Items_Controller { list ($next_item) = $photo->parent()->viewable()->children(1, $position, $where); } - $template = new Theme_View("page.html", "photo"); + $template = new Theme_View("page.html", "item", "photo"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", 0); diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index a1e7dcc3..f2a77033 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -55,7 +55,7 @@ class Quick_Controller extends Controller { } } - if (Input::instance()->get("page_type") == "album") { + if (Input::instance()->get("page_type") == "collection") { print json_encode( array("src" => $item->thumb_url() . "?rnd=" . rand(), "width" => $item->thumb_width, @@ -118,7 +118,7 @@ class Quick_Controller extends Controller { $item->delete(); message::success($msg); - if (Input::instance()->get("page_type") == "album") { + if (Input::instance()->get("page_type") == "collection") { print json_encode(array("result" => "success", "reload" => 1)); } else { print json_encode(array("result" => "success", diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index cd72d01e..3139951f 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -98,7 +98,7 @@ class gallery_event_Core { } static function user_menu($menu, $theme) { - if ($theme->page_type != "login") { + if ($theme->page_subtype != "login") { $user = identity::active_user(); if ($user->guest) { $menu->append(Menu::factory("dialog") @@ -125,7 +125,7 @@ class gallery_event_Core { } static function site_menu($menu, $theme) { - if ($theme->page_type != "login") { + if ($theme->page_subtype != "login") { $menu->append(Menu::factory("link") ->id("home") ->label(t("Home")) @@ -271,6 +271,7 @@ class gallery_event_Core { if (access::can("edit", $item)) { $page_type = $theme->page_type(); + $page_subtype = $theme->page_subtype(); switch ($item->type) { case "movie": $edit_title = t("Edit this movie"); @@ -298,7 +299,6 @@ class gallery_event_Core { ->css_class("ui-icon-pencil") ->url(url::site("quick/form_edit/$item->id?page_type=$page_type"))); - if ($item->is_photo() && graphics::can("rotate")) { $options_menu ->append( @@ -319,9 +319,9 @@ class gallery_event_Core { ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type"))); } - // @todo Don't move photos from the photo page; we don't yet have a good way of redirecting after - // move - if ($page_type == "album") { + // @todo Don't move photos from the photo page; we don't yet have a good way of redirecting + // after move + if ($page_subtype == "album") { $options_menu ->append(Menu::factory("dialog") ->id("move") diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index b3b6d0bb..8f96c3d9 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -124,11 +124,7 @@ class item_Core { * @return string form */ static function get_delete_form($item) { - if (Input::instance()->get("page_type") == "album") { - $page_type = "album"; - } else { - $page_type = "photo"; - } + $page_type = Input::instance()->get("page_type"); $form = new Forge( "quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "g-confirm-delete")); $form->hidden("_method")->value("put"); diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index e98914c4..07ba3bbf 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -23,11 +23,12 @@ class Theme_View_Core extends Gallery_View { * * @throws Kohana_Exception if the requested view cannot be found * @param string $name view name - * @param string $page_type page type: album, photo, tags, etc + * @param string $page_type page type: collection, item, or other + * @param string $page_subtype page sub type: album, photo, tags, etc * @param string $theme_name view name * @return void */ - public function __construct($name, $page_type) { + public function __construct($name, $page_type, $page_subtype) { $theme_name = module::get_var("gallery", "active_site_theme"); if (!file_exists(THEMEPATH . $theme_name)) { module::set_var("gallery", "active_site_theme", "wind"); @@ -45,8 +46,9 @@ class Theme_View_Core extends Gallery_View { $this->set_global("theme", $this); $this->set_global("user", identity::active_user()); $this->set_global("page_type", $page_type); + $this->set_global("page_subtype", $page_subtype); $this->set_global("page_title", null); - if ($page_type == "album") { + if ($page_type == "collection") { $this->set_global("thumb_proportion", $this->thumb_proportion()); } @@ -78,6 +80,10 @@ class Theme_View_Core extends Gallery_View { return $this->page_type; } + public function page_subtype() { + return $this->page_subtype; + } + public function user_menu() { $menu = Menu::factory("root") ->css_id("g-login-menu") @@ -143,12 +149,13 @@ class Theme_View_Core extends Gallery_View { public function paginator() { $v = new View("paginator.html"); $v->page_type = $this->page_type; + $v->page_subtype = $this->page_subtype; $v->first_page_url = null; $v->previous_page_url = null; $v->next_page_url = null; $v->last_page_url = null; - if ($this->page_type == "album" || $this->page_type == "tag") { + if ($this->page_type == "collection") { $v->page = $this->page; $v->max_pages = $this->max_pages; $v->total = $this->children_count; diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index cf9e271f..539e063f 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -33,7 +33,7 @@ class Search_Controller extends Controller { $max_pages = max(ceil($count / $page_size), 1); - $template = new Theme_View("page.html", "search"); + $template = new Theme_View("page.html", "other", "search"); $template->set_global("page", $page); $template->set_global("max_pages", $max_pages); $template->set_global("page_size", $page_size); diff --git a/modules/search/helpers/search_theme.php b/modules/search/helpers/search_theme.php index 24125d05..1bb6121c 100644 --- a/modules/search/helpers/search_theme.php +++ b/modules/search/helpers/search_theme.php @@ -19,7 +19,7 @@ */ class search_theme_Core { static function header_top($theme) { - if ($theme->page_type() != "login") { + if ($theme->page_subtype() != "login") { $view = new View("search_link.html"); return $view->render(); }else { diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index c3b14fcc..52001719 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -34,7 +34,7 @@ class Tags_Controller extends REST_Controller { url::redirect($album->abs_url("page=$max_pages")); } - $template = new Theme_View("page.html", "tag"); + $template = new Theme_View("page.html", "collection", "tag"); $template->set_global("page", $page); $template->set_global("max_pages", $max_pages); $template->set_global("page_size", $page_size); diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php index 20ef18fa..f0b56175 100644 --- a/modules/tag/helpers/tag_block.php +++ b/modules/tag/helpers/tag_block.php @@ -32,7 +32,7 @@ class tag_block_Core { $block->content = new View("tag_block.html"); $block->content->cloud = tag::cloud(30); - if ($theme->item() && $theme->page_type() != "tag" && access::can("edit", $theme->item())) { + if ($theme->item() && $theme->page_subtype() != "tag" && access::can("edit", $theme->item())) { $controller = new Tags_Controller(); $block->content->form = tag::get_add_form($theme->item()); } else { diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php index 5f36b554..e18e76b6 100644 --- a/modules/user/controllers/password.php +++ b/modules/user/controllers/password.php @@ -93,7 +93,7 @@ class Password_Controller extends Controller { } private function _new_password_form($hash=null) { - $template = new Theme_View("page.html", "reset"); + $template = new Theme_View("page.html", "other", "reset"); $form = new Forge("password/do_reset", "", "post", array("id" => "g-change-password-form")); $group = $form->group("reset")->label(t("Change Password")); diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index f41dcd27..6056f54e 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -33,7 +33,7 @@ <link rel="stylesheet" type="text/css" href="<?= $theme->url("css/fix-ie.css") ?>" media="screen,print,projection" /> <![endif]--> - <? if ($theme->page_type == 'album'): ?> + <? if ($theme->page_type == "collection"): ?> <? if ($thumb_proportion != 1): ?> <? $new_width = $thumb_proportion * 213 ?> <? $new_height = $thumb_proportion * 240 ?> @@ -61,10 +61,10 @@ <?= $theme->script("ui.init.js") ?> <? /* These are page specific, but if we put them before $theme->head() they get combined */ ?> - <? if ($theme->page_type == "photo"): ?> + <? if ($theme->page_subtype == "photo"): ?> <?= $theme->script("jquery.scrollTo.js") ?> <?= $theme->script("gallery.show_full_size.js") ?> - <? elseif ($theme->page_type == "movie"): ?> + <? elseif ($theme->page_subtype == "movie"): ?> <?= $theme->script("flowplayer.js") ?> <? endif ?> @@ -122,7 +122,7 @@ </div> </div> <div id="g-sidebar" class="yui-b"> - <? if ($theme->page_type != "login"): ?> + <? if ($theme->page_subtype != "login"): ?> <?= new View("sidebar.html") ?> <? endif ?> </div> diff --git a/themes/wind/views/paginator.html.php b/themes/wind/views/paginator.html.php index 5d300cf4..f6c03084 100644 --- a/themes/wind/views/paginator.html.php +++ b/themes/wind/views/paginator.html.php @@ -6,12 +6,13 @@ // for album views. // // Available variables for all page types: -// $page_type - "album", "movie", "photo" or "tag" +// $page_type - "collection", "item", or "other" +// $page_subtype - "album", "movie", "photo", "tag", etc. // $previous_page_url - the url to the previous page, if there is one // $next_page_url - the url to the next page, if there is one // $total - the total number of photos in this album // -// Available for the "album" and "tag" page types: +// Available for the "collection" page types: // $page - what page number we're on // $max_pages - the maximum page number // $page_size - the page size @@ -20,14 +21,14 @@ // $first_visible_position - the position number of the first visible photo on this page // $last_visible_position - the position number of the last visible photo on this page // -// Available for "photo" and "movie" page types: +// Available for "item" page types: // $position - the position number of this photo // ?> <ul class="g-pager ui-helper-clearfix"> <li class="g-first"> - <? if ($page_type == "album" || $page_type == "tag"): ?> + <? if ($page_type == "collection"): ?> <? if (isset($first_page_url)): ?> <a href="<?= $first_page_url ?>" class="g-button ui-icon-left ui-state-default ui-corner-all"> <span class="ui-icon ui-icon-seek-first"></span><?= t("First") ?></a> @@ -48,7 +49,7 @@ <li class="g-info"> <? if ($total): ?> - <? if ($page_type == "album" || $page_type == "tag"): ?> + <? if ($page_type == "collection"): ?> <?= /* @todo This message isn't easily localizable */ t2("Photo %from_number of %count", "Photos %from_number - %to_number of %count", @@ -73,7 +74,7 @@ <span class="ui-icon ui-icon-seek-next"></span><?= t("Next") ?></a> <? endif ?> - <? if ($page_type == "album" || $page_type == "tag"): ?> + <? if ($page_type == "collection"): ?> <? if (isset($last_page_url)): ?> <a href="<?= $last_page_url ?>" class="g-button ui-icon-right ui-state-default ui-corner-all"> <span class="ui-icon ui-icon-seek-end"></span><?= t("Last") ?></a> diff --git a/themes/wind/views/sidebar.html.php b/themes/wind/views/sidebar.html.php index cd50fc01..086d1359 100644 --- a/themes/wind/views/sidebar.html.php +++ b/themes/wind/views/sidebar.html.php @@ -1,13 +1,13 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <?= $theme->sidebar_top() ?> <div id="g-view-menu" class="g-buttonset ui-helper-clearfix"> - <? if ($page_type == "album"):?> + <? if ($page_subtype == "album"):?> <?= $theme->album_menu() ?> - <? elseif ($page_type == "photo") : ?> + <? elseif ($page_subtype == "photo") : ?> <?= $theme->photo_menu() ?> - <? elseif ($page_type == "movie") : ?> + <? elseif ($page_subtype == "movie") : ?> <?= $theme->movie_menu() ?> - <? elseif ($page_type == "tag") : ?> + <? elseif ($page_subtype == "tag") : ?> <?= $theme->tag_menu() ?> <? endif ?> </div> |