You are here

function date_views_querystring in Date 7.3

Same name and namespace in other branches
  1. 8 date_views/includes/date_views.views.inc \date_views_querystring()
  2. 6.2 includes/date_api.views.inc \date_views_querystring()
  3. 7 date_views/includes/date_views.views.inc \date_views_querystring()
  4. 7.2 date_views/includes/date_views.views.inc \date_views_querystring()

Helper function to generate a query string.

Parameters

object $view: A View object.

array $extra_params: An extra parameters.

Return value

null|string Return a query or NULL.

1 call to date_views_querystring()
date_pager_url in date_views/date_views.module
A version of date_real_url that formats links correctly for the Date pager.

File

date_views/includes/date_views.views.inc, line 191
Defines date-related Views data and plugins:.

Code

function date_views_querystring($view, array $extra_params = array()) {
  $query_params = array_merge($_GET, $extra_params);

  // Allow NULL params to be removed from the query string.
  foreach ($extra_params as $key => $value) {
    if (!isset($value)) {
      unset($query_params[$key]);
    }
  }

  // Filter the special "q" and "view" variables out of the query string.
  $exclude = array(
    'q',
  );

  // If we don't explicitly add a value for "view", filter it out.
  if (empty($extra_params['view'])) {
    $exclude[] = 'view';
  }

  // Clear out old date pager settings if not explicitly added.
  if (!empty($view->date_info->pager_id) && empty($extra_params[$view->date_info->pager_id])) {
    $exclude[] = $view->date_info->pager_id;
  }
  $query = drupal_get_query_parameters($query_params, $exclude);

  // To prevent an empty query string from adding a "?" on to the end of a URL,
  // we return NULL.
  return !empty($query) ? $query : NULL;
}