// Обрабатываем материалы
public function materials($categories, $materials, $tagsMap, $tagsFitlerLevel, $tagsFitlerFood, $tagsFitlerTreatment) {
$arrayMaterials = array();
foreach ($materials as $value) {
if(in_array($value->catid, $categories)){
foreach ($tagsMap as $tagLevel) {
if(in_array($tagLevel->tag_id, $tagsFitlerLevel) && $tagLevel->content_item_id == $value->id || empty($tagsFitlerLevel) || $tagsFitlerLevel[0] == 'null'){
foreach ($tagsMap as $tagFood) {
if(in_array($tagFood->tag_id, $tagsFitlerFood) && $tagFood->content_item_id == $value->id || empty($tagsFitlerFood) || $tagsFitlerFood[0] == 'null'){
foreach ($tagsMap as $tagTreatment) {
if(in_array($tagTreatment->tag_id, $tagsFitlerTreatment) && $tagTreatment->content_item_id == $value->id || empty($tagsFitlerTreatment) || $tagsFitlerTreatment[0] == 'null'){
$arrayMaterial = array();
array_push($arrayMaterial, $value->id);
array_push($arrayMaterial, $value->title);
array_push($arrayMaterial, $value->catid);
array_push($arrayMaterials, $arrayMaterial);
$arrayMaterial = array();
break 3;
}
}
}
}
}
}
}
}
return $arrayMaterials;
}
public function materials($categories, $materials, $tagsMap, $tagsFitlerLevel, $tagsFitlerFood, $tagsFitlerTreatment) {
$arrayMaterials = array();
$filterLevel = 0;
$filterFood = 0;
$filterTreatment = 0;
foreach ($materials as $value) {
if(in_array($value->catid, $categories)){
foreach ($tagsMap as $tag) {
if($tag->content_item_id == $value->id):
if(empty($tagsFitlerLevel) || $tagsFitlerLevel[0] == 'null' || in_array($tag->tag_id, $tagsFitlerLevel)){
$filterLevel = 1;
}
if(empty($tagsFitlerFood) || $tagsFitlerFood[0] == 'null' || in_array($tag->tag_id, $tagsFitlerFood)){
$filterFood = 1;
}
if(empty($tagsFitlerTreatment) || $tagsFitlerTreatment[0] == 'null' || in_array($tag->tag_id, $tagsFitlerTreatment)){
$filterTreatment = 1;
}
if($filterLevel == 1 && $filterFood == 1 && $filterTreatment == 1){
$arrayMaterial = array();
array_push($arrayMaterial, $value->id);
array_push($arrayMaterial, $value->title);
array_push($arrayMaterial, $value->catid);
array_push($arrayMaterials, $arrayMaterial);
$arrayMaterial = array();
}
endif;
}
$filterLevel = 0;
$filterFood = 0;
$filterTreatment = 0;
}
}
return $arrayMaterials;
}