示例#1
0
 protected function setUp()
 {
     $this->_files = dirname(dirname(dirname(__FILE__))) . '/data';
     $this->_data = dirname(dirname(dirname(dirname(__FILE__)))) . '/data';
     Media_Info::config(array('image' => new Media_Info_Adapter_GenericMock(null), 'audio' => new Media_Info_Adapter_GenericMock(null), 'document' => new Media_Info_Adapter_GenericMock(null), 'video' => new Media_Info_Adapter_GenericMock(null)));
     Mime_Type::config('Magic', array('adapter' => 'Freedesktop', 'file' => "{$this->_data}/magic.db"));
     Mime_Type::config('Glob', array('adapter' => 'Freedesktop', 'file' => "{$this->_data}/glob.db"));
 }
示例#2
0
 public function testHasManyWithMissingMediaAdapters()
 {
     $_backupConfig = Configure::read('Media');
     $_backupProcess = Media_Process::config();
     $_backupInfo = Media_Info::config();
     $s = array('convert' => 'image/png', 'zoomCrop' => array(100, 100));
     $m = array('convert' => 'image/png', 'fitCrop' => array(300, 300));
     $l = array('convert' => 'image/png', 'fit' => array(600, 440));
     Configure::write('Media.filter', array('audio' => compact('s', 'm'), 'document' => compact('s', 'm'), 'generic' => array(), 'image' => compact('s', 'm', 'l'), 'video' => compact('s', 'm')));
     Media_Process::config(array('image' => null));
     Media_Info::config(array('image' => null));
     $Model = $this->_model('hasMany');
     $file = $this->Data->getFile(array('image-jpg.jpg' => 'ta.jpg'));
     $data = array('Movie' => array('title' => 'Weekend', 'director' => 'Jean-Luc Godard'), 'Attachment' => array(array('file' => $file, 'model' => 'Movie')));
     $Model->create();
     $result = false;
     $expected = null;
     try {
         $result = $Model->saveAll($data, array('validate' => 'first'));
     } catch (Exception $exception) {
         $expected = $exception;
     }
     if ($expected === null) {
         $this->fail('Expected Model::saveAll to raise an error.');
     }
     $this->assertFalse($result);
     $this->assertTrue(file_exists($this->Data->settings['transfer'] . 'img' . DS . 'ta.jpg'));
     $result = $Model->find('first', array('conditions' => array('title' => 'Weekend')));
     $expected = array(0 => array('id' => '1', 'model' => 'Movie', 'foreign_key' => '4', 'dirname' => 'img', 'basename' => 'ta.jpg', 'checksum' => '073addc9c90e4d20a9a19d8a31e01b39', 'group' => null, 'alternative' => null, 'path' => 'img/ta.jpg'));
     $this->assertEqual($result['Attachment'], $expected);
     Media_Process::config($_backupProcess);
     Media_Info::config($_backupInfo);
     Configure::write('Media', $_backupConfig);
 }
示例#3
0
if ($cached = Cache::read('mime_type_glob')) {
    Mime_Type::config('Glob', array('adapter' => 'Memory'));
    foreach ($cached as $item) {
        Mime_Type::$glob->register($item);
    }
} else {
    Mime_Type::config('Glob', array('adapter' => 'Freedesktop', 'file' => $mm . DS . 'data' . DS . 'glob.db'));
    Cache::write('mime_type_glob', Mime_Type::$glob->to('array'));
}
/**
 * Configure the adpters to be used by media process class. Adjust this
 * mapping of media names to adapters according to your environment. For example:
 * most PHP installations have GD enabled thus should choose the `Gd` adapter for
 * image transformations. However the `Imagick` adapter may be more desirable
 * in other cases and also supports transformations for documents.
 *
 * @see GeneratorBehavior
 */
require_once 'Media/Process.php';
Media_Process::config(array('document' => $hasImagick ? 'Imagick' : null, 'image' => $hasImagick ? 'Imagick' : 'Gd'));
/**
 * Configure the adpters to be used by media info class. Adjust this
 * mapping of media names to adapters according to your environment. In contrast
 * to `Media_Proces` which operates only with one adapter per media type
 * `Media_Info` can use multiple adapter per media type.
 *
 * @see MetaBehavior
 */
require_once 'Media/Info.php';
Media_Info::config(array('image' => $hasImagick ? array('ImageBasic', 'Imagick') : array('ImageBasic')));
示例#4
0
 function testHasManyWithMissingMediaAdapters()
 {
     $_backupConfig = Configure::read('Media');
     $_backupProcess = Media_Process::config();
     $_backupInfo = Media_Info::config();
     $s = array('convert' => 'image/png', 'zoomCrop' => array(100, 100));
     $m = array('convert' => 'image/png', 'fitCrop' => array(300, 300));
     $l = array('convert' => 'image/png', 'fit' => array(600, 440));
     Configure::write('Media.filter', array('audio' => compact('s', 'm'), 'document' => compact('s', 'm'), 'generic' => array(), 'image' => compact('s', 'm', 'l'), 'video' => compact('s', 'm')));
     Media_Process::config(array('image' => null));
     Media_Info::config(array('image' => null));
     $Model = $this->_model('hasMany');
     $file = $this->Data->getFile(array('image-jpg.jpg' => 'ta.jpg'));
     $data = array('Movie' => array('title' => 'Weekend', 'director' => 'Jean-Luc Godard'), 'Attachment' => array(array('file' => $file, 'model' => 'Movie')));
     $this->expectError();
     $this->expectError();
     $this->expectError();
     $Model->create();
     $result = $Model->saveAll($data, array('validate' => 'first'));
     $this->assertTrue($result);
     $this->assertTrue(file_exists($this->Folder->pwd() . 'transfer' . DS . 'img' . DS . 'ta.jpg'));
     $result = $Model->find('first', array('conditions' => array('title' => 'Weekend')));
     $expected = array(0 => array('id' => 1, 'model' => 'Movie', 'foreign_key' => 4, 'dirname' => 'img', 'basename' => 'ta.jpg', 'checksum' => '1920c29e7fbe4d1ad2f9173ef4591133', 'group' => null, 'alternative' => null));
     $this->assertEqual($result['Attachment'], $expected);
     Media_Process::config($_backupProcess);
     Media_Info::config($_backupInfo);
     Configure::write('Media', $_backupConfig);
 }
示例#5
0
 * in other cases and also supports transformations for documents.
 *
 * @see GeneratorBehavior
 */
require_once 'Media/Process.php';
Media_Process::config(array('document' => $hasImagick ? 'Imagick' : null, 'image' => $hasImagick ? 'Imagick' : 'Gd'));
/**
 * Configure the adpters to be used by media info class. Adjust this
 * mapping of media names to adapters according to your environment. In contrast
 * to `Media_Proces` which operates only with one adapter per media type
 * `Media_Info` can use multiple adapter per media type.
 *
 * @see MetaBehavior
 */
require_once 'Media/Info.php';
Media_Info::config(array('audio' => array('NewWave'), 'document' => $hasImagick ? array('Imagick') : array(), 'image' => $hasImagick ? array('ImageBasic', 'Imagick') : array('ImageBasic')));
/**
 * Filters and versions
 *
 * For each media type a set of filters keyed by version name is configured.
 * A filter is a set of instructions which are processed by the Media_Process class.
 *
 * For more information on available methods see the classes
 * located in `libs/mm/src/Media/Process`.
 *
 * @see GeneratorBehavior
 */
// $sRGB = $mm . DS . 'data' . DS . 'sRGB_IEC61966-2-1_black_scaled.icc';
$s = array('convert' => 'image/jpeg', 'fitCrop' => array(100, 100));
$m = array('convert' => 'image/jpeg', 'fit' => array(300, 300));
$l = array('convert' => 'image/jpeg', 'fit' => array(600, 440));
示例#6
0
文件: core.php 项目: razzman/media
 * in other cases and also supports transformations for documents.
 *
 * @see GeneratorBehavior
 */
require_once 'Media/Process.php';
Media_Process::config(array('document' => $hasImagick ? 'Imagick' : null, 'image' => $hasImagick ? 'Imagick' : 'Gd'));
/**
 * Configure the adpters to be used by media info class. Adjust this
 * mapping of media names to adapters according to your environment. In contrast
 * to `Media_Proces` which operates only with one adapter per media type
 * `Media_Info` can use multiple adapter per media type.
 *
 * @see MetaBehavior
 */
require_once 'Media/Info.php';
Media_Info::config(array('image' => array('ImageBasic')));
/**
 * Filters and versions
 *
 * For each media type a set of filters keyed by version name is configured.
 * A filter is a set of instructions which are processed by the Media_Process class.
 *
 * For more information on available methods see the classes
 * located in `libs/mm/src/Media/Process`.
 *
 * @see GeneratorBehavior
 */
// $sRGB = $mm . DS . 'data' . DS . 'sRGB_IEC61966-2-1_black_scaled.icc';
$s = array('convert' => 'image/png', 'zoomCrop' => array(100, 100));
$m = array('convert' => 'image/png', 'fitCrop' => array(300, 300));
$l = array('convert' => 'image/png', 'fit' => array(600, 440));