$fd = Catalog::initMark($ans); if (isset($_GET['lim'])) { $lim = $_GET['lim']; } else { $lim = '0,20'; } $p = explode(',', $lim); if (sizeof($p) != 2) { return infra_err($ans, 'Is wrong paramter lim'); } $start = (int) $p[0]; $count = (int) $p[1]; $args = array($start, $count); $list = Catalog::cache('producers.php', function ($start, $count) { $ans = array(); $conf = infra_config(); $data = Catalog::init(); $prods = array(); Xlsx::runPoss($data, function (&$pos) use(&$prods) { @$prods[$pos['Производитель']]++; }); arsort($prods, SORT_NUMERIC); $prods = array_slice($prods, $start, $count); return $prods; }, $args, isset($_GET['re'])); $ans['menu'] = infra_loadJSON('*catalog/menu.json'); $ans['list'] = $list; $conf = infra_config(); $ans['breadcrumbs'][] = array('href' => '', 'title' => $conf['catalog']['title'], 'add' => 'group'); $ans['breadcrumbs'][] = array('href' => 'producers', 'title' => 'Производители'); return infra_ret($ans);
use itlife\files\Xlsx; infra_cache_no(); $orig_val = infra_toutf(strip_tags($_GET['val'])); $orig_art = infra_toutf(strip_tags($_GET['art'])); $val = infra_strtolower($orig_val); $art = infra_strtolower($orig_art); $args = array($val, $art); $ans = array(); $pos = Catalog::cache('position', function ($val, $art) { $data = Catalog::init(); // список всей продукции return Xlsx::runPoss($data, function (&$pos, $i, &$group) use(&$val, &$art) { if (mb_strtolower($pos['producer']) !== $val) { return; } if (mb_strtolower($pos['article']) !== $art) { return; } return $pos; }); }, $args, isset($_GET['re'])); if (isset($_GET['seo'])) { if (!$pos) { return infra_err($ans, 'Position not found'); } $link = $_GET['seo']; $link = $link . '/' . $pos['producer'] . '/' . $pos['article']; $ans['external'] = '*catalog/seo.json'; $ans['canonical'] = infra_view_getPath() . '?' . $link; return infra_ans($ans); }
public static function getPoss($mdgroup) { if ($mdgroup) { foreach ($mdgroup as $group => $v) { break; } } else { $group = false; } return Catalog::cache('getPoss', function &($group) { $data = Catalog::init(); if ($group) { $data = Xlsx::runGroups($data, function &($gr) use($group) { if ($gr['title'] == $group) { return $gr; } }); } $poss = array(); Xlsx::runPoss($data, function (&$pos) use(&$poss) { $poss[] =& $pos; }); return $poss; }, array($group)); }