示例#1
0
 protected function getFeed($feed = null)
 {
     $feed = isset($this->feeds[$feed]) ? $feed : $this->getDefaultSection();
     $feedData = $this->feeds[$feed];
     $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : self::$defaultModel;
     $controller = DataModel::factory($modelClass, $feedData);
     return $controller;
 }
示例#2
0
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'notice':
             $response = null;
             $responseVersion = 1;
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $response = array('notice' => '', 'moduleID' => null, 'link' => $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice'));
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $response['moduleID'] = $moduleID;
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $response['notice'] = $controller->getHomeScreenAlert();
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         case 'modules':
             if ($setcontext = $this->getArg('setcontext')) {
                 Kurogo::sharedInstance()->setUserContext($setcontext);
             }
             $responseVersion = 2;
             $response = array('primary' => array(), 'secondary' => array(), 'customize' => $this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true), 'displayType' => $this->getOptionalModuleVar('display_type', 'springboard'));
             $allmodules = $this->getAllModules();
             $navModules = Kurogo::getSiteSections('navigation', Config::APPLY_CONTEXTS_NAVIGATION);
             foreach ($navModules as $moduleID => $moduleData) {
                 if ($module = Kurogo::arrayVal($allmodules, $moduleID)) {
                     $title = Kurogo::arrayVal($moduleData, 'title', $module->getModuleVar('title'));
                     $type = Kurogo::arrayVal($moduleData, 'type', 'primary');
                     $visible = Kurogo::arrayVal($moduleData, 'visible', 1);
                     $response[$type][] = array('tag' => $moduleID, 'title' => $title, 'visible' => (bool) $visible);
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         default:
             $this->invalidCommand();
     }
 }
示例#3
0
 protected function getFeed($feed)
 {
     if (!isset($this->feeds[$feed])) {
         throw new KurogoException(get_class($this) . ": Invalid Album id: {$feed}");
         return false;
     }
     $feedData = $this->feeds[$feed];
     $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : 'PhotosDataModel';
     $controller = DataModel::factory($modelClass, $feedData);
     return $controller;
 }
示例#4
0
 protected function getFeed($feed = null)
 {
     $feed = isset($this->feeds[$feed]) ? $feed : $this->getDefaultSection();
     $feedData = $this->feeds[$feed];
     $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : self::$defaultModel;
     $controller = DataModel::factory($modelClass, $feedData);
     $maxResultsOption = $this->pagetype == 'tablet' ? 'MAX_TABLET_RESULTS' : 'MAX_RESULTS';
     $maxPerPage = $this->getOptionalModuleVar($maxResultsOption, 20);
     $controller->setLimit($maxPerPage);
     return $controller;
 }
 protected function getNewsFeed($sport, $gender = null)
 {
     if ($sport == 'topnews') {
         $feedData = $this->getNavData('topnews');
     } elseif (isset($this->feeds[$sport])) {
         $feedData = $this->feeds[$sport];
     } else {
         throw new KurogoDataException($this->getLocalizedString('ERROR_INVALID_SPORT', $sport));
     }
     if (isset($feedData['DATA_RETRIEVER']) || isset($feedData['BASE_URL'])) {
         $dataModel = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : 'AthleticNewsDataModel';
         $newsFeed = DataModel::factory($dataModel, $feedData);
         return $newsFeed;
     }
     return null;
 }
