You are here

function _cleanpager_rewrite_path in Clean Pagination 6

Same name and namespace in other branches
  1. 7 cleanpager.module \_cleanpager_rewrite_path()

Remove number at end of path

1 call to _cleanpager_rewrite_path()
cleanpager_check_match in ./cleanpager.module
Checks if the page should use clean pagination

File

./cleanpager.module, line 191

Code

function _cleanpager_rewrite_path(&$pager = FALSE, &$page = NULL) {
  static $q, $pr, $p;
  if (!isset($q)) {
    $q = $_GET['q'];
    $p = 0;
    $pr = FALSE;
    $q_array = explode('/', $_GET['q']);
    if (_cleanpager_is_pager_element(end($q_array))) {
      $p = array_pop($q_array);

      // Check for page/page_number
      if (variable_get('cleanpager_use_additional_path', TRUE)) {
        if (end($q_array) == CLEANPAGER_ADDITIONAL_PATH_VARIABLE) {
          array_pop($q_array);
          $pr = TRUE;
        }
      }
      else {
        $pr = TRUE;
      }
      if ($pr) {
        $q = implode('/', $q_array);
        $_REQUEST['q'] = $_GET['q'] = $q;
        $_REQUEST['page'] = $_GET['page'] = $p;
      }
    }
  }
  $page = $p;
  $pager = $pr;
  return $q;
}