Esempio n. 1
0
 /** Add and resize images
  * @access public
  * @param array $imageData
  */
 public function addAndResize($imageData)
 {
     // Loop through the array of objects to add
     foreach ($imageData as $data) {
         $finds = new Finds();
         $findID = $finds->fetchRow($finds->select()->where('id = ?', $data->findID))->secuid;
         // Create the image data array
         $images = array('secuid' => $data->secuid, 'filesize' => $data->size, 'filename' => $data->name, 'mimetype' => $data->mimetype, 'filecreated' => $this->timeCreation(), 'institution' => $this->getInstitution(), 'created' => $this->timeCreation(), 'createdBy' => $this->getUserNumber(), 'ccLicense' => 4, 'imagerights' => $this->getCopyright());
         // Create the linking data
         $linkData = array('find_id' => $findID, 'image_id' => $data->secuid, 'created' => $this->timeCreation(), 'createdBy' => $this->getUserNumber(), 'secuid' => $this->generateSecuId());
         // Insert the image data to slides table
         $slideID = parent::insert($images);
         // Create the links in the link table
         $links = new FindsImages();
         // Insert that data
         $links->insert($linkData);
         // Now process the images
         $processor = new Pas_Image_Magick();
         // Set the path
         $processor->setImage($data->path);
         // Set the thumbnail image number from slide insertion - must be an integer
         $processor->setImageNumber((int) $slideID);
         // Resize loop
         $processor->resize();
         return $slideID;
     }
 }
Esempio n. 2
0
 /** Unlink an image from a record
  */
 public function unlinkAction()
 {
     if ($this->_getParam('returnID', false)) {
         $this->view->findID = $this->_getParam('secuid');
         $this->view->returnID = $this->_getParam('returnID');
         if ($this->_request->isPost()) {
             $id = (int) $this->_request->getPost('id');
             $del = $this->_request->getPost('del');
             if ($del == 'Yes' && $id > 0) {
                 $imageID = $this->_request->getPost('imageID');
                 $findID = $this->_request->getPost('findID');
                 $slides = new Slides();
                 $imagedata = $slides->fetchRow('imageID = ' . $id);
                 $imageID = $imagedata['secuid'];
                 $linked = new FindsImages();
                 $where = array();
                 $where[] = $linked->getAdapter()->quoteInto('image_id = ?', $imageID);
                 $where[] = $linked->getAdapter()->quoteInto('find_id = ?', $findID);
                 $linked->delete($where);
                 $this->_flashMessenger->addMessage('Image and links deleted!');
                 $this->_redirect('/database/artefacts/record/id/' . $this->_getParam('returnID'));
                 $this->_helper->cache->remove('findtoimage' . $returnID);
             }
         } else {
             $id = (int) $this->_request->getParam('id');
             if ((int) $id > 0) {
                 $this->view->slide = $this->_images->fetchRow($slides->select()->where('imageID = ?', $id));
                 $this->view->params = $this->_getAllParams();
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }
Esempio n. 3
0
 /** Delete an image
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     if ($this->_request->isPost()) {
         $id = (int) $this->_request->getPost('id');
         $del = $this->_request->getPost('del');
         if ($del == 'Yes' && $id > 0) {
             $imagedata = $this->_images->getFileName($id);
             $filename = $imagedata['0']['f'];
             $splitf = explode('.', $filename);
             $spf = $splitf['0'];
             $imagedir = $imagedata['0']['imagedir'];
             $imagenumber = $imagedata['0']['imageID'];
             $zoom = './' . $imagedir . 'zoom/' . $spf . '_zdata';
             $thumb = IMAGE_PATH . 'thumbnails/' . $imagenumber . '.jpg';
             $small = './' . $imagedir . 'small/' . $filename;
             $display = './' . $imagedir . 'display/' . $filename;
             $medium = './' . $imagedir . 'medium/' . $filename;
             $original = './' . $imagedir . $filename;
             $where = 'imageID = ' . $id;
             $this->_images->delete($where);
             $this->_helper->solrUpdater->deleteById('images', $id);
             $linked = new FindsImages();
             $wherelinks = array();
             $wherelinks[] = $linked->getAdapter()->quoteInto('image_id = ?', $imagedata['0']['secuid']);
             $linked->delete($wherelinks);
             $this->getFlash()->addMessage('Image and metadata deleted');
             unlink($thumb);
             unlink($display);
             unlink($small);
             unlink($original);
             unlink($medium);
             unlink(strtolower($thumb));
             unlink(strtolower($display));
             unlink(strtolower($small));
             unlink(strtolower($original));
             unlink(strtolower($medium));
             unlink($zoom);
         }
         $this->redirect('/database/myscheme/myimages/');
     } else {
         $id = (int) $this->_request->getParam('id');
         if ((int) $id > 0) {
             $this->view->slide = $this->_images->fetchRow('imageID =' . $id);
         }
     }
 }
Esempio n. 4
0
 public function deleteimagelinkAction()
 {
     if ($this->_getParam('id', false)) {
         $links = new FindsImages();
         $where = $links->getAdapter()->quoteInto('id = ?', (int) $this->_getParam('id'));
         $links->delete($where);
     } else {
         throw new Exception('No parameter on url string');
     }
 }
Esempio n. 5
0
 /** Delete image link
  * @access public
  * @return mixed
  */
 public function deleteimagelinkAction()
 {
     if ($this->getParam('id', false)) {
         $links = new FindsImages();
         $where = $links->getAdapter()->quoteInto('id = ?', (int) $this->getParam('id'));
         $links->delete($where);
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }