diff --git a/VERSIONS_HOTLINE/130660 b/VERSIONS_HOTLINE/130660 new file mode 100644 index 0000000000000000000000000000000000000000..212c7a39a5b7913d501b1e4dc2e1836b1b521787 --- /dev/null +++ b/VERSIONS_HOTLINE/130660 @@ -0,0 +1 @@ + - correctif #130660 : OPAC : Ajout d'un bouton de suppression de bande annonce \ No newline at end of file diff --git a/library/Class/Notice/Urls.php b/library/Class/Notice/Urls.php index f43a1664ad2f33189f2d39a4060f6ac3daa818d8..460713d05b71d3c44e2947f5778e0614afe06d39 100644 --- a/library/Class/Notice/Urls.php +++ b/library/Class/Notice/Urls.php @@ -132,7 +132,8 @@ class Class_Notice_Urls { if (!$url = $link->getUrl()) return; - if (strpos($url, $this->_url_site) === false) + if ($this->_url_site + && (strpos($url, (string) $this->_url_site) === false)) $link->setTarget('_blank'); } diff --git a/library/ZendAfi/View/Helper/Trailer.php b/library/ZendAfi/View/Helper/Trailer.php index bdc062767d64d0df4466cc6b4d09b14e2ec677ec..a3dbb588b8f7c5e0689e01563a213614fac2676f 100644 --- a/library/ZendAfi/View/Helper/Trailer.php +++ b/library/ZendAfi/View/Helper/Trailer.php @@ -35,15 +35,10 @@ class ZendAfi_View_Helper_Trailer extends ZendAfi_View_Helper_BaseHelper { protected function _renderTrailer($notice, $width) { - return - $this->_renderEditLink($notice) - . - $this->_renderPlayer($notice, $width); - } + $notice_id = $notice->getId(); - - protected function _renderPlayer($notice, $width) { $height = (int)($width * 4/5); + $args= ['titre' => $notice->getRecordTitle(), 'auteur' => $notice->getAuteurPrincipal(), 'clef_oeuvre' => $notice->getClefOeuvre(), @@ -52,7 +47,33 @@ class ZendAfi_View_Helper_Trailer extends ZendAfi_View_Helper_BaseHelper { 'height' => $height]; $data = Class_WebService_AllServices::runServiceAfiTrailers($args); - $player=$data['player']; + + if (isset($data['disable_trailer']) && $data['disable_trailer']) + return $this->_renderDisabledTrailer($notice_id); + + return + $this->_renderEditLink($notice_id) + . + $this->_renderPlayer($data); + } + + protected function _renderDisabledTrailer($notice_id){ + $enable_url = $this->view->url(['module' => 'admin', + 'controller' => 'records', + 'action' => 'enable-trailer', + 'id' => $notice_id]); + return $this->view->tag('p', $this->_('La bande annonce est désactivée pour cette notice')) + .$this->view + ->Admin_Button((new Class_Button) + ->setText($this->_('Activer la bande-annonce')) + ->setUrl($enable_url) + ->setImage(Class_Admin_Skin::current() + ->renderButtonIconOn('validate', $this->view))); + } + + + protected function _renderPlayer($data) { + $player = $data['player']; preg_match('/src="([^"]+)"/', $player, $match); if ( $match && ($url = $match[1])) @@ -63,19 +84,30 @@ class ZendAfi_View_Helper_Trailer extends ZendAfi_View_Helper_BaseHelper { } - protected function _renderEditLink($notice) { + protected function _renderEditLink($notice_id) { if (!Class_Users::isCurrentUserCanAccesBackend()) return ''; - $url = $this->view->url(['module' => 'admin', - 'controller' => 'records', - 'action' => 'trailer', - 'id' => $notice->getId()]); + $edit_url = $this->view->url(['module' => 'admin', + 'controller' => 'records', + 'action' => 'trailer', + 'id' => $notice_id]); + + $disable_url = $this->view->url(['module' => 'admin', + 'controller' => 'records', + 'action' => 'disable-trailer', + 'id' => $notice_id]); return $this->view + ->Admin_Button((new Class_Button) + ->setText($this->_('Désactiver la bande-annonce')) + ->setUrl($disable_url) + ->setImage(Class_Admin_Skin::current() + ->renderButtonIconOn('delete', $this->view))). + $this->view ->Admin_Button((new Class_Button) ->setText($this->_('Modifier la bande-annonce')) - ->setUrl($url) + ->setUrl($edit_url) ->setAttrib('data-popup', 'true') ->setImage(Class_Admin_Skin::current() ->renderButtonIconOn('configuration', $this->view))); diff --git a/tests/application/modules/admin/controllers/RecordsControllerTest.php b/tests/application/modules/admin/controllers/RecordsControllerTest.php index b877d32cf868ad7c4cc756dba74b323e8a67ae60..0a608457e29b938a7efdf22d791249ee0e9e726e 100644 --- a/tests/application/modules/admin/controllers/RecordsControllerTest.php +++ b/tests/application/modules/admin/controllers/RecordsControllerTest.php @@ -55,7 +55,7 @@ abstract class RecordsControllerTestCase extends Admin_AbstractControllerTestCas ['id' => 345, 'libelle' => 'J.K.Rowling']); - Class_CosmoVar::set('url_services', 'http://cache.org'); + Class_CosmoVar::setValueOf('url_services', 'http://cache.org'); Class_WebService_Afi::setHttpClient($this->_http_client = $this->mock()); Class_WebService_Afi::setKey('SuperKey'); diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerPelliculeTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerPelliculeTest.php index bca8f8953857aef24f5b22d77ac1407f5da32cb6..b0c8b1ad7b66dcf7f1939bdb269eb09d7ad2e480 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerPelliculeTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerPelliculeTest.php @@ -27,7 +27,7 @@ class NoticeAjaxControllerPelliculeActiveTest extends AbstractControllerTestCase public function setUp() { parent::setUp(); - Class_CosmoVar::set('url_services', 'http://cache.org'); + Class_CosmoVar::setValueOf('url_services', 'http://cache.org'); Class_AdminVar::set('PELLICULE_SETTINGS', json_encode(['Provider' => [Class_AdminVar_PelliculeSettings::ELECTRE_REST_2], 'Login' => ['mylogin'], diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 1784365ecc593444016747d900f41fa1c7eaf6c8..aaf7a29faef803e781122e5e742a432895767dbb 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -474,8 +474,23 @@ class NoticeAjaxControllerBandeAnnonceTest extends AbstractControllerTestCase { public function responseShouldContainsSourceTitle() { $this->dispatch('/noticeajax/bandeannonce/id/2'); $this->assertXPathContentContains('//h3', - 'Source : Testing', - $this->_response->getBody()); + 'Source : Testing'); + } + + + /** @test */ + public function responseShouldContainsButtonModifierLaBandeAnnonce() { + $this->dispatch('/noticeajax/bandeannonce/id/2'); + $this->assertXPathContentContains('//button', + 'Modifier la bande-annonce'); + } + + + /** @test */ + public function responseShouldContainsButtonDesactiverLaBandeAnnonce() { + $this->dispatch('/noticeajax/bandeannonce/id/2'); + $this->assertXPathContentContains('//button', + utf8_encode('Désactiver la bande-annonce')); } @@ -536,6 +551,46 @@ class NoticeAjaxControllerBandeAnnonceTest extends AbstractControllerTestCase { + +class NoticeAjaxControllerBandeAnnonceDesactiveeTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + Class_CosmoVar::setValueOf('url_services', 'https://websvc.net/main.php'); + Class_WebService_Afi::setHttpClient($this->mock() + ->whenCalled('open_url') + ->answers(json_encode(['source' => 'Testing', + 'player' => 'toto', + 'disable_trailer' => 1 + ]))); + + $this->fixture(Class_Notice::class, + ['id' => 2, + 'unimarc' => file_get_contents(ROOT_PATH . 'tests/fixtures/dvd_potter.uni'), + 'clef_oeuvre' => 'POTTER', + 'type_doc' => Class_TypeDoc::DVD]); + } + + + /** @test */ + public function responseShouldContainsBandeAnnonceDesactivee() { + $this->dispatch('/noticeajax/bandeannonce/id/2'); + $this->assertXPathContentContains('//p',utf8_encode('La bande annonce est désactivée')); + } + + + /** @test */ + public function responseShouldContainsButtonActiverLaBandeAnnonce() { + $this->dispatch('/noticeajax/bandeannonce/id/2'); + $this->assertXPathContentContains('//button', + 'Activer la bande-annonce'); + } +} + + + + abstract class NoticeAjaxControllerLastFmTestCase extends AbstractControllerTestCase {