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 - curl -s http://getcomposer.org/installer | php
- php composer.phar install - php composer.phar install
- sudo apt-get update - 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 'create database ab_test;create database db_test;'
- mysql -e "source `pwd`/hudson/fixtures.sql" - mysql -e "source `pwd`/hudson/fixtures.sql"
- git clone git://github.com/alchemy-fr/Phraseanet-Extension.git - git clone git://github.com/alchemy-fr/Phraseanet-Extension.git

View File

@@ -35,11 +35,13 @@ $finder
->name('.gitignore') ->name('.gitignore')
->name('check_cs.php') ->name('check_cs.php')
->name('cleaner.php') ->name('cleaner.php')
->name('lib/phpunit.xml.dist') ->name('phpunit.xml.dist')
->name('launchpadToLocales.php') ->name('launchpadToLocales.php')
->name('localesToLaunchPad.php') ->name('localesToLaunchPad.php')
->name('pom.xml') ->name('pom.xml')
->name('composer.json')
->name('vendors.php') ->name('vendors.php')
->name('vendors.win.php')
->name('builder.php') ->name('builder.php')
->ignoreDotFiles(false) ->ignoreDotFiles(false)
->ignoreVCS(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) { if ($delete_subdef) {
$delete_subef = explode('_', $delete_subdef); $delete_subef = explode('_', $delete_subdef);
$group = $delete_subef[0]; $group = $delete_subef[0];
$name = $delete_subef[1]; $name = $delete_subef[1];
$subdefs = $databox->get_subdef_structure(); $subdefs = $databox->get_subdef_structure();
$subdefs->delete_subdef($group, $name); $subdefs->delete_subdef($group, $name);
} elseif (count($add_subdef) === 3) { } elseif (count($add_subdef) === 3) {
$subdefs = $databox->get_subdef_structure(); $subdefs = $databox->get_subdef_structure();
$UnicodeProcessor = new \unicode(); $UnicodeProcessor = new \unicode();
@@ -76,11 +78,14 @@ class Subdefs implements ControllerProviderInterface
$subdefs->add_subdef($group, $name, $class); $subdefs->add_subdef($group, $name, $class);
} else { } else {
$subdefs = $databox->get_subdef_structure(); $subdefs = $databox->get_subdef_structure();
$options = array();
foreach ($Parmsubdefs as $post_sub) { foreach ($Parmsubdefs as $post_sub) {
$options = array();
$post_sub_ex = explode('_', $post_sub); $post_sub_ex = explode('_', $post_sub);
$group = $post_sub_ex[0]; $group = $post_sub_ex[0];
@@ -105,11 +110,14 @@ class Subdefs implements ControllerProviderInterface
$media = $request->get($post_sub . '_' . $mediatype, array()); $media = $request->get($post_sub . '_' . $mediatype, array());
foreach ($media as $option => $value) { foreach ($media as $option => $value) {
if ($option == 'resolution' && $mediatype == 'image') { if ($option == 'resolution' && $mediatype == 'image') {
$option = 'dpi'; $option = 'dpi';
} }
$options[$option] = $value; $options[$option] = $value;
} }
$subdefs->set_subdef($group, $name, $class, $downloadable, $options); $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_sbas' => $Serializer->serialize($sbas, 'json'),
'thesau_json_bas2sbas' => $Serializer->serialize($bas2sbas, 'json'), 'thesau_json_bas2sbas' => $Serializer->serialize($bas2sbas, 'json'),
'thesau_languages' => \User_Adapter::avLanguages(), '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); return new Response($out);

View File

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

View File

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

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Subdef; namespace Alchemy\Phrasea\Media\Subdef;
/**
* Gif Subdef
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Gif extends Image class Gif extends Image
{ {
const OPTION_DELAY = 'delay'; const OPTION_DELAY = 'delay';
@@ -19,7 +25,7 @@ class Gif extends Image
{ {
parent::__construct(); 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() public function getType()

View File

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

View File

@@ -11,19 +11,27 @@
namespace Alchemy\Phrasea\Media\Subdef\OptionType; 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 class Boolean implements OptionType
{ {
protected $name; protected $name;
protected $default_value; protected $displayName;
protected $defaultValue;
protected $value; protected $value;
public function __construct($name, $default_value = null) public function __construct($displayName, $name, $defaultValue = null)
{ {
$this->displayName = $displayName;
$this->name = $name; $this->name = $name;
$this->default_value = $default_value; $this->defaultValue = $defaultValue;
if ($default_value) { if ($defaultValue) {
$this->setValue($default_value); $this->setValue($defaultValue);
} }
} }
@@ -39,6 +47,11 @@ class Boolean implements OptionType
return self::TYPE_BOOLEAN; return self::TYPE_BOOLEAN;
} }
public function getDisplayName()
{
return $this->displayName;
}
public function getName() public function getName()
{ {
return $this->name; return $this->name;

View File

@@ -11,25 +11,40 @@
namespace Alchemy\Phrasea\Media\Subdef\OptionType; 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 class Enum implements OptionType
{ {
protected $default_value; protected $name;
protected $value; protected $displayName;
protected $defaultValue;
protected $available; 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->name = $name;
$this->available = $available; $this->available = $available;
$this->default_value = $default_value; $this->defaultValue = $defaultValue;
if ($default_value) { if ($defaultValue) {
$this->setValue($default_value); $this->setValue($defaultValue);
} }
} }
public function setValue($value) public function setValue($value)
{ {
if ( ! $value) {
$this->value = null;
return $this;
}
if ( ! in_array($value, $this->available)) { if ( ! in_array($value, $this->available)) {
throw new \Exception_InvalidArgument( throw new \Exception_InvalidArgument(
sprintf( sprintf(
@@ -46,6 +61,11 @@ class Enum implements OptionType
return $this; return $this;
} }
public function getDisplayName()
{
return $this->displayName;
}
public function getType() public function getType()
{ {
return self::TYPE_ENUM; return self::TYPE_ENUM;

View File

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

View File

@@ -11,30 +11,45 @@
namespace Alchemy\Phrasea\Media\Subdef\OptionType; 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 class Range implements OptionType
{ {
protected $min_value; protected $name;
protected $max_value; protected $displayName;
protected $default_value; protected $minValue;
protected $maxValue;
protected $defaultValue;
protected $value; protected $value;
protected $step; 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->name = $name;
$this->min_value = $min_value; $this->minValue = $minValue;
$this->max_value = $max_value; $this->maxValue = $maxValue;
$this->default_value = $default_value; $this->defaultValue = $defaultValue;
$this->step = $step; $this->step = $step;
if ($default_value) { if ($defaultValue) {
$this->setValue($default_value); $this->setValue($defaultValue);
} }
} }
public function setValue($value) 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'); throw new \Exception_InvalidArgument('The value provided does not fit in range');
} }
@@ -43,6 +58,11 @@ class Range implements OptionType
return $this; return $this;
} }
public function getDisplayName()
{
return $this->displayName;
}
public function getType() public function getType()
{ {
return self::TYPE_RANGE; return self::TYPE_RANGE;
@@ -65,11 +85,11 @@ class Range implements OptionType
public function getMinValue() public function getMinValue()
{ {
return $this->min_value; return $this->minValue;
} }
public function getMaxValue() public function getMaxValue()
{ {
return $this->max_value; return $this->maxValue;
} }
} }

View File

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

View File

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

View File

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

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type; 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 class Audio implements Type
{ {

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type; 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 class Document implements Type
{ {

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type; 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 class Flash implements Type
{ {

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type; 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 class Image implements Type
{ {

View File

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

View File

@@ -11,6 +11,12 @@
namespace Alchemy\Phrasea\Media\Type; 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 class Video implements Type
{ {

View File

@@ -3,7 +3,7 @@
/* /*
* This file is part of Phraseanet * 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 * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
@@ -11,7 +11,6 @@
/** /**
* *
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */

View File

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

View File

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

View File

@@ -32,6 +32,7 @@ class databox_subdef
* @var string * @var string
*/ */
protected $class; protected $class;
protected $devices = array();
protected $name; protected $name;
protected $path; protected $path;
protected $subdef_group; protected $subdef_group;
@@ -50,6 +51,12 @@ class databox_subdef
const CLASS_THUMBNAIL = 'thumbnail'; const CLASS_THUMBNAIL = 'thumbnail';
const CLASS_PREVIEW = 'preview'; const CLASS_PREVIEW = 'preview';
const CLASS_DOCUMENT = 'document'; 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->subdef_group = $type;
$this->class = (string) $sd->attributes()->class; $this->class = (string) $sd->attributes()->class;
foreach ($sd->devices as $device) {
$this->devices[] = (string) $device;
}
$this->name = strtolower($sd->attributes()->name); $this->name = strtolower($sd->attributes()->name);
$this->downloadable = p4field::isyes($sd->attributes()->downloadable); $this->downloadable = p4field::isyes($sd->attributes()->downloadable);
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : ''; $this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
@@ -98,73 +110,6 @@ class databox_subdef
return $this; 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 * @return string
@@ -183,6 +128,16 @@ class databox_subdef
return $this->path; return $this->path;
} }
/**
* The devices matching this subdefinition
*
* @return Array
*/
public function getDevices()
{
return $this->devices;
}
/** /**
* *
* @return string * @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() 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() public function getSubdefGroup()
{ {
@@ -211,6 +168,7 @@ class databox_subdef
} }
/** /**
* An associative label ; keys are i18n languages
* *
* @return Array * @return Array
*/ */
@@ -219,17 +177,38 @@ class databox_subdef
return $this->labels; return $this->labels;
} }
/**
* boolean
*
* @return type
*/
public function is_downloadable() public function is_downloadable()
{ {
return $this->downloadable; return $this->downloadable;
} }
/**
* Get an array of Alchemy\Phrasea\Media\Subdef\Subdef available for the current Media Type
*
* @return array
*/
public function getAvailableSubdefTypes() public function getAvailableSubdefTypes()
{ {
$subdefTypes = array(); $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()])) { if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) {
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) { foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) {
if ($subdefType == $this->subdef_type->getType()) { if ($subdefType == $this->subdef_type->getType()) {
$mediatype_obj = $this->subdef_type; $mediatype_obj = $this->subdef_type;
} else { } 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; $subdefTypes[] = $mediatype_obj;
} }
} }
@@ -273,6 +254,7 @@ class databox_subdef
} }
/** /**
* The name of the subdef
* *
* @return string * @return string
*/ */
@@ -281,17 +263,120 @@ class databox_subdef
return $this->name; return $this->name;
} }
/**
* Get the MediaAlchemyst specs for the current subdef
*
* @return type
*/
public function getSpecs() public function getSpecs()
{ {
return $this->subdef_type->getMediaAlchemystSpec(); 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() public function getOptions()
{ {
return $this->subdef_type->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])) { if (isset($this->AvSubdefs[$subdef_type]) && isset($this->AvSubdefs[$subdef_type][$subdef_name])) {
return $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); $parent->removeChild($node);
} }
if (isset($AvSubdefs[$group]) && isset($AvSubdefs[$group][$name])) if (isset($AvSubdefs[$group]) && isset($AvSubdefs[$group][$name])) {
unset($AvSubdefs[$group][$name]); unset($AvSubdefs[$group][$name]);
}
$this->databox->saveStructure($dom_struct); $this->databox->saveStructure($dom_struct);
@@ -220,9 +221,21 @@ class databox_subdefsStructure implements IteratorAggregate
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false')); $subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
foreach ($options as $option => $value) { foreach ($options as $option => $value) {
$child = $dom_struct->createElement($option);
$child->appendChild($dom_struct->createTextNode($value)); if (is_scalar($value)) {
$subdef->appendChild($child);
$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(); $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) 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'])) { if ( ! isset($to['email']) || ! PHPMailer::ValidateAddress($to['email'])) {
return false; return false;
@@ -252,7 +253,9 @@ class mail
$mail->AddAttachment($f); // attachment $mail->AddAttachment($f); // attachment
} }
$mail->Send(); if ($Core->getConfiguration()->getEnvironnement() !== 'test') {
$mail->Send();
}
return true; return true;
} catch (phpmailerException $e) { } catch (phpmailerException $e) {

View File

@@ -77,6 +77,12 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/ */
protected $name; protected $name;
/**
*
* @var string
*/
protected $etag;
/** /**
* *
* @var DateTime * @var DateTime
@@ -93,7 +99,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
* *
* @var boolean * @var boolean
*/ */
protected $is_physically_present = true; protected $is_physically_present = false;
const TYPE_VIDEO_MP4 = 'VIDEO_MP4'; const TYPE_VIDEO_MP4 = 'VIDEO_MP4';
const TYPE_VIDEO_FLV = 'VIDEO_FLV'; const TYPE_VIDEO_FLV = 'VIDEO_FLV';
@@ -116,7 +122,6 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->name = $name; $this->name = $name;
$this->record = $record; $this->record = $record;
$this->load($substitute); $this->load($substitute);
$this->pathfile = $this->path . $this->file;
$nowtime = new DateTime('-3 days'); $nowtime = new DateTime('-3 days');
$random = $record->get_modification_date() > $nowtime; $random = $record->get_modification_date() > $nowtime;
@@ -138,6 +143,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->mime = $datas['mime']; $this->mime = $datas['mime'];
$this->width = $datas['width']; $this->width = $datas['width'];
$this->height = $datas['height']; $this->height = $datas['height'];
$this->etag = $datas['etag'];
$this->baseurl = $datas['baseurl']; $this->baseurl = $datas['baseurl'];
$this->path = $datas['path']; $this->path = $datas['path'];
$this->file = $datas['file']; $this->file = $datas['file'];
@@ -155,7 +161,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$connbas = $this->record->get_databox()->get_connection(); $connbas = $this->record->get_databox()->get_connection();
$sql = 'SELECT subdef_id, name, baseurl, file, width, height, mime, $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 FROM subdef
WHERE name = :name AND record_id = :record_id'; 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); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$registry = $this->record->get_databox()->get_registry();
if ($row) { if ($row) {
$this->width = (int) $row['width']; $this->width = (int) $row['width'];
$this->height = (int) $row['height']; $this->height = (int) $row['height'];
$this->mime = $row['mime']; $this->mime = $row['mime'];
$this->baseurl = trim($row['baseurl']); $this->baseurl = trim($row['baseurl']);
$this->file = $row['file']; $this->file = $row['file'];
$this->etag = $row['etag'];
$this->path = p4string::addEndSlash($row['path']); $this->path = p4string::addEndSlash($row['path']);
$this->is_substituted = ! ! $row['substit']; $this->is_substituted = ! ! $row['substit'];
$this->subdef_id = (int) $row['subdef_id']; $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']); $this->modification_date = new DateTime($row['updated_on']);
if ($row['created_on']) if ($row['created_on'])
$this->creation_date = new DateTime($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'; if (file_exists($this->path . $this->file)) {
$this->width = 256; $this->is_physically_present = true;
$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;
} }
} elseif ($substitute === false) {
throw new Exception_Media_SubdefNotFound($this->name . ' not found');
}
if ( ! $row || ! $this->is_physically_present) {
$this->find_substitute_file();
} }
$datas = array( $datas = array(
@@ -236,6 +208,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
, 'width' => $this->width , 'width' => $this->width
, 'height' => $this->height , 'height' => $this->height
, 'baseurl' => $this->baseurl , 'baseurl' => $this->baseurl
, 'etag' => $this->etag
, 'path' => $this->path , 'path' => $this->path
, 'file' => $this->file , 'file' => $this->file
, 'physically_present' => $this->is_physically_present , 'physically_present' => $this->is_physically_present
@@ -250,6 +223,70 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return $this; 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 * @return boolean
@@ -274,7 +311,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/ */
public function get_permalink() 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); $this->permalink = media_Permalink_Adapter::getPermalink($this->record->get_databox(), $this);
return $this->permalink; return $this->permalink;
@@ -289,6 +326,29 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return $this->record->get_record_id(); 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 * @return int
@@ -414,7 +474,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/ */
public function get_pathfile() 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 $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 registryInterface $registry
* @param int $angle * @param int $angle
* @return media_subdef * @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(); $Core = \bootstrap::getCore();
$specs = new MediaAlchemyst\Specification\Image(); $specs = new MediaAlchemyst\Specification\Image();
@@ -550,7 +640,13 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $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'))) { if (in_array($this->mime, array('video/mp4'))) {
$token = p4file::apache_tokenize($this->pathfile); $token = p4file::apache_tokenize($this->get_pathfile());
if ($token) { if ($token) {
$this->url = $token; $this->url = $token;
return; return;
} }
} }
$this->url = "/datafiles/" . $this->record->get_sbas_id() $this->url = "/datafiles/" . $this->record->get_sbas_id()
. "/" . $this->record->get_record_id() . "/" . "/" . $this->record->get_record_id() . "/"
. $this->get_name() . "/" . $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); 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 * @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); $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()) { 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(); $original_file = $this->get_subdef($name)->get_pathfile();
unlink($original_file); $this->get_subdef($name)->remove_file();
$this->clearSubdefCache($name); $this->clearSubdefCache($name);
} else { } else {
$path = databox::dispatch($subdef_def->get_path()); $path = databox::dispatch($subdef_def->get_path());
@@ -1584,13 +1628,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$pathdest = null; $pathdest = null;
if ($this->has_subdef($subdefname) && $this->get_subdef($subdefname)->is_physically_present()) { if ($this->has_subdef($subdefname) && $this->get_subdef($subdefname)->is_physically_present()) {
$pathdest = $this->get_subdef($subdefname)->get_pathfile(); $pathdest = $this->get_subdef($subdefname)->get_pathfile();
$this->get_subdef($subdefname)->remove_file();
if ( ! is_file($pathdest) && is_writeable($pathdest)) { $this->clearSubdefCache($subdefname);
unlink($pathdest);
$this->clearSubdefCache($subdefname);
}
} }
$pathdest = $this->generateSubdefPathname($subdef, $pathdest); $pathdest = $this->generateSubdefPathname($subdef, $pathdest);
@@ -1645,6 +1687,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this; 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) protected function generateSubdefPathname(databox_subdef $subdef, $oldVersion = null)
{ {
if ($oldVersion) { 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()); 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) protected function getExtensionFromSpec(MediaAlchemyst\Specification\Specification $spec)
{ {
$extension = null; $extension = null;
@@ -1681,6 +1736,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $extension; return $extension;
} }
/**
* Get the extension from audiocodec
*
* @param string $audioCodec
* @return string
*/
protected function getExtensionFromAudioCodec($audioCodec) protected function getExtensionFromAudioCodec($audioCodec)
{ {
$extension = null; $extension = null;
@@ -1697,6 +1758,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $extension; return $extension;
} }
/**
* Get the extension from videocodec
*
* @param string $videoCodec
* @return string
*/
protected function getExtensionFromVideoCodec($videoCodec) protected function getExtensionFromVideoCodec($videoCodec)
{ {
$extension = null; $extension = null;
@@ -1783,8 +1850,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
continue; continue;
try { try {
$subdef->rotate($registry, $angle); $subdef->rotate($angle);
} catch (Exception $e) { } catch (\Exception $e) {
} }
} }

View File

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

View File

@@ -151,18 +151,6 @@ $GV = array(
'end_slash' => true, 'end_slash' => true,
'required' => 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( array(
'type' => 'boolean', 'type' => 'boolean',
'name' => 'GV_captchas', 'name' => 'GV_captchas',

View File

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

View File

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

View File

@@ -1142,11 +1142,6 @@ function setCss(color)
$("select").hide().show(); $("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>
<script type="text/javascript" id="bitly_loader"></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->assertObjectHasAttribute("mime_type", $embed);
$this->assertEquals($embed->mime_type, $record->get_subdef($subdef_name)->get_mime()); $this->assertEquals($embed->mime_type, $record->get_subdef($subdef_name)->get_mime());
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $embed->mime_type); $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) protected function checkPermalink($permalink, media_subdef $subdef)

View File

@@ -558,6 +558,9 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
$this->assertArrayHasKey("mime_type", $embed); $this->assertArrayHasKey("mime_type", $embed);
$this->assertEquals($embed["mime_type"], $record->get_subdef($subdef_name)->get_mime()); $this->assertEquals($embed["mime_type"], $record->get_subdef($subdef_name)->get_mime());
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $embed["mime_type"]); $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) protected function checkPermalink($permalink, media_subdef $subdef)

View File

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

View File

@@ -12,7 +12,7 @@ class BooleanTest extends \PHPUnit_Framework_TestCase
protected function setUp() 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()); $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() 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->assertEquals('dos', $this->object->getValue());
$this->object->setValue('tres'); $this->object->setValue('tres');
$this->assertEquals('tres', $this->object->getValue()); $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()); $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() 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->assertEquals(6, $this->object->getValue());
$this->object->setValue(8); $this->object->setValue(8);
$this->assertEquals(8, $this->object->getValue()); $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()); $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; $object = new Audio;
$this->assertEquals(Type::TYPE_AUDIO, $object->getType()); $this->assertEquals(Type::TYPE_AUDIO, $object->getType());
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -664,15 +664,6 @@ if ($baskStatus == '0') {
}); });
</script> </script>
<?php <?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')) != '') { if (trim($registry->get('GV_googleAnalytics')) != '') {
?> ?>
<script type="text/javascript"> <script type="text/javascript">