/[drupal]/contributions/modules/event/event.theme
ViewVC logotype

Contents of /contributions/modules/event/event.theme

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


Revision 1.85 - (show annotations) (download) (as text)
Thu Dec 25 16:19:17 2008 UTC (11 months ago) by killes
Branch: MAIN
CVS Tags: HEAD
Changes since 1.84: +34 -48 lines
File MIME type: text/x-php
change list formatting of events to use template file
1 <?php
2 // $Id: event.theme,v 1.84 2008/12/17 23:00:20 killes Exp $
3
4 /**
5 * @addtogroup themeable
6 * @{
7 */
8
9 /**
10 * Format a date selection element.
11 *
12 * @param $element
13 * An associative array containing the properties of the element.
14 * Properties used: title, value, options, description, required and attributes.
15 * @return
16 * A themed HTML string representing the date selection boxes.
17 *
18 * @ingroup themeable
19 */
20 function theme_event($element) {
21 return theme('form_element', $element, '<div class="container-inline">'. $element['#children'] .'</div>');
22 }
23
24 /**
25 * Format a calendar view
26 *
27 * @param day
28 * The day to display.
29 */
30 function theme_event_calendar_month($op, $header, $rows, $attributes = array(), $caption = NULL) {
31 $output = theme("table", $header, $rows, $attributes, $caption);
32 return '<div class="event-calendar"><div class="month-view">'. $output ."</div></div>\n";
33 }
34
35 /**
36 * Format a calendar view
37 *
38 * @param day
39 * The day to display.
40 */
41 function theme_event_calendar_week($op, $header, $rows, $attributes = array(), $caption = NULL) {
42 $output = theme("table", $header, $rows, $attributes, $caption);
43 return '<div class="event-calendar"><div class="week-view">'. $output ."</div></div>\n";
44 }
45
46 /**
47 * Format a calendar view
48 *
49 * @param day
50 * The day to display.
51 */
52 function theme_event_calendar_day($op, $header, $rows, $attributes = array(), $caption = NULL) {
53 $output = theme("table", $header, $rows, $attributes, $caption);
54 return '<div class="event-calendar"><div class="day-view">'. $output ."</div></div>\n";
55 }
56
57 /**
58 * Format a calendar view
59 *
60 * @param day
61 * The day to display.
62 */
63 function theme_event_calendar_table($op, $header, $rows, $attributes = array(), $caption = NULL) {
64 $output = theme("table", $header, $rows, $attributes, $caption);
65 return '<div class="event-calendar"><div class="table-view">'. $output ."</div></div>\n";
66 }
67
68 /**
69 * Format a calendar view
70 *
71 */
72 function template_preprocess_event_calendar_list(&$variables) {
73 }
74
75 /**
76 * Format an event node for display in an expanded calendar, like a calendar page
77 *
78 */
79 function template_preprocess_event_node_day(&$variables) {
80 static $zebra;
81 $variables['zebra'] = $zebra++%2? ' odd' : '';
82 $variables['links'] = theme('links', $variables['node']->event['links']);
83 $variables['teaser'] = check_markup($variables['node']->teaser, $variables['node']->format);
84 $variables['node_type'] = check_plain($variables['node']->type);
85 $variables['show_calendar_link'] = (variable_get('event_type_control', 'all') != 'never') && ((count(event_get_types('all')) + count(event_get_types('solo'))) > 1);
86 $variables['calendar_link'] = 'event/'. _event_format_url($variables['node']->event['start_exploded']) .'/day/'. check_plain($variables['node']->type);
87 $variables['node_title_unsafe'] = $variables['node']->title;
88 $variables['node_title_safe'] = check_plain($variables['node']->title);
89 $variables['node_link'] = 'node/'. $variables['node']->nid;
90 $variables['show_start'] = ($variables['node']->event['state'] != 'allday' && $variables['node']->event['state'] != 'ongoing');
91 $variables['show_end'] = in_array($variables['node']->event['state'], array('singleday', 'end')) && $variables['node']->event['has_end_date'];
92 $variables['ongoing'] = ($variables['node']->event['state'] == 'ongoing' || $variables['node']->event['state'] == 'allday');
93 $variables['start_date'] = $variables['node']->event['start'];
94 $variables['end_date'] = $variables['node']->event['end'];
95 $variables['start_date_utc'] = $variables['node']->event['start_utc'];
96 $variables['end_date_utc'] = $variables['node']->event['end_utc'];
97 $variables['start_date_formatted'] = $variables['node']->event['start_date_format'];
98 $variables['end_date_formatted'] = $variables['node']->event['end_date_format'];
99 if ($variables['node']->event['has_time']) {
100 $variables['start_time_formatted'] = $variables['node']->event['start_time_format'];
101 $variables['end_time_formatted'] = $variables['node']->event['end_time_format'];
102 }
103 else {
104 $variables['start_time_formatted'] = '';
105 $variables['end_time_formatted'] = '';
106 }
107 }
108
109 /**
110 * Format an event node for display in an expanded calendar, like a calendar page
111 *
112 * @param node
113 * The node being displayed
114 */
115 function template_preprocess_event_node_week(&$variables) {
116 static $stripe, $stripe_map;
117 if (empty($stripe_map[$variables['node']->nid])) {
118 if ($stripe >= 10) {
119 $stripe = 1;
120 }
121 else {
122 $stripe++;
123 }
124 $stripe_map[$variables['node']->nid] = $stripe;
125 }
126 $variables['stripe'] = $stripe_map[$variables['node']->nid];
127 $variables['links'] = theme('links', $variables['node']->event['links']);
128 $variables['teaser'] = check_markup($variables['node']->teaser, $variables['node']->format);
129 $variables['node_type'] = check_plain($variables['node']->type);
130 $variables['state'] = check_plain($variables['node']->event['state']);
131 $variables['show_calendar_link'] = (variable_get('event_type_control', 'all') != 'never') && ((count(event_get_types('all')) + count(event_get_types('solo'))) > 1);
132 $variables['calendar_link'] = 'event/'. _event_format_url($variables['node']->event['start_exploded']) .'/week/'. check_plain($variables['node']->type);
133 $variables['node_title_unsafe'] = $variables['node']->title;
134 $variables['node_title_safe'] = check_plain($variables['node']->title);
135 $variables['node_link'] = 'node/'. $variables['node']->nid;
136 $variables['show_start'] = ($variables['node']->event['state'] != 'allday' && $variables['node']->event['state'] != 'ongoing');
137 $variables['show_end'] = in_array($variables['node']->event['state'], array('singleday', 'end')) && $variables['node']->event['has_end_date'];
138 $variables['ongoing'] = ($variables['node']->event['state'] == 'ongoing' || $variables['node']->event['state'] == 'allday');
139 $variables['start_date'] = $variables['node']->event['start'];
140 $variables['end_date'] = $variables['node']->event['end'];
141 $variables['start_date_utc'] = $variables['node']->event['start_utc'];
142 $variables['end_date_utc'] = $variables['node']->event['end_utc'];
143 $variables['start_date_formatted'] = $variables['node']->event['start_date_format'];
144 $variables['end_date_formatted'] = $variables['node']->event['end_date_format'];
145 if ($variables['node']->event['has_time']) {
146 $variables['start_time_formatted'] = $variables['node']->event['start_time_format'];
147 $variables['end_time_formatted'] = $variables['node']->event['end_time_format'];
148 }
149 else {
150 $variables['start_time_formatted'] = '';
151 $variables['end_time_formatted'] = '';
152 }
153 }
154
155 /**
156 * Format an event node for display in an expanded calendar, like a calendar page
157 *
158 * @param node
159 * The node being displayed
160 */
161 function template_preprocess_event_node_month(&$variables) {
162 static $stripe, $stripe_map;
163
164 if (empty($stripe_map[$variables['node']->nid])) {
165 if ($stripe >= 10) {
166 $stripe = 1;
167 }
168 else {
169 $stripe++;
170 }
171 $stripe_map[$variables['node']->nid] = $stripe;
172 }
173
174 $variables['stripe'] = $stripe_map[$variables['node']->nid];
175 $variables['links'] = theme('links', $variables['node']->event['links']);
176 $variables['teaser'] = check_markup($variables['node']->teaser, $variables['node']->format);
177 $variables['node_type'] = check_plain($variables['node']->type);
178 $variables['state'] = check_plain($variables['node']->event['state']);
179 $variables['show_calendar_link'] = (variable_get('event_type_control', 'all') != 'never') && ((count(event_get_types('all')) + count(event_get_types('solo'))) > 1);
180 $variables['calendar_link'] = 'event/'. _event_format_url($variables['node']->event['start_exploded']) .'/month/'. check_plain($variables['node']->type);
181 $variables['node_title_unsafe'] = $variables['node']->title;
182 $variables['node_title_safe'] = check_plain($variables['node']->title);
183 $variables['node_link'] = 'node/'. $variables['node']->nid;
184 $variables['show_start'] = in_array($variables['node']->event['state'], array('singleday', 'start')) && $variables['node']->event['has_time'];
185 $variables['show_end'] = in_array($variables['node']->event['state'], array('singleday', 'end')) && $variables['node']->event['has_end_date'];
186 $variables['ongoing'] = in_array($variables['node']->event['state'], array('ongoing'));
187 $variables['start_date'] = $variables['node']->event['start'];
188 $variables['end_date'] = $variables['node']->event['end'];
189 $variables['start_date_utc'] = $variables['node']->event['start_utc'];
190 $variables['end_date_utc'] = $variables['node']->event['end_utc'];
191 $variables['start_date_formatted'] = $variables['node']->event['start_date_format'];
192 $variables['end_date_formatted'] = $variables['node']->event['end_date_format'];
193 if ($variables['node']->event['has_time']) {
194 $variables['start_time_formatted'] = $variables['node']->event['start_time_format'];
195 $variables['end_time_formatted'] = $variables['node']->event['end_time_format'];
196 }
197 else {
198 $variables['start_time_formatted'] = '';
199 $variables['end_time_formatted'] = '';
200 }
201 }
202
203 /**
204 * Format an event node for display in an expanded calendar, like a calendar page
205 *
206 * @param $variables Theming variables
207 */
208 function template_preprocess_event_node_table(&$variables) {
209 static $stripe, $stripe_map, $link_count;
210 drupal_add_js(drupal_get_path('module', 'event') .'/event.js');
211 $link_count++;
212
213 if (empty($stripe_map[$variables['node']->nid])) {
214 if ($stripe >= 10) {
215 $stripe = 1;
216 }
217 else {
218 $stripe++;
219 }
220 $stripe_map[$variables['node']->nid] = $stripe;
221 }
222 $variables['stripe'] = $stripe_map[$variables['node']->nid];
223 $variables['links'] = theme('links', $variables['node']->event['links']);
224 $variables['teaser'] = check_markup($variables['node']->teaser, $variables['node']->format);
225 $variables['node_type'] = check_plain($variables['node']->type);
226 $variables['state'] = check_plain($variables['node']->event['state']);
227 $variables['show_calendar_link'] = (variable_get('event_type_control', 'all') != 'never') && ((count(event_get_types('all')) + count(event_get_types('solo'))) > 1);
228 $variables['calendar_link'] = 'event/'. _event_format_url($variables['node']->event['start_exploded']) .'/month/'. check_plain($variables['node']->type);
229 $variables['node_title_unsafe'] = $variables['node']->title;
230 $variables['node_title_safe'] = check_plain($variables['node']->title);
231 $variables['node_link'] = 'node/'. $variables['node']->nid;
232 $variables['show_start'] = ($variables['node']->event['state'] != 'allday' && $variables['node']->event['state'] != 'ongoing');
233 $variables['show_end'] = in_array($variables['node']->event['state'], array('singleday', 'end')) && $variables['node']->event['has_end_date'];
234 $variables['start_date'] = $variables['node']->event['start'];
235 $variables['end_date'] = $variables['node']->event['end'];
236 $variables['start_date_utc'] = $variables['node']->event['start_utc'];
237 $variables['end_date_utc'] = $variables['node']->event['end_utc'];
238 $variables['start_date_formatted'] = $variables['node']->event['start_date_format'];
239 $variables['end_date_formatted'] = $variables['node']->event['end_date_format'];
240 if ($variables['node']->event['has_time']) {
241 $variables['start_time_formatted'] = $variables['node']->event['start_time_format'];
242 $variables['end_time_formatted'] = $variables['node']->event['end_time_format'];
243 }
244 else {
245 $variables['start_time_formatted'] = '';
246 $variables['end_time_formatted'] = '';
247 }
248 }
249
250 /**
251 * Format a list of event nodes for display
252 *
253 * @param $variables Theming variables
254 */
255 function template_preprocess_event_node_list(&$variables) {
256 static $stripe, $stripe_map, $link_count;
257 drupal_add_js(drupal_get_path('module', 'event') .'/event.js');
258 $link_count++;
259
260 if (empty($stripe_map[$variables['node']->nid])) {
261 if ($stripe >= 10) {
262 $stripe = 1;
263 }
264 else {
265 $stripe++;
266 }
267 $stripe_map[$variables['node']->nid] = $stripe;
268 }
269 $variables['link_count'] = $link_count;
270 $variables['stripe'] = $stripe_map[$variables['node']->nid];
271 $variables['links'] = theme('links', $variables['node']->event['links']);
272 $variables['teaser'] = check_markup($variables['node']->teaser, $variables['node']->format);
273 $variables['node_type'] = check_plain($variables['node']->type);
274 $variables['state'] = check_plain($variables['node']->event['state']);
275 $variables['show_calendar_link'] = (variable_get('event_type_control', 'all') != 'never') && ((count(event_get_types('all')) + count(event_get_types('solo'))) > 1);
276 $variables['calendar_link'] = 'event/'. _event_format_url($variables['node']->event['start_exploded']) .'/month/'. check_plain($variables['node']->type);
277 $variables['node_title_unsafe'] = $variables['node']->title;
278 $variables['node_title_safe'] = check_plain($variables['node']->title);
279 $variables['node_link'] = 'node/'. $variables['node']->nid;
280 $variables['show_start'] = ($variables['node']->event['state'] != 'allday' && $variables['node']->event['state'] != 'ongoing');
281 $variables['show_end'] = in_array($variables['node']->event['state'], array('singleday', 'end')) && $variables['node']->event['has_end_date'];
282 $variables['start_date'] = $variables['node']->event['start'];
283 $variables['end_date'] = $variables['node']->event['end'];
284 $variables['start_date_utc'] = $variables['node']->event['start_utc'];
285 $variables['end_date_utc'] = $variables['node']->event['end_utc'];
286 $variables['start_date_formatted'] = $variables['node']->event['start_date_format'];
287 $variables['end_date_formatted'] = $variables['node']->event['end_date_format'];
288 if ($variables['node']->event['has_time']) {
289 $variables['start_time_formatted'] = $variables['node']->event['start_time_format'];
290 $variables['end_time_formatted'] = $variables['node']->event['end_time_format'];
291 }
292 else {
293 $variables['start_time_formatted'] = '';
294 $variables['end_time_formatted'] = '';
295 }
296 }
297
298 /**
299 * Format an date's day box in a calendar
300 *
301 * @param date
302 * The day to display.
303 */
304 function theme_event_calendar_date_box($date, $view) {
305 $output = '';
306 switch ($view) {
307 case 'table':
308 $output = '<div class="day">'. t('%month / %day', array('%month' => $date['month'], '%day' => (int)$date['day'])) .'</div>'."\n";
309 break;
310 case 'list':
311 $output = '<div class="day">'. event_format_date($date, 'custom', t('l F d, Y')) .'</div>'."\n";
312 break;
313 case 'day':
314 break;
315 default:
316 $output = '<div class="day">'. (int)$date['day'] .'</div>'."\n";
317 break;
318 }
319 return $output;
320 }
321
322 /**
323 * Format an empty day on a calendar
324 *
325 * @param date
326 * The day to display.
327 */
328 function theme_event_empty_day($date, $view) {
329 $output = '';
330 switch ($view) {
331 case 'table':
332 $output .= '<div class="day">'. t('%month / %day', array('%month' => $date['month'], '%day' => (int)$date['day'])) .'</div>'."\n";
333 $output .= '<div class="event-empty"></div>'."\n";
334 break;
335 case 'day':
336 case 'list':
337 break;
338 default:
339 $output .= '<div class="day">'. (int) $date['day'] .'</div>'."\n";
340 $output .= '<div class="event-empty"></div>'."\n";
341 break;
342 }
343 return $output;
344 }
345
346 /**
347 * Format a node for display
348 *
349 * @param variables
350 * The array of theming variables
351 */
352 function template_preprocess_event_nodeapi(&$variables) {
353 $variables['start_date'] = $variables['node']->event['start'];
354 $variables['end_date'] = $variables['node']->event['end'];
355 $variables['show_end'] = isset($variables['node']->event['has_end_date']) && $variables['node']->event['has_end_date'];
356 $variables['node_type'] = check_plain($variables['node']->type);
357 $variables['start_date_formatted'] = $variables['node']->event['start_date_format'];
358 $variables['end_date_formatted'] = $variables['node']->event['end_date_format'];
359 if ($variables['node']->event['has_time']) {
360 $variables['start_time_formatted'] = $variables['node']->event['start_time_format'];
361 $variables['end_time_formatted'] = $variables['node']->event['end_time_format'];
362 }
363 else {
364 $variables['start_time_formatted'] = '';
365 $variables['end_time_formatted'] = '';
366 }
367 $variables['start_date_utc'] = event_format_date($variables['node']->event['start_utc'], 'custom', "Y-m-d\TH:i:s\Z");
368 $variables['end_date_utc'] = event_format_date($variables['node']->event['end_utc'], 'custom', "Y-m-d\TH:i:s\Z");
369 }
370
371 /**
372 * Format the event filter control dropdown
373 *
374 * @param form
375 * The form containing the taxonomy controls
376 */
377 function theme_event_filter_control($form) {
378 return '<div class="event-filter-control">'. $form .'</div>';
379 }
380
381 /**
382 * Format the 'next' navigation controls for event calendars
383 *
384 * @param link
385 * The url for the navigation
386 * @param $attributes
387 * Attributes for the navigation link.
388 */
389 function theme_event_nav_next($url, $attributes = array()) {
390 return '<span class="next">'. l('»', $url, array('attributes' => $attributes)) .'</span>';
391 }
392
393 /**
394 * Format the 'previous' navigation controls for event calendars
395 *
396 * @param link
397 * The url for the navigation
398 * @param $attributes
399 * Attributes for the navigation link.
400 */
401 function theme_event_nav_prev($url, $attributes = array()) {
402 return '<span class="prev">'. l('«', $url, array('attributes' => $attributes)) .'</span>';
403 }
404
405
406 /**
407 * Format the 'next' navigation controls for event calendars, if
408 * there's no next calendar.
409 *
410 * @param text
411 * The text for the title tag
412 */
413 function theme_event_nav_stop_next($text) {
414 return '<span class="stop" title ="'. $text .'">»</span>';
415 }
416
417 /**
418 * Format the 'previous' navigation controls for event calendars, if
419 * there's no previous calendar.
420 *
421 * @param text
422 * The text for the title tag
423 */
424 function theme_event_nav_stop_prev($text) {
425 return '<span class="stop" title ="'. $text .'">«</span>';
426 }
427
428 /**
429 * Format the links for event calendars
430 *
431 * @param links
432 * An array of links to render
433 * @param view
434 * The current view being rendered
435 */
436 function theme_event_links($links, $view) {
437 return theme('links', $links);
438 }
439
440 /**
441 * Format the ical link
442 *
443 * @param path
444 * The url for the ical feed
445 */
446 function theme_event_ical_link($path) {
447 return '<div class="ical-link">'. l('<img src="'. base_path() . drupal_get_path('module', 'event') .'/images/ical16x16.gif" alt="'. t('Add to iCalendar') .'" />', $path, array('attributes' => array('title' => t('Add this calendar to your iCalendar')), 'absolute' => TRUE, 'html' => TRUE)) .'</div>';
448 }
449
450 /**
451 * Format the 'read more' link for events
452 *
453 * @param path
454 * The url to use for the read more link
455 */
456 function theme_event_more_link($path) {
457 return '<div class="more-link">'. l(t('more'), $path, array('attributes' => array('title' => t('More events.')))) .'</div>';
458 }
459
460 /**
461 * Format an individual upcoming event block item
462 *
463 * @param node
464 * The node to render as an upcoming event
465 * TODO: decorate with hcalendar
466 */
467 function theme_event_upcoming_item($node, $types = array()) {
468 $output = l($node->title, "node/$node->nid", array('attributes' => array('title' => $node->title)));
469 if (count($types) > 1) {
470 $output .= '<span class="event-nodetype">('. $node->event['node_type'] .')</span>';
471 }
472 $output .= '<span class="event-timeleft">('. $node->event['timeleft'] .')</span>';
473 return $output;
474 }
475
476 /**
477 * Format the upcoming event block for event calendars
478 *
479 * @param items
480 * An array of themed upcoming events
481 */
482 function theme_event_upcoming_block($items) {
483 $output = theme("item_list", $items);
484 return $output;
485 }
486 /** @} End of addtogroup themeable */

  ViewVC Help
Powered by ViewVC 1.1.2