summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/comment/controllers/admin_manage_comments.php13
-rw-r--r--modules/comment/views/admin_manage_comments.html.php2
-rw-r--r--modules/gallery/libraries/Gallery_View.php46
-rw-r--r--modules/gallery/libraries/MY_Pagination.php35
-rw-r--r--modules/gallery/libraries/Theme_View.php46
-rw-r--r--modules/user/controllers/admin_users.php8
-rw-r--r--modules/user/views/admin_users.html.php2
7 files changed, 63 insertions, 89 deletions
diff --git a/modules/comment/controllers/admin_manage_comments.php b/modules/comment/controllers/admin_manage_comments.php
index 9bd1d7f6..effefcbb 100644
--- a/modules/comment/controllers/admin_manage_comments.php
+++ b/modules/comment/controllers/admin_manage_comments.php
@@ -45,6 +45,8 @@ class Admin_Manage_Comments_Controller extends Admin_Controller {
$view = new Admin_View("admin.html");
$view->page_title = t("Manage comments");
+ $view->page_type = "collection";
+ $view->page_subtype = "admin_comments";
$view->content = new View("admin_manage_comments.html");
$view->content->counts = $this->_counts();
$view->content->menu = $this->_menu($view->content->counts);
@@ -56,13 +58,12 @@ class Admin_Manage_Comments_Controller extends Admin_Controller {
->limit(self::$items_per_page)
->offset(($page - 1) * self::$items_per_page)
->find_all();
- $view->content->pager = new Pagination();
- $view->content->pager->initialize(
- array("query_string" => "page",
- "total_items" => $view->content->counts->$state,
- "items_per_page" => self::$items_per_page,
- "style" => "classic"));
+ // Pagination info
+ $view->page = $page;
+ $view->page_size = self::$items_per_page;
+ $view->children_count = $this->_counts()->$state;
+ $view->max_pages = ceil($view->children_count / $view->page_size);
print $view;
}
diff --git a/modules/comment/views/admin_manage_comments.html.php b/modules/comment/views/admin_manage_comments.html.php
index 34a28986..e7a61837 100644
--- a/modules/comment/views/admin_manage_comments.html.php
+++ b/modules/comment/views/admin_manage_comments.html.php
@@ -194,7 +194,7 @@
</table>
<div class="g-paginator">
- <?= $pager ?>
+ <?= $theme->paginator() ?>
</div>
</div>
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"
diff --git a/modules/gallery/libraries/MY_Pagination.php b/modules/gallery/libraries/MY_Pagination.php
deleted file mode 100644
index e697c0bd..00000000
--- a/modules/gallery/libraries/MY_Pagination.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2011 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Pagination extends Pagination_Core {
- public function render($style=NULL) {
- // Hide single page pagination
- if ($this->auto_hide === TRUE AND $this->total_pages <= 1) {
- return "";
- }
-
- if ($style === NULL) {
- // Use default style
- $style = $this->style;
- }
-
- // Return rendered pagination view
- return View::factory("pager.html", get_object_vars($this))->render();
- }
-}
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 152efc37..d6834464 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -139,52 +139,6 @@ class Theme_View_Core extends Gallery_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;
- }
-
- /**
* Print out any site wide status information.
*/
public function site_status() {
diff --git a/modules/user/controllers/admin_users.php b/modules/user/controllers/admin_users.php
index a3633b52..41be6c03 100644
--- a/modules/user/controllers/admin_users.php
+++ b/modules/user/controllers/admin_users.php
@@ -21,6 +21,8 @@ class Admin_Users_Controller extends Admin_Controller {
public function index() {
$view = new Admin_View("admin.html");
$view->page_title = t("Users and groups");
+ $view->page_type = "collection";
+ $view->page_subtype = "admin_users";
$view->content = new View("admin_users.html");
// @todo: add this as a config option
@@ -29,6 +31,12 @@ class Admin_Users_Controller extends Admin_Controller {
$builder = db::build();
$user_count = $builder->from("users")->count_records();
+ // Pagination info
+ $view->page = $page;
+ $view->page_size = $page_size;
+ $view->children_count = $user_count;
+ $view->max_pages = ceil($view->children_count / $view->page_size);
+
$view->content->pager = new Pagination();
$view->content->pager->initialize(
array("query_string" => "page",
diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php
index a7bd6b27..033c9dae 100644
--- a/modules/user/views/admin_users.html.php
+++ b/modules/user/views/admin_users.html.php
@@ -110,7 +110,7 @@
</table>
<div class="g-paginator">
- <?= $pager ?>
+ <?= $theme->paginator() ?>
</div>
</div>