本文整理汇总了PHP中Bitrix\Main\Context类的典型用法代码示例。如果您正苦于以下问题:PHP Context类的具体用法?PHP Context怎么用?PHP Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkSession
public static function checkSession()
{
$request = Main\Context::getCurrent()->getRequest();
if (isset($request[static::URL_PARAM_CAMPAIGN]) && isset($request[static::URL_PARAM_BANNER])) {
$_SESSION['SEO_ADV'] = array("ENGINE" => YandexDirect::ENGINE_ID, "CAMPAIGN_ID" => $request[static::URL_PARAM_CAMPAIGN], "BANNER_ID" => $request[static::URL_PARAM_BANNER]);
}
}
示例2: getTabs
public static function getTabs($iblockElementInfo)
{
$showTab = false;
$request = Context::getCurrent()->getRequest();
if ($iblockElementInfo["ID"] > 0 && (!isset($request['action']) || $request['action'] != 'copy')) {
$showTab = true;
if (Loader::includeModule('catalog')) {
/*
$dbRes = CatalogIblockTable::getList(array(
'filter' => array(
'=IBLOCK_ID' => $iblockElementInfo["IBLOCK"]["ID"],
'!PRODUCT_IBLOCK_ID' => 0
),
'select' => array('IBLOCK_ID'),
));
if($dbRes->fetch())
{
$showTab = false;
}
*/
if (\CCatalogSku::getInfoByOfferIBlock($iblockElementInfo["IBLOCK"]["ID"]) !== false) {
$showTab = false;
}
}
}
return $showTab ? array(array("DIV" => "seo_adv", "SORT" => 4, "TAB" => Loc::getMessage("SEO_ADV_TAB"), "TITLE" => Loc::getMessage("SEO_ADV_TAB_TITLE"))) : null;
}
示例3: onBeforeProlog
public static function onBeforeProlog()
{
$id = Context::getCurrent()->getRequest()->getQuery('bx_sender_conversion_id');
if (is_numeric($id) && $id > 0) {
$_SESSION[self::CLICK_PARAM_NAME] = $id;
}
}
示例4: setPage
/**
* Set type of the page
*/
protected function setPage()
{
$urlTemplates = [];
if ($this->arParams['SEF_MODE'] === 'Y') {
$variables = [];
$urlTemplates = \CComponentEngine::MakeComponentUrlTemplates($this->defaultUrlTemplates404, $this->arParams['SEF_URL_TEMPLATES']);
$variableAliases = \CComponentEngine::MakeComponentVariableAliases($this->defaultUrlTemplates404, $this->arParams['VARIABLE_ALIASES']);
$this->templatePage = \CComponentEngine::ParseComponentPath($this->arParams['SEF_FOLDER'], $urlTemplates, $variables);
if (!$this->templatePage) {
if ($this->arParams['SET_404'] === 'Y') {
$folder404 = str_replace('\\', '/', $this->arParams['SEF_FOLDER']);
if ($folder404 != '/') {
$folder404 = '/' . trim($folder404, "/ \t\n\r\v") . "/";
}
if (substr($folder404, -1) == '/') {
$folder404 .= 'index.php';
}
if ($folder404 != Main\Context::getCurrent()->getRequest()->getRequestedPage()) {
$this->return404();
}
}
$this->templatePage = $this->defaultSefPage;
}
if ($this->isSearchRequest() && $this->arParams['USE_SEARCH'] === 'Y') {
$this->templatePage = 'search';
}
\CComponentEngine::InitComponentVariables($this->templatePage, $this->componentVariables, $variableAliases, $variables);
} else {
$this->templatePage = $this->defaultPage;
}
$this->sefFolder = $this->arParams['SEF_FOLDER'];
$this->urlTemplates = $urlTemplates;
$this->variables = $variables;
$this->variableAliases = $variableAliases;
}
示例5: getCurrentLang
private static function getCurrentLang()
{
$context = Context::getCurrent();
if ($context !== null) {
return $context->getLanguage();
}
return 'en';
}
示例6: filter
public function filter()
{
if ($this->getSiteId() == Context::getCurrent()->getSite()) {
return true;
} else {
return false;
}
}
示例7: onBeforeEndBufferContent
public static function onBeforeEndBufferContent()
{
$server = Context::getCurrent()->getServer();
$ajax = $server->get("HTTP_BX_AJAX");
if (SiteSpeed::isOn() && static::$enabled === true && $ajax === null && (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true)) {
Counter::injectIntoPage();
}
}
示例8: validateTokenByPost
/**
* Проверка токена напрямую из запроса
* @return boolean TRUE - если токен валидный
*/
public static function validateTokenByPost()
{
$token = Context::getCurrent()->getRequest()->getPost("csrf");
if ($token) {
return self::validateToken($token);
}
self::removeToken();
return false;
}
示例9: checkSession
public static function checkSession()
{
$request = Main\Context::getCurrent()->getRequest();
if (isset($request[static::URL_PARAM_CAMPAIGN]) && isset($request[static::URL_PARAM_BANNER])) {
$dbRes = YandexBannerTable::getList(array('filter' => array('=XML_ID' => $request[static::URL_PARAM_BANNER], '=ENGINE.CODE' => YandexDirect::ENGINE_ID), 'select' => array('ID', 'CAMPAIGN_ID')));
$banner = $dbRes->fetch();
if ($banner) {
$_SESSION['SEO_ADV'] = array("ENGINE" => YandexDirect::ENGINE_ID, "CAMPAIGN_ID" => $banner['CAMPAIGN_ID'], "BANNER_ID" => $banner['ID']);
}
}
}
示例10: initProperties
/**
* Инициализация свойств класса из входных параметров
*/
protected function initProperties()
{
$this->request = Context::getCurrent()->getRequest();
foreach ($this->arParams as $name => $value) {
if ($name === "CACHE_TIME") {
$this->cacheTime = (int) $value;
} elseif (property_exists($this, $name)) {
$this->{$name} = is_numeric($value) ? +$value : $value;
}
}
}
示例11: parseRequest
/**
* Преобразует номер старницы и количество показываемых элементов,
* в свойства 'limit' и 'offset'
* @param integer $defaultPageNow номер страницы по умолчанию
* @param integer $defaultPerPage количество записей на странице по умолчанию
* @return array массив с ключами 'limit' и 'offset'
*/
public function parseRequest($defaultPageNow, $defaultPerPage)
{
$pageNow = (int) Context::getCurrent()->getRequest()->getQuery($this->pageNowRequestName);
$perPage = (int) Context::getCurrent()->getRequest()->getQuery($this->limitRequestName);
//
$this->pageNow = $pageNow > 0 ? $pageNow : $defaultPageNow;
$this->limit = $perPage > 0 ? $perPage : $defaultPerPage;
//
$this->init();
return ["limit" => $this->limit, "offset" => $this->getOffset()];
}
示例12: checkScope
/**
* Checks the valid scope for the applicaton.
*
* @return bool
*/
public function checkScope()
{
/** @var Main\HttpRequest $request */
$request = Main\Context::getCurrent()->getRequest();
$realPath = $request->getScriptFile();
foreach ($this->validUrls as $url) {
if (strpos($realPath, $url) === 0) {
return true;
}
}
return false;
}
示例13: getCurrentLang
private static function getCurrentLang()
{
if (self::$currentLang === null) {
$context = Context::getCurrent();
if ($context !== null) {
self::$currentLang = $context->getLanguage();
} else {
self::$currentLang = 'en';
}
}
return self::$currentLang;
}
示例14: catchCatalogOrderPayment
public static function catchCatalogOrderPayment($orderId, $value)
{
if (!static::isOn()) {
return;
}
if ($value == 'Y') {
$data = static::getOrderInfo($orderId);
$data['paid'] = '1';
$data['bx_user_id'] = static::getBxUserId();
$data['domain'] = Context::getCurrent()->getServer()->getHttpHost();
$data['date'] = date(DATE_ISO8601);
CounterDataTable::add(array('TYPE' => 'order_pay', 'DATA' => $data));
}
}
示例15: __construct
private function __construct()
{
global $APPLICATION;
$this->setDeviceWidth($_COOKIE["MOBILE_RESOLUTION_WIDTH"]);
$this->setDeviceHeight($_COOKIE["MOBILE_RESOLUTION_HEIGHT"]);
$this->setScreenCategory($_COOKIE["MOBILE_SCREEN_CATEGORY"]);
$this->setPixelratio($_COOKIE["MOBILE_SCALE"]);
$this->setPgVersion($_COOKIE["PG_VERSION"]);
if (isset($_COOKIE["MOBILE_DEV"]) && $_COOKIE["MOBILE_DEV"] == "Y") {
self::$isDev = true;
}
$this->setDevice($_COOKIE["MOBILE_DEVICE"]);
if ($_COOKIE["IS_WEBRTC_SUPPORTED"] && $_COOKIE["IS_WEBRTC_SUPPORTED"] == "Y") {
$this->setWebRtcSupport(true);
}
if ($_COOKIE["IS_BXSCRIPT_SUPPORTED"] && $_COOKIE["IS_BXSCRIPT_SUPPORTED"] == "Y") {
$this->setBXScriptSupported(true);
}
if ($this->getDevice() == "iPad") {
$this->setScreenCategory("LARGE");
if (intval($this->getPixelRatio()) == 2) {
$this->setDeviceWidth($_COOKIE["MOBILE_RESOLUTION_WIDTH"] / 2);
$this->setDeviceHeight($_COOKIE["MOBILE_RESOLUTION_HEIGHT"] / 2);
}
}
//detecting OS
if (array_key_exists("MOBILE_DEVICE", $_COOKIE)) {
$deviceDetectSource = $_COOKIE["MOBILE_DEVICE"];
} else {
$deviceDetectSource = strtolower(Context::getCurrent()->getServer()->get("HTTP_USER_AGENT"));
}
if (strrpos(ToUpper($deviceDetectSource), "IPHONE") > 0 || strrpos(ToUpper($deviceDetectSource), "IPAD") > 0) {
self::$platform = "ios";
} elseif (strrpos(ToUpper($deviceDetectSource), "ANDROID") > 0 || strrpos(ToUpper($deviceDetectSource), "ANDROID") === 0) {
self::$platform = "android";
}
if (array_key_exists("emulate_platform", $_REQUEST)) {
self::$platform = $_REQUEST["emulate_platform"];
}
if (array_key_exists("MOBILE_API_VERSION", $_COOKIE)) {
self::$apiVersion = intval($_COOKIE["MOBILE_API_VERSION"]);
} elseif ($APPLICATION->get_cookie("MOBILE_APP_VERSION")) {
self::$apiVersion = $APPLICATION->get_cookie("MOBILE_APP_VERSION");
} elseif (array_key_exists("api_version", $_REQUEST)) {
self::$apiVersion = intval($_REQUEST["api_version"]);
}
}