Projet

Général

Profil

Paste
Télécharger (5,17 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / node / views_handler_argument_dates_various.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_argument_node_created_fulldate.
6
 */
7

    
8
/**
9
 * Argument handler for a full date (CCYYMMDD).
10
 */
11
class views_handler_argument_node_created_fulldate extends views_handler_argument_date {
12

    
13
  /**
14
   * {@inheritdoc}
15
   */
16
  public function construct() {
17
    parent::construct();
18
    $this->format = 'F j, Y';
19
    $this->arg_format = 'Ymd';
20
    $this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
21
  }
22

    
23
  /**
24
   * Provide a link to the next level of the view.
25
   */
26
  public function summary_name($data) {
27
    $created = $data->{$this->name_alias};
28
    return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
29
  }
30

    
31
  /**
32
   * Provide a link to the next level of the view.
33
   */
34
  public function title() {
35
    $timestamp = strtotime($this->argument . " 00:00:00 UTC");
36
    if ($timestamp !== FALSE) {
37
      return format_date($timestamp, 'custom', $this->format, 'UTC');
38
    }
39
  }
40

    
41
}
42

    
43
/**
44
 * Argument handler for a year (CCYY).
45
 */
46
class views_handler_argument_node_created_year extends views_handler_argument_date {
47

    
48
  /**
49
   * {@inheritdoc}
50
   */
51
  public function construct() {
52
    parent::construct();
53
    $this->arg_format = 'Y';
54
    $this->formula = views_date_sql_extract('YEAR', "***table***.$this->real_field");
55
  }
56

    
57
}
58

    
59
/**
60
 * Argument handler for a year plus month (CCYYMM).
61
 */
62
class views_handler_argument_node_created_year_month extends views_handler_argument_date {
63

    
64
  /**
65
   * {@inheritdoc}
66
   */
67
  public function construct() {
68
    parent::construct();
69
    $this->format = 'F Y';
70
    $this->arg_format = 'Ym';
71
    $this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
72
  }
73

    
74
  /**
75
   * Provide a link to the next level of the view
76
   */
77
  public function summary_name($data) {
78
    $created = $data->{$this->name_alias};
79
    return format_date(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
80
  }
81

    
82
  /**
83
   * Provide a link to the next level of the view
84
   */
85
  public function title() {
86
    $timestamp = strtotime($this->argument . "15" . " 00:00:00 UTC");
87
    if ($timestamp !== FALSE) {
88
      return format_date($timestamp, 'custom', $this->format, 'UTC');
89
    }
90
  }
91

    
92
}
93

    
94
/**
95
 * Argument handler for a month (MM).
96
 */
97
class views_handler_argument_node_created_month extends views_handler_argument_date {
98

    
99
  /**
100
   * {@inheritdoc}
101
   */
102
  public function construct() {
103
    parent::construct();
104
    $this->formula = views_date_sql_extract('MONTH', "***table***.$this->real_field");
105
    $this->format = 'F';
106
    $this->arg_format = 'm';
107
  }
108

    
109
  /**
110
   * Provide a link to the next level of the view
111
   */
112
  public function summary_name($data) {
113
    $month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
114
    return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->format, 'UTC');
115
  }
116

    
117
  /**
118
   * Provide a link to the next level of the view
119
   */
120
  public function title() {
121
    $month = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
122
    $timestamp = strtotime("2005" . $month . "15" . " 00:00:00 UTC");
123
    if ($timestamp !== FALSE) {
124
      return format_date($timestamp, 'custom', $this->format, 'UTC');
125
    }
126
  }
127

    
128
  /**
129
   * {@inheritdoc}
130
   */
131
  public function summary_argument($data) {
132
    // Make sure the argument contains leading zeroes.
133
    return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
134
  }
135

    
136
}
137

    
138
/**
139
 * Argument handler for a day (DD).
140
 */
141
class views_handler_argument_node_created_day extends views_handler_argument_date {
142

    
143
  /**
144
   * {@inheritdoc}
145
   */
146
  public function construct() {
147
    parent::construct();
148
    $this->formula = views_date_sql_extract('DAY', "***table***.$this->real_field");
149
    $this->format = 'j';
150
    $this->arg_format = 'd';
151
  }
152

    
153
  /**
154
   * Provide a link to the next level of the view.
155
   */
156
  public function summary_name($data) {
157
    $day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
158
    // strtotime() respects server timezone, so we need to set the time fixed
159
    // as UTC time.
160
    return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
161
  }
162

    
163
  /**
164
   * Provide a link to the next level of the view.
165
   */
166
  public function title() {
167
    $day = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
168
    $timestamp = strtotime("2005" . "05" . $day . " 00:00:00 UTC");
169
    if ($timestamp !== FALSE) {
170
      return format_date($timestamp, 'custom', $this->format, 'UTC');
171
    }
172
  }
173

    
174
  /**
175
   * {@inheritdoc}
176
   */
177
  public function summary_argument($data) {
178
    // Make sure the argument contains leading zeroes.
179
    return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
180
  }
181

    
182
}
183

    
184
/**
185
 * Argument handler for a week.
186
 */
187
class views_handler_argument_node_created_week extends views_handler_argument_date {
188

    
189
  /**
190
   * {@inheritdoc}
191
   */
192
  public function construct() {
193
    parent::construct();
194
    $this->arg_format = 'w';
195
    $this->formula = views_date_sql_extract('WEEK', "***table***.$this->real_field");
196
  }
197

    
198
  /**
199
   * Provide a link to the next level of the view.
200
   */
201
  public function summary_name($data) {
202
    $created = $data->{$this->name_alias};
203
    return t('Week @week', array('@week' => $created));
204
  }
205

    
206
}