Example #1
0
 function fetchRecord()
 {
     // fetch a record from record set
     $arrData = parent::fetchRecord();
     if ($arrData === FALSE) {
         return FALSE;
     }
     // ------ compute title
     // use a special class for selected items
     $title = '<input type="submit" class="';
     if (is_array($this->selectedIdObject) && in_array($arrData['idObject'], $this->selectedIdObject)) {
         $title .= 'TreeItemSelected';
         $op = $this->opDeselectId;
     } else {
         $title .= 'TreeItem';
         $op = $this->opSelectId;
     }
     // attach select operation to title
     $title .= '" value="' . $arrData['title'] . '" name="' . $op . $arrData['idObject'] . '" id="' . $arrData['idObject'] . '_select" />';
     $arrData['title'] = $title;
     // ------ compute icon
     $arrData['icon'] = '<img src="' . getPathImage() . 'lobject/' . $arrData['objectType'] . '.gif" alt="' . $arrData['objectType'] . '" />';
     // ------ show operation
     $arrData['show'] = '<div class="LVShowItem">' . '<input type="submit" class="LVShowItem" value="' . '" name="' . $this->opShowId . $arrData['idObject'] . '" id="' . $arrData['idObject'] . 'img_show" />' . '</div>';
     // ------ play operation
     $arrData['play'] = '<div class="LVShowItem">' . '<input type="submit" class="LVShowItem" value="' . '" name="' . $this->opPlayId . $arrData['idObject'] . '" id="' . $arrData['idObject'] . 'img_play" />' . '</div>';
     return $arrData;
 }
Example #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();
     }
 }
Example #3
0
 protected function init($args)
 {
     parent::init($args);
     if (!isset($args['DB_TYPE'])) {
         $args = array_merge(Kurogo::getSiteSection('database'), $args);
     }
     if (isset($args['SQL'])) {
         $this->setSQL($args['SQL']);
     }
     if (isset($args['PARAMETERS']) && is_array($args['PARAMETERS'])) {
         $this->setParameters($args['PARAMETERS']);
     }
     $this->connection = new db($args);
 }
Example #4
0
 protected function getRetriever()
 {
     if (isset($this->args['READER_RETRIEVER_CLASS'])) {
         $retrieverClass = $this->args['READER_RETRIEVER_CLASS'];
     } else {
         $retrieverClass = $this->DEFAULT_READER_RETRIEVER_CLASS;
     }
     if (isset($this->args['READER_PARSER_CLASS'])) {
         $parserClass = $this->args['READER_PARSER_CLASS'];
     } else {
         if ($this->DEFAULT_READER_PARSER_CLASS) {
             $parserClass = $this->DEFAULT_READER_PARSER_CLASS;
         } else {
             $parserClass = "PassthroughDataParser";
         }
     }
     $this->args["PARSER_CLASS"] = $parserClass;
     return DataRetriever::factory($retrieverClass, $this->args);
 }
Example #5
0
 public static function load($file)
 {
     $filePath = self::filePath($file);
     $path = realpath_exists($filePath);
     if (!$path) {
         $loaderInfoPath = realpath_exists("{$filePath}.needsLoad");
         if ($loaderInfoPath) {
             $loaderInfo = json_decode(file_get_contents($loaderInfoPath), true);
             // TODO do something with loaderInfo
             // e.g. image width/height
             if (isset($loaderInfo, $loaderInfo['url'])) {
                 $args = array('BASE_URL' => $loaderInfo['url'], 'CACHE_LIFETIME' => 0);
                 $retriever = DataRetriever::factory("URLDataRetriever", $args);
                 $data = $retriever->getData();
                 if ($data) {
                     //use a temp file to prevent race conditions
                     $tempFile = $filePath . '.' . uniqid();
                     if (file_put_contents($tempFile, $data)) {
                         if (isset($loaderInfo['processMethod'])) {
                             call_user_func($loaderInfo['processMethod'], $tempFile, $loaderInfo);
                         }
                         rename($tempFile, $filePath);
                         $path = realpath_exists($filePath);
                         unlink($loaderInfoPath);
                     } else {
                         Kurogo::log(LOG_WARNING, "FileLoader failed to save data to '{$filePath}'", 'data');
                     }
                 } else {
                     Kurogo::log(LOG_WARNING, "FileLoader failed to load '{$loaderInfo['url']}'", 'data');
                 }
             } else {
                 Kurogo::log(LOG_WARNING, "FileLoader got invalid loader info", 'data');
             }
         } else {
             Kurogo::log(LOG_WARNING, "FileLoader could not find loader info for '{$file}' at '{$loaderInfoPath}'", 'data');
         }
     }
     return $path;
 }
