Add devices in API answer / CS / Fixes

Add tests to media subdefs
Fix CS
Add Mplayer to build
Fix Alchemy\Phrasea\Exceptions
Add media_subdef etags
This commit is contained in:
Romain Neutron
2012-04-27 16:46:52 +02:00
parent 77a9e0609b
commit 093869d3d0
47 changed files with 784 additions and 353 deletions

View File

@@ -5,7 +5,7 @@ before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install
- sudo apt-get update
- sudo apt-get install -y ffmpeg ufraw dcraw libavcodec-extra-53 openoffice.org openoffice.org-writer unoconv ghostscript gsfonts ufraw graphicsmagick libgraphicsmagick1-dev libfreetype6-dev libjpeg-dev libgif-dev imagemagick imagemagick libtiff-dev libdjvulibre-dev libwmf-dev libmagickcore-dev libmagickwand-dev libpng-dev xpdf libexpat-dev gettext zlib1g-dev build-essential libfaac-dev libmp3lame0 libx264-dev libvpx-dev libtheora-dev libvorbis-dev gpac
- sudo apt-get install -y mplayer ffmpeg ufraw dcraw libavcodec-extra-53 openoffice.org openoffice.org-writer unoconv ghostscript gsfonts ufraw graphicsmagick libgraphicsmagick1-dev libfreetype6-dev libjpeg-dev libgif-dev imagemagick imagemagick libtiff-dev libdjvulibre-dev libwmf-dev libmagickcore-dev libmagickwand-dev libpng-dev xpdf libexpat-dev gettext zlib1g-dev build-essential libfaac-dev libmp3lame0 libx264-dev libvpx-dev libtheora-dev libvorbis-dev gpac
- mysql -e 'create database ab_test;create database db_test;'
- mysql -e "source `pwd`/hudson/fixtures.sql"
- git clone git://github.com/alchemy-fr/Phraseanet-Extension.git

View File

@@ -35,11 +35,13 @@ $finder
->name('.gitignore')
->name('check_cs.php')
->name('cleaner.php')
->name('lib/phpunit.xml.dist')
->name('phpunit.xml.dist')
->name('launchpadToLocales.php')
->name('localesToLaunchPad.php')
->name('pom.xml')
->name('composer.json')
->name('vendors.php')
->name('vendors.win.php')
->name('builder.php')
->ignoreDotFiles(false)
->ignoreVCS(false)

File diff suppressed because one or more lines are too long

View File

@@ -61,12 +61,14 @@ class Subdefs implements ControllerProviderInterface
}
if ($delete_subdef) {
$delete_subef = explode('_', $delete_subdef);
$group = $delete_subef[0];
$name = $delete_subef[1];
$subdefs = $databox->get_subdef_structure();
$subdefs->delete_subdef($group, $name);
} elseif (count($add_subdef) === 3) {
$subdefs = $databox->get_subdef_structure();
$UnicodeProcessor = new \unicode();
@@ -76,11 +78,14 @@ class Subdefs implements ControllerProviderInterface
$subdefs->add_subdef($group, $name, $class);
} else {
$subdefs = $databox->get_subdef_structure();
foreach ($Parmsubdefs as $post_sub) {
$options = array();
foreach ($Parmsubdefs as $post_sub) {
$post_sub_ex = explode('_', $post_sub);
$group = $post_sub_ex[0];
@@ -105,11 +110,14 @@ class Subdefs implements ControllerProviderInterface
$media = $request->get($post_sub . '_' . $mediatype, array());
foreach ($media as $option => $value) {
if ($option == 'resolution' && $mediatype == 'image') {
$option = 'dpi';
}
$options[$option] = $value;
}
$subdefs->set_subdef($group, $name, $class, $downloadable, $options);
}
}

View File

@@ -125,8 +125,6 @@ class Root implements ControllerProviderInterface
'thesau_json_sbas' => $Serializer->serialize($sbas, 'json'),
'thesau_json_bas2sbas' => $Serializer->serialize($bas2sbas, 'json'),
'thesau_languages' => \User_Adapter::avLanguages(),
'GV_bitly_user' => $registry->get('GV_bitly_user'),
'GV_bitly_key' => $registry->get('GV_bitly_key')
));
return new Response($out);

View File

