Ejemplo n.º 1
0
 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getServiceLocator()->get('Album\\Model\\AlbumTable')->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
Ejemplo n.º 2
0
 public function editimageAction()
 {
     $auth = new AuthenticationService();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('home');
     }
     $id = (int) $this->params('id');
     if (!$id) {
         return $this->redirect()->toRoute('addalbum');
     }
     $form = new AlbumForm($this->getRequest()->getBaseUrl() . '/application/album/edit/');
     $album = new Album();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $file = $this->params()->fromFiles('image');
         $albumss = $this->getAdminTable()->getAlbum($id);
         //print_r($albumss); die;
         $data = array('id' => $albumss->id, 'name' => $albumss->name, 'title' => $albumss->title, 'email' => $albumss->email, 'mob' => $albumss->mob, 'address' => $albumss->address, 'short_description' => $albumss->short_description, 'description' => $albumss->description, 'image' => $file['name']);
         $form->setData($data);
         if ($form->isValid()) {
             $adapter = new \Zend\File\Transfer\Adapter\Http();
             $adapter->setDestination(getcwd() . '/public/adminModule/img/AlbumImage/');
             unlink(getcwd() . '/public/adminModule/img/AlbumImage/' . $albumss->image);
             if ($adapter->receive($file['name'])) {
                 //echo $file['name']; die;
                 $album->exchangeArray($form->getData());
                 $this->getAdminTable()->saveAlbum($album);
                 return $this->redirect()->toRoute('album');
             }
         }
     }
     $viewModel = new ViewModel(array('form' => $form, 'id' => $id));
     $viewModel->setTerminal(true);
     return $viewModel;
 }