Example #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();
     }
 }
Example #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;
     }
 }
Example #8
0
 protected function init($args)
 {
     parent::init($args);
     if (isset($args['USE_CURL'])) {
         $this->useCurl = (bool) $args['USE_CURL'];
     }
     if (isset($args['BASE_URL'])) {
         $this->setBaseURL($args['BASE_URL']);
     }
     if (isset($args['METHOD'])) {
         $this->setMethod($args['METHOD']);
     }
     if (isset($args['HEADERS'])) {
         $this->setHeaders($args['HEADERS']);
     }
     if (isset($args['DATA'])) {
         $this->setData($args['DATA']);
     }
     if ($this->useCurl) {
         $this->initCurl($args);
     } else {
         $this->initStreamContext($args);
     }
 }
Example #9
0
 protected function init($args)
 {
     $args['PERSON_CLASS'] = isset($args['PERSON_CLASS']) ? $args['PERSON_CLASS'] : $this->personClass;
     parent::init($args);
     if (isset($args['HOST'])) {
         $this->setHost($args['HOST']);
     }
     $this->port = isset($args['PORT']) ? $args['PORT'] : 389;
     $this->searchBase = isset($args['SEARCH_BASE']) ? $args['SEARCH_BASE'] : '';
     $this->adminDN = isset($args['ADMIN_DN']) ? $args['ADMIN_DN'] : null;
     $this->adminPassword = isset($args['ADMIN_PASSWORD']) ? $args['ADMIN_PASSWORD'] : null;
     $this->searchTimelimit = isset($args['SEARCH_TIMELIMIT']) ? $args['SEARCH_TIMELIMIT'] : 30;
     $this->readTimelimit = isset($args['READ_TIMELIMIT']) ? $args['READ_TIMELIMIT'] : 30;
     if (isset($args['ATTRIBUTES'])) {
         $this->attributes = $args['ATTRIBUTES'];
         $this->baseAttributes = $args['ATTRIBUTES'];
     }
     if (isset($args['SEARCH_FIELDS'])) {
         $this->searchFields = $args['SEARCH_FIELDS'];
     }
     $this->fieldMap = array('userid' => isset($args['LDAP_USERID_FIELD']) ? $args['LDAP_USERID_FIELD'] : 'uid', 'email' => isset($args['LDAP_EMAIL_FIELD']) ? $args['LDAP_EMAIL_FIELD'] : 'mail', 'fullname' => isset($args['LDAP_FULLNAME_FIELD']) ? $args['LDAP_FULLNAME_FIELD'] : '', 'firstname' => isset($args['LDAP_FIRSTNAME_FIELD']) ? $args['LDAP_FIRSTNAME_FIELD'] : 'givenname', 'lastname' => isset($args['LDAP_LASTNAME_FIELD']) ? $args['LDAP_LASTNAME_FIELD'] : 'sn', 'photodata' => isset($args['LDAP_PHOTODATA_FIELD']) ? $args['LDAP_PHOTODATA_FIELD'] : 'jpegphoto', 'phone' => isset($args['LDAP_PHONE_FIELD']) ? $args['LDAP_PHONE_FIELD'] : 'telephonenumber');
     $this->setContext('fieldMap', $this->fieldMap);
 }
