diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index e00ef8760196c6554efb77814a51e631041dcae5..413c0b2c74f85475e03980c018104efc0563bd6b 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -101,7 +101,7 @@ class AuthController extends ZendAfi_Controller_Action { $strategy = Auth_Strategy_Abstract::strategyForController($this); $strategy->setDefaultUrl($this->_getParam('redirect','/opac')); $strategy->onLoginSuccess(function($user) { - $user->registerNotificationsOn($this->getHelper('notify')); + $user->registerNotificationsOn($this->getHelper('notify')->bePopup()); }); $strategy->processLogin(); $this->view->form_action = 'login'; @@ -155,7 +155,7 @@ class AuthController extends ZendAfi_Controller_Action { $strategy = Auth_Strategy_Abstract::strategyForController($this); $strategy->setDefaultUrl($this->_request->getServer('HTTP_REFERER')); $strategy->onLoginSuccess(function($user) { - $user->registerNotificationsOn($this->getHelper('notify')); + $user->registerNotificationsOn($this->getHelper('notify')->bePopup()); }); $strategy->processLogin(); diff --git a/library/Class/ScriptLoader.php b/library/Class/ScriptLoader.php index f7575c3f87c152525eccf7f9fa51d1988003f128..ed5b14019675a1a809e6bd64da3adf86edb35a6a 100644 --- a/library/Class/ScriptLoader.php +++ b/library/Class/ScriptLoader.php @@ -21,6 +21,8 @@ class Class_ScriptLoader { + use Trait_Translator; + const MODE_JQUERY_READY = 0, MODE_JQUERY_MOBILE = 1, @@ -332,7 +334,8 @@ class Class_ScriptLoader { $this->notify(implode('. ', $bar_messages)); if ($popup_messages) - $this->addJQueryReady("$('<p>" .implode('<br> ', $popup_messages). "</p>').dialog()"); + $this->addJQueryReady("$('<p title=\"" . $this->_('Information') . "\">" + .implode('<br> ', $popup_messages). "</p>').dialog()"); return $this; diff --git a/library/ZendAfi/Controller/Action/Helper/FlashMessenger.php b/library/ZendAfi/Controller/Action/Helper/FlashMessenger.php index 42a104919b97a04b623d48436b553b588d60f606..a86f3d0b844ba5646d80d484b2d9077319083160 100644 --- a/library/ZendAfi/Controller/Action/Helper/FlashMessenger.php +++ b/library/ZendAfi/Controller/Action/Helper/FlashMessenger.php @@ -66,7 +66,9 @@ class FlashMessengerNotification { } public function isPopup() { - return isset($this->_params['display']) && ($this->_params['display'] == 'popup'); + return + isset($this->_params['display']) + && ($this->_params['display'] == ZendAfi_Controller_Action_Helper_FlashMessenger::POPUP); } } diff --git a/library/ZendAfi/Controller/Action/Helper/Notify.php b/library/ZendAfi/Controller/Action/Helper/Notify.php index 9f252615141fcaf53af14cbce67d614ea3495f83..818b2dbc5053364f85aab8e0b6f3cdc9a097006c 100644 --- a/library/ZendAfi/Controller/Action/Helper/Notify.php +++ b/library/ZendAfi/Controller/Action/Helper/Notify.php @@ -20,18 +20,26 @@ */ class ZendAfi_Controller_Action_Helper_Notify extends Zend_Controller_Action_Helper_Abstract { + protected $_options = []; + /** * [[file:~/public_html/afi-opac3/library/Class/ScriptLoader.php::public%20function%20showNotifications()%20{][voir Class_ScriptLoader::showNotifications]] */ public function notify($message) { $this->getActionController() ->getHelper('flashMessenger') - ->addNotification($message); + ->addNotification($message, $this->_options); } public function direct($message) { $this->notify($message); } + + + public function bePopup() { + $this->_options['display'] = ZendAfi_Controller_Action_Helper_FlashMessenger::POPUP; + return $this; + } } ?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index b294999e4b0e2fa762fe1d224165f82457281af4..b9436ebd5476fdc9802061b1aecfe9bdd0795b8c 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -894,10 +894,10 @@ class AuthControllerPostSimpleSuccessfulTest extends AuthControllerPostSimpleSuc 2])); } - /** @test */ public function flasMessengerShouldContainMessageDeNotification() { - $this->assertFlashMessengerContentContains('Message de notification'); + $this->assertFlashMessengerContains([ZendAfi_Controller_Action_Helper_FlashMessenger::NOTIFICATION => ['message' => 'Message de notification', + 'display' => 'popup']]); } } @@ -908,15 +908,17 @@ class AuthControllerAjaxLoginPostTest extends AuthControllerPostSimpleSuccessful parent::setUp(); $_SERVER['HTTP_REFERER'] = '/recherche/viewnotice'; $this->postDispatch('/opac/auth/ajax-login', - ['username' => 'foo', 'password' => 'bar'],true); + ['username' => 'foo', 'password' => 'bar'], true); } /** @test */ public function flashMessengerShouldContainMessageDeNotification() { - $this->assertFlashMessengerContentContains('Message de notification'); + $this->assertFlashMessengerContains( + [ZendAfi_Controller_Action_Helper_FlashMessenger::NOTIFICATION => ['message' => 'Message de notification']]); } + /** @test */ public function responseShouldRedirectToReferrer() { $this->assertRedirectTo('/recherche/viewnotice'); @@ -937,7 +939,8 @@ class AuthControllerBoiteLoginPostTest extends AuthControllerPostSimpleSuccessfu /** @test */ public function flashMessengerShouldContainMessageDeNotification() { $this->assertFlashMessengerContains( - [ZendAfi_Controller_Action_Helper_FlashMessenger::NOTIFICATION => ['message' => 'Message de notification']]); + [ZendAfi_Controller_Action_Helper_FlashMessenger::NOTIFICATION => ['message' => 'Message de notification', + 'display' => ZendAfi_Controller_Action_Helper_FlashMessenger::POPUP]]); } /** @test */ diff --git a/tests/library/Class/ScriptLoaderTest.php b/tests/library/Class/ScriptLoaderTest.php index c01dc05584126bce032d599d865defefa4e70006..e47360c48f9b2c7164f629ebfce5d8c4153e31b1 100644 --- a/tests/library/Class/ScriptLoaderTest.php +++ b/tests/library/Class/ScriptLoaderTest.php @@ -267,7 +267,7 @@ class ScriptLoaderNotificationsBarTest extends Storm_Test_ModelTestCase { /** @test */ public function messageThreeAndFourShouldBePopupedUpInJQueryDialog() { - $this->assertContains("$('<p>Third message<br> Fourth message</p>').dialog()", + $this->assertContains("$('<p title=\"Information\">Third message<br> Fourth message</p>').dialog()", $this->_html); } }