当前位置: 首页>>代码示例>>PHP>>正文


PHP DataModel::factory方法代码示例

本文整理汇总了PHP中DataModel::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP DataModel::factory方法的具体用法?PHP DataModel::factory怎么用?PHP DataModel::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataModel的用法示例。


在下文中一共展示了DataModel::factory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFeed

 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;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:8,代码来源:PhotosShellModule.php

示例2: initializeForCommand

 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();
     }
 }
开发者ID:sponto,项目名称:msbm-mobile,代码行数:57,代码来源:HomeAPIModule.php

示例3: getFeed

 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;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:11,代码来源:PhotosAPIModule.php

示例4: getFeed

 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;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:11,代码来源:PhotosWebModule.php

示例5: getNewsFeed

 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;
 }
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:16,代码来源:AthleticsShellModule.php

示例6: initializeForCommand

 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();
     }
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:38,代码来源:HomeAPIModule.php

示例7: initializeForPage

 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);
//.........这里部分代码省略.........
开发者ID:sponto,项目名称:msbm-mobile,代码行数:101,代码来源:HomeWebModule.php

示例8: initializeForPage

 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>';
//.........这里部分代码省略.........
开发者ID:nncsang,项目名称:Kurogo,代码行数:101,代码来源:HomeWebModule.php

示例9: getNewsFeed

 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;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:14,代码来源:AthleticsAPIModule.php


注:本文中的DataModel::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。