summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries/Gallery_View.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2011-04-26 09:48:21 -0700
committerBharat Mediratta <bharat@menalto.com>2011-04-26 09:48:21 -0700
commit5cf38ed816006af52fa08475d2957a6f18846887 (patch)
treeafc496762fad5527ef6b17508096ec38601b0f34 /modules/gallery/libraries/Gallery_View.php
parentc6d1d6a6aed96f772690b74ac0be482bc2128a8d (diff)
Stop using Pagination() and instead use $theme->pager() in views.
Move the pager() function up to Gallery_View and replace themes/admin_wind/views/pager.html.php (Pagination based) with a modified version from the wind theme in themes/admin_wind/views/paginator.html.php. Fixes #1718.
Diffstat (limited to 'modules/gallery/libraries/Gallery_View.php')
-rw-r--r--modules/gallery/libraries/Gallery_View.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php
index 1395686c..e04b9169 100644
--- a/modules/gallery/libraries/Gallery_View.php
+++ b/modules/gallery/libraries/Gallery_View.php
@@ -31,6 +31,52 @@ class Gallery_View_Core extends View {
}
/**
+ * Set up the data and render a pager.
+ *
+ * See themes/wind/views/pager.html for documentation on the variables generated here.
+ */
+ 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 == "collection") {
+ $v->page = $this->page;
+ $v->max_pages = $this->max_pages;
+ $v->total = $this->children_count;
+
+ if ($this->page != 1) {
+ $v->first_page_url = url::site(url::merge(array("page" => 1)));
+ $v->previous_page_url = url::site(url::merge(array("page" => $this->page - 1)));
+ }
+
+ if ($this->page != $this->max_pages) {
+ $v->next_page_url = url::site(url::merge(array("page" => $this->page + 1)));
+ $v->last_page_url = url::site(url::merge(array("page" => $this->max_pages)));
+ }
+
+ $v->first_visible_position = ($this->page - 1) * $this->page_size + 1;
+ $v->last_visible_position = min($this->page * $this->page_size, $v->total);
+ } else if ($this->page_type == "item") {
+ $v->position = $this->position;
+ $v->total = $this->sibling_count;
+ if ($this->previous_item) {
+ $v->previous_page_url = $this->previous_item->url();
+ }
+
+ if ($this->next_item) {
+ $v->next_page_url = $this->next_item->url();
+ }
+ }
+
+ return $v;
+ }
+
+ /**
* Begin gather up scripts or css files so that they can be combined into a single request.
*
* @param $types a comma separated list of types to combine, eg "script,css"