Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php
/**
* @file content_distribution.views.inc
* Provides support for the Views module.
*
*/
function content_distribution_views_default_views() {
// get list of all available queue ids to populate 'relationship'
// field of the view
$qids = nodequeue_get_all_qids(0,0);
$views = array();
$view = new view;
$view->name = 'content_distribution_queue';
$view->description = 'Display a list of all nodes in queue \'Content Distribution Queue\'';
$view->tag = 'nodequeue';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'nodequeue_rel' => array(
'label' => 'queue',
'required' => 1,
'limit' => 1,
'qids' => $qids,
'id' => 'nodequeue_rel',
'table' => 'node',
'field' => 'nodequeue_rel',
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'title' => array(
'id' => 'title',
'table' => 'node',
'field' => 'title',
'label' => '',
'relationship' => 'none',
'link_to_node' => 1,
),
));
$handler->override_option('sorts', array(
'position' => array(
'id' => 'position',
'table' => 'nodequeue_nodes',
'field' => 'position',
'order' => 'ASC',
'relationship' => 'nodequeue_rel',
),
));
$handler->override_option('arguments', array(
'qid' => array(
'default_action' => 'not found',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'qid',
'table' => 'nodequeue_nodes',
'field' => 'qid',
'relationship' => 'nodequeue_rel',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_php' => '',
),
'type' => array(
'default_action' => 'not found',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_php' => '',
),
'changed' => array(
'id' => 'changed',
'table' => 'node',
'field' => 'changed',
'validate_type' => 'none',
'validate_fail' => 'not found',
'default_argument_type' => 'php',
'relationship' => 'none',
'title' => '',
'default_action' => 'not found',
'wildcard' => '',
'wildcard_substitution' => '',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'published_date' => array(
'operator' => '<=',
'value' => array(
'type' => 'offset',
'value' => 'now',
'min' => '',
'max' => '',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => 'published_date_op',
'label' => 'Content Distribution: Published Date',
'use_operator' => 0,
'identifier' => 'published_date',
'optional' => 1,
'remember' => 0,
),
'id' => 'published_date',
'table' => 'content_distribution',
'field' => 'published_date',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('title', 'Queue \'Content Distribution Queue\'');
$handler->override_option('use_pager', '1');
$handler->override_option('use_more', 1);
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'teaser' => 1,
'links' => 1,
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('path', 'nodequeue/distribution');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler = $view->new_display('block', 'Block', 'block');
$handler->override_option('items_per_page', 5);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
'type' => 'ul',
));
$handler->override_option('row_options', array(
'inline' => array(),
'separator' => '',
));
$handler->override_option('block_description', 'Queue \'Content Distribution Queue\'');
$handler->override_option('block_caching', -1);
$views[$view->name] = $view;
return $views;
}
/**
* Implementation of hook_views_data_alter()
*
* Replaces the node.changed data for the views module and adds an
* 'Updated date' argument.
*/
function content_distribution_views_data_alter(&$data) {
// changed field
$data['node']['changed'] = array(
'title' => t('Updated date'), // The item it appears as on the UI,
'help' => t('The date the node was last updated.'), // The help that appears on the UI,
'field' => array(
'handler' => 'views_handler_field_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort_date',
),
'filter' => array(
'handler' => 'views_handler_filter_date',
),
'argument' => array(
'field' => 'changed',
'handler' => 'views_handler_argument_node_created_fulldate',
),
);
}
/**
* Define extra filters for the views module.
*/
function content_distribution_views_data(){
$data = array();
// Define the base group of this table. Fields that don't
// have a group defined will go into this field by default.
$data['content_distribution']['table']['group'] = t('Content Distribution');
$data['content_distribution']['table']['base'] = array(
'field' => 'nid',
'title' => t('Content Distribution'),
'help' => t("Content distribution relates to nodes which are set up to be distributed remotely."),
);
$data['content_distribution']['table']['join'] = array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
);
// ----------------------------------------------------------------
// Fields
//published date
$data['content_distribution']['published_date'] = array(
'title' => t('Published Date'),
'help' => t('Date and time of when node is set to be published.'),
'field' => array(
'handler' => 'views_handler_field_date',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort_date',
),
'filter' => array(
'handler' => 'views_handler_filter_date',
),
);
//week argument
$data['content_distribution']['published_week'] = array(
'title' => t('Published week'),
'help' => t('In the form of WW (01 - 53).'),
'argument' => array(
'field' => 'published_date',
'handler' => 'views_handler_argument_node_created_week',
),
);
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
return $data;
}
/**
* Implementation of hook_views_query_alter()
*
* Rewrites the where clause for the third argument (updated date)
* so it is 'greater than or equals' rather than the default 'equals'
* for the nodequeue view to function correctly
*/
function content_distribution_views_query_alter(&$view, &$query) {
if ($view->name == 'content_distribution_queue') {
$query->where[0]['clauses'][3] = "DATE_FORMAT((FROM_UNIXTIME(node.changed)), '%Y%m%%d%H%i') >= '%s'";
}
}
/**
* Implementation of hook_views_api().
*/
function content_distribution_views_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'content_distribution') . '/includes',
);
}