diff --git a/application/modules/admin/controllers/ModulesController.php b/application/modules/admin/controllers/ModulesController.php index a59120c493ff7eb58f8fee7ba97fec825a880e20..926b6b555aee9bb63c50c6e32e7ec498710256ae 100644 --- a/application/modules/admin/controllers/ModulesController.php +++ b/application/modules/admin/controllers/ModulesController.php @@ -189,6 +189,9 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { if ('resultat' == $this->_getParam('action1')) return $this->_forward('search-result'); + if('viewnotice' == $this->_getParam('action1')) + return $this->_forward('record'); + if ($this->isValidPostNotice()) return $this->updateEtRetour($this->getPostNotice()); @@ -208,6 +211,8 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { protected function isValidPostNotice() { + $this->preferences['links_zones_errors'] = ''; + $this->preferences['thumbnail_fields_errors'] = ''; if (!$this->_request->isPost() || 'viewnotice' != $this->_getParam('action1')) return false; @@ -242,7 +247,7 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { $datas[2]); } - $this->view->links_errors = $link_errors; + $this->preferences['links_zones_errors'] = $this->view->links_errors = $link_errors; $this->preferences['thumbnail_fields'] = $this->processZones('thumbnail'); $lines = explode(';', $this->preferences['thumbnail_fields']); @@ -271,7 +276,7 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { $datas[1]); } - $this->view->thumbs_errors = $thumb_errors; + $this->preferences['thumbnail_fields_errors'] = $this->view->thumbs_errors = $thumb_errors; return empty($link_errors) && empty($thumb_errors) ; } @@ -296,6 +301,20 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { } + public function recordAction() { + $codif = Class_Codification::getInstance(); + $this->view->titre = $this->_('Configuration de l\'affichage du type %s', + $codif->getLibelleFacette('T' . $this->_getParam('action2'))); + + if ($this->isValidPostNotice()) + return $this->updateEtRetour($this->getPostNotice()); + + $params = array_merge($this->preferences, $this->getPostNotice()); + $this->view->form = ZendAfi_Form_Configuration_Record::newWith($params); + $this->view->form->setAction($this->view->url()); + } + + public function noticeajaxAction() { $this->view->type_doc = $this->action2; $this->noticeConsolidationOnglets(); @@ -334,6 +353,7 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { protected function getPostNotice() { + $enreg = []; foreach($this->_request->getPost() as $clef => $valeur) { if (false === ($pos = strpos($clef, '_'))) { $enreg[$clef] = $valeur; @@ -415,11 +435,10 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { [$this->_getParam('type_module')] [$this->_getParam('action1') . $this->_getParam('action2')] = $enreg; - $this->profil - ->setCfgModules($cfg_modules) - ->save(); - $this->view->reload = 'SITE'; - $this->render->renderScript('modules/_retour.phtml'); + if($this->profil->setCfgModules($cfg_modules)->save()) + $this->_helper->notify($this->_('La configuration a été enregistrée')); + + $this->_redirectClose(Class_Url::absolute()); } diff --git a/application/modules/admin/views/scripts/modules/record.phtml b/application/modules/admin/views/scripts/modules/record.phtml new file mode 100644 index 0000000000000000000000000000000000000000..fb242e29dad1e1f4f12bec7faf7da998bfac22d7 --- /dev/null +++ b/application/modules/admin/views/scripts/modules/record.phtml @@ -0,0 +1,3 @@ +<?php +echo $this->renderForm($this->form); +?> diff --git a/library/ZendAfi/Form/Configuration/Record.php b/library/ZendAfi/Form/Configuration/Record.php new file mode 100644 index 0000000000000000000000000000000000000000..0a8cf85effcfe79506616a11e73f5c5995f9a0e1 --- /dev/null +++ b/library/ZendAfi/Form/Configuration/Record.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright (c) 2012-2017, 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_Form_Configuration_Record extends ZendAfi_Form { + + public function init() { + parent::init(); + $this + ->addElement('recordTabs', + 'record_tabs', + ['label' => $this->_('Composition de l\'affichage')]) + ->addElement('codeList', + 'champs', + ['label' => $this->_('Champs à afficher'), + 'field' => 'champs', + 'values' => '', + 'required' => true, + 'validators' => [['name' => 'notEmpty', + 'value' => false, + 'options' => [ 'messages' => $this->_('Indiquez au moins 1 champ à afficher pour la liste')]]]]) + + ->addElement('unimarc', + 'links_zones', + ['label' => $this->_('Zones de liens')]) + + ->addElement('unimarc', + 'thumbnail_fields', + ['label' => $this->_('Zones de vignette'), + 'validators' => [['name' => 'unimarc']]]) + + ->addElement('text', + 'analytics', + ['label' => $this->_('Zone de dépouillements')]) + ->addElement('text', + 'analytics_title', + ['label' => $this->_('Sous-zone de titre')]) + ->addElement('text', + 'analytics_authors', + ['label' => $this->_('Sous-zones d\'auteurs<br>(séparées par des ";")')]) + + ->addElement('select', + 'boite', + ['label' => $this->_('Style de la boite'), + 'multiOptions' => (new Class_Profil_Templates(Class_Profil::getCurrentProfil()))->toArray()]) + + ; + } + + + public function populate($datas) { + $this->getElement('record_tabs') + ->setSettings($datas['onglets']); + + $this->getElement('champs') + ->setValues($datas['entete']); + + $this->getElement('links_zones') + ->setSettings($datas) + ->setMessages($datas['links_zones_errors']); + + $this->getElement('thumbnail_fields') + ->setSettings($datas) + ->setMessages($datas['thumbnail_fields_errors']); + + $this + ->addDisplayGroup(['champs'], + 'head_group', + ['legend' => $this->_('Entête')]) + ->addDisplayGroup(['record_tabs'], + 'record_display_group', + ['legend' => $this->_('Affichage')]) + ->addDisplayGroup(['links_zones'], + 'unimarc_link_zones', + ['legend' => $this->_('Zones de liens')]) + ->addDisplayGroup(['thumbnail_fields'], + 'unimarc_thumbnails_zones', + ['legend' => $this->_('Zones de vignette')]) + ->addDisplayGroup(['analytics', + 'analytics_title', + 'analytics_authors'], + 'unimarc_zone_group', + ['legend' => $this->_('Dépouillements')]) + ->addToStyleGroup(['boite']); + return parent::populate($datas); + } +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Decorator/RecordTabs.php b/library/ZendAfi/Form/Decorator/RecordTabs.php new file mode 100644 index 0000000000000000000000000000000000000000..6bb9bb4aec3fbc76fe03a701b6b059c20069a1df --- /dev/null +++ b/library/ZendAfi/Form/Decorator/RecordTabs.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright (c) 2012-2017, 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_Form_Decorator_RecordTabs extends Zend_Form_Decorator_Abstract { + /** + * @param string $content + * @return string + */ + public function render($content) { + return $this->_element->getView()->recordTabs($this->_element->getSettings()); + } +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Decorator/Unimarc.php b/library/ZendAfi/Form/Decorator/Unimarc.php new file mode 100644 index 0000000000000000000000000000000000000000..43f9815f26a5d255835976f3c1db4991d9a94078 --- /dev/null +++ b/library/ZendAfi/Form/Decorator/Unimarc.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright (c) 2012-2017, 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_Form_Decorator_Unimarc extends Zend_Form_Decorator_Abstract { + /** + * @param string $content + * @return string + */ + public function render($content) { + return $this->_element->getView()->unimarcZoneConfig($this->_element->getSettings(), + $this->_element->getId(), + $this->_element->getMessages()); + } +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Element/RecordTabs.php b/library/ZendAfi/Form/Element/RecordTabs.php new file mode 100644 index 0000000000000000000000000000000000000000..6b2bec7c3b55d7e6f68ec0dfb4b169b844d3bd2c --- /dev/null +++ b/library/ZendAfi/Form/Element/RecordTabs.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright (c) 2012-2014, 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_Form_Element_RecordTabs extends Zend_Form_Element { + protected + $_settings; + + public function __construct($spec, $options = null) { + parent::__construct($spec, $options); + + $decorators = $this->_decorators; + $this->_decorators = ['ImageViewer' => new ZendAfi_Form_Decorator_RecordTabs()]; + + foreach ($decorators as $name => $value) + $this->_decorators[$name] = $value; + $this->removeDecorator('ViewHelper'); + } + + + public function setSettings($settings) { + $this->_settings = $settings; + return $this; + } + + + public function getSettings() { + return $this->_settings; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Element/Unimarc.php b/library/ZendAfi/Form/Element/Unimarc.php new file mode 100644 index 0000000000000000000000000000000000000000..3aa3c86880e904cb54f367bdf2550f756c6b8f4c --- /dev/null +++ b/library/ZendAfi/Form/Element/Unimarc.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright (c) 2012-2014, 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_Form_Element_Unimarc extends Zend_Form_Element { + protected + $_settings, + $_error_messages; + + public function __construct($spec, $options = null) { + parent::__construct($spec, $options); + + $decorators = $this->_decorators; + $this->_decorators = ['ImageViewer' => new ZendAfi_Form_Decorator_Unimarc()]; + + foreach ($decorators as $name => $value) + $this->_decorators[$name] = $value; + $this->removeDecorator('ViewHelper'); + } + + + public function setSettings($settings) { + $this->_settings = $settings; + return $this; + } + + + public function getSettings() { + return $this->_settings; + } + + + public function setMessages($errors) { + $this->_error_messages = $errors; + return $this; + } + + + public function getMessages() { + return $this->_error_messages; + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/RecordTabs.php b/library/ZendAfi/View/Helper/RecordTabs.php new file mode 100644 index 0000000000000000000000000000000000000000..ab48f6738ee4d851a734b0c69f10871bd76244f4 --- /dev/null +++ b/library/ZendAfi/View/Helper/RecordTabs.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright (c) 2012-2017, 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_RecordTabs extends ZendAfi_View_Helper_BaseHelper { + protected $_tabs; + + + public function recordTabs($tabs) { + if(!$this->_tabs = $tabs) + return ''; + + return $this->_tag('div', + $this->_tag('table', $this->_getTableHeader() . $this->_getTableContent())); + } + + + protected function _getTableHeader() { + $columns = [$this->_('Rubrique'), + $this->_('Style'), + $this->_('Ordre'), + $this->_('Titre'), + $this->_('Largeur')]; + $columns = array_map(function($title) {return $this->_tag('th', $title);}, $columns); + return $this->_tag('tr', implode($columns)); + } + + + protected function _getTableContent() { + $codif = Class_Codification::getInstance(); + foreach($this->_tabs as $clef => $valeurs) { + $nom_onglet = $codif->getNomOnglet($clef); + if (!$valeurs['titre']) + $valeurs['titre'] = $nom_onglet; + + $input = function($name, $size) use ($clef, $valeurs) { + return $this->_tag('input', null, + ['type' => 'text', + 'name' => $clef . '_' . $name, + 'size' => $size, + 'value' => $valeurs[$name]]); + }; + + $content = [$nom_onglet, + $this->view->formSelect($clef . '_aff', + $valeurs['aff'], + '', + [$this->_('Ne pas afficher'), + $this->_('Bloc déplié'), + $this->_('Bloc fermé'), + $this->_('Dans un onglet')]), + $input('ordre', 3), + $input('titre', 20), + $input('largeur', 3)]; + + $content = array_map(function($td) { return $this->_tag('td', $td);}, $content); + $html[] = $this->_tag('tr', implode($content)); + } + + return implode($html); + } +} diff --git a/library/ZendAfi/View/Helper/UnimarcZoneConfig.php b/library/ZendAfi/View/Helper/UnimarcZoneConfig.php index a5b5eb4d0f681611bafbbb41d717a38ecf0dc5f9..42ed7c346a29e1a179c080f542daf3a7421b9dbf 100644 --- a/library/ZendAfi/View/Helper/UnimarcZoneConfig.php +++ b/library/ZendAfi/View/Helper/UnimarcZoneConfig.php @@ -24,13 +24,11 @@ class ZendAfi_View_Helper_UnimarcZoneConfig extends ZendAfi_View_Helper_BaseHelp protected $unimarc_type='links'; - public function unimarcZoneConfig($title,$preferences,$preference_field, $errors) { + public function unimarcZoneConfig($preferences,$preference_field, $errors) { if ($preference_field == 'thumbnail_fields') $this->unimarc_type='thumbnails'; - $content = $this->_tag('legend', $title); - $content .= $this->displayErrors($errors); - $content .= $this->renderMultiInput($preferences,$preference_field); - return $this->_tag('fieldset', $content); + + return $this->displayErrors($errors) . $this->renderMultiInput($preferences,$preference_field); } protected function displayErrors($errors) { diff --git a/tests/application/modules/admin/controllers/ModulesControllerTest.php b/tests/application/modules/admin/controllers/ModulesControllerTest.php index 4aac3adac263a1f6cc2f775e0af3611a3ee46aef..4324ceb7f14d383b55511a06ef2dc026273a1bcb 100644 --- a/tests/application/modules/admin/controllers/ModulesControllerTest.php +++ b/tests/application/modules/admin/controllers/ModulesControllerTest.php @@ -32,7 +32,7 @@ class ModulesControllerRechercheTest extends Admin_AbstractControllerTestCase { /** @test */ public function titleShouldBeRecordDisplayProperty() { - $this->assertXPathContentContains('//h1', 'Propriétés d\'affichage des notices'); + $this->assertXPathContentContains('//h1', 'Configuration de l\'affichage'); }