diff --git a/VERSIONS_HOTLINE/36324 b/VERSIONS_HOTLINE/36324 new file mode 100644 index 0000000000000000000000000000000000000000..2420d01cb7bdaa2e6605e528fedd5125fb42a5a3 --- /dev/null +++ b/VERSIONS_HOTLINE/36324 @@ -0,0 +1 @@ + - ticket #36324 : Correction de l'afffichage des ressources numériques en mode téléphone diff --git a/application/modules/telephone/controllers/RechercheController.php b/application/modules/telephone/controllers/RechercheController.php index 02299af1e24c44386f6a5cd77ed6b16794e81007..778280c6d8116b62c2896bd40673ecc5a0023688 100644 --- a/application/modules/telephone/controllers/RechercheController.php +++ b/application/modules/telephone/controllers/RechercheController.php @@ -28,35 +28,50 @@ class Telephone_RechercheController extends RechercheController { } $actions = [$this->_('Description du document') => ['action' => 'detail'], - $this->_('Où le trouver ?') => ['action' => 'exemplaires'], - $this->_('Critiques') => ['action' => 'avis'], - $this->_('Résumé') => ['action' => 'resume'], - $this->_('Vidéos associées') => ['action' => 'videos'], - $this->_('Rebondir dans le catalogue') => ['action' => 'tags'], - $this->_('Biographie de l\'auteur') => ['action' => 'biographie'], - $this->_('Documents similaires') => ['action' => 'similaires'], - $this->_('Notices liées') => ['action' => 'frbr'] - ]; + $this->_('Où le trouver ?') => ['action' => 'exemplaires'], + $this->_('Critiques') => ['action' => 'avis'], + $this->_('Résumé') => ['action' => 'resume'], + $this->_('Vidéos associées') => ['action' => 'videos'], + $this->_('Rebondir dans le catalogue') => ['action' => 'tags'], + $this->_('Biographie de l\'auteur') => ['action' => 'biographie'], + $this->_('Documents similaires') => ['action' => 'similaires'], + $this->_('Notices liées') => ['action' => 'frbr']]; + + $actions = $this->getActionForTypeDoc($actions, $notice); + + $this->view->notice = $notice; + $this->view->actions = $actions; + } + + + protected function getActionForTypeDoc($actions, $notice) { + if(!$notice->isRessourceNumerique()) + return $actions; + + $action_array = ['action' => 'ressourcesnumeriques', + 'attribs' => ['data-ajax' => 'false']]; if ($notice->isLivreNumerique()|| $notice->isEpub()) { - $actions[$this->_('Feuilleter le livre')] = ['action' => 'ressourcesnumeriques', - 'attribs' => ['data-ajax' => 'false']]; - } + $actions[$this->_('Feuilleter le livre')] = $action_array; + return $actions; + } if ($notice->isArteVOD()) { - $actions[$this->_('Bande-annonce')] = ['action' => 'ressourcesnumeriques', - 'attribs' => ['data-ajax' => 'false']]; + $actions[$this->_('Bande-annonce')] = $action_array; + return $actions; } if ($notice->isAudioRecord()) { - $actions[$this->_('Ecouter l\'album')] = ['action' => 'ressourcesnumeriques', - 'attribs' => ['data-ajax' => 'false']]; - } + $actions[$this->_('Ecouter l\'album')] = $action_array; + return $actions; + } - $this->view->notice = $notice; - $this->view->actions = $actions; - } + if($notice->isToutApprendre()) { + $actions[$this->_('Cours ToutApprendre')] = $action_array; + } + return $actions; + } public function grandeimageAction() { @@ -85,7 +100,7 @@ class Telephone_RechercheController extends RechercheController { public function ressourcesnumeriquesAction() { - if (!$this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id'))) + if (!$this->view->notice = Class_Notice::find($this->_getParam('id'))) $this->_redirect('/'); } diff --git a/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml b/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml index 8237fd39f5694286b903a46439828a9c5c55187d..39359e51cc07e3e597ce1e979a4a91d1e783ef84 100644 --- a/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml +++ b/application/modules/telephone/views/scripts/recherche/ressourcesnumeriques.phtml @@ -1,9 +1,6 @@ -<?php -echo $this->toolbar($this->_("Livre numérisé"), - array('action' => 'simple')); - -echo '<h1>'.$this->notice->getTitrePrincipal().'</h1>'; - +<?php +echo $this->toolbar($this->_("Livre numérisé"), + ['action' => 'simple']); +echo $this->tag('h1', $this->notice->getTitrePrincipal()); echo $this->renderAlbum($this->notice->getAlbum()); - -?> \ No newline at end of file +?> diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 5d02c2cddab99bbfa09b4f484b1f07cd5657d632..409b66b4771694c664dab897813fcd0a25574061 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -478,6 +478,9 @@ class Class_Notice extends Storm_Model_Abstract { return ($this->getTypeDoc() == Class_TypeDoc::AUDIO_RECORD); } + public function isToutApprendre() { + return ($this->getTypeDoc() == Class_TypeDoc::TOUTAPPRENDRE); + } public function isSite() { return ($this->getTypeDoc() == Class_TypeDoc::SITE); diff --git a/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php b/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php index 6169d7616e7d5b5c89e2f145db5e241a2c566e89..3f5dbb272237e3844f84065524bc8514a2b13439 100644 --- a/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php +++ b/library/ZendAfi/View/Helper/Telephone/RenderAlbum.php @@ -16,14 +16,14 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Telephone_RenderAlbum extends ZendAfi_View_Helper_RenderAlbum { public function renderAlbum($album) { - return $album + return $album ? sprintf('<div id="resnum">%s</div>', $this->renderAlbumHelper($album)) - : ''; + : $this->view->_('Aucune ressource numérique trouvée.'); } @@ -48,6 +48,14 @@ class ZendAfi_View_Helper_Telephone_RenderAlbum extends ZendAfi_View_Helper_Rend if ($album->isAudioRecord()) return $this->view->tagAlbumTrackList($album); + if($album->isCoursToutApprendre()) { + Class_ScriptLoader::getInstance() + ->addAdminScript('onload_utils') + ->addJQueryReady('setupAnchorsTarget();'); + + return parent::renderAlbumHelper($album); + } + return $this->view->tagAlbumMediaList($album); } } diff --git a/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php b/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php index f05ee05a22698277a6cd58a294c3fe545385d31d..4acb8b472f81f064297280597df9e8886ea924f4 100644 --- a/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php +++ b/tests/application/modules/telephone/controllers/RechercheControllerRessourceNumeriqueTest.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'TelephoneAbstractControllerTestCase.php'; @@ -55,10 +55,10 @@ class Telephone_RechercheControllerPropagandaViewNoticeTest extends Telephone_Re $this->dispatch('/telephone/recherche/viewnotice/id/9', true); } - + /** @test */ public function pageShouldContainsLinkToRessouresNumeriquesEpub() { - $this->assertNotXPathContentContains('//a[contains(@href, "ressourcesnumeriques/id/9")][@data-ajax="false"]', + $this->assertNotXPathContentContains('//a[contains(@href, "ressourcesnumeriques/id/9")][@data-ajax="false"]', 'Feuilleter le livre',$this->_response->getBody()); } @@ -66,8 +66,40 @@ class Telephone_RechercheControllerPropagandaViewNoticeTest extends Telephone_Re +class Telephone_RechercheControllerNumericRessourcesTest extends TelephoneAbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + $this->fixture('Class_Album', + ['id' => 1, + 'titre' => 'smalltalk', + 'type_doc_id' => Class_TypeDoc::TOUTAPPRENDRE]); + + $item = $this->fixture('Class_Exemplaire', + ['id' => 16, + 'id_notice' => 15, + 'id_origine' => 1]); + + $record = $this->fixture('Class_Notice', + ['id' => 15, + 'type_doc' => Class_TypeDoc::TOUTAPPRENDRE]); + + $record->setTitrePrincipal('SmallTalk') + ->setExemplaire($item); + + $this->dispatch('/recherche/ressourcesnumeriques/id/15', true); + } - + /** @test */ + public function onloadUtilShouldBeLoaded() { + $this->assertXPath('//script[contains(@src, "/public/admin/js/onload_utils.js")]'); + } -?> \ No newline at end of file + + /** @test */ + public function wrongAccountRequirementMessageShouldBeDisplay() { + $this->assertXPathContentContains('//div//p', 'Vous devez être connecté sous un compte avec abonnement valide pour pouvoir accéder au cours en ligne'); + } +} \ No newline at end of file