Example #1
0
 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 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;
     }
 }
Example #4
0
 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]);
     }
 }
 public function filter()
 {
     if ($this->getSiteId() == Context::getCurrent()->getSite()) {
         return true;
     } else {
         return false;
     }
 }
Example #6
0
 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();
     }
 }
Example #7
0
 private static function getCurrentLang()
 {
     $context = Context::getCurrent();
     if ($context !== null) {
         return $context->getLanguage();
     }
     return 'en';
 }
Example #8
0
 /**
  * Проверка токена напрямую из запроса
  * @return boolean TRUE - если токен валидный
  */
 public static function validateTokenByPost()
 {
     $token = Context::getCurrent()->getRequest()->getPost("csrf");
     if ($token) {
         return self::validateToken($token);
     }
     self::removeToken();
     return false;
 }
Example #9
0
 /**
  * Преобразует номер старницы и количество показываемых элементов,
  * в свойства '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()];
 }
Example #10
0
 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']);
         }
     }
 }
Example #11
0
 /**
  * Инициализация свойств класса из входных параметров
  */
 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;
         }
     }
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
 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;
 }
Example #14
0
 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));
     }
 }
Example #15
0
 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"]);
     }
 }
Example #16
0
 /**
  * Initializes the navigation from URI.
  */
 public function initFromUri()
 {
     $navParams = array();
     $request = \Bitrix\Main\Context::getCurrent()->getRequest();
     if (($value = $request->getQuery($this->id)) !== null) {
         //parameters are in the QUERY_STRING
         $params = explode("-", $value);
         for ($i = 0, $n = count($params); $i < $n; $i += 2) {
             $navParams[$params[$i]] = $params[$i + 1];
         }
     } else {
         //probably parametrs are in the SEF URI
         $matches = array();
         if (preg_match("'/" . preg_quote($this->id, "'") . "/page-([\\d]|all)+(/size-([\\d]+))?'", $request->getRequestUri(), $matches)) {
             $navParams["page"] = $matches[1];
             if (isset($matches[3])) {
                 $navParams["size"] = $matches[3];
             }
         }
     }
     if (isset($navParams["size"])) {
         //set page size from user request
         if (in_array($navParams["size"], $this->pageSizes)) {
             $this->setPageSize((int) $navParams["size"]);
         }
     }
     if (isset($navParams["page"])) {
         if ($navParams["page"] == "all" && $this->allowAll == true) {
             //show all records in one page
             $this->allRecords = true;
         } else {
             //set current page within boundaries
             $currentPage = (int) $navParams["page"];
             if ($currentPage >= 1) {
                 if ($this->recordCount !== null) {
                     $maxPage = $this->getPageCount();
                     if ($currentPage > $maxPage) {
                         $currentPage = $maxPage;
                     }
                 }
                 $this->setCurrentPage($currentPage);
             }
         }
     }
 }
Example #17
0
 protected static function checkAccessPermissions($parameters = array())
 {
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $errors = array();
     $CCrmPerms = new CCrmPerms($GLOBALS['USER']->GetID());
     if ($CCrmPerms->HavePerm('CONFIG', BX_CRM_PERM_NONE, 'WRITE')) {
         $errors[] = Loc::getMessage("SALE_CCLI2_CRM_MODULE_WRITE_ACCESS_DENIED");
     }
     if (!LocationHelper::checkLocationEnabled()) {
         $errors[] = 'Locations were disabled or data has not been converted';
     }
     if ($parameters['CHECK_CSRF']) {
         $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList();
         if (!strlen($post['csrf']) || bitrix_sessid() != $post['csrf']) {
             $errors[] = 'CSRF token is not valid';
         }
     }
     return $errors;
 }
Example #18
0
 /**
  * Sets isEnable property value
  * @param bool $isEnable
  */
 public static function setEnable($isEnable = true)
 {
     if ($isEnable && !self::$isEnable) {
         self::$onBeforeHandleKey = AddEventHandler("main", "OnBeforeEndBufferContent", array(__CLASS__, "OnBeforeEndBufferContent"));
         self::$onHandleKey = AddEventHandler("main", "OnEndBufferContent", array(__CLASS__, "OnEndBufferContent"));
         self::$isEnable = true;
         \CJSCore::init(array("fc"), false);
         $actionType = \Bitrix\Main\Context::getCurrent()->getServer()->get("HTTP_BX_ACTION_TYPE");
         if ($actionType == "get_dynamic") {
             //Is it the background request?
             self::$isBackgroundRequest = true;
         }
     } elseif (!$isEnable && self::$isEnable) {
         if (self::$onBeforeHandleKey >= 0) {
             RemoveEventHandler("main", "OnBeforeEndBufferContent", self::$onBeforeHandleKey);
         }
         if (self::$onBeforeHandleKey >= 0) {
             RemoveEventHandler("main", "OnEndBufferContent", self::$onHandleKey);
         }
         self::$isEnable = false;
     }
 }
Example #19
0
 /**
  * Start Component
  */
 public function executeComponent()
 {
     global $APPLICATION;
     $context = Main\Context::getCurrent();
     // mark usage
     $lastUsage = Main\Config\Option::get('main', 'rcm_component_usage', 0);
     if ($lastUsage == 0 || time() - $lastUsage > 3600) {
         Main\Config\Option::set('main', 'rcm_component_usage', time());
     }
     // execute
     try {
         $this->checkModules();
     } catch (SystemException $e) {
         ShowError($e->getMessage());
         return;
     }
     $this->processRequest();
     // define what to do and check cache
     $this->rcmParams = $this->getServiceRequestParamsByType($this->arParams['RCM_TYPE']);
     $showByIds = $context->getServer()->getRequestMethod() == 'POST' && $context->getRequest()->getPost('rcm') == 'yes';
     if (!$showByIds) {
         // check if ids are already in cache
         try {
             if (!$this->extractDataFromCache()) {
                 // echo js for requesting items from recommendation service
                 $this->arResult['REQUEST_ITEMS'] = true;
                 $this->arResult['RCM_PARAMS'] = $this->rcmParams;
                 $this->arResult['RCM_TEMPLATE'] = $this->getTemplateName();
                 // abort cache, we will write it on next request with the same parameters
                 $this->abortDataCache();
                 // clear cache for ajax call
                 if (Main\Context::getCurrent()->getRequest()->get('clear_cache') == 'Y') {
                     $this->clearResultCache($this->getAdditionalCacheId(), '/' . $this->getSiteId() . '/bitrix/catalog.bigdata.products/common');
                 }
                 $this->includeComponentTemplate();
                 $this->setResultCacheKeys(array());
             }
             // show cache and die
             return;
         } catch (SystemException $e) {
             $this->abortDataCache();
             if ($this->isAjax()) {
                 $APPLICATION->restartBuffer();
                 echo CUtil::PhpToJSObject(array('STATUS' => 'ERROR', 'MESSAGE' => $e->getMessage()));
                 die;
             }
             ShowError($e->getMessage());
         }
     }
     if ($showByIds) {
         // we have an ajax query to get items html
         // and there was no cache
         $ajaxItemIds = $context->getRequest()->get('AJAX_ITEMS');
         if (!empty($ajaxItemIds) && is_array($ajaxItemIds)) {
             $this->ajaxItemsIds = $ajaxItemIds;
         } else {
             // show something
             $this->ajaxItemsIds = null;
             // last viewed will be shown
         }
         // draw products with collected ids
         $this->prepareData();
         $this->formatResult();
     }
     if (!$this->extractDataFromCache()) {
         $this->setResultCacheKeys(array());
         $this->includeComponentTemplate();
     }
 }
Example #20
0
 /**
  * Constructor Controller.
  */
 public function __construct()
 {
     $this->errorCollection = new ErrorCollection();
     $this->request = Context::getCurrent()->getRequest();
     $this->init();
 }
Example #21
0
 public function initCache($TTL, $uniqueString, $initDir = false, $baseDir = "cache")
 {
     if ($initDir === false) {
         $request = Main\Context::getCurrent()->getRequest();
         $initDir = $request->getRequestedPageDirectory();
     }
     $personalRoot = Main\Application::getPersonalRoot();
     $this->baseDir = $personalRoot . "/" . $baseDir . "/";
     $this->initDir = $initDir;
     $this->filename = "/" . $this->getPath($uniqueString);
     $this->TTL = $TTL;
     $this->uniqueString = $uniqueString;
     $this->vars = false;
     if ($TTL <= 0) {
         return false;
     }
     if (static::shouldClearCache()) {
         return false;
     }
     $arAllVars = array("CONTENT" => "", "VARS" => "");
     if (!$this->cacheEngine->read($arAllVars, $this->baseDir, $this->initDir, $this->filename, $this->TTL)) {
         return false;
     }
     if (static::$showCacheStat) {
         $read = 0;
         $path = '';
         if ($this->cacheEngine instanceof ICacheEngineStat) {
             $read = $this->cacheEngine->getReadBytes();
             $path = $this->cacheEngine->getCachePath();
         } elseif ($this->cacheEngine instanceof \ICacheBackend) {
             /** @noinspection PhpUndefinedFieldInspection */
             $read = $this->cacheEngine->read;
             /** @noinspection PhpUndefinedFieldInspection */
             $path = $this->cacheEngine->path;
         }
         Diag\CacheTracker::addCacheStatBytes($read);
         Diag\CacheTracker::add($read, $path, $this->baseDir, $this->initDir, $this->filename, "R");
     }
     $this->content = $arAllVars["CONTENT"];
     $this->vars = $arAllVars["VARS"];
     return true;
 }
Example #22
0
 protected function getPost($key = "", $checkPost = true)
 {
     static $request = false;
     if ($key === true || $key === false) {
         $checkPost = $key;
         $key = "";
     }
     $checkPost = $checkPost === true ? "postAndGet" : "onlyGet";
     if ($request === false) {
         $req = \Bitrix\Main\Context::getCurrent()->getRequest();
         $request = array("onlyGet" => $req->getQueryList()->toArray(), "postAndGet" => array_merge($req->getQueryList()->toArray(), $req->getPostList()->toArray()));
     }
     $post = $request[$checkPost];
     if ($key == "") {
         return array_key_exists(self::INFO_NAME, $post) ? $post[self::INFO_NAME] : false;
     } else {
         if (array_key_exists(self::INFO_NAME, $post) && array_key_exists($key, $post[self::INFO_NAME])) {
             return $post[self::INFO_NAME][$key];
         }
     }
     return false;
 }
Example #23
0
	if ($arParams["ADD_SECTIONS_CHAIN"] && !empty($arResult["SECTION"]["PATH"]) && is_array($arResult["SECTION"]["PATH"]))
	{
		foreach($arResult["SECTION"]["PATH"] as $arPath)
		{
			if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "")
				$APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
			else
				$APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);
		}
	}
	if ($arParams["ADD_ELEMENT_CHAIN"])
	{
		if ($arResult["IPROPERTY_VALUES"]["ELEMENT_PAGE_TITLE"] != "")
			$APPLICATION->AddChainItem($arResult["IPROPERTY_VALUES"]["ELEMENT_PAGE_TITLE"]);
		else
			$APPLICATION->AddChainItem($arResult["NAME"]);
	}

	if ($arParams["SET_LAST_MODIFIED"] && $arResult["TIMESTAMP_X"])
	{
		Context::getCurrent()->getResponse()->setLastModified(DateTime::createFromUserTime($arResult["TIMESTAMP_X"]));
	}

	return $arResult["ID"];
}
else
{
	return 0;
}
?>
 /**
  * @return string
  */
 public static function getDatetimeExpressionTemplate()
 {
     if (self::$datetimeTemplate === null) {
         $helper = Application::getConnection()->getSqlHelper();
         $format = Context::getCurrent()->getCulture()->getDateTimeFormat();
         $datetimeFieldName = '#FIELD#';
         $datetimeField = $datetimeFieldName;
         if (\CTimeZone::Enabled()) {
             $diff = \CTimeZone::GetOffset();
             if ($diff != 0) {
                 $datetimeField = $helper->addSecondsToDateTime($diff, $datetimeField);
             }
             unset($diff);
         }
         self::$datetimeTemplate = str_replace(array('%', $datetimeFieldName), array('%%', '%1$s'), $helper->formatDate($format, $datetimeField));
         unset($datetimeField, $datetimeFieldName, $format, $helper);
     }
     return self::$datetimeTemplate;
 }
Example #25
0
 public static function money($money, Context\Culture $culture = null)
 {
     if ($culture == null) {
         $culture = \Bitrix\Main\Context::getCurrent()->getCulture();
     }
     return $money;
 }
Example #26
0
            $bCanEdit = false;
        }
        //need fm_lpa for every .php file, even with no php code inside
        if ($bCanEdit && !$USER->CanDoOperation('edit_php') && in_array(GetFileExtension($currentFilePath), GetScriptFileExt()) && !$USER->CanDoFileOperation('fm_lpa', array(SITE_ID, $currentFilePath))) {
            $bCanEdit = false;
        }
        if ($bCanEdit && IsModuleInstalled("fileman") && !($USER->CanDoOperation("fileman_admin_files") && $USER->CanDoOperation("fileman_edit_existent_files"))) {
            $bCanEdit = false;
        }
        if ($bCanEdit) {
            echo $APPLICATION->IncludeStringBefore();
            $BX_GLOBAL_AREA_EDIT_ICON = true;
        }
    }
}
define("START_EXEC_PROLOG_AFTER_2", microtime());
$GLOBALS["BX_STATE"] = "WA";
$APPLICATION->RestartWorkarea(true);
//magically replacing the current file with another one
$event = new Main\Event("main", "OnFileRewrite", array("path" => Main\Context::getCurrent()->getRequest()->getScriptFile()));
$event->send();
foreach ($event->getResults() as $evenResult) {
    if (($result = $evenResult->getParameters()) != '') {
        $file = new Main\IO\File($_SERVER["DOCUMENT_ROOT"] . $result);
        if ($file->isExists()) {
            //only the first result matters
            include $file->getPhysicalPath();
            die;
        }
    }
}
{
	$currentUser = $engine->getCurrentUser();
}
catch(Exception $e)
{
	$currentUser = null;
	$bNeedAuth = true;
}

$bReadOnly = $bNeedAuth;
$bAllowUpdate = !$bNeedAuth;
$bSale = Main\ModuleManager::isModuleInstalled('sale')
	&& Main\ModuleManager::isModuleInstalled('catalog')
	&& Main\Loader::includeModule('currency');

$request = Main\Context::getCurrent()->getRequest();

$back_url = isset($request["back_url"]) ? $request["back_url"] : '';

$campaignId = intval($request["campaign"]);
$elementId = intval($request["element"]);
$ID = intval($request["ID"]);

if($ID > 0)
{
	$dbRes = Adv\YandexBannerTable::getByPrimary($ID);
	$banner = $dbRes->fetch();
	if($banner)
	{
		$campaignId = $banner["CAMPAIGN_ID"];
	}
Example #28
0
    $metaKeywords = \Bitrix\Main\Type\Collection::firstNotEmpty($arResult, $arParams["META_KEYWORDS"], $arResult["IPROPERTY_VALUES"], "SECTION_META_KEYWORDS");
    if (is_array($metaKeywords)) {
        $APPLICATION->SetPageProperty("keywords", implode(" ", $metaKeywords), $arTitleOptions);
    } elseif ($metaKeywords != "") {
        $APPLICATION->SetPageProperty("keywords", $metaKeywords, $arTitleOptions);
    }
}
if ($arParams["SET_META_DESCRIPTION"] === 'Y') {
    $metaDescription = \Bitrix\Main\Type\Collection::firstNotEmpty($arResult, $arParams["META_DESCRIPTION"], $arResult["IPROPERTY_VALUES"], "SECTION_META_DESCRIPTION");
    if (is_array($metaDescription)) {
        $APPLICATION->SetPageProperty("description", implode(" ", $metaDescription), $arTitleOptions);
    } elseif ($metaDescription != "") {
        $APPLICATION->SetPageProperty("description", $metaDescription, $arTitleOptions);
    }
}
if (!empty($arResult['BACKGROUND_IMAGE']) && is_array($arResult['BACKGROUND_IMAGE'])) {
    $APPLICATION->SetPageProperty("backgroundImage", 'style="background-image: url(\'' . $arResult['BACKGROUND_IMAGE']['SRC'] . '\')"');
}
if ($arParams["ADD_SECTIONS_CHAIN"] && isset($arResult["PATH"]) && is_array($arResult["PATH"])) {
    foreach ($arResult["PATH"] as $arPath) {
        if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "") {
            $APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
        } else {
            $APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);
        }
    }
}
if ($arParams["SET_LAST_MODIFIED"] && $arResult["ITEMS_TIMESTAMP_X"]) {
    Context::getCurrent()->getResponse()->setLastModified($arResult["ITEMS_TIMESTAMP_X"]);
}
return $arResult["ID"];
Example #29
0
 /**
  * Returns true if current request was initiated by Ajax.
  *
  * @return boolean
  */
 public static function isAjaxRequest()
 {
     if (self::$isAjaxRequest == null) {
         $actionType = Context::getCurrent()->getServer()->get("HTTP_BX_ACTION_TYPE");
         self::$isAjaxRequest = $actionType == "get_dynamic" || defined("actionType") && constant("actionType") == "get_dynamic";
     }
     return self::$isAjaxRequest;
 }
Example #30
-1
 protected function createTopic()
 {
     $topic = array('TITLE' => $this->entity->getXmlId(), 'TAGS' => '', 'MESSAGE' => $this->entity->getXmlId(), 'AUTHOR_ID' => 0);
     /** @var $request \Bitrix\Main\HttpRequest */
     $request = \Bitrix\Main\Context::getCurrent()->getRequest();
     $post = array_merge($request->getQueryList()->toArray(), $request->getPostList()->toArray());
     $event = new Event("forum", "OnCommentTopicAdd", array($this->entity->getType(), $this->entity->getId(), $post, &$topic));
     $event->send();
     if (strlen($topic["AUTHOR_NAME"]) <= 0) {
         $topic["AUTHOR_NAME"] = $topic["AUTHOR_ID"] <= 0 ? Loc::getMessage("FORUM_USER_SYSTEM") : self::getUserName($topic["AUTHOR_ID"]);
     }
     $topic = array_merge($topic, array("FORUM_ID" => $this->forum["ID"], 'TITLE' => $topic["TITLE"], 'TAGS' => $topic["TAGS"], 'MESSAGE' => $topic["MESSAGE"], "USER_START_ID" => $topic["AUTHOR_ID"], "USER_START_NAME" => $topic["AUTHOR_NAME"], "LAST_POSTER_NAME" => $topic["AUTHOR_NAME"], "XML_ID" => $this->entity->getXmlId(), "APPROVED" => "Y"));
     if (($tid = \CForumTopic::add($topic)) > 0) {
         if ($this->forum["ALLOW_HTML"] != "Y") {
             $topic['MESSAGE'] = strip_tags($topic['MESSAGE']);
         }
         $fields = array("POST_MESSAGE" => $topic['MESSAGE'], "AUTHOR_ID" => $topic["AUTHOR_ID"], "AUTHOR_NAME" => $topic["AUTHOR_NAME"], "FORUM_ID" => $topic["FORUM_ID"], "TOPIC_ID" => $tid, "APPROVED" => $topic["APPROVED"], "NEW_TOPIC" => "Y", "PARAM1" => $this->entity->getType(), "PARAM2" => $this->entity->getId());
         if (\CForumMessage::Add($fields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N")) > 0) {
             $event = new Event("forum", "OnAfterCommentTopicAdd", array($this->entity->getType(), $this->entity->getId(), $tid));
             $event->send();
             self::$topics[$this->entity->getXmlId()] = $topic + array("ID" => $tid);
             return self::$topics[$this->entity->getXmlId()];
         }
         \CForumTopic::Delete($tid);
     }
     $this->errorCollection->add(array(new Error(Loc::getMessage("FORUM_CM_TOPIC_IS_NOT_CREATED"), self::ERROR_PARAMS_TOPIC_ID)));
     return null;
 }