Commit 712a30b5 authored by Dries's avatar Dries

- Improvements by Goba:

  + removes the lots of pagers and indirect pager themeing
  + add the theme_pager() function, which should be called as
    theme("pager", ...) to get a pager.
parent ea1acde1
......@@ -57,24 +57,6 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = "") {
return db_query_range($query, (int)$pager_from_array[$element], (int)$limit);
}
/**
* Use this function in your module or theme to display a pager.
*
* @param $tags defines your buttons; text or img.
* @param $limit how many nodes are displayed per page
* @param $element support for multiple pagers per page (specify which this
* is)
* @param $type allows for distinction between pagers on main page and admin
* page, etc. Supported types are "default", "admin" and "simple".
* @param $attributes extra html attributes for \<a href> (eg. title,
* onMouseOver, etc.)
*
* @return string html of pager
*/
function pager_display($tags = "", $limit = 10, $element = 0, $type = "default", $attributes = array()) {
return theme("pager_display_". $type, $tags, $limit, $element, $attributes);
}
/** @} End of defgroup pager_api */
/**
......@@ -83,13 +65,10 @@ function pager_display($tags = "", $limit = 10, $element = 0, $type = "default",
*/
/**
* DEFAULT PAGER: When writing themes, you can rewrite this pager function in
* your theme. This is the most common pager type, and thus the main one to
* re-write in your theme.
*
* @see pager_display
* When writing themes, you can rewrite this pager function in your theme.
* You need to call theme("pager", ...) to get a pager.
*/
function theme_pager_display_default($tags = "", $limit = 10, $element = 0, $attributes = array()) {
function theme_pager($tags = "", $limit = 10, $element = 0, $attributes = array()) {
global $pager_total;
if ($pager_total[$element] > $limit) {
$output .= "<div id=\"pager\" class=\"container-inline\">";
......@@ -103,38 +82,6 @@ function theme_pager_display_default($tags = "", $limit = 10, $element = 0, $att
return $output;
}
}
/**
* SIMPLE PAGER: When writing themes, you can rewrite this pager function in
* your theme. Keep in mind that the pager it defines is intended to have a
* "simple" look, possibly located in a table or block.
*
* @see pager_display
*/
function theme_pager_display_simple($tags = "", $limit = 10, $element = 0, $attributes = array()) {
/*
** It's left as an exercise to theme writers to create an alternative
** pager for pager_display_simple(). if your theme does not offer a
** replacement, the theme.inc pager_display_default() is used.
*/
return theme_pager_display_default($tags, $limit, $element, $attributes);
}
/**
* ADMIN PAGER: When writing themes, you can rewrite this pager function in your
* theme. Most themes will probably NOT re-write this function, as admin pages
* are not normally themed.
*
* @see pager_display
*/
function theme_pager_display_admin($tags = "", $limit = 10, $element = 0, $attributes = array()) {
/*
** It's left as an exercise to theme writers to create an alternative
** pager for pager_display_admin(). if your theme does not offer a
** replacement, the pager.inc pager_display_default() is used.
*/
return theme_pager_display_default($tags, $limit, $element, $attributes);
}
/** @} End of addtogroup themeable */
/**
......
......@@ -122,7 +122,7 @@ function blog_page_user($uid) {
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= theme("pager", NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">" . l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed/$account->uid", array("title" => t("View the XML version of %username's blog", array("%username" => $account->name)))) . "</div>";
print theme("page", $output, $title);
......@@ -138,7 +138,7 @@ function blog_page_last() {
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= theme("pager", NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">". l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."</div>";
print theme("page", $output);
......
......@@ -122,7 +122,7 @@ function blog_page_user($uid) {
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= theme("pager", NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">" . l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed/$account->uid", array("title" => t("View the XML version of %username's blog", array("%username" => $account->name)))) . "</div>";
print theme("page", $output, $title);
......@@ -138,7 +138,7 @@ function blog_page_last() {
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
$output .= pager_display(NULL, variable_get("default_nodes_main", 10));
$output .= theme("pager", NULL, variable_get("default_nodes_main", 10));
$output .= "<div class=\"xml-icon\">". l("<img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" />", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."</div>";
print theme("page", $output);
......
......@@ -743,7 +743,7 @@ function comment_render($node, $cid = 0) {
** Use the standard pager, $pager_total is the number of returned rows,
** is global and defined in pager.inc
*/
if ($pager = pager_display(NULL, $comments_per_page, 0, "default", array("comments_per_page" => $comments_per_page))) {
if ($pager = theme("pager", NULL, $comments_per_page, 0, array("comments_per_page" => $comments_per_page))) {
$output .= $pager;
}
......@@ -994,7 +994,7 @@ function comment_admin_overview($status = 0) {
$rows[] = array(l($comment->subject, "node/view/$comment->nid/$comment->cid#$comment->cid", array("title" => htmlspecialchars(substr($comment->comment, 0, 128)))) ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme("mark") : ""), format_name($comment), ($comment->status == 0 ? t("published") : t("not published")) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td>". l(t("edit comment"), "admin/comment/edit/$comment->cid"), l(t("delete comment"), "admin/comment/delete/$comment->cid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 6));
}
......
......@@ -743,7 +743,7 @@ function comment_render($node, $cid = 0) {
** Use the standard pager, $pager_total is the number of returned rows,
** is global and defined in pager.inc
*/
if ($pager = pager_display(NULL, $comments_per_page, 0, "default", array("comments_per_page" => $comments_per_page))) {
if ($pager = theme("pager", NULL, $comments_per_page, 0, array("comments_per_page" => $comments_per_page))) {
$output .= $pager;
}
......@@ -994,7 +994,7 @@ function comment_admin_overview($status = 0) {
$rows[] = array(l($comment->subject, "node/view/$comment->nid/$comment->cid#$comment->cid", array("title" => htmlspecialchars(substr($comment->comment, 0, 128)))) ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme("mark") : ""), format_name($comment), ($comment->status == 0 ? t("published") : t("not published")) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td>". l(t("edit comment"), "admin/comment/edit/$comment->cid"), l(t("delete comment"), "admin/comment/delete/$comment->cid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 6));
}
......
......@@ -617,7 +617,7 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset
}
}
if ($pager = pager_display(NULL, $forum_per_page, 0, "default", tablesort_pager())) {
if ($pager = theme("pager", NULL, $forum_per_page, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => "5", "class" => "pager"));
}
}
......
......@@ -617,7 +617,7 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page, $offset
}
}
if ($pager = pager_display(NULL, $forum_per_page, 0, "default", tablesort_pager())) {
if ($pager = theme("pager", NULL, $forum_per_page, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => "5", "class" => "pager"));
}
}
......
......@@ -229,7 +229,7 @@ function locale_seek() {
}
}
if ($pager = pager_display(NULL, 50, 0, "admin", $request)) {
if ($pager = theme("pager", NULL, 50, 0, $request)) {
$rows[] = array(array("data" => "$pager", "colspan" => "5"));
}
......
......@@ -229,7 +229,7 @@ function locale_seek() {
}
}
if ($pager = pager_display(NULL, 50, 0, "admin", $request)) {
if ($pager = theme("pager", NULL, 50, 0, $request)) {
$rows[] = array(array("data" => "$pager", "colspan" => "5"));
}
......
......@@ -694,7 +694,7 @@ function node_admin_nodes() {
$rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme_mark() : ""), module_invoke($node->type, "node", "name"), format_name($node), ($node->status ? t("published") : t("not published")), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin")) {
if ($pager = theme("pager", NULL, 50, 0)) {
$rows[] = array(array("data" => $pager, "colspan" => 7));
}
......
......@@ -694,7 +694,7 @@ function node_admin_nodes() {
$rows[] = array(form_checkbox(NULL, "status][$node->nid", 1, 0), l($node->title, "node/view/$node->nid") ." ". (node_is_new($node->nid, $node->changed) ? theme_mark() : ""), module_invoke($node->type, "node", "name"), format_name($node), ($node->status ? t("published") : t("not published")), l(t("edit node"), "admin/node/edit/$node->nid"), l(t("delete node"), "admin/node/delete/$node->nid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin")) {
if ($pager = theme("pager", NULL, 50, 0)) {
$rows[] = array(array("data" => $pager, "colspan" => 7));
}
......
......@@ -204,7 +204,7 @@ function path_overview() {
$rows[] = array($data->dst, $data->src, l(t("edit"), "admin/path/edit/$data->pid"), l(t("delete"), "admin/path/delete/$data->pid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => "4"));
}
......
......@@ -204,7 +204,7 @@ function path_overview() {
$rows[] = array($data->dst, $data->src, l(t("edit"), "admin/path/edit/$data->pid"), l(t("delete"), "admin/path/delete/$data->pid"));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => "4"));
}
......
......@@ -232,7 +232,7 @@ function statistics_admin_topnodes_table() {
while ($nid = db_fetch_array($result)) {
$rows[] = array(l($nid["title"], "node/view/". $nid["nid"], array("title" => t("View this posting."))), $nid["daycount"], $nid["totalcount"], format_date($nid["timestamp"], "small"), l("track node", "admin/statistics/log/node/$nid[nid]"));
}
if ($pager = pager_display(NULL, 20, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 5));
}
......@@ -291,7 +291,7 @@ function statistics_admin_accesslog_table($type, $id) {
$rows[] = array(array("data" => format_date($log->timestamp, "small"), "nowrap" => "nowrap"), ($log->nid ? l($log->title, "node/view/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t("track node"), "admin/statistics/log/node/$log->nid") : ""), ($user->uid ? l(t("track user"), "admin/statistics/log/user/$user->uid") : ""), ($log->hostname ? l(t("track host"), "admin/statistics/log/host/$log->hostname") : ""));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 8));
}
......@@ -332,7 +332,7 @@ function statistics_top_refer() {
while ($referrer = db_fetch_array($result)) {
$rows[] = array("<a href=\"". $referrer["url"] ."\">". substr($referrer["url"], 0, 100) ."</a>", format_date($referrer["last_view"], "small"), $referrer["count"]);
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 3));
}
......
......@@ -232,7 +232,7 @@ function statistics_admin_topnodes_table() {
while ($nid = db_fetch_array($result)) {
$rows[] = array(l($nid["title"], "node/view/". $nid["nid"], array("title" => t("View this posting."))), $nid["daycount"], $nid["totalcount"], format_date($nid["timestamp"], "small"), l("track node", "admin/statistics/log/node/$nid[nid]"));
}
if ($pager = pager_display(NULL, 20, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 20, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 5));
}
......@@ -291,7 +291,7 @@ function statistics_admin_accesslog_table($type, $id) {
$rows[] = array(array("data" => format_date($log->timestamp, "small"), "nowrap" => "nowrap"), ($log->nid ? l($log->title, "node/view/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t("track node"), "admin/statistics/log/node/$log->nid") : ""), ($user->uid ? l(t("track user"), "admin/statistics/log/user/$user->uid") : ""), ($log->hostname ? l(t("track host"), "admin/statistics/log/host/$log->hostname") : ""));
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 8));
}
......@@ -332,7 +332,7 @@ function statistics_top_refer() {
while ($referrer = db_fetch_array($result)) {
$rows[] = array("<a href=\"". $referrer["url"] ."\">". substr($referrer["url"], 0, 100) ."</a>", format_date($referrer["last_view"], "small"), $referrer["count"]);
}
if ($pager = pager_display(NULL, 50, 0, "admin", tablesort_pager())) {
if ($pager = theme("pager", NULL, 50, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 3));
}
......
......@@ -688,7 +688,7 @@ function taxonomy_render_nodes($result) {
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
}
$output .= pager_display(NULL, variable_get("default_nodes_main", 10), 0);
$output .= theme("pager", NULL, variable_get("default_nodes_main", 10), 0);
return $output;
}
......
......@@ -688,7 +688,7 @@ function taxonomy_render_nodes($result) {
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
}
$output .= pager_display(NULL, variable_get("default_nodes_main", 10), 0);
$output .= theme("pager", NULL, variable_get("default_nodes_main", 10), 0);
return $output;
}
......
......@@ -79,7 +79,7 @@ function tracker_posts($id = 0) {
$rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title . $comments, "class" => "content"), array("data" => $author, "class" => "author"), array("data" => format_date($node->last_activity, "small"), "class" => "last_post"));
}
if ($pager = pager_display(NULL, 10, 0, "default", tablesort_pager())) {
if ($pager = theme("pager", NULL, 10, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 4));
}
......
......@@ -79,7 +79,7 @@ function tracker_posts($id = 0) {
$rows[] = array(array("data" => $type, "class" => "type"), array("data" => $title . $comments, "class" => "content"), array("data" => $author, "class" => "author"), array("data" => format_date($node->last_activity, "small"), "class" => "last_post"));
}
if ($pager = pager_display(NULL, 10, 0, "default", tablesort_pager())) {
if ($pager = theme("pager", NULL, 10, 0, tablesort_pager())) {
$rows[] = array(array("data" => $pager, "colspan" => 4));
}
......
......@@ -1479,7 +1479,7 @@ function user_admin_account() {
$rows[] = array($account->uid, format_name($account), $status[$account->status], $account->rolename, format_date($account->timestamp, "small"), l(t("edit account"), "admin/user/edit/$account->uid"));
}
$pager = pager_display(NULL, 50, 0, "admin", tablesort_pager());
$pager = theme("pager", NULL, 50, 0, tablesort_pager());
if (!empty($pager)) {
$rows[] = array(array("data" => $pager, "colspan" => 6));
}
......
......@@ -1479,7 +1479,7 @@ function user_admin_account() {
$rows[] = array($account->uid, format_name($account), $status[$account->status], $account->rolename, format_date($account->timestamp, "small"), l(t("edit account"), "admin/user/edit/$account->uid"));
}
$pager = pager_display(NULL, 50, 0, "admin", tablesort_pager());
$pager = theme("pager", NULL, 50, 0, tablesort_pager());
if (!empty($pager)) {
$rows[] = array(array("data" => $pager, "colspan" => 6));
}
......
......@@ -98,7 +98,7 @@ function watchdog_overview($type) {
$rows[] = array(array("data" => t("No log messages available."), "colspan" => "5"));
}
$pager = pager_display(NULL, 50, 0, "admin", tablesort_pager());
$pager = theme("pager", NULL, 50, 0, tablesort_pager());
if (!empty($pager)) {
$rows[] = array(array("data" => $pager, "colspan" => "5"));
}
......
......@@ -98,7 +98,7 @@ function watchdog_overview($type) {
$rows[] = array(array("data" => t("No log messages available."), "colspan" => "5"));
}
$pager = pager_display(NULL, 50, 0, "admin", tablesort_pager());
$pager = theme("pager", NULL, 50, 0, tablesort_pager());
if (!empty($pager)) {
$rows[] = array(array("data" => $pager, "colspan" => "5"));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment