You are here

function alpha_pagination_handler_pagination::ensureQuery in Views Alpha Pagination 7

Extract the SQL query from the query information.

Once extracted, place it into the options array so it is passed to the render function. This code was lifted nearly verbatim from the views module where the query is constructed for the ui to show the query in the administrative area. I am open to suggestions on how to make this better.

3 calls to alpha_pagination_handler_pagination::ensureQuery()
alpha_pagination_handler_pagination::getCid in views/alpha_pagination_handler_pagination.inc
Retrieves a cache identifier for the view, display and query, if set.
alpha_pagination_handler_pagination::getEntityIds in views/alpha_pagination_handler_pagination.inc
Construct the actual SQL query for the view being generated.
alpha_pagination_handler_pagination::post_execute in views/alpha_pagination_handler_pagination.inc
Run after the view is executed, before the result is cached.

File

views/alpha_pagination_handler_pagination.inc, line 305
Definition of alpha_pagination_handler_pagination.

Class

alpha_pagination_handler_pagination
Views area handler to display an alphabetic pagination representive of the entire result set for this view and not just the limited number being displayed by the view's configuration

Code

function ensureQuery() {
  if (empty($this->options['query'])) {
    $query = $this->view->build_info['query'];
    if (!empty($query)) {
      $quoted = $query
        ->getArguments();
      $connection = Database::getConnection();
      foreach ($quoted as $key => $val) {
        if (is_array($val)) {
          $quoted[$key] = implode(', ', array_map(array(
            $connection,
            'quote',
          ), $val));
        }
        else {
          $quoted[$key] = $connection
            ->quote($val);
        }
      }
      $this->options['query'] = check_plain(strtr($query, $quoted));
    }
  }
}