/[drupal]/contributions/modules/twitter/twitter.views.inc
ViewVC logotype

Contents of /contributions/modules/twitter/twitter.views.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Thu Jun 11 03:01:02 2009 UTC (5 months, 2 weeks ago) by walkah
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +8 -39 lines
File MIME type: text/x-php
sync head with DRUPAL-6--3
1 <?php
2 // $Id: twitter.views.inc,v 1.6.2.1 2009/05/28 06:45:21 walkah Exp $
3 /**
4 * @file
5 * Provide views data and handlers for twitter.module
6 */
7
8 /**
9 * @defgroup views_twitter_module twitter.module handlers
10 *
11 * Includes the ability to create views of just the twitter table.
12 * @{
13 */
14
15 /**
16 * Implementation of hook_views_handlers()
17 */
18 function twitter_views_handlers() {
19 return array(
20 'handlers' => array(
21 'twitter_views_handler_field_profile_image' => array(
22 'parent' => 'views_handler_field',
23 'file' => 'twitter_views_field_handlers.inc',
24 ),
25 'twitter_views_handler_field_xss' => array(
26 'parent' => 'views_handler_field',
27 'file' => 'twitter_views_field_handlers.inc',
28 ),
29 ),
30 );
31 }
32
33
34 /**
35 * Implementation of hook_views_data()
36 */
37 function twitter_views_data() {
38 // Basic table information.
39
40 $data['twitter']['table']['group'] = t('Twitter');
41
42 // Advertise this table as a possible base table
43 $data['twitter']['table']['base'] = array(
44 'field' => 'twitter_id',
45 'title' => t('Twitter message'),
46 'help' => t('Twitter status messages.'),
47 'weight' => 10,
48 );
49
50 // Twitter screen name
51 $data['twitter']['screen_name'] = array(
52 'title' => t('Login name'),
53 'help' => t('The login account of the Twitter user.'),
54 'field' => array(
55 'handler' => 'views_handler_field',
56 'click sortable' => TRUE,
57 ),
58 'filter' => array(
59 'handler' => 'views_handler_filter_string',
60 ),
61 'sort' => array(
62 'handler' => 'views_handler_sort',
63 ),
64 'argument' => array(
65 'handler' => 'views_handler_argument_string',
66 ),
67 );
68
69 // Twitter message timestamp
70 $data['twitter']['created_time'] = array(
71 'title' => t('Created time'),
72 'help' => t('The time the Twitter message was posted.'),
73 'field' => array(
74 'handler' => 'views_handler_field_date',
75 'click sortable' => TRUE,
76 ),
77 'sort' => array(
78 'handler' => 'views_handler_sort',
79 ),
80 'filter' => array(
81 'handler' => 'views_handler_filter_date',
82 ),
83 );
84
85 // Twitter text
86 $data['twitter']['text'] = array(
87 'title' => t('Message text'),
88 'help' => t('The text of the Twitter message.'),
89 'field' => array(
90 'handler' => 'twitter_views_handler_field_xss',
91 'click sortable' => TRUE,
92 ),
93 'filter' => array(
94 'handler' => 'views_handler_filter_string',
95 ),
96 );
97
98 // Twitter source
99 $data['twitter']['source'] = array(
100 'title' => t('Source'),
101 'help' => t('The name of the application that posted the Twitter message.'),
102 'field' => array(
103 'handler' => 'views_handler_field_xss',
104 'click sortable' => TRUE,
105 ),
106 'filter' => array(
107 'handler' => 'views_handler_filter_string',
108 ),
109 'sort' => array(
110 'handler' => 'views_handler_sort',
111 ),
112 );
113
114
115
116
117 $data['twitter_account']['table']['group'] = t('Twitter');
118
119 $data['twitter_account']['table']['join'] = array(
120 'twitter' => array(
121 'left_field' => 'screen_name',
122 'field' => 'screen_name',
123 ),
124 'users' => array(
125 'left_field' => 'uid',
126 'field' => 'uid',
127 // 'left_table' => 'twitter_user',
128 ),
129 );
130
131 // Twitter screen name
132 $data['twitter_account']['screen_name'] = array(
133 'title' => t('Login name'),
134 'help' => t('The login account of the Twitter user.'),
135 'field' => array(
136 'handler' => 'views_handler_field',
137 'click sortable' => TRUE,
138 ),
139 'filter' => array(
140 'handler' => 'views_handler_filter_string',
141 ),
142 'sort' => array(
143 'handler' => 'views_handler_sort',
144 ),
145 'argument' => array(
146 'handler' => 'views_handler_argument_string',
147 ),
148 );
149
150
151 // Twitter account full name
152 $data['twitter_account']['name'] = array(
153 'title' => t('Full name'),
154 'help' => t('The full name Twitter account user.'),
155 'field' => array(
156 'handler' => 'views_handler_field',
157 'click sortable' => TRUE,
158 ),
159 'filter' => array(
160 'handler' => 'views_handler_filter_string',
161 ),
162 'sort' => array(
163 'handler' => 'views_handler_sort',
164 ),
165 'argument' => array(
166 'handler' => 'views_handler_argument_string',
167 ),
168 );
169
170 // Twitter account description
171 $data['twitter_account']['description'] = array(
172 'title' => t('Description'),
173 'help' => t('The description of the Twitter account.'),
174 'field' => array(
175 'handler' => 'views_handler_field',
176 'click sortable' => TRUE,
177 ),
178 'filter' => array(
179 'handler' => 'views_handler_field_xss',
180 ),
181 'sort' => array(
182 'handler' => 'views_handler_sort',
183 ),
184 );
185
186 // Twitter account location
187 $data['twitter_account']['location'] = array(
188 'title' => t('Location'),
189 'help' => t('The location of the Twitter account.'),
190 'field' => array(
191 'handler' => 'views_handler_field',
192 'click sortable' => TRUE,
193 ),
194 'filter' => array(
195 'handler' => 'views_handler_field_xss',
196 ),
197 'sort' => array(
198 'handler' => 'views_handler_sort',
199 ),
200 );
201
202 // Twitter account description
203 $data['twitter_account']['followers_count'] = array(
204 'title' => t('Followers'),
205 'help' => t('The number of users following this Twitter account.'),
206 'field' => array(
207 'handler' => 'views_handler_field_numeric',
208 'click sortable' => TRUE,
209 ),
210 'filter' => array(
211 'handler' => 'views_handler_filter_numeric',
212 ),
213 'sort' => array(
214 'handler' => 'views_handler_sort',
215 ),
216 );
217
218 // Twitter account profile image
219 $data['twitter_account']['profile_image_url'] = array(
220 'title' => t('Profile image'),
221 'help' => t('The image used by the Twitter account.'),
222 'field' => array(
223 'handler' => 'twitter_views_handler_field_profile_image',
224 'click sortable' => TRUE,
225 ),
226 );
227
228 // Twitter account url
229 $data['twitter_account']['url'] = array(
230 'title' => t('URL'),
231 'help' => t('The URL given by the Twitter account user.'),
232 'field' => array(
233 'handler' => 'views_handler_field_url',
234 'click sortable' => TRUE,
235 ),
236 'filter' => array(
237 'handler' => 'views_handler_filter_string',
238 ),
239 'sort' => array(
240 'handler' => 'views_handler_sort',
241 ),
242 );
243
244 // Twitter account protected
245 $data['twitter_account']['protected'] = array(
246 'title' => t('Protected status'),
247 'help' => t('Whether posts from this Twitter account should be visible to the general public.'),
248 'field' => array(
249 'handler' => 'views_handler_field_boolean',
250 'click sortable' => TRUE,
251 ),
252 'filter' => array(
253 'handler' => 'views_handler_filter_boolean_operator',
254 ),
255 'sort' => array(
256 'handler' => 'views_handler_sort',
257 ),
258 );
259
260 // Twitter message timestamp
261 $data['twitter_account']['last_refresh'] = array(
262 'title' => t('Last refresh'),
263 'help' => t('The time the Twitter account statuses were retrieved.'),
264 'field' => array(
265 'handler' => 'views_handler_field_date',
266 'click sortable' => TRUE,
267 ),
268 'sort' => array(
269 'handler' => 'views_handler_sort',
270 ),
271 'filter' => array(
272 'handler' => 'views_handler_filter_date',
273 ),
274 );
275
276 // Twitter account description
277 $data['twitter_account']['uid'] = array(
278 'title' => t('User ID'),
279 'help' => t('The UID of the Twitter account.'),
280 );
281 // Twitter account protected
282 $data['twitter_account']['import'] = array(
283 'title' => t('Import status'),
284 'help' => t('Whether posts from this Twitter account should be imported automatically.'),
285 'field' => array(
286 'handler' => 'views_handler_field_boolean',
287 'click sortable' => TRUE,
288 ),
289 'filter' => array(
290 'handler' => 'views_handler_filter_boolean_operator',
291 ),
292 'sort' => array(
293 'handler' => 'views_handler_sort',
294 ),
295 );
296
297 return $data;
298 }
299
300
301 function twitter_views_data_alter(&$data) {
302 $data['users']['table']['join']['twitter'] = array(
303 'left_table' => 'twitter_account',
304 'left_field' => 'uid',
305 'field' => 'uid',
306 );
307 $data['users']['table']['join']['twitter_account'] = array(
308 // 'left_table' => 'twitter_user',
309 'left_field' => 'uid',
310 'field' => 'uid',
311 );
312 }
313
314 /**
315 * @}
316 */

  ViewVC Help
Powered by ViewVC 1.1.2