CMS  Version 3.9
CalendarHelper Class Reference

Public Member Functions

 CalendarHelper ()
 
 getHandler ($event)
 If the event DataItem class is Event and the instance has a composite class, then find the handler that renders that composite class. More...
 
 addHandler ($class, $handler)
 

Static Public Member Functions

static eventFilterSetup ()
 
static createCalendarFacet ()
 

Public Attributes

 $handlerMap = array()
 

Detailed Description

Definition at line 8 of file calendar_helper.inc.

Member Function Documentation

◆ addHandler()

CalendarHelper::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 67 of file calendar_helper.inc.

68  {
69  $this->handlerMap[$class] = $handler;
70  }
$handler
Definition: event_form.inc:62

◆ CalendarHelper()

CalendarHelper::CalendarHelper ( )

Definition at line 12 of file calendar_helper.inc.

13  {
14  ComponentManager::fireEvent("RegisterCalendarEventHandlers", $this);
15  }
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.

◆ createCalendarFacet()

static CalendarHelper::createCalendarFacet ( )
static

Definition at line 97 of file calendar_helper.inc.

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  }
Defines the Event class.
Definition: calendar.inc:43

◆ eventFilterSetup()

static CalendarHelper::eventFilterSetup ( )
static

Definition at line 72 of file calendar_helper.inc.

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  }
$filterForm
$calendars
Definition: calendars.inc:39
$dateRangeRenderer
Definition: email_logs.inc:14
$event
Definition: event_form.inc:46
Defines the Event class.
Definition: event.inc:43
if(count($sites) > 1) $calendarSelect
Definition: event_edit.inc:92

◆ getHandler()

CalendarHelper::getHandler (   $event)

If the event DataItem class is Event and the instance has a composite class, then find the handler that renders that composite class.

e.g., CompositeProgramEvent could be rendered by ProgramEventhandler

If the event class is not Event, then the map should link the data item class to the handler e.g., MyEventClass rendered by MyEventHandler

Parameters
obj$eventclass Event or any obj that can be rendered on the calendar
Returns
obj handler instance of StandardEventHandler or class inheriting from it or class EventHandler

Definition at line 31 of file calendar_helper.inc.

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  }

Member Data Documentation

◆ $handlerMap

CalendarHelper::$handlerMap = array()

Definition at line 10 of file calendar_helper.inc.


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