protected function initialize() { $config = $this->loadFeedData(); if (isset($config['contacts'])) { try { if (isset($config['contacts']['CONTROLLER_CLASS'])) { $modelClass = $config['contacts']['CONTROLLER_CLASS']; } else { $modelClass = isset($config['contacts']['MODEL_CLASS']) ? $config['contacts']['MODEL_CLASS'] : 'EmergencyContactsDataModel'; } $this->contactsController = EmergencyContactsDataModel::factory($modelClass, $config['contacts']); } catch (KurogoException $e) { $this->contactsController = DataController::factory($config['contacts']['CONTROLLER_CLASS'], $config['contacts']); } } if (isset($config['notice'])) { try { if (isset($config['notice']['CONTROLLER_CLASS'])) { $modelClass = $config['notice']['CONTROLLER_CLASS']; } else { $modelClass = isset($config['notice']['MODEL_CLASS']) ? $config['notice']['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; } $this->emergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $config['notice']); } catch (KurogoException $e) { $this->emergencyNoticeController = DataController::factory($config['notice']['CONTROLLER_CLASS'], $config['notice']); } } }
public function getAllControllers() { $controllers = array(); $config = $this->loadFeedData(); if (isset($config['contacts'])) { try { if (isset($config['contacts']['CONTROLLER_CLASS'])) { $modelClass = $config['contacts']['CONTROLLER_CLASS']; } else { $modelClass = isset($config['contacts']['MODEL_CLASS']) ? $config['contacts']['MODEL_CLASS'] : 'EmergencyContactsDataModel'; } $controllers[] = EmergencyContactsDataModel::factory($modelClass, $config['contacts']); } catch (KurogoException $e) { $controllers[] = DataController::factory($config['contacts']['CONTROLLER_CLASS'], $config['contacts']); } } if (isset($config['notice'])) { try { if (isset($config['notice']['CONTROLLER_CLASS'])) { $modelClass = $config['notice']['CONTROLLER_CLASS']; } else { $modelClass = isset($config['notice']['MODEL_CLASS']) ? $config['notice']['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; } $controllers[] = EmergencyNoticeDataModel::factory($modelClass, $config['notice']); } catch (KurogoException $e) { $controllers[] = DataController::factory($config['notice']['CONTROLLER_CLASS'], $config['notice']); } } return $controllers; }
private function getNoticeController() { $config = $this->loadFeedData(); if (isset($config['notice'])) { $modelClass = isset($config['notice']['MODEL_CLASS']) ? $config['notice']['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; return EmergencyNoticeDataModel::factory($modelClass, $config['notice']); } return null; }
protected function initializeForCommand() { switch ($this->command) { case 'notice': if ($noticeConfig = $this->getOptionalModuleSection('notice', 'feeds')) { $modelClass = isset($noticeConfig['MODEL_CLASS']) ? $noticeConfig['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; $emergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $noticeConfig); $emergencyNotice = $emergencyNoticeController->getFeaturedEmergencyNotice(); if (isset($emergencyNotice['text'])) { $emergencyNotice['text'] = Sanitizer::htmlStripTags2UTF8($emergencyNotice['text']); } if (isset($emergencyNotice['body'])) { $emergencyNotice['body'] = Sanitizer::htmlStripTags2UTF8($emergencyNotice['body']); } // if there is no emergency notice and a no-notice section // is set, use it as a feed if (!isset($emergencyNotice) && ($noEmergencyConfig = $this->getOptionalModuleSection('no-notice', 'feeds'))) { $modelClass = isset($noEmergencyConfig['MODEL_CLASS']) ? $noEmergencyConfig['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; if (!isset($noEmergencyConfig['NOTICE_EXPIRATION'])) { $noEmergencyConfig['NOTICE_EXPIRATION'] = 0; } $noEmergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $noEmergencyConfig); $emergencyNotice = $noEmergencyNoticeController->getFeaturedEmergencyNotice(); } else { if (!isset($emergencyNotice)) { // if there is not a no emergency feed, there may be a no emergency string if ($noEmergencyString = $this->getOptionalModuleVar('NO_EMERGENCY', null, 'strings')) { $emergencyNotice['text'] = $noEmergencyString; $emergencyNotice['unixtime'] = time(); } } } $noticeEnabled = true; } else { // Config section 'notice' not set, there is not notice $emergencyNotice = null; $noticeEnabled = false; } $response = array('notice' => $emergencyNotice, 'noticeEnabled' => $noticeEnabled); $this->setResponse($response); $this->setResponseVersion(2); break; case 'contacts': if ($contactsConfig = $this->getOptionalModuleSection('contacts', 'feeds')) { $modelClass = isset($contactsConfig['MODEL_CLASS']) ? $contactsConfig['MODEL_CLASS'] : 'EmergencyContactsDataModel'; $contactsController = EmergencyContactsDataModel::factory($modelClass, $contactsConfig); $response = array('primary' => self::formatContacts($contactsController->getPrimaryContacts()), 'secondary' => self::formatContacts($contactsController->getSecondaryContacts())); } else { $response = new stdClass(); } $this->setResponse($response); $this->setResponseVersion(2); break; } }
protected function initializeForCommand() { $config = $this->getConfig('feeds'); switch ($this->command) { case 'notice': if ($noticeConfig = $config->getOptionalSection('notice')) { try { if (isset($noticeConfig['CONTROLLER_CLASS'])) { $modelClass = $noticeConfig['CONTROLLER_CLASS']; } else { $modelClass = isset($noticeConfig['MODEL_CLASS']) ? $noticeConfig['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; } $emergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $noticeConfig); } catch (KurogoException $e) { $emergencyNoticeController = DataController::factory($noticeConfig['CONTROLLER_CLASS'], $noticeConfig); } $emergencyNotice = $emergencyNoticeController->getFeaturedEmergencyNotice(); $noticeEnabled = true; } else { // Config section 'notice' not set, there is not notice $emergencyNotice = null; $noticeEnabled = false; } $response = array('notice' => $emergencyNotice, 'noticeEnabled' => $noticeEnabled); $this->setResponse($response); $this->setResponseVersion(2); break; case 'contacts': if ($contactsConfig = $config->getOptionalSection('contacts')) { try { if (isset($contactsConfig['CONTROLLER_CLASS'])) { $modelClass = $contactsConfig['CONTROLLER_CLASS']; } else { $modelClass = isset($contactsConfig['MODEL_CLASS']) ? $contactsConfig['MODEL_CLASS'] : 'EmergencyContactsDataModel'; } $contactsController = EmergencyContactsDataModel::factory($modelClass, $contactsConfig); } catch (KurogoException $e) { $contactsController = DataController::factory($contactsConfig['CONTROLLER_CLASS'], $contactsConfig); } $response = array('primary' => self::formatContacts($contactsController->getPrimaryContacts()), 'secondary' => self::formatContacts($contactsController->getSecondaryContacts())); } else { $response = new stdClass(); } $this->setResponse($response); $this->setResponseVersion(2); break; } }
protected function initialize() { $config = $this->loadFeedData(); if (isset($config['contacts'])) { $modelClass = isset($config['contacts']['MODEL_CLASS']) ? $config['contacts']['MODEL_CLASS'] : 'EmergencyContactsDataModel'; $this->contactsController = EmergencyContactsDataModel::factory($modelClass, $config['contacts']); } if (isset($config['notice'])) { $modelClass = isset($config['notice']['MODEL_CLASS']) ? $config['notice']['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; $this->emergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $config['notice']); } if (isset($config['no-notice'])) { $modelClass = isset($config['no-notice']['MODEL_CLASS']) ? $config['no-notice']['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; if (!isset($config['no-notice']['NOTICE_EXPIRATION'])) { $config['no-notice']['NOTICE_EXPIRATION'] = 0; } $this->nonEmergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $config['no-notice']); } }