Exemplo n.º 1
0
 public function addAction()
 {
     $form = new ProductForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $product = new Product();
         $form->setInputFilter($product->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $product->exchangeArray($form->getData());
             //$this->getProductTable()->saveProduct($product);
             $adapter = new \Zend\File\Transfer\Adapter\Http();
             $dir = getcwd() . '/public/img/';
             $data = $form->getData();
             $filename = $data['image'];
             $fileTlsName = $dir . $filename;
             // pashet
             //$adapter->addValidator('Extension', false, 'jpg,png,gif');
             var_dump($adapter);
             die;
             //var_dump($fileTlsName);die;
             //$adapter->addFilter('Rename', $fileTlsName);// rename file
             if ($adapter->receive($filename)) {
                 // upload file
                 return $this->redirect()->toRoute('product');
             }
         }
     }
     return array('form' => $form);
 }
Exemplo n.º 2
0
 public function addAction()
 {
     if ($this->zfcUserAuthentication()->hasIdentity() && $this->zfcUserAuthentication()->getIdentity()->getRole() == "admin") {
         $form = new ProductForm();
         $request = $this->getRequest();
         if ($request->isPost()) {
             $product = new Product();
             $form->setInputFilter($product->getInputFilter());
             $form->setData(array_merge($request->getPost()->toArray(), $request->getFiles()->toArray()));
             if ($form->isValid()) {
                 $fileName = $form->getData()['image']['name'];
                 if (move_uploaded_file($form->getData()['image']['tmp_name'], getcwd() . '/public/img/' . $fileName)) {
                     echo "Файл корректен и был успешно загружен.\n";
                 } else {
                     echo "Возможная атака с помощью файловой загрузки!\n";
                 }
                 $product->exchangeArray($form->getData());
                 $this->getProductTable()->saveProduct($product);
                 // Redirect to list of products
                 return $this->redirect()->toRoute('product');
             }
         }
         return array('form' => $form);
     } else {
         $view = new ViewModel(array('message' => 'GET OUT OF HERE!'));
         $view->setTemplate('product/error/access');
         return $view;
     }
 }
Exemplo n.º 3
0
 public function addAction()
 {
     $form = new ProductForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $product = new Product();
         $form->setInputFilter($product->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $product->exchangeArray($form->getData());
             $this->getProductTable()->saveProduct($product);
             return $this->redirect()->toRoute('product');
         }
     }
     return array('form' => $form);
 }
Exemplo n.º 4
0
 public function addAction()
 {
     $form = new ProductForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $product = new Product();
         $form->setInputFilter($product->getInputFilter());
         $form->setData($request->getPost());
         var_dump($request->getPost());
         if ($form->isValid()) {
             $product->exchangeArray($form->getData());
             $this->getProductTable()->saveProduct($product);
             // Redirect to list of products
             return $this->redirect()->toRoute('product');
         } else {
             echo 'NOPE';
         }
     }
     return array('form' => $form, 'shops' => $this->getShopTable()->fetchAll($this->getServiceLocator()->get('AuthService')->getStorage()->read()->id), 'product_categories' => $this->getProductCategoryTable()->fetchAll($this->getServiceLocator()->get('AuthService')->getStorage()->read()->id));
 }
 public function statusAction()
 {
     $view = new ViewModel();
     $this->layout('layout/bags');
     $id = $this->params()->fromRoute('id', 0);
     $status = $this->params()->fromRoute('status', 0);
     $ProductTable = $this->getServiceLocator()->get('ProductTable');
     if ($id == 0) {
         return $this->redirect()->toRoute('Product', array('controller' => 'product', 'action' => 'list-news'));
     } else {
         $exchange_data = array();
         $exchange_data['id'] = $id;
         $exchange_data['status'] = $status;
         $Product = new Product();
         $Product->exchangeArray($exchange_data);
         $checkupdate = $ProductTable->savestatus($Product);
         $view->id = $id;
         $view->check = $checkupdate;
         return $view;
     }
 }
Exemplo n.º 6
0
 public function statusAction()
 {
     $view = new ViewModel();
     $this->layout('layout/apotravinyadmin');
     $id = $this->params()->fromRoute('id', 0);
     $status = $this->params()->fromRoute('status', 0);
     if ($status == '1') {
         $status_update = '0';
     } else {
         if ($status == '0') {
             $status_update = '1';
         }
     }
     $ProductTable = $this->getServiceLocator()->get('ProductTable');
     if ($id == 0) {
         return $this->redirect()->toRoute('Crowler', array('controller' => 'index', 'action' => 'index'));
     } else {
         $exchange_data = array('id' => $id, 'status' => $status_update);
         //           print_r($exchange_data);die;
         $ProductTable_data = new Product();
         $ProductTable_data->exchangeArray($exchange_data);
         $checkupdate = $ProductTable->savestatus($ProductTable_data);
         // print_r($checkupdate);die;
         $view->id = $id;
         $view->check = $checkupdate;
         return $view;
     }
 }