本文整理匯總了PHP中CIBlock::_GetProductUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP CIBlock::_GetProductUrl方法的具體用法?PHP CIBlock::_GetProductUrl怎麽用?PHP CIBlock::_GetProductUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CIBlock
的用法示例。
在下文中一共展示了CIBlock::_GetProductUrl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ReplaceDetailUrl
public static function ReplaceDetailUrl($url, $arr, $server_name = false, $arrType = false)
{
/** @global CDatabase $DB */
global $DB;
static $arSectionCache = array();
static $arSectionPathCache = array();
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_CODE = "";
$SECTION_ID = intval($arr["IBLOCK_SECTION_ID"]);
if ($SECTION_ID > 0 && (strpos($url, "#SECTION_CODE#") !== false || strpos($url, "#SECTION_CODE_PATH#") !== false)) {
if (!array_key_exists($SECTION_ID, $arSectionCache)) {
$res = $DB->Query("SELECT IBLOCK_ID, CODE FROM b_iblock_section WHERE ID = " . $SECTION_ID);
$arSectionCache[$SECTION_ID] = $res->Fetch();
}
if (is_array($arSectionCache[$SECTION_ID])) {
$SECTION_CODE = $arSectionCache[$SECTION_ID]["CODE"];
}
}
$SECTION_CODE_PATH = "";
if ($SECTION_ID > 0 && array_key_exists($SECTION_ID, $arSectionCache) && strpos($url, "#SECTION_CODE_PATH#") !== false) {
if (!array_key_exists($SECTION_ID, $arSectionPathCache)) {
$res = CIBlockSection::GetNavChain($arSectionCache[$SECTION_ID]["IBLOCK_ID"], $SECTION_ID, array("ID", "IBLOCK_SECTION_ID", "CODE"));
while ($a = $res->Fetch()) {
$arSectionPathCache[$SECTION_ID] .= urlencode($a["CODE"]) . "/";
}
}
if (isset($arSectionCache[$SECTION_ID])) {
$SECTION_CODE_PATH = rtrim($arSectionPathCache[$SECTION_ID], "/");
}
}
$arReplace[] = $SECTION_ID > 0 ? $SECTION_ID : "";
$arReplace[] = urlencode($SECTION_CODE);
$arReplace[] = $SECTION_CODE_PATH;
} elseif ($arrType === "S") {
$SECTION_ID = intval($arr["ID"]);
$SECTION_CODE_PATH = "";
if (strpos($url, "#SECTION_CODE_PATH#") !== false && $SECTION_ID > 0) {
if (!array_key_exists($SECTION_ID, $arSectionCache)) {
$res = $DB->Query("SELECT IBLOCK_ID, CODE FROM b_iblock_section WHERE ID = " . $SECTION_ID);
$arSectionCache[$SECTION_ID] = $res->Fetch();
}
if (is_array($arSectionCache[$SECTION_ID])) {
if (!array_key_exists($SECTION_ID, $arSectionPathCache)) {
$res = CIBlockSection::GetNavChain($arSectionCache[$SECTION_ID]["IBLOCK_ID"], $SECTION_ID, array("ID", "IBLOCK_SECTION_ID", "CODE"));
while ($a = $res->Fetch()) {
$arSectionPathCache[$SECTION_ID] .= urlencode($a["CODE"]) . "/";
}
}
if (isset($arSectionCache[$SECTION_ID])) {
$SECTION_CODE_PATH = rtrim($arSectionPathCache[$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);
}
示例2: 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);
}