Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/handlers/views_handler_sort_date.inc | ||
---|---|---|
14 | 14 |
* @ingroup views_sort_handlers |
15 | 15 |
*/ |
16 | 16 |
class views_handler_sort_date extends views_handler_sort { |
17 |
function option_definition() { |
|
17 |
|
|
18 |
/** |
|
19 |
* {@inheritdoc} |
|
20 |
*/ |
|
21 |
public function option_definition() { |
|
18 | 22 |
$options = parent::option_definition(); |
19 | 23 |
|
20 | 24 |
$options['granularity'] = array('default' => 'second'); |
... | ... | |
22 | 26 |
return $options; |
23 | 27 |
} |
24 | 28 |
|
25 |
function options_form(&$form, &$form_state) { |
|
29 |
/** |
|
30 |
* {@inheritdoc} |
|
31 |
*/ |
|
32 |
public function options_form(&$form, &$form_state) { |
|
26 | 33 |
parent::options_form($form, $form_state); |
27 | 34 |
|
28 | 35 |
$form['granularity'] = array( |
... | ... | |
42 | 49 |
} |
43 | 50 |
|
44 | 51 |
/** |
45 |
* Called to add the sort to a query.
|
|
52 |
* {@inheritdoc}
|
|
46 | 53 |
*/ |
47 |
function query() { |
|
54 |
public function query() {
|
|
48 | 55 |
$this->ensure_my_table(); |
49 | 56 |
switch ($this->options['granularity']) { |
50 | 57 |
case 'second': |
51 | 58 |
default: |
52 | 59 |
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']); |
53 | 60 |
return; |
61 |
|
|
54 | 62 |
case 'minute': |
55 | 63 |
$formula = views_date_sql_format('YmdHi', "$this->table_alias.$this->real_field"); |
56 | 64 |
break; |
65 |
|
|
57 | 66 |
case 'hour': |
58 | 67 |
$formula = views_date_sql_format('YmdH', "$this->table_alias.$this->real_field"); |
59 | 68 |
break; |
69 |
|
|
60 | 70 |
case 'day': |
61 | 71 |
$formula = views_date_sql_format('Ymd', "$this->table_alias.$this->real_field"); |
62 | 72 |
break; |
73 |
|
|
63 | 74 |
case 'month': |
64 | 75 |
$formula = views_date_sql_format('Ym', "$this->table_alias.$this->real_field"); |
65 | 76 |
break; |
77 |
|
|
66 | 78 |
case 'year': |
67 | 79 |
$formula = views_date_sql_format('Y', "$this->table_alias.$this->real_field"); |
68 | 80 |
break; |
... | ... | |
71 | 83 |
// Add the field. |
72 | 84 |
$this->query->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field . '_' . $this->options['granularity']); |
73 | 85 |
} |
86 |
|
|
74 | 87 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules