/** * Contructor * @param type $controller * @param type $name */ function __construct($controller, $name) { //Administering calendars if (CalendarConfig::subpackage_enabled('calendars')) { //Configuration for calendar grid field $gridCalendarConfig = GridFieldConfig_RecordEditor::create(); $gridCalendarConfig->removeComponentsByType('GridFieldDataColumns'); $gridCalendarConfig->addComponent($dataColumns = new GridFieldDataColumns(), 'GridFieldEditButton'); $c = singleton('Calendar'); $summaryFields = $c->summaryFields(); //$summaryFields = array( // 'Title' => 'Title', // //'SubscriptionOptIn' => 'Opt In', // //'Shaded' => 'Shaded' //); $s = CalendarConfig::subpackage_settings('calendars'); //show shading info in the gridfield if ($s['shading']) { $summaryFields['Shaded'] = 'Shaded'; } $dataColumns->setDisplayFields($summaryFields); //settings for the case that colors are enabled if ($s['colors']) { $dataColumns->setFieldFormatting(array("Title" => '<div style=\\"height:20px;width:20px;display:inline-block;vertical-align:middle;margin-right:6px;background:$Color\\"></div> $Title')); } $GridFieldCalendars = new GridField('Calendars', '', PublicCalendar::get(), $gridCalendarConfig); $fields = new FieldList($GridFieldCalendars); $actions = new FieldList(); $this->addExtraClass('CalendarsForm'); parent::__construct($controller, $name, $fields, $actions); } }
/** * All public calendars */ function all() { $calendars = PublicCalendar::get(); $events = new ArrayList(); foreach ($calendars as $cal) { $events->merge($cal->Events()); } $eventsArr = $events->toNestedArray(); //Debug::dump($eventsArr); //return false; $ics = new ICSExport($eventsArr); return $this->output($ics, 'all'); }
/** * Shaded events controller * Shaded events for the calendar are called once on calendar initialization, * hence the offset of 3000 days */ public function shadedevents($request, $json = true, $calendars = null, $offset = 3000) { if (!$calendars) { $calendars = PublicCalendar::get(); } $calendars = $calendars->filter(array('shaded' => true)); return $this->publicevents($request, $json, $calendars, $offset); }
public function AllCalendars() { $calendars = PublicCalendar::get(); return $calendars; }
public function updateFrontEndFields(FieldList $fields) { $calendarDropdown = DropdownField::create('CalendarID', 'Calendar', PublicCalendar::get()->map('ID', 'Title'))->setEmptyString('Choose calendar...'); $fields->push($calendarDropdown); }
/** * @param $obj * @param $val * @param $record * @return DataObject */ public static function getCalendarByTitle(&$obj, $val, $record) { $c = PublicCalendar::get()->filter('Title', $val)->First(); if ($c && $c->exists()) { return $c; } else { $c = new PublicCalendar(); $c->Title = $val; $c->write(); return $c; } }