本文整理汇总了PHP中Media::name方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::name方法的具体用法?PHP Media::name怎么用?PHP Media::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::name方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
function convert($Media, $mimeType)
{
if (Media::name(null, $mimeType) === 'Image') {
$randomFrame = rand(1, $Media->objects['ffmpeg_movie']->getFrameCount() - 1);
$resource = $Media->objects['ffmpeg_movie']->getFrame($randomFrame)->toGDImage();
if (!is_resource($resource)) {
return false;
}
$Image = Media::factory(array('gd' => $resource), 'image/gd');
return $Image->convert($mimeType);
}
return false;
}
示例2: convert
function convert($Media, $mimeType)
{
if (!isset($this->_formatMap[$mimeType])) {
return false;
}
try {
$Media->objects['Imagick']->setFormat($this->_formatMap[$mimeType]);
} catch (Exception $E) {
return false;
}
if ($Media->name !== Media::name(null, $mimeType)) {
// document -> image
return Media::factory($Media->objects['Imagick']->clone(), $mimeType);
} else {
$Media->mimeType = $mimeType;
}
return true;
}
示例3: convert
function convert($Media, $mimeType)
{
if (Media::name(null, $mimeType) === 'Image') {
$coverArt = $this->__coverArt($Media);
if (!$coverArt) {
return false;
}
$resource = @imagecreatefromstring($coverArt);
if (!is_resource($resource)) {
return false;
}
$Image = Media::factory(array('gd' => $resource), 'image/gd');
return $Image->convert($mimeType);
}
return false;
}
示例4: array
/**
* Factory method
*
* Takes a file and determines type of media to use for it
* Falls back to generic media
*
* @param mixed $file See description of the constructor
* @param string $mimeType Sets the mimeType of the new media
* @return object
*/
static function &factory($file, $mimeType = null)
{
if ($mimeType === null) {
$mimeType = MimeType::guessType($file, array('experimental' => false));
}
$name = Media::name(null, $mimeType);
$class = $name . 'Media';
if (!class_exists($class)) {
App::import('Vendor', 'Media.' . $class, array('file' => 'media' . DS . strtolower($name) . '.php'));
}
$Object = new $class($file, $mimeType);
return $Object;
}
示例5: array
/**
* Factory method
*
* Takes a file and determines type of media to use for it
* Falls back to generic media
*
* @param mixed $file See description of the constructor
* @param string $mimeType Sets the mimeType of the new media
* @return object
*/
static function &factory($file, $mimeType = null)
{
if ($mimeType === null) {
$mimeType = MimeType::guessType($file, array('experimental' => false));
}
$name = Media::name(null, $mimeType);
$class = $name . 'Media';
if (!class_exists($class)) {
App::uses($class, 'Media.Libs/Media');
}
$Object = new $class($file, $mimeType);
return $Object;
}
示例6: make
/**
* Parses instruction sets and invokes `Media::make()` for a file
*
* @param Model $Model
* @param string $file Path to a file relative to `baseDirectory` or an absolute path to a file
* @param boolean Whether to overwrite existing versions with the same name or not
* @return boolean
*/
function make(&$Model, $file, $overwrite = false)
{
extract($this->settings[$Model->alias]);
list($file, $relativeFile) = $this->_file($Model, $file);
$relativeDirectory = DS . rtrim(dirname($relativeFile), '.');
$name = Media::name($file);
$filter = Configure::read('Media.filter.' . strtolower($name));
$hasCallback = method_exists($Model, 'beforeMake');
foreach ($filter as $version => $instructions) {
$directory = Folder::slashTerm($filterDirectory . $version . $relativeDirectory);
$Folder = new Folder($directory, $createDirectory);
if (!$Folder->pwd()) {
$message = "GeneratorBehavior::make - Directory `{$directory}` ";
$message .= "could not be created or is not writable. ";
$message .= "Please check the permissions.";
trigger_error($message, E_USER_WARNING);
continue;
}
if ($hasCallback) {
$process = compact('overwrite', 'directory', 'name', 'version', 'instructions');
if ($Model->beforeMake($file, $process)) {
continue;
}
}
if (!($Media = Media::make($file, $instructions))) {
$message = "GeneratorBehavior::make - Failed to make version `{$version}` ";
$message .= "of file `{$file}`. ";
trigger_error($message, E_USER_WARNING);
continue;
}
$Media->store($directory . basename($file), $overwrite);
}
return true;
}
示例7: _make
/**
* "makes" a file
*
* @param string $file Absolute path to a file
* @access protected
* @return boolean
*/
function _make($file)
{
$File = new File($file);
$name = Media::name($file);
$subdir = array_pop(explode(DS, dirname($this->source)));
if ($name === 'Icon' || strpos($file, 'ico' . DS) !== false) {
$message = "MakeTask::_make - ";
$message .= "All functionality related to assets has been deprecated.";
trigger_error($message, E_USER_NOTICE);
return true;
}
if ($this->version) {
$configString = 'Media.filter.' . strtolower($name) . '.' . $this->version;
$filter = array(Configure::read($configString));
} else {
$configString = 'Media.filter.' . strtolower($name);
$filter = Configure::read($configString);
}
foreach ($filter as $version => $instructions) {
$directory = Folder::slashTerm(rtrim($this->destination . $version . DS . $subdir, '.'));
$Folder = new Folder($directory, $this->_createDirectories);
if (!$Folder->pwd()) {
$this->err($directory . ' could not be created or is not writable.');
$this->err('Please check your permissions.');
return false;
}
$Media = Media::make($File->pwd(), $instructions);
if (!$Media) {
$this->err('Failed to make version ' . $version . ' of media.');
return false;
}
$Media->store($Folder->pwd() . $File->name, $this->overwrite);
}
return true;
}