本文整理汇总了PHP中Pager::_buildQueryString方法的典型用法代码示例。如果您正苦于以下问题:PHP Pager::_buildQueryString方法的具体用法?PHP Pager::_buildQueryString怎么用?PHP Pager::_buildQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pager
的用法示例。
在下文中一共展示了Pager::_buildQueryString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLinks
/**
* Returns an array with the paginated links, one in each item.
*
* @access public
* @param int $row Current page number (starts from zero)
* @param int $total_rows Total number of rows, as returned by Pager::getTotalRows()
* @param int $per_page Maximum number of rows per page
* @param string $show_links An option to show 'Next'/'Previous' links, page numbering links or both ('sides', 'pages' or 'all')
* @param string $show_blank An option to show 'Next'/'Previous' strings even if there are no appropriate next or previous pages
* @param array $link_str The strings to be used instead of the default 'Next >>' and '<< Previous'
* @return array The list of paginated links
* @see getTotalRows()
*/
function getLinks($row, $total_rows, $per_page, $show_links = "all", $show_blank = "off", $link_str = -1)
{
global $HTTP_SERVER_VARS;
// check for emptyness
if (empty($total_rows) || empty($per_page)) {
return array();
}
if ($link_str == -1) {
if (APP_CURRENT_LANG == "br") {
$link_str = array("previous" => "<< Anterior", "next" => "Próxima >>");
} else {
$link_str = array("previous" => "<< Previous", "next" => "Next >>");
}
}
$extra_vars = Pager::_buildQueryString();
$file = $HTTP_SERVER_VARS["SCRIPT_NAME"];
$number_of_pages = ceil($total_rows / $per_page);
$subscript = 0;
for ($current = 0; $current < $number_of_pages; $current++) {
// if we need to show all links, or the 'side' links,
// let's add the 'Previous' link as the first item of the array
if (($show_links == "all" || $show_links == "sides") && $current == 0) {
if ($row != 0) {
$array[0] = '<A HREF="' . $file . '?pagerRow=' . ($row - 1) . $extra_vars . '">' . $link_str["previous"] . '</A>';
} elseif ($row == 0 && $show_blank == "on") {
$array[0] = $link_str["previous"];
}
}
// check to show page numbering links or not
if ($show_links == "all" || $show_links == "pages") {
if ($row == $current) {
// if we only have one page worth of rows, we should show the '1' page number
if ($current == $number_of_pages - 1 && $number_of_pages == 1 && $show_blank == "off") {
$array[0] = "<b>" . ($current > 0 ? $current + 1 : 1) . "</b>";
} else {
$array[++$subscript] = "<b>" . ($current > 0 ? $current + 1 : 1) . "</b>";
}
} else {
$array[++$subscript] = '<A HREF="' . $file . '?pagerRow=' . $current . $extra_vars . '">' . ($current + 1) . '</A>';
}
}
// only add the 'Next' link to the array if we are on the last iteration of this loop
if (($show_links == "all" || $show_links == "sides") && $current == $number_of_pages - 1) {
if ($row != $number_of_pages - 1) {
$array[++$subscript] = '<A HREF="' . $file . '?pagerRow=' . ($row + 1) . $extra_vars . '">' . $link_str["next"] . '</A>';
} elseif ($row == $number_of_pages - 1 && $show_blank == "on") {
$array[++$subscript] = $link_str["next"];
}
}
}
return $array;
}