public function testShouldThrowExceptionWhenSourceClassNotFound()
 {
     //GIVEN
     $sSourceFile = 'source_file.fail';
     //WHEN
     $this->_oStandardMock->expects($this->any())->method('is_file')->with($this->equalTo($sSourceFile))->will($this->returnValue(true));
     //THEN
     $this->setExpectedException('AM_Resource_Factory_Exception', '', 502);
     //WHEN
     $oSource = AM_Resource_Factory::create($sSourceFile);
 }
Exemple #2
0
 /**
  * Get all page of PDF and convert them to the png
  * @return array
  * @throws AM_Model_Db_StaticPdf_Data_Exception
  */
 public function getAllPagesThumbnails()
 {
     $sResource = $this->_sResourceDir . DIRECTORY_SEPARATOR . $this->getResourceBaseName();
     $oImageSource = AM_Resource_Factory::create($sResource);
     if (!$oImageSource instanceof AM_Resource_Concrete_Pdf) {
         throw new AM_Model_Db_StaticPdf_Data_Exception(sptintf('Wrong resource given "%s". Must be a PDF resource', $sResource));
     }
     $aFiles = $oImageSource->getAllPagesThumbnails();
     return $aFiles;
 }
Exemple #3
0
 /**
  * Get first page of PDF file and conver it the PNG
  * @return string
  * @throws AM_Model_Db_IssueHelpPage_Data_Exception
  */
 public function getFirstPageAsPng()
 {
     $sResource = $this->_sResourceDir . DIRECTORY_SEPARATOR . $this->getResourceBaseName();
     $oImageSource = AM_Resource_Factory::create($sResource);
     if (!$oImageSource instanceof AM_Resource_Concrete_Pdf) {
         throw new AM_Model_Db_IssueHelpPage_Data_Exception(sptintf('Wrong resource given "%s". Must be a PDF resource', $sResource));
     }
     $sFirstPagePath = $oImageSource->getFileForThumbnail();
     return $sFirstPagePath;
 }
Exemple #4
0
 /**
  * Add sorce file to thumbnailer
  * @param string $sFilePath path to image file
  * @return AM_Handler_Thumbnail
  * @throws AM_Handler_Thumbnail_Exception
  */
 public function addSourceFile($sFilePath)
 {
     $oSource = AM_Resource_Factory::create((string) $sFilePath);
     if (!is_object($oSource) || !$oSource instanceof AM_Resource_Abstract) {
         throw new AM_Handler_Thumbnail_Exception(sprintf('Wrong source given', 501));
     }
     $this->_aSources[] = $oSource;
     return $this;
 }
 /**
  * Resizes elements
  */
 protected function _resizeElements()
 {
     $oQuery = AM_Model_Db_Table_Abstract::factory('element_data')->select()->setIntegrityCheck(false)->from('element_data')->joinInner('element', 'element.id = element_data.id_element')->joinInner('page', 'page.id = element.page')->joinInner('revision', 'revision.id = page.revision')->joinInner('issue', 'issue.id = revision.issue')->joinInner('application', 'application.id = issue.application')->joinInner('client', 'client.id = application.client')->where(sprintf('element_data.key_name IN ("%s", "%s", "%s")', AM_Model_Db_Element_Data_Resource::DATA_KEY_RESOURCE, AM_Model_Db_Element_Data_MiniArticle::DATA_KEY_THUMBNAIL, AM_Model_Db_Element_Data_MiniArticle::DATA_KEY_THUMBNAIL_SELECTED))->where('page.deleted = ?', 'no')->where('revision.deleted = ?', 'no')->where('issue.deleted = ?', 'no')->where('application.deleted = ?', 'no')->where('client.deleted = ?', 'no')->columns(array('id' => 'element_data.id_element'))->order('element_data.id_element ASC');
     /* @var $oQuery Zend_Db_Table_Select */
     if ($this->_iFromId > 0) {
         $oQuery->where('element_data.id_element > ?', $this->_iFromId);
     }
     if ($this->_iElementId > 0) {
         $oQuery->where('element_data.id_element = ?', $this->_iElementId);
     }
     if ($this->_iPageId > 0) {
         $oQuery->where('page.id = ?', $this->_iPageId);
     }
     if ($this->_iRevisionId > 0) {
         $oQuery->where('revision.id = ?', $this->_iRevisionId);
     }
     if ($this->_iIssueId > 0) {
         $oQuery->where('issue.id = ?', $this->_iIssueId);
     }
     if ($this->_iApplicationId > 0) {
         $oQuery->where('application.id = ?', $this->_iApplicationId);
     }
     $oElementDatas = AM_Model_Db_Table_Abstract::factory('element_data')->fetchAll($oQuery);
     $iCounter = 0;
     foreach ($oElementDatas as $oElementData) {
         try {
             $oData = $oElementData->getData();
             $bZoom = (bool) $oElementData->getData()->getDataValue(AM_Model_Db_Element_Data_Gallery::DATA_KEY_ENABLE_ZOOM, false);
             if (!is_null($oData) && method_exists($oData, 'getThumbnailPresetName')) {
                 $this->_resizeImage($oElementData->value, $oElementData->getElement(), AM_Model_Db_Element_Data_Resource::TYPE, $oElementData->key_name, $oElementData->getData()->getThumbnailPresetName(), $bZoom);
                 $sFileExtension = strtolower(pathinfo($oElementData->value, PATHINFO_EXTENSION));
                 if ('pdf' == $sFileExtension && AM_Model_Db_Element_Data_Resource::DATA_KEY_RESOURCE == $oElementData->key_name) {
                     $oData->delete(AM_Model_Db_Element_Data_Resource::PDF_INFO, false);
                     $sFilePath = AM_Tools::getContentPath(AM_Model_Db_Element_Data_Resource::TYPE, $oElementData->getElement()->id) . DIRECTORY_SEPARATOR . AM_Model_Db_Element_Data_Resource::DATA_KEY_RESOURCE . '.' . $sFileExtension;
                     $oResource = AM_Resource_Factory::create($sFilePath);
                     $sPdfInfo = $oResource->getPdfInfo();
                     $oData->addKeyValue(AM_Model_Db_Element_Data_Resource::PDF_INFO, $sPdfInfo);
                 }
             }
         } catch (Exception $oException) {
             $this->_echo(sprintf('%s', $oException->getMessage()), 'error');
         }
         if ($iCounter++ > 100) {
             $iCounter = 0;
             AM_Handler_Temp::getInstance()->end();
         }
     }
 }