本文整理汇总了PHP中CIBlockSection::getSectionCode方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockSection::getSectionCode方法的具体用法?PHP CIBlockSection::getSectionCode怎么用?PHP CIBlockSection::getSectionCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockSection
的用法示例。
在下文中一共展示了CIBlockSection::getSectionCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReplaceDetailUrl
public static function ReplaceDetailUrl($url, $arr, $server_name = false, $arrType = false)
{
/** @global CDatabase $DB */
global $DB;
if ($server_name) {
$url = str_replace("#LANG#", $arr["LANG_DIR"], $url);
if (defined("ADMIN_SECTION") && ADMIN_SECTION === true || !defined("BX_STARTED")) {
static $cache = array();
if (!isset($cache[$arr["LID"]])) {
$db_lang = CLang::GetByID($arr["LID"]);
$arLang = $db_lang->Fetch();
$cache[$arr["LID"]] = $arLang;
}
$arLang = $cache[$arr["LID"]];
$url = str_replace("#SITE_DIR#", $arLang["DIR"], $url);
$url = str_replace("#SERVER_NAME#", $arLang["SERVER_NAME"], $url);
} else {
$url = str_replace("#SITE_DIR#", SITE_DIR, $url);
$url = str_replace("#SERVER_NAME#", SITE_SERVER_NAME, $url);
}
}
if (strpos($url, "#PRODUCT_URL#") !== false) {
$url = str_replace("#PRODUCT_URL#", CIBlock::_GetProductUrl($arr["ID"], $arr["IBLOCK_ID"], $server_name, $arrType), $url);
}
static $arSearch = array("#SITE_DIR#", "#ID#", "#CODE#", "#EXTERNAL_ID#", "#IBLOCK_TYPE_ID#", "#IBLOCK_ID#", "#IBLOCK_CODE#", "#IBLOCK_EXTERNAL_ID#", "#ELEMENT_ID#", "#ELEMENT_CODE#", "#SECTION_ID#", "#SECTION_CODE#", "#SECTION_CODE_PATH#");
$arReplace = array($arr["LANG_DIR"], intval($arr["ID"]) > 0 ? intval($arr["ID"]) : "", urlencode(isset($arr["~CODE"]) ? $arr["~CODE"] : $arr["CODE"]), urlencode(isset($arr["~EXTERNAL_ID"]) ? $arr["~EXTERNAL_ID"] : $arr["EXTERNAL_ID"]), urlencode(isset($arr["~IBLOCK_TYPE_ID"]) ? $arr["~IBLOCK_TYPE_ID"] : $arr["IBLOCK_TYPE_ID"]), intval($arr["IBLOCK_ID"]) > 0 ? intval($arr["IBLOCK_ID"]) : "", urlencode(isset($arr["~IBLOCK_CODE"]) ? $arr["~IBLOCK_CODE"] : $arr["IBLOCK_CODE"]), urlencode(isset($arr["~IBLOCK_EXTERNAL_ID"]) ? $arr["~IBLOCK_EXTERNAL_ID"] : $arr["IBLOCK_EXTERNAL_ID"]));
if ($arrType === "E") {
$arReplace[] = intval($arr["ID"]) > 0 ? intval($arr["ID"]) : "";
$arReplace[] = urlencode(isset($arr["~CODE"]) ? $arr["~CODE"] : $arr["CODE"]);
#Deal with symbol codes
$SECTION_ID = intval($arr["IBLOCK_SECTION_ID"]);
$SECTION_CODE = "";
if ($SECTION_ID > 0 && strpos($url, "#SECTION_CODE#") !== false) {
$SECTION_CODE = CIBlockSection::getSectionCode($SECTION_ID);
}
$SECTION_CODE_PATH = "";
if ($SECTION_ID > 0 && strpos($url, "#SECTION_CODE_PATH#") !== false) {
$SECTION_CODE_PATH = CIBlockSection::getSectionCodePath($SECTION_ID);
}
$arReplace[] = $SECTION_ID > 0 ? $SECTION_ID : "";
$arReplace[] = $SECTION_CODE;
$arReplace[] = $SECTION_CODE_PATH;
} elseif ($arrType === "S") {
$SECTION_ID = intval($arr["ID"]);
$SECTION_CODE_PATH = "";
if ($SECTION_ID > 0 && strpos($url, "#SECTION_CODE_PATH#") !== false) {
$SECTION_CODE_PATH = CIBlockSection::getSectionCodePath($SECTION_ID);
}
$arReplace[] = "";
$arReplace[] = "";
$arReplace[] = $SECTION_ID > 0 ? $SECTION_ID : "";
$arReplace[] = urlencode(isset($arr["~CODE"]) ? $arr["~CODE"] : $arr["CODE"]);
$arReplace[] = $SECTION_CODE_PATH;
} else {
$arReplace[] = intval($arr["ELEMENT_ID"]) > 0 ? intval($arr["ELEMENT_ID"]) : "";
$arReplace[] = urlencode(isset($arr["~ELEMENT_CODE"]) ? $arr["~ELEMENT_CODE"] : $arr["ELEMENT_CODE"]);
$arReplace[] = intval($arr["IBLOCK_SECTION_ID"]) > 0 ? intval($arr["IBLOCK_SECTION_ID"]) : "";
$arReplace[] = urlencode(isset($arr["~SECTION_CODE"]) ? $arr["~SECTION_CODE"] : $arr["SECTION_CODE"]);
$arReplace[] = "";
}
$url = str_replace($arSearch, $arReplace, $url);
return preg_replace("'(?<!:)/+'s", "/", $url);
}