예제 #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;
     }
 }
예제 #2
0
 /** Link an image to a record
  */
 public function linkAction()
 {
     if ($this->_getParam('imageID', false)) {
         $form = new ImageLinkForm();
         $this->view->form = $form;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $updateData = array();
                 $updateData['image_id'] = $this->_getParam('imageID');
                 $updateData['find_id'] = $form->getValue('findID');
                 $updateData['secuid'] = $this->secuid();
                 $updateData['created'] = $this->getTimeForForms();
                 $updateData['createdBy'] = $this->getIdentityForForms();
                 foreach ($updateData as $key => $value) {
                     if (is_null($value) || $value == "") {
                         unset($updateData[$key]);
                     }
                 }
                 $images = new FindsImages();
                 $insert = $images->insert($updateData);
                 $findID = $form->getValue('findID');
                 $finds = new Finds();
                 $returns = $finds->fetchRow($finds->select()->where('secuid = ?', $findID));
                 $returnID = $returns->id;
                 $this->_helper->cache->remove('findtoimage' . $returnID);
                 $this->_flashMessenger->addMessage('You just linked an image to this record');
                 $this->_redirect('/database/artefacts/record/id/' . $returnID);
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }