CMS  Version 3.9
CalendarView Class Reference

Inherits FacetFilterable.

Public Member Functions

 CalendarView ($events, $id=null)
 
 getID ()
 
 addHandler ($class, $handler)
 
 getHandler ($event)
 
 addFacetTaggingHandler ($handler)
 Adds a row tagging handler. More...
 
 summary ($event)
 
 details ($event, $param=null)
 
 filterEvents ($events, $currentDay)
 
 rewriteQueryString ($year, $month)
 
 calculateMonthRange ()
 
 drawMiniCalendar ()
 
 createEventDialog ()
 
 drawMonth ()
 
 writeScript ()
 
 header ($alt=event_display)
 
 formatEventListLink ($link, $dLink, $currentDay, $eventBubbleID, $idx)
 
 drawEventList ()
 

Public Attributes

 $current_day
 
 $events
 
 $id
 The HTML tag id for the calendar view. More...
 
 $month
 
 $year
 
 $handlerMap = array()
 
 $calendarLink = "/calendar"
 
 $listLink = "/event_list"
 
 $listDialog = ""
 
 $detailLink = "/event_detail"
 
 $yearParam = "year"
 
 $monthParam = "month"
 
 $maxEventsPerDay = null
 The maximum number of events to display per day on monthly view. More...
 
 $tagRowCallbacks
 Array of callbacks for adding extra attributes to each row. More...
 

Detailed Description

Definition at line 227 of file calendar_view.inc.

Member Function Documentation

◆ addFacetTaggingHandler()

CalendarView::addFacetTaggingHandler (   $handler)

Adds a row tagging handler.

This function will receive the data item for each row and can add custom attributes to the row tag.

Definition at line 315 of file calendar_view.inc.

316  {
317  $this->tagRowCallbacks[] = $handler;
318  }
$handler
Definition: event_form.inc:62

◆ addHandler()

CalendarView::addHandler (   $class,
  $handler 
)
Parameters
String$classcomposite event class or data item class name
obj$handlerinstance of a class inherits from either StandardEventHandler or EventHandler

Definition at line 272 of file calendar_view.inc.

273  {
274  $this->handlerMap[$class] = $handler;
275  }

◆ calculateMonthRange()

CalendarView::calculateMonthRange ( )

Definition at line 364 of file calendar_view.inc.

365  {
366  if ($this->year < 2005 || $this->year > 2038 || $this->month < 1 || $this->month > 12)
367  {
368  die("Date out of range");
369  }
370 
371  $this->startStr = sprintf("%d-%02d-01", $this->year, $this->month);
372  $this->start = strtotime($this->startStr);
373 
374  $this->dayOfWeek = date("w", $this->start);
375  $this->daysInMonth = getMonthDays($this->month, $this->year);
376 
377  $this->prevMonth = $this->month - 1;
378  $this->prevYear = $this->year;
379 
380  if ($this->prevMonth <= 0)
381  {
382  $this->prevYear--;
383  $this->prevMonth = 12;
384  }
385 
386  $this->nextMonth = $this->month + 1;
387  $this->nextYear = $this->year;
388  if ($this->nextMonth > 12)
389 
390  {
391  $this->nextMonth = 1;
392  $this->nextYear++;
393  }
394 
395  $this->endStr = sprintf("%d-%02d-01", $this->nextYear, $this->nextMonth);
396 
397  $this->prevLink = $this->rewriteQueryString($this->prevYear, $this->prevMonth);
398  $this->nextLink = $this->rewriteQueryString($this->nextYear, $this->nextMonth);
399  }
$view month
$view year
rewriteQueryString($year, $month)

◆ CalendarView()

CalendarView::CalendarView (   $events,
  $id = null 
)

Definition at line 244 of file calendar_view.inc.

245  {
246  $this->events = $events;
247  $this->id = $id;
248  $this->month = date("n");
249  $this->year = date("Y");
250  $this->tagRowCallbacks = array();
251  $this->addHandler(Event, new StandardEventHandler());
252  ComponentManager::fireEvent("RegisterCalendarEventHandlers", $this);
253 
254  $max = Settings::getValue("calendar", "max_events_per_day");
255  if($max)
256  {
257  $this->maxEventsPerDay = $max;
258  }
259  }
$id
The HTML tag id for the calendar view.
addHandler($class, $handler)
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
Defines the Event class.
Definition: event.inc:43
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
$max

◆ createEventDialog()

CalendarView::createEventDialog ( )

Definition at line 497 of file calendar_view.inc.

498  {
499  }

◆ details()

CalendarView::details (   $event,
  $param = null 
)

Definition at line 325 of file calendar_view.inc.

326  {
327  return $this->getHandler($event)->details($event, $param);
328  }
$event
Definition: event_form.inc:46
getHandler($event)

