本文整理汇总了PHP中OW::context方法的典型用法代码示例。如果您正苦于以下问题:PHP OW::context方法的具体用法?PHP OW::context怎么用?PHP OW::context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OW
的用法示例。
在下文中一共展示了OW::context方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detectContext
private static function detectContext()
{
if (self::$context !== null) {
return;
}
if (defined('OW_USE_CONTEXT')) {
switch (true) {
case OW_USE_CONTEXT == 1:
self::$context = self::CONTEXT_DESKTOP;
return;
case OW_USE_CONTEXT == 1 << 1:
self::$context = self::CONTEXT_MOBILE;
return;
case OW_USE_CONTEXT == 1 << 2:
self::$context = self::CONTEXT_API;
return;
}
}
$context = self::CONTEXT_DESKTOP;
try {
$isSmart = UTIL_Browser::isSmartphone();
} catch (Exception $e) {
return;
}
if (defined('OW_CRON')) {
$context = self::CONTEXT_DESKTOP;
} else {
if (self::getSession()->isKeySet(OW_Application::CONTEXT_NAME)) {
$context = self::getSession()->get(OW_Application::CONTEXT_NAME);
} else {
if ($isSmart) {
$context = self::CONTEXT_MOBILE;
}
}
}
if (defined('OW_USE_CONTEXT')) {
if ((OW_USE_CONTEXT & 1 << 1) == 0 && $context == self::CONTEXT_MOBILE) {
$context = self::CONTEXT_DESKTOP;
}
if ((OW_USE_CONTEXT & 1 << 2) == 0 && $context == self::CONTEXT_API) {
$context = self::CONTEXT_DESKTOP;
}
}
self::$context = $context;
}
示例2: detectContext
private static function detectContext()
{
if (self::$context !== null) {
return;
}
if (defined('OW_USE_CONTEXT')) {
switch (true) {
case OW_USE_CONTEXT == 1:
self::$context = self::CONTEXT_DESKTOP;
return;
case OW_USE_CONTEXT == 1 << 1:
self::$context = self::CONTEXT_MOBILE;
return;
case OW_USE_CONTEXT == 1 << 2:
self::$context = self::CONTEXT_API;
return;
}
}
$context = self::CONTEXT_DESKTOP;
try {
$isSmart = UTIL_Browser::isSmartphone();
} catch (Exception $e) {
return;
}
if (defined('OW_CRON')) {
$context = self::CONTEXT_DESKTOP;
} else {
if (self::getSession()->isKeySet(OW_Application::CONTEXT_NAME)) {
$context = self::getSession()->get(OW_Application::CONTEXT_NAME);
} else {
if ($isSmart) {
$context = self::CONTEXT_MOBILE;
}
}
}
if (defined('OW_USE_CONTEXT')) {
if ((OW_USE_CONTEXT & 1 << 1) == 0 && $context == self::CONTEXT_MOBILE) {
$context = self::CONTEXT_DESKTOP;
}
if ((OW_USE_CONTEXT & 1 << 2) == 0 && $context == self::CONTEXT_API) {
$context = self::CONTEXT_DESKTOP;
}
}
if ((bool) OW::getConfig()->getValue('base', 'disable_mobile_context') && $context == self::CONTEXT_MOBILE) {
$context = self::CONTEXT_DESKTOP;
}
//temp API context detection
//TODO remake
$uri = UTIL_Url::getRealRequestUri(OW::getRouter()->getBaseUrl(), $_SERVER['REQUEST_URI']);
if (mb_strstr($uri, '/')) {
if (trim(mb_substr($uri, 0, mb_strpos($uri, '/'))) == 'api') {
$context = self::CONTEXT_API;
}
} else {
if (trim($uri) == 'api') {
$context = self::CONTEXT_API;
}
}
self::$context = $context;
}