| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: theme.inc,v 1.10.2.80 2011/01/03 12:45:27 karens Exp $ 3 /** 4 * Display a calendar navigation and links 5 */ 6 function template_preprocess_calendar_main(&$vars) { 7 require_once('./'. drupal_get_path('module', 'calendar') .'/includes/calendar.inc'); 8 $view = $vars['view']; 9 10 $result = (array) $view->result; 11 $options = $view->style_plugin->options; 12 $handler = $view->style_plugin; 13 14 $vars['display_type'] = $view->date_info->granularity; 15 $vars['min_date_formatted'] = !empty($view->date_info->min_date) ? date_format($view->date_info->min_date, DATE_FORMAT_DATETIME) : ''; 16 $vars['max_date_formatted'] = !empty($view->date_info->end_date) ? date_format($view->date_info->max_date, DATE_FORMAT_DATETIME) : ''; 17 $view->date_info->mini = isset($view->date_info->mini) ? $view->date_info->mini : $view->date_info->granularity == 'year'; 18 19 $url = $view->get_url(); 20 $view->date_info->url = $url; 21 $arg = $view->date_info->date_arg; 22 $displays = $view->date_info->display_types; 23 24 // Set up the links to other calendar views. 25 $current_date = $view->date_info->min_date; 26 if (!empty($date->info->day)) { 27 $current_date = date_make_date($date_info->date_arg .' 00:00:00'); 28 } 29 elseif (!empty($view->date_info->week)) { 30 $week = date_week_range($view->date_info->week, $view->date_info->year); 31 $current_date = $week[0]; 32 } 33 elseif (!empty($view->date_info->month)) { 34 $current_date = date_make_date($view->date_info->year .'-'. date_pad($view->date_info->month) .'-01 00:00:00'); 35 } 36 else { 37 $current_date = date_make_date($view->date_info->year .'-01-01 00:00:00'); 38 } 39 if (empty($view->date_info->month) || $view->date_info->month == $view->argument['date_argument']->options['wildcard']) { 40 $view->date_info->month = date_format($current_date, 'm'); 41 } 42 if (empty($view->date_info->day) || $view->date_info->day == $view->argument['date_argument']->options['wildcard']) { 43 $view->date_info->day = date_format($current_date, 'd'); 44 } 45 if (empty($view->date_info->week) || $view->date_info->week == $view->argument['date_argument']->options['wildcard']) { 46 $view->date_info->week = date_week($view->date_info->year .'-'. date_pad($view->date_info->month) .'-'. date_pad($view->date_info->day)); 47 } 48 49 $calendar_links = array(); 50 $base = array('attributes' => array('rel' => 'nofollow')); 51 if (!empty($displays['year'])) { 52 $calendar_links['calendar calendar-year'] = $base + array('title' => date_t('Year', 'datetime'), 'href' => date_real_url($view, 'year')); 53 } 54 if (!empty($displays['month'])) { 55 $calendar_links['calendar calendar-month'] = $base + array('title' => date_t('Month', 'datetime'), 'href' => date_real_url($view, 'month')); 56 } 57 if (!empty($displays['week'])) { 58 $calendar_links['calendar calendar-week'] = $base + array('title' => date_t('Week', 'datetime'), 'href' => date_real_url($view, 'week')); 59 } 60 if (!empty($displays['day'])) { 61 $calendar_links['calendar calendar-day'] = $base + array('title' => date_t('Day', 'datetime'), 'href' => date_real_url($view, 'day')); 62 } 63 $vars['calendar_links'] = $calendar_links; 64 65 // If the Date Popup module is enabled, add a popup date selector. 66 if (!empty($view->date_info->calendar_popup)) { 67 $vars['calendar_popup'] = '<div class="clear-block">'. calendar_date_select($view) .'</div>'; 68 } 69 70 // If an 'Add new ... link is provided, add it here. 71 // the query will bring the user back here after adding the node. 72 if (!empty($view->date_info->calendar_date_link) 73 && (user_access("administer nodes") || user_access('create '. $view->date_info->calendar_date_link .' content'))) { 74 $name = node_get_types('name', $view->date_info->calendar_date_link); 75 $href = 'node/add/'. str_replace('_', '-', $view->date_info->calendar_date_link); 76 $query = 'destination='. $view->date_info->url; 77 $vars['calendar_links']['calendar calendar-add'] = $base + array( 78 'title' => t('Add+'), 79 'href' => $href, 80 'query' => $query, 81 ); 82 } 83 84 $vars['view'] = $view; 85 $vars['mini'] = !empty($view->date_info->mini); 86 $vars['block'] = !empty($view->date_info->block); 87 $vars['block_identifier'] = date_block_identifier($view); 88 89 } 90 91 /** 92 * Display a view as a calendar. 93 * 94 * This preprocessor does all the work needed for all types of calendar 95 * views and the template takes care of displaying links to related views. 96 */ 97 function template_preprocess_calendar(&$vars) { 98 require_once('./'. drupal_get_path('module', 'calendar') .'/includes/calendar.inc'); 99 $view = $vars['view']; 100 101 // Make sure we only run through this function one time. 102 if (!empty($view->date_info->calendar_processed)) { 103 return; 104 } 105 106 $result = (array) $view->result; 107 $options = $view->style_plugin->options; 108 $handler = $view->style_plugin; 109 110 $fields = $view->field; 111 112 // Render each field into an output array. We have to do the rendering 113 // here because we don't apppear to have full access to the view 114 // handlers in the theme functions. 115 $items = array(); 116 $calendar_fields = date_api_fields($view->base_table); 117 $calendar_fields = array_keys($calendar_fields['alias']); 118 119 foreach ($result as $num => $row) { 120 $copy = drupal_clone($row); 121 $items[$num] = $row; 122 $items[$num]->raw = $copy; 123 $items[$num]->calendar_fields = new stdClass(); 124 125 foreach ($row as $key => $value) { 126 if (in_array($key, $calendar_fields)) { 127 $items[$num]->calendar_fields->$key = $value; 128 } 129 } 130 foreach ($fields as $name => $field) { 131 // Some fields, like the node edit and delete links, have no alias. 132 $field_alias = $field->field_alias != 'unknown' ? $field->field_alias : $name; 133 if (!empty($field) && is_object($field)) { 134 // Theme the copy instead of the original row so duplicate date 135 // fields each get a fresh copy of the original data to theme. 136 $items[$num]->{$field_alias} = $field->theme($copy); 137 } 138 if (!empty($field->options['exclude'])) { 139 if (isset($items[$num]->{$field_alias})) unset($items[$num]->{$field_alias}); 140 } 141 } 142 } 143 144 $vars['display_type'] = $view->date_info->granularity; 145 $vars['min_date_formatted'] = date_format($view->date_info->min_date, DATE_FORMAT_DATETIME); 146 $vars['max_date_formatted'] = date_format($view->date_info->max_date, DATE_FORMAT_DATETIME); 147 148 // Massage the resulting items into formatted calendar items. 149 $items = calendar_build_nodes($view, $items); 150 151 // Merge in items from other sources. 152 foreach (module_implements('calendar_add_items') as $module) { 153 $function = $module .'_calendar_add_items'; 154 if (function_exists($function)) { 155 if ($feeds = $function($view)) { 156 foreach ($feeds as $feed) { 157 $items = $feed; 158 } 159 } 160 } 161 } 162 163 $view->date_info->mini = isset($view->date_info->mini) ? $view->date_info->mini : $view->date_info->granularity == 'year'; 164 165 // Create the calendar day names and rows. 166 $rows = calendar_build_calendar($view, $items); 167 168 $vars['items'] = $items; 169 $vars['rows'] = $rows; 170 171 $view->date_info->calendar_processed = TRUE; 172 $vars['view'] = $view; 173 $vars['mini'] = !empty($view->date_info->mini); 174 $vars['block'] = !empty($view->date_info->block); 175 } 176 177 /** 178 * Display a month view. 179 */ 180 function template_preprocess_calendar_month(&$vars) { 181 // Add in all the $vars added by the main calendar preprocessor. 182 template_preprocess_calendar($vars); 183 $view = $vars['view']; 184 185 $rows = $vars['rows']; 186 187 if (sizeof($rows) > 1) { 188 $day_names = array_shift($rows); 189 } 190 else { 191 $day_names = $rows; 192 $rows = array(); 193 } 194 195 $month_rows = $rows; 196 foreach ($rows as $weekno => $row) { 197 foreach ($row as $day => $data) { 198 $cell = $data['data']; 199 200 // If this cell is already rendered, like the weekno column, 201 // move to the next item. 202 if (!is_array($cell)) { 203 $month_rows[$weekno][$day]['data'] = $cell; 204 continue; 205 } 206 $data = $cell['datebox']; 207 if ($cell['empty']) { 208 $data .= $cell['empty']; 209 } 210 else { 211 $data .= implode($cell['all_day']); 212 foreach ($cell['items'] as $hour => $item) { 213 $data .= implode($item); 214 } 215 $data .= $cell['link']; 216 } 217 if ($view->date_info->mini) { 218 $month_rows[$weekno][$day]['data'] = $data; 219 } 220 else { 221 $month_rows[$weekno][$day]['data'] = '<div class="inner">'. $data .'</div>'; 222 } 223 } 224 } 225 226 $vars['rows'] = $month_rows; 227 $vars['day_names'] = $day_names; 228 229 $vars['display_type'] = $view->date_info->granularity; 230 $vars['min_date_formatted'] = date_format($view->date_info->min_date, DATE_FORMAT_DATETIME); 231 $vars['max_date_formatted'] = date_format($view->date_info->max_date, DATE_FORMAT_DATETIME); 232 } 233 234 /** 235 * Display a mini month view. 236 */ 237 function template_preprocess_calendar_mini(&$vars) { 238 // Add in all the $vars added by the main calendar preprocessor. 239 template_preprocess_calendar_month($vars); 240 241 $view = $vars['view']; 242 $view->date_info->show_title = !empty($view->date_info->show_title) ? $view->date_info->show_title : FALSE; 243 $vars['show_title'] = $view->date_info->show_title; 244 $vars['view'] = $view; 245 } 246 247 /** 248 * Display a year view. 249 */ 250 function template_preprocess_calendar_year(&$vars) { 251 // Add in all the $vars added by the main calendar preprocessor. 252 $vars['view']->date_info->style_with_weekno = FALSE; 253 template_preprocess_calendar($vars); 254 255 // Get the url of the year view and remove the year argument from it. 256 // TODO clean this up in case there is another arg that looks like 257 // the year to make sure only the year gets removed. 258 $view = $vars['view']; 259 $year = date_format($view->date_info->min_date, 'Y'); 260 261 // Construct a calendar for each month, adjusting the $view passed 262 // to the theme so it will produce the right results. 263 $view = drupal_clone($vars['view']); 264 $rows = $vars['rows']; 265 $months = array(); 266 foreach ($rows as $month => $month_rows) { 267 $view->date_info->month = $month; 268 $view->date_info->granularity = 'month'; 269 $view->date_info->mini = TRUE; 270 $view->date_info->hide_nav = TRUE; 271 $view->date_info->show_title = TRUE; 272 $view->date_info->url = date_real_url($view, NULL, date_pad($year, 4) .'-'. date_pad($month)); 273 $view->date_info->min_date = date_make_date($view->date_info->year .'-'. date_pad($month) .'-01 00:00:00', date_default_timezone_name()); 274 $view->date_info->max_date = drupal_clone($view->date_info->min_date); 275 date_modify($view->date_info->max_date, '+1 month'); 276 date_modify($view->date_info->max_date, '-1 second'); 277 $months[$month] = theme('calendar_mini', $view, $vars['options'], $month_rows); 278 } 279 $vars['months'] = $months; 280 $vars['view']->date_info->hide_nav = FALSE; 281 $vars['view']->date_info->granularity = 'year'; 282 283 } 284 285 /** 286 * Display a day view. 287 */ 288 function template_preprocess_calendar_day(&$vars) { 289 290 // Add in all the $vars added by the main calendar preprocessor. 291 $vars['view']->style_with_weekno = FALSE; 292 template_preprocess_calendar($vars); 293 294 $view = $vars['view']; 295 $rows = $vars['rows']; 296 297 $item_count = 0; 298 $by_hour_count = 0; 299 $grouping_field = $view->date_info->style_groupby_field; 300 301 // If we're not grouping by time, move all items into the 'all day' array. 302 if (empty($view->date_info->style_groupby_times)) { 303 // Items are already grouped into times, so we need to process each time-group. 304 foreach ($rows['items'] as $time => $items) { 305 foreach($items as $item) { 306 $rows['all_day'][] = $item; 307 } 308 } 309 $rows['items'] = array(); 310 } 311 312 $columns = array(); 313 314 // Move all_day items into the right columns and render them. 315 $grouped_items = array(); 316 foreach ($rows['all_day'] as $item) { 317 if (isset($item->{$grouping_field})) { 318 $column = $item->{$grouping_field}; 319 $item->{$grouping_field} = ''; // Remove the grouping field from the results. 320 if (!in_array($column, $columns)) { 321 $columns[] = $column; 322 } 323 } 324 else { 325 $column = t('Items'); 326 } 327 $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_'. $view->date_info->granularity .'_node'; 328 $grouped_items[$column][] = theme($theme, $item, $view); 329 $item_count++; 330 } 331 $vars['rows']['all_day'] = $grouped_items; 332 333 // Moved timed items into the right columns and render them. 334 $start_times = $view->date_info->style_groupby_times; 335 $show_empty_times = $view->date_info->style_show_empty_times; 336 $end_start_time = '23:59:59'; 337 $start_time = array_shift($start_times); 338 $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time; 339 340 $grouped_items = array(); 341 foreach ($rows['items'] as $time => $items) { 342 foreach ($items as $item) { 343 if (isset($item->{$grouping_field})) { 344 $column = $item->{$grouping_field}; 345 $item->{$grouping_field} = ''; // Remove the grouping field from the results. 346 if (!in_array($column, $columns)) { 347 $columns[] = $column; 348 } 349 } 350 else { 351 $column = t('Items'); 352 } 353 // Find the next time slot and fill it. Populate the skipped 354 // slots if the option to show empty times was chosen. 355 while ($time >= $next_start_time && $time < $end_start_time) { 356 if ((!empty($show_empty_times)) && !array_key_exists($start_time, $grouped_items)) { 357 $grouped_items[$start_time]['values'] = array(); 358 } 359 $start_time = $next_start_time; 360 $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time; 361 } 362 $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_'. $view->date_info->granularity .'_node'; 363 $grouped_items[$start_time]['values'][$column][] = theme($theme, $item, $view); 364 $item_count++; 365 $by_hour_count++; 366 } 367 } 368 369 // Finish out the day's time values if we want to see empty times. 370 if (!empty($show_empty_times)) { 371 while ($start_time < $end_start_time) { 372 if (!array_key_exists($start_time, $grouped_items)) { 373 $grouped_items[$start_time]['values'] = array(); 374 } 375 $start_time = $next_start_time; 376 $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time; 377 } 378 } 379 380 // Do the headers last, once we know what the actual values are. 381 $i = 0; 382 $start_times = array_keys($grouped_items); 383 foreach ($start_times as $start_time) { 384 $next_start_time = array_key_exists($i + 1, $start_times) ? $start_times[$i + 1] : '23:59:59'; 385 $heading = theme('calendar_time_row_heading', $start_time, $next_start_time, $rows['date']); 386 $grouped_items[$start_time]['hour'] = $heading['hour']; 387 $grouped_items[$start_time]['ampm'] = $heading['ampm']; 388 $i++; 389 } 390 ksort($grouped_items); 391 $vars['rows']['items'] = $grouped_items; 392 393 if (empty($columns)) { 394 $columns = array(t('Items')); 395 } 396 $vars['columns'] = $columns; 397 398 $vars['agenda_hour_class'] = 'calendar-agenda-hour'; 399 $first_column_width = 10; 400 401 if (empty($view->date_info->style_groupby_times)) { 402 $vars['agenda_hour_class'] .= ' calendar-agenda-no-hours'; 403 $first_column_width = 1; 404 } 405 406 $vars['first_column_width'] = $first_column_width; 407 if (count($columns)) { 408 $vars['column_width'] = round((100 - $first_column_width)/count($columns)); 409 } 410 else { 411 $vars['column_width'] = (100 - $first_column_width); 412 } 413 $vars['item_count'] = $item_count; 414 $vars['by_hour_count'] = $by_hour_count; 415 return; 416 } 417 418 /** 419 * Display a week view. 420 */ 421 function template_preprocess_calendar_week(&$vars) { 422 // Add in all the $vars added by the main calendar preprocessor. 423 $vars['view']->style_with_weekno = FALSE; 424 template_preprocess_calendar($vars); 425 426 $view = $vars['view']; 427 $rows = $vars['rows']; 428 $item_count = 0; 429 $by_hour_count = 0; 430 431 if (sizeof($rows) > 1) { 432 $day_names = array_shift($rows); 433 } 434 else { 435 $day_names = $rows; 436 $rows = array(); 437 } 438 439 // Moved timed items into the right columns and render them. 440 $show_empty_times = $view->date_info->style_show_empty_times; 441 $end_start_time = '23:59:59'; 442 443 $grouped_items = array(); 444 $vars['rows'] = $rows[0]; 445 foreach ($rows[0] as $weekno => $row) { 446 $vars['rows'][$weekno] = $row['data']; 447 448 // If we're not grouping by time, move all items into the 'all day' array. 449 if (empty($view->date_info->style_groupby_times)) { 450 foreach ($row['data']['items'] as $item) { 451 $row['data']['all_day'] = array_merge($row['data']['all_date'], $item); 452 } 453 $row['data']['items'] = array(); 454 } 455 456 $columns[] = $weekno; 457 $start_times = $view->date_info->style_groupby_times; 458 $start_time = array_shift($start_times); 459 $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time; 460 foreach ($row['data']['all_day'] as $key => $item) { 461 $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_'. $view->date_info->granularity .'_node'; 462 $vars['rows'][$weekno]['all_day'][$key] = theme($theme, $item, $view); 463 $item_count++; 464 } 465 foreach ($row['data']['items'] as $time => $items) { 466 foreach ($items as $item) { 467 // Find the next time slot and fill it. Populate the skipped 468 // slots if the option to show empty times was chosen. 469 while ($time >= $next_start_time && $time < $end_start_time) { 470 if (($show_empty_times) && !array_key_exists($start_time, $grouped_items)) { 471 $grouped_items[$start_time]['values'][$weekno] = array(); 472 } 473 $start_time = $next_start_time; 474 $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time; 475 } 476 $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_'. $view->date_info->granularity .'_node'; 477 $grouped_items[$start_time]['values'][$weekno][] = theme($theme, $item, $view); 478 $item_count++; 479 $by_hour_count++; 480 } 481 } 482 483 // Finish out the day's time values if we want to see empty times. 484 if ($show_empty_times) { 485 while ($start_time < $end_start_time) { 486 if (!array_key_exists($start_time, $grouped_items)) { 487 $grouped_items[$start_time]['values'][$weekno] = array(); 488 } 489 $start_time = $next_start_time; 490 $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time; 491 } 492 } 493 } 494 ksort($grouped_items); 495 496 // Do the headers last, once we know what the actual values are. 497 $i = 0; 498 $start_times = array_keys($grouped_items); 499 foreach ($start_times as $start_time) { 500 $next_start_time = array_key_exists($i + 1, $start_times) ? $start_times[$i + 1] : '23:59:59'; 501 $heading = theme('calendar_time_row_heading', $start_time, $next_start_time, $row['data']['date']); 502 $grouped_items[$start_time]['hour'] = $heading['hour']; 503 $grouped_items[$start_time]['ampm'] = $heading['ampm']; 504 } 505 506 $vars['items'] = $grouped_items; 507 508 $vars['day_names'] = $day_names; 509 $vars['columns'] = $columns; 510 $vars['start_times'] = $view->date_info->style_groupby_times; 511 512 $vars['agenda_hour_class'] = 'calendar-agenda-hour'; 513 $first_column_width = 10; 514 515 if (empty($view->date_info->style_groupby_times)) { 516 $vars['agenda_hour_class'] .= ' calendar-agenda-no-hours'; 517 $first_column_width = 1; 518 } 519 $vars['item_count'] = $item_count; 520 $vars['by_hour_count'] = $by_hour_count; 521 return; 522 } 523 524 /** 525 * Create the calendar date box. 526 */ 527 function template_preprocess_calendar_datebox(&$vars) { 528 $date = $vars['date']; 529 $view = $vars['view']; 530 531 $vars['day'] = intval(substr($date, 8, 2)); 532 $force_view_url = !empty($view->date_info->block) ? TRUE : FALSE; 533 $vars['url'] = date_real_url($view, NULL, $date, $force_view_url); 534 $vars['link'] = !empty($view->date_info->display_types['day']) ? l($vars['day'], $vars['url']) : $vars['day']; 535 $vars['granularity'] = $view->date_info->granularity; 536 $vars['mini'] = $view->date_info->mini; 537 538 if ($view->date_info->mini) { 539 if (!empty($vars['selected'])) { 540 $vars['class'] = 'mini-day-on'; 541 } 542 else { 543 $vars['class'] = 'mini-day-off'; 544 } 545 } 546 else { 547 $vars['class'] = 'day'; 548 } 549 } 550 551 /** 552 * Format an calendar node for display. 553 */ 554 function template_preprocess_calendar_node(&$vars) { 555 $node = $vars['node']; 556 $view = $vars['view']; 557 $fields = array(); 558 foreach ($view->field as $name => $field) { 559 // Some fields, like the node edit and delete links, have no alias. 560 $field_alias = $field->field_alias != 'unknown' ? $field->field_alias : $name; 561 if (!empty($node->$field_alias)) { 562 $data = $node->$field_alias; 563 $label = $field->options['label']; 564 565 // CCK has some special label options. 566 if (!empty($field->content_field)) { 567 switch ($field->options['label_type']) { 568 case 'none': 569 $label = ''; 570 break; 571 case 'widget': 572 $label = $field->content_field['widget']['label']; 573 break; 574 } 575 } 576 $fields[$field_alias] = array( 577 'id' => views_css_safe($field_alias), 578 'label' => $label, 579 'data' => $data, 580 ); 581 } 582 } 583 $vars['fields'] = $fields; 584 $vars['calendar_start'] = $node->calendar_start; 585 $vars['calendar_end'] = $node->calendar_end; 586 $vars['calendar_start_date'] = $node->calendar_start_date; 587 $vars['calendar_end_date'] = $node->calendar_end_date; 588 589 // We added the node type to the results in the query, 590 // but it will show up as $node->node_type instead of 591 // $node->type. Rename it to match the normal way it 592 // would show up on a node object. 593 $vars['node']->type = $vars['node']->node_type; 594 } 595 596 /** 597 * Format an calendar month node for display. 598 */ 599 function template_preprocess_calendar_month_node(&$vars) { 600 template_preprocess_calendar_node($vars); 601 } 602 603 /** 604 * Format an calendar month node for display. 605 */ 606 function template_preprocess_calendar_month_multiple_node(&$vars) { 607 $view = $vars['view']; 608 $curday = $vars['curday']; 609 610 // get the year month and date 611 $parts = explode('-', substr($curday, 0, 10)); 612 $year = $parts[0]; 613 $month = intval($parts[1]); 614 $day = intval($parts[2]); 615 616 // create the link to the day 617 $vars['link'] = date_real_url($view, NULL, date_pad($year, 4) .'-'. date_pad($month) .'-'. date_pad($day)); 618 } 619 620 /** 621 * Format an calendar day node for display. 622 */ 623 function template_preprocess_calendar_day_node(&$vars) { 624 template_preprocess_calendar_node($vars); 625 $node = $vars['node']; 626 // Remote items may have a teaser to show. 627 if (!empty($node->remote) && !empty($node->teaser)) { 628 $fields['teaser'] = '<div class="content">'. ($node->teaser) ."</div>\n"; 629 } 630 } 631 632 /** 633 * Format an calendar week node for display. 634 */ 635 function template_preprocess_calendar_week_node(&$vars) { 636 template_preprocess_calendar_node($vars); 637 } 638 639 /** 640 * Format an calendar week node for display. 641 */ 642 function template_preprocess_calendar_week_multiple_node(&$vars) { 643 $view = $vars['view']; 644 $curday = $vars['curday']; 645 646 // get the year month and date 647 $parts = explode('-', substr($curday, 0, 10)); 648 $year = $parts[0]; 649 $month = intval($parts[1]); 650 $day = intval($parts[2]); 651 652 // create the link to the day 653 $vars['link'] = date_real_url($view, NULL, date_pad($year, 4) .'-'. date_pad($month) .'-'. date_pad($day)); 654 } 655 656 /** 657 * Format the time row headings in the week and day view. 658 */ 659 function theme_calendar_time_row_heading($start_time, $next_start_time, $curday_date) { 660 static $format_hour, $format_ampm; 661 if (empty($format_hour)) { 662 $format = variable_get('date_format_short', 'm/d/Y - H:i'); 663 $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute'))); 664 $format_ampm = strstr($format, 'a') ? 'a' : (strstr($format, 'A') ? 'A' : ''); 665 } 666 if ($start_time == '00:00:00' && $next_start_time == '23:59:59') { 667 $hour = t('All times'); 668 } 669 elseif ($start_time == '00:00:00') { 670 $date = date_create($curday_date .' '. $next_start_time); 671 $hour = t('Before @time', array('@time' => date_format($date, $format_hour))); 672 } 673 else { 674 $date = date_create($curday_date .' '. $start_time); 675 $hour = date_format($date, $format_hour); 676 } 677 if (!empty($date)) { 678 $ampm = date_format($date, $format_ampm); 679 } 680 else { 681 $ampm = ''; 682 } 683 return array('hour' => $hour, 'ampm' => $ampm); 684 } 685 686 /** 687 * Format a node stripe legend 688 */ 689 function theme_calendar_stripe_legend() { 690 if (empty($GLOBALS['calendar_stripes'])) { 691 return ''; 692 } 693 $header = array( 694 array('class' => 'calendar-legend', 'data' => t('Item')), 695 array('class' => 'calendar-legend', 'data' => t('Key')) 696 ); 697 $rows = array(); 698 $output = ''; 699 foreach ((array) $GLOBALS['calendar_stripes'] as $label => $stripe) { 700 if($stripe){ 701 $rows[] = array($label, '<div style="background-color:'. $stripe .';color:'. $stripe .'" class="stripe" title="Key: '. $label .'"> </div>'); 702 } 703 } 704 if (!empty($rows)) { 705 $output .= theme('table', $header, $rows, array('class' => 'mini calendar-legend')); 706 } 707 return $output; 708 } 709 710 /** 711 * Format node stripes 712 */ 713 function theme_calendar_stripe_stripe($node) { 714 if (empty($node->stripe) || (!count($node->stripe))) { 715 return; 716 } 717 $output = ''; 718 if(is_array($node->stripe_label)){ 719 foreach($node->stripe_label as $k => $stripe_label){ 720 if(!empty($node->stripe[$k]) && !empty($stripe_label)) { 721 $GLOBALS['calendar_stripes'][$stripe_label] = $node->stripe[$k]; 722 $output.= '<div style="background-color:'. $node->stripe[$k] .';color:'. $node->stripe[$k] .'" class="stripe" title="Key: '. $node->stripe_label[$k] .'"> </div>'."\n"; 723 } 724 } 725 } 726 return $output; 727 } 728 729 /** 730 * Format an empty day on a calendar 731 * 732 * @param day 733 * The day to display. 734 */ 735 function theme_calendar_empty_day($curday, $view) { 736 737 if ($view->date_info->calendar_type != 'day') { 738 return '<div class="calendar-empty"> </div>'."\n"; 739 } 740 else { 741 return '<div class="calendar-dayview-empty">'. t('Empty day') .'</div>'; 742 } 743 } 744 745 /** @} End of addtogroup themeable */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |