productsController.php
4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
Class ProductsController Extends baseController {
protected $_navig = array('name'=>"products");
public function index()
{
}
public function hit($prefix){
$menu = new Menu($this->lang);
$row = $menu->view_params('');
$this->tpl->assign('menu_one',$row);
$this->meta = array('title'=>$row['title'],'description'=>$row['description'],'keywords'=>$row['keywords'],'about'=>$row['about']);
$info = new Info($this->lang);
$row = $info->view($prefix);
$this->tpl->assign('text',$row);
$products = new Products($this->lang);
$this->tpl->assign('products',$products->getHit());
}
public function view($brend_translit = null,$catalog_translit = null)
{
$brends = new Brends($this->lang);
$brend_id = $brends->getTranslit($brend_translit);
Catalog::$brend_id = $brend_id;
Catalog::$brend_translit = $brend_translit;
$row = $brends->getBrend($brend_id);
$this->meta = array('title'=>$row['meta_title'],'description'=>$row['meta_description'],'keywords'=>$row['meta_keywords']);
$this->tpl->assign('brend',$row);
if($catalog_translit != null){
$catalog = new Catalog($this->lang);
$catalog_id = $catalog->getTranslit($catalog_translit);
Catalog::$catalog_id = $catalog_id;
$this->tpl->assign('catalog_id',$catalog_id);
$row = $catalog->getRubric($catalog_id);
$this->meta = array('title'=>$row['meta_title'],'description'=>$row['meta_description'],'keywords'=>$row['meta_keywords']);
$this->tpl->assign('rubric',$row);
}
$banners = new Banners($this->lang);
$res = $banners->viewBannerBlock($brend_id,1,1);
$this->tpl->assign('banner_top',$res);
$products = new Products($this->lang);
$this->tpl->assign('products',$products->getView($brend_id,$catalog_id,$this->getParam));
}
public function search()
{
$this->meta = array('title'=>"Ïîèñê",'description'=>"Ïîèñê",'keywords'=>"Ïîèñê");
$products = new Products($this->lang);
$this->tpl->assign('products',$products->getView(false,false,$this->getParam));
}
public function view_filter($filter_translit){
$filters = new Filters($this->lang);
$filter_id = $filters->getTranslit($filter_translit);
$row = $filters->getFilter($filter_id);
$this->meta = array('title'=>$row['meta_title'],'description'=>$row['meta_description'],'keywords'=>$row['meta_keywords']);
$this->tpl->assign('filter',$row);
$list = $filters->getListFilters($filter_id);
$this->tpl->assign('filters_list',$list);
$this->getParam['filter_id'] = $filter_id;
$products = new Products($this->lang);
$this->tpl->assign('products',$products->getView(null,$this->getParam));
}
public function open($brend_translit,$catalog_translit,$product_id = 0)
{
$brends = new Brends($this->lang);
$brend_id = $brends->getTranslit($brend_translit);
Catalog::$brend_id = $brend_id;
Catalog::$brend_translit = $brend_translit;
$row = $brends->getBrend($brend_id);
$this->tpl->assign('brend',$row);
$banners = new Banners($this->lang);
$res = $banners->viewBannerBlock($brend_id,1,1);
$this->tpl->assign('banner_top',$res);
$catalog = new Catalog($this->lang);
$catalog_id = $catalog->getTranslit($catalog_translit);
Catalog::$catalog_id = $catalog_id;
$this->tpl->assign('catalog_id',$catalog_id);
$gallery = new Gallery($this->lang);
$this->tpl->assign('gallery',$gallery->getViewProduct($product_id));
$products = new Products($this->lang);
$products->addViewProduct($product_id);
$this->tpl->assign('recommended',$products->getRecommended($product_id));
$row = $products->getProduct($product_id);
$this->meta = array('title'=>$row['meta_title'],'description'=>$row['meta_description'],'keywords'=>$row['meta_keywords']);
$this->tpl->assign('product',$row);
$reviews = new Reviews($this->lang);
if(isset($this->postParam['send'])){
$this->error = $reviews->valid($this->postParam);
if(!$this->error){
$reviews->save($this->postParam,"products",$product_id);
Redirect('?send=ok#reviews');
}
}
$this->tpl->assign('reviews',$reviews->getAll("products",$product_id));
}
public function basket(){
$products = new Products($this->lang);
if(isset($this->postParam['send_order'])){
$this->error = $products->valid($this->postParam);
if(!$this->error){
$people = new People($this->lang);
if(!$people_id = $people->isLogin()){
if($people_id = $people->isEmail($this->postParam['order_email'])){
}else{
$people_id = $people->savePeople($this->postParam);
}
$people->sendLoginPswPeople($people_id);
}
$people->saveOrder($people_id,$this->postParam);
$products->sendOrder($this->postParam);
Redirect($this->url.'/products/basket_ok/');
}
}
if(isset($this->postParam['product_count'])){
$products->updateBasket($this->postParam);
}
$res = $products->getBasketProducts();
$this->tpl->assign('basket_products',$res);
$sumCost = $products->getSumCost();
$this->tpl->assign('sumCost',$sumCost);
}
public function basket_ok(){
}
}
?>