本文整理汇总了PHP中Kurogo类的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo类的具体用法?PHP Kurogo怎么用?PHP Kurogo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kurogo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveResponse
protected function retrieveResponse()
{
if (!class_exists('ZipArchive')) {
throw new KurogoException("class ZipArchive (php-zip) not available");
}
$tmpFile = Kurogo::tempFile();
// this is the same as parent
if (!($this->requestURL = $this->url())) {
throw new KurogoDataException("URL could not be determined");
}
$this->requestParameters = $this->parameters();
// the following are private functions in URLDataRetriever
//$this->requestMethod = $this->setContextMethod();
//$this->requestHeaders = $this->setContextHeaders();
//$this->requestData = $this->setContextData();
Kurogo::log(LOG_INFO, "Retrieving {$this->requestURL}", 'url_retriever');
// the creation of $data is different from parent
copy($this->requestURL, $tmpFile);
$zip = new ZipArchive();
$zip->open($tmpFile);
$data = $zip->getFromIndex(0);
unlink($tmpFile);
// this is the same as parent
$http_response_header = isset($http_response_header) ? $http_response_header : array();
$response = $this->initResponse();
$response->setRequest($this->requestMethod, $this->requestURL, $this->requestParameters, $this->requestHeaders, null);
$response->setResponse($data);
$response->setResponseHeaders($http_response_header);
Kurogo::log(LOG_DEBUG, sprintf("Returned status %d and %d bytes", $response->getCode(), strlen($data)), 'url_retriever');
return $response;
}
示例2: formatDate
public static function formatDate($date, $dateStyle, $timeStyle)
{
$dateStyleConstant = self::getDateConstant($dateStyle);
$timeStyleConstant = self::getTimeConstant($timeStyle);
if ($date instanceof DateTime) {
$date = $date->format('U');
}
$string = '';
if ($dateStyleConstant) {
$string .= strftime(Kurogo::getLocalizedString($dateStyleConstant), $date);
if ($timeStyleConstant) {
$string .= " ";
}
}
if ($timeStyleConstant) {
// Work around lack of %P support in Mac OS X
$format = Kurogo::getLocalizedString($timeStyleConstant);
$lowercase = false;
if (strpos($format, '%P') !== false) {
$format = str_replace('%P', '%p', $format);
$lowercase = true;
}
$formatted = strftime($format, $date);
if ($lowercase) {
$formatted = strtolower($formatted);
}
// Work around leading spaces that come from use of %l (but don't exist in date())
if (strpos($format, '%l') !== false) {
$formatted = trim($formatted);
}
$string .= $formatted;
}
return $string;
}
示例3: url
public function url()
{
if (empty($this->startDate) || empty($this->endDate)) {
throw new KurogoConfigurationException('Start or end date cannot be blank');
}
$diff = $this->endTimestamp() - $this->startTimestamp();
if ($diff < 86400 || $diff == 89999) {
// fix for DST
if (count($this->trumbaFilters) > 0) {
$this->setRequiresDateFilter(false);
$this->addFilter('startdate', $this->startDate->format('Ymd'));
$this->addFilter('days', 1);
} else {
$this->setRequiresDateFilter(true);
$this->addFilter('startdate', $this->startDate->format('Ym') . '01');
$this->addFilter('months', 1);
}
} elseif ($diff % 86400 == 0) {
$this->setRequiresDateFilter(false);
$this->addFilter('startdate', $this->startDate->format('Ymd'));
$this->addFilter('days', $diff / 86400);
} else {
Kurogo::log(LOG_WARNING, "Non day integral duration specified {$diff}", 'calendar');
}
return parent::url();
}
示例4: parseEntry
protected function parseEntry($entry)
{
switch ($this->response->getContext('retriever')) {
case 'feed':
$photo = new FlickrFeedPhotoObject();
$photo->setID($entry['guid']);
$photo->setAuthor($entry['author_name']);
$photo->setMimeType($entry['photo_mime']);
$photo->setURL($entry['photo_url']);
$photo->setHeight($entry['height']);
$photo->setWidth($entry['width']);
$photo->setThumbnailURL($entry['thumb_url']);
$published = new DateTime($entry['date_taken']);
$photo->setPublished($published);
$photo->setDescription($entry['description']);
break;
case 'api':
$photo = new FlickrAPIPhotoObject();
$photo->setUserID(Kurogo::arrayVal($entry, 'owner'));
$photo->setID($entry['id']);
$photo->setFarm($entry['farm']);
$photo->setServer($entry['server']);
$photo->setSecret($entry['secret']);
$photo->setDescription($entry['description']['_content']);
$photo->setAuthor($entry['ownername']);
$published = new DateTime($entry['datetaken']);
$photo->setPublished($published);
$photo->setThumbnailURL($photo->getFlickrUrl('s'));
$photo->setURL($photo->getFlickrUrl('z'));
break;
}
$photo->setTitle($entry['title']);
$photo->setTags($entry['tags']);
return $photo;
}
示例5: init
public function init($args)
{
$args['ID'] = $this->id;
$this->title = Kurogo::arrayVal($args, 'TITLE', $this->id);
$this->description = Kurogo::arrayVal($args, 'DESCRIPTION');
$this->rule = UserContextRule::factory($args);
}
示例6: initializeForPage
protected function initializeForPage()
{
$this->handleRequest($this->args);
$modules = $this->getModuleCustomizeList();
$moduleIDs = array();
$disabledModuleIDs = array();
foreach ($modules as $id => $info) {
$moduleIDs[] = $id;
if ($info['disabled']) {
$disabledModuleIDs[] = $id;
}
}
switch ($this->pagetype) {
case 'compliant':
case 'tablet':
$this->addInlineJavascript('var modules = ' . json_encode($moduleIDs) . ';' . 'var disabledModules = ' . json_encode($disabledModuleIDs) . ';' . 'var MODULE_ORDER_COOKIE = "' . self::MODULE_ORDER_COOKIE . '";' . 'var DISABLED_MODULES_COOKIE = "' . self::DISABLED_MODULES_COOKIE . '";' . 'var MODULE_ORDER_COOKIE_LIFESPAN = ' . Kurogo::getSiteVar('MODULE_ORDER_COOKIE_LIFESPAN') . ';' . 'var COOKIE_PATH = "' . COOKIE_PATH . '";');
$this->addInlineJavascriptFooter('init();');
break;
case 'touch':
case 'basic':
foreach ($moduleIDs as $index => $id) {
$modules[$id]['toggleDisabledURL'] = $this->buildBreadcrumbURL('index', array('action' => $modules[$id]['disabled'] ? 'on' : 'off', '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;
}
$this->assignByRef('modules', $modules);
}
示例7: auth
public function auth($options, &$userArray)
{
if (isset($options['startOver']) && $options['startOver']) {
$this->reset();
}
if (isset($_REQUEST['openid_mode'])) {
if (isset($_REQUEST['openid_identity'])) {
if ($ns = $this->getOpenIDNamespace('http://specs.openid.net/extensions/oauth/1.0', $_REQUEST)) {
if ($request_token = $this->getOpenIDValue('request_token', $ns, $_REQUEST)) {
$this->setToken(OAuthProvider::TOKEN_TYPE_REQUEST, $request_token);
if (!$this->getAccessToken($options)) {
throw new KurogoDataServerException("Error getting OAuth Access token");
}
}
}
$userArray = $_REQUEST;
return AUTH_OK;
} else {
Kurogo::log(LOG_WARNING, "openid_identity not found", 'auth');
return AUTH_FAILED;
}
} else {
//redirect to auth page
$url = $this->getAuthURL($options);
header("Location: " . $url);
exit;
}
}
示例8: initializeForPage
protected function initializeForPage()
{
$this->assign('deviceName', Kurogo::getOptionalSiteVar($this->platform, null, 'deviceNames'));
$this->assign('introduction', $this->getOptionalModuleVar('introduction', null, $this->platform, 'apps'));
$this->assign('instructions', $this->getOptionalModuleVar('instructions', null, $this->platform, 'apps'));
$this->assign('downloadUrl', $this->getOptionalModuleVar('url', null, $this->platform, 'apps'));
}
示例9: _outputTypeFile
function _outputTypeFile($matches) {
$file = $matches[3];
$platform = Kurogo::deviceClassifier()->getPlatform();
$pagetype = Kurogo::deviceClassifier()->getPagetype();
$testDirs = array(
THEME_DIR.'/'.$matches[1].$matches[2],
SITE_DIR.'/'.$matches[1].$matches[2],
APP_DIR.'/'.$matches[1].$matches[2],
);
$testFiles = array(
"$pagetype-$platform/$file",
"$pagetype/$file",
"$file",
);
foreach ($testDirs as $dir) {
foreach ($testFiles as $file) {
if ($file = realpath_exists("$dir/$file")) {
_outputFile($file);
}
}
}
_404();
}
示例10: getDataController
protected function getDataController($categoryPath, &$listItemPath) {
if (!$this->feeds)
$this->feeds = $this->loadFeedData();
if ($categoryPath === NULL) {
return MapDataController::factory('MapDataController', array(
'JS_MAP_CLASS' => 'GoogleJSMap',
'DEFAULT_ZOOM_LEVEL' => $this->getOptionalModuleVar('DEFAULT_ZOOM_LEVEL', 10)
));
} else {
$listItemPath = $categoryPath;
if ($this->numGroups > 0) {
if (count($categoryPath) < 2) {
$path = implode(MAP_CATEGORY_DELIMITER, $categoryPath);
throw new Exception("invalid category path $path for multiple feed groups");
}
$feedIndex = array_shift($listItemPath).MAP_CATEGORY_DELIMITER.array_shift($listItemPath);
} else {
$feedIndex = array_shift($listItemPath);
}
$feedData = $this->feeds[$feedIndex];
$controller = MapDataController::factory($feedData['CONTROLLER_CLASS'], $feedData);
$controller->setCategory($feedIndex);
$controller->setDebugMode(Kurogo::getSiteVar('DATA_DEBUG'));
return $controller;
}
}
示例11: init
public function init($args)
{
$this->baseURL = $args['BASE_URL'];
$this->diskCache = new DiskCache(Kurogo::getSiteVar('WMS_CACHE', 'maps'), 86400 * 7, true);
$this->diskCache->preserveFormat();
$filename = md5($this->baseURL);
$metafile = $filename . '-meta.txt';
if (!$this->diskCache->isFresh($filename)) {
$params = array('request' => 'GetCapabilities', 'service' => 'WMS');
$query = $this->baseURL . '?' . http_build_query($params);
file_put_contents($this->diskCache->getFullPath($metafile), $query);
$contents = file_get_contents($query);
$this->diskCache->write($contents, $filename);
} else {
$contents = $this->diskCache->read($filename);
}
$this->wmsParser = new WMSDataParser();
$this->wmsParser->parseData($contents);
$this->enableAllLayers();
// TODO make sure this projection is supported by the server
$projections = $this->wmsParser->getProjections();
if (count($projections)) {
// make sure this is a projection we can handle
foreach ($projections as $proj) {
$contents = MapProjector::getProjSpecs($proj);
if ($contents) {
$this->setMapProjection($proj);
}
}
} else {
$this->setMapProjection(GEOGRAPHIC_PROJECTION);
}
}
示例12: init
public function init($args)
{
if (isset($args['HALT_ON_PARSE_ERRORS'])) {
$this->haltOnParseErrors($args['HALT_ON_PARSE_ERRORS']);
}
$this->setDebugMode(Kurogo::getSiteVar('DATA_DEBUG'));
}
示例13: log
public function log($priority, $message, $area, $backTrace = null)
{
if (!self::isValidPriority($priority)) {
throw new Exception("Invalid logging priority {$priority}");
}
if (!preg_match("/^[a-z0-9_-]+\$/i", $area)) {
throw new Exception("Invalid area {$area}");
}
//don't log items above the current logging level
$loggingLevel = isset($this->areaLevel[$area]) ? $this->areaLevel[$area] : $this->defaultLevel;
if ($priority > $loggingLevel) {
return;
}
if (!$backTrace) {
$backTrace = debug_backtrace();
}
$compactTrace = self::compactTrace($backTrace);
if (isset($_SERVER['REQUEST_URI'])) {
$request = $_SERVER['REQUEST_URI'];
} elseif (defined('KUROGO_SHELL')) {
$request = json_encode(Kurogo::getArrayForRequest());
} else {
$request = null;
}
$content = sprintf("%s\t%s:%s\t%s\t%s\t%s", date(Kurogo::getSiteVar('LOG_DATE_FORMAT')), $area, self::priorityToString($priority), $compactTrace, $request, $message) . PHP_EOL;
self::fileAppend($this->logFile, $content);
}
示例14: cacheFilename
/**
* Returns a base filename for the cache file that will be used. The default implementation uses
* a hash of the value returned from the url
* @return string
*/
protected function cacheFilename($url = null)
{
$url = $url ? $url : $this->url();
// Add the user's id to the cache-key for a per-user cache.
$session = Kurogo::getSession();
$user = $session->getUser();
return md5($url . $user->getUserID());
}
示例15: errorFromException
public static function errorFromException(Exception $exception) {
$error = new KurogoError($exception->getCode(), 'Exception', $exception->getMessage());
if(!Kurogo::getSiteVar('PRODUCTION_ERROR_HANDLER_ENABLED')) {
$error->file = $exception->getFile();
$error->line = $exception->getLine();
$error->trace = $exception->getTrace();
}
return $error;
}