◆ drawEventList()

CalendarView::drawEventList ( )

Definition at line 671 of file calendar_view.inc.

672  {
673  $this->createEventDialog();
674 
675  $this->calculateMonthRange();
676 
677  $this->header(calendar_display);
678 
679  if (count($this->events) > 0)
680  {
681  foreach($this->events as $event)
682  {
683  $handler = $this->getHandler($event);
684  $content .= $handler->details($event);
685  $content .= "<br>";
686  }
687  echo $content;
688  }
689  else
690  {
691 ?>
692 <p><i>No events have been scheduled for this month.</i></p>
693 <?
694  }
695  }
header($alt=event_display)
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24

◆ drawMiniCalendar()

CalendarView::drawMiniCalendar ( )

Definition at line 401 of file calendar_view.inc.

402  {
403  $this->createEventDialog();
404 
405  global $script;
406  $script .= <<<ENDSCRIPT
407 <script type="text/javascript" src="/components/calendar/js/calendar.js"></script>
408 ENDSCRIPT;
409 
410  $this->calculateMonthRange();
411 
412  $bubbles = "";
413 
414 ?>
415 <div id="minicalendar">
416 <table>
417  <tr>
418  <td colspan="7" class="month"><a class="calendar_nav" href="<?echo $this->prevLink?>">&lt;</a>&nbsp; <?echo date("F Y", $this->start)?>&nbsp; <a class="calendar_nav" href="<?echo $this->nextLink?>">&gt;</a> </td>
419  </tr>
420  <tr>
421  <th width="14%">Su</th>
422  <th width="14%">Mo</th>
423  <th width="14%">Tu</th>
424  <th width="14%">We</th>
425  <th width="14%">Th</th>
426  <th width="14%">Fr</th>
427  <th width="14%">Sa</th>
428  </tr>
429  <tr>
430 <?
431  for($c = 0; $c < $this->dayOfWeek; ++$c)
432  {
433 ?><td class="empty">&nbsp;</td><?
434  }
435 
436  $today = date("Y-m-d");
437 
438  for($i = 1; $i <= $this->daysInMonth; ++$i)
439  {
440 
441  $currentDay = sprintf("%d-%02d-%02d", $this->year, $this->month, $i);
442  $eventsToday = $this->filterEvents($this->events, $currentDay);
443 
444  if (count($eventsToday) > 0)
445  {
446  $class = "event";
447  $event = $eventsToday[0];
448  $eventBubbleID = "event_bubble_".str_replace("-", "_", $currentDay);
449  $dayTitle = date("F jS Y", strtotime($currentDay));
450 
451  $link = $this->formatEventListLink($this->listLink, $this->listDialog, $currentDay, $eventBubbleID, $i);
452 
453  $bubbles .=
454  "<div id='$eventBubbleID' class='event_bubble'>
455  <div class='event_bubble_content'>
456  <h4>{$dayTitle}</h4>";
457 
458  foreach($eventsToday as $event)
459  {
460  $handler = $this->getHandler($event);
461  $bubbles .= $handler->summary($event);
462  }
463 
464  $bubbles .=
465  " </div>
466  <div class='event_bubble_bottom'>&nbsp;</div></div>";
467  }
468  else
469  {
470  $class = (($c % 7) == 0 || ($c % 7) == 6) ? "weekend" : "weekday";
471  $link = $i;
472  }
473 
474  if ($currentDay == $today) $class="today";
475 ?>
476  <td class="<?echo $class ?>" ><?echo $link ?></td>
477 <?
478  ++$c;
479  if (($c % 7) == 0) echo "</tr><tr>";
480  }
481 
482  while ($c % 7)
483  {
484 
485 ?><td class="empty">&nbsp;</td>
486 <?
487  $c++;
488  }
489 ?>
490 </tr>
491 </table>
492 </div>
493 <?echo $bubbles?>
494 <?
495  }
& nbsp
Definition: index.inc:49
$helpTree width
Definition: tree.inc:45
formatEventListLink($link, $dLink, $currentDay, $eventBubbleID, $idx)
filterEvents($events, $currentDay)
if(!checkRole("admin")) $c
$topicList colspan
Definition: group_form.inc:54
$script

◆ drawMonth()

CalendarView::drawMonth ( )

Definition at line 501 of file calendar_view.inc.

