You are here

function globallink_pager_array_splice in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 globallink.inc \globallink_pager_array_splice()
  2. 7.6 globallink.inc \globallink_pager_array_splice()

Splices the pager array.

Parameters

array $data: Array of page data.

int $limit: Page limit. Defaults to 9.

int $element: The current page. Defaults to 0.

Return value

array The sliced pager array.

8 calls to globallink_pager_array_splice()
globallink_block_receive_form in globallink_block/globallink_block_receive.inc
Builds form to receive a block submission.
globallink_dashboard_receive in ./globallink_receive_translations.inc
Builds form to receive a GlobalLink submission.
globallink_entity_receive_form in globallink_entity/globallink_entity_receive.inc
Builds form to receive an entity submission.
globallink_fieldable_panels_receive_form in globallink_fieldable_panels/globallink_fieldable_panels_receive.inc
Builds form to receive a fieldable panels submission.
globallink_interface_receive_form in globallink_interface/globallink_interface_receive.inc
Builds form to receive an interface submission.

... See full list

File

./globallink.inc, line 559
Miscellaneous GlobalLink functions for node translations (non-entity).

Code

function globallink_pager_array_splice($data, $limit = 9, $element = 0) {
  global $pager_page_array, $pager_total, $pager_total_items;
  $page = isset($_GET['page']) ? $_GET['page'] : '';

  // Convert comma-separated $page to an array, used by other functions.
  $pager_page_array = explode(',', $page);

  // We calculate the total of pages as ceil(items / limit).
  $pager_total_items[$element] = count($data);
  $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
  $pager_page_array[$element] = max(0, min((int) $pager_page_array[$element], (int) $pager_total[$element] - 1));
  return array_slice($data, $pager_page_array[$element] * $limit, $limit, TRUE);
}