Projet

Général

Profil

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

root / drupal7 / sites / all / modules / flag / includes / views / flag_handler_sort_flagged.inc @ 76e2e7c3

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
   *
18
   * Should be overridden by classes that don't override sort_form.
19
   */
20
  function sort_options() {
21
    return array(
22
      'ASC' => t('Unflagged first'),
23
      'DESC' => t('Flagged first'),
24
    );
25
  }
26

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

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

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

    
48
}