Ejemplo n.º 1
0
 function GetNext($bTextHtmlAuto = true, $use_tilda = true)
 {
     static $arSectionPathCache = array();
     $res = parent::GetNext($bTextHtmlAuto, $use_tilda);
     if ($res) {
         //Handle List URL for Element, Section or IBlock
         if ($this->strListUrl) {
             $TEMPLATE = $this->strListUrl;
         } elseif (array_key_exists("~LIST_PAGE_URL", $res)) {
             $TEMPLATE = $res["~LIST_PAGE_URL"];
         } elseif (!$use_tilda && array_key_exists("LIST_PAGE_URL", $res)) {
             $TEMPLATE = $res["LIST_PAGE_URL"];
         } else {
             $TEMPLATE = "";
         }
         if ($TEMPLATE) {
             $res_tmp = $res;
             if (intval($res["IBLOCK_ID"]) <= 0 && intval($res["ID"]) > 0) {
                 $res_tmp["IBLOCK_ID"] = $res["ID"];
                 $res_tmp["IBLOCK_CODE"] = $res["CODE"];
                 $res_tmp["IBLOCK_EXTERNAL_ID"] = $res["EXTERNAL_ID"];
                 if ($use_tilda) {
                     $res_tmp["~IBLOCK_ID"] = $res["~ID"];
                     $res_tmp["~IBLOCK_CODE"] = $res["~CODE"];
                     $res_tmp["~IBLOCK_EXTERNAL_ID"] = $res["~EXTERNAL_ID"];
                 }
             }
             if ($use_tilda) {
                 $res["~LIST_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res_tmp, true, false);
                 $res["LIST_PAGE_URL"] = htmlspecialcharsbx($res["~LIST_PAGE_URL"]);
             } else {
                 $res["LIST_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res_tmp, true, false);
             }
         }
         //If this is Element or Section then process it's detail and section URLs
         if (strlen($res["IBLOCK_ID"])) {
             if (array_key_exists("GLOBAL_ACTIVE", $res)) {
                 $type = "S";
             } else {
                 $type = "E";
             }
             if ($this->strDetailUrl) {
                 $TEMPLATE = $this->strDetailUrl;
             } elseif (array_key_exists("~DETAIL_PAGE_URL", $res)) {
                 $TEMPLATE = $res["~DETAIL_PAGE_URL"];
             } elseif (!$use_tilda && array_key_exists("DETAIL_PAGE_URL", $res)) {
                 $TEMPLATE = $res["DETAIL_PAGE_URL"];
             } else {
                 $TEMPLATE = "";
             }
             if ($TEMPLATE) {
                 if ($this->arSectionContext) {
                     $TEMPLATE = str_replace("#SECTION_ID#", $this->arSectionContext["ID"], $TEMPLATE);
                     $TEMPLATE = str_replace("#SECTION_CODE#", $this->arSectionContext["CODE"], $TEMPLATE);
                     if ($this->arSectionContext["ID"] > 0 && $this->arSectionContext["IBLOCK_ID"] > 0 && strpos($TEMPLATE, "#SECTION_CODE_PATH#") !== false) {
                         if (!array_key_exists($this->arSectionContext["ID"], $arSectionPathCache)) {
                             $rs = CIBlockSection::GetNavChain($this->arSectionContext["IBLOCK_ID"], $this->arSectionContext["ID"], array("ID", "IBLOCK_SECTION_ID", "CODE"));
                             while ($a = $rs->Fetch()) {
                                 $arSectionPathCache[$this->arSectionContext["ID"]] .= urlencode($a["CODE"]) . "/";
                             }
                         }
                         if (isset($arSectionPathCache[$this->arSectionContext["ID"]])) {
                             $SECTION_CODE_PATH = rtrim($arSectionPathCache[$this->arSectionContext["ID"]], "/");
                         } else {
                             $SECTION_CODE_PATH = "";
                         }
                         $TEMPLATE = str_replace("#SECTION_CODE_PATH#", $SECTION_CODE_PATH, $TEMPLATE);
                     }
                 }
                 if ($use_tilda) {
                     $res["~DETAIL_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res, true, $type);
                     $res["DETAIL_PAGE_URL"] = htmlspecialcharsbx($res["~DETAIL_PAGE_URL"]);
                 } else {
                     $res["DETAIL_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res, true, $type);
                 }
             }
             if ($this->strSectionUrl) {
                 $TEMPLATE = $this->strSectionUrl;
             } elseif (array_key_exists("~SECTION_PAGE_URL", $res)) {
                 $TEMPLATE = $res["~SECTION_PAGE_URL"];
             } elseif (!$use_tilda && array_key_exists("SECTION_PAGE_URL", $res)) {
                 $TEMPLATE = $res["SECTION_PAGE_URL"];
             } else {
                 $TEMPLATE = "";
             }
             if ($TEMPLATE) {
                 if ($use_tilda) {
                     $res["~SECTION_PAGE_URL"] = CIBlock::ReplaceSectionUrl($TEMPLATE, $res, true, $type);
                     $res["SECTION_PAGE_URL"] = htmlspecialcharsbx($res["~SECTION_PAGE_URL"]);
                 } else {
                     $res["SECTION_PAGE_URL"] = CIBlock::ReplaceSectionUrl($TEMPLATE, $res, true, $type);
                 }
             }
         }
     }
     return $res;
 }