-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcyoa.views.inc
239 lines (229 loc) · 6.78 KB
/
cyoa.views.inc
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
<?php
/**
* Implementation of hook_views_data().
*/
function cyoa_views_data() {
$data = array();
$data['cyoa']['table']['group'] = t('Cyoa');
$data['cyoa']['cyoaid'] = array(
'title' => t('Cyoaid'),
'help' => t('The choice your own adventure ID.'),
// Information for accepting a nid as an argument
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'views_handler_argument_numeric',
'name field' => 'title', // the field to display in the summary.
'numeric' => TRUE,
'validate type' => 'cyoaid',
),
// Information for accepting a nid as a filter
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
// Information for sorting on a nid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
/* //FIXME Completed is not in use yet.
$data['cyoa']['completed'] = array(
'title'=> t('Completed'),
'help' => t('Whether or not the adventure has been completed.'),
'field' => array(
'handler' => 'views_handler_field_boolean',
'click sortable' => TRUE,
),
'filter' => array(
'handler' => 'views_handler_filter_boolean_operator',
'label' => t('Completed'),
'type' => 'yes-no',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
*/
/* auto join the cyoa table with the cyoac table */
$data['cyoa']['table']['join'] = array(
'cyoac' => array(
'left_field' => 'cyoaid',
'field' => 'cyoaid',
),
);
/*
* Date adventure started
*/
$data['cyoa']['timestamp'] = array(
'title' => t('Date started'), // The item it appears as on the UI,
'help' => t('The date the adventure started.'), // 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',
),
);
/*
* Hostname // FIXME TODO convert this to session_id?
*/
$data['cyoa']['hostname'] = array(
'title' => t('Hostname'),
'help' => t('Hostname'),
'sort' => array(
'handler' => 'views_handler_sort',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
'help' => t('Current hostname'),
),
);
/*
* cyoa_nid
*/
$data['node']['cyoa_nid'] = array(
'group' => t('Cyoa'),
'title' => t('Cyoa node'),
'real field' => 'nid',
'help' => t('Create a relationship to a node cyoa.'),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'cyoa',
'base field' => 'nid',
'label' => t('Cyoa to node'),
'relationship field' => 'nid',
),
);
$data['cyoa']['uid'] = array(
'group' => t('Cyoa'),
'title' => t('Cyoa user'),
'help' => t('Create a relationship to a cyoa.'),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'users',
'base field' => 'uid',
'label' => t('Cyoa to user'),
),
);
$data['cyoa']['uid_hostname'] = array(
'real field' => 'uid',
'title' => t('Current user or hostname '),
'help' => t('Filter by current username or hostname .'),
'filter' => array(
'handler' => 'views_handler_filter_cyoa_uid_hostname',
'type' => 'yes-no',
),
);
$data['cyoac']['table']['join'] = array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
);
$data['cyoac']['timestamp'] = array(
'title' => t('Date path aken'), // The item it appears as on the UI,
'help' => t('The date the adventure started.'), // 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',
),
);
$data['cyoac']['table']['group'] = t('Cyoa choices');
$data['cyoac']['cyoacid'] = array(
'title' => t('Cyoacid'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'help' => t('The choice your own adventure choice ID.'), // The help that appears on the UI,
// Information for accepting a nid as an argument
'argument' => array(
'handler' => 'views_handler_argument_numeric',
'name field' => 'title', // the field to display in the summary.
'numeric' => TRUE,
),
// Information for accepting a nid as a filter
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
// Information for sorting on a nid.
'sort' => array(
'handler' => 'views_handler_sort',
),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'cyoa',
'base field' => 'cyoaid',
'label' => t('Cyoa to adventure'),
'relationship field' => 'cyoaid',
),
);
$data['cyoac']['cyoaid'] = array(
'title' => t('Choice\'s Cyoaid'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'help' => t('The choice your own adventure ID for the choice.'), // The help that appears on the UI,
// Information for accepting a nid as an argument
'argument' => array(
'handler' => 'views_handler_argument_numeric',
'name field' => 'title', // the field to display in the summary.
'numeric' => TRUE,
),
// Information for accepting a nid as a filter
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
// Information for sorting on a nid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['cyoac']['pcyoacid'] = array(
'title' => t('Parent Cyoacid'),
'help' => t('The choice your own adventure parent choice ID.'), // The help that appears on the UI,
// Information for accepting a nid as an argument
'argument' => array(
'handler' => 'views_handler_argument_numeric',
'name field' => 'title', // the field to display in the summary.
'numeric' => TRUE,
),
// Information for accepting a nid as a filter
'filter' => array(
'handler' => 'views_handler_filter_numeric',
),
// Information for sorting on a nid.
'sort' => array(
'handler' => 'views_handler_sort',
),
);
return $data;
}
/**
* Implementation of hook_views_data().
*/
function cyoa_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'cyoa') ,
),
'handlers' => array(
'views_handler_filter_cyoa_uid_hostname' => array(
'parent' => 'views_handler_filter_boolean_operator',
),
)
);
}