Example #10
0
 protected function getRetriever()
 {
     if (!$this->retriever) {
         $this->retriever = DataRetriever::factory('OAuthDataRetriever', array('OAUTH_CONSUMER_KEY' => $this->consumerKey, 'OAUTH_CONSUMER_SECRET' => $this->consumerSecret, 'signatureMethod' => $this->signatureMethod, 'cert' => $this->cert));
     }
     return $this->retriever;
 }
 protected function init($args)
 {
     $args['PERSON_CLASS'] = isset($args['PERSON_CLASS']) ? $args['PERSON_CLASS'] : $this->personClass;
     parent::init($args);
     if (isset($args['HOST'])) {
         $this->setHost($args['HOST']);
     }
     $this->port = isset($args['PORT']) ? $args['PORT'] : 389;
     $this->searchBase = isset($args['SEARCH_BASE']) ? $args['SEARCH_BASE'] : '';
     $this->adminDN = isset($args['ADMIN_DN']) ? $args['ADMIN_DN'] : null;
     $this->adminPassword = isset($args['ADMIN_PASSWORD']) ? $args['ADMIN_PASSWORD'] : null;
     $this->searchTimelimit = isset($args['SEARCH_TIMELIMIT']) ? $args['SEARCH_TIMELIMIT'] : 30;
     $this->readTimelimit = isset($args['READ_TIMELIMIT']) ? $args['READ_TIMELIMIT'] : 30;
     if (isset($args['ATTRIBUTES'])) {
         $this->attributes = $args['ATTRIBUTES'];
         $this->baseAttributes = $args['ATTRIBUTES'];
     }
     if (isset($args['SEARCH_FIELDS'])) {
         $this->searchFields = $args['SEARCH_FIELDS'];
     }
     if (isset($args['LDAP_FILTER'])) {
         if (!is_array($args['LDAP_FILTER'])) {
             throw new KurogoConfigurationException("LDAP_FILTER expected to be an array");
         }
         foreach ($args['LDAP_FILTER'] as $filterString) {
             $this->additionalFilters[] = new LDAPFilter($filterString, null, LDAPFilter::FILTER_OPTION_CUSTOM);
         }
     }
     $this->useSurroundWildcard = Kurogo::arrayVal($args, 'SURROUND_WILDCARD', false);
     $this->fieldMap = array('userid' => isset($args['LDAP_USERID_FIELD']) ? $args['LDAP_USERID_FIELD'] : 'uid', 'email' => isset($args['LDAP_EMAIL_FIELD']) ? $args['LDAP_EMAIL_FIELD'] : 'mail', 'fullname' => isset($args['LDAP_FULLNAME_FIELD']) ? $args['LDAP_FULLNAME_FIELD'] : '', 'firstname' => isset($args['LDAP_FIRSTNAME_FIELD']) ? $args['LDAP_FIRSTNAME_FIELD'] : 'givenname', 'lastname' => isset($args['LDAP_LASTNAME_FIELD']) ? $args['LDAP_LASTNAME_FIELD'] : 'sn', 'photodata' => isset($args['LDAP_PHOTODATA_FIELD']) ? $args['LDAP_PHOTODATA_FIELD'] : 'jpegphoto', 'phone' => isset($args['LDAP_PHONE_FIELD']) ? $args['LDAP_PHONE_FIELD'] : 'telephonenumber');
     $this->setContext('fieldMap', $this->fieldMap);
 }
Example #12
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;
     }
 }
