$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) { $page = $pages; } $ans['numbers'] = Catalog::numbers($page, $pages, 11); $ans['list'] = array_slice($ans['list'], ($page - 1) * $md['count'], $md['count']); //Text $ans['text'] = infra_loadTEXT('*files/get.php?' . $conf['catalog']['dir'] . 'articals/' . $ans['title']); //Изменение текста не отражается как изменение каталога, должно быть вне кэша foreach ($ans['list'] as $k => $pos) { $pos = Catalog::getPos($pos); unset($pos['texts']); unset($pos['files']); $ans['list'][$k] = $pos; } return $ans; }, $args, $re); return infra_ret($ans);
public static function getGroups($list, $now = false) { //Groups $subgroups = Catalog::cache('search.php subgroups', function () { //Микров вставка всё ради того чтобы не пользоваться $data на этом уровне //данный кэш один для любой страницы каталога $subgroups = array(); $data = Catalog::init(); Xlsx::runGroups($data, function ($group) use(&$subgroups) { if (empty($group['childs'])) { return; } $subgroup = array(); array_walk($group['childs'], function ($g) use(&$subgroup) { $subgroup[] = array('title' => $g['title'], 'name' => $g['name']); }); $subgroups[$group['title']] = $subgroup; }); return $subgroups; }); $groups = array(); foreach ($list as &$pos) { $path = $pos['path']; foreach ($list as &$pos) { foreach ($pos['path'] as $v) { if (!isset($groups[$v])) { $groups[$v] = array('pos' => $pos, 'count' => 0); } $groups[$v]['count']++; } $rpath = array(); foreach ($path as $k => $p) { if ($pos['path'][$k] == $p) { $rpath[$k] = $p; } else { break; } } $path = $rpath; } break; } if (!sizeof($path)) { $conf = infra_config(); $groupchilds = $subgroups[$conf['catalog']['title']]; } else { $g = $path[sizeof($path) - 1]; if (isset($subgroups[$g])) { $groupchilds = $subgroups[$g]; } else { if (!$now || $now != $g) { $groupchilds = array(array("name" => $g, "title" => $g)); } else { $groupchilds = false; } } } $childs = array(); if ($groupchilds) { foreach ($groupchilds as $g) { if (!$groups[$g['title']]) { continue; } $pos = Catalog::getPos($groups[$g['title']]['pos']); $pos = array('article' => $pos['article'], 'producer' => $pos['producer'], 'images' => $pos['images']); $childs[] = array_merge($g, array('pos' => $pos, 'count' => $groups[$g['title']]['count'])); } } return $childs; }