示例#6
0
 public function initializeForCommand()
 {
     switch ($this->command) {
         case 'notice':
             $response = null;
             $responseVersion = 1;
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $response = array('notice' => '', 'moduleID' => null, 'link' => $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice'));
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $response['moduleID'] = $moduleID;
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $response['notice'] = $controller->getHomeScreenAlert();
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion($responseVersion);
             break;
         default:
             $this->invalidCommand();
     }
 }
示例#7
0
 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'help':
             break;
         case 'index':
             $this->setPageTitle($this->getOptionalModuleVar('pageTitle', Kurogo::getSiteString('SITE_NAME'), 'index', 'pages'));
             if ($this->pagetype == 'tablet') {
                 $modulePanes = $this->getTabletModulePanes();
                 $this->assign('modulePanes', $modulePanes);
                 $this->addInlineJavascript('var homePortlets = {};');
                 $this->addOnLoad('loadModulePages(' . json_encode($modulePanes) . ');');
                 $this->addOnOrientationChange('moduleHandleWindowResize();');
             } else {
                 $this->assign('modules', $this->getAllModuleNavigationData(self::EXCLUDE_HIDDEN_MODULES));
                 $this->assign('hideImages', $this->getOptionalModuleVar('HIDE_IMAGES', false));
             }
             if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                 $noticeData = $this->getOptionalModuleSection('notice');
                 if ($noticeData) {
                     $bannerNotice = null;
                     // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                     if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                         $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                         $controller = WebModule::factory($moduleID);
                         $string = "Module {$moduleID}";
                     } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                         $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                     } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                         $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                         $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                     } else {
                         throw new KurogoConfigurationException("Banner alert not properly configured");
                     }
                     if (!$controller instanceof HomeAlertInterface) {
                         throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                     }
                     $bannerNotice = $controller->getHomeScreenAlert();
                     if ($bannerNotice) {
                         $this->assign('bannerNotice', $bannerNotice);
                         // is this necessary?
                         $bannerModule = $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice');
                         if ($bannerModule) {
                             $this->assign('bannerURL', $this->buildURLForModule($moduleID, 'index'));
                         }
                     }
                 }
             }
             if ($this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 $this->assign('placeholder', $this->getLocalizedString("SEARCH_PLACEHOLDER", Kurogo::getSiteString('SITE_NAME')));
             }
             if ($this->getPlatform() == 'iphone' && $this->getOptionalModuleVar('ADD_TO_HOME', false)) {
                 $this->addInternalJavascript('/common/javascript/lib/add2homeConfig.js');
                 $this->addInternalJavascript('/common/javascript/lib/add2home.js');
                 $this->addInternalCSS('/common/css/add2home.css');
             }
             $this->assignUserContexts($this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true));
             $this->assign('SHOW_DOWNLOAD_TEXT', Kurogo::getOptionalSiteVar('downloadText', '', $this->platform, 'apps'));
             $homeModuleID = $this->getHomeModuleID();
             if ($iconSet = $this->getOptionalThemeVar('navigation_icon_set')) {
                 $iconSetSize = $this->getOptionalThemeVar('navigation_icon_size');
                 $downloadImgPrefix = "/common/images/iconsets/{$iconSet}/{$iconSetSize}/download";
             } else {
                 $downloadImgPrefix = "/modules/{$homeModuleID}/images/download";
             }
             $this->assign('downloadImgPrefix', $downloadImgPrefix);
             $this->assign('displayType', $this->getModuleVar('display_type'));
             break;
         case 'search':
             $searchTerms = $this->getArg('filter');
             $useAjax = $this->pagetype != 'basic';
             $searchModules = array();
             if ($this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 foreach ($this->getAllModuleNavigationData(self::EXCLUDE_HIDDEN_MODULES) as $type => $modules) {
                     foreach ($modules as $id => $info) {
                         if ($id == 'customize') {
                             continue;
                         }
                         $module = self::factory($id);
                         if ($module->getOptionalModuleVar('search', false, 'module')) {
                             $searchModule = array('id' => $id, 'elementId' => 'federatedSearchModule_' . $id, 'title' => $info['title']);
                             if ($useAjax) {
                                 $searchModule['ajaxURL'] = FULL_URL_PREFIX . ltrim($this->buildURL('searchResult', array('id' => $id, 'filter' => $searchTerms)), '/');
                             } else {
                                 $searchModule['results'] = $this->runFederatedSearchForModule($module, $searchTerms);
                             }
                             $searchModules[] = $searchModule;
                         }
                     }
                 }
                 if ($useAjax) {
                     $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
                     $this->addInlineJavascript('var federatedSearchModules = ' . json_encode($searchModules) . ";\n");
                     $this->addOnLoad('runFederatedSearch(federatedSearchModules);');
                 }
             }
             $this->assign('federatedSearchModules', $searchModules);
             $this->assign('searchTerms', $searchTerms);
             $this->setLogData($searchTerms);
             break;
         case 'modules':
             $configModule = $this->getArg('configModule', $this->configModule);
             $this->assign('modules', $this->getAllModuleNavigationData(self::EXCLUDE_HIDDEN_MODULES));
             $this->assign('hideImages', $this->getOptionalModuleVar('HIDE_IMAGES', false));
             $this->assign('displayType', $this->getModuleVar('display_type'));
             if ($configModule == $this->configModule && $this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 $this->assign('placeholder', $this->getLocalizedString("SEARCH_PLACEHOLDER", Kurogo::getSiteString('SITE_NAME')));
             }
             $this->assignUserContexts($this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true));
             break;
         case 'searchResult':
             $moduleID = $this->getArg('id');
             $searchTerms = $this->getArg('filter');
             $this->setLogData($searchTerms);
             $module = self::factory($moduleID);
             $this->assign('federatedSearchResults', $this->runFederatedSearchForModule($module, $searchTerms));
             break;
         case 'pane':
             // This wrapper exists so we can catch module errors and prevent redirection to the error page
             $moduleID = $this->getArg('id');
             try {
                 $module = self::factory($moduleID, 'pane', array(self::AJAX_PARAMETER => 1));
                 $content = $module->fetchPage();
             } catch (Exception $e) {
                 Kurogo::log(LOG_WARNING, $e->getMessage(), "home", $e->getTrace());
                 $content = '<p class="nonfocal">' . $this->getLocalizedString('ERROR_MODULE_PANE') . '</p>';
             }
             $this->assign('content', $content);
             break;
         case 'customize':
             $allowCustomize = $this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true);
             $this->assign('allowCustomize', $allowCustomize);
             if (!$allowCustomize) {
                 break;
             }
             $this->handleCustomizeRequest($this->args);
             $modules = $this->getModuleCustomizeList();
             $moduleIDs = array_keys($modules);
             switch ($this->pagetype) {
                 case 'compliant':
                 case 'tablet':
                     $this->addInlineJavascript('var MODULE_NAV_COOKIE = "' . self::MODULE_NAV_COOKIE . '";' . 'var MODULE_NAV_COOKIE_LIFESPAN = ' . Kurogo::getSiteVar('MODULE_NAV_COOKIE_LIFESPAN') . ';' . 'var COOKIE_PATH = "' . COOKIE_PATH . '";');
                     $this->addInlineJavascriptFooter('init();');
                     break;
                 case 'basic':
                     foreach ($moduleIDs as $index => $id) {
                         $modules[$id]['toggleVisibleURL'] = $this->buildBreadcrumbURL('index', array('action' => $modules[$id]['visible'] ? 'off' : 'on', 'module' => $id), false);
                         if ($index > 0) {
                             $modules[$id]['swapUpURL'] = $this->buildBreadcrumbURL('index', array('action' => 'swap', 'module1' => $id, 'module2' => $moduleIDs[$index - 1]), false);
                         }
                         if ($index < count($moduleIDs) - 1) {
                             $modules[$id]['swapDownURL'] = $this->buildBreadcrumbURL('index', array('action' => 'swap', 'module1' => $id, 'module2' => $moduleIDs[$index + 1]), false);
                         }
                     }
                     break;
                 default:
                     break;
             }
             // show user selectable context switching
             if ($contexts = Kurogo::sharedInstance()->getContexts()) {
                 $userContextList = $this->getUserContextListData('customizemodules', false);
                 $this->assign('customizeUserContextListDescription', $this->getLocalizedString('USER_CONTEXT_LIST_DESCRIPTION'));
                 if ($this->platform == 'iphone') {
                     $this->assign('customizeUserContextListDescriptionFooter', $this->getLocalizedString('USER_CONTEXT_LIST_DESCRIPTION_FOOTER_DRAG'));
                 } else {
                     $this->assign('customizeUserContextListDescriptionFooter', $this->getLocalizedString('USER_CONTEXT_LIST_DESCRIPTION_FOOTER'));
                 }
                 $this->assign('customizeUserContextList', $userContextList);
             } else {
                 $key = 'CUSTOMIZE_INSTRUCTIONS';
                 if ($this->pagetype == 'compliant' || $this->pagetype == 'tablet') {
                     $key = 'CUSTOMIZE_INSTRUCTIONS_' . strtoupper($this->pagetype);
                     if ($this->platform == 'iphone') {
                         $key .= '_DRAG';
                     }
                 }
                 $this->assign('customizeInstructions', $this->getLocalizedString($key));
             }
             $this->assign('modules', $modules);
             break;
         case 'customizemodules':
             $modules = $this->getModuleCustomizeList();
             $this->assign('modules', $modules);
             break;
     }
 }
示例#8
0
 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'help':
             break;
         case 'index':
             if ($this->pagetype == 'tablet') {
                 $modulePanes = $this->getTabletModulePanes($this->getModuleSection('tablet_panes'));
                 $this->assign('modulePanes', $modulePanes);
                 $this->addOnLoad('loadModulePages(' . json_encode($modulePanes) . ');');
                 $this->addOnOrientationChange('moduleHandleWindowResize();');
             } else {
                 $this->assign('modules', $this->getModuleNavlist());
                 $this->assign('hideImages', $this->getOptionalModuleVar('HIDE_IMAGES', false));
                 if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
                     $noticeData = $this->getOptionalModuleSection('notice');
                     if ($noticeData) {
                         $bannerNotice = null;
                         // notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
                         if (isset($noticeData['BANNER_ALERT_MODULE'])) {
                             $moduleID = $noticeData['BANNER_ALERT_MODULE'];
                             $controller = WebModule::factory($moduleID);
                             $string = "Module {$moduleID}";
                         } elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
                             $controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
                             $string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
                         } elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
                             $controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
                             $string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
                         } else {
                             throw new KurogoConfigurationException("Banner alert not properly configured");
                         }
                         if (!$controller instanceof HomeAlertInterface) {
                             throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
                         }
                         $bannerNotice = $controller->getHomeScreenAlert();
                         if ($bannerNotice) {
                             $this->assign('bannerNotice', $bannerNotice);
                             // is this necessary?
                             $bannerModule = $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice');
                             if ($bannerModule) {
                                 $this->assign('bannerURL', $this->buildURLForModule($moduleID, 'index'));
                             }
                         }
                     }
                 }
             }
             if ($this->getOptionalModuleVar('SHOW_FEDERATED_SEARCH', true)) {
                 $this->assign('showFederatedSearch', true);
                 $this->assign('placeholder', $this->getLocalizedString("SEARCH_PLACEHOLDER", Kurogo::getSiteString('SITE_NAME')));
             }
             if ($this->getPlatform() == 'iphone' && $this->getOptionalModuleVar('ADD_TO_HOME', false)) {
                 $this->addInternalJavascript('/common/javascript/lib/add2homeConfig.js');
                 $this->addInternalJavascript('/common/javascript/lib/add2home.js');
                 $this->addInternalCSS('/common/css/add2home.css');
             }
             $this->assign('SHOW_DOWNLOAD_TEXT', DownloadWebModule::appDownloadText($this->platform));
             $this->assign('displayType', $this->getModuleVar('display_type'));
             break;
         case 'search':
             $searchTerms = $this->getArg('filter');
             $useAjax = $this->pagetype != 'basic' && $this->pagetype != 'touch';
             $searchModules = array();
             foreach ($this->getAllModuleNavigationData(self::EXCLUDE_DISABLED_MODULES) as $type => $modules) {
                 foreach ($modules as $id => $info) {
                     $module = self::factory($id);
                     if ($module->getModuleVar('search')) {
                         $searchModule = array('id' => $id, 'elementId' => 'federatedSearchModule_' . $id, 'title' => $info['title']);
                         if ($useAjax) {
                             $searchModule['ajaxURL'] = FULL_URL_PREFIX . ltrim($this->buildURL('searchResult', array('id' => $id, 'filter' => $searchTerms)), '/');
                         } else {
                             $searchModule['results'] = $this->runFederatedSearchForModule($module, $searchTerms);
                         }
                         $searchModules[] = $searchModule;
                     }
                 }
             }
             if ($useAjax) {
                 $this->addInlineJavascript('var federatedSearchModules = ' . json_encode($searchModules) . ";\n");
                 $this->addOnLoad('runFederatedSearch(federatedSearchModules);');
             }
             $this->assign('federatedSearchModules', $searchModules);
             $this->assign('searchTerms', $searchTerms);
             $this->setLogData($searchTerms);
             break;
         case 'searchResult':
             $moduleID = $this->getArg('id');
             $searchTerms = $this->getArg('filter');
             $module = self::factory($moduleID);
             $this->assign('federatedSearchResults', $this->runFederatedSearchForModule($module, $searchTerms));
             break;
         case 'pane':
             // This wrapper exists so we can catch module errors and prevent redirection to the error page
             $moduleID = $this->getArg('id');
             try {
                 $module = self::factory($moduleID, 'pane', array('ajax' => 1));
                 $content = $module->fetchPage();
             } catch (Exception $e) {
                 Kurogo::log(LOG_WARNING, $e->getMessage(), "home", $e->getTrace());
                 $content = '<p class="nonfocal">' . $this->getLocalizedString('ERROR_MODULE_PANE') . '</p>';
             }
             $this->assign('content', $content);
             break;
     }
 }
示例#9
0
 protected function getNewsFeed($sport, $gender = null)
 {
     if ($sport == 'topnews') {
         $feedData = $this->getNavData('topnews');
     } else {
         $feedData = $this->getOptionalModuleSection($sport, 'feeds');
     }
     if (isset($feedData['DATA_RETRIEVER']) || isset($feedData['BASE_URL'])) {
         $dataModel = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : self::$defaultNewsModel;
         $newsFeed = DataModel::factory($dataModel, $feedData);
         return $newsFeed;
     }
     return null;
 }