public function views_handler_sort_node_language::query in Views (for Drupal 7) 7.3
Called to add the sort to a query.
Overrides views_handler_sort::query
File
- modules/
locale/ views_handler_sort_node_language.inc, line 25 - Contains .
Class
- views_handler_sort_node_language
- Sort handler that allows sorting on a specific language.
Code
public function query() {
if (isset($this->options['language'])) {
$langcode = $this
->get_system_langcode($this->options['language']);
// Validate the langcode.
if (preg_match('/^[a-z0-9\\-]+$/i', $langcode)) {
$this
->ensure_my_table();
// See https://stackoverflow.com/questions/14104055/ordering-by-specific-field-value-first
$formula = "{$this->table_alias}_language = '{$langcode}'";
$this->query
->add_orderby($this->table_alias, NULL, $this->options['order'], $formula);
}
}
}