diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 079fb2e000c6ca176022f32620dea433c9050fdd..414146e64979a77e164764a1add7ca16a034cb1d 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -306,6 +306,7 @@ class NoticeAjaxController extends ZendAfi_Controller_Action { $this->_sendResponseWithScripts($html); } + public function videomorceauAction() { if($this->service_afi > "") { $width = $this->_getParam('width', 500); diff --git a/library/Class/NoticeUnimarc.php b/library/Class/NoticeUnimarc.php index 91eddde21929950f8450d1824a6be57dc85a5599..ef078897615d279c61b51fc29408215267309c73 100644 --- a/library/Class/NoticeUnimarc.php +++ b/library/Class/NoticeUnimarc.php @@ -190,6 +190,21 @@ class Class_NoticeUnimarc { } + public function get_field($zone) { + $instance = new Class_NoticeUnimarc_Field; + + $bloc = substr($zone, 3); + $fields = explode($this->subfield_begin, $bloc); + + foreach($fields as $field) { + $set = 'set' . substr($field, 0, 1); + $instance->$set(substr($field, 1)); + } + + return $instance; + } + + public function decoupe_bloc_champ_thesaurus($bloc) { $bloc=substr($bloc,3); diff --git a/library/Class/NoticeUnimarc/Field.php b/library/Class/NoticeUnimarc/Field.php new file mode 100644 index 0000000000000000000000000000000000000000..21c2e4f23c35e9f78bb17dfe74ea67636c4f5b73 --- /dev/null +++ b/library/Class/NoticeUnimarc/Field.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_NoticeUnimarc_Field extends Class_Entity {} diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index eb3313b1bcbd7e9621c53686bee7a3585ae14207..68414f04b8138ac6510a3820dc6e2e49e92b1720 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -395,5 +395,5 @@ label[for=note] ~ div label.multi-element-label + br { } .jumbotron .nav-link { - font-size: 2em; + font-size: 1.5em; } \ No newline at end of file diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 34b92f4b109a76a0f129275f1bd80540469a0588..96c32d92788c8cace42176aac1fc6ce18eba61c1 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -143,6 +143,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'tag' => 'class fas fa-tag', 'star' => 'class fas fa-star', 'star-empty' => 'class far fa-star', + 'track' => 'class fas fa-music', ] ]; diff --git a/library/templates/Intonation/Library/Track.php b/library/templates/Intonation/Library/Track.php new file mode 100644 index 0000000000000000000000000000000000000000..19e5f3832970cec3772bae80d6dd250ad7fb7e60 --- /dev/null +++ b/library/templates/Intonation/Library/Track.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_Track extends Class_Entity { +} diff --git a/library/templates/Intonation/Library/Tracks.php b/library/templates/Intonation/Library/Tracks.php new file mode 100644 index 0000000000000000000000000000000000000000..ae5835b115d0d61d5f6442e922127eea3a59f0e8 --- /dev/null +++ b/library/templates/Intonation/Library/Tracks.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_Library_Tracks { + + protected $_model; + + + public function setModel($model) { + $this->_model = $model; + return $this; + } + + + public function collection() { + return new Storm_Collection($this->tracks()); + } + + + public function tracks() { + if (!$this->_model->isTypeDocSonore()) + return []; + + if ($this->_model->isGam()) + return (new Intonation_Library_TracksGam) + ->setModel($this->_model) + ->getTracks(); + + return (new Intonation_Library_TracksBase) + ->setModel($this->_model) + ->getTracks(); + } +} + + + +abstract class Intonation_Library_TracksAbstract { + + protected $_model; + + + public function setModel($model) { + $this->_model = $model; + return $this; + } + + + abstract public function getTracks(); + abstract protected function _trackFromUnimarc($unimarc, $tracks); +} + + + +class Intonation_Library_TracksBase extends Intonation_Library_TracksAbstract { + public function getTracks() { + $tracks = []; + $unimarc = $this->_model->get_subfield('464'); + + foreach ($unimarc as $unimarc_track) + $tracks = $this->_trackFromUnimarc($unimarc_track, $tracks); + + return $tracks; + } + + + protected function _trackFromUnimarc($unimarc, $tracks) { + $field = $this->_model->get_field($unimarc); + $tracks [] = new Intonation_Library_Track(['Title' => $field->gett(), + 'Duration' => $field->getd(), + 'Author' => implode(' ', [$field->geta(), + $field->getb()]), + 'Volume' => $field->getv(), + 'Url' => $field->get3()]); + return $tracks; + } +} + + + +class Intonation_Library_TracksGam extends Intonation_Library_TracksAbstract { + public function getTracks() { + $tracks = []; + $unimarc = $this->_model->get_subfield('856'); + + foreach ($unimarc as $unimarc_track) + $tracks = $this->_trackFromUnimarc($unimarc_track, $tracks); + + return $tracks; + } + + + protected function _trackFromUnimarc($unimarc, $tracks) { + $field = $this->_model->get_field($unimarc); + $tracks [] = new Intonation_Library_Track(['Title' => $field->getz(), + 'Url' => $field->getu()]); + return $tracks; + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord.php b/library/templates/Intonation/View/RenderRecord.php index edacca6fbdb61eadf9a01d758ede59c26b864d5c..242798ad0375ac59f6a084cfd28e9b37f76020e9 100644 --- a/library/templates/Intonation/View/RenderRecord.php +++ b/library/templates/Intonation/View/RenderRecord.php @@ -88,10 +88,13 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { : ''); $trailer = $this->_renderAjaxBloc('trailer'); + $tracks = (new Intonation_Library_Tracks) + ->setModel($this->_record) + ->collection(); $html = $album . $trailer - . $this->_renderAjaxBloc('morceaux') + . $this->view->renderTracks($tracks) . $this->_renderAjaxBloc('photos'); return @@ -150,7 +153,7 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { . $this->_div(['class' => 'mh-100 no-gutters col-12 col-md-10 col-xl-3'], $this->_recordItems()) . $this->_div(['class' => 'col-12 col-md-10 col-xl-9 mt-3'], $this->_nav()); - return $this->_div(['class' => 'jumbotron jumbotron-fluid w-100 no_overflow'], + return $this->_div(['class' => 'jumbotron jumbotron-fluid w-100 no_overflwo'], $this->_grid($html, [], ['class' => 'justify-content-center'])); diff --git a/library/templates/Intonation/View/RenderTracks.php b/library/templates/Intonation/View/RenderTracks.php new file mode 100644 index 0000000000000000000000000000000000000000..ff8dbaceadff158e644b8e1de4d6ffc53a655b29 --- /dev/null +++ b/library/templates/Intonation/View/RenderTracks.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_View_RenderTracks extends ZendAfi_View_Helper_BaseHelper { + public function renderTracks($tracks) { + if ($tracks->isEmpty()) + return ''; + + $html = []; + + /* foreach ($tracks as $track) */ + /* if ( ($title = $track->getTitle()) && ($url = $track->getUrl())) */ + /* $html [] = $this->_tag('track' */ + + /* return $this->view->grid(implode($html)); */ + + foreach ($tracks as $track) + if ( ($title = $track->getTitle()) && ($url = $track->getUrl())) + $html [] = $this->_div(['class' => 'col-lg-5 mb-3'], + $this->_div(['class' => 'card bg-info text-white shadow'], + $this->_div(['class' => 'card-body'], + $this->_div(['class' => 'card-title'], + $this->_tag('h3', + Class_Template::current()->getIco($this->view, + 'track', + 'utils') + . $track->getTitle())) + . $this->_tag('audio', + '', + ['class' => 'd-block', + 'src' => $url, + 'preload' => 'auto', + 'onplaying' => "$('audio').not($(this)).trigger('pause');", + 'controls' => 'true'])))); + + return $this->view->grid(implode($html), [], ['class' => 'justify-content-between']); + } +} diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 414c9f664d404cb618aad8441a186e8709b5ee60..4613002ce587d995357c5ca4f2f9ae64825b56da 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -2073,9 +2073,24 @@ class TemplatesRecordMediaDispatchTest extends TemplatesIntonationTestCase { public function setUp() { parent::setUp(); + $this->fixture('Class_TypeDoc', + ['id' => 8, + 'label' => 'mp3', + 'famille_id' => Class_CodifTypeDoc::SONORE + ]); + + $unimarc = (new Class_NoticeUnimarc_Fluent) + ->zoneWithContent('001', '12345') + ->zoneWithChildren('464', ['t' => 'Lotus out of water', + '3' => 'https://my-super-sound/1.mp3']) + ->zoneWithChildren('464', ['t' => 'Milking song', + '3' => 'https://my-super-sound/2.mp3']); + $record = $this->fixture('Class_Notice', ['id' => 456, 'titre_principal' => 'Psycho', + 'unimarc' => $unimarc->render(), + 'type_doc' => 8, 'clef_oeuvre' => 'PSYKO', 'facettes' => 'G13 M12']); @@ -2089,6 +2104,12 @@ class TemplatesRecordMediaDispatchTest extends TemplatesIntonationTestCase { } + /** @test */ + public function shouldContainsTracks() { + $this->assertXPath('//div//track[contains(@href, "big_picture_300x300.jpg")]'); + } + + /** @test */ public function navLinkToRecordResumeShoulBeActive() { $this->assertXPath('//ul[contains(@class, "nav-tabs")]//li/a[contains(@href, "record/media")][contains(@class, "active")]'); @@ -2131,3 +2152,42 @@ class TemplatesDispatchNoticeAjaxTrailerTest extends TemplatesIntonationTestCase $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]', $this->_response->getBody()); } } + + + +class TemplatesGamRecordMediaDispatchTest extends TemplatesIntonationTestCase { + public function setUp() { + parent::setUp(); + + $this->fixture('Class_TypeDoc', + ['id' => 8, + 'label' => 'mp3', + 'famille_id' => Class_CodifTypeDoc::SONORE + ]); + + $unimarc = (new Class_NoticeUnimarc_Fluent) + ->zoneWithContent('001', '12345') + ->zoneWithChildren('801', ['b' => 'GAM']) + ->zoneWithChildren('464', ['t' => 'Lotus out of water']) + ->zoneWithChildren('856', ['u' => 'https://my-super-sound/1.mp3', + 'z' => 'Lotus out of water']) + ->zoneWithChildren('464', ['t' => 'Milking song', + '3' => 'https://my-super-sound/2.mp3']); + + $record = $this->fixture('Class_Notice', + ['id' => 456, + 'titre_principal' => 'Psycho', + 'unimarc' => $unimarc->render(), + 'type_doc' => 8, + 'clef_oeuvre' => 'PSYKO', + 'facettes' => 'G13 M12']); + + $this->dispatch('/opac/record/media/id/456/id_profil/72'); + } + + + /** @test */ + public function shouldGamTracks() { + $this->assertXPath('//div//track'); + } +} \ No newline at end of file