コード例 #1
0
ファイル: Yml.php プロジェクト: infrajs/yml
 public static function init()
 {
     $data = Catalog::init();
     Xlsx::runGroups($data, function (&$group, $i, &$parent) {
         $group['data'] = array_filter($group['data'], function (&$pos) {
             //Убираем позиции у которых не указана цена
             //if($pos['Синхронизация']!='Да')return false;
             if (!$pos['Цена']) {
                 return false;
             }
             $pos['Цена'] = preg_replace('/\\s/', '', $pos['Цена']);
             if (!$pos['Цена']) {
                 return false;
             }
             if (strtolower($pos['Маркет']) == 'да') {
                 $pos['Описание'] = strip_tags($pos['Описание']);
                 $pos['Описание'] = preg_replace('/ /', ' ', $pos['Описание']);
                 return true;
             }
         });
         $group['data'] = array_values($group['data']);
     });
     Xlsx::runGroups($data, function (&$group, $i, &$parent) {
         if ($group['childs']) {
             $group['childs'] = array_filter($group['childs'], function (&$g) {
                 if (!$g['data'] && !$g['childs']) {
                     return false;
                 }
                 return true;
             });
             $group['childs'] = array_values($group['childs']);
         }
     }, array(), true);
     Xlsx::runPoss($data, function (&$pos) {
         $conf = Catalog::$conf;
         Xlsx::addFiles($conf['dir'], $pos, array('Производитель', 'article'));
         foreach ($pos['images'] as $k => $v) {
             $src = $pos['images'][$k];
             $p = explode('/', $src);
             foreach ($p as $i => $n) {
                 $p[$i] = urlencode($n);
                 $p[$i] = preg_replace('/\\+/', '%20', $p[$i]);
             }
             $pos['images'][$k] = implode('/', $p);
         }
     });
     return static::parse($data);
 }
コード例 #2
0
ファイル: search.php プロジェクト: infrajs/catalog
            if (!$group['path']) {
                $ans['breadcrumbs'][] = array('href' => 'producers', '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
    $src = Rubrics::find($conf['dir'] . 'articles/', $ans['title']);
    if ($src) {
        $ans['textinfo'] = Rubrics::info($src);
        $ans['text'] = Load::loadTEXT('-doc/get.php?src=' . $src);
        //Изменение текста не отражается как изменение каталога, должно быть вне кэша
    }
    foreach ($ans['list'] as $k => $pos) {
        $pos = Catalog::getPos($pos);
        $group = Catalog::getGroup($pos['group']);
        $pos['descr'] = $group['descr'];
        unset($pos['texts']);
        unset($pos['files']);
        $ans['list'][$k] = $pos;
    }
    return $ans;
}, $args, $re);
return Ans::ret($ans);
コード例 #3
0
ファイル: index.php プロジェクト: infrajs/yml
<?php

namespace infrajs\yml;

use infrajs\catalog\Catalog;
use infrajs\config\Config;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../');
    require_once 'vendor/autoload.php';
}
$html = Catalog::cache('ymlshow', function () {
    return Yml::init();
});
header("Content-type: text/xml");
echo $html;
コード例 #4
0
ファイル: filters.php プロジェクト: infrajs/catalog
        $block['row'] = array();
        if ($param['option']['nocount']) {
            $row = array('title' => 'Не указано', 'filter' => $param['nofilter']);
            $row['checked'] = !!$mymd['no'];
            if ($row['checked']) {
                $row['add'] = $add . $paramid . '.no=';
            } else {
                $row['add'] = $add . $paramid . '.no=1';
            }
            $block['row'][] = $row;
        }
        if ($block['type'] == 'string') {
            foreach ($param['option']['values'] as $value) {
                $row = array('title' => $value['title'], 'filter' => $value['filter']);
                $row['checked'] = !!$mymd[$value['id']];
                $valueid = Sequence::short(array(Catalog::urlencode($value['id'])));
                if ($row['checked']) {
                    $row['add'] = $add . $paramid . '.' . $valueid . '=';
                } else {
                    $row['add'] = $add . $paramid . '.' . $valueid . '=1';
                }
                $block['row'][] = $row;
            }
        }
        if ($conf['filteroneitem'] || sizeof($block['row']) > 1) {
            $ans['template'][] = $block;
        }
    }
    return $ans;
}, $args, isset($_GET['re']));
$ans = array_merge($ans, $res);
コード例 #5
0
ファイル: infra.php プロジェクト: infrajs/catalog
<?php

