本文整理汇总了PHP中Bitrix\Main\Application::getDocumentRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getDocumentRoot方法的具体用法?PHP Application::getDocumentRoot怎么用?PHP Application::getDocumentRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Application
的用法示例。
在下文中一共展示了Application::getDocumentRoot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showTab
public static function showTab($div, $iblockElementInfo)
{
$engineList = array();
if (Option::get('main', 'vendor', '') == '1c_bitrix') {
$engineList[] = array("DIV" => "yandex_direct", "TAB" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT"), "TITLE" => Loc::getMessage("SEO_ADV_YANDEX_DIRECT_TITLE"), "HANDLER" => IO\Path::combine(Application::getDocumentRoot(), BX_ROOT, "/modules/seo/admin/tab/seo_search_yandex_direct.php"));
}
if (count($engineList) > 0) {
$engineTabControl = new \CAdminViewTabControl("engineTabControl", $engineList);
?>
<tr>
<td colspan="2">
<?php
$engineTabControl->begin();
foreach ($engineList as $engineTab) {
$engineTabControl->beginNextTab();
$file = new IO\File($engineTab["HANDLER"]);
if ($file->isExists()) {
require $file->getPath();
}
}
$engineTabControl->end();
?>
</td>
</tr>
<?php
}
}
示例2: modifyDbconn
public static function modifyDbconn($DBHost, $DBName, $DBLogin, $DBPassword)
{
if (strlen($DBHost) <= 0) {
throw new \Bitrix\Main\ArgumentNullException("DBHost");
}
if (strlen($DBName) <= 0) {
throw new \Bitrix\Main\ArgumentNullException("DBName");
}
if (strlen($DBLogin) <= 0) {
throw new \Bitrix\Main\ArgumentNullException("DBLogin");
}
$filename = \Bitrix\Main\Application::getDocumentRoot() . "/bitrix/php_interface/dbconn.php";
$file = new \Bitrix\Main\IO\File($filename);
if (!$file->isExists()) {
return false;
}
$content = file_get_contents($filename);
if (strlen($content) <= 0) {
return false;
}
file_put_contents(\Bitrix\Main\Application::getDocumentRoot() . "/bitrix/php_interface/dbconn.php.bak", $content);
$content = preg_replace('/(\\$DBHost\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBHost . '${4}', $content);
$content = preg_replace('/(\\$DBName\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBName . '${4}', $content);
$content = preg_replace('/(\\$DBLogin\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBLogin . '${4}', $content);
$content = preg_replace('/(\\$DBPassword\\s*=\\s*(\\"|\')+)(.*)((\\"|\')+;)/', '${1}' . $DBPassword . '${4}', $content);
return file_put_contents($filename, $content);
}
示例3: getMap
private static function getMap()
{
if (empty(self::$map)) {
self::$map = (include Application::getDocumentRoot() . "/bitrix/modules/mobileapp/maps/resources.php");
}
return self::$map;
}
示例4: getList
/**
* @param string $dbName
* @return array List of all sites & their params
*/
public static function getList($dbName = false)
{
if (!$dbName) {
$connection = \Bitrix\Main\Application::getConnection();
$dbName = $connection->getDbName();
}
$result = array();
$shellAdapter = new ShellAdapter();
$execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/bx-sites -o json -a list -d " . $dbName);
$sitesData = $shellAdapter->getLastOutput();
if ($execRes) {
$arData = json_decode($sitesData, true);
if (isset($arData["params"])) {
$result = $arData["params"];
}
$rsSite = \Bitrix\Main\SiteTable::getList();
while ($site = $rsSite->fetch()) {
foreach ($result as $siteId => $siteInfo) {
$docRoot = strlen($site["DOC_ROOT"]) > 0 ? $site["DOC_ROOT"] : \Bitrix\Main\Application::getDocumentRoot();
if ($siteInfo["DocumentRoot"] == $docRoot) {
$result[$siteId]["NAME"] = $site["NAME"] . " (" . $site["LID"] . ") ";
} else {
$result[$siteId]["NAME"] = $siteId;
}
}
}
}
return $result;
}
示例5: UnInstallFiles
function UnInstallFiles()
{
$rootDir = Application::getDocumentRoot() . '/' . Application::getPersonalRoot();
$adminGatewayFile = '/admin/ws_tools.php';
unlink($rootDir . $adminGatewayFile);
return true;
}
示例6: UnInstallFiles
public function UnInstallFiles()
{
$files = array('js' => '/js/' . $this->MODULE_ID, 'img' => '/images/' . $this->MODULE_ID, 'request' => '/tools/' . $this->MODULE_ID);
$rootDir = Application::getDocumentRoot() . '/' . ltrim(Application::getPersonalRoot(), '/');
foreach ($files as $file) {
Directory::deleteDirectory($rootDir . $file);
}
}
示例7: setOptions
/**
* @param array $options
*/
public function setOptions(array $options)
{
parent::setOptions($options);
$this->file = new File(Application::getDocumentRoot() . $this->options['path']);
if (!$this->file->isFile()) {
throw new \Shantilab\BxEcho\Exceptions\InvalidFilePathException(Application::getDocumentRoot() . $this->options['path']);
}
}
示例8: getPath
public function getPath($notDocumentRoot = false)
{
$drName = dirname(__DIR__);
if ($notDocumentRoot) {
return str_replace(Application::getDocumentRoot(), '', $drName);
}
return $drName;
}
示例9: GetPath
/**
* @param bool $notDocumentRoot
* @return mixed|string
*/
public function GetPath($notDocumentRoot = false)
{
if ($notDocumentRoot) {
return str_ireplace(Application::getDocumentRoot(), '', dirname(__DIR__));
} else {
return dirname(__DIR__);
}
// текущая папка с полным путем можем узнать с помощью константы __DIR__ а путь то родительского каталога узнаем ф-ей dirname()
}
示例10: saveConfiguration
public function saveConfiguration()
{
$path = \Bitrix\Main\Application::getDocumentRoot() . self::CONFIGURATION_FILE_PATH;
$path = preg_replace("'[\\\\/]+'", "/", $path);
$data = var_export($this->data, true);
if (!is_writable($path)) {
@chmod($path, 0600);
}
file_put_contents($path, "<" . "?php\n\$data=" . $data . ";\n");
}
示例11: __construct
public function __construct($path)
{
if (empty($path)) {
throw new InvalidPathException($path);
}
$this->originalPath = $path;
$this->path = Path::normalize($path);
$this->documentRoot = \Bitrix\Main\Application::getDocumentRoot();
if (empty($this->path)) {
throw new InvalidPathException($path);
}
}
示例12: initialize
public function initialize(array $options)
{
$this->logFile = static::DEFAULT_LOG_FILE;
if (isset($options["file"]) && !empty($options["file"])) {
$this->logFile = $options["file"];
}
$this->logFile = preg_replace("'[\\\\/]+'", "/", $this->logFile);
if (substr($this->logFile, 0, 1) !== "/" && !preg_match("#^[a-z]:/#", $this->logFile)) {
$this->logFile = Main\Application::getDocumentRoot() . "/" . $this->logFile;
}
$this->logFileHistory = $this->logFile . ".old";
$this->maxLogSize = static::MAX_LOG_SIZE;
if (isset($options["log_size"]) && $options["log_size"] > 0) {
$this->maxLogSize = intval($options["log_size"]);
}
}
示例13: __construct
public function __construct($path, $siteId = null)
{
if (empty($path)) {
throw new InvalidPathException($path);
}
$this->originalPath = $path;
$this->path = Path::normalize($path);
if ($siteId === null) {
$this->documentRoot = Main\Application::getDocumentRoot();
} else {
$this->documentRoot = Main\SiteTable::getDocumentRoot($siteId);
}
if (empty($this->path)) {
throw new InvalidPathException($path);
}
}
示例14: getCurrentTemplateId
public static function getCurrentTemplateId($siteId)
{
$cacheFlags = Config\Configuration::getValue("cache_flags");
$ttl = isset($cacheFlags["site_template"]) ? $cacheFlags["site_template"] : 0;
$connection = Application::getConnection();
$sqlHelper = $connection->getSqlHelper();
$field = $connection->getType() === "mysql" ? "`CONDITION`" : "CONDITION";
$path2templates = IO\Path::combine(Application::getDocumentRoot(), Application::getPersonalRoot(), "templates");
if ($ttl === false) {
$sql = "\n\t\t\t\tSELECT " . $field . ", TEMPLATE\n\t\t\t\tFROM b_site_template\n\t\t\t\tWHERE SITE_ID = '" . $sqlHelper->forSql($siteId) . "'\n\t\t\t\tORDER BY IF(LENGTH(" . $field . ") > 0, 1, 2), SORT\n\t\t\t\t";
$recordset = $connection->query($sql);
while ($record = $recordset->fetch()) {
$condition = trim($record["CONDITION"]);
if ($condition != '' && !@eval("return " . $condition . ";")) {
continue;
}
if (IO\Directory::isDirectoryExists($path2templates . "/" . $record["TEMPLATE"])) {
return $record["TEMPLATE"];
}
}
} else {
$managedCache = Application::getInstance()->getManagedCache();
if ($managedCache->read($ttl, "b_site_template")) {
$arSiteTemplateBySite = $managedCache->get("b_site_template");
} else {
$arSiteTemplateBySite = array();
$sql = "\n\t\t\t\t\tSELECT " . $field . ", TEMPLATE, SITE_ID\n\t\t\t\t\tFROM b_site_template\n\t\t\t\t\tWHERE SITE_ID = '" . $sqlHelper->forSql($siteId) . "'\n\t\t\t\t\tORDER BY SITE_ID, IF(LENGTH(" . $field . ") > 0, 1, 2), SORT\n\t\t\t\t\t";
$recordset = $connection->query($sql);
while ($record = $recordset->fetch()) {
$arSiteTemplateBySite[$record['SITE_ID']][] = $record;
}
$managedCache->set("b_site_template", $arSiteTemplateBySite);
}
if (is_array($arSiteTemplateBySite[$siteId])) {
foreach ($arSiteTemplateBySite[$siteId] as $record) {
$condition = trim($record["CONDITION"]);
if ($condition != '' && !@eval("return " . $condition . ";")) {
continue;
}
if (IO\Directory::isDirectoryExists($path2templates . "/" . $record["TEMPLATE"])) {
return $record["TEMPLATE"];
}
}
}
}
return ".default";
}
示例15: __construct
private function __construct()
{
// Initialize Twig template engine
$documentRoot = Application::getDocumentRoot();
$cacheStoragePathOption = \COption::GetOptionString("wlbl.twigrix", "cache_storage_path");
if ($cacheStoragePathOption == "") {
$cacheStoragePath = $documentRoot . BX_PERSONAL_ROOT . "/cache/twig";
} else {
$cacheStoragePath = $documentRoot . $cacheStoragePathOption;
}
$debugModeOptionValue = \COption::GetOptionString("wlbl.twigrix", "debug_mode");
$debugMode = $debugModeOptionValue == "Y" ? true : false;
$loader = new \Twig_Loader_Filesystem($documentRoot);
$this->environment = new \Twig_Environment($loader, ['autoescape' => false, 'cache' => $cacheStoragePath, 'debug' => $debugMode]);
$this->addExtensions();
self::$instance = $this;
}