@@ -11,6 +11,13 @@
namespace Alchemy\Phrasea\Media\Subdef;
/**
* Audio Subdef
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Audio extends Provider
{
const OPTION_BITRATE = 'bitrate';
@@ -22,13 +29,13 @@ class Audio extends Provider
{
$AVaudiosamplerate = array(
8000, 11025, 16000, 22050, 32000, 44056, 44100,
47250, 48000, 50000, 50400, 88200, 96000, null
47250, 48000, 50000, 50400, 88200, 96000
);
$this->registerOption(new OptionType\Range(self::OPTION_BITRATE, 100, 4000, 800));
$this->registerOption(new OptionType\Range(self::OPTION_THREADS, 1, 16, 1));
$this->registerOption(new OptionType\Enum(self::OPTION_AUDIOSAMPLERATE, $AVaudiosamplerate));
$this->registerOption(new OptionType\Enum(self::OPTION_ACODEC, array('libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'), 'libfaac'));
$this->registerOption(new OptionType\Range(_('Birate'), self::OPTION_BITRATE, 100, 4000, 800));
$this->registerOption(new OptionType\Range(_('Threads'), self::OPTION_THREADS, 1, 16, 1));
$this->registerOption(new OptionType\Enum(_('AudioSamplerate'), self::OPTION_AUDIOSAMPLERATE, $AVaudiosamplerate));
$this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, array('libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'), 'libfaac'));
}
public function getType()

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Subdef;
/**
* FlexPaper Subdef
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class FlexPaper extends Provider
{
protected $options = array();

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Subdef;
/**
* Gif Subdef
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Gif extends Image
{
const OPTION_DELAY = 'delay';
@@ -19,7 +25,7 @@ class Gif extends Image
{
parent::__construct();
$this->registerOption(new OptionType\Range(self::OPTION_DELAY, 50, 500, 100));
$this->registerOption(new OptionType\Range(_('Delay'), self::OPTION_DELAY, 50, 500, 100));
}
public function getType()

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Subdef;
/**
* Image Subdef
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Image extends Provider
{
const OPTION_SIZE = 'size';
@@ -22,10 +28,10 @@ class Image extends Provider
public function __construct()
{
$this->registerOption(new OptionType\Range(self::OPTION_SIZE, 20, 3000, 800));
$this->registerOption(new OptionType\Range(self::OPTION_RESOLUTION, 50, 300, 72));
$this->registerOption(new OptionType\Boolean(self::OPTION_STRIP, false));
$this->registerOption(new OptionType\Range(self::OPTION_QUALITY, 0, 100, 75));
$this->registerOption(new OptionType\Range(_('Dimension'), self::OPTION_SIZE, 20, 3000, 800));
$this->registerOption(new OptionType\Range(_('Resolution'), self::OPTION_RESOLUTION, 50, 300, 72));
$this->registerOption(new OptionType\Boolean(_('Remove ICC Profile'), self::OPTION_STRIP, false));
$this->registerOption(new OptionType\Range(_('Quality'), self::OPTION_QUALITY, 0, 100, 75));
}
public function getType()

View File

@@ -11,19 +11,27 @@
namespace Alchemy\Phrasea\Media\Subdef\OptionType;
/**
* Boolean Subdef Option
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Boolean implements OptionType
{
protected $name;
protected $default_value;
protected $displayName;
protected $defaultValue;
protected $value;
public function __construct($name, $default_value = null)
public function __construct($displayName, $name, $defaultValue = null)
{
$this->displayName = $displayName;
$this->name = $name;
$this->default_value = $default_value;
$this->defaultValue = $defaultValue;
if ($default_value) {
$this->setValue($default_value);
if ($defaultValue) {
$this->setValue($defaultValue);
}
}
@@ -39,6 +47,11 @@ class Boolean implements OptionType
return self::TYPE_BOOLEAN;
}
public function getDisplayName()
{
return $this->displayName;
}
public function getName()
{
return $this->name;

View File

@@ -11,25 +11,40 @@
namespace Alchemy\Phrasea\Media\Subdef\OptionType;
/**
* Enum Subdef Option
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Enum implements OptionType
{
protected $default_value;
protected $value;
protected $name;
protected $displayName;
protected $defaultValue;
protected $available;
protected $value;
public function __construct($name, Array $available, $default_value = null)
public function __construct($displayName, $name, Array $available, $defaultValue = null)
{
$this->displayName = $displayName;
$this->name = $name;
$this->available = $available;
$this->default_value = $default_value;
$this->defaultValue = $defaultValue;
if ($default_value) {
$this->setValue($default_value);
if ($defaultValue) {
$this->setValue($defaultValue);
}
}
public function setValue($value)
{
if ( ! $value) {
$this->value = null;
return $this;
}
if ( ! in_array($value, $this->available)) {
throw new \Exception_InvalidArgument(
sprintf(
@@ -46,6 +61,11 @@ class Enum implements OptionType
return $this;
}
public function getDisplayName()
{
return $this->displayName;
}
public function getType()
{
return self::TYPE_ENUM;

View File

@@ -11,15 +11,23 @@
namespace Alchemy\Phrasea\Media\Subdef\OptionType;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
interface OptionType
{
const TYPE_RANGE = 'Range';
const TYPE_ENUM = 'Enum';
const TYPE_BOOLEAN = 'Boolean';
const TYPE_MULTI = 'Multi';
public function getType();
public function getDisplayName();
public function getName();
public function getType();
public function getValue();
}

View File

@@ -11,30 +11,45 @@
namespace Alchemy\Phrasea\Media\Subdef\OptionType;
/**
* Range Subdef Option
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Range implements OptionType
{
protected $min_value;
protected $max_value;
protected $default_value;
protected $name;
protected $displayName;
protected $minValue;
protected $maxValue;
protected $defaultValue;
protected $value;
protected $step;
public function __construct($name, $min_value, $max_value, $default_value = null, $step = 1)
public function __construct($displayName, $name, $minValue, $maxValue, $defaultValue = null, $step = 1)
{
$this->displayName = $displayName;
$this->name = $name;
$this->min_value = $min_value;
$this->max_value = $max_value;
$this->default_value = $default_value;
$this->minValue = $minValue;
$this->maxValue = $maxValue;
$this->defaultValue = $defaultValue;
$this->step = $step;
if ($default_value) {
$this->setValue($default_value);
if ($defaultValue) {
$this->setValue($defaultValue);
}
}
public function setValue($value)
{
if ($value > $this->max_value || $value < $this->min_value) {
if ( ! $value) {
$this->value = null;
return $this;
}
if ($value > $this->maxValue || $value < $this->minValue) {
throw new \Exception_InvalidArgument('The value provided does not fit in range');
}
@@ -43,6 +58,11 @@ class Range implements OptionType
return $this;
}
public function getDisplayName()
{
return $this->displayName;
}
public function getType()
{
return self::TYPE_RANGE;
@@ -65,11 +85,11 @@ class Range implements OptionType
public function getMinValue()
{
return $this->min_value;
return $this->minValue;
}
public function getMaxValue()
{
return $this->max_value;
return $this->maxValue;
}
}

View File

@@ -11,12 +11,17 @@
namespace Alchemy\Phrasea\Media\Subdef;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
abstract class Provider implements Subdef
{
protected $options = array();
protected $spec;
protected function registerOption(OptionType\OptionType $option)
public function registerOption(OptionType\OptionType $option)
{
$this->options[$option->getName()] = $option;

View File

@@ -11,6 +11,11 @@
namespace Alchemy\Phrasea\Media\Subdef;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
interface Subdef
{
const TYPE_IMAGE = 'image';

View File

@@ -11,11 +11,17 @@
namespace Alchemy\Phrasea\Media\Subdef;
/**
* Video Subdef
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Video extends Audio
{
const OPTION_SIZE = 'size';
const OPTION_FRAMERATE = 'fps';
const OPTION_VCODEC = 'v_codec';
const OPTION_VCODEC = 'vcodec';
const OPTION_GOPSIZE = 'GOPsize';
protected $options = array();
@@ -24,10 +30,10 @@ class Video extends Audio
{
parent::__construct();
$this->registerOption(new OptionType\Range(self::OPTION_GOPSIZE, 1, 200, 25));
$this->registerOption(new OptionType\Range(self::OPTION_SIZE, 100, 2000, 600, 16));
$this->registerOption(new OptionType\Range(self::OPTION_FRAMERATE, 1, 200, 20));
$this->registerOption(new OptionType\Enum(self::OPTION_VCODEC, array('libx264', 'libvpx', 'libtheora'), 'libx264'));
$this->registerOption(new OptionType\Range(_('GOP size'), self::OPTION_GOPSIZE, 1, 200, 25));
$this->registerOption(new OptionType\Range(_('Dimension'), self::OPTION_SIZE, 100, 2000, 600, 16));
$this->registerOption(new OptionType\Range(_('Frame Rate'), self::OPTION_FRAMERATE, 1, 200, 20));
$this->registerOption(new OptionType\Enum(_('Video Codec'), self::OPTION_VCODEC, array('libx264', 'libvpx', 'libtheora'), 'libx264'));
}
public function getType()

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type;
/**
* Phrasea Audio Media Type
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Audio implements Type
{

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type;
/**
* Phrasea Document Media Type
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Document implements Type
{

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type;
/**
* Phrasea Flash Media Type
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Flash implements Type
{

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type;
/**
* Phrasea Image Media Type
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Image implements Type
{

View File

@@ -11,13 +11,19 @@
namespace Alchemy\Phrasea\Media\Type;
/**
* Phrasea Type Media Type
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
interface Type
{
const TYPE_AUDIO = 'Audio';
const TYPE_VIDEO = 'Video';
const TYPE_DOCUMENT = 'Document';
const TYPE_FLASH = 'Flash';
const TYPE_IMAGE = 'Image';
const TYPE_AUDIO = 'audio';
const TYPE_VIDEO = 'video';
const TYPE_DOCUMENT = 'document';
const TYPE_FLASH = 'flash';
const TYPE_IMAGE = 'image';
public function getType();
}

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type;
/**
* Phrasea Video Media Type
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Video implements Type
{

View File

@@ -3,7 +3,7 @@
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@@ -11,7 +11,6 @@
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/

View File

@@ -212,9 +212,9 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array();
foreach ($fields as $field) {
$ret[$field->get_meta_struct_id()] = array(
'meta_structure_id' => $field->get_meta_struct_id()
, 'name' => $field->get_name()
, 'value' => $field->get_serialized_values(";")
'meta_structure_id' => $field->get_meta_struct_id(),
'name' => $field->get_name(),
'value' => $field->get_serialized_values(";"),
);
}
$result->set_datas($ret);
@@ -249,20 +249,20 @@ class API_V1_adapter extends API_V1_Abstract
$request->get('record_type') : '';
$params = array(
'fields' => is_array($request->get('fields')) ? $request->get('fields') : array()
, 'status' => is_array($request->get('status')) ? $request->get('status') : array()
, 'bases' => is_array($request->get('bases')) ? $request->get('bases') : array()
, 'search_type' => $search_type
, 'recordtype' => $record_type
, 'datemin' => $request->get('datemin') ? : ''
, 'datemax' => $request->get('datemax') ? : ''
, 'datefield' => $request->get('datefield') ? : ''
, 'sort' => $request->get('sort') ? : ''
, 'ord' => $request->get('ord') ? : ''
, 'stemme' => $request->get('stemme') ? : ''
, 'per_page' => $request->get('per_page') ? : 10
, 'query' => $request->get('query') ? : ''
, 'page' => (int) ($request->get('page') ? : 0)
'fields' => is_array($request->get('fields')) ? $request->get('fields') : array(),
'status' => is_array($request->get('status')) ? $request->get('status') : array(),
'bases' => is_array($request->get('bases')) ? $request->get('bases') : array(),
'search_type' => $search_type,
'recordtype' => $record_type,
'datemin' => $request->get('datemin') ? : '',
'datemax' => $request->get('datemax') ? : '',
'datefield' => $request->get('datefield') ? : '',
'sort' => $request->get('sort') ? : '',
'ord' => $request->get('ord') ? : '',
'stemme' => $request->get('stemme') ? : '',
'per_page' => $request->get('per_page') ? : 10,
'query' => $request->get('query') ? : '',
'page' => (int) ($request->get('page') ? : 0),
);
if (is_array($request->get('bases')) === false) {
@@ -327,17 +327,17 @@ class API_V1_adapter extends API_V1_Abstract
$search_result = $search_engine->query_per_page($params['query'], $params["page"], $perPage);
$ret = array(
'total_pages' => $search_result->get_total_pages()
, 'current_page' => $search_result->get_current_page()
, 'available_results' => $search_result->get_count_available_results()
, 'total_results' => $search_result->get_count_total_results()
, 'error' => $search_result->get_error()
, 'warning' => $search_result->get_warning()
, 'query_time' => $search_result->get_query_time()
, 'search_indexes' => $search_result->get_search_indexes()
, 'suggestions' => $search_result->get_suggestions()
, 'results' => array()
, 'query' => $search_engine->get_query()
'total_pages' => $search_result->get_total_pages(),
'current_page' => $search_result->get_current_page(),
'available_results' => $search_result->get_count_available_results(),
'total_results' => $search_result->get_count_total_results(),
'error' => $search_result->get_error(),
'warning' => $search_result->get_warning(),
'query_time' => $search_result->get_query_time(),
'search_indexes' => $search_result->get_search_indexes(),
'suggestions' => $search_result->get_suggestions(),
'results' => array(),
'query' => $search_engine->get_query(),
);
foreach ($search_result->get_datas()->get_elements() as $record) {
@@ -738,10 +738,10 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_basket_element(\Entities\BasketElement $basket_element)
{
$ret = array(
'basket_element_id' => $basket_element->getId()
, 'order' => $basket_element->getOrd()
, 'record' => $this->list_record($basket_element->getRecord())
, 'validation_item' => ! ! $basket_element->getValidationDatas()
'basket_element_id' => $basket_element->getId(),
'order' => $basket_element->getOrd(),
'record' => $this->list_record($basket_element->getRecord()),
'validation_item' => ! ! $basket_element->getValidationDatas(),
);
if ($basket_element->getValidationDatas()) {
@@ -757,7 +757,7 @@ class API_V1_adapter extends API_V1_Abstract
'is_mine' => $user->get_id() == $this->core->getAuthenticatedUser()->get_id(),
'agreement' => $validation_datas->getAgreement(),
'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM),
'note' => $validation_datas->getNote()
'note' => $validation_datas->getNote(),
);
if ($user->get_id() == $this->core->getAuthenticatedUser()->get_id()) {
@@ -900,10 +900,10 @@ class API_V1_adapter extends API_V1_Abstract
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
$datas = array(
'feed' => $this->list_publication($feed, $user)
, 'offset_start' => $offset_start
, 'per_page' => $per_page
, 'entries' => $this->list_publications_entries($feed, $offset_start, $per_page)
'feed' => $this->list_publication($feed, $user),
'offset_start' => $offset_start,
'per_page' => $per_page,
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
);
$result->set_datas($datas);
@@ -921,15 +921,15 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_publication(Feed_Adapter $feed, $user)
{
return array(
'id' => $feed->get_id()
, 'title' => $feed->get_title()
, 'subtitle' => $feed->get_subtitle()
, 'total_entries' => $feed->get_count_total_entries()
, 'icon' => $feed->get_icon_url()
, 'public' => $feed->is_public()
, 'is_mine' => $feed->is_owner($user)
, 'created_on' => $feed->get_created_on()->format(DATE_ATOM)
, 'updated_on' => $feed->get_updated_on()->format(DATE_ATOM)
'id' => $feed->get_id(),
'title' => $feed->get_title(),
'subtitle' => $feed->get_subtitle(),
'total_entries' => $feed->get_count_total_entries(),
'icon' => $feed->get_icon_url(),
'public' => $feed->is_public(),
'is_mine' => $feed->is_owner($user),
'created_on' => $feed->get_created_on()->format(DATE_ATOM),
'updated_on' => $feed->get_updated_on()->format(DATE_ATOM),
);
}
@@ -971,13 +971,13 @@ class API_V1_adapter extends API_V1_Abstract
}
return array(
'author_email' => $entry->get_author_email()
, 'author_name' => $entry->get_author_name()
, 'created_on' => $entry->get_created_on()->format(DATE_ATOM)
, 'updated_on' => $entry->get_updated_on()->format(DATE_ATOM)
, 'title' => $entry->get_title()
, 'subtitle' => $entry->get_subtitle()
, 'items' => $items
'author_email' => $entry->get_author_email(),
'author_name' => $entry->get_author_name(),
'created_on' => $entry->get_created_on()->format(DATE_ATOM),
'updated_on' => $entry->get_updated_on()->format(DATE_ATOM),
'title' => $entry->get_title(),
'subtitle' => $entry->get_subtitle(),
'items' => $items,
);
}
@@ -1039,12 +1039,13 @@ class API_V1_adapter extends API_V1_Abstract
$permalink = null;
return array(
'permalink' => $permalink
, 'height' => $media->get_height()
, 'width' => $media->get_width()
, 'filesize' => $media->get_size()
, 'player_type' => $media->get_type()
, 'mime_type' => $media->get_mime()
'permalink' => $permalink,
'height' => $media->get_height(),
'width' => $media->get_width(),
'filesize' => $media->get_size(),
'devices' => $media->getDevices(),
'player_type' => $media->get_type(),
'mime_type' => $media->get_mime(),
);
}
@@ -1058,13 +1059,13 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_permalink(media_Permalink_Adapter &$permalink, registryInterface &$registry)
{
return array(
'created_on' => $permalink->get_created_on()->format(DATE_ATOM)
, 'id' => $permalink->get_id()
, 'is_activated' => $permalink->get_is_activated()
, 'label' => $permalink->get_label()
, 'last_modified' => $permalink->get_last_modified()->format(DATE_ATOM)
, 'page_url' => $permalink->get_page($registry)
, 'url' => $permalink->get_url($registry)
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
'id' => $permalink->get_id(),
'is_activated' => $permalink->get_is_activated(),
'label' => $permalink->get_label(),
'last_modified' => $permalink->get_last_modified()->format(DATE_ATOM),
'page_url' => $permalink->get_page($registry),
'url' => $permalink->get_url($registry)
);
}
@@ -1118,10 +1119,10 @@ class API_V1_adapter extends API_V1_Abstract
*/
return array(
'meta_id' => $value->getId()
, 'meta_structure_id' => $field->get_meta_struct_id()
, 'name' => $field->get_name()
, 'value' => $value->getValue()
'meta_id' => $value->getId(),
'meta_structure_id' => $field->get_meta_struct_id(),
'name' => $field->get_name(),
'value' => $value->getValue(),
);
}
@@ -1134,13 +1135,13 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_basket(\Entities\Basket $basket)
{
$ret = array(
'created_on' => $basket->getCreated()->format(DATE_ATOM)
, 'description' => (string) $basket->getDescription()
, 'name' => $basket->getName()
, 'pusher_usr_id' => $basket->getPusherId()
, 'ssel_id' => $basket->getId()
, 'updated_on' => $basket->getUpdated()->format(DATE_ATOM)
, 'unread' => ! $basket->getIsRead()
'created_on' => $basket->getCreated()->format(DATE_ATOM),
'description' => (string) $basket->getDescription(),
'name' => $basket->getName(),
'pusher_usr_id' => $basket->getPusherId(),
'ssel_id' => $basket->getId(),
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
'unread' => ! $basket->getIsRead(),
);
if ($basket->getValidation()) {
@@ -1155,7 +1156,7 @@ class API_V1_adapter extends API_V1_Abstract
'usr_name' => $user->get_display_name(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers()
'can_see_others' => $participant->getCanSeeOthers(),
);
}
@@ -1168,13 +1169,12 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array_merge(
array(
'validation_users' => $users
, 'validation_end_date' => $expires_on_atom
, 'validation_infos' => $basket->getValidation()->getValidationString($user)
, 'validation_confirmed' => $basket->getValidation()->getParticipant($user)->getIsConfirmed()
, 'mine' => $basket->getValidation()->isInitiator($user)
)
, $ret
'validation_users' => $users,
'validation_end_date' => $expires_on_atom,
'validation_infos' => $basket->getValidation()->getValidationString($user),
'validation_confirmed' => $basket->getValidation()->getParticipant($user)->getIsConfirmed(),
'mine' => $basket->getValidation()->isInitiator($user),
), $ret
);
}
@@ -1190,21 +1190,21 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_record(record_adapter $record)
{
return array(
'databox_id' => $record->get_sbas_id()
, 'record_id' => $record->get_record_id()
, 'mime_type' => $record->get_mime()
, 'title' => $record->get_title()
, 'original_name' => $record->get_original_name()
, 'last_modification' => $record->get_modification_date()->format(DATE_ATOM)
, 'created_on' => $record->get_creation_date()->format(DATE_ATOM)
, 'collection_id' => phrasea::collFromBas($record->get_base_id())
, 'sha256' => $record->get_sha256()
, 'thumbnail' => $this->list_embedable_media(
'databox_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id(),
'mime_type' => $record->get_mime(),
'title' => $record->get_title(),
'original_name' => $record->get_original_name(),
'last_modification' => $record->get_modification_date()->format(DATE_ATOM),
'created_on' => $record->get_creation_date()->format(DATE_ATOM),
'collection_id' => phrasea::collFromBas($record->get_base_id()),
'sha256' => $record->get_sha256(),
'thumbnail' => $this->list_embedable_media(
$record->get_thumbnail(), registry::get_instance()
)
, 'technical_informations' => $record->get_technical_infos()
, 'phrasea_type' => $record->get_type()
, 'uuid' => $record->get_uuid()
),
'technical_informations' => $record->get_technical_infos(),
'phrasea_type' => $record->get_type(),
'uuid' => $record->get_uuid(),
);
}
@@ -1281,10 +1281,10 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_collection(collection $collection)
{
$ret = array(
'base_id' => $collection->get_base_id()
, 'coll_id' => $collection->get_coll_id()
, 'name' => $collection->get_name()
, 'record_amount' => $collection->get_record_amount()
'base_id' => $collection->get_base_id(),
'coll_id' => $collection->get_coll_id(),
'name' => $collection->get_name(),
'record_amount' => $collection->get_record_amount(),
);
return $ret;
@@ -1301,13 +1301,13 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array();
foreach ($status as $n => $datas) {
$ret[$n] = array(
'bit' => $n
, 'label_on' => $datas['labelon']
, 'label_off' => $datas['labeloff']
, 'img_on' => $datas['img_on']
, 'img_off' => $datas['img_off']
, 'searchable' => $datas['searchable']
, 'printable' => $datas['printable']
'bit' => $n,
'label_on' => $datas['labelon'],
'label_off' => $datas['labeloff'],
'img_on' => $datas['img_on'],
'img_off' => $datas['img_off'],
'searchable' => $datas['searchable'],
'printable' => $datas['printable'],
);
}
@@ -1339,18 +1339,18 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_databox_metadata_field_properties(databox_field $databox_field)
{
$ret = array(
'id' => $databox_field->get_id()
, 'namespace' => $databox_field->get_metadata_namespace()
, 'source' => $databox_field->get_metadata_source()
, 'tagname' => $databox_field->get_metadata_tagname()
, 'name' => $databox_field->get_name()
, 'separator' => $databox_field->get_separator()
, 'thesaurus_branch' => $databox_field->get_tbranch()
, 'type' => $databox_field->get_type()
, 'indexable' => $databox_field->is_indexable()
, 'multivalue' => $databox_field->is_multi()
, 'readonly' => $databox_field->is_readonly()
, 'required' => $databox_field->is_required()
'id' => $databox_field->get_id(),
'namespace' => $databox_field->get_metadata_namespace(),
'source' => $databox_field->get_metadata_source(),
'tagname' => $databox_field->get_metadata_tagname(),
'name' => $databox_field->get_name(),
'separator' => $databox_field->get_separator(),
'thesaurus_branch' => $databox_field->get_tbranch(),
'type' => $databox_field->get_type(),
'indexable' => $databox_field->is_indexable(),
'multivalue' => $databox_field->is_multi(),
'readonly' => $databox_field->is_readonly(),
'required' => $databox_field->is_required(),
);
return $ret;

View File

@@ -62,8 +62,10 @@ class Session_Storage_PHPSession extends Session_Storage_Abstract implements Ses
*/
protected function start()
{
session_cache_limiter('');
session_name($this->name);
session_start();
$this->open = true;
return $this;

View File

@@ -32,6 +32,7 @@ class databox_subdef
* @var string
*/
protected $class;
protected $devices = array();
protected $name;
protected $path;
protected $subdef_group;
@@ -50,6 +51,12 @@ class databox_subdef
const CLASS_THUMBNAIL = 'thumbnail';
const CLASS_PREVIEW = 'preview';
const CLASS_DOCUMENT = 'document';
const DEVICE_ALL = 'all';
const DEVICE_HANDHELD = 'handheld';
const DEVICE_PRINT = 'print';
const DEVICE_PROJECTION = 'projection';
const DEVICE_SCREEN = 'screen';
const DEVICE_TV = 'tv';
/**
*
@@ -60,6 +67,11 @@ class databox_subdef
{
$this->subdef_group = $type;
$this->class = (string) $sd->attributes()->class;
foreach ($sd->devices as $device) {
$this->devices[] = (string) $device;
}
$this->name = strtolower($sd->attributes()->name);
$this->downloadable = p4field::isyes($sd->attributes()->downloadable);
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
@@ -98,73 +110,6 @@ class databox_subdef
return $this;
}
protected function buildImageSubdef(SimpleXMLElement $sd)
{
$image = new Image();
if ($sd->size) {
$image->setOptionValue(Image::OPTION_SIZE, (int) $sd->size);
}
if ($sd->quality) {
$image->setOptionValue(Image::OPTION_QUALITY, (int) $sd->quality);
}
if ($sd->strip) {
$image->setOptionValue(Image::OPTION_STRIP, p4field::isyes($sd->strip));
}
if ($sd->dpi) {
$image->setOptionValue(Image::OPTION_RESOLUTION, (int) $sd->dpi);
}
return $image;
}
protected function buildAudioSubdef(SimpleXMLElement $sd)
{
return new Audio();
}
protected function buildFlexPaperSubdef(SimpleXMLElement $sd)
{
return new FlexPaper();
}
protected function buildGifSubdef(SimpleXMLElement $sd)
{
$gif = new Gif();
if ($sd->size) {
$gif->setOptionValue(Gif::OPTION_SIZE, (int) $sd->size);
}
if ($sd->delay) {
$gif->setOptionValue(Gif::OPTION_DELAY, (int) $sd->delay);
}
return $gif;
}
protected function buildVideoSubdef(SimpleXMLElement $sd)
{
$video = new Video();
if ($sd->size) {
$video->setOptionValue(Video::OPTION_SIZE, (int) $sd->size);
}
if ($sd->acodec) {
$video->setOptionValue(Video::OPTION_ACODEC, (string) $sd->acodec);
}
if ($sd->vcodec) {
$video->setOptionValue(Video::OPTION_VCODEC, (string) $sd->vcodec);
}
if ($sd->fps) {
$video->setOptionValue(Video::OPTION_FRAMERATE, (int) $sd->fps);
}
if ($sd->bitrate) {
$video->setOptionValue(Video::OPTION_BITRATE, (int) $sd->bitrate);
}
return $video;
}
/**
*
* @return string
@@ -183,6 +128,16 @@ class databox_subdef
return $this->path;
}
/**
* The devices matching this subdefinition
*
* @return Array
*/
public function getDevices()
{
return $this->devices;
}
/**
*
* @return string
@@ -193,8 +148,9 @@ class databox_subdef
}
/**
* The current SubdefType the subdef converts documents
*
* @return type
* @return Alchemy\Phrasea\Media\Subdef\Subdef
*/
public function getSubdefType()
{
@@ -202,8 +158,9 @@ class databox_subdef
}
/**
* The current Group which the subdef is in (Audio, Video ...)
*
* @return type
* @return Alchemy\Phrasea\Media\Type\Type
*/
public function getSubdefGroup()
{
@@ -211,6 +168,7 @@ class databox_subdef
}
/**
* An associative label ; keys are i18n languages
*
* @return Array
*/
@@ -219,17 +177,38 @@ class databox_subdef
return $this->labels;
}
/**
* boolean
*
* @return type
*/
public function is_downloadable()
{
return $this->downloadable;
}
/**
* Get an array of Alchemy\Phrasea\Media\Subdef\Subdef available for the current Media Type
*
* @return array
*/
public function getAvailableSubdefTypes()
{
$subdefTypes = array();
$availableDevices = array(
self::DEVICE_ALL,
self::DEVICE_HANDHELD,
self::DEVICE_PRINT,
self::DEVICE_PROJECTION,
self::DEVICE_SCREEN,
self::DEVICE_TV,
);
if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) {
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) {
if ($subdefType == $this->subdef_type->getType()) {
$mediatype_obj = $this->subdef_type;
} else {
@@ -255,6 +234,8 @@ class databox_subdef
}
}
$mediatype_obj->registerOption(new \Alchemy\Phrasea\Media\Subdef\OptionType\Multi(_('Target Device'), 'device', $availableDevices, $this->devices));
$subdefTypes[] = $mediatype_obj;
}
}
@@ -273,6 +254,7 @@ class databox_subdef
}
/**
* The name of the subdef
*
* @return string
*/
@@ -281,17 +263,120 @@ class databox_subdef
return $this->name;
}
/**
* Get the MediaAlchemyst specs for the current subdef
*
* @return type
*/
public function getSpecs()
{
return $this->subdef_type->getMediaAlchemystSpec();
}
/**
* An array of Alchemy\Phrasea\Media\Subdef\OptionType\OptionType for the current subdef
*
* @return <type>
* @return array
*/
public function getOptions()
{
return $this->subdef_type->getOptions();
}
/**
* Build Image Subdef object depending the SimpleXMLElement
*
* @param SimpleXMLElement $sd
* @return \Alchemy\Phrasea\Media\Subdef\Video
*/
protected function buildImageSubdef(SimpleXMLElement $sd)
{
$image = new Image();
if ($sd->size) {
$image->setOptionValue(Image::OPTION_SIZE, (int) $sd->size);
}
if ($sd->quality) {
$image->setOptionValue(Image::OPTION_QUALITY, (int) $sd->quality);
}
if ($sd->strip) {
$image->setOptionValue(Image::OPTION_STRIP, p4field::isyes($sd->strip));
}
if ($sd->dpi) {
$image->setOptionValue(Image::OPTION_RESOLUTION, (int) $sd->dpi);
}
return $image;
}
/**
* Build Audio Subdef object depending the SimpleXMLElement
*
* @param SimpleXMLElement $sd
* @return \Alchemy\Phrasea\Media\Subdef\Video
*/
protected function buildAudioSubdef(SimpleXMLElement $sd)
{
return new Audio();
}
/**
* Build Flexpaper Subdef object depending the SimpleXMLElement
*
* @param SimpleXMLElement $sd
* @return \Alchemy\Phrasea\Media\Subdef\Video
*/
protected function buildFlexPaperSubdef(SimpleXMLElement $sd)
{
return new FlexPaper();
}
/**
* Build GIF Subdef object depending the SimpleXMLElement
*
* @param SimpleXMLElement $sd
* @return \Alchemy\Phrasea\Media\Subdef\Video
*/
protected function buildGifSubdef(SimpleXMLElement $sd)
{
$gif = new Gif();
if ($sd->size) {
$gif->setOptionValue(Gif::OPTION_SIZE, (int) $sd->size);
}
if ($sd->delay) {
$gif->setOptionValue(Gif::OPTION_DELAY, (int) $sd->delay);
}
return $gif;
}
/**
* Build Video Subdef object depending the SimpleXMLElement
*
* @param SimpleXMLElement $sd
* @return \Alchemy\Phrasea\Media\Subdef\Video
*/
protected function buildVideoSubdef(SimpleXMLElement $sd)
{
$video = new Video();
if ($sd->size) {
$video->setOptionValue(Video::OPTION_SIZE, (int) $sd->size);
}
if ($sd->a_codec) {
$video->setOptionValue(Video::OPTION_ACODEC, (string) $sd->acodec);
}
if ($sd->v_codec) {
$video->setOptionValue(Video::OPTION_VCODEC, (string) $sd->vcodec);
}
if ($sd->fps) {
$video->setOptionValue(Video::OPTION_FRAMERATE, (int) $sd->fps);
}
if ($sd->bitrate) {
$video->setOptionValue(Video::OPTION_BITRATE, (int) $sd->bitrate);
}
return $video;
}
}

View File

@@ -131,7 +131,7 @@ class databox_subdefsStructure implements IteratorAggregate
if (isset($this->AvSubdefs[$subdef_type]) && isset($this->AvSubdefs[$subdef_type][$subdef_name])) {
return $this->AvSubdefs[$subdef_type][$subdef_name];
}
throw new Exception_Databox_SubdefNotFound();
throw new Exception_Databox_SubdefNotFound(sprintf('Databox subdef name `%s` of type `%s` not found', $subdef_name, $subdef_type));
}
/**
@@ -157,8 +157,9 @@ class databox_subdefsStructure implements IteratorAggregate
$parent->removeChild($node);
}
if (isset($AvSubdefs[$group]) && isset($AvSubdefs[$group][$name]))
if (isset($AvSubdefs[$group]) && isset($AvSubdefs[$group][$name])) {
unset($AvSubdefs[$group][$name]);
}
$this->databox->saveStructure($dom_struct);
@@ -220,9 +221,21 @@ class databox_subdefsStructure implements IteratorAggregate
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
foreach ($options as $option => $value) {
if (is_scalar($value)) {
$child = $dom_struct->createElement($option);
$child->appendChild($dom_struct->createTextNode($value));
$subdef->appendChild($child);
} elseif (is_array($value)) {
foreach ($value as $v) {
$child = $dom_struct->createElement($option);
$child->appendChild($dom_struct->createTextNode($v));
$subdef->appendChild($child);
}
}
}
$dom_xp = $this->databox->get_xpath_structure();

View File

@@ -187,8 +187,9 @@ class mail
public static function send_mail($subject, $body, $to, $from = false, $files = array(), $reading_confirm_to = false)
{
$Core = \bootstrap::getCore();
$registry = registry::get_instance();
$registry = $Core->getRegistry();
if ( ! isset($to['email']) || ! PHPMailer::ValidateAddress($to['email'])) {
return false;
@@ -252,7 +253,9 @@ class mail
$mail->AddAttachment($f); // attachment
}
if ($Core->getConfiguration()->getEnvironnement() !== 'test') {
$mail->Send();
}
return true;
} catch (phpmailerException $e) {

View File

@@ -77,6 +77,12 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/
protected $name;
/**
*
* @var string
*/
protected $etag;
/**
*
* @var DateTime
@@ -93,7 +99,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*
* @var boolean
*/
protected $is_physically_present = true;
protected $is_physically_present = false;
const TYPE_VIDEO_MP4 = 'VIDEO_MP4';
const TYPE_VIDEO_FLV = 'VIDEO_FLV';
@@ -116,7 +122,6 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->name = $name;
$this->record = $record;
$this->load($substitute);
$this->pathfile = $this->path . $this->file;
$nowtime = new DateTime('-3 days');
$random = $record->get_modification_date() > $nowtime;
@@ -138,6 +143,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->mime = $datas['mime'];
$this->width = $datas['width'];
$this->height = $datas['height'];
$this->etag = $datas['etag'];
$this->baseurl = $datas['baseurl'];
$this->path = $datas['path'];
$this->file = $datas['file'];
@@ -155,7 +161,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$connbas = $this->record->get_databox()->get_connection();
$sql = 'SELECT subdef_id, name, baseurl, file, width, height, mime,
path, size, substit, created_on, updated_on
path, size, substit, created_on, updated_on, etag
FROM subdef
WHERE name = :name AND record_id = :record_id';
@@ -169,14 +175,14 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$registry = $this->record->get_databox()->get_registry();
if ($row) {
$this->width = (int) $row['width'];
$this->height = (int) $row['height'];
$this->mime = $row['mime'];
$this->baseurl = trim($row['baseurl']);
$this->file = $row['file'];
$this->etag = $row['etag'];
$this->path = p4string::addEndSlash($row['path']);
$this->is_substituted = ! ! $row['substit'];
$this->subdef_id = (int) $row['subdef_id'];
@@ -185,50 +191,16 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->modification_date = new DateTime($row['updated_on']);
if ($row['created_on'])
$this->creation_date = new DateTime($row['created_on']);
}
elseif ($substitute === false) {
throw new Exception_Media_SubdefNotFound($this->name . ' not found');
} else {
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->baseurl = 'skins/icons/';
$this->path = $registry->get('GV_RootPath') . 'www/skins/icons/';
$this->file = 'deleted.png';
$this->is_physically_present = false;
$this->is_substituted = true;
}
if ( ! $row || ! file_exists($this->path . $this->file)) {
if ($this->record->is_grouping()) {
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->baseurl = 'skins/icons/substitution/';
$this->path = $registry->get('GV_RootPath')
. 'www/skins/icons/substitution/';
$this->file = 'regroup_thumb.png';
$this->is_substituted = true;
} else {
$mime = $this->record->get_mime();
$mime = trim($mime) != '' ? str_replace('/', '_', $mime) : 'application_octet-stream';
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->baseurl = 'skins/icons/substitution/';
$this->path = $registry->get('GV_RootPath')
. 'www/skins/icons/substitution/';
$this->file = str_replace('+', '%20', $mime) . '.png';
$this->is_substituted = true;
if (file_exists($this->path . $this->file)) {
$this->is_physically_present = true;
}
$this->is_physically_present = false;
if ( ! file_exists($this->path . $this->file)) {
$this->baseurl = 'skins/icons/';
$this->path = $registry->get('GV_RootPath')
. 'www/skins/icons/';
$this->file = 'substitution.png';
$this->is_substituted = true;
} elseif ($substitute === false) {
throw new Exception_Media_SubdefNotFound($this->name . ' not found');
}
if ( ! $row || ! $this->is_physically_present) {
$this->find_substitute_file();
}
$datas = array(
@@ -236,6 +208,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
, 'width' => $this->width
, 'height' => $this->height
, 'baseurl' => $this->baseurl
, 'etag' => $this->etag
, 'path' => $this->path
, 'file' => $this->file
, 'physically_present' => $this->is_physically_present
@@ -250,6 +223,70 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return $this;
}
/**
* Removes the file associated to a subdef
*
* @return \media_subdef
*/
public function remove_file()
{
if ($this->is_physically_present() && is_writable($this->get_pathfile())) {
unlink($this->get_pathfile());
$this->delete_data_from_cache();
if ($this->get_permalink() instanceof media_Permalink_Adapter) {
$this->get_permalink()->delete_data_from_cache();
}
$this->find_substitute_file();
}
return $this;
}
/**
* Find a substitution file for a sibdef
*
* @return \media_subdef
*/
protected function find_substitute_file()
{
$registry = $this->record->get_databox()->get_registry();
if ($this->record->is_grouping()) {
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->baseurl = 'skins/icons/substitution/';
$this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/';
$this->file = 'regroup_thumb.png';
$this->is_substituted = true;
} else {
$mime = $this->record->get_mime();
$mime = trim($mime) != '' ? str_replace('/', '_', $mime) : 'application_octet-stream';
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;
$this->baseurl = 'skins/icons/substitution/';
$this->path = $registry->get('GV_RootPath') . 'www/skins/icons/substitution/';
$this->file = str_replace('+', '%20', $mime) . '.png';
$this->is_substituted = true;
}
$this->is_physically_present = false;
if ( ! file_exists($this->path . $this->file)) {
$this->baseurl = 'skins/icons/';
$this->path = $registry->get('GV_RootPath') . 'www/skins/icons/';
$this->file = 'substitution.png';
$this->is_substituted = true;
}
return $this;
}
/**
*
* @return boolean
@@ -274,7 +311,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/
public function get_permalink()
{
if ( ! $this->permalink && $this->is_physically_present)
if ( ! $this->permalink && $this->is_physically_present())
$this->permalink = media_Permalink_Adapter::getPermalink($this->record->get_databox(), $this);
return $this->permalink;
@@ -289,6 +326,29 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return $this->record->get_record_id();
}
public function getEtag()
{
if ( ! $this->etag && $this->is_physically_present()) {
$this->setEtag(md5_file($this->get_pathfile()));
}
return $this->etag;
}
public function setEtag($etag)
{
$this->etag = $etag;
$sql = "UPDATE subdef SET etag = :etag WHERE subdef_id = :subdef_id";
$stmt = $this->record->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':subdef_id' => $this->subdef_id, ':etag' => $etag));
$stmt->closeCursor();
$this->delete_data_from_cache();
return $this;
}
/**
*
* @return int
@@ -414,7 +474,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/
public function get_pathfile()
{
return $this->pathfile;
return $this->path . $this->file;
}
/**
@@ -446,14 +506,44 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return $this->get_url();
}
/**
* Return the databox subdef corresponding to the subdef
*
* @return \databox_subdef
*/
public function getDataboxSubdef()
{
return $this->record
->get_databox()
->get_subdef_structure()
->get_subdef($this->record->get_type(), $this->get_name());
}
public function getDevices()
{
if ($this->get_name() == 'document') {
return array(\databox_subdef::DEVICE_ALL);
}
return $this->record
->get_databox()
->get_subdef_structure()
->get_subdef($this->record->get_type(), $this->get_name())
->getDevices();
}
/**
*
* @param registryInterface $registry
* @param int $angle
* @return media_subdef
*/
public function rotate(registryInterface $registry, $angle)
public function rotate($angle)
{
if ( ! $this->is_physically_present()) {
throw new \Alchemy\Phrasea\Exception\RuntimeException('You can not rotate a substitution');
}
$Core = \bootstrap::getCore();
$specs = new MediaAlchemyst\Specification\Image();
@@ -550,7 +640,13 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$stmt->execute($params);
$stmt->closeCursor();
return new self($record, $name);
$subdef = new self($record, $name);
if ($subdef->get_permalink() instanceof media_Permalink_Adapter) {
$subdef->get_permalink()->delete_data_from_cache();
}
return $subdef;
}
/**
@@ -570,13 +666,14 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
}
if (in_array($this->mime, array('video/mp4'))) {
$token = p4file::apache_tokenize($this->pathfile);
$token = p4file::apache_tokenize($this->get_pathfile());
if ($token) {
$this->url = $token;
return;
}
}
$this->url = "/datafiles/" . $this->record->get_sbas_id()
. "/" . $this->record->get_record_id() . "/"
. $this->get_name() . "/"

View File

@@ -601,6 +601,50 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this->subdefs[$name] = new media_subdef($this, $name, $substitute);
}
/**
* Returns an array of subdef matching
*
* @param string|array $devices the matching device (see databox_subdef::DEVICE_*)
* @param type $mimes the matching mime types
* @return array
*/
public function getSubdfefByDeviceAndMime($devices = null, $mimes = null)
{
$subdefNames = array();
$searchDevices = array_merge((array) $devices, databox_subdef::DEVICE_ALL);
foreach ($this->databox->get_subdef_structure() as $databoxSubdef) {
if ($devices && ! array_intersect($databoxSubdef->getDevices(), $searchDevices)) {
continue;
}
array_push($subdefNames, $databoxSubdef->get_name());
}
$subdefs = array();
foreach ($this->get_subdefs() as $subdef) {
if ( ! in_array($subdef->get_name(), $subdefNames)) {
continue;
}
if ($mimes && ! in_array($subdef->get_mime(), (array) $mimes)) {
continue;
}
if ($subdef->is_substituted()) {
continue;
}
$subdefs[] = $subdef;
}
return $subdefs;
}
/**
*
* @return Array
@@ -917,9 +961,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$subdef_def = $this->get_databox()->get_subdef_structure()->get_subdef($this->get_type(), $name);
if ($this->has_subdef($name) && ! $this->get_subdef($name)->is_substituted()) {
$value = $this->get_subdef($name);
$original_file = p4string::addEndSlash($value->get_path()) . $value->get_file();
unlink($original_file);
$original_file = $this->get_subdef($name)->get_pathfile();
$this->get_subdef($name)->remove_file();
$this->clearSubdefCache($name);
} else {
$path = databox::dispatch($subdef_def->get_path());
@@ -1584,14 +1628,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$pathdest = null;
if ($this->has_subdef($subdefname) && $this->get_subdef($subdefname)->is_physically_present()) {
$pathdest = $this->get_subdef($subdefname)->get_pathfile();
if ( ! is_file($pathdest) && is_writeable($pathdest)) {
unlink($pathdest);
$pathdest = $this->get_subdef($subdefname)->get_pathfile();
$this->get_subdef($subdefname)->remove_file();
$this->clearSubdefCache($subdefname);
}
}
$pathdest = $this->generateSubdefPathname($subdef, $pathdest);
@@ -1645,6 +1687,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this;
}
/**
* Generate a subdef pathname depending the databox_subdef and the previous file(if regenerated)
*
* @param databox_subdef $subdef
* @param type $oldVersion
* @return type
*/
protected function generateSubdefPathname(databox_subdef $subdef, $oldVersion = null)
{
if ($oldVersion) {
@@ -1656,6 +1705,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $pathdest . $this->get_record_id() . '_' . $subdef->get_name() . '.' . $this->getExtensionFromSpec($subdef->getSpecs());
}
/**
* Get the extension from MediaAlchemyst specs
*
* @param MediaAlchemyst\Specification\Specification $spec
* @return string
*/
protected function getExtensionFromSpec(MediaAlchemyst\Specification\Specification $spec)
{
$extension = null;
@@ -1681,6 +1736,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $extension;
}
/**
* Get the extension from audiocodec
*
* @param string $audioCodec
* @return string
*/
protected function getExtensionFromAudioCodec($audioCodec)
{
$extension = null;
@@ -1697,6 +1758,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $extension;
}
/**
* Get the extension from videocodec
*
* @param string $videoCodec
* @return string
*/
protected function getExtensionFromVideoCodec($videoCodec)
{
$extension = null;
@@ -1783,8 +1850,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
continue;
try {
$subdef->rotate($registry, $angle);
} catch (Exception $e) {
$subdef->rotate($angle);
} catch (\Exception $e) {
}
}

View File

@@ -773,7 +773,7 @@ class set_export extends set_abstract
* @param string $exportname
* @param string $mime
* @param string $disposition
* @return Void
* @return \Symfony\Component\HttpFoundation\Response
*/
public static function stream_file(
$file, $exportname, $mime, $disposition = 'attachment')

View File

@@ -151,18 +151,6 @@ $GV = array(
'end_slash' => true,
'required' => true
),
array(
'type' => 'string',
'name' => 'GV_bitly_user',
'comment' => _('reglages:: Nom d\'utilisateur pour l\'api bit.ly'),
'default' => ''
),
array(
'type' => 'string',
'name' => 'GV_bitly_key',
'comment' => _('reglages:: ccle d\'api pour l\'api bit.ly'),
'default' => '',
),
array(
'type' => 'boolean',
'name' => 'GV_captchas',

View File

@@ -6973,6 +6973,16 @@
<comment></comment>
</field>
<field>
<name>etag</name>
<type>char(32)</type>
<null>YES</null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field>
<name>dispatched</name>
<type>tinyint(1) unsigned</type>

View File

@@ -283,7 +283,7 @@
{% set varname = subdefgroup~'_'~subdefname~'_'~subdefType.getType()~'['~ option.getName() ~']' %}
<tr>
<td style="width:120px;">
{{option.getName()}}
{{option.getDisplayName()}}
</td>
<td style="width:250px;">
{% set extradata = '' %}
@@ -304,7 +304,7 @@
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_ENUM') %}
<select name="{{varname}}">
<option>{% trans 'Choisir' %}</option>
<option value="">{% trans 'Choisir' %}</option>
{% for pot_value in option.getAvailableValues() %}
<option value="{{ pot_value }}" {% if pot_value == option.getValue() %}selected="selected"{% endif %}>{{ pot_value }}</option>
{% endfor %}
@@ -312,8 +312,13 @@
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_BOOLEAN') %}
<input name="{{varname}}" type="radio" value="yes" {% if option.getValue() %}checked="checked"{% endif %} /> {% trans 'yes' %}
<input name="{{varname}}" type="radio" value="no" {% if option.getValue() is empty %}checked="checked"{% endif %}/> {% trans 'no' %}
{% else %}
<input name="{{varname}}" type="text" value="{{ option.getValue() }}"/>
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_MULTI') %}
{% for pot_value, selected in option.Value(true) %}
<input type="checkbox" name="{{varname}}[]" value="{{ pot_value }}" {% if selected %}checked="checked"{% endif %}/><label>{{ pot_value }}</label>
{% endfor %}
{% endif %}
</td>
<td>

View File

@@ -1142,11 +1142,6 @@ function setCss(color)
$("select").hide().show();
}
{% if GV_bitly_user is not empty and GV_bitly_key is not empty %}
$(document).ready(function(){
$("#bitly_loader").attr("src","http{{ request.is_secure() ? 's' : '' }}://bit.ly/javascript-api.js?version=latest&login={{GV_bitly_user}}&apiKey={{GV_bitly_key}}");
});
{% endif %}
</script>
<script type="text/javascript" id="bitly_loader"></script>

View File

@@ -534,6 +534,9 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
$this->assertObjectHasAttribute("mime_type", $embed);
$this->assertEquals($embed->mime_type, $record->get_subdef($subdef_name)->get_mime());
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $embed->mime_type);
$this->assertObjectHasAttribute("devices", $embed);
$this->assertEquals($embed->devices, $record->get_subdef($subdef_name)->getDevices());
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $embed->devices);
}
protected function checkPermalink($permalink, media_subdef $subdef)

