shopsController.php 1.21 KB
<?php

Class Admin_ShopsController Extends baseController {

protected $_navig = array('name'=>"Íîâîñòè");

public function preDispatch(){
  $auth = new Auth();
  if($auth->is_login_session() == false)Redirect('/admin/auth/');
}

public function index($n = 0)
{
 $menu = new Menu($this->lang);
 $row = $menu->view_params('shops');
 $this->tpl->assign('menu_one',$row);
 $this->meta = array('title'=>$row['name']);

 $shops = new Shops($this->lang);
 $res = $shops->getShops();
 $this->tpl->assign("shops",$res);
}

public function save($id = 0){
	$brends = new Brends($this->lang);

  $shops = new Shops($this->lang);
  if ($_SERVER["REQUEST_METHOD"] == "POST") {
     $this->error = $shops->valid($this->postParam,$_FILES);
     if(!$this->error){
      $shops->save($this->postParam,$_FILES);
      Redirect($this->url.'/admin/shops/');
     }
  }
  if($id != null){
   $row = $shops->view($id);
   $this->tpl->assign('shop', $row);
   $this->tpl->assign('shop_brends',$brends->getShopBrends($id));
  }
  
	$this->tpl->assign('brends',$brends->getRubrics_tree());  
}


public function delete($id = null){
  if($id != null){
   $shops = new Shops($this->lang);
   $shops->delete($id);
   Redirect($this->url.'/admin/shops/');
  }
}

}
?>