function theme_avatar_selection_pager in Avatar Selection 6
Same name and namespace in other branches
- 5.2 avatar_selection.module \theme_avatar_selection_pager()
- 7 avatar_selection.module \theme_avatar_selection_pager()
Output themed pager navigation.
Parameters
$form_id: CSS identifier for the form to modify.
$dom_identifier: CSS identifier of form element to replace.
$total: Total number of elements to navigate through.
$limit: Maximum number of elements to show on one page.
Return value
HTML formatted pager navigation.
3 theme calls to theme_avatar_selection_pager()
- avatar_selection_edit_form in ./
avatar_selection.admin.inc - Create the form structure for listing the avatars and managing them in the 'Manage Avatars' tab under the Avatar Selection administration page.
- avatar_selection_form_user_profile_form_alter in ./
avatar_selection.module - Implementation of hook_form_alter().
- avatar_selection_form_user_register_alter in ./
avatar_selection.module - Implementation of hook_form_alter().
File
- ./
avatar_selection.module, line 546 - The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user, and to the administrator to disable uploading other avatar files by the user.
Code
function theme_avatar_selection_pager($form_id, $dom_identifier, $total = 10, $limit = 10) {
$path = $_GET['q'];
$total_pages = ceil($total / $limit);
$current_page = isset($_GET['page']) ? $_GET['page'] : 0;
// Calculate various markers within this pager piece:
// Middle is used to 'center' pages around the current page.
$middle_page = 5;
$first_page = $current_page - $middle_page + 1;
$last_page = $current_page + $middle_page + 1;
$output = '<div class="avatar-selection-pager-nav">';
if ($current_page > 0) {
$output .= theme('avatar_selection_pager_link', t('« first'), $path, 0, $form_id, $dom_identifier);
$output .= theme('avatar_selection_pager_link', t('‹ previous'), $path, $current_page - 1, $form_id, $dom_identifier);
}
$i = $first_page;
// Adjust 'center' if at end of query.
if ($last_page > $total_pages) {
$i = $i + ($total_pages - $last_page);
$last_page = $total_pages;
}
// Adjust 'center' if at start of query.
if ($i <= 0) {
$last_page = $last_page + (1 - $i);
$i = 1;
}
// When there is more than one page, create the pager list.
if ($total_pages > 1) {
for (; $i <= $last_page && $i <= $total_pages; $i++) {
if ($i < $current_page + 1) {
$output .= theme('avatar_selection_pager_link', $i, $path, $i - 1, $form_id, $dom_identifier);
}
if ($i == $current_page + 1) {
$output .= '<strong class="pager-current">' . $i . '</strong>';
}
if ($i > $current_page + 1) {
$output .= theme('avatar_selection_pager_link', $i, $path, $i - 1, $form_id, $dom_identifier);
}
}
}
if ($current_page + 1 < $total_pages) {
$output .= theme('avatar_selection_pager_link', t('next ›'), $path, $current_page + 1, $form_id, $dom_identifier);
$output .= theme('avatar_selection_pager_link', t('last »'), $path, $total_pages - 1, $form_id, $dom_identifier);
}
$output .= '</div>';
return $output;
}