Source for file abook_util.php
Documentation is available at abook_util.php
* The following functions are utility functions for templates. Do not
* echo output in these functions.
* @copyright 2005-2020 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: abook_util.php 14845 2020-01-07 08:09:34Z pdontthink $
* Display a column header with sort buttons
* @param string $field Which field to display
* @param array $current_page_args All known query string arguments
* for the current page request; structured
* as an associative array of key/value pairs
global $abook_sort_order, $nbsp;
$alt =
_("Sort by nickname");
$alt =
_("Sort by name");
$alt =
_("Sort by email");
$alt =
_("Sort by info");
return 'BAD SORT FIELD GIVEN: "'.
$field.
'"';
// show_abook_sort_button() creates a hyperlink (using hyperlink.tpl) that encompases an image, using a getImage() call
return $str .
($has_sort ?
$nbsp .
show_abook_sort_button($abook_sort_order, $alt, $down, $up, $current_page_args) :
'');
* Creates an address book paginator
* @param boolean $abook_page_selector Whether or not to show the page selector
* @param int $abook_page_selector_max The maximum number of page links to show
* @param int $page_number What page is being viewed - 0 if not used
* @param int $page_size Maximum number of addresses to be shown
* @param int $total_addresses The total count of addresses in the backend
* @param boolean $show_all Whether or not all addresses are being shown
* @param array $current_page_args All known query string arguments
* for the current page request; structured
* as an associative array of key/value pairs
* @param boolean $compact Whether or not to build a smaller,
* @return string The paginator, ready for output
$page_number, $page_size, $total_addresses,
$show_all, $current_page_args, $compact) {
// if showing all, just show pagination link
unset
($current_page_args['show_all']);
// if we don't have enough information to build the paginator, return nothing
if (empty($page_number) ||
empty($page_size) ||
empty($total_addresses))
// calculate some values we need below
$show_elipses_before =
FALSE;
$show_elipses_after =
FALSE;
$total_pages =
ceil($total_addresses /
$page_size);
if ($page_number >
$total_pages) $page_number =
$total_pages;
$spacing =
($compact ?
$nbsp :
$nbsp .
$nbsp);
// only enough addresses for one page anyway? no pagination needed
if ($total_pages <
2) return '';
array_merge($current_page_args, array('show_all' =>
1)))
// build next/previous links for compact paginator
// i18n: "<<" is for the first page in the paginator. "<" is for the previous page.
$paginator_string .=
_("<<") .
'][' .
_("<") .
'][';
if ($page_number <
$total_pages)
// i18n: ">>" is for the last page in the paginator. ">" is for the next page.
$paginator_string .=
_(">") .
'][' .
_(">>") .
']';
// build next/previous links for regular paginator
$paginator_string .=
_("Previous");
$paginator_string .=
$nbsp .
$sep .
$nbsp;
if ($page_number <
$total_pages)
$paginator_string .=
_("Next");
$paginator_string .=
']';
// paginator is turned off - just show previous/next links
if (!$abook_page_selector)
return $paginator_string .
$spacing .
$show_all_string;
$paginator_string .=
$spacing;
if ($total_pages <=
$abook_page_selector_max)
$end_page =
$total_pages;
$pages_to_show =
($abook_page_selector_max %
2 ?
$abook_page_selector_max :
$abook_page_selector_max -
1);
$end_page =
$page_number +
floor($pages_to_show /
2);
$start_page =
$page_number -
floor($pages_to_show /
2);
if (!($abook_page_selector_max %
2)) $start_page--
;
$end_page +=
1 -
$start_page;
else if ($end_page >
$total_pages)
$start_page -=
$end_page -
$total_pages;
$end_page =
$total_pages;
// do we need to insert elipses?
$show_elipses_before =
TRUE;
if ($total_pages >
$end_page)
$show_elipses_after =
TRUE;
// now build the actual (compact) paginator
for ($i =
1; $i <=
$total_pages; $i++
)
$aValues[$i] =
$i .
'/' .
$total_pages;
$temp_page_number =
$current_page_args['page_number'];
unset
($current_page_args['page_number']);
$current_page_args['page_number'] =
$temp_page_number;
$paginator_string .=
addSelect('page_number', $aValues,
?
array('onchange' =>
'SubmitOnSelect(this, \''
// need a submit button when select widget cannot submit itself
$paginator_string .=
addSubmit(_("Go"), 'paginator_submit');
// now build the actual (regular) paginator
$paginator_string .=
'[' .
$nbsp;
if ($show_elipses_before)
for ($x =
$start_page; $x <=
$end_page; $x++
)
$paginator_string .=
$x .
$nbsp;
$paginator_string .=
'...' .
$nbsp
$paginator_string .=
']';
$paginator_string .=
$spacing .
$show_all_string;
return $paginator_string;
* Build a page (pagination) link for use with the address book list page
* @param int $page_number The page number for the link
* @param string $text The link text
* @param array $current_page_args All known query string arguments
* for the current page request; structured
* as an associative array of key/value pairs
$current_page_args['page_number'] =
$page_number;
Documentation generated on Mon, 13 Jan 2020 04:21:57 +0100 by phpDocumentor 1.4.3