CMS  Version 3.9
calendar_helper.inc
Go to the documentation of this file.
1 <?php
9 {
10  var $handlerMap = array();
11 
12  function CalendarHelper()
13  {
14  ComponentManager::fireEvent("RegisterCalendarEventHandlers", $this);
15  }
16 
31  function getHandler($event)
32  {
33  $pk = $event->getPrimaryKey();
34  if(!$event->$pk && count($this->handlerMap))
35  {
36  $handler_class = array_shift(array_values($this->handlerMap));
37  return new $handler_class;
38  }
39 
40  if(get_class($event) == "Event" && $event->composite_class)
41  {
42  $event_class = $event->composite_class;
43  }
44  else
45  {
46  $event_class = get_class($event);
47  }
48 
49  if(array_key_exists($event_class, $this->handlerMap))
50  {
51  $handler = $this->handlerMap[$event_class];
52  }
53  else
54  {
56  }
57 
58  return $handler;
59  }
60 
68  {
69  $this->handlerMap[$class] = $handler;
70  }
71 
72  static function eventFilterSetup()
73  {
74  $event = new Event();
75  $event->fromGET();
76 
77  $event->filter = new InclusionFilter("calendar_id", "start_date", "end_date");
78 
79  $filterForm = new FilterForm($event, "GET");
80  $filterForm->hide("end_date");
81 
82  $calendars = Query::create(Calendar, "ORDER BY name")->execute();
83  if(count($calendars) > 0)
84  {
85  $calendarSelect = new FilterFieldRenderer($filterForm, "calendar_id", "Calendar", FilterFieldRenderer::formatOptions($calendars, "{name}"));
86  }
87  else
88  {
89  $filterForm->hide("calendar_id");
90  }
91  $dateRangeRenderer = new DateRangeFilterRenderer($filterForm, "start_date", "start_date", "year");
92  $dateRangeRenderer->dateRangeLabel = "Event Date";
93 
94  return $filterForm;
95  }
96 
97  static function createCalendarFacet()
98  {
99  $facet = new MultiSelectFacetFilter("calendar_id", array(Calendar => "{name}"));
100 
101  $facet->dropdownMaxWidth = "160px";
102  $facet->width = "200px";
103  $facet->height = "240px";
104 
105  return $facet;
106  }
107 }
108 
109 ?>
$filterForm
$calendars
Definition: calendars.inc:39
$dateRangeRenderer
Definition: email_logs.inc:14
$event
Definition: event_form.inc:46
$handler
Definition: event_form.inc:62
static eventFilterSetup()
getHandler($event)
If the event DataItem class is Event and the instance has a composite class, then find the handler th...
addHandler($class, $handler)
static createCalendarFacet()
Defines the Event class.
Definition: calendar.inc:43
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
if(count($sites) > 1) $calendarSelect
Definition: event_edit.inc:92