本文整理汇总了PHP中CBitrixComponent::GetRelativePath方法的典型用法代码示例。如果您正苦于以下问题:PHP CBitrixComponent::GetRelativePath方法的具体用法?PHP CBitrixComponent::GetRelativePath怎么用?PHP CBitrixComponent::GetRelativePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitrixComponent
的用法示例。
在下文中一共展示了CBitrixComponent::GetRelativePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function __SearchTemplate($customTemplatePath = "")
{
$this->__file = "";
$this->__fileAlt = "";
$this->__folder = "";
$this->__hasCSS = null;
$this->__hasJS = null;
$arFolders = array();
$relativePath = $this->__component->GetRelativePath();
$parentRelativePath = "";
$parentTemplateName = "";
$parentComponent =& $this->__component->GetParent();
$defSiteTemplate = $this->__siteTemplate == ".default";
if ($parentComponent && $parentComponent->GetTemplate()) {
$parentRelativePath = $parentComponent->GetRelativePath();
$parentTemplateName = $parentComponent->GetTemplate()->GetName();
if (!$defSiteTemplate) {
$arFolders[] = array("path" => "/local/templates/" . $this->__siteTemplate . "/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true);
}
$arFolders[] = array("path" => "/local/templates/.default/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => ".default");
$arFolders[] = array("path" => "/local/components" . $parentRelativePath . "/templates/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => "");
}
if (!$defSiteTemplate) {
$arFolders[] = array("path" => "/local/templates/" . $this->__siteTemplate . "/components" . $relativePath);
}
$arFolders[] = array("path" => "/local/templates/.default/components" . $relativePath, "site_template" => ".default");
$arFolders[] = array("path" => "/local/components" . $relativePath . "/templates", "site_template" => "");
if ($parentComponent) {
if (!$defSiteTemplate) {
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true);
}
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/.default/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => ".default");
$arFolders[] = array("path" => "/bitrix/components" . $parentRelativePath . "/templates/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => "");
}
if (!$defSiteTemplate) {
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $relativePath);
}
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/.default/components" . $relativePath, "site_template" => ".default");
$arFolders[] = array("path" => "/bitrix/components" . $relativePath . "/templates", "site_template" => "");
if (strlen($customTemplatePath) > 0 && ($templatePageFile = $this->__SearchTemplateFile($customTemplatePath, $this->__page))) {
$this->__fileAlt = $customTemplatePath . "/" . $templatePageFile;
foreach ($arFolders as $folder) {
if (is_dir($_SERVER["DOCUMENT_ROOT"] . $folder["path"] . "/" . $this->__name)) {
$this->__file = $folder["path"] . "/" . $this->__name . "/" . $templatePageFile;
$this->__folder = $folder["path"] . "/" . $this->__name;
}
if (strlen($this->__file) > 0) {
if (isset($folder["site_template"])) {
$this->__siteTemplate = $folder["site_template"];
}
if (isset($folder["in_theme"]) && $folder["in_theme"] === true) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
}
return strlen($this->__file) > 0;
}
static $cache = array();
$cache_id = $relativePath . "|" . $this->__siteTemplate . "|" . $parentRelativePath . "|" . $parentTemplateName . "|" . $this->__page . "|" . $this->__name;
if (!isset($cache[$cache_id])) {
foreach ($arFolders as $folder) {
$fname = $folder["path"] . "/" . $this->__name;
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if (is_dir($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if ($templatePageFile = $this->__SearchTemplateFile($fname, $this->__page)) {
$this->__file = $fname . "/" . $templatePageFile;
$this->__folder = $fname;
$this->__hasCSS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/style.css");
$this->__hasJS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/script.js");
}
} elseif (is_file($_SERVER["DOCUMENT_ROOT"] . $fname)) {
$this->__file = $fname;
if (strpos($this->__name, "/") !== false) {
$this->__folder = $folder["path"] . "/" . substr($this->__name, 0, bxstrrpos($this->__name, "/"));
}
}
} else {
if ($templatePageFile = $this->__SearchTemplateFile($folder["path"], $this->__name)) {
$this->__file = $folder["path"] . "/" . $templatePageFile;
}
}
if ($this->__file != "") {
if (isset($folder["site_template"])) {
$this->__siteTemplate = $folder["site_template"];
}
if (isset($folder["in_theme"]) && $folder["in_theme"] === true) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
}
$cache[$cache_id] = array($this->__folder, $this->__file, $this->__siteTemplate, $this->__templateInTheme, $this->__hasCSS, $this->__hasJS);
} else {
$this->__folder = $cache[$cache_id][0];
$this->__file = $cache[$cache_id][1];
//.........这里部分代码省略.........
示例2: array
function __SearchTemplate($customTemplatePath = "")
{
$this->__file = "";
$this->__fileAlt = "";
$this->__folder = "";
$this->__hasCSS = null;
$this->__hasJS = null;
$arFolders = array();
$relativePath = $this->__component->GetRelativePath();
$parentComponent =& $this->__component->GetParent();
if ($parentComponent) {
$parentRelativePath = $parentComponent->GetRelativePath();
$parentTemplateName = $parentComponent->GetTemplate()->GetName();
$arFolders[] = BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath;
$arFolders[] = BX_PERSONAL_ROOT . "/templates/.default/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath;
$arFolders[] = "/bitrix/components" . $parentRelativePath . "/templates/" . $parentTemplateName . $relativePath;
} else {
$parentRelativePath = "";
$parentTemplateName = "";
}
$arFolders[] = BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $relativePath;
$arFolders[] = BX_PERSONAL_ROOT . "/templates/.default/components" . $relativePath;
$arFolders[] = "/bitrix/components" . $relativePath . "/templates";
if (strlen($customTemplatePath) > 0 && ($templatePageFile = $this->__SearchTemplateFile($customTemplatePath, $this->__page))) {
$this->__fileAlt = $customTemplatePath . "/" . $templatePageFile;
for ($i = 0, $cnt = count($arFolders); $i < $cnt; $i++) {
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $arFolders[$i] . "/" . $this->__name) && is_dir($_SERVER["DOCUMENT_ROOT"] . $arFolders[$i] . "/" . $this->__name)) {
$this->__file = $arFolders[$i] . "/" . $this->__name . "/" . $templatePageFile;
$this->__folder = $arFolders[$i] . "/" . $this->__name;
}
if (StrLen($this->__file) > 0) {
if ($i == 0 || $i == 3) {
} elseif ($i == 1 || $i == 4) {
$this->__siteTemplate = ".default";
} else {
$this->__siteTemplate = "";
}
if ($parentComponent && $i < 3) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
}
return strlen($this->__file) > 0;
}
static $cache;
$cache_id = $relativePath . "|" . $this->__siteTemplate . "|" . $parentRelativePath . "|" . $parentTemplateName . "|" . $this->__page . "|" . $this->__name;
if (!isset($cache)) {
$cache = array();
}
if (!isset($cache[$cache_id])) {
$i = 0;
foreach ($arFolders as $folder) {
$fname = $folder . "/" . $this->__name;
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if (is_dir($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if ($templatePageFile = $this->__SearchTemplateFile($fname, $this->__page)) {
$this->__file = $fname . "/" . $templatePageFile;
$this->__folder = $fname;
$this->__hasCSS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/style.css");
$this->__hasJS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/script.js");
}
} elseif (is_file($_SERVER["DOCUMENT_ROOT"] . $fname)) {
$this->__file = $fname;
if (StrPos($this->__name, "/") !== false) {
$this->__folder = $folder . "/" . SubStr($this->__name, 0, bxstrrpos($this->__name, "/"));
}
}
} else {
if ($templatePageFile = $this->__SearchTemplateFile($folder, $this->__name)) {
$this->__file = $folder . "/" . $templatePageFile;
}
}
if ($this->__file != "") {
if ($i == 0 || $i == 3) {
} elseif ($i == 1 || $i == 4) {
$this->__siteTemplate = ".default";
} else {
$this->__siteTemplate = "";
}
if ($parentComponent && $i < 3) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
$i++;
}
$cache[$cache_id] = array($this->__folder, $this->__file, $this->__siteTemplate, $this->__templateInTheme, $this->__hasCSS, $this->__hasJS);
} else {
$this->__folder = $cache[$cache_id][0];
$this->__file = $cache[$cache_id][1];
$this->__siteTemplate = $cache[$cache_id][2];
$this->__templateInTheme = $cache[$cache_id][3];
$this->__hasCSS = $cache[$cache_id][4];
$this->__hasJS = $cache[$cache_id][5];
}
//.........这里部分代码省略.........