/** Edit a specific image */ public function editAction() { if ($this->_getParam('id', 0)) { $form = new ImageEditForm(); $form->submit->setLabel('Update image..'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $updateData = array(); $updateData['label'] = $form->getValue('label'); $updateData['imagerights'] = $form->getValue('imagerights'); $updateData['county'] = $form->getValue('county'); $updateData['period'] = $form->getValue('period'); $updateData['updated'] = $this->getTimeForForms(); $updateData['updatedBy'] = $this->getIdentityForForms(); foreach ($updateData as $key => $value) { if (is_null($value) || $value == "") { unset($updateData[$key]); } } $where = $this->_images->getAdapter()->quoteInto('imageID = ?', $this->_getParam('id')); $rotate = $form->getValue('rotate'); $filename = $form->getValue('filename'); $imagedir = $form->getValue('imagedir'); $regenerate = $form->getValue('regenerate'); $path = './' . $imagedir . $filename; $largepath = './' . $imagedir; $mediumpath = './' . $imagedir . 'medium/'; $smallpath = './' . $imagedir . 'small/'; $displaypath = './' . $imagedir . 'display/'; $thumbpath = self::PATH . 'thumbnails/'; $id = $this->_getParam('id'); $name = substr($filename, 0, strrpos($filename, '.')); $ext = '.jpg'; if (isset($rotate)) { //rotate original $phMagickOriginal = new phMagick($largepath . $filename, $largepath . $filename); $phMagickOriginal->rotate($rotate); //rotate image for medium if (file_exists($mediumpath . $name . $ext)) { $phMagickMedium = new phMagick($mediumpath . $name . $ext, $mediumpath . $name . $ext); $phMagickMedium->rotate($rotate); // Zend_Debug::dump($phMagickMedium); } else { $phMagickMediumCreate = new phMagick($largepath . $filename, $mediumpath . $name . $ext); $phMagickMediumCreate->resize(500, 0); $phMagickMediumCreate->rotate($rotate); $phMagickMediumCreate->convert(); // Zend_Debug::dump($phMagickMediumCreate); } //rotate small image if (file_exists($smallpath . $name . $ext)) { $phMagickSmall = new phMagick($smallpath . $name . $ext, $smallpath . $name . $ext); $phMagickSmall->rotate($rotate); //Zend_Debug::dump($phMagickSmall); } else { $phMagickSmallCreate = new phMagick($largepath . $filename, $smallpath . $name . $ext); $phMagickSmallCreate->resize(40, 0); $phMagickSmallCreate->rotate($rotate); $phMagickSmallCreate->convert(); //Zend_Debug::dump($phMagickSmallCreate); } //rotate display image if (file_exists($displaypath . $name . $ext)) { $phMagickDisplay = new phMagick($displaypath . $name . $ext, $displaypath . $name . $ext); $phMagickDisplay->rotate($rotate); // Zend_Debug::dump($phMagickDisplay); } else { $phMagickDisplayCreate = new phMagick($largepath . $name . $ext, $displaypath . $name . $ext); $phMagickDisplayCreate->resize(0, 150); $phMagickDisplayCreate->rotate($rotate); $phMagickDisplayCreate->convert(); //Zend_Debug::dump($phMagickDisplayCreate); } //rotate thumbnail if (file_exists($thumbpath . $id . '.jpg')) { $phMagickThumb = new phMagick($thumbpath . $id . '.jpg', $thumbpath . $id . '.jpg'); $phMagickThumb->rotate($rotate); //Zend_Debug::dump($phMagickThumb); } else { $thumbpath = self::PATH . 'thumbnails/'; $originalpath = $path; $phMagickRegen = new phMagick($originalpath, $thumbpath . $id . '.jpg'); $phMagickRegen->resize(100, 0); $phMagickRegen->convert(); } } if (isset($regenerate)) { $thumbpath = self::PATH . 'thumbnails/'; $originalpath = $path; $phMagickRegen = new phMagick($originalpath, $thumbpath . $id . '.jpg'); $phMagickRegen->resize(100, 0); $phMagickRegen->convert(); } $update = $this->_images->update($updateData, $where); //Update the solr instance $this->_helper->solrUpdater->update('beoimages', $this->_getParam('id')); $this->_helper->cache->remove('findtoimage' . $this->_getParam('id')); $this->_flashMessenger->addMessage('Image and metadata updated!'); $this->_redirect(self::REDIRECT . 'image/id/' . $this->_getParam('id')); } else { $form->populate($form->getValues()); } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $image = $this->_images->getImage($id); $form->populate($image['0']); } } } else { throw new Exception($this->_missingParameter); } }
/** 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); } }