本文整理汇总了PHP中Kurogo::sharedInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo::sharedInstance方法的具体用法?PHP Kurogo::sharedInstance怎么用?PHP Kurogo::sharedInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kurogo
的用法示例。
在下文中一共展示了Kurogo::sharedInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJSONOutput
public function getJSONOutput()
{
$contexts = Kurogo::sharedInstance()->getActiveContexts();
$this->contexts = array_keys($contexts);
if (is_null($this->version)) {
throw new KurogoException('APIResponse version must be set before display');
}
return json_encode($this);
}
示例2: initializeForCommand
public function initializeForCommand()
{
switch ($this->command) {
case 'notice':
$response = null;
$responseVersion = 1;
if ($this->getOptionalModuleVar('BANNER_ALERT', false, 'notice')) {
$noticeData = $this->getOptionalModuleSection('notice');
if ($noticeData) {
$response = array('notice' => '', 'moduleID' => null, 'link' => $this->getOptionalModuleVar('BANNER_ALERT_MODULE_LINK', false, 'notice'));
// notice can either take a module or data model class or retriever class. The section is passed on. It must implement the HomeAlertInterface interface
if (isset($noticeData['BANNER_ALERT_MODULE'])) {
$moduleID = $noticeData['BANNER_ALERT_MODULE'];
$controller = WebModule::factory($moduleID);
$response['moduleID'] = $moduleID;
$string = "Module {$moduleID}";
} elseif (isset($noticeData['BANNER_ALERT_MODEL_CLASS'])) {
$controller = DataModel::factory($noticeData['BANNER_ALERT_MODEL_CLASS'], $noticeData);
$string = $noticeData['BANNER_ALERT_MODEL_CLASS'];
} elseif (isset($noticeData['BANNER_ALERT_RETRIEVER_CLASS'])) {
$controller = DataRetriever::factory($noticeData['BANNER_ALERT_RETRIEVER_CLASS'], $noticeData);
$string = $noticeData['BANNER_ALERT_RETRIEVER_CLASS'];
} else {
throw new KurogoConfigurationException("Banner alert not properly configured");
}
if (!$controller instanceof HomeAlertInterface) {
throw new KurogoConfigurationException("{$string} does not implement HomeAlertModule interface");
}
$response['notice'] = $controller->getHomeScreenAlert();
}
}
$this->setResponse($response);
$this->setResponseVersion($responseVersion);
break;
case 'modules':
if ($setcontext = $this->getArg('setcontext')) {
Kurogo::sharedInstance()->setUserContext($setcontext);
}
$responseVersion = 2;
$response = array('primary' => array(), 'secondary' => array(), 'customize' => $this->getOptionalModuleVar('ALLOW_CUSTOMIZE', true), 'displayType' => $this->getOptionalModuleVar('display_type', 'springboard'));
$allmodules = $this->getAllModules();
$navModules = Kurogo::getSiteSections('navigation', Config::APPLY_CONTEXTS_NAVIGATION);
foreach ($navModules as $moduleID => $moduleData) {
if ($module = Kurogo::arrayVal($allmodules, $moduleID)) {
$title = Kurogo::arrayVal($moduleData, 'title', $module->getModuleVar('title'));
$type = Kurogo::arrayVal($moduleData, 'type', 'primary');
$visible = Kurogo::arrayVal($moduleData, 'visible', 1);
$response[$type][] = array('tag' => $moduleID, 'title' => $title, 'visible' => (bool) $visible);
}
}
$this->setResponse($response);
$this->setResponseVersion($responseVersion);
break;
default:
$this->invalidCommand();
}
}
示例3: initializeForCommand
public function initializeForCommand()
{
switch ($this->command) {
case 'version':
$this->out(KUROGO_VERSION);
return 0;
break;
case 'clearCaches':
$result = Kurogo::sharedInstance()->clearCaches();
return 0;
break;
case 'fetchAllData':
$allModules = $this->getAllModules();
$time = 0;
$this->out("Fetching data for site: " . SITE_NAME);
$start = microtime(true);
foreach ($allModules as $moduleID => $module) {
if ($module->isEnabled() && $module->getOptionalModuleVar('PREFETCH_DATA')) {
$module->setDispatcher($this->Dispatcher());
try {
$module->init('fetchAllData');
$module->executeCommand();
} catch (KurogoException $e) {
$this->out("Error: " . $e->getMessage());
}
}
}
$end = microtime(true);
$diff = $end - $start;
$time += $diff;
$this->out("Total: " . sprintf("%.2f", $end - $start) . " seconds.");
return 0;
break;
case 'deployPostFlight':
$this->verbose = $this->getArg('v');
$this->out('Running KurogoShell kurogo deployPostFlight');
$postFlightFilePath = SITE_SCRIPTS_DIR . DIRECTORY_SEPARATOR . 'deployPostFlight.sh';
if (!file_exists($postFlightFilePath)) {
$this->out("{$postFlightFilePath} does not exist, skipping execution");
return 0;
} elseif (!is_executable($postFlightFilePath)) {
$this->out("{$postFlightFilePath} exists, but is not executable. This must be fixed");
return 126;
}
$outputLines = array();
exec(sprintf("%s %s %s", escapeshellcmd($postFlightFilePath), escapeshellarg(ROOT_DIR), escapeshellarg(SITE_DIR)), $outputLines, $returnValue);
foreach ($outputLines as $lineNumber => $line) {
$this->out($line);
}
return $returnValue;
break;
default:
$this->invalidCommand();
break;
}
}
示例4: applyContexts
protected function applyContexts($sectionVars, $area, $type, $applyContexts)
{
if (!$this->activeContexts) {
$this->activeContexts = Kurogo::sharedInstance()->getActiveContexts();
}
$contextData = array();
$deny = array();
if ($type instanceof Module) {
$type = $type->getConfigModule();
}
foreach ($this->activeContexts as $context) {
if ($context->getID() == UserContext::CONTEXT_DEFAULT) {
continue;
}
Kurogo::log(LOG_DEBUG, "Apply context {$context} to {$area} {$type}", 'context');
if ($contextData) {
throw new KurogoException("Multiple contexts not yet completed");
}
if ($contextData = $this->getContextData($context->getID(), $area, $type)) {
switch ($applyContexts) {
case Config::APPLY_CONTEXTS_NAVIGATION:
$_sectionData = array();
$deny = array();
foreach ($contextData as $field => $sections) {
foreach ($sections as $section => $value) {
switch ($field) {
case 'visible':
if (isset($sectionVars[$section])) {
$_sectionData[$section] = $sectionVars[$section];
}
$_sectionData[$section][$field] = $value;
break;
case 'deny':
if ($value) {
$deny[] = $section;
}
}
}
}
$sectionVars = $_sectionData;
foreach ($deny as $section) {
unset($sectionVars[$section]);
}
break;
default:
throw new KurogoException("Invalid apply context value {$applyContexts}");
}
}
}
return $sectionVars;
}
示例5: getLocalizedString
public function getLocalizedString($key)
{
if (!preg_match("/^[a-z0-9_]+\$/i", $key)) {
throw new KurogoConfigurationException("Invalid string key {$key}");
}
Kurogo::log(LOG_DEBUG, "Retrieving localized string for {$key}", 'module');
// use any number of args past the first as options
$args = func_get_args();
array_shift($args);
if (count($args) == 0 || is_null($args[0])) {
$args = null;
}
$languages = Kurogo::sharedInstance()->getLanguages();
foreach ($languages as $language) {
$val = $this->getStringForLanguage($key, $language, $args);
if ($val !== null) {
Kurogo::log(LOG_INFO, "Found localized string \"{$val}\" for {$key} in {$language}", 'module');
return Kurogo::getOptionalSiteVar('LOCALIZATION_DEBUG') ? $key : $val;
}
}
throw new KurogoConfigurationException("Unable to find string {$key} for Module {$this->id}");
}
示例6: exportStatsData
/**
* export the stats data to the database
*/
public static function exportStatsData($startTimestamp = null)
{
$site = Kurogo::sharedInstance()->getSite();
$baseLogDir = $site->getBaseLogDir();
$logDir = $site->getLogDir();
$statsLogFileName = Kurogo::getOptionalSiteVar('KUROGO_STATS_LOG_FILENAME', 'kurogo_stats_log_v1');
//if the base dir is different then the log dir then get all files with the log file name
if ($baseLogDir != $logDir) {
$logFiles = glob($baseLogDir . DIRECTORY_SEPARATOR . "*" . DIRECTORY_SEPARATOR . $statsLogFileName);
} else {
$logFiles = array($logDir . DIRECTORY_SEPARATOR . $statsLogFileName);
}
//cycle through all log files
foreach ($logFiles as $statsLogFile) {
if (!file_exists($statsLogFile)) {
continue;
}
$today = date('Ymd', time());
//copy the log file
$tempLogFolder = Kurogo::tempDirectory();
$statsLogFileCopy = rtrim($tempLogFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . "stats_log_copy.{$today}";
if (!is_writable($tempLogFolder)) {
throw new Exception("Unable to write to Temporary Directory {$tempLogFolder}");
}
if (!rename($statsLogFile, $statsLogFileCopy)) {
Kurogo::log(LOG_DEBUG, "Failed to rename {$statsLogFile} to {$statsLogFileCopy}", 'kurogostats');
return;
}
$handle = fopen($statsLogFileCopy, 'r');
$startDate = '';
while (!feof($handle)) {
$line = trim(fgets($handle, 1024));
$value = explode("\t", $line);
if (count($value) != count(self::validFields()) || !isset($value[0]) || intval($value[0]) <= 0) {
continue;
}
if (!$startDate) {
$startTimestamp = $value[0];
$startDate = date('Y-m-d', $startTimestamp);
// If startTimestamp is during today
// Set startTimestamp to the beginning of today
if ($startDate == date('Y-m-d')) {
list($year, $month, $day) = explode('-', $startDate);
$startTimestamp = mktime(0, 0, 0, $month, $day, $year);
}
}
//insert the raw data to the database
$logData = array_combine(self::validFields(), $value);
self::insertStatsToMainTable($logData);
}
fclose($handle);
unlink($statsLogFileCopy);
self::updateSummaryFromShards($startTimestamp);
}
}
示例7: popErrorReporting
public static function popErrorReporting()
{
return Kurogo::sharedInstance()->_popErrorReporting();
}
示例8: initializeForPage
//.........这里部分代码省略.........
}
}
}
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;
}
}
示例9: getMemoryCache
protected function getMemoryCache()
{
if ($this->useMemoryCache) {
return Kurogo::sharedInstance()->cacher();
}
return false;
}
示例10: initializeForCommand
public function initializeForCommand() {
$this->requiresAdmin();
switch ($this->command) {
case 'checkversion':
$data = array(
'current'=>Kurogo::sharedInstance()->checkCurrentVersion(),
'local' =>KUROGO_VERSION
);
$this->setResponse($data);
$this->setResponseVersion(1);
break;
case 'clearcaches':
$result = Kurogo::sharedInstance()->clearCaches();
if ($result===0) {
$this->setResponse(true);
$this->setResponseVersion(1);
} else {
$this->throwError(KurogoError(1, "Error clearing caches", "There was an error ($result) clearing the caches"));
}
break;
case 'getconfigsections':
$type = $this->getArg('type');
switch ($type)
{
case 'module':
$moduleID = $this->getArg('module','');
try {
$module = WebModule::factory($moduleID);
} catch (Exception $e) {
throw new Exception('Module ' . $moduleID . ' not found');
}
$sections = $module->getModuleAdminSections();
break;
case 'site':
throw new Exception("getconfigsections for site not handled yet");
}
$this->setResponse($sections);
$this->setResponseVersion(1);
break;
case 'getconfigdata':
$type = $this->getArg('type');
$section = $this->getArg('section','');
switch ($type)
{
case 'module':
$moduleID = $this->getArg('module','');
try {
$module = WebModule::factory($moduleID);
} catch (Exception $e) {
throw new Exception('Module ' . $moduleID . ' not found');
}
$adminData = $this->getAdminData($module, $section);
break;
case 'site':
$adminData = $this->getAdminData('site', $section);
break;
}
$this->setResponse($adminData);
$this->setResponseVersion(1);
break;
case 'setconfigdata':
$type = $this->getArg('type');
$data = $this->getArg('data', array());
$section = $this->getArg('section','');
$subsection = null;
if (empty($data)) {
$data = array();
} elseif (!is_array($data)) {
throw new Exception("Invalid data for $type $section");
}
switch ($type)
{
case 'module':
if ($section == 'overview') {
foreach ($data as $moduleID=>$props) {
try {
$module = WebModule::factory($moduleID);
} catch (Exception $e) {
throw new Exception('Module ' . $moduleID . ' not found');
}
if (!is_array($props)) {
throw new Exception("Invalid properties for $type $section");
}
$valid_props = array('protected','secure','disabled','search');
//.........这里部分代码省略.........
示例11: getLocalizedString
public static function getLocalizedString($key, $opts = null)
{
return Kurogo::sharedInstance()->localizedString($key, $opts);
}
示例12: getMinifyGroupsConfig
function getMinifyGroupsConfig()
{
$minifyConfig = array();
$key = $_GET['g'];
// javascript and css search directory order
$dirs = array(APP_DIR, SHARED_APP_DIR, SITE_APP_DIR, SHARED_THEME_DIR, THEME_DIR);
//
// Check for specific file request
//
if (strpos($key, MIN_FILE_PREFIX) === 0) {
// file path relative to either templates or the theme (check theme first)
$path = substr($key, strlen(MIN_FILE_PREFIX));
$files = array();
foreach ($dirs as $dir) {
if ($dir) {
$files[] = $dir . $path;
}
}
$config = array('include' => 'all', 'files' => $files);
return array($key => buildFileList($config));
}
//
// Page request
//
$pageOnly = isset($_GET['pageOnly']) && $_GET['pageOnly'];
$noCommon = $pageOnly || isset($_GET['noCommon']) && $_GET['noCommon'];
// if this is a copied module also pull in files from that module
$configModule = isset($_GET['config']) ? $_GET['config'] : '';
list($ext, $module, $page, $pagetype, $platform, $browser, $pathHash) = explode('-', $key);
$cache = new DiskCache(CACHE_DIR . '/minify', Kurogo::getOptionalSiteVar('MINIFY_CACHE_TIMEOUT', 30), true);
$cacheName = "group_{$key}";
$Kurogo = Kurogo::sharedInstance();
$Kurogo->setCurrentModuleID($module);
if ($configModule) {
$Kurogo->setCurrentConfigModule($configModule);
$cacheName .= "-{$configModule}";
}
if ($pageOnly) {
$cacheName .= "-pageOnly";
}
if ($cache->isFresh($cacheName)) {
$minifyConfig = $cache->read($cacheName);
} else {
if ($noCommon) {
// Info module does not inherit from common files
$subDirs = array('/modules/' . $module);
} else {
$subDirs = array('/common', '/modules/' . $module);
}
if ($configModule && $configModule !== $module) {
$subDirs[] = '/modules/' . $configModule;
}
$checkFiles = array('css' => getFileConfigForDirs('css', 'css', $page, $pagetype, $platform, $browser, $dirs, $subDirs, $pageOnly), 'js' => getFileConfigForDirs('js', 'javascript', $page, $pagetype, $platform, $browser, $dirs, $subDirs, $pageOnly));
//error_log(print_r($checkFiles, true));
$minifyConfig[$key] = buildFileList($checkFiles[$ext]);
//error_log(__FUNCTION__."($pagetype-$platform-$browser) scanned filesystem for $key");
$cache->write($minifyConfig, $cacheName);
}
// Add minify source object for the theme config
if ($ext == 'css') {
$themeConfig = Kurogo::getThemeConfig();
if ($themeConfig) {
$minifyConfig[$key][] = new Minify_Source(array('id' => 'themeConfigModTimeChecker', 'getContentFunc' => 'minifyThemeConfigModTimeCheckerContent', 'minifier' => '', 'contentType' => Minify::TYPE_CSS, 'lastModified' => $themeConfig->getLastModified()));
}
}
//error_log(__FUNCTION__."($pagetype-$platform-$browser) returning: ".print_r($minifyConfig, true));
return $minifyConfig;
}
示例13: initializeForCommand
public function initializeForCommand()
{
switch ($this->command) {
case 'hello':
$allmodules = $this->getAllModules();
if ($this->requestedVersion >= 3) {
$version = 3;
} else {
$version = 2;
$homeModuleData = $this->getAllModuleNavigationData();
$homeModules = array('primary' => array_keys($homeModuleData['primary']), 'secondary' => array_keys($homeModuleData['secondary']));
}
$platform = $this->clientPlatform;
if ($this->clientPagetype == 'tablet') {
$platform .= '-tablet';
}
foreach ($allmodules as $moduleID => $module) {
if ($module->isEnabled()) {
//home is deprecated in lieu of using the "modules" command of the home module
$home = false;
if ($version < 3) {
if (($key = array_search($moduleID, $homeModules['primary'])) !== FALSE) {
if (Kurogo::arrayVal($homeModuleData['primary'][$moduleID], 'visible', true)) {
$title = Kurogo::arrayVal($homeModuleData['primary'][$moduleID], 'title', $module->getModuleVar('title'));
$home = array('type' => 'primary', 'order' => $key, 'title' => $title);
}
} elseif (($key = array_search($moduleID, $homeModules['secondary'])) !== FALSE) {
if (Kurogo::arrayVal($homeModuleData['secondary'][$moduleID], 'visible', true)) {
$title = Kurogo::arrayVal($homeModuleData['secondary'][$moduleID], 'title', $module->getModuleVar('title'));
$home = array('type' => 'secondary', 'order' => $key, 'title' => $title);
}
}
}
$moduleResponse = array('id' => $module->getID(), 'tag' => $module->getConfigModule(), 'icon' => $module->getOptionalModuleVar('icon', $module->getConfigModule(), 'module'), 'title' => $module->getModuleVar('title', 'module'), 'access' => $module->getAccess(AccessControlList::RULE_TYPE_ACCESS), 'payload' => $module->getPayload(), 'bridge' => $module->getWebBridgeConfig($platform), 'vmin' => $module->getVmin(), 'vmax' => $module->getVmax());
if ($version < 3) {
$moduleResponse['home'] = $home;
}
$modules[] = $moduleResponse;
}
}
$contexts = array();
foreach (Kurogo::sharedInstance()->getContexts() as $context) {
if ($context->isManual()) {
$contexts[] = array('id' => $context->getID(), 'title' => $context->getTitle(), 'description' => $context->getDescription());
}
}
$response = array('timezone' => Kurogo::getSiteVar('LOCAL_TIMEZONE'), 'site' => Kurogo::getSiteString('SITE_NAME'), 'organization' => Kurogo::getSiteString('ORGANIZATION_NAME'), 'version' => KUROGO_VERSION, 'modules' => $modules, 'default' => Kurogo::defaultModule(), 'home' => $this->getHomeModuleID(), 'contexts' => $contexts, 'contextsDisplay' => array('home' => Kurogo::getSiteVar('USER_CONTEXT_LIST_STYLE_NATIVE', 'contexts'), 'customize' => Kurogo::getSiteVar('USER_CONTEXT_LIST_STYLE_CUSTOMIZE', 'contexts')));
if ($appData = Kurogo::getAppData($this->clientPlatform)) {
if ($version = Kurogo::arrayVal($appData, 'version')) {
if (version_compare($this->clientVersion, $version) < 0) {
$response['appdata'] = array('url' => Kurogo::arrayVal($appData, 'url'), 'version' => Kurogo::arrayVal($appData, 'version'));
}
}
}
$this->setResponse($response);
$this->setResponseVersion($version);
break;
case 'setcontext':
$context = $this->getArg('context');
$response = Kurogo::sharedInstance()->setUserContext($context);
$this->setResponse($response);
$this->setResponseVersion(1);
break;
case 'classify':
$userAgent = $this->getArg('useragent');
if (!$userAgent) {
throw new KurogoException("useragent parameter not specified");
}
$response = Kurogo::deviceClassifier()->classifyUserAgent($userAgent);
$this->setResponse($response);
$this->setResponseVersion(1);
break;
default:
$this->invalidCommand();
break;
}
}
示例14: deviceClassifier
public static function deviceClassifier() {
return Kurogo::sharedInstance()->getDeviceClassifier();
}
示例15: initializeForCommand
public function initializeForCommand()
{
$this->requiresAdmin();
switch ($this->command) {
case 'checkversion':
$current = Kurogo::sharedInstance()->checkCurrentVersion();
Kurogo::log(LOG_INFO, sprintf("Checking version. This site: %s Current Kurogo Version: %s", $current, KUROGO_VERSION), 'admin');
$uptodate = version_compare(KUROGO_VERSION, $current, ">=");
$messageKey = $uptodate ? 'KUROGO_VERSION_MESSAGE_UPTODATE' : 'KUROGO_VERSION_MESSAGE_NOTUPDATED';
$data = array('current' => $current, 'local' => KUROGO_VERSION, 'uptodate' => $uptodate, 'message' => $this->getLocalizedString($messageKey, $current, KUROGO_VERSION));
$this->setResponse($data);
$this->setResponseVersion(1);
break;
case 'getlocalizedstring':
$key = $this->getArg('key');
$data = array();
if (is_array($key)) {
foreach ($key as $k) {
$data[$k] = $this->getLocalizedString($k);
}
} else {
$data[$key] = $this->getLocalizedString($key);
}
$this->setResponse($data);
$this->setResponseVersion(1);
break;
case 'clearcaches':
Kurogo::log(LOG_NOTICE, "Clearing Site Caches", 'admin');
$result = Kurogo::sharedInstance()->clearCaches();
if ($result === 0) {
$this->setResponse(true);
$this->setResponseVersion(1);
} else {
$this->throwError(new KurogoError(1, "Error clearing caches", "There was an error ({$result}) clearing the caches"));
}
break;
case 'upload':
$type = $this->getArg('type');
$section = $this->getArg('section', '');
$subsection = null;
switch ($type) {
case 'module':
$moduleID = $this->getArg('module', '');
$module = WebModule::factory($moduleID);
$type = $module;
break;
case 'site':
break;
default:
throw new KurogoConfigurationException("Invalid type {$type}");
}
if (count($_FILES) == 0) {
throw new KurogoException("No files uploaded");
}
foreach ($_FILES as $key => $uploadData) {
$this->uploadFile($type, $section, $subsection, $key, $uploadData);
}
$this->setResponseVersion(1);
$this->setResponse(true);
break;
case 'getconfigsections':
$type = $this->getArg('type');
switch ($type) {
case 'module':
$moduleID = $this->getArg('module', '');
$module = WebModule::factory($moduleID);
$sections = $module->getModuleAdminSections();
break;
case 'site':
throw new KurogoConfigurationException("getconfigsections for site not handled yet");
}
$this->setResponse($sections);
$this->setResponseVersion(1);
break;
case 'getconfigdata':
$type = $this->getArg('type');
$section = $this->getArg('section', '');
switch ($type) {
case 'module':
$moduleID = $this->getArg('module', '');
$module = WebModule::factory($moduleID);
$adminData = $this->getAdminData($module, $section);
break;
case 'site':
$adminData = $this->getAdminData('site', $section);
break;
}
$this->setResponse($adminData);
$this->setResponseVersion(1);
break;
case 'setconfigdata':
$type = $this->getArg('type');
$data = $this->getArg('data', array());
$section = $this->getArg('section', '');
$subsection = null;
if (empty($data)) {
$data = array();
} elseif (!is_array($data)) {
throw new KurogoConfigurationException("Invalid data for {$type} {$section}");
}
//.........这里部分代码省略.........