function GetRSSText($arIBLOCK, $LIMIT_NUM = false, $LIMIT_DAY = false, $yandex = false) { global $DB; $strRes = ""; $serverName = ""; if (isset($arIBLOCK["SERVER_NAME"]) && strlen($arIBLOCK["SERVER_NAME"]) > 0) { $serverName = $arIBLOCK["SERVER_NAME"]; } if (strlen($serverName) <= 0 && !isset($arIBLOCK["SERVER_NAME"])) { $dbSite = CSite::GetList($b = "sort", $o = "asc", array("LID" => $arIBLOCK["LID"])); if ($arSite = $dbSite->Fetch()) { $serverName = $arSite["SERVER_NAME"]; } } if (strlen($serverName) <= 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com"); } } $strRes .= "<channel>\n"; $strRes .= "<title>" . htmlspecialcharsbx($arIBLOCK["NAME"]) . "</title>\n"; $strRes .= "<link>http://" . $serverName . "</link>\n"; $strRes .= "<description>" . htmlspecialcharsbx($arIBLOCK["DESCRIPTION"]) . "</description>\n"; $strRes .= "<lastBuildDate>" . date("r") . "</lastBuildDate>\n"; $strRes .= "<ttl>" . $arIBLOCK["RSS_TTL"] . "</ttl>\n"; $db_img_arr = CFile::GetFileArray($arIBLOCK["PICTURE"]); if ($db_img_arr) { if (substr($db_img_arr["SRC"], 0, 1) == "/") { $strImage = "http://" . $serverName . $db_img_arr["SRC"]; } else { $strImage = $db_img_arr["SRC"]; } $strRes .= "<image>\n"; $strRes .= "<title>" . htmlspecialcharsbx($arIBLOCK["NAME"]) . "</title>\n"; $strRes .= "<url>" . $strImage . "</url>\n"; $strRes .= "<link>http://" . $serverName . "</link>\n"; $strRes .= "<width>" . $db_img_arr["WIDTH"] . "</width>\n"; $strRes .= "<height>" . $db_img_arr["HEIGHT"] . "</height>\n"; $strRes .= "</image>\n"; } $arNodes = array(); $db_res = $DB->Query("SELECT NODE, NODE_VALUE FROM b_iblock_rss WHERE IBLOCK_ID = " . IntVal($arIBLOCK["ID"])); while ($db_res_arr = $db_res->Fetch()) { $arNodes[$db_res_arr["NODE"]] = $db_res_arr["NODE_VALUE"]; } CTimeZone::Disable(); $strSql = "SELECT DISTINCT BE.*, " . "\t" . $DB->DateToCharFunction("BE.TIMESTAMP_X") . " as TIMESTAMP_X, " . "\t" . $DB->DateToCharFunction("BE.ACTIVE_FROM", "FULL") . " as ACTIVE_FROM, " . "\t" . $DB->DateToCharFunction("BE.ACTIVE_TO", "FULL") . " as ACTIVE_TO, " . "\tL.DIR as LANG_DIR, B.DETAIL_PAGE_URL, B.LIST_PAGE_URL, B.LID, L.SERVER_NAME " . "FROM b_iblock_element BE, b_lang L, b_iblock B " . "\tLEFT JOIN b_iblock_group IBG ON IBG.IBLOCK_ID=B.ID " . "WHERE BE.IBLOCK_ID = B.ID " . "\tAND B.LID = L.LID " . "\tAND IBG.GROUP_ID IN (2) " . "\tAND BE.WF_STATUS_ID = 1 AND BE.WF_PARENT_ELEMENT_ID is null " . "\tAND IBG.PERMISSION>='R' " . "\tAND (IBG.PERMISSION='X' OR B.ACTIVE='Y') " . "\tAND (BE.IBLOCK_ID = " . IntVal($arIBLOCK["ID"]) . ") " . "\tAND ((BE.ACTIVE_TO >= " . $DB->GetNowFunction() . " OR BE.ACTIVE_TO IS NULL) AND (BE.ACTIVE_FROM <= " . $DB->GetNowFunction() . " OR BE.ACTIVE_FROM IS NULL)) " . "\tAND (BE.ACTIVE = 'Y') "; if ($LIMIT_DAY !== false) { $strSql .= " AND (BE.ACTIVE_FROM>=" . $DB->CharToDateFunction($DB->ForSql(date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL")), mktime(date("H"), date("i"), date("s"), date("m"), date("d") - IntVal($LIMIT_DAY), date("Y")))), "FULL") . " OR BE.ACTIVE_FROM IS NULL) "; } $strSql .= "ORDER BY BE.ACTIVE_FROM DESC, BE.SORT ASC "; $res = $DB->Query($strSql); CTimeZone::Enable(); $items = new CIBlockResult($res->result); if ($LIMIT_NUM !== False && IntVal($LIMIT_NUM) > 0) { $items->NavStart($LIMIT_NUM); } while ($arItem = $items->GetNext()) { $props = CIBlockElement::GetProperty($arIBLOCK["ID"], $arItem["ID"], "sort", "asc", array("ACTIVE" => "Y", "NON_EMPTY" => "Y")); $arProps = array(); while ($arProp = $props->Fetch()) { if (strlen($arProp["CODE"]) > 0) { $arProps[$arProp["CODE"]] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => htmlspecialcharsex($arProp["VALUE"])); } else { $arProps[$arProp["ID"]] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => htmlspecialcharsex($arProp["VALUE"])); } } $arLinkProp = $arProps["DOC_LINK"]; $strRes .= "<item>\n"; if (strlen($arNodes["title"]) > 0) { $strRes .= "<title>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["title"], $arProps, $arItem)) . "</title>\n"; } else { $strRes .= "<title>" . htmlspecialcharsbx($arItem["~NAME"]) . "</title>\n"; } if (strlen($arNodes["link"]) > 0) { $strRes .= "<link>" . CIBlockRSS::ExtractProperties($arNodes["link"], $arProps, $arItem) . "</link>\n"; } else { $strRes .= "<link>http://" . $serverName . ($arLinkProp["VALUE"] ? $arLinkProp["VALUE"] : $arItem["DETAIL_PAGE_URL"]) . "</link>\n"; } if (strlen($arNodes["description"]) > 0) { $strRes .= "<description>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["description"], $arProps, $arItem)) . "</description>\n"; } else { $strRes .= "<description>" . ($arItem["PREVIEW_TEXT"] || $yandex ? htmlspecialcharsbx($arItem["PREVIEW_TEXT"]) : htmlspecialcharsbx($arItem["DETAIL_TEXT"])) . "</description>\n"; } if (strlen($arNodes["enclosure"]) > 0) { $strRes .= "<enclosure url=\"" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["enclosure"], $arProps, $arItem)) . "\" length=\"" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["enclosure_length"], $arProps, $arItem)) . "\" type=\"" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["enclosure_type"], $arProps, $arItem)) . "\"/>\n"; } else { $db_img_arr = CFile::GetFileArray($arItem["PREVIEW_PICTURE"]); if ($db_img_arr) { if (substr($db_img_arr["SRC"], 0, 1) == "/") { $strImage = "http://" . $serverName . $db_img_arr["SRC"]; } else { $strImage = $db_img_arr["SRC"]; } $strRes .= "<enclosure url=\"" . $strImage . "\" length=\"" . $db_img_arr["FILE_SIZE"] . "\" type=\"" . $db_img_arr["CONTENT_TYPE"] . "\" width=\"" . $db_img_arr["WIDTH"] . "\" height=\"" . $db_img_arr["HEIGHT"] . "\"/>\n"; } } if (strlen($arNodes["category"]) > 0) { $strRes .= "<category>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["category"], $arProps, $arItem)) . "</category>\n"; } else { $strPath = ""; $nav = CIBlockSection::GetNavChain($arIBLOCK["ID"], $arItem["IBLOCK_SECTION_ID"]); while ($ar_nav = $nav->GetNext()) { $strPath .= $ar_nav["NAME"] . "/"; } if (strlen($strPath) > 0) { $strRes .= "<category>" . htmlspecialcharsbx($strPath) . "</category>\n"; } } if ($yandex) { $strRes .= "<yandex:full-text>" . htmlspecialcharsbx($arItem["DETAIL_TEXT"]) . "</yandex:full-text>\n"; } if (strlen($arNodes["pubDate"]) > 0) { $strRes .= "<pubDate>" . htmlspecialcharsbx(CIBlockRSS::ExtractProperties($arNodes["pubDate"], $arProps, $arItem)) . "</pubDate>\n"; } else { if (strlen($arItem["ACTIVE_FROM"]) > 0) { $strRes .= "<pubDate>" . date("r", MkDateTime($DB->FormatDate($arItem["ACTIVE_FROM"], Clang::GetDateFormat("FULL"), "DD.MM.YYYY H:I:S"), "d.m.Y H:i:s")) . "</pubDate>\n"; } else { $strRes .= "<pubDate>" . date("r") . "</pubDate>\n"; } } $strRes .= "</item>\n"; } $strRes .= "</channel>\n"; return $strRes; }
function GetCatalogProductTable($IBLOCK, $SECT_ID = false, $arOrder = array("sort" => "asc"), $cnt = 0) { return false; $arFilter = array("IBLOCK_ID" => intval($IBLOCK), "ACTIVE" => "Y", "ACTIVE_DATE" => "Y"); if ($SECT_ID !== false) { $arFilter["SECTION_ID"] = intval($SECT_ID); } $res = CCatalogProduct::GetListEx($arOrder, $arFilter); $dbr = new CIBlockResult($res->result); if ($cnt > 0) { $dbr->NavStart($cnt); } return $dbr; }
/** * Returns list of the information blocks of specified $type linked to the specified site * * @param string $lang Site identifier blocks linked to. * @param string $type Information blocks type to get blocks from. * @param array|string|int $arTypesInc Information block ID or CODE or array of IDs or CODEs to get. * @param array|string|int $arTypesExc Information block ID or CODE or array of IDs or CODEs to exclude. * @param array $arOrder Order in which blocks will be returned. * @param int $cnt Maximum count of iblocks to be returned. * @param bool $bCountActive * * @return CIBlockResult * @deprecated No longer used by internal code and not recommended. */ function GetIBlockListLang($lang, $type, $arTypesInc = array(), $arTypesExc = array(), $arOrder = array("SORT" => "ASC"), $cnt = 0, $bCountActive = false) { $arIDsInc = array(); $arCODEsInc = array(); if (is_array($arTypesInc)) { foreach ($arTypesInc as $i) { if (intval($i) > 0) { $arIDsInc[] = $i; } else { $arCODEsInc[] = $i; } } } elseif (intval($arTypesInc) > 0) { $arIDsInc[] = $arTypesInc; } else { $arCODEsInc[] = $arTypesInc; } $arIDsExc = array(); $arCODEsExc = array(); if (is_array($arTypesExc)) { foreach ($arTypesExc as $i) { if (intval($i) > 0) { $arIDsExc[] = $i; } else { $arCODEsExc[] = $i; } } } elseif (intval($arTypesExc) > 0) { $arIDsExc[] = $arTypesExc; } else { $arCODEsExc[] = $arTypesExc; } $res = CIBlock::GetList($arOrder, array("type" => $type, "LID" => $lang, "ACTIVE" => "Y", "CNT_ACTIVE" => $bCountActive ? "Y" : "N", "ID" => $arIDsInc, "CODE" => $arCODEsInc, "!ID" => $arIDsExc, "!CODE" => $arCODEsExc), $bCountActive); $dbr = new CIBlockResult($res); if ($cnt > 0) { $dbr->NavStart($cnt); } return $dbr; }
function GetIBlockListLang($lang, $type, $arTypesInc = array(), $arTypesExc = array(), $arOrder = array("SORT" => "ASC"), $cnt = 0) { if (!is_array($arTypesInc)) { $arTypesInc = array($arTypesInc); } $arIDsInc = array(); $arCODEsInc = array(); foreach ($arTypesInc as $i) { if (IntVal($i) > 0) { $arIDsInc[] = $i; } else { $arCODEsInc[] = $i; } } if (!is_array($arTypesExc)) { $arTypesExc = array($arTypesExc); } $arIDsExc = array(); $arCODEsExc = array(); foreach ($arTypesExc as $i) { if (intval($arTypesExc[$i]) > 0) { $arIDsExc[] = $i; } else { $arCODEsExc[] = $i; } } $res = CIBlock::GetList($arOrder, array("type" => $type, "LID" => $lang, "ACTIVE" => "Y", "ID" => $arIDsInc, "CODE" => $arCODEsInc, "!ID" => $arIDsExc, "!CODE" => $arCODEsExc)); $dbr = new CIBlockResult($res); if ($cnt > 0) { $dbr->NavStart($cnt); } return $dbr; }