public function __construct($fileName, $settings) { $this->settings = array( 'SITE_ID' => $settings['SITE_ID'], 'PROTOCOL' => $settings['PROTOCOL'] == 'https' ? 'https' : 'http', 'DOMAIN' => $settings['DOMAIN'], ); $site = SiteTable::getRow(array("filter" => array("LID" => $this->settings['SITE_ID']))); $this->siteRoot = Path::combine( SiteTable::getDocumentRoot($this->settings['SITE_ID']), $site['DIR'] ); if(substr($fileName, -strlen(self::FILE_EXT)) != self::FILE_EXT) { $fileName .= self::FILE_EXT; } if($this->partFile == '') { $this->partFile = $fileName; } $this->pathPhysical = null; // hack for object reconstuct during file splitting parent::__construct($this->siteRoot.'/'.$fileName, $this->settings['SITE_ID']); $this->partChanged = $this->isExists() && !$this->isSplitNeeded(); }
private static function saveRules($siteId, array $arUrlRewrite) { $site = SiteTable::getRow(array("filter" => array("LID" => $siteId))); $docRoot = $site["DOC_ROOT"]; if (!empty($docRoot)) { $docRoot = IO\Path::normalize($docRoot); } else { $docRoot = Application::getDocumentRoot(); } $data = var_export($arUrlRewrite, true); IO\File::putFileContents($docRoot . "/urlrewrite.php", "<" . "?php\n\$arUrlRewrite=" . $data . ";\n"); Application::resetAccelerator(); }
public static function getDocumentRoot($siteId = null) { if ($siteId === null) { $context = Application::getInstance()->getContext(); $siteId = $context->getSite(); } if (!isset(self::$documentRootCache[$siteId])) { $ar = SiteTable::getRow(array("filter" => array("LID" => $siteId))); if ($ar && ($docRoot = $ar["DOC_ROOT"]) && strlen($docRoot) > 0) { if (!IO\Path::isAbsolute($docRoot)) { $docRoot = IO\Path::combine(Application::getDocumentRoot(), $docRoot); } self::$documentRootCache[$siteId] = $docRoot; } else { self::$documentRootCache[$siteId] = Application::getDocumentRoot(); } } return self::$documentRootCache[$siteId]; }
protected static function ensureLanguageDefined() { if (empty(self::$languageID)) { $arFilter = array('=LID' => SITE_ID, '=ACTIVE' => 'Y'); if (defined("ADMIN_SECTION")) { $arFilter = array('=DEF' => 'Y', '=ACTIVE' => 'Y'); } self::$languageID = LANGUAGE_ID; $arLang = \Bitrix\Main\SiteTable::getRow(array('filter' => $arFilter, 'select' => array('LANGUAGE_ID'), 'limit' => 1)); if (is_array($arLang) && !empty($arLang['LANGUAGE_ID'])) { self::$languageID = $arLang['LANGUAGE_ID']; } if (empty(self::$languageID)) { self::$languageID = 'en'; } } }