protected function alpha_pagination_handler_pagination::getEntityIds in Views Alpha Pagination 7
Construct the actual SQL query for the view being generated.
Then parse it to short-circuit certain conditions that may exist and make any alterations. This is not the most elegant of solutions, but it is very effective.
Return value
array An indexed array of entity identifiers.
1 call to alpha_pagination_handler_pagination::getEntityIds()
- alpha_pagination_handler_pagination::getEntityPrefixes in views/
alpha_pagination_handler_pagination.inc - Retrieve the distinct first character prefix from the field tables.
File
- views/
alpha_pagination_handler_pagination.inc, line 638 - 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
protected function getEntityIds() {
$this
->ensureQuery();
$query_parts = explode("\n", $this->options['query']);
// Get the base field. This will change depending on the type of view we
// are putting the paginator on.
$base_field = $this->view->base_field;
// If we are dealing with a substring, then short circuit it as we are most
// likely dealing with a glossary contextual filter.
foreach ($query_parts as $k => $part) {
if ($position = strpos($part, "SUBSTRING")) {
$part = substr($part, 0, $position) . " 1 OR " . substr($part, $position);
$query_parts[$k] = $part;
}
}
// Evaluate the last line looking for anything which may limit the result
// set as we need results against the entire set of data and not just what
// is configured in the view.
$last_line = array_pop($query_parts);
if (substr($last_line, 0, 5) != "LIMIT") {
$query_parts[] = $last_line;
}
// Construct the query from the array and change the single quotes from
// HTML special characters back into single quotes.
$query = join("\n", $query_parts);
$query = str_replace("'", '\'', $query);
$query = str_replace("&", '&', $query);
$query = str_replace("<", '<', $query);
$query = str_replace(">", '>', $query);
// Based on our query, get the list of entity identifiers that are affected.
// These will be used to generate the pagination items.
$entity_ids = array();
$result = db_query($query);
while ($data = $result
->fetchObject()) {
$entity_ids[] = $data->{$base_field};
}
return $entity_ids;
}