View File

@@ -558,6 +558,9 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->assertArrayHasKey("mime_type", $embed);
$this->assertEquals($embed["mime_type"], $record->get_subdef($subdef_name)->get_mime());
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $embed["mime_type"]);
$this->assertArrayHasKey("devices", $embed);
$this->assertEquals($embed['devices'], $record->get_subdef($subdef_name)->getDevices());
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $embed['devices']);
}
protected function checkPermalink($permalink, media_subdef $subdef)

View File

@@ -100,6 +100,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
, 'quality' => 90
))
);
$this->assertTrue($this->client->getResponse()->isRedirect());
$subdef = $subdefs->get_subdef("image", "name");

View File

@@ -12,7 +12,7 @@ class BooleanTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->object = new Boolean('boolean', true);
$this->object = new Boolean('Booleen', 'boolean', true);
}
/**
@@ -42,4 +42,12 @@ class BooleanTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('boolean', $this->object->getName());
}
/**
* @covers Alchemy\Phrasea\Media\Subdef\OptionType\Boolean::getDisplayName
*/
public function testGetDisplayName()
{
$this->assertEquals('Booleen', $this->object->getDisplayName());
}
}

View File

@@ -12,7 +12,7 @@ class EnumTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->object = new Enum('enumerateur', array('un', 'dos', 'tres'), 'dos');
$this->object = new Enum('Numo', 'enumerateur', array('un', 'dos', 'tres'), 'dos');
}
/**
@@ -24,6 +24,8 @@ class EnumTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('dos', $this->object->getValue());
$this->object->setValue('tres');
$this->assertEquals('tres', $this->object->getValue());
$this->object->setValue('');
$this->assertNull($this->object->getValue());
}
/**
@@ -59,4 +61,12 @@ class EnumTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('enumerateur', $this->object->getName());
}
/**
* @covers Alchemy\Phrasea\Media\Subdef\OptionType\Enum::getDisplayName
*/
public function testGetDisplayName()
{
$this->assertEquals('Numo', $this->object->getDisplayName());
}
}