namespace infrajs\catalog;

use infrajs\ans\Ans;
use infrajs\path\Path;
use infrajs\cache\Cache;
use infrajs\infra\Infra;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../');
    require_once 'vendor/autoload.php';
}
$conf =& Config::get('catalog');
Catalog::$conf = array_merge(Catalog::$conf, $conf);
$conf = Catalog::$conf;
コード例 #6
0
ファイル: producers.php プロジェクト: infrajs/catalog
$fd = Catalog::initMark($ans);
if (isset($_GET['lim'])) {
    $lim = $_GET['lim'];
} else {
    $lim = '0,20';
}
$p = explode(',', $lim);
if (sizeof($p) != 2) {
    return Ans::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();
    $data = Catalog::init();
    $prods = array();
    Xlsx::runPoss($data, function &(&$pos) use(&$prods) {
        if (empty($prods[$pos['producer']])) {
            $prods[$pos['producer']] = 0;
        }
        $prods[$pos['producer']]++;
        $r = null;
        return $r;
    });
    arsort($prods, SORT_NUMERIC);
    $prods = array_slice($prods, $start, $count);
    return $prods;
}, $args, isset($_GET['re']));
$ans['menu'] = Load::loadJSON('-catalog/menu.json');
$ans['list'] = $list;
コード例 #7
0
ファイル: position.php プロジェクト: infrajs/catalog
    }
    $ans['canonical'] = View::getPath() . $link;
    return Ans::ans($ans);
}
$ans = array('val' => $val, 'prod' => $prod, 'art' => $art);
$ans['breadcrumbs'] = array();
//Путь где я нахожусь
$conf = Config::get('catalog');
$ans['breadcrumbs'][] = array('title' => $conf['title']);
$active = $orig_art;
if ($pos) {
    $group = Catalog::getGroup($pos['group']);
    if (isset($group['descr']['Артикул']) && $group['descr']['Артикул'] == 'Скрытый') {
        $active = $pos['Наименование'];
    }
    $ans['path'] = $pos['path'];
    $pos = Catalog::getPos($pos);
    $pos['descr'] = $group['descr'];
    $ans['pos'] = $pos;
    array_map(function ($p) use(&$ans) {
        $ans['breadcrumbs'][] = array('title' => $p, 'add' => 'group::group.' . $p . '=1');
    }, $pos['path']);
    $ans['breadcrumbs'][] = array('add' => 'producer::producer.' . $orig_val . '=1', 'title' => $orig_val);
    $ans['breadcrumbs'][] = array('active' => true, 'title' => $active);
    return Ans::ret($ans);
} else {
    $ans['breadcrumbs'][] = array('href' => 'producers', 'title' => 'Производители');
    $ans['breadcrumbs'][] = array('href' => '', 'title' => $orig_val, 'add' => 'producer::producer.' . $orig_val . '=1');
    $ans['breadcrumbs'][] = array('active' => true, 'title' => $active);
    return Ans::err($ans);
}
コード例 #8
0
ファイル: Catalog.php プロジェクト: infrajs/catalog
 public static function search($md, &$ans = array())
 {
     $args = array(Catalog::nocache($md));
     $res = Catalog::cache('search.php filter list', function ($md) {
         $ans['list'] = Catalog::getPoss($md['group']);
         //ЭТАП filters list
         $ans['filters'] = Catalog::filtering($ans['list'], $md);
         $now = null;
         foreach ($md['group'] as $now => $one) {
             break;
         }
         $ans['childs'] = Catalog::getGroups($ans['list'], $now);
         $ans['count'] = sizeof($ans['list']);
         return $ans;
     }, $args, isset($_GET['re']));
     $ans = array_merge($ans, $res);
     return $ans;
 }
コード例 #9
0
ファイル: rubrics.php プロジェクト: infrajs/catalog
<?php

namespace infrajs\catalog;

use infrajs\excel\Xlsx;
use infrajs\load\Load;
use infrajs\ans\Ans;
use infrajs\router\Router;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../');
    require_once 'vendor/autoload.php';
    Router::init();
}
$ans = array();
$fd = Catalog::initMark($ans);
//На главной странице каталога показываются
$data = Load::loadJSON('-catalog/search.php?m=' . $ans['m']);
$ans['childs'] = $data['childs'];
return Ans::ret($ans);