本文整理汇总了PHP中Kurogo::getOptionalSiteVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo::getOptionalSiteVar方法的具体用法?PHP Kurogo::getOptionalSiteVar怎么用?PHP Kurogo::getOptionalSiteVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kurogo
的用法示例。
在下文中一共展示了Kurogo::getOptionalSiteVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
示例2: getMinifyGroupsConfig
function getMinifyGroupsConfig()
{
$minifyConfig = array();
$key = $_GET['g'];
//
// 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));
$config = array('include' => 'all', 'files' => array(THEME_DIR . $path, SITE_APP_DIR . $path, SHARED_APP_DIR . $path, APP_DIR . $path));
return array($key => buildFileList($config));
}
//
// Page request
//
$pageOnly = isset($_GET['pageOnly']) && $_GET['pageOnly'];
// 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}";
if ($configModule) {
$cacheName .= "-{$configModule}";
}
if ($pageOnly) {
$cacheName .= "-pageOnly";
}
if ($cache->isFresh($cacheName)) {
$minifyConfig = $cache->read($cacheName);
} else {
$dirs = array(APP_DIR, SHARED_APP_DIR, SITE_APP_DIR, THEME_DIR);
if ($pageOnly || ($pagetype == 'tablet' || $platform == 'computer') && in_array($module, array('info', 'admin'))) {
// Info module does not inherit from common files
$subDirs = array('/modules/' . $module);
} else {
$subDirs = array('/common', '/modules/' . $module);
}
if ($configModule) {
$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.ini
if ($ext == 'css') {
$themeVarsFile = realpath_exists(THEME_DIR . '/config.ini');
if ($themeVarsFile) {
$minifyConfig[$key][] = new Minify_Source(array('id' => 'themeConfigModTimeChecker', 'getContentFunc' => 'minifyThemeConfigModTimeCheckerContent', 'minifier' => '', 'contentType' => Minify::TYPE_CSS, 'lastModified' => filemtime($themeVarsFile)));
}
}
//error_log(__FUNCTION__."($pagetype-$platform-$browser) returning: ".print_r($minifyConfig, true));
return $minifyConfig;
}
示例3: init
protected function init($page = '', $args = array())
{
if (!Kurogo::getSiteVar('PRODUCTION_ERROR_HANDLER_ENABLED')) {
set_exception_handler("exceptionHandlerForError");
}
$this->pagetype = Kurogo::deviceClassifier()->getPagetype();
$this->platform = Kurogo::deviceClassifier()->getPlatform();
$this->page = 'index';
$this->setTemplatePage($this->page, $this->id);
$this->args = $args;
$this->logView = Kurogo::getOptionalSiteVar('STATS_ENABLED', true) ? true : false;
try {
$this->moduleName = $this->getOptionalModuleVar('title', 'Error', 'module');
} catch (KurogoConfigurationException $e) {
}
return;
}
示例4: migrateData
public function migrateData($updateSummaryOnly = false)
{
$this->out("Beginning Migration");
if ($table = Kurogo::getOptionalSiteVar("KUROGO_STATS_TABLE", "")) {
$this->out("Using table {$table}");
$this->out("Analyzing data.", false);
$day = KurogoStats::getStartDate($table);
$this->out(".", false);
$endDay = KurogoStats::getLastDate($table);
$this->out(".", false);
$totalRows = KurogoStats::getTotalRows($table);
$totalNumberOfDays = floor((strtotime($endDay) - strtotime($day)) / (60 * 60 * 24));
$this->out(".", false);
$this->out("Done.");
$this->out("Migrating data from {$day} to {$endDay}");
$this->out("Total Number of Days: {$totalNumberOfDays}");
$this->out("Total Number of Rows: " . number_format($totalRows));
$this->out("");
$startTime = microtime(true);
$totalRowsProcessed = 0;
$dayCount = 0;
while (strtotime($day) <= strtotime($endDay)) {
$this->out("Migrating data for {$day}....", false);
$rowsProcessed = KurogoStats::migrateData($table, $day, 50000, $updateSummaryOnly);
$totalRowsProcessed += $rowsProcessed;
$dayCount++;
$this->out("rows found: {$rowsProcessed}", false);
$timeTaken = microtime(true) - $startTime;
$clockTimeTaken = $this->secondsToTime($timeTaken);
$rowsRemaining = $totalRows - $totalRowsProcessed;
$daysRemaining = $totalNumberOfDays - $dayCount;
$pctDone = floor($totalRowsProcessed * 100 / $totalRows);
$this->out("\t Elapsed: {$clockTimeTaken} \t {$daysRemaining} days remaining. " . number_format($rowsRemaining) . " rows remaining. {$pctDone}% complete.");
$dayTimestamp = strtotime($day);
$nextDayTimestamp = strtotime("+1 day", $dayTimestamp);
$day = date("Y-m-d", $nextDayTimestamp);
}
$this->out('All data has been migrated successfully.');
} else {
$this->out('The stats table is not configured.');
}
}
示例5: init
public function init($args)
{
$args['TITLE'] = '';
// set BASE_URL first so parent doesn't complain
$this->isPlaces = Kurogo::getOptionalSiteVar('USE_GOOGLE_PLACES', false, 'maps');
if ($this->isPlaces) {
$args['BASE_URL'] = self::PLACES_BASE_URL;
$this->apiKey = Kurogo::getSiteVar('GOOGLE_PLACES_API_KEY', 'maps');
} else {
$args['BASE_URL'] = self::GEOCODE_BASE_URL;
// the Google Maps license requires that geocode results
// be displayed with a Google Map
$this->staticMapClass = 'GoogleStaticMap';
$this->dynamicMapClass = 'GoogleJSMap';
}
$this->defaultCenter = Kurogo::getSiteVar('DEFAULT_CENTER', 'maps');
// TODO: grab the following from config
// default lat/lon, radius
parent::init($args);
}
示例6: __construct
function __construct($device = null) {
$this->version = intval(Kurogo::getSiteVar('MOBI_SERVICE_VERSION'));
$this->userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if ($device && strlen($device)) {
$this->setDevice($device); // user override of device detection
} elseif (isset($_COOKIE[self::COOKIE_KEY])) {
$this->setDevice($_COOKIE[self::COOKIE_KEY]);
} elseif (isset($_SERVER['HTTP_USER_AGENT'])) {
if ($data = Kurogo::getSiteVar('MOBI_SERVICE_USE_EXTERNAL') ?
$this->detectDeviceExternal($this->userAgent) : $this->detectDeviceInternal($this->userAgent) ) {
if ($data['pagetype']=='tablet' && !Kurogo::getOptionalSiteVar('TABLET_ENABLED', 1)) {
//@TODO make this less hard coded
switch ($data['platform'])
{
case 'android':
$data['pagetype'] = 'compliant';
break;
case 'ipad':
$data['pagetype'] = 'compliant';
$data['platform'] = 'iphone';
break;
}
}
$this->pagetype = $data['pagetype'];
$this->platform = $data['platform'];
$this->certs = $data['supports_certificate'];
$this->setDeviceCookie();
}
}
}
示例7: init
protected function init($page = '', $args = array())
{
if ($page == 'error') {
if (!Kurogo::getSiteVar('PRODUCTION_ERROR_HANDLER_ENABLED')) {
set_exception_handler("exceptionHandlerForError");
}
$this->pagetype = Kurogo::deviceClassifier()->getPagetype();
$this->platform = Kurogo::deviceClassifier()->getPlatform();
$this->browser = Kurogo::deviceClassifier()->getBrowser();
$this->page = 'error';
$this->setTemplatePage($this->page, $this->id);
$this->setArgs($args);
$this->ajaxContentLoad = $this->getArg(self::AJAX_PARAMETER) ? true : false;
$this->logView = Kurogo::getOptionalSiteVar('STATS_ENABLED', true) ? true : false;
try {
$this->moduleName = $this->getOptionalModuleVar('title', 'Error', 'module');
} catch (KurogoConfigurationException $e) {
}
} else {
$this->redirectToModule($this->getHomeModuleID(), 'index');
}
return;
}
示例8: init
public function init($args)
{
// alter args for initializing retriever
if (isset($args['title'])) {
$args['TITLE'] = $args['title'];
}
$this->isPlaces = Kurogo::getOptionalSiteVar('USE_GOOGLE_PLACES', false, 'maps');
if ($this->isPlaces) {
$args['BASE_URL'] = self::PLACES_BASE_URL;
$this->apiKey = Kurogo::getSiteVar('GOOGLE_PLACES_API_KEY', 'maps');
} else {
$args['BASE_URL'] = self::GEOCODE_BASE_URL;
// the Google Maps license requires that geocode results
// be displayed with a Google Map
$this->staticMapClass = 'GoogleStaticMap';
$this->dynamicMapClass = 'GoogleJSMap';
}
$this->defaultCenter = $args['center'];
if (isset($args['NEARBY_THRESHOLD'])) {
$this->defaultRadius = $args['NEARBY_THRESHOLD'];
}
parent::init($args);
$this->retriever->setCacheLifetime(1);
}
示例9: getAdminData
private function getAdminData($type, $section, $subsection = null)
{
if ($type == 'site') {
$configData = $this->getSiteAdminConfig();
$module = $this;
} elseif ($type instanceof Module) {
$configData = $type->getModuleAdminConfig();
$module = $type;
} else {
throw new KurogoConfigurationException("Invalid type {$type}");
}
if (!isset($configData[$section])) {
throw new KurogoConfigurationException("Invalid section {$section}");
}
$sectionData = $configData[$section];
if ($subsection) {
if (!isset($configData[$section]['sections'][$subsection])) {
throw new KurogoConfigurationException("Invalid subsection {$subsection} for section {$section}");
}
$sectionData = $configData[$section]['sections'][$subsection];
}
$sectionData['section'] = $section;
if (isset($sectionData['titleKey'])) {
$sectionData['title'] = $module->getLocalizedString($sectionData['titleKey']);
unset($sectionData['titleKey']);
}
if (isset($sectionData['descriptionKey'])) {
$sectionData['description'] = $module->getLocalizedString($sectionData['descriptionKey']);
unset($sectionData['descriptionKey']);
}
if (isset($sectionData['fieldgroups'])) {
foreach ($sectionData['fieldgroups'] as $fieldgroup => &$fieldgroupData) {
if (isset($fieldgroupData['labelKey'])) {
$fieldgroupData['label'] = $module->getLocalizedString($fieldgroupData['labelKey']);
unset($fieldgroupData['labelKey']);
}
if (isset($fieldgroupData['descriptionKey'])) {
$fieldgroupData['description'] = $module->getLocalizedString($fieldgroupData['descriptionKey']);
unset($fieldgroupData['descriptionKey']);
}
}
}
switch ($sectionData['sectiontype']) {
case 'fields':
foreach ($sectionData['fields'] as $key => &$field) {
if (isset($field['labelKey'])) {
$field['label'] = $module->getLocalizedString($field['labelKey']);
unset($field['labelKey']);
}
if (isset($field['descriptionKey'])) {
$field['description'] = $module->getLocalizedString($field['descriptionKey']);
unset($field['descriptionKey']);
}
if (isset($field['valueMethod'])) {
$field['value'] = call_user_func(array($module, $field['valueMethod']));
unset($field['valueMethod']);
} elseif (isset($field['valueKey'])) {
$field['value'] = $module->getLocalizedString($field['valueKey']);
unset($field['valueKey']);
} elseif ($type == 'site') {
if (isset($field['config'])) {
switch ($field['config']) {
case 'site':
$field['value'] = Kurogo::getOptionalSiteVar($key, '', $field['section']);
break;
case 'strings':
$field['value'] = Kurogo::getOptionalSiteString($key);
break;
default:
throw new KurogoConfigurationException("Unknown config " . $field['config']);
break;
}
}
} elseif (isset($field['config'], $field['section'])) {
$field['value'] = $module->getOptionalModuleVar($key, isset($field['default']) ? $field['default'] : '', $field['section'], $field['config']);
}
switch ($field['type']) {
case 'paragraph':
if (is_array($field['value'])) {
$field['value'] = implode("\n\n", $field['value']);
}
break;
case 'select':
if (isset($field['optionsMethod'])) {
if (is_array($field['optionsMethod'])) {
$field['options'] = call_user_func($field['optionsMethod']);
} else {
$field['options'] = $module->{$field}['optionsMethod']();
}
unset($field['optionsMethod']);
}
if (isset($field['optionsFirst'])) {
$field['options'] = array_merge(array('' => $field['optionsFirst']), $field['options']);
unset($field['optionsFirst']);
}
}
if (isset($field['value'])) {
$value = $this->getUnconstantedValue($field['value'], $constant);
if ($constant) {
$field['value'] = $value;
//.........这里部分代码省略.........
示例10: getLoginModuleID
protected function getLoginModuleID()
{
if (!$this->loginModuleID) {
$this->loginModuleID = Kurogo::getOptionalSiteVar('LOGIN_MODULE', 'login', 'authentication');
}
return $this->loginModuleID;
}
示例11: getHomeModuleID
protected function getHomeModuleID()
{
if (!$this->homeModuleID) {
$this->homeModuleID = Kurogo::getOptionalSiteVar('HOME_MODULE', 'home', 'modules');
}
return $this->homeModuleID;
}
示例12: getLastDateFromSummary
public static function getLastDateFromSummary()
{
$summaryTable = Kurogo::getOptionalSiteVar("KUROGO_STATS_SUMMARY_TABLE", "kurogo_stats_module_v1");
$conn = self::connection();
$sql = "SELECT date(`date`) AS date FROM `{$summaryTable}` GROUP BY 1 ORDER BY 1 DESC LIMIT 1";
if (!($data = $conn->query($sql, array(), db::IGNORE_ERRORS))) {
self::createSummaryTables($summaryTable);
$data = $conn->query($sql);
}
if (!($result = $data->fetch())) {
return false;
}
return $result['date'];
}
示例13: retrieveStats
public static function retrieveStats(KurogoStatsOption $OptionObject)
{
// get data type, group and fields
$type = $OptionObject->getType();
$group = $OptionObject->getGroup();
$fields = $OptionObject->getFields();
switch ($type) {
case 'count':
if (count($fields) == 0) {
$fields[] = "COUNT(*) AS count";
} elseif (count($fields) == 1) {
$fields[] = "COUNT(DISTINCT " . current($fields) . ") AS count";
} else {
throw new Exception("Counting can only include 0 or 1 fields");
}
break;
case 'sum':
if (count($fields) > 1) {
throw new Exception("Sum logging type can only contain 1 field");
}
$fields = array("SUM(" . current($fields) . ") AS sum");
break;
case 'avg':
if (count($fields) > 1) {
throw new Exception("Average logging type can only contain 1 field");
}
$fields = array("AVG(" . current($fields) . ") AS avg");
break;
}
// get the group fields
if ($group) {
$fields = array_unique(array_merge($fields, self::getGroupFields($group)));
}
// build a list of parameters
$filters = array();
$params = array();
foreach ($OptionObject->getFilters() as $filter) {
$filters[] = $filter->getDBString();
$params[] = $filter->getValue();
}
// build the query
$table = Kurogo::getOptionalSiteVar("KUROGO_STATS_TABLE", "kurogo_stats_v1");
$sql = "SELECT " . implode(',', $fields) . " FROM " . $table;
$sql .= $filters ? " WHERE " . implode(' AND ', $filters) : '';
$sql .= $group ? " GROUP BY " . implode(', ', $group) : '';
//what happens where there are more than 1 group?
if (count($group) > 1) {
throw new Exception("Multi groups not functioning");
}
$groupString = implode(',', $group);
if ($type == 'count' && $OptionObject->getSortField() == 'count') {
$dir = $OptionObject->getSortDir() == SORT_ASC ? "ASC" : "DESC";
$sql .= " ORDER BY count {$dir}, {$groupString}";
if ($OptionObject->getLimit()) {
$sql .= " LIMIT " . $OptionObject->getLimit();
}
}
//prime the results as necessary
$result = self::initStatsResult($OptionObject);
//query
$conn = self::connection();
$data = $conn->query($sql, $params);
while ($row = $data->fetch()) {
if ($groupString && isset($row[$groupString])) {
if ($groupString == 'data') {
$result[$row[$groupString]] = array('label' => $row['dataLabel'] ? $row['dataLabel'] : $row[$groupString], $type => $row[$type]);
} else {
$result[$row[$groupString]] = $row[$type];
}
} else {
return $row[$type] ? $row[$type] : 0;
}
}
if ($type == 'count' && $OptionObject->getSortField() == 'count') {
if ($OptionObject->getSortDir() == SORT_ASC) {
asort($result);
} else {
arsort($result);
}
if ($OptionObject->getLimit()) {
$result = array_slice($result, 0, $OptionObject->getLimit(), true);
}
}
return $result;
}
示例14: getServerConfig
public static function getServerConfig($id, $page, $args)
{
$isNative = self::hasNativePlatform();
$staticConfig = array('module' => $id, 'page' => $page, 'ajaxArgs' => WebModule::AJAX_PARAMETER . "=1", 'timeout' => Kurogo::getOptionalSiteVar('WEB_BRIDGE_AJAX_TIMEOUT', 60), 'events' => $isNative);
if (self::forceNativePlatform($pagetype, $platform, $browser)) {
$staticConfig['ajaxArgs'] .= '&' . http_build_query(self::pagetypeAndPlatformToParams($pagetype, $platform, $browser));
}
// configMappings are so that keys used by native side are
// independent of the config keys in the kgoBridge class
$configMappings = json_encode(array('KGO_WEB_BRIDGE_CONFIG_URL' => 'urlPrefix', 'KGO_WEB_BRIDGE_PAGE_ARGS' => 'pageArgs', 'KGO_WEB_BRIDGE_COOKIES' => 'cookies', 'KGO_WEB_BRIDGE_AJAX_CONTENT' => 'ajaxContent', 'KGO_WEB_BRIDGE_GEOLOCATION' => 'geolocation'));
// native bridge variables
$jsInit = '__KGO_WEB_BRIDGE_JAVASCRIPT_INIT__';
$bridgeConfig = '__KGO_WEB_BRIDGE_CONFIG_JSON__';
if (!$isNative) {
// emulate what native bridge would replace variables with
$jsInit = '';
$bridgeConfig = json_encode(array('KGO_WEB_BRIDGE_CONFIG_URL' => rtrim(FULL_URL_PREFIX, '/'), 'KGO_WEB_BRIDGE_PAGE_ARGS' => http_build_query($args)));
}
return array('jsInit' => $jsInit, 'configMappings' => $configMappings, 'staticConfig' => json_encode($staticConfig), 'bridgeConfig' => $bridgeConfig);
}
示例15: buildNativeWebTemplatesForPlatform
public function buildNativeWebTemplatesForPlatform($platform)
{
$pages = array_keys($this->getModuleSections('pages'));
if ($pages) {
$pages = array_diff($pages, array('pane'));
}
if (!$pages) {
throw new KurogoConfigurationException("module does not have any pages defined in pages.ini");
}
$additionalAssets = $this->nativeWebTemplateAssets();
$nativeConfig = $this->getOptionalModuleSection('native_template');
if ($nativeConfig && $nativeConfig['additional_assets']) {
$additionalAssets = array_unique(array_merge($additionalAssets, $nativeConfig['additional_assets']));
}
// Phone version
$rewriter = new KurogoWebBridge($this->configModule, KurogoWebBridge::PAGETYPE_PHONE, $platform, KurogoWebBridge::BROWSER);
$rewriter->saveTemplates($pages, $additionalAssets);
if (Kurogo::getOptionalSiteVar('NATIVE_TABLET_ENABLED', 1)) {
// Tablet version
$rewriter = new KurogoWebBridge($this->configModule, KurogoWebBridge::PAGETYPE_TABLET, $platform, KurogoWebBridge::BROWSER);
$rewriter->saveTemplates($pages, $additionalAssets);
}
}