diff --git a/.travis.yml b/.travis.yml index e6229a1008..14b36052e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/builder.php b/builder.php index 3ad24e17e9..2375e6125e 100755 --- a/builder.php +++ b/builder.php @@ -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) diff --git a/hudson/fixtures.sql b/hudson/fixtures.sql index fea42e244b..7991611690 100644 --- a/hudson/fixtures.sql +++ b/hudson/fixtures.sql @@ -1229,7 +1229,7 @@ CREATE TABLE `registry` ( LOCK TABLES `registry` WRITE; /*!40000 ALTER TABLE `registry` DISABLE KEYS */; -INSERT INTO `registry` VALUES (1,'GV_timezone','Europe/Paris','string'),(2,'GV_sit','c51b8b3501fb45447c359fda7d3784d4','string'),(3,'GV_default_lng','fr_FR','string'),(4,'GV_STATIC_URL','','string'),(5,'GV_message','May the force be with you','string'),(6,'GV_message_on','0','boolean'),(7,'GV_log_errors','0','boolean'),(8,'GV_google_api','0','boolean'),(9,'GV_i18n_service','http://localization.webservice.alchemyasp.com/','string'),(10,'GV_bitly_user','','string'),(11,'GV_bitly_key','','string'),(12,'GV_captchas','0','boolean'),(13,'GV_captcha_public_key','','string'),(14,'GV_captcha_private_key','','string'),(15,'GV_youtube_api','0','boolean'),(16,'GV_youtube_client_id','','string'),(17,'GV_youtube_client_secret','','string'),(18,'GV_youtube_dev_key','','string'),(19,'GV_flickr_api','0','boolean'),(20,'GV_flickr_client_id','','string'),(21,'GV_flickr_client_secret','','string'),(22,'GV_dailymotion_api','0','boolean'),(23,'GV_dailymotion_client_id','','string'),(24,'GV_dailymotion_client_secret','','string'),(25,'GV_client_navigator','0','boolean'),(26,'GV_events','a:1:{i:0;s:24:\"eventsmanager_event_test\";}','array'),(27,'GV_notifications','a:12:{i:0;s:33:\"eventsmanager_notify_autoregister\";i:1;s:37:\"eventsmanager_notify_bridgeuploadfail\";i:2;s:37:\"eventsmanager_notify_downloadmailfail\";i:3;s:25:\"eventsmanager_notify_feed\";i:4;s:26:\"eventsmanager_notify_order\";i:5;s:33:\"eventsmanager_notify_orderdeliver\";i:6;s:38:\"eventsmanager_notify_ordernotdelivered\";i:7;s:25:\"eventsmanager_notify_push\";i:8;s:29:\"eventsmanager_notify_register\";i:9;s:29:\"eventsmanager_notify_validate\";i:10;s:35:\"eventsmanager_notify_validationdone\";i:11;s:39:\"eventsmanager_notify_validationreminder\";}','array'),(28,'GV_appletAllowedFileExt','jpg,jpeg,bmp,tif,gif,png,pdf,doc,odt,mpg,mpeg,mov,avi,xls,flv,mp3,mp2','string'),(32,'GV_sphinx','0','boolean'),(33,'GV_sphinx_host','127.0.0.1','string'),(34,'GV_sphinx_port','9306','integer'),(35,'GV_sphinx_rt_host','127.0.0.1','string'),(36,'GV_sphinx_rt_port','9308','integer'),(37,'GV_phrasea_sort','','string'),(38,'GV_modxsendfile','0','boolean'),(39,'GV_X_Accel_Redirect','','string'),(40,'GV_X_Accel_Redirect_mount_point','noweb','string'),(41,'GV_h264_streaming','0','boolean'),(42,'GV_mod_auth_token_directory','','string'),(43,'GV_mod_auth_token_directory_path','','string'),(44,'GV_mod_auth_token_passphrase','','string'),(46,'GV_PHP_INI','','string'),(58,'GV_pdfmaxpages','5','integer'),(59,'GV_filesOwner','','string'),(60,'GV_filesGroup','','string'),(61,'GV_adminMail','support@alchemy.fr','string'),(62,'GV_view_bas_and_coll','0','boolean'),(63,'GV_choose_export_title','0','boolean'),(64,'GV_default_export_title','support@alchemy.fr','string'),(65,'GV_social_tools','none','string'),(66,'GV_home_publi','COOLIRIS','string'),(67,'GV_min_letters_truncation','1','integer'),(68,'GV_defaultQuery','all','string'),(69,'GV_defaultQuery_type','0','string'),(70,'GV_anonymousReport','0','boolean'),(71,'GV_thesaurus','0','boolean'),(72,'GV_multiAndReport','0','boolean'),(73,'GV_seeOngChgDoc','0','boolean'),(74,'GV_seeNewThumb','0','boolean'),(75,'GV_defaulmailsenderaddr','phraseanet@example.com','string'),(76,'GV_smtp','0','boolean'),(77,'GV_smtp_auth','0','boolean'),(78,'GV_smtp_host','','string'),(79,'GV_smtp_port','','string'),(80,'GV_smtp_secure','0','boolean'),(81,'GV_smtp_user','','string'),(82,'GV_smtp_password','','string'),(83,'GV_activeFTP','0','boolean'),(84,'GV_ftp_for_user','0','boolean'),(85,'GV_download_max','120','integer'),(86,'GV_ong_search','1','integer'),(87,'GV_ong_advsearch','2','integer'),(88,'GV_ong_topics','0','integer'),(89,'GV_ong_actif','1','integer'),(90,'GV_client_render_topics','tree','string'),(91,'GV_rollover_reg_preview','0','boolean'),(92,'GV_rollover_chu','0','boolean'),(93,'GV_client_coll_ckbox','checkbox','string'),(94,'GV_viewSizeBaket','0','boolean'),(95,'GV_clientAutoShowProposals','0','boolean'),(96,'GV_needAuth2DL','0','boolean'),(97,'GV_autoselectDB','0','boolean'),(98,'GV_autoregister','0','boolean'),(99,'GV_validation_reminder','2','integer'),(100,'GV_val_expiration','10','integer'),(101,'GV_homeTitle','Phraseanet','string'),(102,'GV_metaKeywords','','string'),(103,'GV_metaDescription','','string'),(104,'GV_googleAnalytics','','string'),(105,'GV_allow_search_engine','0','boolean'),(106,'GV_display_gcf','0','boolean'),(107,'GV_base_datapath_noweb','/tmp/','string'),(108,'GV_base_datapath_web','/tmp/','string'),(109,'GV_base_dataurl','web/','string'),(110,'GV_ServerName','http://local.phrasea/','string'),(111,'GV_cli','/usr/local/bin/php','string'),(112,'GV_imagick','/usr/local/bin/gm','string'),(113,'GV_pathcomposite','/usr/local/bin/gm','string'),(114,'GV_exiftool','/home/vagrant/builds/alchemy-fr/Phraseanet/lib/vendor/exiftool/exiftool','string'),(115,'GV_swf_extract','','string'),(116,'GV_pdf2swf','','string'),(117,'GV_swf_render','','string'),(118,'GV_unoconv','','string'),(119,'GV_ffmpeg','','string'),(120,'GV_mp4box','','string'),(121,'GV_mplayer','','string'),(122,'GV_pdftotext','','string'); +INSERT INTO `registry` VALUES (1,'GV_timezone','Europe/Paris','string'),(2,'GV_sit','c51b8b3501fb45447c359fda7d3784d4','string'),(3,'GV_default_lng','fr_FR','string'),(4,'GV_STATIC_URL','','string'),(5,'GV_message','May the force be with you','string'),(6,'GV_message_on','0','boolean'),(7,'GV_log_errors','0','boolean'),(8,'GV_google_api','0','boolean'),(9,'GV_i18n_service','http://localization.webservice.alchemyasp.com/','string'),(10,'GV_bitly_user','','string'),(11,'GV_bitly_key','','string'),(12,'GV_captchas','0','boolean'),(13,'GV_captcha_public_key','','string'),(14,'GV_captcha_private_key','','string'),(15,'GV_youtube_api','0','boolean'),(16,'GV_youtube_client_id','','string'),(17,'GV_youtube_client_secret','','string'),(18,'GV_youtube_dev_key','','string'),(19,'GV_flickr_api','0','boolean'),(20,'GV_flickr_client_id','','string'),(21,'GV_flickr_client_secret','','string'),(22,'GV_dailymotion_api','0','boolean'),(23,'GV_dailymotion_client_id','','string'),(24,'GV_dailymotion_client_secret','','string'),(25,'GV_client_navigator','0','boolean'),(26,'GV_events','a:1:{i:0;s:24:\"eventsmanager_event_test\";}','array'),(27,'GV_notifications','a:12:{i:0;s:33:\"eventsmanager_notify_autoregister\";i:1;s:37:\"eventsmanager_notify_bridgeuploadfail\";i:2;s:37:\"eventsmanager_notify_downloadmailfail\";i:3;s:25:\"eventsmanager_notify_feed\";i:4;s:26:\"eventsmanager_notify_order\";i:5;s:33:\"eventsmanager_notify_orderdeliver\";i:6;s:38:\"eventsmanager_notify_ordernotdelivered\";i:7;s:25:\"eventsmanager_notify_push\";i:8;s:29:\"eventsmanager_notify_register\";i:9;s:29:\"eventsmanager_notify_validate\";i:10;s:35:\"eventsmanager_notify_validationdone\";i:11;s:39:\"eventsmanager_notify_validationreminder\";}','array'),(28,'GV_appletAllowedFileExt','jpg,jpeg,bmp,tif,gif,png,pdf,doc,odt,mpg,mpeg,mov,avi,xls,flv,mp3,mp2','string'),(32,'GV_sphinx','0','boolean'),(33,'GV_sphinx_host','127.0.0.1','string'),(34,'GV_sphinx_port','9306','integer'),(35,'GV_sphinx_rt_host','127.0.0.1','string'),(36,'GV_sphinx_rt_port','9308','integer'),(37,'GV_phrasea_sort','','string'),(38,'GV_modxsendfile','0','boolean'),(39,'GV_X_Accel_Redirect','','string'),(40,'GV_X_Accel_Redirect_mount_point','noweb','string'),(41,'GV_h264_streaming','0','boolean'),(42,'GV_mod_auth_token_directory','','string'),(43,'GV_mod_auth_token_directory_path','','string'),(44,'GV_mod_auth_token_passphrase','','string'),(46,'GV_PHP_INI','','string'),(58,'GV_pdfmaxpages','5','integer'),(59,'GV_filesOwner','','string'),(60,'GV_filesGroup','','string'),(61,'GV_adminMail','support@alchemy.fr','string'),(62,'GV_view_bas_and_coll','0','boolean'),(63,'GV_choose_export_title','0','boolean'),(64,'GV_default_export_title','support@alchemy.fr','string'),(65,'GV_social_tools','none','string'),(66,'GV_home_publi','COOLIRIS','string'),(67,'GV_min_letters_truncation','1','integer'),(68,'GV_defaultQuery','all','string'),(69,'GV_defaultQuery_type','0','string'),(70,'GV_anonymousReport','0','boolean'),(71,'GV_thesaurus','0','boolean'),(72,'GV_multiAndReport','0','boolean'),(73,'GV_seeOngChgDoc','0','boolean'),(74,'GV_seeNewThumb','0','boolean'),(75,'GV_defaulmailsenderaddr','phraseanet@example.com','string'),(76,'GV_smtp','0','boolean'),(77,'GV_smtp_auth','0','boolean'),(78,'GV_smtp_host','','string'),(79,'GV_smtp_port','','string'),(80,'GV_smtp_secure','0','boolean'),(81,'GV_smtp_user','','string'),(82,'GV_smtp_password','','string'),(83,'GV_activeFTP','0','boolean'),(84,'GV_ftp_for_user','0','boolean'),(85,'GV_download_max','120','integer'),(86,'GV_ong_search','1','integer'),(87,'GV_ong_advsearch','2','integer'),(88,'GV_ong_topics','0','integer'),(89,'GV_ong_actif','1','integer'),(90,'GV_client_render_topics','tree','string'),(91,'GV_rollover_reg_preview','0','boolean'),(92,'GV_rollover_chu','0','boolean'),(93,'GV_client_coll_ckbox','checkbox','string'),(94,'GV_viewSizeBaket','0','boolean'),(95,'GV_clientAutoShowProposals','0','boolean'),(96,'GV_needAuth2DL','0','boolean'),(97,'GV_autoselectDB','0','boolean'),(98,'GV_autoregister','0','boolean'),(99,'GV_validation_reminder','2','integer'),(100,'GV_val_expiration','10','integer'),(101,'GV_homeTitle','Phraseanet','string'),(102,'GV_metaKeywords','','string'),(103,'GV_metaDescription','','string'),(104,'GV_googleAnalytics','','string'),(105,'GV_allow_search_engine','0','boolean'),(106,'GV_display_gcf','0','boolean'),(107,'GV_base_datapath_noweb','/tmp/','string'),(108,'GV_base_datapath_web','/tmp/','string'),(109,'GV_base_dataurl','web/','string'),(110,'GV_ServerName','http://local.phrasea/','string'),(111,'GV_cli','/usr/local/bin/php','string'),(112,'GV_imagick','/usr/local/bin/gm','string'),(113,'GV_pathcomposite','/usr/local/bin/gm','string'),(114,'GV_exiftool','/home/vagrant/builds/alchemy-fr/Phraseanet/lib/vendor/exiftool/exiftool','string'),(115,'GV_swf_extract','','string'),(116,'GV_pdf2swf','','string'),(117,'GV_swf_render','','string'),(118,'GV_unoconv','','string'),(119,'GV_ffmpeg','','string'),(120,'GV_mp4box','','string'),(121,'GV_mplayer','/usr/bin/mplayer','string'),(122,'GV_pdftotext','','string'); /*!40000 ALTER TABLE `registry` ENABLE KEYS */; UNLOCK TABLES; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php b/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php index 03790bc76b..942626eb0d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php @@ -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(); - $options = array(); foreach ($Parmsubdefs as $post_sub) { + + $options = array(); + $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); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index 41dd2c1271..4fada95f38 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -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); diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php index aa5c4038ab..5e13f0fca5 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php @@ -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() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php index 8b5def0208..06553fea28 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php @@ -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(); diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Gif.php b/lib/Alchemy/Phrasea/Media/Subdef/Gif.php index 99a30e3de8..5aef401ebb 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Gif.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Gif.php @@ -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() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Image.php b/lib/Alchemy/Phrasea/Media/Subdef/Image.php index 577e8b8b89..258b0c6f3f 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Image.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Image.php @@ -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() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Boolean.php b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Boolean.php index d653bf12cc..cc9a0023c4 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Boolean.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Boolean.php @@ -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; diff --git a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Enum.php b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Enum.php index 217fd465a6..0e1eb87992 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Enum.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Enum.php @@ -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; diff --git a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/OptionType.php b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/OptionType.php index f515d6d1b1..08bd5964ed 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/OptionType.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/OptionType.php @@ -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(); } diff --git a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Range.php b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Range.php index bbb807c218..aef1abc257 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Range.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Range.php @@ -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; } } diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php index e68e85b369..77ce4d4cfe 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php @@ -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; diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php b/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php index 0afbd9da09..c3ccf99c4d 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Subdef.php @@ -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'; diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Video.php b/lib/Alchemy/Phrasea/Media/Subdef/Video.php index 2bc04beb8e..568527ed54 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Video.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Video.php @@ -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() diff --git a/lib/Alchemy/Phrasea/Media/Type/Audio.php b/lib/Alchemy/Phrasea/Media/Type/Audio.php index 21167aa5fa..825023793a 100644 --- a/lib/Alchemy/Phrasea/Media/Type/Audio.php +++ b/lib/Alchemy/Phrasea/Media/Type/Audio.php @@ -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 { diff --git a/lib/Alchemy/Phrasea/Media/Type/Document.php b/lib/Alchemy/Phrasea/Media/Type/Document.php index f699b29774..7aba7b88e8 100644 --- a/lib/Alchemy/Phrasea/Media/Type/Document.php +++ b/lib/Alchemy/Phrasea/Media/Type/Document.php @@ -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 { diff --git a/lib/Alchemy/Phrasea/Media/Type/Flash.php b/lib/Alchemy/Phrasea/Media/Type/Flash.php index ce7783e54c..1eb8f6afee 100644 --- a/lib/Alchemy/Phrasea/Media/Type/Flash.php +++ b/lib/Alchemy/Phrasea/Media/Type/Flash.php @@ -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 { diff --git a/lib/Alchemy/Phrasea/Media/Type/Image.php b/lib/Alchemy/Phrasea/Media/Type/Image.php index 89da35809c..3a9fd8f8cc 100644 --- a/lib/Alchemy/Phrasea/Media/Type/Image.php +++ b/lib/Alchemy/Phrasea/Media/Type/Image.php @@ -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 { diff --git a/lib/Alchemy/Phrasea/Media/Type/Type.php b/lib/Alchemy/Phrasea/Media/Type/Type.php index 6432d9ece2..32f2517152 100644 --- a/lib/Alchemy/Phrasea/Media/Type/Type.php +++ b/lib/Alchemy/Phrasea/Media/Type/Type.php @@ -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(); } diff --git a/lib/Alchemy/Phrasea/Media/Type/Video.php b/lib/Alchemy/Phrasea/Media/Type/Video.php index 944f40303c..fa85a554b2 100644 --- a/lib/Alchemy/Phrasea/Media/Type/Video.php +++ b/lib/Alchemy/Phrasea/Media/Type/Video.php @@ -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 { diff --git a/lib/classes/API/OAuth2/Application/Navigator.class.php b/lib/classes/API/OAuth2/Application/Navigator.class.php index 4b2dc3fcec..934761511f 100644 --- a/lib/classes/API/OAuth2/Application/Navigator.class.php +++ b/lib/classes/API/OAuth2/Application/Navigator.class.php @@ -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 */ diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php index f28173ec11..a69f1e7e81 100644 --- a/lib/classes/API/V1/adapter.class.php +++ b/lib/classes/API/V1/adapter.class.php @@ -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; diff --git a/lib/classes/Session/Storage/PHPSession.class.php b/lib/classes/Session/Storage/PHPSession.class.php index ee977845fa..a96e98285e 100644 --- a/lib/classes/Session/Storage/PHPSession.class.php +++ b/lib/classes/Session/Storage/PHPSession.class.php @@ -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; diff --git a/lib/classes/databox/subdef.class.php b/lib/classes/databox/subdef.class.php index c70acdf3cd..39b017c371 100644 --- a/lib/classes/databox/subdef.class.php +++ b/lib/classes/databox/subdef.class.php @@ -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 + * @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; + } } diff --git a/lib/classes/databox/subdefsStructure.class.php b/lib/classes/databox/subdefsStructure.class.php index 9c41d82819..604aefa0d9 100644 --- a/lib/classes/databox/subdefsStructure.class.php +++ b/lib/classes/databox/subdefsStructure.class.php @@ -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) { - $child = $dom_struct->createElement($option); - $child->appendChild($dom_struct->createTextNode($value)); - $subdef->appendChild($child); + + 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(); diff --git a/lib/classes/mail.class.php b/lib/classes/mail.class.php index cf76db1df1..c7a488343a 100644 --- a/lib/classes/mail.class.php +++ b/lib/classes/mail.class.php @@ -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 } - $mail->Send(); + if ($Core->getConfiguration()->getEnvironnement() !== 'test') { + $mail->Send(); + } return true; } catch (phpmailerException $e) { diff --git a/lib/classes/media/subdef.class.php b/lib/classes/media/subdef.class.php index 073dc3f041..aa3d6501db 100644 --- a/lib/classes/media/subdef.class.php +++ b/lib/classes/media/subdef.class.php @@ -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; - } - $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; + if (file_exists($this->path . $this->file)) { + $this->is_physically_present = 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() . "/" diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index 1190ff80a7..adbc9c296f 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -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,13 +1628,11 @@ 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(); + $this->get_subdef($subdefname)->remove_file(); - if ( ! is_file($pathdest) && is_writeable($pathdest)) { - unlink($pathdest); - - $this->clearSubdefCache($subdefname); - } + $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) { } } diff --git a/lib/classes/set/export.class.php b/lib/classes/set/export.class.php index 4ae5082a33..a6fa3ccf5e 100644 --- a/lib/classes/set/export.class.php +++ b/lib/classes/set/export.class.php @@ -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') diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index 495d15f815..67f8a7baac 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -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', diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index 604e19086a..e8ff3efbe8 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -6973,6 +6973,16 @@ + + etag + char(32) + YES + + + + + + dispatched tinyint(1) unsigned diff --git a/templates/web/admin/subdefs.twig b/templates/web/admin/subdefs.twig index f1d436de5f..b8b87941b6 100644 --- a/templates/web/admin/subdefs.twig +++ b/templates/web/admin/subdefs.twig @@ -283,7 +283,7 @@ {% set varname = subdefgroup~'_'~subdefname~'_'~subdefType.getType()~'['~ option.getName() ~']' %} - {{option.getName()}} + {{option.getDisplayName()}} {% set extradata = '' %} @@ -304,7 +304,7 @@ {% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_ENUM') %} {% trans 'yes' %} {% trans 'no' %} - {% else %} - + {% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_MULTI') %} + + {% for pot_value, selected in option.Value(true) %} + + {% endfor %} + + {% endif %} diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index cbf7090790..7e8d3a9461 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -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 %} diff --git a/tests/Alchemy/Phrasea/Application/ApiJsonTest.php b/tests/Alchemy/Phrasea/Application/ApiJsonTest.php index b8ac926dac..80bfdc71db 100644 --- a/tests/Alchemy/Phrasea/Application/ApiJsonTest.php +++ b/tests/Alchemy/Phrasea/Application/ApiJsonTest.php @@ -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) diff --git a/tests/Alchemy/Phrasea/Application/ApiYamlTest.php b/tests/Alchemy/Phrasea/Application/ApiYamlTest.php index 9fcaa0d2e5..d668f5f1f9 100644 --- a/tests/Alchemy/Phrasea/Application/ApiYamlTest.php +++ b/tests/Alchemy/Phrasea/Application/ApiYamlTest.php @@ -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) diff --git a/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php b/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php index e8acea54a4..734222f5b3 100644 --- a/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php +++ b/tests/Alchemy/Phrasea/Controller/Admin/SubdefsTest.php @@ -100,6 +100,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract , 'quality' => 90 )) ); + $this->assertTrue($this->client->getResponse()->isRedirect()); $subdef = $subdefs->get_subdef("image", "name"); diff --git a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php index b2830edc66..b2c436e71d 100644 --- a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php +++ b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/BooleanTest.php @@ -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()); + } + } diff --git a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php index b8932650d8..81328912a7 100644 --- a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php +++ b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/EnumTest.php @@ -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()); + } + } diff --git a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php index e27d40e650..45b37f772b 100644 --- a/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php +++ b/tests/Alchemy/Phrasea/Media/Subdef/OptionType/RangeTest.php @@ -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()); + } + } diff --git a/tests/Alchemy/Phrasea/Media/Type/AudioTest.php b/tests/Alchemy/Phrasea/Media/Type/AudioTest.php index c639d6bae3..74382f63b3 100644 --- a/tests/Alchemy/Phrasea/Media/Type/AudioTest.php +++ b/tests/Alchemy/Phrasea/Media/Type/AudioTest.php @@ -13,5 +13,4 @@ class AudioTest extends \PHPUnit_Framework_TestCase $object = new Audio; $this->assertEquals(Type::TYPE_AUDIO, $object->getType()); } - } diff --git a/tests/Alchemy/Phrasea/Media/Type/DocumentTest.php b/tests/Alchemy/Phrasea/Media/Type/DocumentTest.php index 7efa0a082c..8325ad29df 100644 --- a/tests/Alchemy/Phrasea/Media/Type/DocumentTest.php +++ b/tests/Alchemy/Phrasea/Media/Type/DocumentTest.php @@ -13,5 +13,4 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $object = new Document(); $this->assertEquals(Type::TYPE_DOCUMENT, $object->getType()); } - } diff --git a/tests/Alchemy/Phrasea/Media/Type/FlashTest.php b/tests/Alchemy/Phrasea/Media/Type/FlashTest.php index 78cab30e62..ff55633d65 100644 --- a/tests/Alchemy/Phrasea/Media/Type/FlashTest.php +++ b/tests/Alchemy/Phrasea/Media/Type/FlashTest.php @@ -13,5 +13,4 @@ class FlashTest extends \PHPUnit_Framework_TestCase $object = new Flash(); $this->assertEquals(Type::TYPE_FLASH, $object->getType()); } - } diff --git a/tests/Alchemy/Phrasea/Media/Type/ImageTest.php b/tests/Alchemy/Phrasea/Media/Type/ImageTest.php index ff73a763bf..acfa231e76 100644 --- a/tests/Alchemy/Phrasea/Media/Type/ImageTest.php +++ b/tests/Alchemy/Phrasea/Media/Type/ImageTest.php @@ -13,5 +13,4 @@ class ImageTest extends \PHPUnit_Framework_TestCase $object = new Image(); $this->assertEquals(Type::TYPE_IMAGE, $object->getType()); } - } diff --git a/tests/Alchemy/Phrasea/Media/Type/VideoTest.php b/tests/Alchemy/Phrasea/Media/Type/VideoTest.php index c20a275624..d10a0c2c7f 100644 --- a/tests/Alchemy/Phrasea/Media/Type/VideoTest.php +++ b/tests/Alchemy/Phrasea/Media/Type/VideoTest.php @@ -13,5 +13,4 @@ class VideoTest extends \PHPUnit_Framework_TestCase $object = new Video(); $this->assertEquals(Type::TYPE_VIDEO, $object->getType()); } - } diff --git a/www/client/index.php b/www/client/index.php index d136558cf8..27a4339dd9 100644 --- a/www/client/index.php +++ b/www/client/index.php @@ -664,15 +664,6 @@ if ($baskStatus == '0') { }); get('GV_bitly_user')) !== '' && trim($registry->get('GV_bitly_key')) !== '') { - $request = new http_request(); - ?> - - - -get('GV_googleAnalytics')) != '') { ?>