diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index 7ff6ece6ffd312c8279e19a052dba088348d642d..8252f78ec84e2ea7f4c4b43d547f0137279fc645 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -205,16 +205,20 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { } + public function linkalbumtoAction() { + $this->_renderAlbumForm(Class_Album::newInstance(), + 'Ajouter un album'); + } + + public function addalbumtoAction() { - if (!$categorie = Class_AlbumCategorie::find((int)$this->_getParam('id'))) { - $this->_redirect('admin/album'); - return; - } + $categorie = ''; + $title = 'Ajouter un album'; + if ($categorie = Class_AlbumCategorie::find((int)$this->_getParam('id'))) + $title .= ' dans la collection "' . $categorie->getLibelle() . '"'; $this->_renderAlbumForm( - Class_Album::newInstance()->setCategorie($categorie), - 'Ajouter un album dans la collection "' . $categorie->getLibelle() . '"' - ); + Class_Album::newInstance()->setCategorie($categorie), $title); } @@ -558,14 +562,16 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { if ($album->save() && $album->receiveFile() - && $album->receivePDF() - && $album->index()) { + && $album->receivePDF()) { + + $album->index(); $frbr_links = []; foreach(Class_FRBR_Link::findAllRecordLinksForAlbum($album) as $link) $frbr_links[md5($link->getSource().$link->getTarget())] = $link; - $absoluteUrl = $this->view->absoluteUrl($album->getPermalink()); + $absoluteUrl = $this->view->absoluteUrl(array_merge(['id' => $album->getId()], + $album->getPermalink()), null, true); $received_links = []; $urls = $frbr_multi['frbr_url']; @@ -596,8 +602,11 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { (new Storm_Cache())->clean(); $this->_helper->notify('Album sauvegardé'); - $this->_redirect('admin/album/edit_album/id/' . $album->getId()); + + $this->_redirectClose('admin/album/edit_album/id/' . $album->getId()); + return true; } + return false; } @@ -618,7 +627,8 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { * @param string $titre */ protected function _renderAlbumForm($album, $titre) { - $this->_validateAndSaveAlbum($album); + if ($this->_validateAndSaveAlbum($album)) + return; $this->view->titre = $titre; $this->view->errors = $album->getErrors(); @@ -627,7 +637,28 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { ->setValue($album->getFichier()); $this->view->form->getElement('pdf') ->setValue($album->getPdf()); - $this->render('album_form'); + + if ($this->isPopupRequest()) + $this->_prepareAlbumAjaxFrom(); + + $this->getHelper('ViewRenderer')->setScriptAction('album_form'); + } + + protected function _prepareAlbumAjaxFrom() { + $id_notice = $this->_getParam('id_notice') + ? $this->_getParam('id_notice') + : ''; + + $this->view->form->beSimple() + ->setAction($this->view->url(['action' => 'link_album_to', + 'id_notice' => $id_notice])) + ->setEnctype('application/x-www-form-urlencoded'); + + if (!$this->_request->isPost()) { + $notice = Class_Notice::find($id_notice); + $this->view->form->populateFrbrUrl( + $this->view->absoluteUrl($this->view->urlNotice($notice, [], null, true), null, true)); + } } diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 15e7b8b6ae36a84640f5ce30a3c019bfa0375bae..54b7bbb29789e4937e99193dc3c2b526c61e1d04 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -298,6 +298,17 @@ class NoticeAjaxController extends Zend_Controller_Action { public function resnumeriquesAction() { $html = ''; + $add_album_tag = ''; + if (1 == Class_AdminVar::isBibNumEnabled() && Class_Users::isCurrentUserAdmin()) + $add_album_tag = $this->view->tagAnchor($this->view->url(['module' => 'admin', + 'controller' => 'album', + 'action' => 'link_album_to', + 'id_notice' => $this->id_notice], + null, true), + $this->_('Créer un album'), + ['class' => 'link_album', + 'data-popup' => 'true']); + if (null !== $exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => $this->id_notice])) $html .= $this->view->renderAlbum($exemplaire->getAlbum()); @@ -306,6 +317,7 @@ class NoticeAjaxController extends Zend_Controller_Action { if ('' == $html) $html = sprintf('<p>%s</p>', $this->view->_('Aucune ressource correspondante')); + $html = $add_album_tag . $html; $this->_sendResponse($html . Class_ScriptLoader::getInstance()->html()); } diff --git a/application/modules/opac/views/scripts/recherche/viewnotice.phtml b/application/modules/opac/views/scripts/recherche/viewnotice.phtml index 847c2f9b5f0ebbd68d40cd6a4cc975d624999b46..48fd740d8ad7696a0386536c3fbdd2b110000ec6 100644 --- a/application/modules/opac/views/scripts/recherche/viewnotice.phtml +++ b/application/modules/opac/views/scripts/recherche/viewnotice.phtml @@ -4,6 +4,7 @@ $this->openBoite($this->title); $script_loader = Class_ScriptLoader::getInstance() ->addStyleSheet(URL_ADMIN_JS.'slimbox/slimbox2') ->addAdminScript('slimbox/slimbox2.min.js') + ->addAdminScript('multi_inputs/multi_inputs.js') ->addStyleSheet(URL_ADMIN_JS.'rating/jquery.rating') ->addAdminScript('rating/jquery.rating.pack') diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 4edb762d08bafc03f21449f10d2114321b8b3760..9ef8c95c150f306507ccb8f55882e30e656965b1 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -2,7 +2,7 @@ // Constantes error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","235"); +define("PATCH_LEVEL","236"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); diff --git a/cosmogramme/sql/patch/patch_236.php b/cosmogramme/sql/patch/patch_236.php new file mode 100644 index 0000000000000000000000000000000000000000..4d4aceb1c359bb091adca4d86496d9f8a896b53c --- /dev/null +++ b/cosmogramme/sql/patch/patch_236.php @@ -0,0 +1,8 @@ +<?php + +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); +$adapter->query("ALTER TABLE album MODIFY genre varchar(100) NULL default ''"); +$adapter->query("ALTER TABLE album MODIFY matiere varchar(100) NULL default ''"); +$adapter->query("ALTER TABLE album MODIFY nature_doc varchar(50) NULL default ''"); +$adapter->query("ALTER TABLE album MODIFY dewey varchar(100) NULL default ''"); +$adapter->query("ALTER TABLE album MODIFY tags text NULL default ''"); diff --git a/library/Class/Album.php b/library/Class/Album.php index ff692082ff7c29739ea7a24e7a4a093ff7e9b98f..2589abce9b8dfedc85d454a0d5f17306a6657fde 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -650,6 +650,9 @@ class Class_Album extends Storm_Model_Abstract { protected function _isFileInRequest($name) { + if (!array_key_exists($name, $_FILES)) + return false; + return (0 !== $_FILES[$name]['size']); } diff --git a/library/Class/Onglet.php b/library/Class/Onglet.php index 02a2a4934ad82cff56c06d746286d97a7cf50511..3d4e1ac9b973c729f6d5d8236524f5f660bfdc83 100644 --- a/library/Class/Onglet.php +++ b/library/Class/Onglet.php @@ -91,6 +91,9 @@ class Class_Onglet { function checkIfHasRessourcesNumeriques($notice) { + if (1 == Class_AdminVar::isBibNumEnabled() && Class_Users::isCurrentUserAdmin()) + return true; + return (null !== ($exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => $notice->getId()])) && null !== $exemplaire->getAlbum()) || 0 < Class_FRBR_Link::countAlbumsFromNotice($notice); diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index 0c13dcfe1e4ee3bc989c03dfd4e198dccaf5077d..7fba0c42652a56d204b6151796375003634aa617 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -24,7 +24,13 @@ class ZendAfi_Form_Album extends ZendAfi_Form { const RIGHT_OTHER_KEY = 2; const RIGHT_PUBLIC_DOMAIN = 'Domaine public'; - public static function newWith($album = [], $custom_form = null) { + protected $_simple_elements = ['titre', + 'cat_id', + 'type_doc_id', + 'visible', + 'frbr_multi']; + + public static function newWith($album) { $form = new self(); $form @@ -133,7 +139,8 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'style' => 'width:440px;']) ->addElement('select', 'cat_id', ['label' => $this->_('Catégorie'), - 'multiOptions' => Class_AlbumCategorie::getAllLibelles()]) + 'multiOptions' => ['' => $this->_('Choisissez une catégorie')] + + Class_AlbumCategorie::getAllLibelles()]) ->addElement('checkbox', 'visible', ['label' => $this->_('Visible')]) @@ -338,6 +345,31 @@ class ZendAfi_Form_Album extends ZendAfi_Form { public function getPublicDomain() { return self::RIGHT_PUBLIC_DOMAIN; } + + public function populateFrbrUrl($url) { + $values = ['frbr_type' => [], 'frbr_url' => [$url]]; + $this->frbr_multi + ->setValues($values); + } + + public function beSimple() { + $this->_removeNotSimpleElements(); + $this->_removeEmptyGroups(); + + return $this; + } + + protected function _removeNotSimpleElements() { + foreach ($this->getElements() as $element) + if (!in_array($element->getName(), $this->_simple_elements)) + $this->removeElement($element->getName()); + } + + protected function _removeEmptyGroups() { + foreach ($this->getDisplayGroups() as $group) + if (!count($group->getElements())) + $this->removeDisplayGroup($group->getName()); + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/RenderAlbum.php b/library/ZendAfi/View/Helper/RenderAlbum.php index 94f484667edc6c889fd5ed2c28481a82ee17e245..fe7a2459c2026bbcfb2448b1a1ef925088177c02 100644 --- a/library/ZendAfi/View/Helper/RenderAlbum.php +++ b/library/ZendAfi/View/Helper/RenderAlbum.php @@ -21,9 +21,14 @@ class ZendAfi_View_Helper_RenderAlbum extends Zend_View_Helper_HtmlElement { public function renderAlbum($album) { - return $album - ? sprintf('<div id="resnum">%s</div>', $this->renderAlbumHelper($album)) - : ''; + if (!$album) + return ''; + + $actions = '<div class="actions">' + . $this->view->tagEditAlbumMedia($album) + . $this->view->tagEditAlbum($album) + . '</div>'; + return $actions . sprintf('<div id="resnum">%s</div>', $this->renderAlbumHelper($album)); } diff --git a/library/ZendAfi/View/Helper/TagEditAlbum.php b/library/ZendAfi/View/Helper/TagEditAlbum.php new file mode 100644 index 0000000000000000000000000000000000000000..be33cf54295a45e73eced326d77df9465a19c385 --- /dev/null +++ b/library/ZendAfi/View/Helper/TagEditAlbum.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright (c) 2012, 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 ZendAfi_View_Helper_TagEditAlbum extends Zend_View_Helper_HtmlElement { + /** + * @param Class_Album $album + * @return string + */ + public function tagEditAlbum($album) { + if (!Class_Users::isCurrentUserAdmin()) + return ''; + + return $this->view->tagAnchor($this->view->url(['module' => 'admin', + 'controller' => 'album', + 'action' => 'edit_album', + 'id' => $album->getId()]), + $this->view->tagImg(URL_ADMIN_IMG.'ico/edit.gif', + ['class' => 'album_edit', + 'alt' => $this->view->translate("Modifier l'album"), + 'title' => $this->view->translate("Modifier l'album")]), + ['class' => 'edit_album']); + } +} +?> diff --git a/library/ZendAfi/View/Helper/TagEditAlbumMedia.php b/library/ZendAfi/View/Helper/TagEditAlbumMedia.php new file mode 100644 index 0000000000000000000000000000000000000000..290aa3a6b3cdf9ce787ce30713f98e6eb99ba8ee --- /dev/null +++ b/library/ZendAfi/View/Helper/TagEditAlbumMedia.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright (c) 2012, 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 ZendAfi_View_Helper_TagEditAlbumMedia extends Zend_View_Helper_HtmlElement { + /** + * @param Class_Album $album + * @return string + */ + public function tagEditAlbumMedia($album) { + if (!Class_Users::isCurrentUserAdmin()) + return ''; + + return $this->view->tagAnchor($this->view->url(['module' => 'admin', + 'controller' => 'album', + 'action' => 'edit_images', + 'id' => $album->getId()]), + $this->view->tagImg(URL_ADMIN_IMG.'ico/album_images.png', + ['class' => 'media_album_edit', + 'alt' => $this->view->translate("Gérer les médias"), + 'title' => $this->view->translate("Gérer les médias")]) . $album->formatedCount(), + ['class' => 'edit_images']); + } +} +?> diff --git a/library/ZendAfi/View/Helper/UrlNotice.php b/library/ZendAfi/View/Helper/UrlNotice.php index e8efef75305387c2129407d4f1bc1d776ffae1c7..c4d98b6406a877d87d41869a348d45fa8162c868 100644 --- a/library/ZendAfi/View/Helper/UrlNotice.php +++ b/library/ZendAfi/View/Helper/UrlNotice.php @@ -23,10 +23,10 @@ class ZendAfi_View_Helper_UrlNotice extends Zend_View_Helper_HtmlElement { /** * @param mixed $notice array or Class_Notice */ - public function urlNotice($notice, $preferences=[]) { + public function urlNotice($notice, $preferences=[], $name = null, $reset = false) { if (!$notice) return $this->view->url(['controller'=>'recherche', - 'action' => 'simple']); + 'action' => 'simple'], $name, $reset); if (is_array($notice)) $notice = Class_Notice::find($notice['id_notice']); @@ -79,7 +79,7 @@ class ZendAfi_View_Helper_UrlNotice extends Zend_View_Helper_HtmlElement { 'id_module' => null])); } - return $this->view->url(array_filter($options)); + return $this->view->url(array_filter($options), $name, $reset); } diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 18e385023957b4aba9fdea59513219a21ff8390a..2bf319356e93430e0e6d6a7d0fb728d0667f19cd 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -767,6 +767,15 @@ ul.view-raw-rss li { left: 0px; } +.edit_album { + float: right; +} + +.edit_images { + float: right; + margin-left: 10px; +} + .titre div.rss { float: right; diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index 524616ca31ac5cd8bd86d69b02b1f9e9daae5809..03234d1e6ea772889979e1dc7d28a04422d1578f 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -710,6 +710,53 @@ class Admin_AlbumControllerAddAlbumToPatrimoineTest extends Admin_AlbumControlle + +class Admin_AlbumControllerAddAlbumFromFrontEnd extends Admin_AlbumControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/album/add_album_to/id/0'); + } + + + /** @test */ + public function actionShouldNotBeRedirected() { + $this->assertNotRedirect('/admin/album'); + } + + + /** @test */ + public function titleShouldBeAjouterUnAlbum() { + $this->assertXPathContentRegex('//h1', "/^Ajouter un album$/"); + } + + + /** @test */ + public function fieldCatIdShouldBeEmpty() { + $this->assertXPath('//form[@id="album"]//select[@name="cat_id"]/option[1][@value=""]'); + } + +} + + + +class Admin_AlbumControllerPostAlbumIronMaidenWithoutCategory extends Admin_AlbumControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->postDispatch('/admin/album/add_album_to/id/0', + ['titre' => 'Iron Maiden', + 'sous_titre' => 'The Number of the Beast']); + } + + + /** @test */ + public function errorMessageShouldBePresent() { + $this->assertXPathContentContains('//ul[@class="errors"]/li', 'Une valeur est requise'); + } +} + + + abstract class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTestCase extends Admin_AlbumControllerTestCase { public function setUp() { parent::setUp(); @@ -832,6 +879,7 @@ class Admin_AlbumControllerPostAlbumRenaissanceToPatrimoineTest $this->postDispatch('/admin/album/add_album_to/id/38', ['titre' => 'Renaissance', 'sous_titre' => 'Ze Renaissance', + 'cat_id' => 38, 'description' => 'Oeuvres majeures sous François 1er', 'nature_doc' => '2;3', 'type_doc_id' => '102', @@ -1129,6 +1177,7 @@ class Admin_AlbumControllerEditAlbumMesBDPostFrbrDeleteTest extends Admin_AlbumC $this->postDispatch('/admin/album/edit_album/id/43', ['titre' => 'Renaissance', 'sous_titre' => 'Ze Renaissance', + 'cat_id' => 2, 'description' => 'Oeuvres majeures sous François 1er', 'nature_doc' => '2;3', 'type_doc_id' => '102', @@ -1176,6 +1225,7 @@ class Admin_AlbumControllerEditAlbumMesBDPostFrbrModifyTest extends Admin_AlbumC $this->postDispatch('/admin/album/edit_album/id/43', ['titre' => 'Renaissance', 'sous_titre' => 'Ze Renaissance', + 'cat_id' => 2, 'description' => 'Oeuvres majeures sous François 1er', 'nature_doc' => '2;3', 'type_doc_id' => '102', @@ -1290,13 +1340,13 @@ class Admin_AlbumControllerEditAlbumMesBDTest extends Admin_AlbumControllerEditA /** @test */ public function formShouldHaveAComboToSelectCategorie() { - $this->assertXPathContentContains("//form//select[@name='cat_id']/option[1][@value=2]", 'Favoris'); + $this->assertXPathContentContains("//form//select[@name='cat_id']/option[2][@value=2]", 'Favoris'); } /** @test */ public function comboCategoriesShouldDisplayFullPath() { - $this->assertXPathContentContains("//form//select[@name='cat_id']/option[2][@value=6]", 'Favoris>Adulte'); + $this->assertXPathContentContains("//form//select[@name='cat_id']/option[3][@value=6]", 'Favoris>Adulte'); } @@ -1563,6 +1613,7 @@ class Admin_AlbumControllerPostEditAlbumMesBDTest extends Admin_AlbumControllerT Storm_Cache::setDefaultZendCache($this->cache_mock); $this->postDispatch('/admin/album/edit_album/id/43', ['titre' => 'Mes BD', + 'cat_id' => 2, 'description' => "Les préférées de l'année", 'tags' => 'selection', 'type_doc_id' => 201, @@ -2798,4 +2849,110 @@ class AlbumControllerMultiMediasExportEAD extends ControllerAlbumMultiMediasTest } } + + + + +class Admin_AlbumControllerAddAlbumToAjaxTest extends Admin_AlbumControllerTestCase { + protected + $_json, + $_xpath; + + public function setUp() { + parent::setUp(); + + $this->dispatch('/admin/album/link_album_to/id_notice/8/render/popup', true); + $this->_json = json_decode($this->_response->getBody()); + $this->_xpath = new Storm_Test_XPath(); + } + + + /** @test */ + public function titleElementShouldBePresent() { + $this->_xpath->assertXPath($this->_json->content, '//input[@type="text"][@name="titre"]'); + } + + + /** @test */ + public function categoryElementShouldBePresent() { + $this->_xpath->assertXPath($this->_json->content, '//select[@name="cat_id"]/option[1][@label="Choisissez une catégorie"]'); + } + + + /** @test */ + public function docTypeElementShouldBePresent() { + $this->_xpath->assertXPath($this->_json->content, '//select[@name="type_doc_id"]'); + } + + + /** @test */ + public function frbrLinkTypeElementShouldBePresent() { + $this->_xpath->assertXPath($this->_json->content, '//script', + '{"name":"frbr_type","label":"Type de lien","attribs":{"style":"width:180px;"},"type":"select","options":{"":"Aucun","2:source":"Diaporama - Est le diaporama de","2:target":"Diaporama - A pour diaporama","1:source":"Ebook - A pour ebook","1:target":"Ebook - Est l\'ebook de"}}'); + + } + + + /** @test */ + public function frbrRecordLinkElementShouldContainRecordPermalink() { + $this->_xpath->assertXPath($this->_json->content, '//script', '"frbr_url":["'.str_replace('/', '\/', ROOT_URL.BASE_URL).'\/recherche\/viewnotice\/clef\/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1\/id\/8"'); + } +} + + + + +class Admin_AlbumControllerAddAlbumToAjaxPostTest extends Admin_AlbumControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->postDispatch('/admin/album/link_album_to/id_notice/8/render/popup', + ['titre' => 'Before The Flood', + 'cat_id' => 2, + 'visible' => '1', + 'type_doc_id' => 100, + 'frbr_type' => ['1:source'], + 'frbr_url' => [ROOT_URL.BASE_URL.'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true); + } + + + /** @test */ + public function newAlbumTitleShouldBeBeforeTheFlood() { + $this->assertEquals('Before The Flood', Class_Album::findFirstBy(['order'=>'id desc'])->getTitre()); + } + + + /** @test */ + public function shouldHaveCreatedFrbrLinkForBeforeTheFlood() { + $this->assertNotNull(Class_FRBR_Link::findFirstBy(['target' => ROOT_URL.BASE_URL.'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8'])); + } +} + + + + +class Admin_AlbumControllerAddAlbumToAjaxPostNoVisibleTest extends Admin_AlbumControllerTestCase { + public function setUp() { + parent::setUp(); + + $this->postDispatch('/admin/album/link_album_to/id_notice/8/render/popup', + ['titre' => 'Dark', + 'visible' => '0', + 'type_doc_id' => 100, + 'frbr_type' => ['1:source'], + 'frbr_url' => [ROOT_URL.BASE_URL.'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true); + } + + + /** @test */ + public function darkAlbumShouldBeSaved() { + $this->assertNotNull(Class_Album::findFirstBy(['titre' => 'Dark'])); + } + + + /** @test */ + public function shouldHaveCreatedFrbrLinkForDark() { + $this->assertNotNull(Class_FRBR_Link::findFirstBy(['target' => ROOT_URL.BASE_URL.'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8'])); + } +} ?> diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 4c50518dc858150a67f2464adb693b2fc97f3bf8..7522db7584b31b4e45d53b04204d5cb98907b6c3 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -369,6 +369,19 @@ class NoticeAjaxControllerResNumeriquesFromFrbrLinkTest extends AbstractControll public function frbrLinkedAlbumTitleShouldBeDisplayed() { $this->assertXPathContentContains('//h3', 'Aces High'); } + + + /** @test */ + public function linkedAlbumShouldBeEditable() { + $this->assertXPath('//a[@class="edit_album"][contains(@href, "/admin/album/edit_album/id/42")]/img[contains(@src, "ico/edit.gif")]', $this->_response->getBody()); + } + + + /** @test */ + public function addAlbumLinkShouldBeDisplayed() { + $this->assertXPathContentRegex('//a[@class="link_album"][@data-popup="true"][contains(@href, "/admin/album/link_album_to/id_notice/123")]', '/Cr(.*)er un album/'); + } + } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 65c4b303787a9c71ba33437e2fea54c775c46289..bc9d6872225a45abd9a4b8a364ccd4bf62d651a5 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -636,12 +636,12 @@ class RechercheControllerUploadVignetteTest extends RechercheControllerNoticeTes - class RechercheControllerViewNoticeAsAdminTest extends RechercheControllerNoticeTestCase { public function setUp() { parent::setUp(); $this->notice->setTypeDoc(5); Class_Users::getIdentity()->beAdminPortail(); + $this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true); } @@ -663,6 +663,94 @@ class RechercheControllerViewNoticeAsAdminTest extends RechercheControllerNotice $this->assertHTML5(); } } +class RechercheControllerViewNoticeAndResnumeriqueTabAsAdminTest extends RechercheControllerNoticeTestCase { + public function setUp() { + parent::setUp(); + Class_Users::getIdentity()->beAdminPortail(); + + $preferences = ['barre_nav' => 'Document', + 'entete' =>"ABCDEFGIKLMNOPRSTtYZ8v9", + 'onglets' => ['detail' => ['titre' => 'Details', + 'aff' => '1', + 'ordre' => 1, + 'largeur' => 10], + 'avis' => ['titre' => 'avis', + 'aff' => '1', + 'ordre' => 2, + 'largeur' => 10], + 'exemplaires' => ['titre' => 'exemplaires', + 'aff' => '2', + 'ordre' => 3, + 'largeur' => 10], + 'resume' => ['titre' => 'resume', + 'aff' => '2', + 'ordre' => 4, + 'largeur' => 10], + 'tags' => ['titre' => 'tags', + 'aff' => '2', + 'ordre' => 5, + 'largeur' => 10], + 'biographie' => ['titre' => 'biographie', + 'aff' => '2', + 'ordre' => 6, + 'largeur' => 10], + 'similaires' => ['titre' => 'similaires', + 'aff' => '2', + 'ordre' => 7, + 'largeur' => 10], + 'bibliographie' => ['titre' => 'bibliographie', + 'aff' => '3', + 'ordre' => 7, + 'largeur' => 10], + 'morceaux' => ['titre' => 'morceaux', + 'aff' => '3', + 'ordre' => 8, + 'largeur' => 10], + 'bandeAnnonce' => ['titre' => 'bande annonce', + 'aff' => '3', + 'ordre' => 9, + 'largeur' => 10], + 'photos' => ['titre' => 'photos', + 'aff' => '3', + 'ordre' => 14, + 'largeur' => 10], + 'videos' => ['titre' => 'videos', + 'aff' => '3', + 'ordre' => 11, + 'largeur' => 10], + 'resnumeriques' => ['titre' => 'ressources n', + 'aff' => '2', + 'ordre' => 12, + 'largeur' => 10], + 'babeltheque' => ['titre' => 'babeltheque', + 'aff' => '3', + 'ordre' => 13, + 'largeur' => 10], + 'frbr' => ['titre' => 'frbr', + 'aff' => '0', + 'ordre' => 10, + 'largeur' => 10], + 'serie' => ['titre' => 'serie', + 'aff' => '0', + 'ordre' => 11, + 'largeur' => 10]], + 'boite' => null]; + + Class_Profil::beVolatile(); + $this->fixture('Class_Profil', ['id' => 1, + 'libelle' => 'Afibre']) + ->setBarreNavOn(true) + ->setCfgModules(['recherche' => ['viewnotice1' => $preferences]]) + ->beCurrentProfil(); + $this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true); + } + + + /** @test */ + public function resnumeriquesBlocShouldBePresent() { + $this->assertXPathContentContains('//div[@class="resnumeriques block_info_notice"]//h2', 'ressources n'); + } +}