Remove mplayer, delegate technical read to MediaVorus

This commit is contained in:
Romain Neutron
2012-05-04 16:29:05 +02:00
parent ad59dbcb36
commit 516008d84d
20 changed files with 494 additions and 713 deletions

View File

@@ -119,26 +119,37 @@ class Publications implements ControllerProviderInterface
return new Response('ERROR:error while upload');
}
$file = new \system_file($fileData['tmp_name']);
if ( ! in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif'))) {
$media = \MediaVorus\MediaVorus::guess(new \SplFileInfo($fileData['tmp_name']));
if ($media->getType() !== \MediaVorus\Media\Media::TYPE_IMAGE) {
return new Response('ERROR:bad filetype');
}
if ($file->getSize() > 200000) {
return new Response('ERROR:file too large');
$spec = new \MediaAlchemyst\Specification\Image();
$spec->setResizeMode(\MediaAlchemyst\Specification\Image::RESIZE_MODE_OUTBOUND);
$spec->setDimensions(32, 32);
$spec->setStrip(true);
$spec->setQuality(72);
$tmpname = tempnam(sys_get_temp_dir(), 'feed_icon');
try {
$app['Core']['media-alchemyst']
->open($media->getFile()->getPathname())
->turnInto($tmpname, $spec)
->close();
} catch (\MediaAlchemyst\Exception\Exception $e) {
return new Response('Error while handling icon');
}
$datas = $file->get_technical_datas();
if ( ! isset($datas[\system_file::TC_DATAS_WIDTH]) || ! isset($datas[\system_file::TC_DATAS_HEIGHT])) {
return new Response('ERROR:file is not square');
}
$feed->set_icon($tmpname);
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT]) {
return new Response('ERROR:file is not square');
}
unset($media);
$feed->set_icon($file);
unlink($file->getPathname());
unlink($tmpname);
unlink($fileData['tmp_name']);
return new Response('FILEHREF:' . $feed->get_icon_url() . '?' . mt_rand(100000, 999999));
})->assert('id', '\d+');

View File

@@ -234,7 +234,6 @@ class Installer implements ControllerProviderInterface
$registry->set('GV_unoconv', $request->get('binary_unoconv'), \registry::TYPE_STRING);
$registry->set('GV_ffmpeg', $request->get('binary_ffmpeg'), \registry::TYPE_STRING);
$registry->set('GV_mp4box', $request->get('binary_MP4Box'), \registry::TYPE_STRING);
$registry->set('GV_mplayer', $request->get('binary_mplayer'), \registry::TYPE_STRING);
$registry->set('GV_pdftotext', $request->get('binary_xpdf'), \registry::TYPE_STRING);
$user = \User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true);

View File

