Ejemplo n.º 1
0
 /** Edit a specific image
  * @access public
  * @throws Pas_Exception_Param
  */
 public function editAction()
 {
     if ($this->getParam('id', 0)) {
         $help = new Help();
         $this->view->contents = $help->fetchRow('id = 14')->toArray();
         $form = new ImageEditForm();
         $form->submit->setLabel('Update image');
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             if ($form->isValid($this->_request->getPost())) {
                 $updateData = $form->getValues();
                 $where = $this->_images->getAdapter()->quoteInto('imageID = ?', $this->getParam('id'));
                 $this->_images->update($updateData, $where);
                 $this->_helper->solrUpdater->update('images', $this->getParam('id'));
                 $this->getFlash()->addMessage('Image and metadata updated!');
                 $this->redirect(self::REDIRECT . 'image/id/' . $this->getParam('id'));
             } else {
                 $form->populate($this->_request->getPost());
             }
         } else {
             $id = (int) $this->_request->getParam('id', 0);
             $image = $this->_images->getImage($id);
             if (!empty($image)) {
                 $form->populate($image['0']);
             } else {
                 throw new Pas_Exception('No image with that ID found', 500);
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }