public function FeaturedEventForm()
 {
     $fields = new FieldList();
     //main info
     $events = EventPage::get('EventPage', "EventCategory = 'OpenStack Days'")->sort('EventStartDate', 'DESC');
     $options = array();
     foreach ($events as $event) {
         $options[$event->ID] = $event->Title . ' - ' . $event->formatDateRange();
     }
     $fields->push(new DropdownField('EventID', 'Event', $options));
     $ImageField = new CustomUploadField('Picture', 'Image (Max size 2Mb - Suggested size 300x250px)');
     $ImageField->setCanAttachExisting(false);
     $ImageField->setAllowedMaxFileNumber(1);
     $ImageField->setAllowedFileCategories('image');
     $ImageField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $ImageField->setFolderName('news-images');
     $ImageField->setRecordClass('BetterImage');
     $ImageField->getUpload()->setReplaceFile(false);
     $ImageField->setOverwriteWarning(false);
     $sizeMB = 2;
     // 2 MB
     $size = $sizeMB * 1024 * 1024;
     // 2 MB in bytes
     $ImageField->getValidator()->setAllowedMaxFileSize($size);
     $ImageField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     $fields->push($ImageField);
     // Create action
     $actions = new FieldList();
     $actions->push(new FormAction('saveFeaturedEvent', 'Save'));
     return new Form($this->owner, 'FeaturedEventForm', $fields, $actions);
 }
 public function getRssForPurge($pulled_events)
 {
     $external_ids = array();
     foreach ($pulled_events as $event) {
         $external_ids[] = $event->ExternalSourceId;
     }
     $in_external_ids = implode(',', $external_ids);
     return EventPage::get()->where("ExternalSourceId IS NOT NULL AND ExternalSourceId NOT IN (" . $in_external_ids . ")")->toArray();
 }
예제 #3
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Features');
     $fields->insertBefore(DropdownField::create('State', 'State', $this->dbObject('State')->enumValues()), 'Intro');
     $fields->insertBefore(TextField::create('Tagline'), 'Intro');
     $fields->insertBefore(TextField::create('Contact'), 'Intro');
     $fields->insertBefore(LinkField::create('WebsiteID', 'Website'), 'Intro');
     $fields->insertBefore($image = UploadField::create('SmallImage', 'Small Image'), 'SplashImage');
     $image->setFolderName('Uploads/Small-Images');
     return $fields;
 }
예제 #4
0
 function PastEvents($num = 1)
 {
     return EventPage::get()->where("EventEndDate <= now()")->sort('EventStartDate')->limit($num);
 }
예제 #5
0
 public function getEvents($num = 4, $type, $filter = '')
 {
     $output = '';
     switch ($type) {
         case 'future_events':
             $events = $this->FutureEvents($num, $filter);
             break;
         case 'future_summits':
             $events = $this->FutureSummits($num);
             break;
         case 'past_summits':
             $events = $this->PastSummits($num);
             break;
     }
     if ($events) {
         foreach ($events as $key => $event) {
             $first = $key == 0;
             $data = array('IsEmpty' => 0, 'IsFirst' => $first);
             $output .= $event->renderWith('EventHolder_event', $data);
         }
     } else {
         $data = array('IsEmpty' => 1);
         $event = new EventPage();
         $output .= $event->renderWith('EventHolder_event', $data);
     }
     return $output;
 }
예제 #6
0
 public function getSummitEvent()
 {
     return EventPage::get()->where("IsSummit = 1 AND EventStartDate > NOW()")->sort('EventStartDate')->first();
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldToTab('Root.RelatedPage', DropdownField::create('EventPageID', 'EventPage', EventPage::get()->map('ID', 'Title'))->setEmptyString('Choose event page...'));
 }
예제 #8
0
 function saveRssEvents($events_array)
 {
     foreach ($events_array as $event) {
         $filter_array = array();
         $filter_array["EventEndDate"] = $event->EventEndDate;
         $filter_array["ExternalSourceId"] = $event->ExternalSourceId;
         $count = EventPage::get()->filter($filter_array)->Count();
         $event_repository = $this->event_repository;
         if ($count == 0) {
             $this->tx_manager->transaction(function () use($event_repository, $event) {
                 $event_repository->add($event);
             });
         }
     }
 }
예제 #9
0
 function getFeaturedEvent()
 {
     return EventPage::get()->filter(array('Featured' => 1))->sort('EventStartDate', 'ASC')->limit(1);
 }
 function EventsYearlyCountText()
 {
     $this_year = date('Y');
     $event_count = EventPage::get()->where("YEAR(EventStartDate) = '" . $this_year . "' AND EventPage.EventCategory = 'Openstack Days'")->sort(array('EventStartDate' => 'ASC', 'EventContinent' => 'ASC'))->count();
     return "There are more than <strong>" . $event_count . " OpenStack Days</strong> scheduled for " . $this_year;
 }
예제 #11
0
 public function Events($direction = 'ASC')
 {
     $children = EventPage::get('EventPage', "\"ParentID\" = {$this->ID} AND \"ShowInMenus\" = 1", "\"StartDate\" {$direction}");
     return $children;
 }
 public function countAllPosted()
 {
     return EventPage::get()->where("EventEndDate >= now()")->sort('EventStartDate', 'ASC')->count();
 }