Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/node/views_handler_argument_dates_various.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Handlers for various date arguments. |
|
6 |
* |
|
7 |
* @ingroup views_argument_handlers |
|
5 |
* Definition of views_handler_argument_node_created_fulldate. |
|
8 | 6 |
*/ |
9 | 7 |
|
10 | 8 |
/** |
11 |
* Argument handler for a full date (CCYYMMDD) |
|
9 |
* Argument handler for a full date (CCYYMMDD).
|
|
12 | 10 |
*/ |
13 | 11 |
class views_handler_argument_node_created_fulldate extends views_handler_argument_date { |
12 |
|
|
14 | 13 |
/** |
15 |
* Constructor implementation
|
|
14 |
* {@inheritdoc}
|
|
16 | 15 |
*/ |
17 |
function construct() { |
|
16 |
public function construct() {
|
|
18 | 17 |
parent::construct(); |
19 | 18 |
$this->format = 'F j, Y'; |
20 | 19 |
$this->arg_format = 'Ymd'; |
... | ... | |
22 | 21 |
} |
23 | 22 |
|
24 | 23 |
/** |
25 |
* Provide a link to the next level of the view |
|
24 |
* Provide a link to the next level of the view.
|
|
26 | 25 |
*/ |
27 |
function summary_name($data) { |
|
26 |
public function summary_name($data) {
|
|
28 | 27 |
$created = $data->{$this->name_alias}; |
29 | 28 |
return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); |
30 | 29 |
} |
31 | 30 |
|
32 | 31 |
/** |
33 |
* Provide a link to the next level of the view |
|
32 |
* Provide a link to the next level of the view.
|
|
34 | 33 |
*/ |
35 |
function title() { |
|
34 |
public function title() {
|
|
36 | 35 |
$timestamp = strtotime($this->argument . " 00:00:00 UTC"); |
37 | 36 |
if ($timestamp !== FALSE) { |
38 | 37 |
return format_date($timestamp, 'custom', $this->format, 'UTC'); |
39 | 38 |
} |
40 | 39 |
} |
40 |
|
|
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
/** |
44 |
* Argument handler for a year (CCYY) |
|
44 |
* Argument handler for a year (CCYY).
|
|
45 | 45 |
*/ |
46 | 46 |
class views_handler_argument_node_created_year extends views_handler_argument_date { |
47 |
|
|
47 | 48 |
/** |
48 |
* Constructor implementation
|
|
49 |
* {@inheritdoc}
|
|
49 | 50 |
*/ |
50 |
function construct() { |
|
51 |
public function construct() {
|
|
51 | 52 |
parent::construct(); |
52 | 53 |
$this->arg_format = 'Y'; |
53 | 54 |
$this->formula = views_date_sql_extract('YEAR', "***table***.$this->real_field"); |
54 | 55 |
} |
56 |
|
|
55 | 57 |
} |
56 | 58 |
|
57 | 59 |
/** |
58 |
* Argument handler for a year plus month (CCYYMM) |
|
60 |
* Argument handler for a year plus month (CCYYMM).
|
|
59 | 61 |
*/ |
60 | 62 |
class views_handler_argument_node_created_year_month extends views_handler_argument_date { |
63 |
|
|
61 | 64 |
/** |
62 |
* Constructor implementation
|
|
65 |
* {@inheritdoc}
|
|
63 | 66 |
*/ |
64 |
function construct() { |
|
67 |
public function construct() {
|
|
65 | 68 |
parent::construct(); |
66 | 69 |
$this->format = 'F Y'; |
67 | 70 |
$this->arg_format = 'Ym'; |
... | ... | |
71 | 74 |
/** |
72 | 75 |
* Provide a link to the next level of the view |
73 | 76 |
*/ |
74 |
function summary_name($data) { |
|
77 |
public function summary_name($data) {
|
|
75 | 78 |
$created = $data->{$this->name_alias}; |
76 | 79 |
return format_date(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); |
77 | 80 |
} |
... | ... | |
79 | 82 |
/** |
80 | 83 |
* Provide a link to the next level of the view |
81 | 84 |
*/ |
82 |
function title() { |
|
85 |
public function title() {
|
|
83 | 86 |
$timestamp = strtotime($this->argument . "15" . " 00:00:00 UTC"); |
84 | 87 |
if ($timestamp !== FALSE) { |
85 | 88 |
return format_date($timestamp, 'custom', $this->format, 'UTC'); |
86 | 89 |
} |
87 | 90 |
} |
91 |
|
|
88 | 92 |
} |
89 | 93 |
|
90 | 94 |
/** |
91 |
* Argument handler for a month (MM) |
|
95 |
* Argument handler for a month (MM).
|
|
92 | 96 |
*/ |
93 | 97 |
class views_handler_argument_node_created_month extends views_handler_argument_date { |
98 |
|
|
94 | 99 |
/** |
95 |
* Constructor implementation
|
|
100 |
* {@inheritdoc}
|
|
96 | 101 |
*/ |
97 |
function construct() { |
|
102 |
public function construct() {
|
|
98 | 103 |
parent::construct(); |
99 | 104 |
$this->formula = views_date_sql_extract('MONTH', "***table***.$this->real_field"); |
100 | 105 |
$this->format = 'F'; |
... | ... | |
104 | 109 |
/** |
105 | 110 |
* Provide a link to the next level of the view |
106 | 111 |
*/ |
107 |
function summary_name($data) { |
|
112 |
public function summary_name($data) {
|
|
108 | 113 |
$month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT); |
109 | 114 |
return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->format, 'UTC'); |
110 | 115 |
} |
... | ... | |
112 | 117 |
/** |
113 | 118 |
* Provide a link to the next level of the view |
114 | 119 |
*/ |
115 |
function title() { |
|
120 |
public function title() {
|
|
116 | 121 |
$month = str_pad($this->argument, 2, '0', STR_PAD_LEFT); |
117 | 122 |
$timestamp = strtotime("2005" . $month . "15" . " 00:00:00 UTC"); |
118 | 123 |
if ($timestamp !== FALSE) { |
... | ... | |
120 | 125 |
} |
121 | 126 |
} |
122 | 127 |
|
123 |
function summary_argument($data) { |
|
128 |
/** |
|
129 |
* {@inheritdoc} |
|
130 |
*/ |
|
131 |
public function summary_argument($data) { |
|
124 | 132 |
// Make sure the argument contains leading zeroes. |
125 | 133 |
return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT); |
126 | 134 |
} |
135 |
|
|
127 | 136 |
} |
128 | 137 |
|
129 | 138 |
/** |
130 |
* Argument handler for a day (DD) |
|
139 |
* Argument handler for a day (DD).
|
|
131 | 140 |
*/ |
132 | 141 |
class views_handler_argument_node_created_day extends views_handler_argument_date { |
142 |
|
|
133 | 143 |
/** |
134 |
* Constructor implementation
|
|
144 |
* {@inheritdoc}
|
|
135 | 145 |
*/ |
136 |
function construct() { |
|
146 |
public function construct() {
|
|
137 | 147 |
parent::construct(); |
138 | 148 |
$this->formula = views_date_sql_extract('DAY', "***table***.$this->real_field"); |
139 | 149 |
$this->format = 'j'; |
... | ... | |
141 | 151 |
} |
142 | 152 |
|
143 | 153 |
/** |
144 |
* Provide a link to the next level of the view |
|
154 |
* Provide a link to the next level of the view.
|
|
145 | 155 |
*/ |
146 |
function summary_name($data) { |
|
156 |
public function summary_name($data) {
|
|
147 | 157 |
$day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT); |
148 |
// strtotime respects server timezone, so we need to set the time fixed as utc time |
|
158 |
// strtotime() respects server timezone, so we need to set the time fixed |
|
159 |
// as UTC time. |
|
149 | 160 |
return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); |
150 | 161 |
} |
151 | 162 |
|
152 | 163 |
/** |
153 |
* Provide a link to the next level of the view |
|
164 |
* Provide a link to the next level of the view.
|
|
154 | 165 |
*/ |
155 |
function title() { |
|
166 |
public function title() {
|
|
156 | 167 |
$day = str_pad($this->argument, 2, '0', STR_PAD_LEFT); |
157 | 168 |
$timestamp = strtotime("2005" . "05" . $day . " 00:00:00 UTC"); |
158 | 169 |
if ($timestamp !== FALSE) { |
... | ... | |
160 | 171 |
} |
161 | 172 |
} |
162 | 173 |
|
163 |
function summary_argument($data) { |
|
174 |
/** |
|
175 |
* {@inheritdoc} |
|
176 |
*/ |
|
177 |
public function summary_argument($data) { |
|
164 | 178 |
// Make sure the argument contains leading zeroes. |
165 | 179 |
return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT); |
166 | 180 |
} |
181 |
|
|
167 | 182 |
} |
168 | 183 |
|
169 | 184 |
/** |
170 | 185 |
* Argument handler for a week. |
171 | 186 |
*/ |
172 | 187 |
class views_handler_argument_node_created_week extends views_handler_argument_date { |
188 |
|
|
173 | 189 |
/** |
174 |
* Constructor implementation
|
|
190 |
* {@inheritdoc}
|
|
175 | 191 |
*/ |
176 |
function construct() { |
|
192 |
public function construct() {
|
|
177 | 193 |
parent::construct(); |
178 | 194 |
$this->arg_format = 'w'; |
179 | 195 |
$this->formula = views_date_sql_extract('WEEK', "***table***.$this->real_field"); |
180 | 196 |
} |
181 | 197 |
|
182 | 198 |
/** |
183 |
* Provide a link to the next level of the view |
|
199 |
* Provide a link to the next level of the view.
|
|
184 | 200 |
*/ |
185 |
function summary_name($data) { |
|
201 |
public function summary_name($data) {
|
|
186 | 202 |
$created = $data->{$this->name_alias}; |
187 | 203 |
return t('Week @week', array('@week' => $created)); |
188 | 204 |
} |
205 |
|
|
189 | 206 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules