Esempio n. 1
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;
 }
Esempio n. 2
0
 /**
  * получение результатов
  */
 protected function getResult()
 {
     $urlTemplates = array();
     if ($this->arParams['SEF_MODE'] == 'Y') {
         $variables = array();
         $urlTemplates = \CComponentEngine::MakeComponentUrlTemplates($this->defaultUrlTemplates404, $this->arParams['SEF_URL_TEMPLATES']);
         $variableAliases = \CComponentEngine::MakeComponentVariableAliases($this->defaultUrlTemplates404, $this->arParams['VARIABLE_ALIASES']);
         $this->page = \CComponentEngine::ParseComponentPath($this->arParams['SEF_FOLDER'], $urlTemplates, $variables);
         if (strlen($this->page) <= 0) {
             $this->page = 'index';
         }
         \CComponentEngine::InitComponentVariables($this->page, $this->componentVariables, $variableAliases, $variables);
     } else {
         $this->page = 'index';
     }
     $this->arResult = array('FOLDER' => $this->arParams['SEF_FOLDER'], 'URL_TEMPLATES' => $urlTemplates, 'VARIABLES' => $variables, 'ALIASES' => $variableAliases);
 }
Esempio n. 3
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$arDefaultUrlTemplates404 = array("list" => "profile_list.php", "detail" => "profile_detail.php?ID=#ID#");
$arDefaultVariableAliases404 = array();
$arDefaultVariableAliases = array();
$arComponentVariables = array("ID", "del_id");
$componentPage = "";
$arVariables = array();
$this->setFramemode(false);
if ($arParams["SEF_MODE"] == "Y") {
    $arUrlTemplates = CComponentEngine::MakeComponentUrlTemplates($arDefaultUrlTemplates404, $arParams["SEF_URL_TEMPLATES"]);
    $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases404, $arParams["VARIABLE_ALIASES"]);
    $componentPage = CComponentEngine::ParseComponentPath($arParams["SEF_FOLDER"], $arUrlTemplates, $arVariables);
    CComponentEngine::InitComponentVariables($componentPage, $arComponentVariables, $arVariableAliases, $arVariables);
    foreach ($arUrlTemplates as $url => $value) {
        $arResult["PATH_TO_" . ToUpper($url)] = $arParams["SEF_FOLDER"] . $value;
    }
    if ($componentPage != "detail") {
        $componentPage = "list";
    }
    $arResult = array_merge(array("SEF_FOLDER" => $arParams["SEF_FOLDER"], "URL_TEMPLATES" => $arUrlTemplates, "VARIABLES" => $arVariables, "ALIASES" => $arVariableAliases), $arResult);
} else {
    $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases404, $arParams["VARIABLE_ALIASES"]);
    CComponentEngine::InitComponentVariables(false, $arComponentVariables, $arVariableAliases, $arVariables);
    if (IntVal($_REQUEST["ID"]) > 0) {
        $componentPage = "detail";
    } else {
        $componentPage = "list";
Esempio n. 4
0
<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();

$arDefaultVariableAliases = Array(
	"album_id" => "album_id", 
	"photo_id" => "photo_id", 
);

if($arParams["SEF_MODE"] == "Y")
{
	$arUrlTemplates = CComponentEngine::MakeComponentUrlTemplates(array(), $arParams["SEF_URL_TEMPLATES"]);
	$arVariableAliases = CComponentEngine::MakeComponentVariableAliases(array(), $arParams["VARIABLE_ALIASES"]);
	$componentPage = CComponentEngine::ParseComponentPath($arParams["SEF_FOLDER"], $arUrlTemplates, $arVariables);
	CComponentEngine::InitComponentVariables($componentPage, $arComponentVariables, $arVariableAliases, $arVariables);
	$arResult = array(
		"FOLDER" => $arParams["SEF_FOLDER"],
		"URL_TEMPLATES" => $arUrlTemplates, 
		"VARIABLES" => $arVariables, 
		"ALIASES" => $arVariableAliases
	);

}
else
{
	$arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases, $arParams["VARIABLE_ALIASES"]);
	CComponentEngine::InitComponentVariables(false, $arComponentVariables, $arVariableAliases, $arVariables);

	$componentPage = "";

	if(isset($arVariables["album_id"]) && intval($arVariables["album_id"]) > 0) {
		$componentPage = "album";
Esempio n. 5
0
    }
    $arParams['STORAGE'] = \Bitrix\Disk\Storage::loadById((int) $arParams['STORAGE_ID'], array('ROOT_OBJECT'));
}
if (empty($arParams['STORAGE'])) {
    //necessary
    return;
}
if ($arParams['SEF_MODE'] == 'Y') {
    $arVariables = array();
    $engine = new CComponentEngine($this);
    $engine->addGreedyPart("#PATH#");
    $engine->addGreedyPart("#FILE_PATH#");
    $engine->addGreedyPart("#TRASH_PATH#");
    $engine->addGreedyPart("#TRASH_FILE_PATH#");
    $engine->setResolveCallback(array(\Bitrix\Disk\Driver::getInstance()->getUrlManager(), "resolvePathComponentEngine"));
    $arUrlTemplates = CComponentEngine::MakeComponentUrlTemplates($arDefaultUrlTemplates404, isset($arParams["SEF_URL_TEMPLATES"]) ? $arParams["SEF_URL_TEMPLATES"] : array());
    $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases404, isset($arParams["VARIABLE_ALIASES"]) ? $arParams["VARIABLE_ALIASES"] : array());
    $componentPage = $engine->guessComponentPath($arParams["SEF_FOLDER"], $arUrlTemplates, $arVariables);
    if (empty($componentPage) || !array_key_exists($componentPage, $arDefaultUrlTemplates404)) {
        /** @var \Bitrix\Disk\Storage $arParams['STORAGE'] */
        $componentPage = 'folder_list';
        if ($arParams['STORAGE'] instanceof \Bitrix\Disk\Storage) {
            $arVariables = array('STORAGE' => $arParams['STORAGE'], 'FOLDER_ID' => $arParams['STORAGE']->getRootObjectId(), 'RELATIVE_PATH' => '/', 'RELATIVE_ITEMS' => array());
        }
    }
    CComponentEngine::InitComponentVariables($componentPage, $arComponentVariables, $arVariableAliases, $arVariables);
    $arParams['SEF_FOLDER'] = rtrim($arParams['SEF_FOLDER'], '/') . '/';
    foreach ($arUrlTemplates as $url => $value) {
        if (empty($arParams['PATH_TO_' . strtoupper($url)])) {
            $arResult['PATH_TO_' . strtoupper($url)] = $arParams['SEF_FOLDER'] . $value;
        } elseif (is_string($arParams['PATH_TO_' . strtoupper($url)])) {
Esempio n. 6
0
 /**
  * Инициализирует ЧПУ из настроек компонента
  * @return bool
  */
 protected function getSEF_Settings()
 {
     if ($this->arParams['SEF_MODE'] == 'Y') {
         $engine = new \CComponentEngine($this);
         foreach ($this->arParams['GREEDY_PARTS'] as $part) {
             $engine->addGreedyPart($part);
         }
         $this->arUrlTemplates = \CComponentEngine::MakeComponentUrlTemplates(array(), $this->arParams["SEF_URL_TEMPLATES"]);
         $this->arVariableAliases = \CComponentEngine::MakeComponentVariableAliases(array(), $this->arParams["VARIABLE_ALIASES"]);
         $this->componentRoute = $engine->guessComponentPath($this->arParams["SEF_FOLDER"], $this->arUrlTemplates, $this->arVariables);
         $this->parseGreedyPartsVariables();
         if (!$this->componentRoute) {
             if (static::isPathsEqual($this->request->getRequestedPageDirectory(), $this->arParams["SEF_FOLDER"])) {
                 $this->genCallable(true);
                 return true;
             } else {
                 return false;
             }
         } else {
             \CComponentEngine::InitComponentVariables($this->componentRoute, $this->arComponentVariables, $this->arVariableAliases, $this->arVariables);
             //переставляем переменные в том порядке, к вотором они должны попасть в функцию
             $componentParameters = $this->getComponentParameters();
             if (isset($componentParameters['PARAMETERS']['SEF_MODE'][$this->componentRoute]['VARIABLES'])) {
                 $parametersVars = $componentParameters['PARAMETERS']['SEF_MODE'][$this->componentRoute]['VARIABLES'];
                 foreach ($parametersVars as $varName) {
                     if (isset($this->arVariables[$varName])) {
                         $this->componentRouteVariables[] = $this->arVariables[$varName];
                     } else {
                         $this->componentRouteVariables[] = null;
                     }
                 }
             }
             $this->genCallable();
             return true;
         }
     } else {
         $this->genCallable(true);
         return true;
     }
 }