Projet

Général

Profil

Paste
Télécharger (1,14 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / flag / includes / views / flag_handler_sort_flagged.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains the flagged content sort handler.
6
 */
7

    
8
/**
9
 * Handler to sort on whether objects are flagged or not.
10
 *
11
 * @ingroup views
12
 */
13
class flag_handler_sort_flagged extends views_handler_sort {
14

    
15
  /**
16
   * Provide a list of options for the default sort form.
17
   * Should be overridden by classes that don't override sort_form
18
   */
19
  function sort_options() {
20
    return array(
21
      'ASC' => t('Unflagged first'),
22
      'DESC' => t('Flagged first'),
23
    );
24
  }
25

    
26
  /**
27
   * Display whether or not the sort order is ascending or descending
28
   */
29
  function admin_summary() {
30
    if (!empty($this->options['exposed'])) {
31
      return t('Exposed');
32
    }
33

    
34
    // Get the labels defined in sort_options().
35
    $sort_options = $this->sort_options();
36
    return $sort_options[strtoupper($this->options['order'])];
37
  }
38

    
39
  function query() {
40
    $this->ensure_my_table();
41
    // Add the ordering.
42
    // Using IS NOT NULL means that the ASC/DESC ordering work in the same
43
    // direction as sorting by flagging date: empty results come first.
44
    $this->query->add_orderby(NULL, "($this->table_alias.uid IS NOT NULL)", $this->options['order']);
45
  }
46

    
47
}