Ejemplo n.º 1
0
 public function __construct()
 {
     if ($_GET['ref']) {
         $sql = 'SELECT iuser FROM {{iusers_options}} WHERE selfcode=\'' . $_GET['ref'] . '\'';
         $iuser = DB::getOne($sql);
         if ($iuser) {
             $_SESSION['referal'] = $iuser;
         }
     }
     $sql = 'SELECT * FROM {{tree}} WHERE parent=410 AND visible=1 ORDER BY num';
     $list = DB::getAll($sql);
     foreach ($list as $item) {
         $fields = Fields::getFieldsByTree($item['id'], 'wide');
         $item['pic'] = $fields['files_gal']['image'][0]['path'];
         $multi = Fields::getMultiFields($item['id']);
         foreach ($multi['color'] as $row) {
             $item['list'][$row] = Funcs::$referenceId['color'][$row]['name'];
         }
         Run::$colors[$item['id']] = $item;
     }
     //print '<pre>';print_r(Run::$colors);die;
     $sql = 'SELECT * FROM {{tree}} WHERE id=1';
     $row = DB::getRow($sql);
     Run::$socTitle = $row['seo_title'];
     Run::$socDescription = $row['seo_description'];
 }
Ejemplo n.º 2
0
    public function getList($id, $count = '')
    {
        DB::escapeGet();
        $data = array();
        if ($count != '') {
            $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $id . ' AND visible=1 ORDER BY udate DESC LIMIT 0,' . $count;
            $list = DB::getAll($sql);
        } elseif ($_GET['d']) {
            $d = explode('-', $_GET['d']);
            $db = date('Y-m-d 00:00:01', strtotime($d[0] . '-' . $d[1] . '-01 00:00:01'));
            $de = date('Y-m-d 00:00:01', strtotime($d[0] . '-' . $d[1] . '-01 00:00:01 +1 month'));
            $sql = '
				SELECT * FROM {{tree}} 
				WHERE parent=' . $id . ' AND visible=1 AND (udate BETWEEN \'' . $db . '\' AND \'' . $de . '\') 
				ORDER BY udate DESC
			';
            $list = DB::getPagi($sql);
        } elseif ($_GET['tag']) {
            $sql = '
				SELECT {{tree}}.* FROM {{tree}}
				INNER JOIN ( {{data}} 
					INNER JOIN ({{relations}} 
						INNER JOIN {{reference}} ON {{relations}}.id2={{reference}}.id
					) ON {{data}}.id={{relations}}.id1
				) ON {{tree}}.id={{data}}.tree
				WHERE {{tree}}.parent=' . $id . ' AND {{data}}.path=\'tags\' AND {{tree}}.visible=1 AND {{reference}}.name=\'' . $_GET['tag'] . '\'
				ORDER BY {{tree}}.udate DESC
			';
            $list = DB::getPagi($sql);
        } else {
            $sql = 'SELECT * FROM {{tree}} WHERE parent=' . $id . ' AND visible=1 ORDER BY udate DESC';
            $list = DB::getPagi($sql);
        }
        foreach ($list as $item) {
            $field = Fields::getFieldsByTree($item['id'], 'wide');
            $path = Tree::getPathToTree($item['id']);
            $tags = array();
            $multi = Fields::getMultiFields($item['id']);
            foreach ($multi['tags'] as $tag) {
                $tags[] = Funcs::$referenceId['tags'][$tag]['name'];
            }
            $data[] = array('id' => $item['id'], 'name' => $item['name'], 'preview' => $field['preview'], 'path' => $path, 'udate' => $item['udate'], 'day' => date('d', strtotime($item['udate'])), 'mon' => Funcs::$monthsRus[date('n', strtotime($item['udate'])) - 1], 'date' => date('d', strtotime($item['udate'])) . ' ' . Funcs::$monthsRus[date('n', strtotime($item['udate'])) - 1] . ' ' . date('Y', strtotime($item['udate'])), 'pic' => $field['files_gal']['image'][0]['path'], 'tags' => $tags);
        }
        return $data;
    }
Ejemplo n.º 3
0
    public function getOne($id)
    {
        //die($id);
        if (!Cache::get('model' . $id)) {
            $fields = Fields::getReserveFieldsByModulePath('catalog');
            $sql = '
				SELECT {{catalog}}.*, {{tree}}.* FROM {{catalog}} 
				INNER JOIN {{tree}} ON {{catalog}}.tree={{tree}}.id
				WHERE {{tree}}.id =' . $id . '
			';
            $model = DB::getRow($sql);
            if ($model) {
                foreach ($fields as $key => $item) {
                    if (in_array($item['path'], OneSSA::$catalogStandart)) {
                        $temp[$item['path']] = $model[$item['path']];
                    }
                }
                $return = $temp;
                $return['id'] = $id;
                $parentpath = Tree::getPathToTree($model['parent']);
                $return['path'] = $parentpath . $id . '/';
                $return['tree'] = $id;
                $return['name'] = $model['name'];
                $return['parent'] = $model['parent'];
                $return['rating'] = $model['rating'];
                $return['report'] = Catalog::getCountReport($id);
                $return['sale'] = $item['price'] - $item['supprice'];
                $fields = Fields::getFieldsByTree($id, 'wide');
                $return['pics'] = $fields['files_gal']['image'];
                /*$date_b=explode('.', Funcs::$conf['akcia']['date_begin']);
                		$date_e=explode('.', Funcs::$conf['akcia']['date_end']);
                		$date_b=mktime(0,0,0,$date_b[1], $date_b[0],$date_b[2]);
                		$date_e=mktime(23,59,59,$date_e[1], $date_e[0],$date_e[2]);
                		$today=mktime();
                		$yes=0;
                		if (($today>=$date_b)&&($today<=$date_e))
                		$yes=1;
                		$akcia='0';
                		if ($yes==1)
                		$akcia=$model['akcia'];*/
                $return['akcia'] = $akcia;
                $return['files'] = $fields['files_gal']['application'];
                $multi = Fields::getMultiFields($id);
                if (count($multi['tv']) > 0) {
                    $return['descr1'] = 'Телевидение';
                    $return['descr2'] = Funcs::$referenceId['tv'][$multi['tv'][0]]['name'];
                }
                unset($fields['files_gal']);
                unset($fields['gal']);
                $return['additional'] = Catalog::getAdditionalFieldsArray($fields);
                Cache::set('model' . $id, $return);
                return $return;
            }
        } else {
            return Cache::get('model' . $id);
        }
    }