Example #13
0
 protected function initializeForPage()
 {
     $this->controller = DataRetriever::factory('MoodleDataRetriever', array());
     switch ($this->page) {
         case 'index':
             $this->assign('message', 'Hello World');
             # hard coded values
             # should be replaced by authentication
             //
             //                $user = array(
             //                    'username' => '620065739',
             //                    'password' => '19941206',
             //                    'service' => 'moodle_mobile_app'
             //                );
             //
             //                # get user's moodle token
             //                $this->token = $this->controller->getToken($user); #JSON obj
             //                $this->assign('token', $this->token['token']);
             $userParam = array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742', 'wsfunction' => 'core_webservice_get_site_info');
             # Retrieve user information
             $userInfo = $this->controller->getUserId($userParam);
             $this->assign('info', $userInfo['userid']);
             # Retrieve json list of courses
             $coursesParam = array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742', 'wsfunction' => 'core_enrol_get_users_courses', 'userid' => $userInfo['userid']);
             # Retrieve user courses and converts json to php array
             $userCourses = $this->controller->getCourses($coursesParam);
             //                print_r($userCourses);
             # prep list for courses
             $coursesList = array();
             //                foreach ($userCourses as $courseData)
             //                {
             //                    $course = array(
             //                        'id' => $courseData['id'],
             //                        'shortname' => $courseData['shortname'],
             //                        'fullname' => $courseData['fullname'],
             //                        'usercount' => $courseData['enrolledusercount'],
             //                        'idnumber' => $courseData['idnumber'],
             //                        'url' =>  '/courses/details?wstoken=47aae912ad404c743d7b66ad0c6c0742&wsfunction=core_course_get_contents&courseid=' . $courseData['id']
             //                    );
             //                    $coursesList[] = $course;
             //                }
             foreach ($userCourses as $courseData) {
                 $course = array('subtitle' => $courseData['shortname'], 'title' => $courseData['fullname'], 'url' => $this->buildBreadcrumbURL('details', array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742', 'wsfunction' => 'core_course_get_contents', 'courseid' => $courseData['id'])));
                 $coursesList[] = $course;
             }
             $this->assign('coursesList', $coursesList);
             break;
             # 'url' => $this->buildBreadcrumbURL('details', array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742','wsfunction' => 'core_course_get_contents', 'courseid' => $courseData['id']), false)
         # 'url' => $this->buildBreadcrumbURL('details', array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742','wsfunction' => 'core_course_get_contents', 'courseid' => $courseData['id']), false)
         case 'details':
             $id = $this->getArg('courseid');
             $token = $this->getArg('wstoken');
             $func = $this->getArg('wsfunction');
             $this->assign('wstoken', $token);
             $this->assign('id', $id);
             $this->assign('func', $func);
             if ($courseContent = $this->controller->getContent($id, $token, $func)) {
                 $contentList = array();
                 foreach ($courseContent as $section) {
                     $detail = array('subtitle' => $section['id'], 'title' => $section['name']);
                     $contentList[] = $detail;
                 }
                 $this->assign('contentList', $contentList);
             }
             //                else {
             //                    $this->redirectTo('index');
             //                }
             break;
         default:
             parent::initializeForPage();
     }
     //<KEY name="idnumber"> &wsfunction=core_course_get_contents&courseid=76
     //<VALUE>JAPA10010</VALUE>
     //</KEY>
     //  wsfunction=core_enrol_get_users_courses&userid=9742
     //
     //        switch($this->page)
     //        {
     //            case 'index':
     //                # Retrieve user information
     //                $userInfo = $this->$controller->getUserId($userParam);
     //
     //                # Retrieve json list of courses
     //                $coursesParam = array(
     //                    'wstoken' => $this->$token['wstoken'],
     //                    'wsfunction' => 'moodlewsrestformat',
     //                    'moodlewsrestformat' => 'json'
     //                );
     //                $userCourses = $this->controller->getCourses($coursesParam);
     //
     //                $courseList = array();
     //                foreach ($userCourses as $courseData) {
     //                    $course = array(
     //                        'wstoken' => $this->$token['wstoken'],
     //                        'shortname' => $courseData['shortname'],
     //                        'fullname' => $courseData['fullname'],
     //                        'url' => $this->buildBreadcrumbURL('content', array('id' => $courseData['id'], 'token' => $token['wstoken'], 'name' => $courseData['shortname']))
     //                    );
     //                    $courseList[] = $course;
     //                }
     //
     //                $this->assign('message', 'My Courses');
     //                $this->assign('token', $token['token']);
     //                $this->assign('userid', $userInfo['userid']);
     //                $this->assign('courseList', $courseList);
     //
     //                # http://ourvle.mona.uwi.edu/webservice/rest/server.php?wstoken=e23c35eeda5b1799ffcea51cec0c19b2&wsfunction=core_webservice_get_site_info
     //
     //                break;
     //            case 'content':
     //                # pull course details
     //                # http://ourvle.mona.uwi.edu/webservice/rest/server.php?wstoken=e23c35eeda5b1799ffcea51cec0c19b2&wsfunction=core_course_get_contents&courseid=1485
     //
     //                $courseData = array(
     //                    'id' => $this->getArg('id'), # course content
     //                    'token' => $this->getArg('token'), # user token
     //                    'name' => $this->getArg('shortname') # shortened course name
     //                );
     //
     //                if ($courseContent = $this->$controller->getContent($courseData)) {
     //                    foreach ($courseContent as $courseData) {
     //
     //                    }
     ////                    $this->assign('courseName', $courseContent['']);
     //                }
     //            $this->assign('course_name', $courseData['name']);
     //        }
 }
Example #14
0
 public function init($args)
 {
     parent::init($args);
     $this->setCacheGroup(get_class($this));
 }
Example #15
0
 protected function init($args)
 {
     parent::init($args);
     if (isset($args['BASE_URL'])) {
         $this->setBaseURL($args['BASE_URL']);
     }
     if (isset($args['METHOD'])) {
         $this->setMethod($args['METHOD']);
     }
     if (isset($args['HEADERS'])) {
         $this->setHeaders($args['HEADERS']);
     }
     if (isset($args['DATA'])) {
         $this->setData($args['DATA']);
     }
     $this->initStreamContext($args);
 }
Example #16
0
 protected function init($args)
 {
     parent::init($args);
     if (isset($args['USE_CURL'])) {
         $this->useCurl = (bool) $args['USE_CURL'];
     }
     if (isset($args['BASE_URL'])) {
         $this->setBaseURL($args['BASE_URL']);
     }
     if (isset($args['METHOD'])) {
         $this->setMethod($args['METHOD']);
     }
     if (isset($args['HEADERS'])) {
         $this->setHeaders($args['HEADERS']);
     }
     if (isset($args['DATA'])) {
         $this->setData($args['DATA']);
     }
     if (isset($args['AUTH_TYPE'])) {
         $this->setAuthType($args['AUTH_TYPE']);
     }
     if (isset($args['AUTH_USER'])) {
         $this->setAuthUser($args['AUTH_USER']);
     }
     if (isset($args['AUTH_PASSWORD'])) {
         $this->setAuthPassword($args['AUTH_PASSWORD']);
     }
     if ($this->useCurl) {
         $this->initCurl($args);
     } else {
         $this->initStreamContext($args);
     }
     $this->setCredentials($this->authUser, $this->authPassword);
 }
Example #17
0
 /**
  * The initialization function. Sets the common parameters based on the $args. This method is
  * called by the public factory method. Subclasses can override this method, but must call parent::init()
  * FIRST. Arguments are also passed to the data retiever object
  * @param array $args an associative array of arguments and paramters
  */
 protected function init($args)
 {
     $this->initArgs = $args;
     if (isset($args['DEBUG_MODE'])) {
         $this->setDebugMode($args['DEBUG_MODE']);
     }
     // use a retriever class if set, otherwise use the default retrieve class from the controller
     $args['RETRIEVER_CLASS'] = isset($args['RETRIEVER_CLASS']) ? $args['RETRIEVER_CLASS'] : $this->DEFAULT_RETRIEVER_CLASS;
     $args['CACHE_FOLDER'] = isset($args['CACHE_FOLDER']) ? $args['CACHE_FOLDER'] : get_class($this);
     if ($this->DEFAULT_PARSER_CLASS) {
         $args['DEFAULT_PARSER_CLASS'] = $this->DEFAULT_PARSER_CLASS;
     }
     //instantiate the retriever class and add it to the controller
     $retriever = DataRetriever::factory($args['RETRIEVER_CLASS'], $args);
     $this->setRetriever($retriever);
     if (isset($args['TITLE'])) {
         $this->setTitle($args['TITLE']);
     }
 }
Example #18
0
 function GroupMembersDataRetriever($idstGroup, $dbconn = FALSE, $prefix = FALSE)
 {
     $this->idstGroup = $idstGroup;
     parent::DataRetriever($dbconn, $prefix);
     $this->aclManager = new DoceboACLManager($dbconn, $prefix);
 }
Example #19
0
 public function clearInternalCache()
 {
     parent::clearInternalCache();
     $this->soapHeaders = array();
     $this->soapClient = null;
 }
Example #20
0
 public function initializeForCommand()
 {
     if ($projection = $this->getArg('projection')) {
         $this->mapProjector = new MapProjector();
         $this->mapProjector->setDstProj($projection);
     }
     switch ($this->command) {
         case 'index':
             $categories = array();
             $response = array('displayType' => $this->getModuleDisplayType());
             $groups = $this->getFeedGroups();
             if ($groups) {
                 foreach ($groups as $id => &$groupData) {
                     if (isset($groupData['center'])) {
                         $latlon = filterLatLon($groupData['center']);
                         $groupData['lat'] = $latlon['lat'];
                         $groupData['lon'] = $latlon['lon'];
                     }
                     $groupData['id'] = $id;
                     $categories[] = $groupData;
                 }
                 $response['categories'] = $categories;
             } else {
                 $feeds = $this->loadFeedData();
                 foreach ($feeds as $id => $feedData) {
                     $categories[] = array('title' => $feedData['TITLE'], 'subtitle' => $feedData['SUBTITLE'], 'id' => $id);
                 }
             }
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
         case 'category':
             $this->loadFeedData();
             $categoryId = $this->getArg('category');
             $groups = $this->getFeedGroups();
             if (isset($groups[$categoryId])) {
                 $this->feedGroup = $categoryId;
                 $groupData = $this->loadFeedData();
                 $categories = array();
                 foreach ($groupData as $id => $feed) {
                     if (!isset($feed['HIDDEN']) || !$feed['HIDDEN']) {
                         $category = array('id' => $id, 'title' => $feed['TITLE']);
                         if (isset($feed['SUBTITLE'])) {
                             $category['subtitle'] = $feed['SUBTITLE'];
                         }
                         $categories[] = $category;
                     }
                 }
                 $response = array('categories' => $categories);
                 $this->setResponse($response);
                 $this->setResponseVersion(1);
             } else {
                 $controller = $this->getDataModel();
                 if ($controller) {
                     //if ($categoryId) {
                     //    $category = $controller->findCategory($categoryId);
                     //    $placemarks = $category->placemarks();
                     //    $categories = $category->categories();
                     //} else {
                     $placemarks = $controller->placemarks();
                     $categories = $controller->categories();
                     //}
                     if ($placemarks) {
                         $response['placemarks'] = array();
                         foreach ($placemarks as $placemark) {
                             $response['placemarks'][] = $this->arrayFromPlacemark($placemark);
                         }
                     }
                     if ($categories) {
                         foreach ($categories as $aCategory) {
                             $response['categories'][] = $this->arrayFromCategory($aCategory);
                         }
                     }
                     if (!$placemarks && !$categories) {
                         // need something in the response so that it will be
                         // output as a JSON object rather than a JSON array
                         $response = array('categories' => array());
                     }
                     $this->setResponse($response);
                     $this->setResponseVersion(1);
                 } else {
                     $error = new KurogoError("Could not find data source for requested category");
                     $this->throwError($error);
                 }
             }
             break;
         case 'detail':
             $suppress = $this->getOptionalModuleVar('suppress', array(), 'details', 'page-detail');
             $tabKeys = $this->getOptionalModuleVar('tabkeys', array(), 'tabs', 'page-detail');
             $controller = $this->getDataModel();
             $placemarkId = $this->getArg('id', null);
             if ($controller && $placemarkId !== null) {
                 $placemarks = $controller->selectPlacemark($placemarkId);
                 $placemark = current($placemarks);
                 $fields = $placemark->getFields();
                 $geometry = $placemark->getGeometry();
                 $tabs = $this->getTabsForTabKeys($tabKeys, $this->command);
                 $response = array('sections' => $tabs, 'id' => $placemarkId, 'title' => $placemark->getTitle(), 'subtitle' => $placemark->getSubtitle(), 'address' => $placemark->getAddress());
                 if ($this->requestedVersion >= 2) {
                     $response['description'] = $placemark->getDescription($suppress);
                     $responseVersion = 2;
                 } else {
                     $response['details'] = array('description' => $placemark->getDescription($suppress));
                     $photoURL = $placemark->getField('PhotoURL');
                     if ($photoURL) {
                         $response['photoURL'] = $photoURL;
                     }
                     $responseVersion = 1;
                 }
                 if ($geometry) {
                     $center = $geometry->getCenterCoordinate();
                     $response['lat'] = $center['lat'];
                     $response['lon'] = $center['lon'];
                     $response['geometryType'] = $this->getGeometryType($geometry);
                     $response['geometry'] = $this->formatGeometry($geometry);
                 }
                 $this->setResponse($response);
                 $this->setResponseVersion($responseVersion);
             }
             break;
         case 'search':
             $mapSearch = $this->getSearchClass($this->args);
             $lat = $this->getArg('lat', 0);
             $lon = $this->getArg('lon', 0);
             if ($lat || $lon) {
                 // defaults values for proximity search
                 $tolerance = 1000;
                 $maxItems = 0;
                 // check for settings in feedgroup config
                 $configData = $this->getDataForGroup($this->feedGroup);
                 if ($configData) {
                     if (isset($configData['NEARBY_THRESHOLD'])) {
                         $tolerance = $configData['NEARBY_THRESHOLD'];
                     }
                     if (isset($configData['NEARBY_ITEMS'])) {
                         $maxItems = $configData['NEARBY_ITEMS'];
                     }
                 }
                 // check for override settings in feeds
                 $configData = $this->getCurrentFeed();
                 if (isset($configData['NEARBY_THRESHOLD'])) {
                     $tolerance = $configData['NEARBY_THRESHOLD'];
                 }
                 if (isset($configData['NEARBY_ITEMS'])) {
                     $maxItems = $configData['NEARBY_ITEMS'];
                 }
                 $searchResults = $mapSearch->searchByProximity(array('lat' => $lat, 'lon' => $lon), 1000, 10);
             } else {
                 if ($searchTerms = $this->getArg(array('filter', 'q'))) {
                     $this->setLogData($searchTerms);
                     $searchResults = $mapSearch->searchCampusMap($searchTerms);
                 }
             }
             $provider = null;
             if ($this->requestedVersion >= 2 && $this->getArg('provider', null)) {
                 $providerId = $this->getArg('provider');
                 switch ($providerId) {
                     case 'google':
                         $provider = new GoogleJSMap();
                         break;
                     case 'esri':
                         $provider = new ArcGISJSMap();
                         break;
                 }
                 if ($provider && $projection) {
                     $provider->setMapProjection($projection);
                 }
             }
             $places = array();
             foreach ($searchResults as $result) {
                 if ($this->requestedVersion >= 2) {
                     $place = array('attribs' => $this->shortArrayFromPlacemark($result));
                 } else {
                     $place = $this->shortArrayFromPlacemark($result);
                 }
                 if ($provider) {
                     if ($result instanceof MapPolygon) {
                         $place['placemark'] = $provider->jsObjectForPolygon($result);
                     } elseif ($result instanceof MapPolyline) {
                         $place['placemark'] = $provider->jsObjectForPath($result);
                     } else {
                         $place['placemark'] = $provider->jsObjectForMarker($result);
                     }
                 }
                 $places[] = $place;
             }
             $response = array('total' => count($places), 'returned' => count($places), 'results' => $places);
             $this->setResponse($response);
             $this->setResponseVersion(1);
             break;
             // ajax calls
         // ajax calls
         case 'projectPoint':
             $lat = $this->getArg('lat', 0);
             $lon = $this->getArg('lon', 0);
             $fromProj = $this->getArg('from', GEOGRAPHIC_PROJECTION);
             $toProj = $this->getArg('to', GEOGRAPHIC_PROJECTION);
             $projector = new MapProjector();
             $projector->setSrcProj($fromProj);
             $projector->setDstProj($toProj);
             $result = $projector->projectPoint(array('lat' => $lat, 'lon' => $lon));
             $this->setResponse($result);
             $this->setResponseVersion(1);
             break;
         case 'sortGroupsByDistance':
             $lat = $this->getArg('lat', 0);
             $lon = $this->getArg('lon', 0);
             $categories = array();
             $showDistances = $this->getOptionalModuleVar('SHOW_DISTANCES', true);
             if ($lat || $lon) {
                 foreach ($this->getFeedGroups() as $id => $groupData) {
                     $center = filterLatLon($groupData['center']);
                     $distance = greatCircleDistance($lat, $lon, $center['lat'], $center['lon']);
                     $category = array('title' => $groupData['title'], 'id' => $id);
                     if ($showDistances && ($displayText = $this->displayTextFromMeters($distance))) {
                         $category['distance'] = $displayText;
                     }
                     $categories[] = $category;
                     $distances[] = $distance;
                 }
                 array_multisort($distances, SORT_ASC, $categories);
             }
             $this->setResponse($categories);
             $this->setResponseVersion(1);
             break;
         case 'staticImageURL':
             $params = array('STATIC_MAP_BASE_URL' => $this->getArg('baseURL'), 'STATIC_MAP_CLASS' => $this->getArg('mapClass'));
             $dc = Kurogo::deviceClassifier();
             $mapDevice = new MapDevice($dc->getPagetype(), $dc->getPlatform());
             $mapController = MapImageController::factory($params, $mapDevice);
             if (!$mapController->isStatic()) {
                 $error = new KurogoError(0, "staticImageURL must be used with a StaticMapImageController subclass");
                 $this->throwError($error);
             }
             $currentQuery = $this->getArg('query');
             $mapController->parseQuery($currentQuery);
             $overrides = $this->getArg('overrides');
             $mapController->parseQuery($overrides);
             $zoomDir = $this->getArg('zoom');
             if ($zoomDir == 1 || $zoomDir == 'in') {
                 $level = $mapController->getLevelForZooming('in');
                 $mapController->setZoomLevel($level);
             } elseif ($zoomDir == -1 || $zoomDir == 'out') {
                 $level = $mapController->getLevelForZooming('out');
                 $mapController->setZoomLevel($level);
             }
             $scrollDir = $this->getArg('scroll');
             if ($scrollDir) {
                 $center = $mapController->getCenterForPanning($scrollDir);
                 $mapController->setCenter($center);
             }
             $url = $mapController->getImageURL();
             $this->setResponse($url);
             $this->setResponseVersion(1);
             break;
         case 'geocode':
             // TODO: this is not fully implemented. do not use this API.
             includePackage('Maps', 'Geocoding');
             $locationSearchTerms = $this->getArg('q');
             $geocodingDataRetrieverClass = $this->getOptionalModuleVar('GEOCODING_DATA_RETRIEVER_CLASS');
             $geocodingDataParserClass = $this->getOptionalModuleVar('GEOCODING_DATA_PARSER_CLASS');
             $geocoding_base_url = $this->getOptionalModuleVar('GEOCODING_BASE_URL');
             $arguments = array('BASE_URL' => $geocoding_base_url, 'CACHE_LIFETIME' => 86400, 'PARSER_CLASS' => $geocodingDataParserClass);
             $controller = DataRetriever::factory($geocodingDataRetrieverClass, $arguments);
             $controller->addCustomFilters($locationSearchTerms);
             $response = $controller->getParsedData();
             // checking for Geocoding service error
             if ($response['errorCode'] == 0) {
                 unset($response['errorCode']);
                 unset($response['errorMessage']);
                 $this->setResponse($response);
                 $this->setResponseVersion(1);
             } else {
                 $kurogoError = new KurogoError($response['errorCode'], "Geocoding service Erroe", $response['errorMessage']);
                 $this->setResponseError($kurogoError);
                 $this->setResponseVersion(1);
             }
             break;
         default:
             $this->invalidCommand();
             break;
     }
 }
Example #21
0
 public function init($args)
 {
     parent::init($args);
     $this->fileStem = $args['BASE_URL'];
 }
Example #22
0
 /**
  * Method description
  *
  * More detailed method description
  * @param    void
  * @return   void
  */
 function checkAndSetData()
 {
     if (!$this->getDataSetted() && !$this instanceof iNotSelectable) {
         $this->restoreMemento();
         DataRetriever::manageData($this->getId());
     }
 }