502  {
503  $this->createEventDialog();
504 
505  $this->calculateMonthRange();
506 ?>
507 <div id="fullcalendar">
508 <table id=<?php echo $this->id ?>>
509  <tr>
510  <td class="month" colspan="7"><?echo date("F Y", $this->start)?> <a class="calendar_nav" href="<?echo $this->prevLink?>"><img src="/components/calendar/images/calendar_arrow_l.png" alt="left" width="22" height="22" border="0"></a> <a class="calendar_nav" href="<?echo $this->nextLink?>"><img src="/components/calendar/images/calendar_arrow_r.png" alt="right" width="22" height="22" border="0"></a> </td>
511  </tr>
512  <tr>
513  <th width="14.28%">Su</th>
514  <th width="14.28%">Mo</th>
515  <th width="14.28%">Tu</th>
516  <th width="14.28%">We</th>
517  <th width="14.28%">Th</th>
518  <th width="14.28%">Fr</th>
519  <th width="14.28%">Sa</th>
520  </tr>
521  <tr>
522 <?
523  for($c = 0; $c < $this->dayOfWeek; ++$c)
524  {
525 ?><td class="empty">&nbsp;</td><?
526  }
527 
528  $today = date("Y-m-d");
529 
530  for($i = 1; $i <= $this->daysInMonth; ++$i)
531  {
532 
533  $currentDay = sprintf("%d-%02d-%02d", $this->year, $this->month, $i);
534  $eventsToday = $this->filterEvents($this->events, $currentDay);
535  $content = "";
536 
537  if (count($eventsToday) > 0)
538  {
539  $class = "event";
540  foreach($eventsToday as $event)
541  {
542  $handler = $this->getHandler($event);
543  $content .= $handler->formatSummary($event, $this->tagRowCallbacks);
544  }
545 
546  $link = $i;
547  }
548  else
549  {
550  $class = (($c % 7) == 0 || ($c % 7) == 6) ? "weekend" : "weekday";
551  $link = $i;
552  }
553 
554  if ($currentDay == $today) $class="today";
555 ?>
556  <td class="<?echo $class ?>" data-day="<?php echo $i ?>"><?echo $link ?><? echo $content?></td>
557 <?
558  ++$c;
559  if (($c % 7) == 0) echo "</tr><tr>";
560  }
561 
562  while ($c % 7)
563  {
564 
565 ?><td class="empty">&nbsp;</td>
566 <?
567  $c++;
568  }
569 ?>
570 </tr>
571 </table>
572 </div>
573 <?
574  }
$desc height
Definition: event_edit.inc:64

◆ filterEvents()

CalendarView::filterEvents (   $events,
  $currentDay 
)

Definition at line 330 of file calendar_view.inc.

331  {
332  $ret = array();
333 
334  foreach($events as $event)
335  {
336  $handler = $this->getHandler($event);
337  if ($handler AND $handler->filter($event, $currentDay))
338  {
339  $ret[] = $event;
340  }
341  // If not found - function getHandler outputs trace
342  }
343 
344  return $ret;
345  }

◆ formatEventListLink()

CalendarView::formatEventListLink (   $link,
  $dLink,
  $currentDay,
  $eventBubbleID,
  $idx 
)

Definition at line 647 of file calendar_view.inc.

648  {
649  if($link)
650  {
651  $link .= (preg_match("/\?/", $link)) ? "&" : "?";
652  $link .= "date=$currentDay";
653  }
654  else
655  $link = "#";
656 
657  if($dLink)
658  {
659  if(preg_match("/[\‍(.*?\‍)]$/", $dLink))
660  $dLink = preg_replace("/[\‍(.*?\‍)]$/", ", '$currentDay')", $dLink);
661  else
662  $dLink .= "('$currentDay')";
663  $onclick = "onclick=\"$dLink; return false;\"";
664  }
665 
666  return "<a class='eventlink' href=\"{$link}\" $onclick;
667  onmouseover='showEventBubble(\"$eventBubbleID\", this);' onmouseout='hideEventBubble(\"$eventBubbleID\");'>{$idx}</a>";
668  }

◆ getHandler()

CalendarView::getHandler (   $event)

Definition at line 288 of file calendar_view.inc.

289  {
290  if(get_class($event) == "Event" && $event->composite_class)
291  {
292  $event_class = $event->composite_class;
293  }
294  else
295  {
296  $event_class = get_class($event);
297  }
298 
299  if(array_key_exists($event_class, $this->handlerMap))
300  {
301  $handler = $this->handlerMap[$event_class];
302  }
303  else
304  {
306  }
307 
308  return $handler;
309  }

◆ getID()

CalendarView::getID ( )

Definition at line 261 of file calendar_view.inc.

262  {
263  return $this->id;
264  }

◆ header()

CalendarView::header (   $alt = event_display)

Definition at line 601 of file calendar_view.inc.

602  {
603  $link = $this->rewriteQueryString($this->year, $this->month, $alt);
604  $altTitle = ($alt == event_display) ? "List of Events" : "Calendar";
605 ?>
606 <table style='width: 100%' class="layout">
607  <tr>
608  <td><p><a href="<? echo $link ?>">View <? echo $altTitle ?></a></p></td>
609  <td align="right">
610  <form method="get" action="">
611  <?php
612  $calendar_id = htmlSafe(checkNumeric($_GET["calendar_id"]));
613  if($calendar_id)
614  {
615  echo "<input id='calendar_id' type='hidden' name='calendar_id' value='$calendar_id'/>\n";
616  }
617  ?>
618  <select name="month">
619 <?
620  for($i = 1; $i <= 12; ++$i)
621  {
622  $monthName = date("F", strtotime("$i/1/2007"));
623  option($i, $monthName, $i == $this->month);
624  }
625 ?>
626  </select>&nbsp;<select name="year">
627 <?
628  $endYear = date("Y") + 2;
629  for($i = 2006; $i <= $endYear; ++$i)
630  {
631  option($i, $i, (int)$this->year);
632  }
633 ?>
634  </select>
635  <input type="submit" class="button" value=" GO "/>
636  </form>
637  </td>
638  </tr>
639 </table>
640 <?
641 
642  }
$calendar_id
$helpTree style
Definition: tree.inc:46
$form action
Definition: edit.inc:67
text align
Definition: redirects.inc:13

◆ rewriteQueryString()

CalendarView::rewriteQueryString (   $year,
  $month 
)

Definition at line 347 of file calendar_view.inc.

348  {
349  global $isAdmin;
350 
351  $qs = $_SERVER['QUERY_STRING'];
352 
353  $identifier = $_REQUEST["identifier"];
354 
355  if ($isAdmin) $identifier = "/admin/$identifier";
356 
357  $qs = preg_replace("/identifier=[\\w_]+&*/", "", $qs);
358  $qs = preg_replace("/{$this->yearParam}=\\d+&*/", "", $qs);
359  $qs = preg_replace("/{$this->monthParam}=\\d+&*/", "", $qs);
360 
361  return "$identifier".appendToQueryString($qs, "{$this->yearParam}=$year&{$this->monthParam}=$month");
362  }
$identifier

◆ summary()

CalendarView::summary (   $event)

Definition at line 320 of file calendar_view.inc.

321  {
322  return $this->getHandler($event)->summary($event);
323  }

◆ writeScript()

CalendarView::writeScript ( )

Definition at line 576 of file calendar_view.inc.

577  {
578  if(!count($this->tagRowCallbacks) || !$this->maxEventsPerDay) return;
579 
580  $options = "{}";
581  if($this->maxEventsPerDay)
582  {
583  $options = "{per_day: {$this->maxEventsPerDay}}";
584  }
585 
586  ob_start();
587  ?>
588  <script type="text/javascript" src="/components/calendar/js/filtering_calendar.js"></script>
589  <script type="text/javascript">
590  window.addEvent('domready', function()
591  {
592  var <?echo $this->id?> = new FilteringCalendar('<?echo $this->id ?>', <?php echo $options ?>);
593  });
594  </script>
595  <?
596  $script = ob_get_contents();
597  ob_end_clean();
598  return $script;
599  }

Member Data Documentation

◆ $calendarLink

CalendarView::$calendarLink = "/calendar"

Definition at line 235 of file calendar_view.inc.

◆ $current_day

CalendarView::$current_day

Definition at line 229 of file calendar_view.inc.

◆ $detailLink

CalendarView::$detailLink = "/event_detail"

Definition at line 238 of file calendar_view.inc.

◆ $events

CalendarView::$events

Definition at line 230 of file calendar_view.inc.

◆ $handlerMap

CalendarView::$handlerMap = array()

Definition at line 234 of file calendar_view.inc.

◆ $id

CalendarView::$id

The HTML tag id for the calendar view.

Definition at line 231 of file calendar_view.inc.

◆ $listDialog

CalendarView::$listDialog = ""

Definition at line 237 of file calendar_view.inc.

◆ $listLink

CalendarView::$listLink = "/event_list"

Definition at line 236 of file calendar_view.inc.

◆ $maxEventsPerDay

CalendarView::$maxEventsPerDay = null

The maximum number of events to display per day on monthly view.

Definition at line 241 of file calendar_view.inc.

◆ $month

CalendarView::$month

Definition at line 232 of file calendar_view.inc.

◆ $monthParam

CalendarView::$monthParam = "month"

Definition at line 240 of file calendar_view.inc.

◆ $tagRowCallbacks

CalendarView::$tagRowCallbacks

Array of callbacks for adding extra attributes to each row.

Definition at line 242 of file calendar_view.inc.

◆ $year

CalendarView::$year

Definition at line 233 of file calendar_view.inc.

◆ $yearParam

CalendarView::$yearParam = "year"

Definition at line 239 of file calendar_view.inc.


The documentation for this class was generated from the following file: