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


PHP WebModule::factory方法代码示例

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


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

示例1: 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

示例2: getCreditsHTML

 protected function getCreditsHTML()
 {
     //get original device
     $device = Kurogo::deviceClassifier()->getDevice();
     //set browser to unknown so we don't get AppQ HTML
     Kurogo::deviceClassifier()->setBrowser('unknown');
     $module = WebModule::factory($this->configModule, 'credits_html');
     $html = $module->fetchPage();
     //restore device
     Kurogo::deviceClassifier()->setDevice($device);
     return $html;
 }
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:12,代码来源:AboutAPIModule.php

示例3: 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

示例4: searchItems

 public static function searchItems($moduleID, $searchTerms, $limit = null, $options = null)
 {
     $module = WebModule::factory($moduleID);
     return $module->searchItems($searchTerms, $limit, $options);
 }
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:5,代码来源:Kurogo.php

示例5: implode

          $parts[0] = $url_redirects[$id];
          $url = URL_PREFIX . implode("/", $parts);
        }
        header("Location: " . $url);
        exit;
      }
    }
    
    // find the page part
    if (isset($parts[1])) {
      if (strlen($parts[1])) {
        $page = basename($parts[1], '.php');
      }
      
    } else {
      // redirect with trailing slash for completeness
      header("Location: ./$id/");
      exit;
    }

    if ($module = WebModule::factory($id, $page, $args)) {
        /* log this page view */
        PageViews::increment($id, Kurogo::deviceClassifier()->getPlatform());
        
        $module->displayPage();
    } else {
        throw new Exception("Module $id cannot be loaded");
    }
}
exit;
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:30,代码来源:index.php

示例6: initializeForCommand

 public function initializeForCommand()
 {
     $this->requiresAdmin();
     switch ($this->command) {
         case 'checkversion':
             $current = Kurogo::sharedInstance()->checkCurrentVersion();
             Kurogo::log(LOG_INFO, sprintf("Checking version. This site: %s Current Kurogo Version: %s", $current, KUROGO_VERSION), 'admin');
             $uptodate = version_compare(KUROGO_VERSION, $current, ">=");
             $messageKey = $uptodate ? 'KUROGO_VERSION_MESSAGE_UPTODATE' : 'KUROGO_VERSION_MESSAGE_NOTUPDATED';
             $data = array('current' => $current, 'local' => KUROGO_VERSION, 'uptodate' => $uptodate, 'message' => $this->getLocalizedString($messageKey, $current, KUROGO_VERSION));
             $this->setResponse($data);
             $this->setResponseVersion(1);
             break;
         case 'getlocalizedstring':
             $key = $this->getArg('key');
             $data = array();
             if (is_array($key)) {
                 foreach ($key as $k) {
                     $data[$k] = $this->getLocalizedString($k);
                 }
             } else {
                 $data[$key] = $this->getLocalizedString($key);
             }
             $this->setResponse($data);
             $this->setResponseVersion(1);
             break;
         case 'clearcaches':
             Kurogo::log(LOG_NOTICE, "Clearing Site Caches", 'admin');
             $result = Kurogo::sharedInstance()->clearCaches();
             if ($result === 0) {
                 $this->setResponse(true);
                 $this->setResponseVersion(1);
             } else {
                 $this->throwError(new KurogoError(1, "Error clearing caches", "There was an error ({$result}) clearing the caches"));
             }
             break;
         case 'upload':
             $type = $this->getArg('type');
             $section = $this->getArg('section', '');
             $subsection = null;
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $type = $module;
                     break;
                 case 'site':
                     break;
                 default:
                     throw new KurogoConfigurationException("Invalid type {$type}");
             }
             if (count($_FILES) == 0) {
                 throw new KurogoException("No files uploaded");
             }
             foreach ($_FILES as $key => $uploadData) {
                 $this->uploadFile($type, $section, $subsection, $key, $uploadData);
             }
             $this->setResponseVersion(1);
             $this->setResponse(true);
             break;
         case 'getconfigsections':
             $type = $this->getArg('type');
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $sections = $module->getModuleAdminSections();
                     break;
                 case 'site':
                     throw new KurogoConfigurationException("getconfigsections for site not handled yet");
             }
             $this->setResponse($sections);
             $this->setResponseVersion(1);
             break;
         case 'getconfigdata':
             $type = $this->getArg('type');
             $section = $this->getArg('section', '');
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $adminData = $this->getAdminData($module, $section);
                     break;
                 case 'site':
                     $adminData = $this->getAdminData('site', $section);
                     break;
             }
             $this->setResponse($adminData);
             $this->setResponseVersion(1);
             break;
         case 'setconfigdata':
             $type = $this->getArg('type');
             $data = $this->getArg('data', array());
             $section = $this->getArg('section', '');
             $subsection = null;
             if (empty($data)) {
                 $data = array();
             } elseif (!is_array($data)) {
                 throw new KurogoConfigurationException("Invalid data for {$type} {$section}");
             }
//.........这里部分代码省略.........
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:AdminAPIModule.php

示例7: initializeForPage

 protected function initializeForPage()
 {
     //make sure that only desktop/tablet devices can use the module
     $deviceClassifier = Kurogo::deviceClassifier();
     if ($this->page != 'index' && !($deviceClassifier->isComputer() || $deviceClassifier->isTablet())) {
         $this->redirectTo('index');
     }
     $navSections = $this->getNavSections();
     $section = '';
     $this->assign('navSections', $navSections);
     $this->addJQuery();
     $this->addJQueryUI();
     switch ($this->page) {
         case 'modules':
             $subNavSections = $this->getSubNavSections($this->page);
             $this->assign('subNavSections', $subNavSections);
             $defaultSubNavSection = key($subNavSections);
             $section = $this->getArg('section', $defaultSubNavSection);
             $moduleID = $this->getArg('module');
             if ($moduleID) {
                 $this->setTemplatePage('module');
                 try {
                     if ($module = WebModule::factory($moduleID)) {
                         $this->assign('moduleName', $module->getModuleName());
                         $this->assign('moduleID', $module->getConfigModule());
                         $this->assign('moduleIcon', $module->getOptionalModuleVar('icon', $module->getConfigModule(), 'module'));
                         $section = $moduleID;
                         $moduleSection = $this->getArg('section', 'general');
                         $this->assign('moduleSection', $moduleSection);
                     }
                 } catch (KurogoException $e) {
                     $this->redirectTo($this->page, array());
                 }
             } elseif ($section == $defaultSubNavSection) {
                 $moduleClasses = WebModule::getAllModuleClasses();
                 $this->assign('moduleClasses', $moduleClasses);
                 $this->setTemplatePage($section);
             } elseif ($section == 'homescreen') {
                 $this->setTemplatePage($section);
                 $modules = $this->getModules();
                 $this->assign('modules', $modules);
             } else {
                 $this->redirectTo($this->page, array());
             }
             break;
         case 'site':
             $subNavSections = $this->getSubNavSections($this->page);
             $this->assign('subNavSections', $subNavSections);
             $defaultSubNavSection = key($subNavSections);
             $section = $this->getArg('section', $defaultSubNavSection);
             if (!isset($subNavSections[$section])) {
                 $this->redirectTo($this->page, array());
             }
             break;
         case 'credits':
             $section = $this->getArg('section', 'credits');
             $subNavSections = array('credits' => array('id' => 'credits', 'title' => $this->getLocalizedString("ADMIN_CREDITS_CREDITS_TITLE"), 'url' => $this->buildURL($this->page, array('section' => 'credits'))), 'license' => array('id' => 'license', 'title' => $this->getLocalizedString("ADMIN_CREDITS_LICENSE_TITLE"), 'url' => $this->buildURL($this->page, array('section' => 'license'))));
             $this->assign('subNavSections', $subNavSections);
             if (isset($subNavSections[$section])) {
                 switch ($section) {
                     case 'license':
                         $licenseFile = ROOT_DIR . "/LICENSE";
                         if (is_file($licenseFile)) {
                             $this->assign('license', file_get_contents($licenseFile));
                         } else {
                             die($licenseFile);
                             throw new KurogoException("Unable to load LICENSE file, you may have a compromised Kurogo Installation");
                         }
                 }
                 $this->setTemplatePage($section);
             } else {
                 $this->redirectTo('section', array());
             }
             break;
         case 'index':
             //redirect desktop devices to the "default page"
             $deviceClassifier = Kurogo::deviceClassifier();
             if ($deviceClassifier->isComputer() || $deviceClassifier->isTablet()) {
                 $defaultSection = current($navSections);
                 $this->redirectTo($defaultSection['id'], array());
             }
             break;
         default:
             $this->redirectTo('index', array());
             break;
     }
     $this->assign('section', $section);
 }
开发者ID:sponto,项目名称:msbm-mobile,代码行数:88,代码来源:AdminWebModule.php

示例8: getAllModuleNavigationData

 protected function getAllModuleNavigationData($includeDisabled = self::INCLUDE_DISABLED_MODULES)
 {
     $moduleConfig = $this->getModuleNavigationIDs($includeDisabled);
     $homeModuleID = $this->getHomeModuleID();
     $modules = array('home' => array(), 'primary' => array(), 'secondary' => array());
     $disabledIDs = $this->getUserDisabledModuleIDs();
     foreach ($moduleConfig as $type => $modulesOfType) {
         foreach ($modulesOfType as $moduleID => $title) {
             $shortTitle = $title;
             $moduleConfig = ModuleConfigFile::factory($moduleID, 'module', ModuleConfigFile::OPTION_DO_NOT_CREATE);
             if ($moduleConfig) {
                 $shortTitle = $moduleConfig->getOptionalVar('shortTitle', $title);
             }
             $selected = $this->configModule == $moduleID;
             $primary = $type == 'primary';
             $classes = array();
             if ($selected) {
                 $classes[] = 'selected';
             }
             if (!$primary) {
                 $classes[] = 'utility';
             }
             $imgSuffix = $this->pagetype == 'tablet' && $selected ? '-selected' : '';
             //this is fixed for now
             $modulesThatCannotBeDisabled = array('customize');
             $moduleNavData = array('type' => $type, 'selected' => $selected, 'title' => $title, 'shortTitle' => $shortTitle, 'url' => "/{$moduleID}/", 'disableable' => !in_array($moduleID, $modulesThatCannotBeDisabled), 'disabled' => $includeDisabled && in_array($moduleID, $disabledIDs), 'img' => "/modules/{$homeModuleID}/images/{$moduleID}{$imgSuffix}" . $this->imageExt, 'class' => implode(' ', $classes));
             if (Kurogo::getOptionalSiteVar('DYNAMIC_MODULE_NAV_DATA', false)) {
                 $module = WebModule::factory($moduleID, false, array(), false);
                 // do not initialize
                 if ($moduleNavData = $module->getModuleNavigationData($moduleNavData)) {
                     $modules[$moduleNavData['type']][$moduleID] = $moduleNavData;
                 }
             } else {
                 $modules[$type][$moduleID] = $moduleNavData;
             }
         }
     }
     $modules = $this->getUserSortedModules($modules);
     //error_log('$modules(): '.print_r(array_keys($modules), true));
     return $modules;
 }
开发者ID:rolandinsh,项目名称:Kurogo-Mobile-Web,代码行数:41,代码来源:WebModule.php

示例9: initializeForPage

    protected function initializeForPage() {
        //make sure that only desktop devices can use the module
        if (!Kurogo::deviceClassifier()->isComputer() && $this->page !='index') {
            $this->redirectTo('index');
        }

        $navSections = $this->getNavSections();
        $section = '';
        $this->assign('navSections', $navSections);
        $this->addJQuery();
        $this->addJQueryUI();

        switch ($this->page)
        {
            case 'modules':
                $subNavSections = $this->getSubNavSections($this->page);
                $this->assign('subNavSections', $subNavSections);
        
                $defaultSubNavSection = key($subNavSections);
                $section = $this->getArg('section', $defaultSubNavSection);
                $moduleID = $this->getArg('module');
                
                if ($moduleID) {
                    $this->setTemplatePage('module');
                    try {
                        if ($module = WebModule::factory($moduleID)) {
                            $this->assign('moduleName', $module->getModuleName());
                            $this->assign('moduleID', $module->getConfigModule());
                            $section = $moduleID;
                            $moduleSection = $this->getArg('section','general');
                            $this->assign('moduleSection',$moduleSection);
                        }
                    } catch (Exception $e) {
                        $this->redirectTo($this->page, array());
                    }
                
                } elseif ($section == $defaultSubNavSection) {
                    $this->setTemplatePage($section);
                } elseif ($section == 'homescreen') {
                    $this->setTemplatePage($section);
                    
                    $homeModule = WebModule::factory('home');
                    $modules = $this->getModules();
                    $this->assign('modules', $modules);                    
                    
                } else {
                    $this->redirectTo($this->page, array());
                }
                                
                break;
            case 'site':            
        
                $subNavSections = $this->getSubNavSections($this->page);
                $this->assign('subNavSections', $subNavSections);
        
                $defaultSubNavSection = key($subNavSections);
                $section = $this->getArg('section', $defaultSubNavSection);
                
                if (!isset($subNavSections[$section])) {
                    $this->redirectTo($this->page, array());
                }
                break;
            case 'credits':
                
                $section = $this->getArg('section', 'credits');
                $subNavSections =  array(
                    'credits'=>array(
                        'id'=>'credits',
                        'title'=>'Credits',
                        'url'=>$this->buildURL($this->page, array('section'=>'credits'))
                    ),
                    'license'=>array(
                        'id'=>'license',
                        'title'=>'License',
                        'url'=>$this->buildURL($this->page, array('section'=>'license'))
                    )
                );
                $this->assign('subNavSections', $subNavSections);
                
                if (isset($subNavSections[$section])) {
                    $this->setTemplatePage($section);
                } else {
                    $this->redirectTo('section', array());
                }
                break;
                
            case 'index':
                //redirect desktop devices to the "default page"
                if (Kurogo::deviceClassifier()->isComputer()) {
                    $defaultSection = current($navSections);
                    $this->redirectTo($defaultSection['id'], array());
                }
                break;
            default:
                $this->redirectTo('index', array());
                break;
  
        }  

        $this->assign('section', $section);
//.........这里部分代码省略.........
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:AdminWebModule.php

示例10: 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

示例11: getAllModuleNavigationData

 protected function getAllModuleNavigationData($includeHidden = self::INCLUDE_HIDDEN_MODULES, $iconSetType = 'navigation')
 {
     $modules = $moduleNavData = array('primary' => array(), 'secondary' => array());
     $navModules = Kurogo::getSiteSections('navigation', Config::APPLY_CONTEXTS_NAVIGATION);
     foreach ($navModules as $moduleID => $moduleData) {
         $type = Kurogo::arrayVal($moduleData, 'type', 'primary');
         $moduleNavData[$type][$moduleID] = $moduleData;
     }
     if ($iconSet = $this->getOptionalThemeVar($iconSetType . '_icon_set')) {
         $iconSetSize = $this->getOptionalThemeVar($iconSetType . '_icon_size');
         $imgPrefix = "/common/images/iconsets/{$iconSet}/{$iconSetSize}/";
     } else {
         $homeModuleID = $this->getHomeModuleID();
         $imgPrefix = "/modules/{$homeModuleID}/images/";
     }
     //this is fixed for now
     $modulesThatCannotBeHidden = array('customize');
     $allModuleData = array();
     $userNavData = $this->getUserNavData();
     foreach ($moduleNavData as $type => $modulesOfType) {
         foreach ($modulesOfType as $moduleID => $navData) {
             $icon = $moduleID;
             $selected = $this->configModule == $moduleID;
             $primary = $type == 'primary';
             $classes = array();
             if ($selected) {
                 $classes[] = 'selected';
             }
             if (!$primary) {
                 $classes[] = 'utility';
             }
             $hidable = !in_array($moduleID, $modulesThatCannotBeHidden);
             $imgSuffix = $this->pagetype == 'tablet' && $selected ? '' : '';
             $linkTarget = Kurogo::arrayVal($navData, 'linkTarget');
             // customize is implemented as a page on the home module
             if ($moduleID == 'customize') {
                 $visible = true;
                 $icon = $moduleID;
                 $moduleData = array('type' => $type, 'selected' => $selected, 'title' => $this->getLocalizedString('CUSTOMIZE_TITLE'), 'shortTitle' => $this->getLocalizedString('CUSTOMIZE_SHORT_TITLE'), 'url' => "/" . $this->getHomeModuleID() . "/customize", 'hideable' => $hidable, 'visible' => true, 'img' => $imgPrefix . "{$icon}{$imgSuffix}" . $this->imageExt, 'class' => implode(' ', $classes), 'linkTarget' => $linkTarget);
             } else {
                 //this will throw an exception if a module is not available, so watch out
                 $moduleConfig = Kurogo::getModuleConfig('module', $moduleID);
                 $title = Kurogo::arrayVal($navData, 'title', $moduleConfig->getVar('title'));
                 $shortTitle = Kurogo::arrayVal($navData, 'shortTitle', $title);
                 $icon = $moduleConfig->getOptionalVar('icon', $moduleID);
                 $visible = Kurogo::arrayVal($userNavData, $moduleID, Kurogo::arrayVal($navData, 'visible', 1));
                 $moduleData = array('type' => $type, 'selected' => $selected, 'title' => $title, 'shortTitle' => $shortTitle, 'url' => "/{$moduleID}/", 'hideable' => $hidable, 'visible' => $visible, 'img' => $imgPrefix . "{$icon}{$imgSuffix}" . $this->imageExt, 'class' => implode(' ', $classes), 'linkTarget' => $linkTarget);
                 if (Kurogo::getOptionalSiteVar('DYNAMIC_MODULE_NAV_DATA', false)) {
                     $module = WebModule::factory($moduleID, false, array(), false);
                     // do not initialize
                     $moduleData = $module->getModuleNavigationData($moduleData);
                 }
             }
             if ($visible || $includeHidden || $type == 'primary' && isset($userNavData['visible'])) {
                 $modules[$type][$moduleID] = $moduleData;
             }
         }
     }
     if (isset($userNavData['visible'])) {
         $userModuleNavData = array();
         foreach ($userNavData['visible'] as $moduleID => $visible) {
             if (isset($modules['primary'][$moduleID])) {
                 if ($visible || $includeHidden) {
                     $userModuleNavData[$moduleID] = $modules['primary'][$moduleID];
                     $userModuleNavData[$moduleID]['visible'] = $visible;
                 }
             }
         }
         // make sure all primary modules are defined in userNavData
         // this ensures that new modules show up if a user has customized their layout
         $userModules = array_keys($userNavData['visible']);
         $navModules = array_keys($modules['primary']);
         if ($diff = array_diff($navModules, $userModules)) {
             foreach ($diff as $moduleID) {
                 $userModuleNavData[$moduleID] = $modules['primary'][$moduleID];
             }
         }
         $modules['primary'] = $userModuleNavData;
     }
     return $modules;
 }
开发者ID:sponto,项目名称:msbm-mobile,代码行数:81,代码来源:WebModule.php

示例12: getAllModules

 protected function getAllModules() {
   $dirs = array(MODULES_DIR, SITE_MODULES_DIR);
   $modules = array();
   foreach ($dirs as $dir) {
       if (is_dir($dir)) {
           $d = dir($dir);
           while (false !== ($entry = $d->read())) {
               if ($entry[0]!='.' && is_dir(sprintf("%s/%s", $dir, $entry))) {
                  $module = WebModule::factory($entry);
                  $modules[$entry] = $module;
               }
           }
           $d->close();
       }
   }
   ksort($modules);    
   return $modules;        
 }
开发者ID:nicosiseng,项目名称:Kurogo-Mobile-Web,代码行数:18,代码来源:WebModule.php

示例13: 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

示例14: getCreditsHTML

 protected function getCreditsHTML()
 {
     $module = WebModule::factory($this->configModule, 'credits_html');
     return $module->fetchPage();
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:5,代码来源:AboutAPIModule.php

示例15: initializeForCommand

    public function initializeForCommand() {  
        $this->requiresAdmin();
        
        switch ($this->command) {
            case 'checkversion':
                $data = array(
                    'current'=>Kurogo::sharedInstance()->checkCurrentVersion(),
                    'local'  =>KUROGO_VERSION
                );
                $this->setResponse($data);
                $this->setResponseVersion(1);
                
                break;
            
            case 'clearcaches':

                $result = Kurogo::sharedInstance()->clearCaches();
                if ($result===0) {
                    $this->setResponse(true);
                    $this->setResponseVersion(1);
                } else {
                    $this->throwError(KurogoError(1, "Error clearing caches", "There was an error ($result) clearing the caches"));
                }
                break;
                
            case 'getconfigsections':
                $type = $this->getArg('type');
                switch ($type) 
                {
                    case 'module':
                        $moduleID = $this->getArg('module','');
                        try {
                            $module = WebModule::factory($moduleID);
                        } catch (Exception $e) {
                            throw new Exception('Module ' . $moduleID . ' not found');
                        }
        
                        $sections = $module->getModuleAdminSections();
                        break;
                    case 'site':
                        throw new Exception("getconfigsections for site not handled yet");
                }
                
                $this->setResponse($sections);
                $this->setResponseVersion(1);
                break;
                
            case 'getconfigdata':
                $type = $this->getArg('type');
                $section = $this->getArg('section','');
                
                switch ($type) 
                {
                    case 'module':
                        $moduleID = $this->getArg('module','');
                        try {
                            $module = WebModule::factory($moduleID);
                        } catch (Exception $e) {
                            throw new Exception('Module ' . $moduleID . ' not found');
                        }
        
                        $adminData = $this->getAdminData($module, $section);
                        break;
                    case 'site':
                        $adminData = $this->getAdminData('site', $section);
                        break;
                }
                
                $this->setResponse($adminData);
                $this->setResponseVersion(1);
                break;
                
            case 'setconfigdata':
                $type = $this->getArg('type');
                $data = $this->getArg('data', array());
                $section = $this->getArg('section','');
                $subsection = null;
                if (empty($data)) {
                    $data = array();
                } elseif (!is_array($data)) {
                    throw new Exception("Invalid data for $type $section");
                }
                
                switch ($type)
                {
                    case 'module':
                    
                        if ($section == 'overview') {
                            foreach ($data as $moduleID=>$props) {
                                try {
                                    $module = WebModule::factory($moduleID);
                                } catch (Exception $e) {
                                    throw new Exception('Module ' . $moduleID . ' not found');
                                }
                                
                                if (!is_array($props)) {
                                    throw new Exception("Invalid properties for $type $section");
                                }
                                
                                $valid_props = array('protected','secure','disabled','search');
//.........这里部分代码省略.........
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:AdminAPIModule.php


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