$ans['breadcrumbs'][] = array('href' => 'find', 'title' => $menu['find']['title']); $ans['breadcrumbs'][] = array('title' => $ans['name']); } else { //is!, descr!, text!, name!, breadcrumbs!, title if ($md['group']) { foreach ($md['group'] as $group => $v) { break; } } else { $group = false; } $group = Catalog::getGroup($group); $ans['is'] = 'group'; $ans['breadcrumbs'][] = array('href' => '', 'title' => $conf['catalog']['title'], 'add' => 'group:'); array_map(function ($p) use(&$ans) { $group = Catalog::getGroup($p); $ans['breadcrumbs'][] = array('href' => '', 'title' => $group['name'], 'add' => 'group::group.' . $p . ':1'); }, $group['path']); if (sizeof($ans['breadcrumbs']) == 1) { array_unshift($ans['breadcrumbs'], array('main' => true, "title" => "Главная", "nomark" => true)); } $ans['name'] = $group['name']; //имя группы длинное $ans['descr'] = @$group['descr']['Описание группы']; $ans['title'] = $group['title']; } } Catalog::sort($ans['list'], $md); //Numbers $pages = ceil(sizeof($ans['list']) / $md['count']); if ($pages < $page) {
public static function markData(&$md) { if (isset($md['sort'])) { $md['sort'] = (string) $md['sort']; // price, name, def, group, producer if (!in_array($md['sort'], array('name', 'group', 'producer', 'change', 'cost'))) { unset($md['sort']); } } if (isset($md['search'])) { $md['search'] = (string) $md['search']; $md['search'] = trim($md['search']); $ar = preg_split('/[\\s,]+/', $md['search']); $res = array(); foreach ($ar as $k => $v) { if ($v == '') { continue; } $res[] = $v; } if ($res) { $md['search'] = implode(' ', $res); } else { unset($md['search']); } } if (isset($md['producer'])) { if (!is_array($md['producer'])) { $md['producer'] = array(); } $md['producer'] = array_filter($md['producer']); $producers = array_keys($md['producer']); $producers = array_filter($producers, function (&$value) { if (in_array($value, array('yes', 'no'))) { return true; } if (Catalog::getProducer($value)) { return true; } return false; }); $md['producer'] = array_fill_keys($producers, 1); if (!$md['producer']) { unset($md['producer']); } } if (isset($md['group'])) { if (!is_array($md['group'])) { $md['group'] = array(); } $md['group'] = array_filter($md['group']); $groups = array_keys($md['group']); $groups = array_filter($groups, function (&$value) { if (in_array($value, array('yes', 'no'))) { return true; } if (!Catalog::getGroup($value)) { return false; } return true; }); $md['group'] = array_fill_keys($groups, 1); if (!$md['group']) { unset($md['group']); } } if (isset($md['reverse'])) { $md['reverse'] = (bool) $md['reverse']; if (!$md['reverse']) { unset($md['reverse']); } } if (isset($md['count'])) { $md['count'] = (int) $md['count']; if ($md['count'] < 1) { unset($md['count']); } if ($md['count'] > 1000) { unset($md['count']); } } $name = 'cost'; if (isset($md[$name])) { if (!is_array($md[$name])) { $md[$name] = array(); } $md[$name] = array_filter($md[$name]); //Удаляет false значения $values = array_keys($md[$name]); $values = array_filter($values, function (&$val) { if (in_array($value, array('yes', 'no'))) { return true; } if (!$val) { return false; } return true; }); $md[$name] = array_fill_keys($values, 1); if (!$md[$name]) { unset($md[$name]); } } if (isset($md['more'])) { if (!is_array($md['more'])) { unset($md['more']); } else { foreach ($md['more'] as $k => $v) { if (!is_array($v)) { unset($md['more'][$k]); } else { foreach ($v as $kk => $vv) { if (!$vv) { unset($md['more'][$k][$kk]); } } if (!$md['more'][$k]) { unset($md['more'][$k]); } } } if (!$md['more']) { unset($md['more']); } } } Extend::markData($md); }