diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 1a69732348539bdab03319d0f450b8b3358aa020..079fb2e000c6ca176022f32620dea433c9050fdd 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -479,4 +479,29 @@ class NoticeAjaxController extends ZendAfi_Controller_Action { ? $this->_forward('resnumeriques') : $this->_forward('exemplaires'); } + + + public function trailerAction() { + session_write_close(); + + $args = ['titre' => $this->notice->getRecordTitle(), + 'auteur' => $this->notice->getAuteurPrincipal(), + 'clef_oeuvre' => $this->notice->getClefOeuvre(), + 'type_doc' => $this->notice->getFamilleId()]; + + if ( !$data = Class_WebService_AllServices::runServiceAfi(6, $args)) + return $this->_sendResponse(''); + + if ( !isset($data['player']) || (!$html = $data['player'])) + return $this->_sendResponse(''); + + $source = isset($data['source']) ? $data['source'] : $this->_('source inconnue'); + + preg_match('/src="([^"]+)"/', $html, $match); + + if ( !$url = $match[1]) + return $this->_sendResponse(''); + + $this->_sendResponseWithScripts($this->view->renderEmbed($data['source'], $url)); + } } \ No newline at end of file diff --git a/application/modules/opac/controllers/RecordController.php b/application/modules/opac/controllers/RecordController.php index 7a5de41d8280c170ac5f2e7606bd759a3a2f78ce..42b8b105e9b9919974f6fe0743fb0f7bbf4161df 100644 --- a/application/modules/opac/controllers/RecordController.php +++ b/application/modules/opac/controllers/RecordController.php @@ -21,7 +21,19 @@ class RecordController extends ZendAfi_Controller_Action { - public function resumeAction() { - $this->view->record = Class_Notice::find($this->_getParam('id')); + + public function preDispatch() { + parent::preDispatch(); + + if (!$this->view->record = Class_Notice::find($this->_getParam('id'))) { + $this->_helper->notify($this->_('Impossible d\'afficher les donnés. Le document est introuvable')); + $this->_redirectToIndex(); + } } + + + public function resumeAction() {} + + + public function mediaAction() {} } diff --git a/application/modules/opac/views/scripts/record/media.phtml b/application/modules/opac/views/scripts/record/media.phtml new file mode 100644 index 0000000000000000000000000000000000000000..f486a8327fc8e3d01da407ccfdb41a586ea5714e --- /dev/null +++ b/application/modules/opac/views/scripts/record/media.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->RenderRecord_Media($this->record); diff --git a/library/templates/Intonation/View/RenderEmbed.php b/library/templates/Intonation/View/RenderEmbed.php new file mode 100644 index 0000000000000000000000000000000000000000..1015341939934266bd2ee97f61a26ee14cb2f399 --- /dev/null +++ b/library/templates/Intonation/View/RenderEmbed.php @@ -0,0 +1,36 @@ +<?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_RenderEmbed extends ZendAfi_View_Helper_BaseHelper { + public function renderEmbed($source, $url) { + return + $this->_div(['class' => 'embed-responsive embed-responsive-16by9'], + $this->_tag('iframe', + '', + ['src' => $url, + 'allowfullscreen' => 1, + 'class' => 'embed-responsive-item'])) + . $this->_tag('p', + $source, + ['class' => 'blockquote-footer text-right']); + } +} diff --git a/library/templates/Intonation/View/RenderRecord.php b/library/templates/Intonation/View/RenderRecord.php index 6ae3e64875fb165c9292c47583ff40354e507e00..edacca6fbdb61eadf9a01d758ede59c26b864d5c 100644 --- a/library/templates/Intonation/View/RenderRecord.php +++ b/library/templates/Intonation/View/RenderRecord.php @@ -33,7 +33,7 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { ->setView($this->view) ->setModel($this->_record); - $this->view->titre = $this->_wrapped->getTitle(); + $this->view->titre = $this->_getTitle() . $this->_getSubtitle(); $html = [$this->_renderHead(), $this->_renderContent()]; @@ -42,13 +42,18 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { } + protected function _getTitle() { + return $this->_wrapped->getTitle(); + } + + + protected function _getSubtitle() { + return ''; + } + + protected function _renderContent() { - $html = [$this->_renderSummary(), - $this->_renderMedia(), - $this->_renderReviews(), - $this->_renderDetails(), - $this->_renderCollection(), - $this->_renderAuthor()]; + $html = $this->_getContentBlocs(); $html = $this->_div(['class' => 'col-md-10 col-xl-9'], implode($html)); @@ -56,6 +61,16 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { } + protected function _getContentBlocs() { + return [$this->_renderSummary(), + $this->_renderMedia(), + $this->_renderReviews(), + $this->_renderDetails(), + $this->_renderCollection(), + $this->_renderAuthor()]; + } + + protected function _renderSummary() { return $this->_renderBloc($this->_('Résumé'), $this->_record->getResume()); @@ -68,12 +83,20 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _renderMedia() { + $album = ($album = $this->_record->getAlbum() + ? $this->view->renderAlbum($album) + : ''); + + $trailer = $this->_renderAjaxBloc('trailer'); + + $html = $album + . $trailer + . $this->_renderAjaxBloc('morceaux') + . $this->_renderAjaxBloc('photos'); + return $this->_renderBloc($this->_('Médias'), - $this->_grid($this->_renderAjaxBloc('resnumeriques') - . $this->_renderAjaxBloc('bandeannonce') - . $this->_renderAjaxBloc('morceaux') - . $this->_renderAjaxBloc('photos'))); + $this->_grid($html)); } @@ -123,9 +146,9 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _renderHead() { $html = $this->_div(['class' => 'col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2'], $this->_recordThumbnail()) - . $this->_div(['class' => 'col-12 col-md-6 col-lg-7 col-xl-4'], $this->_recordMetaData()) + . $this->_div(['class' => 'col-12 col-md-6 col-lg-7 col-xl-4 ml-1'], $this->_recordMetaData()) . $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'], $this->_nav()); + . $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'], $this->_grid($html, @@ -209,7 +232,7 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { ['class' => 'img-thumbnail w-100', 'alt' => ($image ? $this->_('Couverture de %s', - $this->view->titre) + $this->_getTitle()) : $this->_('Aïe, aïe, aïe ! Pas d\'image pour "%s".', $this->_wrapped->getTitle()))]); } @@ -233,7 +256,7 @@ class Intonation_View_RenderRecord extends ZendAfi_View_Helper_BaseHelper { protected function _recordMetaData() { - $html = $this->_tag('h1', $this->view->titre); + $html = $this->_tag('h1', $this->_getTitle()); if ($author_link = $this->_wrapped->getSecondaryLink()) $html .= $this->view->tagAnchor($author_link->getUrl(), $author_link->getText(), diff --git a/library/templates/Intonation/View/RenderRecord/Media.php b/library/templates/Intonation/View/RenderRecord/Media.php new file mode 100644 index 0000000000000000000000000000000000000000..ed54ab3d99f2fe9dfc0477f67a79902b1e433a2d --- /dev/null +++ b/library/templates/Intonation/View/RenderRecord/Media.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright (c) 2012-2018, 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_RenderRecord_Media extends Intonation_View_RenderRecord { + public function RenderRecord_Media($record) { + return parent::renderRecord($record); + } + + + protected function _getSubtitle() { + return $this->_(' : Médias'); + } + + + protected function _getContentBlocs() { + return [$this->_renderMedia()]; + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderRecord/Resume.php b/library/templates/Intonation/View/RenderRecord/Resume.php index 339d3bd7d3a5dde3e3a02f55ca7e9fcfd5552f4a..fa9e643274f524ec13dfcf44ff364256ec51aed8 100644 --- a/library/templates/Intonation/View/RenderRecord/Resume.php +++ b/library/templates/Intonation/View/RenderRecord/Resume.php @@ -26,11 +26,12 @@ class Intonation_View_RenderRecord_Resume extends Intonation_View_RenderRecord { } - protected function _renderContent() { - $html = [$this->_renderSummary()]; + protected function _getSubtitle() { + return $this->_(' : Résumé'); + } - $html = $this->_div(['class' => 'col-md-10 col-xl-9'], implode($html)); - return $this->_grid($html, [], ['class' => 'justify-content-center']); + protected function _getContentBlocs() { + return [$this->_renderSummary()]; } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 13cf157a82f58ac9ad8fdc1d28a6f54ef80a646d..414c9f664d404cb618aad8441a186e8709b5ee60 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1829,7 +1829,6 @@ class TemplatesDispatchNoticeAjaxResourcesTest extends TemplatesIntonationTestCa - class TemplatesAddReviewTest extends TemplatesIntonationTestCase { protected $_review; @@ -2026,6 +2025,12 @@ class TemplatesRecordResumeDispatchTest extends TemplatesIntonationTestCase { } + /** @test */ + public function pageTitleShouldBePsychoResume() { + $this->assertXPathContentContains('//head//title', 'Psycho : Résumé'); + } + + /** @test */ public function navShouldBePresent() { $this->assertXPath('//body//nav[contains(@class, "navbar")][@role="navigation"]'); @@ -2060,4 +2065,69 @@ class TemplatesRecordResumeDispatchTest extends TemplatesIntonationTestCase { public function pageShouldBeAccessible() { $this->assertAccessible($this->_response->getBody()); } -} \ No newline at end of file +} + + + +class TemplatesRecordMediaDispatchTest extends TemplatesIntonationTestCase { + public function setUp() { + parent::setUp(); + + $record = $this->fixture('Class_Notice', + ['id' => 456, + 'titre_principal' => 'Psycho', + 'clef_oeuvre' => 'PSYKO', + 'facettes' => 'G13 M12']); + + $this->dispatch('/opac/record/media/id/456/id_profil/72'); + } + + + /** @test */ + public function shouldContainsPictures() { + $this->assertXPath('//div//img[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")]'); + } + + + /** @test */ + public function pageShouldBeHtml5Valid() { + $this->assertHTML5(); + } + + + /** @test */ + public function pageShouldBeAccessible() { + $this->assertAccessible($this->_response->getBody()); + } +} + + + +class TemplatesDispatchNoticeAjaxTrailerTest extends TemplatesIntonationTestCase { + /** @test */ + public function shouldDisplayTrailer() { + $this->fixture('Class_Notice', + ['id' => 34, + 'titre_principal' => 'Psycho', + ]); + + Class_CosmoVar::set('url_services', 'https://cache-server.org'); + + $mock = $this + ->mock() + ->whenCalled('open_url') + ->answers(json_encode(['source' => 'testing', + 'player' => '<iframe src="https://www.super-trailers.org/?media=18397590" style="width:500px; height:400px" frameborder="0"></iframe>'])); + + Class_WebService_AllServices::setHttpClient($mock); + + $this->dispatch('/noticeajax/trailer/id/34/id_profil/72'); + $this->assertXPath('//div[contains(@class, "embed-responsive")]//iframe[@src= "https://www.super-trailers.org/?media=18397590"][@class="embed-responsive-item"]', $this->_response->getBody()); + } +}