Ejemplo n.º 1
0
 public function getList($parent)
 {
     $data = array();
     if ($limit != '') {
         $limit = 'LIMIT ' . $limit;
     }
     $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' AND visible=1 ORDER BY name ';
     $list = DB::getPagi($sql);
     $i = 0;
     foreach ($list as $item) {
         $field = Fields::getFieldsByTree($item['id'], 'gal');
         $path = Tree::getPathToTree($item['id']);
         $data['list'][] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path, 'udate' => date('d.m.Y', strtotime($item['udate'])), 'fields' => $field, 'pic' => $field['files_gal1']['image'][0]['path']);
         if (preg_match("/^[0-9]+\$/", substr($item['name'], 0, 1))) {
             $data['list2']['0-9'][] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path);
         }
         if (preg_match("/^[a-zA-Z]+\$/", substr($item['name'], 0, 1))) {
             $data['list2'][strtoupper(substr($item['name'], 0, 1))][] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path);
         }
         if (preg_match("/^[а-яА-Я]+\$/", substr($item['name'], 0, 1))) {
             $data['list2']['А-Я'][] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path);
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 function atb()
 {
     $model = Catalog::getOne($_GET['id']);
     $model['parentpath'] = Tree::getPathToTree($model['parent']);
     $temp = Basket::getSimpleOrder();
     $model['sum'] = $temp['sum'];
     $model['goods'] = $temp['goods'];
     View::$layout = 'popup';
     View::render('popup/addtobasket', $model);
 }
Ejemplo n.º 3
0
 public function getList($parent, $order = 'num', $limit = '')
 {
     $data = array();
     if ($limit != '') {
         $limit = 'LIMIT ' . $limit;
     }
     $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' ORDER BY ' . $order . ' ' . $limit;
     $list = DB::getPagi($sql);
     foreach ($list as $item) {
         $field = Fields::getFieldsByTree($item['id'], 'gal');
         $data[] = array('id' => $item['id'], 'name' => $item['name'], 'path' => Tree::getPathToTree($item['id']), 'udate' => date('d.m.Y', strtotime($item['udate'])), 'fields' => $field, 'pic' => $field['files_gal1']['image'][0]['path']);
     }
     return $data;
 }
Ejemplo n.º 4
0
 function run($id = '')
 {
     $fullURI = Funcs::$uri;
     if ($id) {
         $fullURI = explode('/', Tree::getPathToTree($id));
         unset($fullURI[0]);
         unset($fullURI[count($fullURI)]);
     }
     $data = array();
     $parent = Funcs::$siteDB;
     $path = '';
     foreach ($fullURI as $uri) {
         $path = $path . '/' . $uri;
         if (is_numeric($uri)) {
             $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' AND id=' . $uri . '';
         } else {
             $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' AND path=\'' . $uri . '\'';
         }
         $row = DB::getRow($sql);
         $row['path'] = $path . '/';
         $parent = $row['id'];
         if ($parent == '') {
             $parent = 0;
         }
         $data[] = $row;
     }
     if ($fullURI[0] == 'catalog' && is_numeric($fullURI[count(Funcs::$uri) - 1])) {
         $uri = explode('/', $_SERVER['REQUEST_URI']);
         $num = count($data);
         $data[count($data)] = $data[count($data) - 1];
         $path = $data;
         unset($path[count($path) - 1]);
         unset($path[count($path) - 1]);
         $items = array();
         foreach ($path as $item) {
             $items[] = $item['path'];
         }
         Funcs::$reference['vendor'][$uri[$num]]['path'] = $items[count($items) - 1] . Funcs::$reference['vendor'][$uri[$num]]['path'] . '/';
         $data[count($data) - 2] = Funcs::$reference['vendor'][$uri[$num]];
     } elseif (isset($_GET['ve'])) {
         $path = $items[count($items)] . Funcs::$reference['vendor'][$uri[$num]]['path'] . '/';
         $data[] = array('name' => Funcs::$referenceId['vendor'][$_GET['ve']]['name'], 'path' => $path);
     }
     View::widget('crumbs', array('list' => $data));
 }
Ejemplo n.º 5
0
 function getList()
 {
     $data = array();
     $xml = Sitemap::getSitemapXML();
     //$site=Control::getSite(Funcs::$siteDB);
     $sql = 'SELECT * FROM {{tree}} WHERE visible=1 ORDER BY mdate DESC, cdate DESC';
     $list = DB::getAll($sql);
     foreach ($list as $item) {
         $info = Tree::getInfo($item['id']);
         if ($info['id2'] != 0 && $info['params'] != '') {
             $path = 'http://' . $_SERVER['HTTP_HOST'] . Tree::getPathToTree($item['id'], $info['params']);
         } else {
             $path = 'http://' . $_SERVER['HTTP_HOST'] . Tree::getPathToTree($item['id']);
         }
         $data[] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path, 'mdate' => date('Y-m-d', strtotime($item['mdate'])), 'changefreq' => $xml[str_replace('/', '_', $path)]['changefreq'], 'priority' => $xml[str_replace('/', '_', $path)]['priority'], 'checked' => is_array($xml[str_replace('/', '_', $path)]) ? 'checked' : '');
     }
     return $data;
 }
Ejemplo n.º 6
0
    public function getResult()
    {
        $data = array();
        $q = trim(strip_tags($_GET['q']));
        if ($q) {
            $sql = '
				SELECT * FROM {{search}}
				INNER JOIN {{tree}} ON  {{search}}.tree={{tree}}.id
				WHERE search LIKE \'%' . $q . '%\' AND visible=1
				ORDER BY {{search}}.cdate DESC
			';
            $list = DB::getAll($sql);
            foreach ($list as $item) {
                $fields = Fields::getFieldsByTree($item['tree'], 'gal');
                $path = Tree::getPathToTree($item['tree']);
                $data[] = array('id' => $item['tree'], 'name' => $item['name'], 'path' => $path, 'fields' => $fields, 'info' => Tree::getInfo($item['tree']));
            }
        }
        return $data;
    }
Ejemplo n.º 7
0
    public function getList($parent, $order = 'num', $limit = '')
    {
        $data = array();
        if ($limit != '') {
            $limit = 'LIMIT ' . $limit;
        }
        $act = '';
        if (isset($_GET['act'])) {
            $act = ' AND value_int=' . $_GET['act'] . '';
        }
        $sql = '
			SELECT DISTINCT {{tree}}.* FROM {{tree}} 
			INNER JOIN {{data}} ON {{data}}.tree={{tree}}.id
			WHERE parent=' . $parent . ' AND {{data}}.path=\'act\' ' . $act . ' 
			ORDER BY ' . $order . '	' . $limit . '
		';
        $list = DB::getPagi($sql);
        foreach ($list as $item) {
            $field = Fields::getFieldsByTree($item['id'], 'gal');
            $data[] = array('id' => $item['id'], 'name' => $item['name'], 'path' => Tree::getPathToTree($item['id']), 'udate' => date('d.m.Y', strtotime($item['udate'])), 'fields' => $field, 'pic' => $field['files_gal1'][0]['path']);
        }
        return $data;
    }
Ejemplo n.º 8
0
 public function OffersMenu()
 {
     $data = array();
     $sql = 'SELECT id FROM {{tree}} WHERE parent=1 AND path=\'offers\' AND visible=1 ORDER BY num';
     $parent = DB::getOne($sql);
     $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $parent . ' AND visible=1 AND menu=1 ORDER BY num';
     $list = DB::getAll($sql);
     foreach ($list as $i => $item) {
         $data[$i % 4][] = array('name' => $item['name'], 'path' => Tree::getPathToTree($item['id']), 'id' => $item['id']);
     }
     View::widget('menu/offers', array('list' => $data));
 }
Ejemplo n.º 9
0
    public static function getPrev()
    {
        $tree = Tree::getTreeByUrl();
        $parent = ' parent=' . $tree['parent'] . ' AND ';
        if ($_GET['ids']) {
            $parent = ' id IN (' . $_GET['ids'] . ') AND ';
        }
        $sql = 'SELECT count(*) FROM {{tree}} WHERE ' . $parent . ' visible=1 AND id<>' . $tree['id'] . '';
        if (DB::getOne($sql) > 0) {
            $sql = '
				SELECT id FROM {{tree}}	
				WHERE ' . $parent . ' visible=1 AND id<>' . $tree['id'] . ' AND num<=\'' . $tree['num'] . '\'
				ORDER BY num
			';
            $id = DB::getOne($sql);
            if ($id) {
                return Tree::getPathToTree($id) . ($_GET['ids'] != '' ? '?ids=' . $_GET['ids'] : '');
            } else {
                return Video::getNext();
            }
        }
    }
Ejemplo n.º 10
0
    public static function getServices($parent)
    {
        $data = array();
        $sql = '
			SELECT * FROM {{tree}} 
			WHERE visible=1 AND parent=' . $parent . ' AND menu=1
			ORDER BY num
		';
        $list = DB::getAll($sql);
        foreach ($list as $item) {
            $item['path'] = Tree::getPathToTree($item['id']);
            $fields = Fields::getFieldsByTree($item['id'], 'gal');
            $data[] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $item['path'], 'preview' => $fields['preview'], 'pic' => $fields['files_gal1']['image'][0]['path'], 'picname' => $fields['files_gal1']['image'][0]['name']);
        }
        return $data;
    }
Ejemplo n.º 11
0
    public function getRecurs($parent)
    {
        $data = array('sub' => array(), 'count' => 0);
        $sql = '
			SELECT * FROM {{tree}}
			WHERE parent=' . $parent . ' AND visible=1 AND menu=0
			ORDER BY num
		';
        $list = DB::getAll($sql);
        foreach ($list as $item) {
            $items = Faq::getRecurs($item['id']);
            $path = Tree::getPathToTree($item['id']);
            $data['sub'][] = array('name' => $item['name'], 'path' => $path, 'sub' => $items['sub'], 'count' => $countAll);
        }
        $data['count'] = $countAll;
        return $data;
    }
Ejemplo n.º 12
0
    public static function getPrev($id, $parent, $date)
    {
        $sql = '
			SELECT id FROM {{tree}}	
			WHERE parent=' . $parent . ' AND visible=1 AND id<>' . $id . ' AND udate<=\'' . date('Y-m-d', strtotime($date)) . '\' 
			ORDER BY udate DESC
		';
        $news = DB::getOne($sql);
        if ($news) {
            return Tree::getPathToTree($news);
        }
    }
Ejemplo n.º 13
0
    public static function getType($id, $parent)
    {
        if (!Funcs::$uri[3]) {
            $parent = $id;
        }
        $sql = '
			SELECT {{tree}}.* FROM {{tree}} 
			LEFT JOIN {{catalog}} ON {{tree}}.id={{catalog}}.tree
			WHERE {{tree}}.parent=' . $parent . ' AND {{catalog}}.tree IS NULL ORDER BY {{tree}}.num
		';
        $list = DB::getAll($sql);
        foreach ($list as $item) {
            $item['path'] = Tree::getPathToTree($item['id']);
            $data['list'][] = $item;
        }
        return $data;
    }
Ejemplo n.º 14
0
 function __construct()
 {
     if ($_POST) {
         DB::escapePost();
         if (isset($_POST['report'])) {
             $tree = Tree::getTreeByUrl();
             $href = Catalog::getPathToTree($tree['id']);
             Catalog::setReport($tree['id']);
             View::$layout = 'empty';
             View::render('site/redirect', array('href' => $href, 'text' => 'Отзыв успешно добавлен!'));
             die;
         }
         if (isset($_POST['subscribe'])) {
             $tree = Tree::getTreeByUrl();
             $href = Tree::getPathToTree($tree['id']);
             Catalog::setSubscribe($tree['id']);
             die;
         }
     } else {
         DB::escapeGet();
         if (Funcs::$uri[1] == '' && isset($_GET['hits']) && Funcs::$uri[1] != 'setratingstars' && Funcs::$uri[1] != 'delreport') {
             $tree = Tree::getTreeByUrl();
             Funcs::setMeta($tree);
             $tree = Catalog::getHitCatalog($tree['id']);
             View::render('catalog/catalog', array('list' => $tree, 'name' => 'Все хиты'));
         } elseif (Funcs::$uri[1] == '' && Funcs::$uri[1] != 'setratingstars' && Funcs::$uri[1] != 'delreport') {
             $tree = Tree::getTreeByUrl();
             Funcs::setMeta($tree);
             $tree = Catalog::getPreviewCatalog($tree['id']);
             //View::render('catalog/catalog',array('list'=>$tree));
         } elseif (Funcs::$uri[1] != 'setratingstars' && Funcs::$uri[1] != 'delreport') {
             $tree = Tree::getTreeByUrl(Funcs::$uri[0]);
             if ($tree['info']['type'] == 'struct') {
                 $temp = Catalog::getInnerListPagi($tree['id']);
                 $tree['list'] = $temp['list'];
                 $tree['vendors'] = Catalog::getVendors($tree['id'], $tree['list']);
                 //$tree['options']['available']=array();
                 //$tree['options']['catalog']=Catalog::getType($tree['id'],$tree['parent']);
                 //$tree['options']['vendors']=Catalog::getVendors($tree['id']);
                 if ($_GET['ve']) {
                     $tree['name'] = $tree['seo_description'] = $tree['name'] . ' ' . Funcs::$referenceId['vendor'][$_GET['ve']]['name'];
                     Funcs::setMeta($tree);
                 }
                 $tree['options']['price'] = Catalog::getValuesPrice($tree['id']);
                 $tree['options']['price2'] = Catalog::getLink('pricelink');
                 //$tree['options']['rating']=array();
                 Funcs::setMeta($tree);
                 $tree['quantity'] = $temp['quantity'];
                 if ($_GET['ajax'] == 'act') {
                     print $tree['quantity'];
                     die;
                 } else {
                     View::render('catalog/list', $tree);
                 }
             } else {
                 Funcs::setMeta($tree, 'goods');
                 $id = $tree['id'];
                 $tree = Catalog::getOne($id);
                 Catalog::setPopularity($id);
                 $tree['reports'] = Catalog::getReports($id);
                 Catalog::setViewed($id);
                 $tree['same_price'] = Catalog::getAdditionalgood($id, 'better_for_same_price');
                 $tree['accessories'] = Catalog::getAdditionalgood($id, 'accessories');
                 //$tree['similargoods']=Catalog::getAdditionalgood($id,'similargoods');
                 $tree['similargoods'] = Catalog::getMore($tree['id'], $tree['parent']);
                 $tree['reportme'] = Catalog::getReport($tree['id']);
                 if (isset($_GET['print'])) {
                     View::$layout = 'empty';
                     View::render('catalog/print', $tree);
                     die;
                 } else {
                     View::render('catalog/one', $tree);
                 }
             }
         }
     }
 }