Ejemplo n.º 1
0
 /** Redirect old url pattern to new find number
  * @todo move the db call to finds model and cache.
  */
 public function redirectAction()
 {
     $this->_helper->layout->disableLayout();
     if ($this->getParam('id', false)) {
         $finds = new Finds();
         $results = $finds->fetchRow($finds->select()->where('secuid = ?', $this->getParam('id')));
         if (!is_null($results)) {
             $id = (int) $results->id;
         } else {
             throw new Pas_Exception_Param($this->_nothingFound);
         }
         $this->getFlash()->addMessage('You have been redirected from an outdated link');
         $this->redirect(self::REDIRECT . $id);
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }
Ejemplo n.º 2
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;
     }
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
 /** Get the data for each comment
  * @return string
  * @throws Zend_Exception
  * @access public
  */
 public function getData()
 {
     switch ($this->getType()) {
         case 'findComment':
             $finds = new Finds();
             $data = $finds->fetchRow($finds->select()->where('id = ?', $this->getId()));
             break;
         case 'newsComment':
             $news = new News();
             $data = $news->fetchRow($news->select()->where('id = ?', $this->getId()));
             break;
         default:
             throw new Zend_Exception('That type of comment is not a choice');
     }
     return $data;
 }