<?php
/**
* XS2:
*
* This file is developed by Solutecs, LLC for the purpose of the company
* and is provided together with XS2 Framework as and inherent part of the
* system. This file can be used on the terms of License Agreement.
*
* +7 (495) 585-0833 / 13 Rusakovskaya street, Moscow 107140 Russia
*
* @link http://www.solutecs.com
* @copyright ©1998-2007 Solutecs, LLC
* @package XS2-MODCOM
* @subpackage proc-catalogue
* @version 1.XX
*/
if (!$_THE['PARAMS'][1]) {
// Пустой запрос
header('location: '.xs2Href(array('mod'=>$_THE['QUE']['MOD'],
'obj'=>'categories',
'met'=>'show')));
exit();
}
// Разбираем запрос
$query = array();
foreach ($_THE['PARAMS'] as $_i=>$_p) {
if ($_i) {
list($_t, $_n) = explode(':', $_p);
$query[$_t] = $_n;
}
}
// Формируем условие
$producers = array($query['producer']);
if ($query['country']) {
if ($countries = xs2GetLinks(array('NType'=>'producer',
'field'=>'Country',
'NodId'=>$query['country'])))
$producers[] = $countries[0]['NodId'];
}
$producers = array_filter($producers);
if ($query['ParId'])
$path = array_map('array_shift',
xs2GetKnee(array('NType'=>'category',
'NodId'=>$query['ParId'])));
// Отбираем подходящие объекты
$found = array_filter(xs2GetNodes(array('NType'=>'item')),'criteria');
$_HTML->assign('found', $found);
// Проверяет узел на соответствие условию
function criteria($node) {
global $producers, $path, $query;
if(count($producers) && !in_array($node['Producer'][0]['NodId'], $producers))
return false; // Производитель (в т.ч. страна) не подходят
if(($query['producer'] || $query['country']) && !count($producers))
return false; // Производитель или страна не найдены
if($query['ParId'] && !in_array($node['ParId'], $path))
return false; // Не подходит раздел
return true;
}
?>
|
|