From e840b1d16ed52e91c58ac1c1997c10ee2935318c Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Thu, 2 Apr 2015 17:50:17 +0200 Subject: [PATCH] hotline #23465 fix bib url --- VERSIONS_HOTLINE/hotline_#23465_fix_bib_url | 1 + .../admin/controllers/AlbumController.php | 42 ++++++++-------- library/Class/Bib.php | 12 +++-- library/ZendAfi/Form/Album.php | 48 +++++++++---------- .../admin/controllers/AlbumControllerTest.php | 1 + .../opac/controllers/BibControllerTest.php | 2 +- 6 files changed, 56 insertions(+), 50 deletions(-) create mode 100644 VERSIONS_HOTLINE/hotline_#23465_fix_bib_url diff --git a/VERSIONS_HOTLINE/hotline_#23465_fix_bib_url b/VERSIONS_HOTLINE/hotline_#23465_fix_bib_url new file mode 100644 index 00000000000..89229041133 --- /dev/null +++ b/VERSIONS_HOTLINE/hotline_#23465_fix_bib_url @@ -0,0 +1 @@ + - ticket #23465 : Correction du lien pour accéder aux bibliothèques depuis le mode territoire \ No newline at end of file diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index 3f8765804ff..8e65f462258 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.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 Admin_AlbumController extends ZendAfi_Controller_Action { use Trait_Translator; protected $_baseUrlOptions = ['module' => 'admin', 'controller' => 'album']; - + public function init() { $this->view->titre = 'Collections'; @@ -64,7 +64,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $response[] = ['label' => $renderStrategy->render($item)]; echo json_encode($response); - exit; + exit; } @@ -73,7 +73,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $form = $this->_formImportEAD(); $this->view->form_import_ead = $form; - + if (!$this->_request->isPost()) return; @@ -83,13 +83,13 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $this->_helper->notify(sprintf('%d albums importés', count($ead->getAlbums()))); $this->_redirect('admin/album'); return; - } - + } + $this->_helper->notify('Le fichier reçu n\'est pas valide'); $this->_redirect('admin/album/importead'); } - + protected function _formImportEAD() { return $this->view ->newForm(['id' => 'import_ead', 'class' => 'form']) @@ -126,7 +126,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $categorie = Class_AlbumCategorie::newInstance() ->setParentCategorie($parent_categorie); - $titre = sprintf(((!$parent_categorie->hasParentCategorie()) + $titre = sprintf(((!$parent_categorie->hasParentCategorie()) ? 'Ajouter une catégorie à la collection "%s"' : 'Ajouter une sous-catégorie à la catégorie "%s"'), $parent_categorie->getLibelle()); @@ -177,7 +177,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $this->_redirect('admin/album'); return; } - + $this->_renderAlbumForm($album, 'Modifier l\'album "' . $album->getTitre() . '"'); } @@ -196,7 +196,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { } $form = $this->_thumbnailsForm($album); - if ($form && $this->_request->isPost() + if ($form && $this->_request->isPost() && $form->isValid($this->_request->getPost()) && ($album->updateAttributes($this->_request->getPost()) ->save())) { @@ -258,7 +258,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $this->view->errors = $ressource->getErrors(); } - + public function editressourceAction() { if (null === ($ressource = Class_AlbumRessource::getLoader() ->find($this->_getParam('id')))) { @@ -296,7 +296,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { protected function _setupRessourceFormAndSave($model) { $form = $this->_ressourceForm($model); - + $this->view->form = $form; if (!$this->_request->isPost() @@ -309,18 +309,18 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $form->addModelErrors($model); return false; } - + return $model->save() && $model->receiveFiles() && $model->getAlbum()->save() && $model->getAlbum()->index(); } - + public function sortressourcesAction() { $album = Class_Album::getLoader()->find((int)$this->_getParam('id')); $album->sortRessourceByFileName()->save(); - $this->_helper->notify('Médias réordonnés par nom de fichier'); + $this->_helper->notify('Médias réordonnés par nom de fichier'); $this->_redirect('admin/album/edit_images/id/'.$album->getId()); } @@ -424,7 +424,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { 'required' => true, 'allowEmpty' => false])) ->addDisplayGroup(['libelle'], 'categorie', - ['legend' => (($categorie->hasParentCategorie()) ? + ['legend' => (($categorie->hasParentCategorie()) ? 'Catégorie' : 'Collection')]) ->populate($categorie->toArray()); @@ -467,7 +467,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { * @return Zend_Form */ protected function _albumForm($album) { - $form = ZendAfi_Form_Album::newWith($album); + $form = ZendAfi_Form_Album::newWithAlbum($album); $form->addAttribs(['data-backurl' => $this->view->url(['action' => 'index', 'cat_id' => $album->getCatId()])]); return $form; @@ -513,7 +513,7 @@ 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()); - } + } } @@ -535,7 +535,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { */ protected function _renderAlbumForm($album, $titre) { $this->_validateAndSaveAlbum($album); - + $this->view->titre = $titre; $this->view->errors = $album->getErrors(); $this->view->album = $album; @@ -548,7 +548,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { protected function _getTreeViewContainerActions() { - $actions = Class_AdminVar::isBibNumEnabled() + $actions = Class_AdminVar::isBibNumEnabled() ? [['url' => $this->_getUrlForAction('add_categorie_to'), 'icon' => 'ico/add_cat.gif', 'label' => 'Ajouter une sous-catégorie'], @@ -559,7 +559,7 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { : []; - return array_merge($actions, + return array_merge($actions, [['url' => $this->_getUrlForAction('edit_categorie'), 'icon' => 'ico/edit.gif', 'label' => 'Modifier la catégorie'], diff --git a/library/Class/Bib.php b/library/Class/Bib.php index 91c7f391fda..aa0f0870f0d 100644 --- a/library/Class/Bib.php +++ b/library/Class/Bib.php @@ -261,10 +261,14 @@ class Class_Bib extends Storm_Model_Abstract { public function getUrl() { $props = $this->getAffZoneAsArray(); - $profil = Class_Profil::find($props["profilID"]); - $parts = $profil ? $profil->getUrlParts() : ['controller' => 'bib', - 'action' => 'bibview', - 'id' => $this->getId()]; + + $parts = ['controller' => 'bib', + 'action' => 'bibview', + 'id' => $this->getId()]; + + if($profil = Class_Profil::find($props["profilID"])) + $parts = array_merge( $parts, $profil->getUrlParts()); + return Class_Url::assemble($parts, null, true); } diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index c6d68562242..7b4b0cf5d63 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -16,13 +16,13 @@ * * 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_Form_Album extends ZendAfi_Form { const RIGHT_PUBLIC_DOMAIN = 'Domaine public'; - public static function newWith($album) { + public static function newWithAlbum($album) { $form = new self(); $form @@ -34,7 +34,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ->addVignetteFor($album) ->addFileFor($album) ->addAffichageFor($album) - ->addDisplayGroup(['titre', + ->addDisplayGroup(['titre', 'sous_titre', 'cat_id', 'type_doc_id', @@ -43,17 +43,17 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'pdf', 'authors', 'editors', - 'collections'], - 'album', + 'collections'], + 'album', ['legend' => $form->_('Album')]) ->addDisplayGroup(['description'], - 'album_desc', + 'album_desc', ['legend' => $form->_('Description')]) ->addDisplayGroup(['droits', 'droits_precision', - 'annee', + 'annee', 'cote', 'provenance', 'distributor', @@ -65,7 +65,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'dewey', 'genre', 'tags'], - 'album_metadata', + 'album_metadata', ['legend' => $form->_('Metadonnées')]) ->addDisplayGroup(['bibliotheques', @@ -125,12 +125,12 @@ class ZendAfi_Form_Album extends ZendAfi_Form { }') ->addJQueryReady('$("input[name=\'droits\']").change(toggleAlbumRights); toggleAlbumRights();'); - + $this ->setAttrib('id', 'album') ->setAttrib('enctype', self::ENCTYPE_MULTIPART) ->addElement('text', 'titre', ['label' => $this->_('Titre *'), - 'size' => 75, + 'size' => 75, 'required' => true, 'allowEmpty' => false]) @@ -144,30 +144,30 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ->addElement('ckeditor', 'description') - ->addElement('text', 'annee', ['label' => $this->_("Année d'édition"), - 'size' => 4, + ->addElement('text', 'annee', ['label' => $this->_("Année d'édition"), + 'size' => 4, 'maxlength' => 4]) - ->addElement('text', 'cote', ['label' => $this->_('Cote'), + ->addElement('text', 'cote', ['label' => $this->_('Cote'), 'size' => 20]) - ->addElement('text', 'provenance', ['label' => $this->_('Provenance'), + ->addElement('text', 'provenance', ['label' => $this->_('Provenance'), 'size' => 75]) - ->addElement('text', 'duration', ['label' => $this->_('Durée totale'), + ->addElement('text', 'duration', ['label' => $this->_('Durée totale'), 'size' => 8]) - ->addElement('select', 'id_langue', ['label' => $this->_('Langue'), + ->addElement('select', 'id_langue', ['label' => $this->_('Langue'), 'multioptions' => Class_CodifLangue::allByIdLibelle()]) - ->addElement('select', 'type_doc_id', ['label' => $this->_('Type de document'), + ->addElement('select', 'type_doc_id', ['label' => $this->_('Type de document'), 'multioptions' => Class_TypeDoc::allByIdLabelForAlbum()]) ->addElement('cochesSuggestion', 'nature_doc', ['label' => $this->_('Nature de document'), 'name' => 'nature_doc', 'rubrique' => 'nature_doc']) - ->addElement('text', 'distributor', ['label' => $this->_('Distributeur'), + ->addElement('text', 'distributor', ['label' => $this->_('Distributeur'), 'size' => 75]) @@ -191,7 +191,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form { ->addElement('textarea', 'tags', ['label' => $this->_('Tags'), 'rows' => 2]) - ->addElement('multiInput', 'authors', + ->addElement('multiInput', 'authors', ['label' => $this->_('Auteurs'), 'fields' => [['name' => 'author', 'label' => $this->_('Nom')], ['name' => 'fonction', 'label' => $this->_('Fonction'), @@ -199,13 +199,13 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 'values' => ['author' => [], 'fonction' => []], 'deleteMessage' => 'cet auteur']) - ->addElement('multiInput', 'editors', + ->addElement('multiInput', 'editors', ['label' => $this->_('Editeurs'), 'fields' => [['name' => 'editor', 'label' => $this->_('Nom')] ], 'values' => ['editor' => []], 'deleteMessage' => ' this editor']) - ->addElement('multiInput', 'collections', + ->addElement('multiInput', 'collections', ['label' => $this->_('Collections'), 'fields' => [['name' => 'collection', 'label' => $this->_('Nom')] ], 'values' => ['collection' => []], @@ -267,11 +267,11 @@ class ZendAfi_Form_Album extends ZendAfi_Form { 2 => 'Autre, Précisez']]) ->addElement('text', 'droits_precision', - ['label' => '', - 'value' => $current_precision, + ['label' => '', + 'value' => $current_precision, 'size' => 75]); } - + public function addAffichageFor($album) { return $this ->addElement('cochesSuggestion', 'bibliotheques', diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index e1d29575024..7d3eaf88f5c 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -948,6 +948,7 @@ class Admin_AlbumControllerEditAlbumMesBDTest extends Admin_AlbumControllerTestC ->addCollection('Ratm') ->setDistributor('Geffen Records') ->save(); + $this->dispatch('/admin/album/edit_album/id/43', true); } diff --git a/tests/application/modules/opac/controllers/BibControllerTest.php b/tests/application/modules/opac/controllers/BibControllerTest.php index cc9814c65bc..7de4eed68c7 100644 --- a/tests/application/modules/opac/controllers/BibControllerTest.php +++ b/tests/application/modules/opac/controllers/BibControllerTest.php @@ -236,7 +236,7 @@ class BibControllerMapViewTest extends BibControllerWithZoneTestCase { /** @test */ public function bibAnnecyShouldBeVisibleOnMap() { - $this->assertXPathContentContains("//span[contains(@onclick, '/id_profil/3')]", "Annecy"); + $this->assertXPathContentContains("//span[contains(@onclick, '/bibview/id/4/id_profil/3')]", "Annecy", $this->_response->getBody()); } } -- GitLab