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