コード例 #1
0
ファイル: BannerController.php プロジェクト: hoaitn/base-zend
 public function editAction()
 {
     $this->view->Title = "Quản lý quảng cáo";
     $this->view->headTitle($this->view->Title);
     $Banner = Banner::getById($this->getRequest()->getParam('id'));
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest()->getParams();
         //checkform
         if ($_FILES['images']['name']) {
             $dir = new My_Plugin_Libs();
             $name = $dir->trimSpacer($request['title']);
             $dirname = "uploads/banner/" . $Banner->id . "/";
             $upload = new My_Plugin_Upload();
             $error = $upload->uploadImageFile($_FILES['images'], 2048, 1024, 1024000, array("image/png", "image/jpg", "image/gif", "image/x-png", "image/jpeg"), $dirname);
             if (!$error) {
                 $filename = $upload->fileName;
             }
         }
         if (count($error) == 0) {
             $Banner->merge($request);
             if ($filename != "") {
                 $Banner->image = $filename;
             }
             $Banner->save();
             $this->Member->log('Quảng cáo:' . $Banner->name . '(' . $Banner->id . ')', 'Sửa chữa');
             My_Plugin_Libs::setSplash('Quảng cáo: <b>' . $Banner->name . '</b> đã sửa thành công. ');
             //redirect to list
             $this->_redirect($this->_helper->url('index', 'banner', 'admin'));
         }
         if (count($error)) {
             $this->view->error = $error;
         }
     }
     $this->view->Banner = $Banner;
 }
コード例 #2
0
ファイル: NewsController.php プロジェクト: hoaitn/base-zend
 public function editAction()
 {
     $this->view->Title = "Management news";
     $this->view->headTitle($this->view->Title);
     $Content = News::getById($this->getRequest()->getParam('id'));
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest()->getParams();
         //checkform
         $error = $this->_checkForm($request);
         if ($_FILES['images']['name']) {
             $dir = new My_Plugin_Libs();
             $name = $dir->trimSpacer($request['title']);
             $dirname = "uploads/news/" . $Content->id . "/";
             $upload = new My_Plugin_Upload();
             $error = $upload->uploadImageFile($_FILES['images'], 800, 600, 1024000, array("image/png", "image/jpg", "image/gif", "image/x-png", "image/jpeg"), $dirname);
             if (!$error) {
                 $filename = $upload->fileName;
             }
         }
         if (count($error) == 0) {
             $Content->merge($request);
             if ($filename != "") {
                 $Content->images = $filename;
             }
             $Content->members_id = $this->Member->id;
             $Content->created_date = date("Y-m-d H:i:s");
             $Content->save();
             $this->Member->log('News:' . $Content->title . '(' . $Content->id . ')', 'Edited');
             My_Plugin_Libs::setSplash('Edit: <b>' . $Content->title . '</b> have been completed. ');
             //redirect to list
             $this->_redirect($this->_helper->url('index', 'news', 'admin'));
         }
         if (count($error)) {
             $this->view->error = $error;
         }
     }
     $this->view->News = $Content;
 }
コード例 #3
0
ファイル: ColorController.php プロジェクト: hoaitn/base-zend
 public function deleteAction()
 {
     $Product = Color::getById($this->getRequest()->getParam('id'));
     if ($Product) {
         if ($this->getRequest()->isPost()) {
             $dir = new My_Plugin_Libs();
             $name = $dir->trimSpacer($request['car_paint_color']);
             $dirname = "uploads/color/" . $name . "/" . $Product->image;
             if (is_file($dirname)) {
                 @chmod($dirname, 0666);
                 @unlink($dirname);
             }
             $Product->delete();
             $this->Member->log('Phong thủy xe: ' . $Product->car_paint_color . '(' . $this->getRequest()->getParam('id') . ')', 'Xóa');
             My_Plugin_Libs::setSplash('Phong thủy xe: <b>' . $Product->car_paint_color . '</b> đã được xóa khỏi hệ thống.');
             $this->_redirect($this->_helper->url('index', 'color', 'admin'));
         }
         $this->view->Color = $Product;
     }
 }