Current Path : /var/www/html/clients/amz.e-nk.ru/reestr/ |
Current File : /var/www/html/clients/amz.e-nk.ru/reestr/section.php~ |
<? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php"); $APPLICATION->SetTitle("Title"); ?><?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?><strong><? global $USER, $APPLICATION; if (CModule::IncludeModule("iblock")): IncludeTemplateLangFile(__FILE__); /************************************************************************* Functions *************************************************************************/ // returns nesting level (depth level) for the specified information block group function CatalogDeep($IBLOCK_ID, $SECTION_ID, $deep) { $max_deep=++$deep; $ll_deep = 0; $rsS = GetIBlockSectionList($IBLOCK_ID, $SECTION_ID); while($arS = $rsS->GetNext()) { $ll_deep = CatalogDeep($IBLOCK_ID,$arS["ID"],$deep); if ($ll_deep >$max_deep) $max_deep = $ll_deep; } return $max_deep; } // returns maximum nesting level (depth level) for the specified information block type function GetMaxDeep($IBLOCK_TYPE) { $max_deep = 0; $l_deep = 0; $iblocks = GetIBlockList($IBLOCK_TYPE); if($arIBlock = $iblocks->GetNext()) { do { $l_deep = CatalogDeep($arIBlock["ID"],0,1); if ( $l_deep > $max_deep) $max_deep = $l_deep; } while($arIBlock = $iblocks->GetNext()); } return $max_deep; } // build recurcive tree of the groups function ShowSectionsTree($IBLOCK_ID, $SECTION_ID, $deep, $max_deep) { global $ID, $APPLICATION; static $HTML; $deep++; $s_style ="style=\"padding-left:3px\""; $rsS = GetIBlockSectionListWithCnt($IBLOCK_ID, $SECTION_ID, Array( "sort"=>"asc")); while($arS = $rsS->GetNext()) { $s_url = $APPLICATION->GetCurPage()."?SECTION_ID=".$arS["ID"]; $str ="<tr valign=\"middle\">"; for ($i=1;$i<$deep;$i++) { $str .= ($i<$deep-1) ? "<td><font class=tablebodytext> </font></td>" : "<td><img height=13 src=/bitrix/templates/demo/images/right_down_arrow.gif width=17 border=0></td>"; } $colspan = $max_deep - $deep; if ($arS["ID"] == $ID) { $str.= sprintf("<td width=100%% colspan=%d><font class=\"text\"><div %s><b><a class=\"tablebodylink\" href=\"%s\">%s</a></b> (%d)</div></font></td></tr>",$colspan, $s_style, $s_url, $arS["NAME"],$arS["ELEMENT_CNT"]); } else { $str.= sprintf("<td width=100%% colspan=%d><font class=\"text\"><div %s><a class=\"tablebodylink\" href=\"%s\">%s</a> (%d)</div></font></td></tr>",$colspan, $s_style, $s_url, $arS["NAME"],$arS["ELEMENT_CNT"]); } $HTML .= $str; ShowSectionsTree($IBLOCK_ID, $arS["ID"], $deep, $max_deep); } return $HTML; } /************************************************************************* Processing of the received parameters *************************************************************************/ global $$FILTER_NAME; $arrFilter = ${$FILTER_NAME}; $filter_set = count($arrFilter)>0 ? "Y" : "N"; $CACHE_FILTER = ($CACHE_FILTER=="Y") ? "Y" : "N"; if ($CACHE_FILTER=="N" && count($arrFilter)>0) $CACHE_TIME = 0; $arrPROPERTY_CODE = is_array($arrPROPERTY_CODE) ? $arrPROPERTY_CODE : array(); if (!(CModule::IncludeModule("sale") && CModule::IncludeModule("catalog"))) $PRICE_CODE = ""; /************************************************************************* Processing of the Buy link *************************************************************************/ if (($_REQUEST["action"] == "ADD_TO_BASKET" || $_REQUEST["action"] == "BUY") && IntVal($_REQUEST["price_id"])>0) { if ($_REQUEST["link"]=="N") $arRewriteFields = array("DETAIL_PAGE_URL"=>""); Add2Basket($_REQUEST["price_id"], 1, $arRewriteFields); if ($_REQUEST["action"] == "BUY") LocalRedirect($BASKET_URL); else LocalRedirect($APPLICATION->GetCurPageParam("", array("price_id", "action", "link"))); } /************************************************************************* Work with cache *************************************************************************/ $obCache = new CPHPCache; $CACHE_ID = __FILE__.md5(serialize($arParams).$USER->GetGroups().CDBResult::NavStringForCache($PAGE_ELEMENT_COUNT)); if($obCache->InitCache($CACHE_TIME, $CACHE_ID, "/")) { $arVars = $obCache->GetVars(); $SECTION_ID = $arVars["SECTION_ID"]; $IBLOCK_ID = $arVars["IBLOCK_ID"]; $ELEMENT_NAME = $arVars["ELEMENT_NAME"]; $IBLOCK_TYPE = $arVars["IBLOCK_TYPE"]; $arrPath = $arVars["arrPath"]; } else { $arSection = GetIBlockSection($SECTION_ID); $SECTION_ID = $arSection["ID"]; $IBLOCK_ID = $arSection["IBLOCK_ID"]; $arIBlock = GetIBlock($IBLOCK_ID); $IBLOCK_TYPE = $arIBlock["IBLOCK_TYPE_ID"]; $arrPath = array(); $rsPath = GetIBlockSectionPath($IBLOCK_ID, $SECTION_ID); while($arPath=$rsPath->GetNext()) $arrPath[] = array("ID" => $arPath["ID"], "NAME" => $arPath["NAME"]); $arIblockType = CIBlockType::GetByIDLang($IBLOCK_TYPE, LANGUAGE_ID); $ELEMENT_NAME = $arIblockType["ELEMENT_NAME"]; } if (intval($SECTION_ID) > 0): CIBlock::ShowPanel($IBLOCK_ID, 0, $SECTION_ID, $IBLOCK_TYPE); if (is_array($arrPath)) { while(list($key, $arS) = each($arrPath)) { if ($SECTION_ID==$arS["ID"]) $SECTION_NAME = $arS["NAME"]; $APPLICATION->AddChainItem($arS["NAME"], $APPLICATION->GetCurPage()."?SECTION_ID=".$arS["ID"]); } } $APPLICATION->SetTitle($SECTION_NAME); if($obCache->StartDataCache()): /**************************************************************** HTML form ****************************************************************/ $arrPrice = ""; // if price type code specified if (strlen($PRICE_CODE)>0 && CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) { $arrPrice = array(); $rsPrice = CCatalogGroup::GetList($v1, $v2, array("NAME" => $PRICE_CODE)); while($arPrice = $rsPrice->Fetch()) $arrPrice[$arPrice["NAME"]] = array("ID" => $arPrice["ID"], "TITLE" => $arPrice["NAME_LANG"]); } else $PRICE_CODE = ""; /************************************ Group tree ************************************/ $HTML = ShowSectionsTree($IBLOCK_ID, $SECTION_ID, 1, GetMaxDeep($IBLOCK_TYPE)); if (strlen($HTML)>0): ?><table border="0" cellpadding="1" cellspacing="0" width="100%"><?=$HTML?></table><? endif; /************************************ Element table ************************************/ // list the element fields that will be used in selection $arSelect = array( "ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "PREVIEW_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_PAGE_URL" ); if (is_array($arrPrice) && count($arrPrice)>0) $arSelect[] = "CATALOG_GROUP_".$arrPrice[$PRICE_CODE]["ID"]; // adding values to the filter $arrFilter["ACTIVE"] = "Y"; $arrFilter["SECTION_ID"] = $SECTION_ID; $arrFilter["INCLUDE_SUBSECTIONS"] = "Y"; if ($rsElements = GetIBlockElementListEx($IBLOCK_TYPE, $IBLOCK_ID, false, array("SECTION_ID"=>"ASC", $ELEMENT_SORT_FIELD => $ELEMENT_SORT_ORDER, "ID" => "DESC"), false, $arrFilter, $arSelect)): $rsElements->NavStart($PAGE_ELEMENT_COUNT); $count = intval($rsElements->SelectedRowsCount()); if ($count<=0 && $filter_set=="Y"): echo ShowNote(GetMessage("CATALOG_ELEMENT_NOT_FOUND")); else: ?><p><?echo $rsElements->NavPrint($ELEMENT_NAME)?></p><? if ($obElement = $rsElements->GetNextElement()): $arElement = $obElement->GetFields(); $arProperty = $obElement->GetProperties(); ?> <table cellspacing=0 cellpadding=0 border=0 class="tableborder" width="100%"> <tr> <td width="100%"> <? do{ $arElement = $obElement->GetFields(); $arProperty = $obElement->GetProperties(); $link = "N"; // flag shows if element has or not detailed description ?> <? // if (is_array($arrPROPERTY_CODE) && count($arrPROPERTY_CODE)>0): // reset($arrPROPERTY_CODE); ?> <table width=100% cellspacing=0 cellpadding=0> <tr> <td width=110> <? if($arElement[PREVIEW_PICTURE]!='') { echo CFile::ShowImage($arElement[PREVIEW_PICTURE],'100','100')."<br>"; } ?> </td> <td> <? if($arElement[NAME]!='') { echo "<a href=detail.php?id=$arElement[ID]>".$arElement[NAME]."</a><br />"; }else{echo $arElement[NAME]."<br />";} if($arProperty[form][VALUE]!='') { echo "<b>Îðãàíèçàöèîííî ïðàâîâàÿ ôîðìà°: </b>".$arProperty[form][VALUE]."<br>"; } if($arProperty[svid][VALUE]!='') { echo "<b>Ñâèäåòåëüñòâî î ðåãèñòðàöèè (äàòà, íîìåð, êåì âûäàí):</b>".$arProperty[svid][VALUE]."<br>"; } if($arProperty[uaddress][VALUE]!='') { echo "<b>Þðèäè÷åñêèé àäðåñ: </b>".$arProperty[uaddress][VALUE]."<br>"; } if($arProperty[faddress][VALUE]!='') { echo "<b>Ôàêòè÷åñêèé Àäðåñ: </b>".$arProperty[faddress][VALUE]."<br>"; } if($arProperty[filial][VALUE]!='') { echo "<b>Ôèëèàëû (ïåðå÷èñëèòü íàèìåíîâàíèå è ôàêòè÷åñêîå ìå: </b>".$arProperty[filial][VALUE]."<br>"; } if($arProperty[fio][VALUE]!='') { echo "<b>Ô.È.Î., äîëæíîñòü êîíòàêòíîãî ëèöà: </b>".$arProperty[fio][VALUE]."<br>"; } if($arProperty[phone][VALUE]!='') { echo "<b>Òåëåôîí, ôàêñ: </b>".$arProperty[phone][VALUE]."<br>"; } if($arProperty[email][VALUE]!='') { echo "<b>Àäðåñ ýëåêòðîííîé ïî÷òû: : </b>".$arProperty[email][VALUE]."<br>"; } if($arProperty[site][VALUE]!='') { echo "<b>Âåá ñàéò: </b>".$arProperty[site][VALUE]."<br>"; } if($arProperty[advice][VALUE]!='') { echo "<b>Ïðåäëîæåíèå: </b>".$arProperty[advice][VALUE]."<br>"; } echo "</td. </tr> </table> ";?> <? //endif; ?> <? } while ($obElement = $rsElements->GetNextElement()); ?> </td></tr></table> <p><?echo $rsElements->NavPrint($ELEMENT_NAME)?></p><? endif; //if ($obElement = $rsElements->GetNextElement()): endif;//if ($count<=0 && $filter_set=="Y"): endif; $obCache->EndDataCache(array( "IBLOCK_ID" => $IBLOCK_ID, "IBLOCK_TYPE" => $IBLOCK_TYPE, "SECTION_ID" => $SECTION_ID, "ELEMENT_NAME" => $ELEMENT_NAME, "arrPath" => $arrPath, )); endif; else: ShowError(GetMessage("CATALOG_SECTION_NOT_FOUND")); @define("ERROR_404", "Y"); endif; endif; ?></strong><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>