galleryController.php
1.43 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
<?php
Class Admin_GalleryController Extends baseController {
public function preDispatch(){
$auth = new Auth();
if($auth->is_login_session() == false)Redirect('/admin/auth/');
}
public function index($product_id = 0)
{
$this->tpl->assign("product_id",$product_id);
/*$menu = new Menu($this->lang);
$row = $menu->view_params('gallery');
$this->tpl->assign('menu_one',$row);
$this->meta = array('title'=>$row['name']);*/
$products = new Products($this->lang);
$row = $products->getProduct($product_id);
$this->tpl->assign('product_one',$row);
$this->meta = array('title'=>$row['name']);
$gallery= new Gallery($this->lang);
$this->getParam['product_id'] = $product_id;
$res = $gallery->getGallery($this->getParam);
$this->tpl->assign("gallery",$res);
}
public function save($product_id,$id = 0){
$this->tpl->assign("product_id",$product_id);
$gallery = new Gallery($this->lang);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->error = $gallery->valid($this->postParam,$_FILES);
if(!$this->error){
$gallery->save($this->postParam,$_FILES);
Redirect($this->url.'/admin/gallery/index/'.$product_id.'/');
}
}
if($id != null){
$row = $gallery->view($id);
$this->tpl->assign('gallery', $row);
}
}
public function delete($product_id,$id = null){
if($id != null){
$gallery = new Gallery($this->lang);
$gallery->delete($id);
Redirect($this->url.'/admin/gallery/index/'.$product_id.'/');
}
}
}
?>