@@ -454,7 +454,6 @@ class API_V1_adapter extends API_V1_Abstract
'unoconv' => $registry->get('GV_unoconv'),
'ffmpeg' => $registry->get('GV_ffmpeg'),
'mp4box' => $registry->get('GV_mp4box'),
'mplayer' => $registry->get('GV_mplayer'),
'pdftotext' => $registry->get('GV_pdftotext'),
'pdfmaxpages' => $registry->get('GV_pdfmaxpages'),),
'mainConfiguration' => array(

View File

@@ -150,20 +150,22 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
/**
*
* @param system_file $file
* @param string $file The path to the file
* @return Feed_Adapter
*/
public function set_icon(system_file $file)
public function set_icon($file)
{
if ( ! file_exists($file)) {
throw new \Alchemy\Phrasea\Exception\InvalidArgumentException('File does not exists');
}
$registry = registry::get_instance();
$config_file = $registry->get('GV_RootPath')
. 'config/feed_' . $this->get_id() . '.jpg';
$www_file = $registry->get('GV_RootPath')
. 'www/custom/feed_' . $this->get_id() . '.jpg';
$config_file = $registry->get('GV_RootPath') . 'config/feed_' . $this->get_id() . '.jpg';
$www_file = $registry->get('GV_RootPath') . 'www/custom/feed_' . $this->get_id() . '.jpg';
copy($file->getPathname(), $config_file);
copy($file->getPathname(), $www_file);
copy($file, $config_file);
copy($file, $www_file);
$this->icon_url = null;
return $this;

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
use MediaVorus\MediaVorus;
use MediaVorus\Media\Media;
/**
*
* @package subdefs
@@ -101,12 +104,41 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/
protected $is_physically_present = false;
/**
* Players types constants
*/
const TYPE_VIDEO_MP4 = 'VIDEO_MP4';
const TYPE_VIDEO_FLV = 'VIDEO_FLV';
const TYPE_FLEXPAPER = 'FLEXPAPER';
const TYPE_AUDIO_MP3 = 'AUDIO_MP3';
const TYPE_IMAGE = 'IMAGE';
const TYPE_NO_PLAYER = 'UNKNOWN';
/**
* Technical datas types constants
*/
const TC_DATA_WIDTH = 'Width';
const TC_DATA_HEIGHT = 'Height';
const TC_DATA_COLORSPACE = 'ColorSpace';
const TC_DATA_CHANNELS = 'Channels';
const TC_DATA_ORIENTATION = 'Orientation';
const TC_DATA_COLORDEPTH = 'ColorDepth';
const TC_DATA_DURATION = 'Duration';
const TC_DATA_AUDIOCODEC = 'AudioCodec';
const TC_DATA_AUDIOSAMPLERATE = 'AudioSamplerate';
const TC_DATA_VIDEOCODEC = 'VideoCodec';
const TC_DATA_FRAMERATE = 'FrameRate';
const TC_DATA_MIMETYPE = 'MimeType';
const TC_DATA_FILESIZE = 'FileSize';
const TC_DATA_LONGITUDE = 'Longitude';
const TC_DATA_LATITUDE = 'Latitude';
const TC_DATA_FOCALLENGTH = 'FocalLength';
const TC_DATA_CAMERAMODEL = 'CameraModel';
const TC_DATA_FLASHFIRED = 'FlashFired';
const TC_DATA_APERTURE = 'Aperture';
const TC_DATA_SHUTTERSPEED = 'ShutterSpeed';
const TC_DATA_HYPERFOCALDISTANCE = 'HyperfocalDistance';
const TC_DATA_ISO = 'ISO';
const TC_DATA_LIGHTVALUE = 'LightValue';
/**
* @todo the presence of file is checked on constructor, it would be better
@@ -525,16 +557,15 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return array(\databox_subdef::DEVICE_ALL);
}
try
{
try {
return $this->record
->get_databox()
->get_subdef_structure()
->get_subdef($this->record->get_type(), $this->get_name())
->getDevices();
}
catch(\Exception_Databox_SubdefNotFound $e)
{
} catch (\Exception_Databox_SubdefNotFound $e) {
return array();
}
}
@@ -553,7 +584,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$Core = \bootstrap::getCore();
$specs = new MediaAlchemyst\Specification\Image();
$specs = new \MediaAlchemyst\Specification\Image();
$specs->setRotationAngle($angle);
try {
@@ -564,31 +595,100 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return $this;
}
$result = new system_file($this->get_pathfile());
$tc_datas = $result->get_technical_datas();
if ($tc_datas[system_file::TC_DATAS_WIDTH] && $tc_datas[system_file::TC_DATAS_HEIGHT]) {
$media = MediaVorus::guess(new SplFileInfo($this->get_pathfile()));
$sql = "UPDATE subdef
SET height = :height , width = :width, updated_on = NOW()
WHERE record_id = :record_id AND name = :name";
$params = array(
':width' => $tc_datas[system_file::TC_DATAS_WIDTH]
, ':height' => $tc_datas[system_file::TC_DATAS_HEIGHT]
, ':record_id' => $this->get_record_id()
, ':name' => $this->get_name()
':width' => $media->getWidth(),
':height' => $media->getHeight(),
':record_id' => $this->get_record_id(),
':name' => $this->get_name(),
);
unset($media);
$stmt = $this->record->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->delete_data_from_cache();
}
return $this;
}
/**
* Read the technical datas of the file.
* Returns an empty array for non physical present files
*
* @return array An array of technical datas Key/values
*/
public function readTechnicalDatas()
{
if ( ! $this->is_physically_present()) {
return array();
}
$media = MediaVorus::guess(new \SplFileInfo($this->get_pathfile()));
switch ($media->getType()) {
case Media::TYPE_IMAGE:
$datas = array(
self::TC_DATA_WIDTH => $media->getWidth(),
self::TC_DATA_HEIGHT => $media->getHeight(),
self::TC_DATA_FOCALLENGTH => $media->getFocalLength(),
self::TC_DATA_CHANNELS => $media->getChannels(),
self::TC_DATA_COLORDEPTH => $media->getColorDepth(),
self::TC_DATA_CAMERAMODEL => $media->getCameraModel(),
self::TC_DATA_FLASHFIRED => $media->getFlashFired(),
self::TC_DATA_APERTURE => $media->getAperture(),
self::TC_DATA_SHUTTERSPEED => $media->getShutterSpeed(),
self::TC_DATA_HYPERFOCALDISTANCE => $media->getHyperfocalDistance(),
self::TC_DATA_ISO => $media->getISO(),
self::TC_DATA_LIGHTVALUE => $media->getLightValue(),
self::TC_DATA_COLORSPACE => $media->getColorSpace(),
);
break;
case Media::TYPE_VIDEO:
$datas = array(
self::TC_DATA_WIDTH => $media->getWidth(),
self::TC_DATA_HEIGHT => $media->getHeight(),
self::TC_DATA_FOCALLENGTH => $media->getFocalLength(),
self::TC_DATA_CHANNELS => $media->getChannels(),
self::TC_DATA_COLORDEPTH => $media->getColorDepth(),
self::TC_DATA_CAMERAMODEL => $media->getCameraModel(),
self::TC_DATA_FLASHFIRED => $media->getFlashFired(),
self::TC_DATA_APERTURE => $media->getAperture(),
self::TC_DATA_SHUTTERSPEED => $media->getShutterSpeed(),
self::TC_DATA_HYPERFOCALDISTANCE => $media->getHyperfocalDistance(),
self::TC_DATA_ISO => $media->getISO(),
self::TC_DATA_LIGHTVALUE => $media->getLightValue(),
self::TC_DATA_COLORSPACE => $media->getColorSpace(),
self::TC_DATA_DURATION => $media->getDuration(),
self::TC_DATA_FRAMERATE => $media->getFrameRate(),
self::TC_DATA_AUDIOSAMPLERATE => $media->getAudioSampleRate(),
self::TC_DATA_VIDEOCODEC => $media->getVideoCodec(),
self::TC_DATA_AUDIOCODEC => $media->getAudioCodec(),
);
break;
case Media::TYPE_FLASH:
case Media::TYPE_AUDIO:
case Media::TYPE_DOCUMENT:
default:
break;
}
$datas[self::TC_DATA_LONGITUDE] = $media->getLongitude();
$datas[self::TC_DATA_LATITUDE] = $media->getLatitude();
$datas[self::TC_DATA_MIMETYPE] = $media->getFile()->getMimeType();
$datas[self::TC_DATA_FILESIZE] = $media->getFile()->getSize();
unset($media);
return $datas;
}
/**
*
* @param record_Interface $record
@@ -602,22 +702,27 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$databox = $record->get_databox();
$connbas = $databox->get_connection();
$media = MediaVorus::guess($system_file);
$path = $system_file->getPath();
$newname = $system_file->getFilename();
$datas = $system_file->get_technical_datas();
$params = array(
':path' => $path,
':file' => $newname,
':baseurl' => $baseurl,
':width' => isset($datas[system_file::TC_DATAS_WIDTH]) ? $datas[system_file::TC_DATAS_WIDTH] : '',
':height' => isset($datas[system_file::TC_DATAS_HEIGHT]) ? $datas[system_file::TC_DATAS_HEIGHT] : '',
':width' => 0,
':height' => 0,
':mime' => $system_file->get_mime(),
':size' => $system_file->getSize(),
':dispatched' => 1,
);
if (in_array($media->getType(), array(Media::TYPE_IMAGE, Media::TYPE_VIDEO))) {
$params[':width'] = $media->getWidth();
$params[':height'] = $media->getHeight();
}
try {
$subdef = new self($record, $name);
@@ -653,6 +758,8 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$subdef->get_permalink()->delete_data_from_cache();
}
unset($media);
return $subdef;
}

View File

@@ -452,7 +452,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_duration()
{
if ( ! $this->duration) {
$this->duration = $this->get_technical_infos(system_file::TC_DATAS_DURATION);
$this->duration = $this->get_technical_infos(media_subdef::TC_DATA_DURATION);
}
return $this->duration;
@@ -740,12 +740,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt->closeCursor();
foreach ($rs as $row) {
switch ($row['name']) {
case 'size':
case system_file::TC_DATAS_WIDTH:
case system_file::TC_DATAS_COLORDEPTH:
case system_file::TC_DATAS_HEIGHT:
case system_file::TC_DATAS_DURATION:
switch (true) {
case ctype_digit($row['value']):
$this->technical_datas[$row['name']] = (int) $row['value'];
break;
default:
@@ -956,6 +952,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$base_url = '';
$media = MediaVorus\MediaVorus::guess($pathfile);
$original_file = $subdef_def = false;
if ($name == 'document') {
@@ -1016,8 +1014,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$connbas = connection::getPDOConnection($this->get_sbas_id());
$image_size = $system_file->get_technical_datas();
$sql = 'UPDATE subdef
SET baseurl = :baseurl,
file = :filename,
@@ -1036,8 +1032,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
':name' => $name,
':baseurl' => $base_url,
':filename' => $system_file->getFilename(),
':width' => $image_size[system_file::TC_DATAS_WIDTH],
':height' => $image_size[system_file::TC_DATAS_HEIGHT],
':width' => $media->getWidth(),
':height' => $media->getHeight(),
':mime' => $system_file->get_mime(),
':path' => $system_file->getPath(),
':filesize' => $system_file->getSize()
@@ -1063,6 +1059,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
}
unset($media);
return $this;
}
@@ -1365,17 +1363,15 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$system_file2 = new system_file($pathhd . $newname);
$system_file2->write_uuid($uuid);
media_subdef::create($record, 'document', $system_file2);
$subdef = media_subdef::create($record, 'document', $system_file2);
$record->delete_data_from_cache(record_adapter::CACHE_SUBDEFS);
$tc_datas = $system_file->get_technical_datas();
$sql = 'REPLACE INTO technical_datas (id, record_id, name, value)
VALUES (null, :record_id, :name, :value)';
$stmt = $connbas->prepare($sql);
foreach ($tc_datas as $name => $value) {
foreach ($subdef->readTechnicalDatas() as $name => $value) {
if (is_null($value))
continue;

View File

@@ -202,7 +202,6 @@ class setup
'xpdf (pdf2text)' => $registry->get('GV_pdftotext'),
'ImageMagick (composite)' => $registry->get('GV_pathcomposite'),
'FFmpeg' => $registry->get('GV_ffmpeg'),
'MPlayer' => $registry->get('GV_mplayer')
);
$constraints = array();

View File

@@ -292,101 +292,6 @@ class system_file extends \SplFileInfo
return $this->sha256;
}
public function get_technical_datas()
{
if ( ! $this->technical_datas)
$this->read_technical_datas();
return $this->technical_datas;
}
protected function read_image_datas()
{
$this->technical_datas[self::TC_DATAS_ORIENTATION] = null;
if (in_array(
$this->get_mime(), array(
'image/tif', 'image/tiff',
'image/jpg', 'image/pjpeg', 'image/pjpg', 'image/jpeg'
)
)
) {
if ($ex = @exif_read_data($this->getPathname(), 'FILE')) {
if (array_key_exists('Orientation', $ex))
$this->technical_datas[self::TC_DATAS_ORIENTATION] = $ex['Orientation'];
}
}
$datas = exiftool::extract_metadatas($this, exiftool::EXTRACT_XML_RDF);
$domrdf = new DOMDocument();
$domrdf->recover = true;
$domrdf->preserveWhiteSpace = false;
if ($domrdf->loadXML($datas)) {
$xptrdf = new DOMXPath($domrdf);
$xptrdf->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$pattern = "(xmlns:([a-zA-Z-_0-9]+)=[']{1}(https?:[/{2,4}|\\{2,4}][\w:#%/;$()~_?/\-=\\\.&]*)[']{1})";
preg_match_all($pattern, $datas, $matches, PREG_PATTERN_ORDER, 0);
$xptrdf->registerNamespace('XMP-exif', 'http://ns.exiftool.ca/XMP/XMP-exif/1.0/');
$xptrdf->registerNamespace('PHRASEANET', 'http://phraseanet.com/metas/PHRASEANET/1.0/');
foreach ($matches[2] as $key => $value)
$xptrdf->registerNamespace($matches[1][$key], $value);
$descriptionNode = @$xptrdf->query('/rdf:RDF/rdf:Description')->item(0);
if ($descriptionNode) {
for ($x = $descriptionNode->firstChild; $x; $x = $x->nextSibling) {
if ($x->nodeType !== XML_ELEMENT_NODE)
continue;
switch ($x->nodeName) {
case 'Composite:ImageSize':
if ((count($_t = explode('x', $x->textContent))) == 2) {
$this->technical_datas[self::TC_DATAS_WIDTH] = 0 + $_t[0];
$this->technical_datas[self::TC_DATAS_HEIGHT] = 0 + $_t[1];
}
break;
case 'ExifIFD:ExifImageWidth':
if ( ! array_key_exists('width', $this->technical_datas))
$this->technical_datas[self::TC_DATAS_WIDTH] = 0 + $x->textContent;
break;
case 'ExifIFD:ExifImageHeight':
if ( ! array_key_exists('height', $this->technical_datas))
$this->technical_datas[self::TC_DATAS_HEIGHT] = 0 + $x->textContent;
break;
case 'File:ColorComponents':
case 'IFD0:SamplesPerPixel':
if ( ! array_key_exists('channels', $this->technical_datas))
$this->technical_datas[self::TC_DATAS_CHANNELS] = 0 + $x->textContent;
break;
case 'File:BitsPerSample':
case 'IFD0:BitsPerSample':
if ( ! array_key_exists('bits', $this->technical_datas))
$this->technical_datas[self::TC_DATAS_COLORDEPTH] = 0 + $x->textContent;
break;
}
if (count($_t = explode(':', $x->nodeName)) !== 2)
continue;
switch ($_t[1]) {
case 'ImageWidth':
if ( ! array_key_exists('width', $this->technical_datas))
$this->technical_datas[self::TC_DATAS_WIDTH] = 0 + $x->textContent;
break;
case 'ImageHeight':
if ( ! array_key_exists('height', $this->technical_datas))
$this->technical_datas[self::TC_DATAS_HEIGHT] = 0 + $x->textContent;
break;
}
}
}
}
return $this;
}
protected function read_pdf_datas()
{
$system = system_server::get_platform();
@@ -420,129 +325,6 @@ class system_file extends \SplFileInfo
return $pdf_text;
}
protected function read_video_datas()
{
$registry = registry::get_instance();
$retour = array('width' => 0, 'height' => 0, 'CMYK' => false);
$hdPath = $this->getPathname();
$datas = exiftool::get_fields(
$hdPath, array('Duration', 'Image Width', 'Image Height')
);
$duration = 0;
if ($datas['Duration']) {
$data = explode('_', trim($datas['Duration']));
$data = explode(':', $data[0]);
$factor = 1;
while ($segment = array_pop($data)) {
$duration += $segment * $factor;
$factor *=60;
}
}
$width = $height = false;
if ($datas['Image Width']) {
if ((int) $datas['Image Width'] > 0)
$width = $datas['Image Width'];
}
if ($datas['Image Height']) {
if ((int) $datas['Image Height'] > 0)
$height = $datas['Image Height'];
}
$this->technical_datas = array();
if ( ! is_executable($registry->get('GV_mplayer'))) {
return $this;
}
$cmd = $registry->get('GV_mplayer')
. ' -identify '
. escapeshellarg($hdPath)
. ' -ao null -vo null -frames 0 | grep ^ID_';
$docProps = array(
'ID_VIDEO_WIDTH' => self::TC_DATAS_WIDTH,
'ID_VIDEO_HEIGHT' => self::TC_DATAS_HEIGHT,
'ID_VIDEO_FPS' => self::TC_DATAS_FRAMERATE,
'ID_AUDIO_CODEC' => self::TC_DATAS_AUDIOCODEC,
'ID_VIDEO_CODEC' => self::TC_DATAS_VIDEOCODEC,
'ID_VIDEO_BITRATE' => self::TC_DATAS_VIDEOBITRATE,
'ID_AUDIO_BITRATE' => self::TC_DATAS_AUDIOBITRATE,
'ID_AUDIO_RATE' => self::TC_DATAS_AUDIOSAMPLERATE
);
$stdout = shell_exec($cmd);
$this->technical_datas = array();
$stdout = explode("\n", $stdout);
foreach ($stdout as $property) {
$props = explode('=', $property);
if (array_key_exists($props[0], $docProps))
$this->technical_datas[$docProps[$props[0]]] = $props[1];
}
$datas = exiftool::extract_metadatas($this, exiftool::EXTRACT_XML_RDF);
$dom_document = new DOMDocument();
if ($dom_document->loadXML($datas)) {
$xq = new DOMXPath($dom_document);
$xq->registerNamespace('RIFF', 'http://ns.exiftool.ca/RIFF/RIFF/1.0/');
$nodes_width = $xq->query('/rdf:RDF/rdf:Description/RIFF:ImageWidth');
$nodes_height = $xq->query('/rdf:RDF/rdf:Description/RIFF:ImageHeight');
if ($nodes_height->length > 0 && $nodes_width->length > 0) {
$width = $nodes_width->item(0)->nodeValue;
$height = $nodes_height->item(0)->nodeValue;
}
}
$this->technical_datas[self::TC_DATAS_DURATION] = $duration;
if ($width)
$this->technical_datas[self::TC_DATAS_WIDTH] = $width;
if ($height)
$this->technical_datas[self::TC_DATAS_HEIGHT] = $height;
return $this;
}
protected function read_audio_datas()
{
return $this->read_video_datas();
}
protected function read_technical_datas()
{
$this->technical_datas = array();
switch ($this->get_phrasea_type()) {
case 'image' :
$this->read_image_datas();
break;
case 'document';
$this->read_image_datas();
// $this->read_pdf_datas();
break;
case 'video':
$this->read_video_datas();
break;
case 'audio':
$this->read_audio_datas();
break;
default:
break;
}
$this->technical_datas[self::TC_DATAS_MIMETYPE] = $this->get_mime();
$this->technical_datas[self::TC_DATAS_FILESIZE] = $this->getSize();
return;
}
/**
*
* @return string
@@ -890,7 +672,16 @@ class system_file extends \SplFileInfo
$tfields = array();
$technical_datas = $this->get_technical_datas();
$media = MediaVorus\MediaVorus::guess($this);
$width = $height = $channels = $colorDepth = array();
if (in_array($media, array(\MediaVorus\Media\Media::TYPE_IMAGE, \MediaVorus\Media\Media::TYPE_VIDEO))) {
$width[] = $media->getWidth();
$height[] = $media->getHeight();
$channels[] = $media->getChannels();
$colorDepth[] = $media->getColorDepth();
}
$tfields[metadata_description_PHRASEANET_tfmimetype::get_source()]
= array($this->get_mime());
@@ -903,36 +694,24 @@ class system_file extends \SplFileInfo
$tfields[metadata_description_PHRASEANET_tffilename::get_source()]
= array($this->get_phrasea_tech_field(self::TECH_FIELD_ORIGINALNAME));
$tfields[metadata_description_PHRASEANET_tfextension::get_source()]
= array($this->get_extension());
$tfields[metadata_description_PHRASEANET_tfwidth::get_source()]
= isset($technical_datas[system_file::TC_DATAS_WIDTH]) ? array(($technical_datas[system_file::TC_DATAS_WIDTH])) : array();
$tfields[metadata_description_PHRASEANET_tfheight::get_source()]
= isset($technical_datas[system_file::TC_DATAS_HEIGHT]) ? array(($technical_datas[system_file::TC_DATAS_HEIGHT])) : array();
$tfields[metadata_description_PHRASEANET_tfbits::get_source()]
= isset($technical_datas[system_file::TC_DATAS_COLORDEPTH]) ? array(($technical_datas[system_file::TC_DATAS_COLORDEPTH])) : array();
$tfields[metadata_description_PHRASEANET_tfchannels::get_source()]
= isset($technical_datas[system_file::TC_DATAS_CHANNELS]) ? array(($technical_datas[system_file::TC_DATAS_CHANNELS])) : array();
$tfields[metadata_description_PHRASEANET_tfextension::get_source()] = array($this->get_extension());
$tfields[metadata_description_PHRASEANET_tfwidth::get_source()] = $width;
$tfields[metadata_description_PHRASEANET_tfheight::get_source()] = $height;
$tfields[metadata_description_PHRASEANET_tfbits::get_source()] = $colorDepth;
$tfields[metadata_description_PHRASEANET_tfchannels::get_source()] = $channels;
$tfields[metadata_description_PHRASEANET_tfctime::get_source()]
= array(date('Y/m/d H:i:s', $this->getCTime()));
$tfields[metadata_description_PHRASEANET_tfmtime::get_source()]
= array(date('Y/m/d H:i:s', $this->getMTime()));
$tfields[metadata_description_PHRASEANET_tfatime::get_source()]
= array(date('Y/m/d H:i:s', $this->getATime()));
$tfields[metadata_description_PHRASEANET_tfctime::get_source()] = array(date('Y/m/d H:i:s', $this->getCTime()));
$tfields[metadata_description_PHRASEANET_tfmtime::get_source()] = array(date('Y/m/d H:i:s', $this->getMTime()));
$tfields[metadata_description_PHRASEANET_tfatime::get_source()] = array(date('Y/m/d H:i:s', $this->getATime()));
$time = time();
$tfields[metadata_description_PHRASEANET_tfarchivedate::get_source()]
= array(date('Y/m/d H:i:s', $time));
$tfields[metadata_description_PHRASEANET_tfeditdate::get_source()]
= array(date('Y/m/d H:i:s', $time));
$tfields[metadata_description_PHRASEANET_tfchgdocdate::get_source()]
= array(date('Y/m/d H:i:s', $time));
$tfields[metadata_description_PHRASEANET_tfarchivedate::get_source()] = array(date('Y/m/d H:i:s', $time));
$tfields[metadata_description_PHRASEANET_tfeditdate::get_source()] = array(date('Y/m/d H:i:s', $time));
$tfields[metadata_description_PHRASEANET_tfchgdocdate::get_source()] = array(date('Y/m/d H:i:s', $time));
if ($this->get_mime() === 'application/pdf') {
$tfields[metadata_description_PHRASEANET_pdftext::get_source()]
= $this->read_pdf_datas();
$tfields[metadata_description_PHRASEANET_pdftext::get_source()] = $this->read_pdf_datas();
}
$datas = exiftool::extract_metadatas($this, exiftool::EXTRACT_XML_RDF);

View File

@@ -195,14 +195,9 @@ class task_period_upgradetov32 extends task_abstract
foreach ($rs as $row) {
try {
$record = new record_adapter($this->sbas_id, $row['record_id']);
$system_file = $record->get_hd_file();
$document = $record->get_subdef('document');
if ( ! $system_file instanceof system_file)
continue;
$tc_datas = $system_file->get_technical_datas();
foreach ($tc_datas as $name => $value) {
foreach ($document->readTechnicalDatas() as $name => $value) {
if (is_null($value))
continue;

View File

@@ -475,12 +475,6 @@ $GV = array(
'comment' => _('reglages:: chemin de l\'executable MP4Box'),
'default' => ''
),
array(
'type' => 'string',
'name' => 'GV_mplayer',
'comment' => _('reglages:: chemin de l\'executable Mplayer'),
'default' => ''
),
array(
'type' => 'string',
'name' => 'GV_pdftotext',

View File

@@ -61,36 +61,36 @@
{{record.get_formated_duration() }}
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_FRAMERATE')) is not empty %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_FRAMERATE')) is not empty %}
{% trans 'Images par secondes' %} :
{{record.get_technical_infos(constant('system_file::TC_DATAS_FRAMERATE')) }} ips
{{record.get_technical_infos(constant('media_subdef::TC_DATA_FRAMERATE')) }} ips
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOCODEC')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOCODEC')) %}
{% trans 'Codec Audio' %} :
{{record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOCODEC')) }}
{{record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOCODEC')) }}
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_VIDEOCODEC')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_VIDEOCODEC')) %}
{% trans 'Codec Video' %} :
{{record.get_technical_infos(constant('system_file::TC_DATAS_VIDEOCODEC')) }}
{{record.get_technical_infos(constant('media_subdef::TC_DATA_VIDEOCODEC')) }}
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_VIDEOBITRATE')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_VIDEOBITRATE')) %}
{% trans 'Debit video' %} :
{% set rate = (record.get_technical_infos(constant('system_file::TC_DATAS_VIDEOBITRATE')) / 1024) %}
{% set rate = (record.get_technical_infos(constant('media_subdef::TC_DATA_VIDEOBITRATE')) / 1024) %}
{{rate|round(1)}} kbps
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOBITRATE')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOBITRATE')) %}
{% trans 'Debit audio' %} :
{% set rate = (record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOBITRATE')) / 1024) %}
{% set rate = (record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOBITRATE')) / 1024) %}
{{rate|round(1)}} kbps
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOSAMPLERATE')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) %}
{% trans 'Frequence d\'echantillonage' %} :
{{record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOSAMPLERATE')) }} kHz
{{record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) }} kHz
<br />
{% endif %}
{% endif %}
@@ -105,20 +105,20 @@
{{record.get_formated_duration() }}
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOCODEC')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOCODEC')) %}
{% trans 'Codec Audio' %} :
{{record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOCODEC')) }}
{{record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOCODEC')) }}
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOBITRATE')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOBITRATE')) %}
{% trans 'Debit audio' %} :
{% set rate = (record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOBITRATE')) / 1024) %}
{% set rate = (record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOBITRATE')) / 1024) %}
{{rate|round(1)}} kbps
<br />
{% endif %}
{% if record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOSAMPLERATE')) %}
{% if record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) %}
{% trans 'Frequence d\'echantillonage' %} :
{{record.get_technical_infos(constant('system_file::TC_DATAS_AUDIOSAMPLERATE')) }} kHz
{{record.get_technical_infos(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) }} kHz
<br />
{% endif %}
{% endif %}

View File

@@ -1429,18 +1429,10 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->assertTrue(is_object($record->technical_informations));
foreach ($record->technical_informations as $key => $value) {
switch ($key) {
case system_file::TC_DATAS_DURATION:
case 'size':
case system_file::TC_DATAS_WIDTH:
case system_file::TC_DATAS_HEIGHT:
case system_file::TC_DATAS_COLORDEPTH:
$this->assertTrue(is_int($value), 'test technical data ' . $key . ' ' . $value);
break;
default;
$this->assertTrue(is_string($value), 'test technical data ' . $key);
break;
}
if(is_string($value))
$this->assertFalse(ctype_digit ($value));
else
$this->assertTrue(is_int($value));
}
}

View File

@@ -1467,17 +1467,10 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->assertTrue(is_array($record["technical_informations"]));
foreach ($record["technical_informations"] as $key => $value) {
switch ($key) {
case system_file::TC_DATAS_DURATION:
case 'size':
case system_file::TC_DATAS_WIDTH:
case system_file::TC_DATAS_HEIGHT:
case system_file::TC_DATAS_COLORDEPTH:
$this->assertTrue(is_int($value), 'test technical data ' . $key . ' ' . $value);
break;
default;
$this->assertTrue(is_string($value), 'test technical data ' . $key);
break;
if (is_string($value)) {
$this->assertFalse(ctype_digit($value));
} else {
$this->assertTrue(is_int($value));
}
}
}

View File

@@ -54,7 +54,6 @@ class ApplicationSetupTest extends PhraseanetWebTestCaseAbstract
'GV_unoconv',
'GV_ffmpeg',
'GV_mp4box',
'GV_mplayer',
'GV_pdftotext',
);

View File

@@ -226,7 +226,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
, array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/test013.ai'))
, array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/test007.ppt'))
);
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
@@ -235,63 +235,6 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
$feed->delete();
}
public function testIconUploadErrorTooLarge()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
$this->client->request(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
, array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/heavy500.jpg'))
);
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
$this->assertRegexp("/ERROR:file too large/", $response->getContent());
$feed->delete();
}
public function testIconUploadErrorNotSquareA()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
$this->client->request(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
, array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/recta_logo.gif'))
);
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
$this->assertRegexp("/ERROR:file is not square/", $response->getContent());
$feed->delete();
}
public function testIconUploadErrorNotSquareB()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
$this->client->request(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
, array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/rectb_logo.gif'))
);
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
$this->assertRegexp("/ERROR:file is not square/", $response->getContent());
$feed->delete();
}
public function testIconUpload()
{
$appbox = appbox::get_instance(\bootstrap::getCore());

View File

@@ -115,14 +115,14 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
self::$feed_1_private = Feed_Adapter::create($appbox, self::$user, self::$feed_1_private_title, self::$feed_1_private_subtitle);
self::$feed_1_private->set_public(false);
self::$feed_1_private->set_icon(new system_file(__DIR__ . '/../../../../testfiles/logocoll.gif'));
self::$feed_1_private->set_icon(__DIR__ . '/../../../../testfiles/logocoll.gif');
self::$feed_2_private = Feed_Adapter::create($appbox, self::$user, self::$feed_2_private_title, self::$feed_2_private_subtitle);
self::$feed_2_private->set_public(false);
self::$feed_3_public = Feed_Adapter::create($appbox, self::$user, self::$feed_3_public_title, self::$feed_3_public_subtitle);
self::$feed_3_public->set_public(true);
self::$feed_3_public->set_icon(new system_file(__DIR__ . '/../../../../testfiles/logocoll.gif'));
self::$feed_3_public->set_icon(__DIR__ . '/../../../../testfiles/logocoll.gif');
self::$feed_4_public = Feed_Adapter::create($appbox, self::$user, self::$feed_4_public_title, self::$feed_4_public_subtitle);
self::$feed_4_public->set_public(true);

View File

@@ -4,7 +4,6 @@ require_once __DIR__ . '/../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
/**
*
* @var Feed_Adapter
@@ -36,21 +35,20 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_icon()
{
$this->assertEquals('/skins/icons/rss32.gif', self::$object->get_icon_url());
$file = new system_file(__DIR__ . '/../testfiles/p4logo.jpg');
$file = __DIR__ . '/../testfiles/p4logo.jpg';
self::$object->set_icon($file);
try
{
$file = new system_file(__DIR__ . '/../testfiles/iphone_pic.jpg');
self::$object->set_icon($file);
$this->fail('Should fail');
}
catch (Exception $e)
{
}
$this->assertEquals('/custom/feed_' . self::$object->get_id() . '.jpg', self::$object->get_icon_url());
}
/**
* @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException
*/
public function testSet_iconFail()
{
$file = __DIR__ . '/../testfiles/unknown.jpg';
self::$object->set_icon($file);
}
public function testIs_aggregated()
{
$this->assertFalse(self::$object->is_aggregated());
@@ -74,10 +72,8 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$coll = null;
$appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($appbox->get_databoxes() as $databox)
{
foreach ($databox->get_collections() as $collection)
{
foreach ($appbox->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
$coll = $collection;
break;
}
@@ -122,10 +118,8 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$coll = null;
$appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($appbox->get_databoxes() as $databox)
{
foreach ($databox->get_collections() as $collection)
{
foreach ($appbox->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
$coll = $collection;
break;
}
@@ -159,31 +153,22 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertNotEquals($title, self::$object->get_title());
$this->assertEquals(strip_tags($title), self::$object->get_title());
try
{
try {
self::$object->set_title('<a></a> ');
$this->fail();
}
catch (Exception $e)
{
} catch (Exception $e) {
}
try
{
try {
self::$object->set_title(' ');
$this->fail();
}
catch (Exception $e)
{
} catch (Exception $e) {
}
try
{
try {
self::$object->set_title('');
$this->fail();
}
catch (Exception $e)
{
} catch (Exception $e) {
}
@@ -257,13 +242,10 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_title()
{
$this->assertEquals(self::$object->get_title(), self::$title);
try
{
try {
self::$object->set_title('');
$this->fail();
}
catch (Exception $e)
{
} catch (Exception $e) {
}
}
@@ -285,6 +267,5 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$this->assertInstanceOf('DateTime', self::$object->get_updated_on());
}
}

View File

@@ -270,4 +270,21 @@ class media_subdefTest extends \PhraseanetPHPUnitAbstract
{
self::$objectNotPresent->rotate(90);
}
/**
* @covers media_subdef::readTechnicalDatas
*/
public function testReadTechnicalDatas()
{
$technical_datas = self::$objectPresent->readTechnicalDatas();
$this->assertArrayHasKey(media_subdef::TC_DATA_WIDTH, $technical_datas);
$this->assertArrayHasKey(media_subdef::TC_DATA_HEIGHT, $technical_datas);
$this->assertArrayHasKey(media_subdef::TC_DATA_CHANNELS, $technical_datas);
$this->assertArrayHasKey(media_subdef::TC_DATA_COLORDEPTH, $technical_datas);
$this->assertArrayHasKey(media_subdef::TC_DATA_MIMETYPE, $technical_datas);
$this->assertArrayHasKey(media_subdef::TC_DATA_FILESIZE, $technical_datas);
$technical_datas = self::$objectNotPresent->readTechnicalDatas();
$this->assertEquals(array(), $technical_datas);
}
}

View File

@@ -198,13 +198,13 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_formated_duration()
{
$this->assertEquals('00:17', self::$record_23->get_formated_duration());
$this->assertTrue(strpos(self::$record_23->get_formated_duration(), '00:17') === 0);
$this->assertEquals('', self::$record_1->get_formated_duration());
}
public function testGet_duration()
{
$this->assertEquals(17, self::$record_23->get_duration());
$this->assertEquals(17, round(self::$record_23->get_duration()));
$this->assertEquals(false, self::$record_1->get_duration());
}

View File

@@ -45,31 +45,6 @@ class system_fileTest extends PhraseanetPHPUnitAbstract
$this->assertEquals('c08fed0e193a1549c130d79814d30a3ac3fcd81980e261c4947ff45691628f92', $this->objects['jpg']->get_sha256());
}
public function testGet_technical_datas()
{
$technical_datas = $this->objects['jpg']->get_technical_datas();
$this->assertArrayHasKey(system_file::TC_DATAS_WIDTH, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_HEIGHT, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_CHANNELS, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_COLORDEPTH, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_MIMETYPE, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_FILESIZE, $technical_datas);
$technical_datas = $this->objects['indd']->get_technical_datas();
$this->assertArrayHasKey(system_file::TC_DATAS_MIMETYPE, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_FILESIZE, $technical_datas);
$registry = registry::get_instance();
if ( ! is_executable($registry->get('GV_mplayer')))
$this->markTestSkipped('MPlayer is not configured');
$technical_datas = $this->objects['wav']->get_technical_datas();
$this->assertArrayHasKey(system_file::TC_DATAS_AUDIOBITRATE, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_AUDIOSAMPLERATE, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_AUDIOCODEC, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_DURATION, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_MIMETYPE, $technical_datas);
$this->assertArrayHasKey(system_file::TC_DATAS_FILESIZE, $technical_datas);
}
public function testGet_phrasea_type()
{
$this->assertEquals('unknown', $this->objects['indd']->get_phrasea_type());