View File

@@ -16,7 +16,7 @@ class RangeTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Range('name', 3, 8, 6, 2);
$this->object = new Range('Rangers', 'name', 3, 8, 6, 2);
}
/**
@@ -28,6 +28,8 @@ class RangeTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(6, $this->object->getValue());
$this->object->setValue(8);
$this->assertEquals(8, $this->object->getValue());
$this->object->setValue('');
$this->assertNull($this->object->getValue());
}
/**
@@ -79,4 +81,12 @@ class RangeTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(8, $this->object->getMaxValue());
}
/**
* @covers Alchemy\Phrasea\Media\Subdef\OptionType\Range::getDisplayName
*/
public function testGetDisplayName()
{
$this->assertEquals('Rangers', $this->object->getDisplayName());
}
}

View File

@@ -13,5 +13,4 @@ class AudioTest extends \PHPUnit_Framework_TestCase
$object = new Audio;
$this->assertEquals(Type::TYPE_AUDIO, $object->getType());
}
}

View File

@@ -13,5 +13,4 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$object = new Document();
$this->assertEquals(Type::TYPE_DOCUMENT, $object->getType());
}
}

View File

@@ -13,5 +13,4 @@ class FlashTest extends \PHPUnit_Framework_TestCase
$object = new Flash();
$this->assertEquals(Type::TYPE_FLASH, $object->getType());
}
}

View File

@@ -13,5 +13,4 @@ class ImageTest extends \PHPUnit_Framework_TestCase
$object = new Image();
$this->assertEquals(Type::TYPE_IMAGE, $object->getType());
}
}

View File

@@ -13,5 +13,4 @@ class VideoTest extends \PHPUnit_Framework_TestCase
$object = new Video();
$this->assertEquals(Type::TYPE_VIDEO, $object->getType());
}
}

View File

@@ -664,15 +664,6 @@ if ($baskStatus == '0') {
});
</script>
<?php
if (trim($registry->get('GV_bitly_user')) !== '' && trim($registry->get('GV_bitly_key')) !== '') {
$request = new http_request();
?>
<script type="text/javascript" src="http<?php echo $request->is_secure() ? 's' : '' ?>://bit.ly/javascript-api.js?version=latest&login=<?php echo $registry->get('GV_bitly_user') ?>&apiKey=<?php echo $registry->get('GV_bitly_key') ?>"></script>
<?php
}
?>
<?php
if (trim($registry->get('GV_googleAnalytics')) != '') {
?>
<script type="text/javascript">