Beispiel #1
0
 /**
  * Construct this job.
  * 
  * Sets properties needed during the process.
  */
 public function __construct(array $options)
 {
     parent::__construct($options);
     // Set the storage.
     $this->_storage = Zend_Registry::get('storage');
     if (!$this->_storage->getAdapter() instanceof Omeka_Storage_Adapter_Filesystem) {
         throw new Omeka_Storage_Exception(__('The storage adapter is not an instance of Omeka_Storage_Adapter_Filesystem.'));
     }
     // Set the image creator.
     try {
         $this->_imageCreator = Zend_Registry::get('file_derivative_creator');
     } catch (Zend_Exception $e) {
         throw new Omeka_File_Derivative_Exception(__('The ImageMagick directory path is missing.'));
     }
     // Set the configured derivative types and constraints.
     foreach ($this->_validDerivativeTypes as $type) {
         if (!is_array($this->_options['derivative_types']) || in_array($type, $this->_options['derivative_types'])) {
             $this->_derivatives[$type] = get_option("{$type}_constraint");
         }
     }
 }
Beispiel #2
0
 /**
  * Returns whether the report can be stored in the associated Omeka_Storage object
  *
  * @param array &$errors The array of errors for why a file cannot store
  * @return bool whether the report can be stored in the associated Omeka_Storage object  
  */
 public function canStore(&$errors)
 {
     // this is a hack because Omeka_Storage_Adapter_Filesystem
     // does not correctly implement canStore when the localDir
     // has been changed. It also offers no way to remove the subDirs
     // we don't use or care about.
     // So we must directly test whether the directory we plan to write to is writeable
     $ad = $this->_storage->getAdapter();
     if ($ad instanceof Omeka_Storage_Adapter_Filesystem) {
         $opt = $ad->getOptions();
         $localDir = $opt['localDir'];
         $absPath = $localDir . '/' . $this->_storagePrefixDir;
         // this reimplements Omeka_Storage_Adapter_Filesystem::_getAbsPath
         $result = is_writable($absPath);
         if (!$result) {
             if (!$errors) {
                 $errors = array();
             }
             $errors[] = __("Make sure that %s is exists and is writeable.", $absPath);
         }
         return $result;
     }
     return $this->_storage->canStore();
 }