protected function initializeForCommand() { $config = $this->getConfig('feeds'); switch($this->command) { case 'notice': $noticeConfig = $config->getSection('notice'); $emergencyNoticeController = DataController::factory('EmergencyNoticeDataController', $noticeConfig); $emergencyNotice = $emergencyNoticeController->getLatestEmergencyNotice(); $response = array('notice' => $emergencyNotice); $this->setResponse($response); $this->setResponseVersion(1); break; case 'contacts': $contactsConfig = $config->getSection('contacts'); $contactsController = DataController::factory($contactsConfig['CONTROLLER_CLASS'], $contactsConfig); $response = array( 'primary' => self::formatContacts($contactsController->getPrimaryContacts()), 'secondary' => self::formatContacts($contactsController->getSecondaryContacts()), ); $this->setResponse($response); $this->setResponseVersion(1); break; } }
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; }
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']); } } }
protected function getContent($feedData) { $content_type = isset($feedData['CONTENT_TYPE']) ? $feedData['CONTENT_TYPE'] : ''; switch ($content_type) { case 'html': $content = isset($feedData['CONTENT_HTML']) ? $feedData['CONTENT_HTML'] : ''; return $content; break; case 'html_url': $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); if (isset($feedData['HTML_ID'])) { $content = $controller->getContentById($feedData['HTML_ID']); } else { $content = $controller->getContent(); } return $content; break; case 'rss': $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); if ($item = $controller->getItemByIndex(0)) { return $item->getContent(); } return ''; break; default: throw new Exception("Invalid content type $content_type"); } }
protected function getFeed($feed = null) { $feed = isset($this->feeds[$feed]) ? $feed : $this->getDefaultSection(); $feedData = $this->feeds[$feed]; $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); return $controller; }
public function items($start=0, $limit=null) { $this->setStandardFilters(); $this->addFilter('command', 'find_all_videos'); $this->addFilter('page_size', $limit); $this->addFilter('page_number', floor($start / $limit)); $items = parent::items(0, $limit); return $items; }
public function items($start=0, $limit=null) { $this->addFilter('max-results', $limit); $this->addFilter('start-index', $start+1); $items = parent::items(0, $limit); return $items; }
protected function init($args) { parent::init($args); if (isset($args['TAG']) && strlen($args['TAG'])) { $this->tag = $args['TAG']; } if (isset($args['AUTHOR']) && strlen($args['AUTHOR'])) { $this->author = $args['AUTHOR']; } }
protected function initialize() { $config = $this->loadFeedData(); if (isset($config['contacts'])) { $this->contactsController = DataController::factory($config['contacts']['CONTROLLER_CLASS'], $config['contacts']); } if (isset($config['notice'])) { $this->emergencyNoticeController = DataController::factory('EmergencyNoticeDataController', $config['notice']); } }
public function __construct() { parent::__construct(); $this->_dataController = DataController::getInstance(); $this->_scriptController = new ScriptController(); $this->_adminController = new AdminController(); $this->_loginController = new LoginController(); add_action('after_switch_theme', array($this, 'activate_theme')); add_action('switch_theme', array($this, 'deactivate_theme')); add_action('tgmpa_register', array($this, 'register_plugin_dependencies')); }
protected function init($args) { parent::init($args); if (isset($args['NOTICE_EXPIRATION'])) { $this->NOTICE_EXPIRATION = $args['NOTICE_EXPIRATION']; } else { $this->NOTICE_EXPIRATION = 7 * 24 * 60 * 60; // 1 week } if (isset($args['NOTICE_MAX_COUNT'])) { $this->NOTICE_MAX_COUNT = $args['NOTICE_MAX_COUNT']; } }
public function getFeed($index) { $feeds = $this->loadFeedData(); if(isset($feeds[$index])) { $feedData = $feeds[$index]; if (!isset($feedData['CONTROLLER_CLASS'])) { $feedData['CONTROLLER_CLASS'] = 'RSSDataController'; } $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); $controller->setDebugMode($this->getSiteVar('DATA_DEBUG')); return $controller; } else { throw new Exception("Error getting news feed for index $index"); } }
protected function getFeeds($type) { if (isset($this->feeds[$type])) { return $this->feeds[$type]; } $feeds = array(); switch ($type) { case 'static': $feeds = $this->loadFeedData(); break; case 'user': $sectionData = $this->getOptionalModuleSection('user_calendars'); $listController = isset($sectionData['CONTROLLER_CLASS']) ? $sectionData['CONTROLLER_CLASS'] : ''; if (strlen($listController)) { $sectionData = array_merge($sectionData, array('SESSION' => $this->getSession())); $controller = CalendarListController::factory($listController, $sectionData); $feeds = $controller->getUserCalendars(); } break; case 'resource': $sectionData = $this->getOptionalModuleSection('resources'); $listController = isset($sectionData['CONTROLLER_CLASS']) ? $sectionData['CONTROLLER_CLASS'] : ''; if (strlen($listController)) { $sectionData = array_merge($sectionData, array('SESSION' => $this->getSession())); $controller = CalendarListController::factory($listController, $sectionData); $feeds = $controller->getResources(); } break; case 'category': $sectionData = $this->getOptionalModuleSection('categories'); $controllerClass = isset($sectionData['CONTROLLER_CLASS']) ? $sectionData['CONTROLLER_CLASS'] : ''; if (strlen($controllerClass)) { $controller = DataController::factory($controllerClass, $sectionData); foreach ($controller->items() as $category) { $feeds[$category->getId()] = array('TITLE' => $category->getName(), 'CATEGORY' => $category->getId(), 'BASE_URL' => $sectionData['EVENT_BASE_URL'], 'CONTROLLER_CLASS' => $sectionData['EVENT_CONTROLLER_CLASS']); } } break; default: throw new KurogoConfigurationException($this->getLocalizedString('ERROR_INVALID_FEED', $type)); } if ($feeds) { foreach ($feeds as $id => &$feed) { $feed['type'] = $type; } $this->feeds[$type] = $feeds; } return $feeds; }
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 getContent($feedData) { $content_type = isset($feedData['CONTENT_TYPE']) ? $feedData['CONTENT_TYPE'] : ''; switch ($content_type) { case 'html': $content = isset($feedData['CONTENT_HTML']) ? $feedData['CONTENT_HTML'] : ''; if (is_array($content)) { $content = implode("\n", $content); } return $content; break; case 'html_url': if (!isset($feedData['CONTROLLER_CLASS'])) { $feedData['CONTROLLER_CLASS'] = 'HTMLDataController'; } $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); if (isset($feedData['HTML_ID']) && strlen($feedData['HTML_ID'])>0) { $content = $controller->getContentById($feedData['HTML_ID']); } elseif (isset($feedData['HTML_TAG']) && strlen($feedData['HTML_TAG'])>0) { $content = $controller->getContentByTag($feedData['HTML_TAG']); } else { $content = $controller->getContent(); } return $content; break; case 'rss': if (!isset($feedData['CONTROLLER_CLASS'])) { $feedData['CONTROLLER_CLASS'] = 'RSSDataController'; } $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); if ($item = $controller->getItemByIndex(0)) { return $item->getContent(); } return ''; break; default: throw new Exception("Invalid content type $content_type"); } }
public function getFeed($index) { $feeds = $this->loadFeedData(); if (isset($feeds[$index])) { $feedData = $feeds[$index]; try { if (isset($feedData['CONTROLLER_CLASS'])) { $modelClass = $feedData['CONTROLLER_CLASS']; } else { $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : self::$defaultModel; } $controller = NewsDataModel::factory($modelClass, $feedData); } catch (KurogoException $e) { $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); $this->legacyController = true; } return $controller; } else { throw new KurogoConfigurationException($this->getLocalizedString('ERROR_INVALID_FEED', $index)); } }
public function initializeForCommand() { $this->feeds = $this->loadFeedData(); switch ($this->command) { case 'sections': error_log(print_r(VideoModuleUtils::getSectionsFromFeeds($this->feeds), true)); $this->setResponse(VideoModuleUtils::getSectionsFromFeeds($this->feeds)); $this->setResponseVersion(1); break; case 'videos': case 'search': // videos commands requires one argument: section. // search requires two arguments: section and q (query). $section = $this->getArg('section'); $query = $this->getArg('q'); $feedData = $this->feeds[$section]; $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); $totalItems = $controller->getTotalItems(); $videos = array(); if ($this->command == 'search') { $items = $controller->search($query, 0, 20); } else { $items = $controller->items(0, 50); } foreach ($items as $video) { $videos[] = VideoAPIModule::cleanVideoArray((array)$video); } $this->setResponse($videos); $this->setResponseVersion(1); break; default: $this->invalidCommand(); break; } }
public function initializeForCommand() { if ($projection = $this->getArg('projection')) { $this->mapProjector = new MapProjector(); $this->mapProjector->setDstProj($projection); } switch ($this->command) { case 'index': $categories = array(); $groups = $this->getFeedGroups(); if ($groups) { foreach ($groups as $id => &$groupData) { if (isset($groupData['center'])) { $latlon = filterLatLon($groupData['center']); $groupData['lat'] = $latlon['lat']; $groupData['lon'] = $latlon['lon']; } $groupData['id'] = $id; $categories[] = $groupData; } $response = array('categories' => $categories); } else { $feeds = $this->loadFeedData(); foreach ($feeds as $id => $feedData) { $categories[] = array('title' => $feedData['TITLE'], 'subtitle' => $feedData['SUBTITLE'], 'id' => $id); } } $this->setResponse($response); $this->setResponseVersion(1); break; case 'category': $this->loadFeedData(); $categoryId = $this->getArg('category'); $groups = $this->getFeedGroups(); if (isset($groups[$categoryId])) { $this->feedGroup = $categoryId; $groupData = $this->loadFeedData(); $categories = array(); foreach ($groupData as $id => $feed) { if (!isset($feed['HIDDEN']) || !$feed['HIDDEN']) { $category = array('id' => $id, 'title' => $feed['TITLE']); if (isset($feed['SUBTITLE'])) { $category['subtitle'] = $feed['SUBTITLE']; } $categories[] = $category; } } $response = array('categories' => $categories); $this->setResponse($response); $this->setResponseVersion(1); } else { $dataController = $this->getDataModel(); if ($dataController) { //if ($categoryId) { // $category = $dataController->findCategory($categoryId); // $placemarks = $category->placemarks(); // $categories = $category->categories(); //} else { $placemarks = $dataController->placemarks(); $categories = $dataController->categories(); //} $response = array(); if ($placemarks) { $response['placemarks'] = array(); foreach ($placemarks as $placemark) { $response['placemarks'][] = $this->arrayFromPlacemark($placemark); } } if ($categories) { $response['categories'] = array(); foreach ($categories as $aCategory) { $response['categories'][] = $this->arrayFromCategory($aCategory); } } $this->setResponse($response); $this->setResponseVersion(1); } else { $error = new KurogoError("Could not find data source for requested category"); $this->throwError($error); } } break; case 'detail': $dataController = $this->getDataModel(); $placemarkId = $this->getArg('id', null); if ($dataController && $placemarkId !== null) { $placemarks = $dataController->selectPlacemark($placemarkId); $placemark = current($placemarks); $fields = $placemark->getFields(); $geometry = $placemark->getGeometry(); $response = array('id' => $placemarkId, 'title' => $placemark->getTitle(), 'subtitle' => $placemark->getSubtitle(), 'address' => $placemark->getAddress(), 'details' => $placemark->getFields()); if ($geometry) { $center = $geometry->getCenterCoordinate(); $response['lat'] = $center['lat']; $response['lon'] = $center['lon']; $response['geometryType'] = $this->getGeometryType($geometry); $response['geometry'] = $this->formatGeometry($geometry); } $this->setResponse($response); $this->setResponseVersion(1); } break; case 'search': $mapSearch = $this->getSearchClass($this->args); $lat = $this->getArg('lat', 0); $lon = $this->getArg('lon', 0); if ($lat || $lon) { // defaults values for proximity search $tolerance = 1000; $maxItems = 0; // check for settings in feedgroup config $configData = $this->getDataForGroup($this->feedGroup); if ($configData) { if (isset($configData['NEARBY_THRESHOLD'])) { $tolerance = $configData['NEARBY_THRESHOLD']; } if (isset($configData['NEARBY_ITEMS'])) { $maxItems = $configData['NEARBY_ITEMS']; } } // check for override settings in feeds $configData = $this->getCurrentFeed(); if (isset($configData['NEARBY_THRESHOLD'])) { $tolerance = $configData['NEARBY_THRESHOLD']; } if (isset($configData['NEARBY_ITEMS'])) { $maxItems = $configData['NEARBY_ITEMS']; } $searchResults = $mapSearch->searchByProximity(array('lat' => $lat, 'lon' => $lon), 1000, 10); } else { $searchTerms = $this->getArg('q'); if ($searchTerms) { $searchResults = $mapSearch->searchCampusMap($searchTerms); } } $places = array(); foreach ($searchResults as $result) { $places[] = $this->shortArrayFromPlacemark($result); } $response = array('total' => count($places), 'returned' => count($places), 'results' => $places); $this->setResponse($response); $this->setResponseVersion(1); break; // ajax calls // ajax calls case 'projectPoint': $lat = $this->getArg('lat', 0); $lon = $this->getArg('lon', 0); $fromProj = $this->getArg('from', GEOGRAPHIC_PROJECTION); $toProj = $this->getArg('to', GEOGRAPHIC_PROJECTION); $projector = new MapProjector(); $projector->setSrcProj($fromProj); $projector->setDstProj($toProj); $result = $projector->projectPoint(array('lat' => $lat, 'lon' => $lon)); $this->setResponse($result); $this->setResponseVersion(1); break; case 'sortGroupsByDistance': $lat = $this->getArg('lat', 0); $lon = $this->getArg('lon', 0); $categories = array(); $showDistances = $this->getOptionalModuleVar('SHOW_DISTANCES', true); if ($lat || $lon) { foreach ($this->getFeedGroups() as $id => $groupData) { $center = filterLatLon($groupData['center']); $distance = greatCircleDistance($lat, $lon, $center['lat'], $center['lon']); $category = array('title' => $groupData['title'], 'id' => $id); if ($showDistances && ($displayText = $this->displayTextFromMeters($distance))) { $category['distance'] = $displayText; } $categories[] = $category; $distances[] = $distance; } array_multisort($distances, SORT_ASC, $categories); } $this->setResponse($categories); $this->setResponseVersion(1); break; case 'staticImageURL': $params = array('STATIC_MAP_BASE_URL' => $this->getArg('baseURL'), 'STATIC_MAP_CLASS' => $this->getArg('mapClass')); $dc = Kurogo::deviceClassifier(); $mapDevice = new MapDevice($dc->getPagetype(), $dc->getPlatform()); $mapController = MapImageController::factory($params, $mapDevice); if (!$mapController->isStatic()) { $error = new KurogoError(0, "staticImageURL must be used with a StaticMapImageController subclass"); $this->throwError($error); } $currentQuery = $this->getArg('query'); $mapController->parseQuery($currentQuery); $overrides = $this->getArg('overrides'); $mapController->parseQuery($overrides); $zoomDir = $this->getArg('zoom'); if ($zoomDir == 1 || $zoomDir == 'in') { $level = $mapController->getLevelForZooming('in'); $mapController->setZoomLevel($level); } elseif ($zoomDir == -1 || $zoomDir == 'out') { $level = $mapController->getLevelForZooming('out'); $mapController->setZoomLevel($level); } $scrollDir = $this->getArg('scroll'); if ($scrollDir) { $center = $mapController->getCenterForPanning($scrollDir); $mapController->setCenter($center); } $url = $mapController->getImageURL(); $this->setResponse($url); $this->setResponseVersion(1); break; case 'geocode': // TODO: this is not fully implemented. do not use this API. includePackage('Maps', 'Geocoding'); $locationSearchTerms = $this->getArg('q'); $geocodingDataControllerClass = $this->getOptionalModuleVar('GEOCODING_DATA_CONTROLLER_CLASS'); $geocodingDataParserClass = $this->getOptionalModuleVar('GEOCODING_DATA_PARSER_CLASS'); $geocoding_base_url = $this->getOptionalModuleVar('GEOCODING_BASE_URL'); $arguments = array('BASE_URL' => $geocoding_base_url, 'CACHE_LIFETIME' => 86400, 'PARSER_CLASS' => $geocodingDataParserClass); $controller = DataController::factory($geocodingDataControllerClass, $arguments); $controller->addCustomFilters($locationSearchTerms); $response = $controller->getParsedData(); // checking for Geocoding service error if ($response['errorCode'] == 0) { unset($response['errorCode']); unset($response['errorMessage']); $this->setResponse($response); $this->setResponseVersion(1); } else { $kurogoError = new KurogoError($response['errorCode'], "Geocoding service Erroe", $response['errorMessage']); $this->setResponseError($kurogoError); $this->setResponseVersion(1); } break; default: $this->invalidCommand(); break; } }
protected function init($args) { parent::init($args); // static map support required; dynamic optional if (isset($args['STATIC_MAP_CLASS'])) $this->staticMapClass = $args['STATIC_MAP_CLASS']; else $this->staticMapClass = $this->DEFAULT_MAP_CLASS; // other optional fields if (isset($args['JS_MAP_CLASS'])) $this->dynamicMapClass = $args['JS_MAP_CLASS']; if (isset($args['STATIC_MAP_BASE_URL'])) $this->staticMapBaseURL = $args['STATIC_MAP_BASE_URL']; if (isset($args['DYNAMIC_MAP_BASE_URL'])) $this->dynamicMapBaseURL = $args['DYNAMIC_MAP_BASE_URL']; $this->searchable = isset($args['SEARCHABLE']) ? ($args['SEARCHABLE'] == 1) : false; if (isset($args['DEFAULT_ZOOM_LEVEL'])) $this->defaultZoomLevel = $args['DEFAULT_ZOOM_LEVEL']; }
public function annonceUne($url, $img) { $data = new DataController($url); $db = Atomik::get('db'); $this->title = $data->fetchTitle('h1', 1); $this->text = $data->fetchCalendarText(); $this->link = $data->fetchLink(); $funtionName = __FUNCTION__; $this->viewOutput = Atomik::render('blocs/leadArticle', array('title' => $this->title, 'text' => $this->text, 'link' => $this->link, 'img' => $img, 'section' => $funtionName)); echo $this->viewOutput; }
public function federatedSearch($searchTerms, $maxCount, &$results) { $section = key($this->feeds); if (!$section) return 0; $feedData = $this->feeds[$section]; if (!$feedData) return 0; $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); $items = $controller->search($searchTerms, 0, $maxCount); if ($items) { $results = array(); foreach ($items as $video) { $listItem = $this->getListItemForVideo($video, $section); unset($listItem['subtitle']); $results[] = $listItem; } return $controller->getTotalItems(); } else { return 0; } }
protected function getFeeds($type) { if (isset($this->feeds[$type])) { return $this->feeds[$type]; } $feeds = array(); switch ($type) { case 'static': $feeds = $this->loadFeedData(); break; case 'user': case 'resource': $section = $type == 'user' ? 'user_calendars' : 'resources'; $sectionData = $this->getOptionalModuleSection($section); $controller = false; if (isset($sectionData['MODEL_CLASS']) || isset($sectionData['RETRIEVER_CLASS']) || isset($sectionData['CONTROLLER_CLASS'])) { try { if (isset($sectionData['CONTROLLER_CLASS'])) { $modelClass = $sectionData['CONTROLLER_CLASS']; } else { $modelClass = isset($sectionData['MODEL_CLASS']) ? $sectionData['MODEL_CLASS'] : 'CalendarListModel'; } $controller = CalendarDataModel::factory($modelClass, $sectionData); } catch (KurogoException $e) { $controller = CalendarListController::factory($sectionData['CONTROLLER_CLASS'], $sectionData); } switch ($type) { case 'resource': $feeds = $controller->getResources(); break; case 'user': $feeds = $controller->getUserCalendars(); break; } } break; case 'category': $sectionData = $this->getOptionalModuleSection('categories'); $controllerClass = isset($sectionData['CONTROLLER_CLASS']) ? $sectionData['CONTROLLER_CLASS'] : ''; if (strlen($controllerClass)) { $controller = DataController::factory($controllerClass, $sectionData); foreach ($controller->items() as $category) { $feeds[$category->getId()] = array('TITLE' => $category->getName(), 'CATEGORY' => $category->getId(), 'BASE_URL' => $sectionData['EVENT_BASE_URL'], 'CONTROLLER_CLASS' => $sectionData['EVENT_CONTROLLER_CLASS']); } } break; default: throw new KurogoConfigurationException($this->getLocalizedString('ERROR_INVALID_FEED', $type)); } if ($feeds) { foreach ($feeds as $id => &$feed) { $feed['type'] = $type; } $this->feeds[$type] = $feeds; } return $feeds; }
protected function initializeForPage() { if ($this->pagetype=='basic') { $this->assign('showUnsupported', true); return; } if (count($this->feeds)==0) { throw new Exception("No video feeds configured"); } // Categories / Sections $section = $this->getArg('section'); if (!isset($this->feeds[$section])) { $section = key($this->feeds); } $feedData = $this->feeds[$section]; $this->assign('currentSection', $section); $this->assign('sections' , $this->getSections()); $this->assign('feedData' , $feedData); $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); switch ($this->page) { case 'search': case 'index': $maxPerPage = $this->getModuleVar('MAX_RESULTS', 10); $start = $this->getArg('start', 0); if ($this->page == 'search') { if ($filter = $this->getArg('filter')) { $searchTerms = trim($filter); $items = $controller->search($searchTerms, $start, $maxPerPage); $this->assign('searchTerms', $searchTerms); } else { $this->redirect('index', array('section'=>$section), false); } } else { $items = $controller->items($start, $maxPerPage); } $totalItems = $controller->getTotalItems(); $videos = array(); foreach ($items as $video) { $videos[] = $this->getListItemForVideo($video, $section); } $this->assign('videos', $videos); $this->assign('totalItems', $totalItems); $previousURL = null; $nextURL = null; if ($totalItems > $maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if (($totalItems - $start) > $maxPerPage) { $args['start'] = $start + $maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $hiddenArgs = array( 'section'=>$section ); $this->assign('start', $start); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('hiddenArgs', $hiddenArgs); $this->generateBookmarkLink(); break; case 'bookmarks': $videos_bkms = array(); foreach ($this->getBookmarks() as $aBookmark) { if ($aBookmark) { // prevent counting empty string $titles = $this->getTitleForBookmark($aBookmark); $subtitle = count($titles) > 1 ? $titles[1] : null; $videos_bkms[] = array( 'title' => $titles[0], 'subtitle' => $subtitle, 'url' => $this->detailURLForBookmark($aBookmark), ); } } $this->assign('videos', $videos_bkms); break; case 'detail': $videoid = $this->getArg('videoid'); if ($video = $controller->getItem($videoid)) { $this->setTemplatePage('detail-' . $video->getType()); $this->assign('videoTitle', $video->getTitle()); $this->assign('videoURL', $video->getURL()); $this->assign('videoid', $video->getID()); $this->assign('videoDescription', $video->getDescription()); $body = $video->getDescription() . "\n\n" . $video->getURL(); $this->assign('shareEmailURL', $this->buildMailToLink("", $video->getTitle(), $body)); $this->assign('videoURL', $video->getURL()); $this->assign('shareRemark', $video->getTitle()); // Bookmark $cookieParams = array( 'section' => $section, 'title' => $video->getTitle(), 'videoid' => $videoid ); $cookieID = http_build_query($cookieParams); $this->generateBookmarkOptions($cookieID); } else { $this->redirectTo('index', array('section'=>$section),false); } break; } }
protected function clearInternalCache() { $this->items = null; parent::clearInternalCache(); }
protected function initializeForPage() { // construct controllers $config = $this->loadFeedData(); if(isset($config['contacts'])) { $contactsController = DataController::factory($config['contacts']['CONTROLLER_CLASS'], $config['contacts']); } else { $contactsController = NULL; } if(isset($config['notice'])) { $emergencyNoticeController = DataController::factory('EmergencyNoticeDataController', $config['notice']); } else { $emergencyNoticeController = NULL; } switch($this->page) { case 'index': $contactNavListItems = array(); if($contactsController !== NULL) { foreach($contactsController->getPrimaryContacts() as $contact) { $contactNavListItems[] = self::contactNavListItem($contact); } if($contactsController->hasSecondaryContacts()) { $moduleStrings = $this->getModuleSection('strings'); $contactNavListItems[] = array( 'title' => $moduleStrings['MORE_CONTACTS'], 'url' => $this->buildBreadcrumbURL('contacts', array()), ); } $this->assign('contactNavListItems', $contactNavListItems); } $this->assign('hasContacts', (count($contactNavListItems) > 0)); $hasEmergencyFeed = ($emergencyNoticeController !== NULL); $this->assign('hasEmergencyFeed', $hasEmergencyFeed); if($hasEmergencyFeed) { $emergencyNotice = $emergencyNoticeController->getLatestEmergencyNotice(); if($emergencyNotice !== NULL) { $this->assign('emergencyFeedEmpty', FALSE); $this->assign('title', $emergencyNotice['title']); $this->assign('content', $emergencyNotice['text']); $this->assign('date', $emergencyNotice['date']); } else { $this->assign('emergencyFeedEmpty', TRUE); } } break; case 'contacts': $contactNavListItems = array(); foreach($contactsController->getAllContacts() as $contact) { $contactNavListItems[] = self::contactNavListItem($contact); } $this->assign('contactNavListItems', $contactNavListItems); break; } }
public function getFeed($index) { $feeds = $this->loadFeedData(); if (isset($feeds[$index])) { $feedData = $feeds[$index]; if (!isset($feedData['CONTROLLER_CLASS'])) { $feedData['CONTROLLER_CLASS'] = 'RSSDataController'; } $controller = DataController::factory($feedData['CONTROLLER_CLASS'], $feedData); return $controller; } else { throw new KurogoConfigurationException("Error getting news feed for index {$index}"); } }
public function items($start=0, $limit=null) { $this->setStandardFilters(); //$this->addFilter('service', 'media'); //$this->addFilter('action', 'list'); $this->addFilter('pager:pageSize', $limit); $this->addFilter('pager:pageIndex', floor($start / $limit)); $items = parent::items(0, $limit); return $items; }
<?php include __DIR__ . '/cors.php'; include __DIR__ . '/data.php'; $method = $_SERVER['REQUEST_METHOD']; $request = explode("/", substr(@$_SERVER['PATH_INFO'], 1)); switch ($method) { case 'POST': $data = file_get_contents('php://input'); $res = json_decode($data); DataController::sendMail($res, $res->sendTo); break; case 'GET': if (isset($request) && !empty($request) && $request[0] !== '') { $id = $request[0]; } else { DataController::getData(); } break; case 'DELETE': if (isset($request) && !empty($request)) { $id = $request[0]; } else { } break; default: print json_encode('developed by: Philip Cesar B. Garay'); break; } exit;
protected function clearInternalCache() { $this->calendar = null; parent::clearInternalCache(); }
protected function retrieveData($url) { if (strpos($url, '.kmz') !== false) { if (!class_exists('ZipArchive')) { throw new KurogoException("class ZipArchive (php-zip) not available"); } $tmpDir = Kurogo::tempDirectory(); if (!is_writable($tmpDir)) { throw new KurogoConfigurationException("Temporary directory {$tmpDir} not available"); } $tmpFile = $tmpDir . '/tmp.kmz'; copy($url, $tmpFile); $zip = new ZipArchive(); $zip->open($tmpFile); $contents = $zip->getFromIndex(0); unlink($tmpFile); return $contents; // this is false on failure, same as file_get_contents } return parent::retrieveData($url); }