diff --git a/VERSIONS_WIP/32110 b/VERSIONS_WIP/32110 new file mode 100644 index 0000000000000000000000000000000000000000..29997c6f7bed124d548e236bc6afeb94e6fa492b --- /dev/null +++ b/VERSIONS_WIP/32110 @@ -0,0 +1 @@ + - ticket #32110 : [PNB] Ecran intermédiaire de prêt: texte riche d'aide paramétrable par la médiathèque \ No newline at end of file diff --git a/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml b/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml index 6dba570e25be7628e8b5de3c3c4f9b6af8889088..094af95173656a593f2f3b5c40de5de29d931661 100644 --- a/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml +++ b/application/modules/opac/views/scripts/bib-numerique/loan-book.phtml @@ -5,6 +5,6 @@ echo $this->tagAnchor($this->url(['action' => 'download-loan-book-ajax']), $this 'class' => 'button blue']); echo $this->tagAnchor('', $this->_('non'), ['onclick' => 'opacDialogClose();return false', 'class' => 'button red']); -echo $this->tag('p', 'Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.'); +echo $this->tag('p', Class_AdminVar::getValueOrDefault('DILICOM_PNB_LOAN_WARNING_MESSAGE')); echo '</div>'; ?> diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 0e65be08ad7558c041e3a1f2a27efdd8511f7e1b..c406e8229fede6c5e631e80083692e3193d4b6de 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -246,6 +246,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'DILICOM_PNB_MAX_LOAN_DURATION' => Class_AdminVar_Meta::newDefault($this->_('Durée maximale (en jours) d\'un prêt PNB Dilicom')), 'DILICOM_PNB_LOAN_COUNT_LIMIT' => Class_AdminVar_Meta::newDefault($this->_('Nombre de prêts simultanés maximum pour un livre PNB Dilicom')), 'DILICOM_PNB_MAX_LOAN_PER_USER' => Class_AdminVar_Meta::newDefault($this->_('Nombre de prêts simultanés maximum pour un abonné PNB Dilicom (par défaut 3)'), ['value' => 3]), + 'DILICOM_PNB_LOAN_WARNING_MESSAGE' => Class_AdminVar_Meta::newEditor($this->_('Message d\'avertissement affiché sur la popup d\'emprunt'), + ['value' => $this->_('Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.')]), 'MYCOW_EID' => Class_AdminVar_Meta::newDefault($this->_('Clé d\'identification MyCOW.EU pour le portail. Cette clé doit être fournie par MyCOW.EU. Elle active la ressource numérique dans le portail.'))->bePrivate(), 'ONEDTOUCH_URL' => Class_AdminVar_Meta::newDefault($this->_('Adresse du serveur OAI 1D touch'))->bePrivate(), diff --git a/library/Class/AdminVar/Meta.php b/library/Class/AdminVar/Meta.php index f2de0637915017f98b5c725753a87d8dc3f0dc8c..48e17d3ea73e010382dbd2c8811fa4c9eee86fc7 100644 --- a/library/Class/AdminVar/Meta.php +++ b/library/Class/AdminVar/Meta.php @@ -27,7 +27,8 @@ class Class_AdminVar_Meta { TYPE_ON_OFF = 'on-off', TYPE_MULTI_INPUT = 'multi-input', TYPE_COMBO = 'combo', - TYPE_RAW_TEXT = 'raw-text'; + TYPE_RAW_TEXT = 'raw-text', + TYPE_EDITOR = 'editor'; protected @@ -41,7 +42,8 @@ class Class_AdminVar_Meta { 'OnOff' => self::TYPE_ON_OFF, 'MultiInput' => self::TYPE_MULTI_INPUT, 'Combo' => self::TYPE_COMBO, - 'RawText' => self::TYPE_RAW_TEXT]; + 'RawText' => self::TYPE_RAW_TEXT, + 'Editor' => self::TYPE_EDITOR]; $type_name = substr($name, 3); @@ -83,6 +85,11 @@ class Class_AdminVar_Meta { } + public function isEditor() { + return self::TYPE_EDITOR == $this->_type; + } + + public function isMultiInput() { return self::TYPE_MULTI_INPUT == $this->_type; } diff --git a/library/ZendAfi/Form/Admin/AdminVar/Editor.php b/library/ZendAfi/Form/Admin/AdminVar/Editor.php new file mode 100644 index 0000000000000000000000000000000000000000..f812541e5010ffe31e62296e16cc4d4935c0493c --- /dev/null +++ b/library/ZendAfi/Form/Admin/AdminVar/Editor.php @@ -0,0 +1,40 @@ +<?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_Admin_AdminVar_Editor extends ZendAfi_Form_Admin_AdminVar { + protected $_select_options = []; + + + public function addVariableEditElement() { + $this->addElement('ckeditor', + 'valeur', + ['label' => $this->_('Valeur')]); + + } + + + public function getAdminVarValue() { + return trim($this->getValues()['valeur']); + } + + +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Admin/AdminVarFactory.php b/library/ZendAfi/Form/Admin/AdminVarFactory.php index 9a585d5e1947c2b43b44f199d50e95a9c7a6f38d..60faeae3124e217e761a539cb96db2f65fe979a1 100644 --- a/library/ZendAfi/Form/Admin/AdminVarFactory.php +++ b/library/ZendAfi/Form/Admin/AdminVarFactory.php @@ -32,7 +32,8 @@ class ZendAfi_Form_Admin_AdminVarFactory { Class_AdminVar_Meta::TYPE_DEFAULT => 'ZendAfi_Form_Admin_AdminVar', Class_AdminVar_Meta::TYPE_ENCODED_DATA => 'ZendAfi_Form_Admin_AdminVar_EncodedData', Class_AdminVar_Meta::TYPE_RAW_TEXT => 'ZendAfi_Form_Admin_AdminVar_RawText', - Class_AdminVar_Meta::TYPE_COMBO => 'ZendAfi_Form_Admin_AdminVar_Combo' + Class_AdminVar_Meta::TYPE_COMBO => 'ZendAfi_Form_Admin_AdminVar_Combo', + Class_AdminVar_Meta::TYPE_EDITOR => 'ZendAfi_Form_Admin_AdminVar_Editor' ]; diff --git a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php index eed12ee577f4c523e571399a33e5544ffaa265bb..abe9116d9b6eb7485cd7900a503f50378c02de3f 100644 --- a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php @@ -284,6 +284,46 @@ class AdminIndexControllerAdminVarEditActionTest extends Admin_AbstractControlle } } +class AdminIndexControllerAdminVarEditCKEditorActionTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile=true; + public function setUp() { + parent::setUp(); + } + + /** @test */ + public function defaultValueShouldBeSet() { + $this->assertEquals('Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.',Class_AdminVar::getValueOrDefault('DILICOM_PNB_LOAN_WARNING_MESSAGE')); + } + + /** @test */ + public function editPageShouldContainsTitlePNBLoanMessage() { + $this->fixture('Class_AdminVar', + ['id' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => '']); + + $this->dispatch('/admin/index/adminvaredit/cle/DILICOM_PNB_LOAN_WARNING_MESSAGE'); + $this->assertQueryContentContains('h1', + 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + $this->_response->getBody()); + } + + /** @test */ + public function postEnrichTextShouldNotRemoveTags() { + $this->fixture('Class_AdminVar', + ['id' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => '']); + $this + ->getRequest() + ->setMethod('POST') + ->setPost(['cle' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => "<b>don't use this, drm are dangerous!</b>"]); + $this->dispatch('/admin/index/adminvaredit/cle/DILICOM_PNB_LOAN_WARNING_MESSAGE'); + $this->assertEquals('<b>don\'t use this, drm are dangerous!</b>', Class_AdminVar::get('DILICOM_PNB_LOAN_WARNING_MESSAGE')); + } + + +} + abstract class AdminIndexControllerAdminVarEditWithWorkflowTestCase extends Admin_AbstractControllerTestCase { public function setUp() { diff --git a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php index 441d4d3c4fd61164cadd5f717f6a4d7f77ba817a..a0aa0de6477255cf8400944a1bcd5601f70f8eed 100644 --- a/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php +++ b/tests/application/modules/opac/controllers/BibNumeriqueControllerDilicomTest.php @@ -107,6 +107,8 @@ abstract class BibNumeriqueContollerDilicomTestCase extends AbstractControllerTe class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueContollerDilicomTestCase { + protected $_storm_default_to_volatile = true; + /** @test */ public function popupConsultBookShouldContainsLinkToOpenAjax() { $this->_http @@ -156,7 +158,6 @@ class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueCo } - /** @test */ public function loanBookPopupShouldContainsLinkToDownload() { $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); @@ -171,6 +172,24 @@ class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueCo } + /** @test */ + public function loanBookPopupShouldContainDefaultMessage() { + $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); + $this->assertContains('Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.', json_decode($this->_response->getBody())->content); + } + + + /** @test */ + public function loanBookPopupShouldContainDefinedMessage() { + $this->fixture('Class_AdminVar', + ['id' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE', + 'valeur' => 'Don\'t use this !' + ]); + $this->dispatch('/bib-numerique/loan-book-ajax/id/3', true); + $this->assertContains('Don\'t use this !', json_decode($this->_response->getBody())->content); + } + + /** @test */ public function downloadLinkShouldAnswersDilicomLink() { $this->_http