function theme_paging_drop_down in Paging 6
Format a query pager.
Menu callbacks that display paged query results should call theme('pager') to retrieve a pager control so that users can view other results. Format a list of nearby pages with additional query results.
Parameters
$tags: An array of labels for the controls in the pager.
$limit: The number of query results to display per page.
$element: An optional integer to distinguish between multiple pagers on one page.
$parameters: An associative array of query string parameters to append to the pager links.
$quantity: The number of pages in the list.
Return value
An HTML string that generates the query pager.
File
- ./
paging.module, line 860 - Allows users to use a tag to break up a node into multiple pages.
Code
function theme_paging_drop_down($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9, $page_names = array()) {
global $pager_page_array, $pager_total;
$output = '';
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle = ceil($quantity / 2);
// current is the page we are currently paged to
$pager_current = $pager_page_array[$element] + 1;
// max is the maximum page number
$pager_max = $pager_total[$element];
// End of marker calculations.
$prev_name = truncate_utf8(t($page_names[$pager_current - 2]), 50, TRUE, TRUE);
$li_previous = theme('pager_previous', isset($tags[1]) ? $tags[1] : t('Previous page: !prev', array(
'!prev' => $prev_name,
)), $limit, $element, 1);
$next_name = truncate_utf8(t($page_names[$pager_current]), 50, TRUE, TRUE);
$li_next = theme('pager_next', isset($tags[3]) ? $tags[3] : t('Next page: !next', array(
'!next' => $next_name,
)), $limit, $element, 1);
if ($pager_total[$element] > 1) {
$output .= '<table id="paging-title-navigation" class="paging-drop-down">
<tbody>
<tr>
<td class="previous-page" style="width: 50%; text-align: left;">';
$output .= '<span>' . $li_previous . '</span>';
$options = '';
// Now generate the actual pager piece.
for ($i = 1; $i <= $pager_max; $i++) {
$page = $_GET['page'] ? $_GET['page'] : '0,' . ($i - 1);
if (strpos($page, ',') == 1) {
$page = $page[0] . ',' . ($i - 1);
}
else {
if (!empty($_GET['page']) && strpos($page, ',') === FALSE) {
$page = $_GET['page'] . ',' . ($i - 1);
}
}
$url = $i == 1 ? url($_GET['q']) : url($_GET['q'], array(
'query' => array(
'page' => $page,
),
));
// Decode the comma entity.
$url = str_replace('%2C', ',', $url);
$options .= theme('paging_drop_down_option', $url, $page_names[$i - 1], $i, $i == $pager_current);
}
$output .= '</td><td class="paging-drop-down" style="text-align: center;">';
$output .= '<select name="paging_drop_down_page" onload="Drupal.theme(\'paging_drop_down\');">' . $options . '</select>';
$output .= '</td><td class="next-page" style="width: 50%; text-align: right;">';
$output .= '<span>' . $li_next . '</span>';
$output .= '</td>
</tr>
</tbody>
</table>';
drupal_add_js("Drupal.theme.prototype.paging_drop_down = function() {\n \$('.paging-drop-down select').bind('change', function() {\n location.href = \$(this).val();\n });\n};\n\n\$(document).ready(function() {\n Drupal.theme('paging_drop_down');\n});", 'inline');
return $output;
}
}