IsAdmin()){ CModule::IncludeModule("iblock"); $IBLOCK_ID = 11; $SECTION_ID = $_GET["section_id"]; $DB_DATA = $_POST["data"]; // ---------- ЗАПИСЬ В ТАБЛИЦУ ---------- // if($DB_DATA){ $query = $DB->Query("SELECT * FROM arteast_filters WHERE section_id=" . $SECTION_ID); $rowsCount = $query->result->num_rows; foreach($DB_DATA as $item){ $explode_data[] = explode("___", $item); } foreach($explode_data as $item){ $PROPERTY_NAME .= $item[0] . ","; $PROPERTY_TYPE .= $item[1] . ","; $PROPERTY_DESC .= $item[2] . ","; } $PROPERTY_NAME = mb_substr($PROPERTY_NAME, 0, -1); $PROPERTY_TYPE = mb_substr($PROPERTY_TYPE, 0, -1); $PROPERTY_DESC = mb_substr($PROPERTY_DESC, 0, -1); if($rowsCount == 0){ $fields = array( "section_id" => $SECTION_ID, "property_type" => "'".$PROPERTY_TYPE."'", "property_name" => "'".$PROPERTY_NAME."'", "property_desc" => "'".$PROPERTY_DESC."'", ); $query = $DB->Insert("arteast_filters",$fields); } } if($_POST["empty"]){ $query = $DB->Query("UPDATE arteast_filters SET property_type='', property_name='', property_desc='' WHERE section_id=" . $SECTION_ID); }elseif($DB_DATA){ $query = $DB->Query("UPDATE arteast_filters SET property_type='$PROPERTY_TYPE', property_name='$PROPERTY_NAME', property_desc='$PROPERTY_DESC' WHERE section_id=" . $SECTION_ID); } // ---------- ЗАПИСЬ В ТАБЛИЦУ ---------- // // ---------- ФОРМА ЗАПИСИ ---------- // if($SECTION_ID){ echo "
Вернуться назад

"; echo "
"; $arFilter = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "SECTION_ID" => $SECTION_ID); $arItems = CIBlockElement::GetList(array("SORT" => "ASC"), $arFilter, false, array("nTopCount" => 20), array("ID")); while($arResult[] = $arItems->GetNext()); foreach($arResult as $key => $item){ $arResult[$key]["PROPERTIES"] = array(); $arElementLink[$item["ID"]] = &$arResult[$key]; $elementsID[$key] = $item["ID"]; $arPropFilter = array("ID" => $elementsID,"IBLOCK_ID" => $arFilter["IBLOCK_ID"]); CIBlockElement::GetPropertyValuesArray($arElementLink, $arFilter["IBLOCK_ID"], $arPropFilter, []); foreach($arResult as $key => $arItem){ if (!empty($arItem["PROPERTIES"])){ foreach ($arItem["PROPERTIES"] as $code => $arProperty){ if((is_array($arProperty["VALUE"]) && !empty($arProperty["VALUE"])) || (!is_array($arProperty["VALUE"]) && strlen($arProperty["VALUE"]) > 0)){ $arProperties[$code] = CIBlockFormatProperties::GetDisplayValue(array("ID" => $arItem["ID"],"NAME" => $arItem["NAME"]),$arProperty,""); } if($arProperty["VALUE"]){ if(!isset($property[$code])){ $property[$code]["ID"] = $arProperty["ID"]; $property[$code]["NAME"] = $arProperty["NAME"]; $property[$code]["PROPERTY_TYPE"] = $arProperty["PROPERTY_TYPE"]; $property[$code]["CODE"] = $arProperty["CODE"]; }else{ if($property[$code]["VALUES"] != $arProperty["VALUE"]){ $property[$code]["VALUES"][$arProperty["VALUE"]] = $arProperty["VALUE"]; } } } } } } } $query = $DB->Query("SELECT * FROM arteast_filters WHERE section_id=" . $SECTION_ID); while ($queryResults = $query->Fetch()){ $dbResults = $queryResults; } $propertyName = explode(",", $dbResults["property_name"]); $propertyType = explode(",", $dbResults["property_type"]); $propertyDesc = explode(",", $dbResults["property_desc"]); unset($property["MORE_PHOTO"], $property["FILES"]); foreach($property as $keyName => $prop){ if(in_array($keyName, $propertyName)) { $checked = "checked"; }else{ $checked = ""; } echo "
"; } echo "
"; echo "
"; echo "
* Чтобы очистить все поля фильтра, поставьте галочку 'Очистить фильтр' и нажмите 'Сохранить фильтр'."; }else{ $arFilter = array('IBLOCK_ID' => $IBLOCK_ID, 'ACTIVE' => 'Y'); $rsSection = CIBlockSection::GetTreeList($arFilter); while($arSection = $rsSection->Fetch()){ $depth = $arSection["DEPTH_LEVEL"]; if($depth == 1){ echo "
" . $arSection["NAME"] . "
"; }else{ if($depth == 2){ $d = $depth; }else{ $d = $depth + $depth/2; } echo "
" . $arSection["NAME"] . "
"; } } } // ---------- END ФОРМА ЗАПИСИ ---------- // }else{ echo "Авторизуйтесь!"; } ?>