private function detectDeviceInternal($user_agent) { includePackage('db'); if (!$user_agent) { return; } if (!$db_file = $GLOBALS['siteConfig']->getVar('MOBI_SERVICE_FILE')) { error_log('MOBI_SERVICE_FILE not specified in site config.'); die("MOBI_SERVICE_FILE not specified in site config."); } try { $db = new db(array('DB_TYPE'=>'sqlite', 'DB_FILE'=>$db_file)); $result = $db->query('SELECT * FROM userAgentPatterns WHERE version<=? ORDER BY patternorder,version DESC', array($this->version)); } catch (Exception $e) { error_log("Error with device detection"); return false; } while ($row = $result->fetch()) { if (preg_match("#" . $row['pattern'] . "#i", $user_agent)) { return $row; } } return false; }
protected function init() { $moduleData = $this->getModuleData(); if ($moduleData['disabled']) { $this->moduleDisabled(); } if ($moduleData['secure'] && (!isset($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] !='on'))) { $this->secureModule(); } if ($this->getSiteVar('AUTHENTICATION_ENABLED')) { includePackage('Authentication'); if ($moduleData['protected']) { if (!$this->isLoggedIn()) { $this->unauthorizedAccess(); } } if (!$this->evaluateACLS()) { $this->unauthorizedAccess(); } } }
<?php includePackage('readability'); /** * KurogoReader * * @uses Readability * @package * @license */ class KurogoReader { /** * baseurl * the base url for this article * with protocol prefix, without slash suffix * * @var mixed * @access private */ private $baseurl; /** * tidyAvailable * flag to mark if tidy function available * * @var mixed * @access private */ private $tidyAvailable; /** * cache vars
protected function initializeForPage() { if (!Kurogo::getOptionalSiteVar('STATS_ENABLED', true)) { throw new KurogoException($this->getLocalizedString('STATS_DISABLED')); } if ($this->page == 'updateStats') { KurogoStats::exportStatsData(); $this->redirectTo('index'); } if ($this->getOptionalModuleVar('AUTO_UPDATE_STATS')) { KurogoStats::exportStatsData(); } $serviceTypes = $this->getServiceTypes(); $service = $this->getArg('service', 'web'); if (!array_key_exists($service, $serviceTypes)) { $service = 'web'; } $interval_types = $this->getIntervalTypes(); $interval = $this->getArg('interval', 'day'); if (!array_key_exists($interval, $interval_types)) { $interval = 'day'; } if ($interval == 'custom') { $start = $this->getArg('start'); $startTime = $start ? mktime(0, 0, 0, $start['Month'], $start['Day'], $start['Year']) : mktime(0, 0, 0); $end = $this->getArg('end', array()); $endTime = $end ? mktime(23, 59, 59, $end['Month'], $end['Day'], $end['Year']) : mktime(23, 59, 59); if ($endTime < $startTime) { $endTime = $startTime; } } else { $times = $this->getTimesForInterval($interval, $interval_types[$interval]['duration']); $startTime = $times['start']; $endTime = $times['end']; } $intervalOptions = array(); $args = $this->args; $args['service'] = $service; $args['interval'] = $interval; foreach ($interval_types as $interval_type => $type) { $args['interval'] = $interval_type; $intervalOptions[$interval_type] = array('title' => $type['title'], 'selected' => $interval_type == $interval, 'url' => $this->buildbreadcrumbURL($this->page, $args, false)); } $args = $this->args; $args['service'] = $service; $args['interval'] = $interval; foreach ($serviceTypes as $serviceType => $serviceTypeTitle) { $args['service'] = $serviceType; $serviceOptions[$serviceType] = array('title' => $serviceTypeTitle, 'selected' => $service == $serviceType, 'url' => $this->buildbreadcrumbURL($this->page, $args, false)); } $this->assign('starttime', $startTime); $this->assign('endtime', $endTime); $this->assign('statsService', $service); $this->assign('interval', $interval); $this->assign('intervalOptions', $intervalOptions); $this->assign('serviceOptions', $serviceOptions); $this->assign('intervalTabclass', count($interval_types) == 4 ? 'fourtabs' : 'threetabs'); $this->assign('serviceTabclass', 'twotabs'); $commonData = array('service' => $service, 'start' => $startTime, 'end' => $endTime); if ($date = KurogoStats::getLastDateFromSummary()) { includePackage('DateTime'); $date = new DateTime($date); $this->assign('lastUpdated', DateFormatter::formatDate($date, DateFormatter::LONG_STYLE, DateFormatter::NO_STYLE)); } switch ($this->page) { case 'index': //get config $chartsConfig = $this->getModuleSections('stats-index'); $charts = array(); foreach ($chartsConfig as $chartIndex => $chartData) { try { $charts[] = $this->prepareChart(array_merge($chartData, $commonData), $interval); } catch (KurogoStatsConfigurationException $e) { $this->redirectTo('statsconfigerror', array('chart' => $chartData['title'])); } } $this->assign('charts', $charts); break; case 'detail': if (!($group = $this->getArg('group'))) { $this->redirectTo('index'); } if (!(${$group} = $this->getArg($group))) { $this->redirectTo('index'); } if (!($chartsConfig = $this->getChartsConfig($group, ${$group}))) { $this->redirectTo('index'); } $charts = array(); $commonData[$group] = ${$group}; foreach ($chartsConfig as $chartIndex => $chartData) { try { $charts[] = $this->prepareChart(array_merge($chartData, $commonData), $interval); } catch (KurogoStatsConfigurationException $e) { $this->redirectTo('statsconfigerror', array('chart' => $chartData['title'])); } } $this->setPageTitle(sprintf("Stats for %s", ${$group})); $this->assign('charts', $charts); break; case 'statsconfigerror': $this->assign('chart', $this->getArg('chart')); break; } }
/* * Copyright © 2010 - 2013 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ /** * @package ExternalData * @subpackage RSS */ /** */ includePackage('RSS'); /** * @package ExternalData * @subpackage RSS */ class LegacyRSSDataParser extends XMLDataParser { protected $channel; protected $channelClass = 'RSSChannel'; protected $itemClass = 'RSSItem'; protected $imageClass = 'RSSImage'; protected $enclosureClass = 'RSSEnclosure'; protected $imageEnclosureClass = 'RSSImageEnclosure'; protected $removeDuplicates = false; protected $htmlEscapedCDATA = false; protected $useDescriptionForContent = false;
<?php /** * @package DataController */ /** * A generic class to handle the retrieval of external data * * Handles retrieval, caching and parsing of data. * @package DataController */ includePackage('DataController'); includePackage('DataResponse'); abstract class DataController { protected $DEFAULT_PARSER_CLASS = 'PassthroughDataParser'; protected $initArgs = array(); protected $cacheFolder = 'Data'; protected $parser; protected $url; protected $cache; protected $baseURL; protected $title; protected $method = 'GET'; protected $filters = array(); protected $requestHeaders = array(); protected $response; protected $totalItems = null; protected $debugMode = false; protected $useCache = true; protected $useStaleCache = true;
<?php /** * @package Core */ includePackage('db'); /** * @package Core */ class PageViews { public static function log_api($module, $platform, $time=NULL) { $extra = serialize($_GET); self::log_item('api', $module, $platform, $extra, $time); } public static function increment($module, $platform, $time=NULL) { self::log_item('web', $module, $platform, "", $time); } public static function log_item($system, $module, $platform, $extra, $time) { if ($time === NULL) $time = time(); if ($system == 'web') $logfile = $GLOBALS['siteConfig']->getVar('WEB_CURRENT_LOG_FILE'); else // assume 'api' $logfile = $GLOBALS['siteConfig']->getVar('API_CURRENT_LOG_FILE'); if (empty($logfile)) {
* Copyright © 2010 - 2012 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ /** * @package ExternalData */ /** * A generic class to handle the retrieval of external data * use soap api * @package ExternalData */ includePackage('DataRetriever', 'SOAP'); class SOAPDataRetriever extends DataRetriever { protected $DEFAULT_RESPONSE_CLASS = 'SOAPDataResponse'; protected $wsdl; protected $soapClient; protected $soapOptions = array('trace' => 1); //use it and wsdl to instantiate SoapClient protected $method; protected $parameters = array(); protected $location; protected $uri; protected $action; protected $saveToFile = false; protected $soapHeaders = array(); public function setWSDL($wsdl)
protected function timeText($photo, $timeOnly = false) { includePackage('Calendar'); return DateFormatter::formatDate($photo->getPublished(), DateFormatter::SHORT_STYLE, DateFormatter::SHORT_STYLE); }
public static function getCacheClasses() { includePackage('Cache'); return KurogoMemoryCache::getCacheClasses(); }
<?php includePackage('Emergency'); class EmergencyWebModule extends WebModule { protected $id='emergency'; protected $hasFeeds = true; protected function prepareAdminForSection($section, &$adminModule) { switch ($section) { case 'feeds': $feeds = $this->loadFeedData(); $adminModule->assign('feeds', $feeds); $adminModule->setTemplatePage('feedAdmin', $this->id); break; default: return parent::prepareAdminForSection($section, $adminModule); } } protected function initializeForPage() { // construct controllers $config = $this->loadFeedData(); if(isset($config['contacts'])) { $contactsController = DataController::factory($config['contacts']['CONTROLLER_CLASS'], $config['contacts']); } else { $contactsController = NULL; }
/** * Common initialization. Checks access. */ protected function init() { if ($this->getModuleVar('disabled','module')) { $this->moduleDisabled(); } if ((Kurogo::getOptionalSiteVar('SECURE_REQUIRED') || $this->getModuleVar('secure','module')) && (!isset($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] !='on'))) { $this->secureModule(); } if (Kurogo::getSiteVar('AUTHENTICATION_ENABLED')) { includePackage('Authentication'); if (!$this->getAccess()) { $this->unauthorizedAccess(); } } }
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; } }
private function setPageVariables() { $this->loadTemplateEngineIfNeeded(); $this->loadPageConfig(); // Set variables common to all modules $this->assign('moduleID', $this->id); $this->assign('moduleName', $this->moduleName); $this->assign('page', $this->page); $this->assign('isModuleHome', $this->page == 'index'); $this->assign('request_uri' , $_SERVER['REQUEST_URI']); // Font size for template $this->assign('fontsizes', $this->fontsizes); $this->assign('fontsize', $this->fontsize); $this->assign('fontsizeCSS', $this->getFontSizeCSS()); $this->assign('fontSizeURLs', $this->getFontSizeURLs()); // Minify URLs $this->assign('minify', $this->getMinifyUrls()); // Google Analytics. This probably needs to be moved if ($gaID = $this->getSiteVar('GOOGLE_ANALYTICS_ID', null, Config::SUPRESS_ERRORS)) { $this->assign('GOOGLE_ANALYTICS_ID', $gaID); $this->assign('gaImageURL', $this->googleAnalyticsGetImageUrl($gaID)); } // Breadcrumbs $this->loadBreadcrumbs(); // Tablet module nav list if ($this->pagetype == 'tablet') { $this->addInternalJavascript('/common/javascript/lib/iscroll.js'); $this->assign('moduleNavList', $this->getModuleNavlist()); } // Set variables for each page $this->initializeForPage(); $this->assign('pageTitle', $this->pageTitle); // Variables which may have been modified by the module subclass $this->assign('inlineCSSBlocks', $this->inlineCSSBlocks); $this->assign('cssURLs', $this->cssURLs); $this->assign('inlineJavascriptBlocks', $this->inlineJavascriptBlocks); $this->assign('onOrientationChangeBlocks', $this->onOrientationChangeBlocks); $this->assign('onLoadBlocks', $this->onLoadBlocks); $this->assign('inlineJavascriptFooterBlocks', $this->inlineJavascriptFooterBlocks); $this->assign('javascriptURLs', $this->javascriptURLs); $this->assign('breadcrumbs', $this->breadcrumbs); $this->assign('breadcrumbArgs', $this->getBreadcrumbArgs()); $this->assign('breadcrumbSamePageArgs', $this->getBreadcrumbArgs(false)); $this->assign('moduleDebugStrings', $this->moduleDebugStrings); $moduleStrings = $this->getModuleSection('strings', array(), Config::SUPRESS_ERRORS); $this->assign('moduleStrings', $moduleStrings); // Module Help if ($this->page == 'help') { $this->assign('hasHelp', false); $template = 'common/'.$this->page; } else { $this->assign('hasHelp', isset($moduleStrings['help'])); $template = 'modules/'.$this->templateModule.'/templates/'.$this->templatePage; } // Pager support if (isset($this->htmlPager)) { $this->assign('pager', $this->getPager()); } // Tab support if (isset($this->tabbedView)) { $this->assign('tabbedView', $this->tabbedView); } // Access Key Start $accessKeyStart = count($this->breadcrumbs); if ($this->id != 'home') { $accessKeyStart++; // Home link } $this->assign('accessKeyStart', $accessKeyStart); if ($this->getSiteVar('AUTHENTICATION_ENABLED')) { includePackage('Authentication'); $this->setCacheMaxAge(0); $session = $this->getSession(); $this->assign('session', $session); $this->assign('session_isLoggedIn', $this->isLoggedIn()); if ($this->isLoggedIn()) { $this->assign('session_max_idle', intval($this->getSiteVar('AUTHENTICATION_IDLE_TIMEOUT', 0, Config::SUPRESS_ERRORS))); } } /* set cache age. Modules that present content that rarely changes can set this value to something higher */ header(sprintf("Cache-Control: max-age=%d", $this->cacheMaxAge)); header("Expires: " . gmdate('D, d M Y H:i:s', time() + $this->cacheMaxAge) . ' GMT'); return $template; }
<?php // http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd // http://portal.opengeospatial.org/files/?artifact_id=27810 includePackage('Maps', 'KML'); class KMLDataParser extends XMLDataParser implements MapDataParser { protected $root; protected $elementStack = array(); protected $data = ''; protected $document; protected $folders = array(); protected $features = array(); protected $title; protected $category; // whitelists protected static $startElements = array('DOCUMENT', 'FOLDER', 'STYLE', 'STYLEMAP', 'PLACEMARK', 'POINT', 'LINESTRING', 'LINEARRING', 'POLYGON'); protected static $endElements = array('DOCUMENT', 'FOLDER', 'STYLE', 'STYLEMAP', 'STYLEURL', 'PLACEMARK'); /////// MapDataParser public function getProjection() { return null; } public function getAllPlacemarks() { return $this->features; } public function getChildCategories() { return $this->folders; }
<?php /** * @package Module * @subpackage Calendar */ includePackage('Calendar'); define('DAY_SECONDS', 24*60*60); /** * @package Module * @subpackage Calendar */ class CalendarWebModule extends WebModule { protected $id = 'calendar'; protected $feeds = array(); protected $timezone; protected $defaultSearchOption = 0; public function timezone() { return $this->timezone; } private $searchOptions = array( array("phrase" => "in the next 7 days", "offset" => 7), array("phrase" => "in the next 15 days", "offset" => 15), array("phrase" => "in the next 30 days", "offset" => 30), array("phrase" => "in the past 15 days", "offset" => -15), array("phrase" => "in the past 30 days", "offset" => -30),
<?php includePackage('Maps'); define('MAP_GROUP_COOKIE', 'mapgroup'); class MapWebModule extends WebModule { protected $id = 'map'; protected $bookmarkLinkTitle = 'Bookmarked Locations'; protected $feedGroup = null; protected $feedGroups = null; protected $numGroups = 1; protected $feeds; private function getDataForGroup($group) { if (!$this->feedGroups) { $this->feedGroups = $this->getFeedGroups(); } return isset($this->feedGroups[$group]) ? $this->feedGroups[$group] : null; } public function getFeedGroups() { return $this->getModuleSections('feedgroups'); } private function getCategoriesAsArray() { $category = $this->getArg('category', null); if ($category !== null) { return explode(MAP_CATEGORY_DELIMITER, $category); }
<?php /* * Copyright © 2010 - 2012 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ includePackage('Maps', 'ArcGIS'); class ArcGISParser extends DataParser implements MapDataParser { //private $singleFusedMapCache; // indicates whether we have map tiles private $initialExtent; private $fullExtent; private $serviceDescription; private $spatialRef; //private $supportedImageFormats; private $units; private $baseURL; // keep track of data controller's initial state private $idField; private $mapName; private $category; private $defaultLayerId; private $searchFilters = array(); // sublayers are known to arcgis as layers // but we call them sublayers since we are known to our datacontroller as a layer private $subLayers = array(); private $selectedLayer = null;
<?php includePackage('Authentication'); class GoogleAppsCalendarListRetriever extends OAuthDataRetriever implements CalendarListRetriever { protected $DEFAULT_PARSER_CLASS = 'GoogleAppsCalendarListParser'; protected $cacheLifetime = 900; protected $requiresToken = true; protected function getDomain() { return $this->authority ? $this->authority->getDomain() : false; } public function parameters() { $parameters = parent::parameters(); switch ($this->getOption('action')) { case 'userCalendars': $parameters['alt'] = 'jsonc'; break; case 'resources': $parameters['alt'] = 'json'; break; default: throw new KurogoException("Unknown action " . $this->getOption('action')); } return $parameters; } public function baseURL() { switch ($this->getOption('action')) { case 'userCalendars':
<?php /* * Copyright © 2010 - 2013 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ /** * @package ExternalData * @subpackage RSS */ includePackage('News'); class RSSItem extends XMLElement implements NewsItemInterface { protected $initArgs = array(); protected $name = 'item'; protected $title; protected $description; protected $link; protected $guid; protected $pubDate; protected $author; protected $comments; protected $content; protected $category = array(); protected $enclosure; protected $images = array(); protected $fetchContent = false;
public function __construct($args) { //load arguments $this->useDB = isset($args['AUTHENTICATION_USE_SESSION_DB']) ? $args['AUTHENTICATION_USE_SESSION_DB'] : false; $this->maxIdleTime = isset($args['AUTHENTICATION_IDLE_TIMEOUT']) ? intval($args['AUTHENTICATION_IDLE_TIMEOUT']) : 0; $this->remainLoggedInTime = isset($args['AUTHENTICATION_REMAIN_LOGGED_IN_TIME']) ? intval($args['AUTHENTICATION_REMAIN_LOGGED_IN_TIME']) : 0; $this->loginCookiePath = URL_BASE . 'login'; if (!isset($_SESSION)) { // set session ini values ini_set('session.name', SITE_KEY); ini_set('session.use_only_cookies', 1); ini_set('session.cookie_path', COOKIE_PATH); ini_set('session.gc_maxlifetime', self::SESSION_GC_TIME); if ($this->useDB) { includePackage('db'); // set the database session handlers session_set_save_handler( array($this, 'sess_open'), array($this, 'sess_close'), array($this, 'sess_read'), array($this, 'sess_write'), array($this, 'sess_destroy'), array($this, 'sess_gc') ); } else { ini_set('session.save_handler', 'files'); // make sure session directory exists if (!is_dir(CACHE_DIR . "/session")) { mkdir(CACHE_DIR . "/session", 0700, true); } ini_set('session.save_path', CACHE_DIR . "/session"); } session_start(); $this->session_id = session_id(); $_SESSION['platform'] = $GLOBALS['deviceClassifier']->getPlatform(); $_SESSION['pagetype'] = $GLOBALS['deviceClassifier']->getPagetype(); $_SESSION['user_agent'] = $GLOBALS['deviceClassifier']->getUserAgent(); } // see if a user is active if (isset($_SESSION['users']) && is_array($_SESSION['users'])) { $lastPing = isset($_SESSION['ping']) ? $_SESSION['ping'] : 0; $diff = time() - $lastPing; // see if max idle time has been reached if ( $this->maxIdleTime && ($diff > $this->maxIdleTime)) { // right now the user is just logged off, but we could show and error if necessary. } else { $ok = false; foreach ($_SESSION['users'] as $userData) { if ($authority = AuthenticationAuthority::getAuthenticationAuthority($userData['auth'])) { if ($user = $authority->getUser($userData['auth_userID'])) { $ok = true; $this->setUser($user); } else { error_log("Error trying to load user " . $userData['auth_userID']); } } } if ($ok) { return; } } } elseif ($users = $this->getLoginCookie()) { $this->login_cookie = $_COOKIE[self::TOKEN_COOKIE]; foreach ($users as $user) { $this->setUser($user); } //regenerate new login cookie $this->setLoginCookie(); return; } else { //anonymous user } }
<?php /* * Copyright © 2010 - 2012 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ includePackage('Maps', 'Shapefile'); function ieee64FromLong($arg) { $mantissa = 1.0; $sign = 1; if ($arg & 9.223372036854776E+18) { $sign = -1; } $exponent = (($arg & 9.218868437227405E+18) >> 52) - (pow(2, 11 - 1) - 1); $mantissaBits = $arg & 4503599627370495.0; for ($pos = 0; $pos < 52; $pos++) { $bit = $mantissaBits & 1; $mantissa += pow(2, $pos - 52) * $bit; $mantissaBits = $mantissaBits >> 1; } return $sign * pow(2, $exponent) * $mantissa; } class ShapefileDataParser extends BinaryFileParser implements MapDataParser { private $features = array(); private $dbfParser;
/* * Copyright © 2010 - 2012 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ /** * @package ExternalData */ /** * A generic class to handle the parsing of external data * @package ExternalData */ includePackage('DataParser'); abstract class DataParser { public abstract function parseData($data); const PARSE_MODE_STRING = 1; const PARSE_MODE_FILE = 2; const PARSE_MODE_RESPONSE = 3; protected $encoding = 'utf-8'; protected $parseMode = self::PARSE_MODE_RESPONSE; protected $initArgs = array(); protected $debugMode = false; protected $totalItems = null; protected $haltOnParseErrors = true; protected $dataController; protected $options = array(); protected $response;
<?php /** * @package DataModel */ /** * A generic class to handle the retrieval of external data * * Handles retrieval, caching and parsing of data. * @package DataModel */ includePackage('DataModel'); includePackage('DataRetriever'); class DataModel { protected $DEFAULT_PARSER_CLASS; protected $DEFAULT_RETRIEVER_CLASS = 'URLDataRetriever'; protected $RETRIEVER_INTERFACE = 'DataRetriever'; protected $initArgs = array(); protected $retriever; protected $title; protected $debugMode = false; protected $options = array(); /** * Clears the internal cache for a new request. All responses and options are erased and * clearInteralCache is called on the retriever */ public function clearInternalCache() { $this->options = array(); $this->retriever->clearInternalCache();
protected function createDatabaseTables() { includePackage('db'); $sql = "SELECT 1 FROM mobi_web_page_views"; $conn = SiteDB::connection(); if (!$result = $conn->query($sql, array(), db::IGNORE_ERRORS)) { $sqls = array( "CREATE TABLE mobi_web_page_views ( day date, platform char(31) NOT NULL, module char(31) NOT NULL, viewcount int NOT NULL)", "CREATE TABLE mobi_api_requests ( day date default NULL, platform char(31) default NULL, module char(31) default NULL, viewcount int default NULL, UNIQUE (day,platform,module) )" ); foreach ($sqls as $sql) { $conn->query($sql); } } }
<?php /** * @package Module * @subpackage People */ includePackage('People'); /** * @package Module * @subpackage People */ class PeopleWebModule extends WebModule { protected $id = 'people'; protected $bookmarkLinkTitle = 'Bookmarked People'; private $detailFields = array(); private $detailAttributes = array(); protected $defaultController = 'LDAPPeopleController'; protected $feeds=array(); protected function detailURLForBookmark($aBookmark) { parse_str($aBookmark, $params); return $this->buildBreadcrumbURL('detail', $params, true); } protected function getTitleForBookmark($aBookmark) { parse_str($aBookmark, $params); $titles = array($params['title']); if (isset($params['subtitle'])) { $titles[] = $params['subtitle']; }
<?php /* * Copyright © 2010 - 2012 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ includePackage('DateTime'); class EmergencyNoticeDataModel extends DataModel { protected $DEFAULT_PARSER_CLASS = 'RSSDataParser'; protected $NOTICE_EXPIRATION = 604800; // 1 week protected $NOTICE_MAX_COUNT = NULL; // unlimited protected $emergencyNotices = NULL; protected $cacheFolder = "Emergency"; protected $DEFAULT_CACHE_LIFETIME = 60; // emergency notice should have a short cache time protected function init($args) { // Present variable if not set before init (the retriever reads it) if (!isset($args['CACHE_LIFETIME'])) { $args['CACHE_LIFETIME'] = $this->DEFAULT_CACHE_LIFETIME; } parent::init($args); if (isset($args['NOTICE_EXPIRATION'])) { $this->NOTICE_EXPIRATION = $args['NOTICE_EXPIRATION'];
<?php includePackage('Maps', 'MapDB'); class MapDBDataController extends MapDataController implements MapFolder { protected $DEFAULT_PARSER_CLASS = "MapDBDataParser"; private $hasDBData = false; private $dbParser; private $subtitle; protected $cacheLifetime = 60; public function getCategoryId() { return $this->dbParser->getCategoryId(); } public function getSubtitle() { return $this->subtitle; } //////// DataController overrides protected function initStreamContext($args) { // no stream is required if: // we don't need to refresh our cache if ($this->cacheIsFresh()) { return; } parent::initStreamContext($args); } protected function init($args) { parent::init($args);
<?php /* * Copyright © 2010 - 2013 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ includePackage('DataModel'); class PhotosDataModel extends ItemListDataModel { protected $cacheFolder = 'Photo'; public function getPhotos() { return $this->items(); } public function items() { $items = parent::items(); foreach ($items as $item) { $item->setRetriever($this->retriever); } return $items; } public function getDefaultPhoto() { $this->setStart(0); $this->setLimit(1); $items = $this->items();
<?php /* * Copyright © 2010 - 2013 Modo Labs Inc. All rights reserved. * * The license governing the contents of this file is located in the LICENSE * file located at the root directory of this distribution. If the LICENSE file * is missing, please contact sales@modolabs.com. * */ includePackage('Authorization'); class TwitterDataRetriever extends OAuthDataRetriever implements SocialDataRetriever, ItemDataRetriever { protected $DEFAULT_PARSER_CLASS = 'TwitterDataParser'; protected $OAuthProviderClass = 'TwitterOAuthProvider'; protected $cacheGroup = 'Twitter'; protected $user; protected $requiresExpect = false; protected $apiVersion = '1.1'; public function getServiceName() { return 'twitter'; } public function getAccount() { return $this->user; } public function getPosts() { $this->setBaseURL('https://api.twitter.com/' . $this->apiVersion . '/statuses/user_timeline.json'); $this->addFilter('screen_name', $this->user);