diff --git a/application/modules/admin/controllers/I18nController.php b/application/modules/admin/controllers/I18nController.php index 5f3781838e03c064179590c3d841014f82feb8a4..3089892c43303ee1ac302c7f37d808445a5b21f9 100644 --- a/application/modules/admin/controllers/I18nController.php +++ b/application/modules/admin/controllers/I18nController.php @@ -25,6 +25,7 @@ class Admin_I18nController extends ZendAfi_Controller_Action { protected $_i18n; public function init() { + parent::init(); $this->_helper->getHelper('AjaxContext') ->addActionContext('update', 'json') ->initContext() @@ -32,6 +33,7 @@ class Admin_I18nController extends ZendAfi_Controller_Action { } public function preDispatch() { + parent::preDispatch(); $this->_i18n = Class_I18n::getInstance(); } @@ -206,6 +208,8 @@ class Admin_I18nController extends ZendAfi_Controller_Action { = $form = ZendAfi_Form_Admin_I18n_UpdateString::newWith($this->_request->getParams()); + $form->setAction($this->view->url(['render' => null])); + if(!$this->_request->isPost()) return; @@ -213,13 +217,15 @@ class Admin_I18nController extends ZendAfi_Controller_Action { $to = $this->_getParam('to', ''); if(!$this->_i18n->updateString($from, $to)) { - $this->_helper->notify($this->_('La modification de la "%s" par "%s" a échoué.', - $from, $to)); - return $this->_redirectToReferer(); + $this->_helper->notify($this->_('La modification de la "%s" par "%s" a échoué. Erreurs : %s', + $from, + $to, + implode(BR, $this->_i18n->getErrors()))); + return $this->_redirectClose($this->_getReferer()); } $this->_helper->notify($this->_('La modification de la chaîne "%s" par "%s" a été enregistrée.', $from, $to)); - $this->_redirectToReferer(); + $this->_redirectClose($this->_getReferer()); } } \ No newline at end of file diff --git a/application/modules/admin/views/scripts/i18n/index.phtml b/application/modules/admin/views/scripts/i18n/index.phtml index b05372b663619fbdcd3d68031e3519b0905b0f70..86c0ea1744534594d2e52b23b70cb0f496c55c11 100644 --- a/application/modules/admin/views/scripts/i18n/index.phtml +++ b/application/modules/admin/views/scripts/i18n/index.phtml @@ -35,12 +35,18 @@ foreach ($this->translated as $langue => $v) { ?> <div class="i18n_content" id="i18n_<?php echo $langue;?>" style="display: none;"> <table> <tr> - <th><?php echo $this->_('Original');?></th> + <th><?php echo $this->_('Original').' '.$this->tagImg(URL_ADMIN_IMG.'flags/' . Class_AdminVar::getDefaultLanguage() .'.png');?></th> <th><?php echo $this->_('Traduction').' '.$this->tagImg(URL_ADMIN_IMG.'flags/' . $langue .'.png'); ?></th> </tr> <?php foreach ($this->form->{$langue}->getElements() as $element) { ?> <tr> - <td class="i18n_label"><?php echo $element->getLabel(); ?></td> + <td class="i18n_label"><?php echo $element->getLabel() + . $this->tagAnchor(['action' => 'update-string', + 'from' => $element->getLabel()], + $this->tagImg(Class_Admin_Skin::current()->getIconUrl('actions', 'edit'), + ['style' => 'width: 16px; margin-left: 1em;']), + ['data-popup' => 'true']); + ?></td> <td><?php echo $element->removeDecorator('label') ?></td> </tr> <?php } ?> @@ -48,4 +54,4 @@ foreach ($this->translated as $langue => $v) { ?> </div> <?php } ?> <?php echo new Zend_Form_Element_Hidden('i18nFormId', array('value' => 1)); ?> -</form> \ No newline at end of file +</form> diff --git a/library/Class/I18n.php b/library/Class/I18n.php index 47caa70b308bbcb12fc358b7aa8189f5addbdc37..95970bede53b84637950d6e24ed2982059105db2 100644 --- a/library/Class/I18n.php +++ b/library/Class/I18n.php @@ -249,6 +249,13 @@ return array( $this->_profile_updator->updateString($from, $to); } - return $this->_profile_updator->hasError(); + return !$this->_profile_updator->hasError(); + } + + + public function getErrors() { + return $this->_profile_updator + ? $this->_profile_updator->getErrors() + : []; } } \ No newline at end of file diff --git a/library/Class/Profil/I18n.php b/library/Class/Profil/I18n.php index a46ecbb9a2467a9ce76421cb326484a372703ae9..e760bef4f18f765a0d5dd6c9668feb2942c62206 100644 --- a/library/Class/Profil/I18n.php +++ b/library/Class/Profil/I18n.php @@ -16,18 +16,41 @@ * * 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 Class_Profil_I18n { const VISITABLE_CLASS_KEY = 'visitable'; const CONFIG_GETTER_KEY = 'configGetter'; /** @var Array */ - protected static $_knownStringKeys = array( - 'titre', 'message', 'exemple', 'libelle', - 'message_carte', 'identifiant', 'mot_de_passe', - 'facettes_message', 'tags_message', 'barre_nav', - ); + protected static $_knownStringKeys = [ + 'titre', + 'titre_connecte', + 'libelle', + + 'message', + 'message_connecte', + 'intro', + 'exemple', + 'placeholder', + 'message_carte', + + 'identifiant', + 'identifiant_exemple', + 'mot_de_passe', + 'mot_de_passe_exemple', + + 'lien_compte', + 'lien_deconnection', + 'lien_connexion', + 'lien_mot_de_passe_oublie', + 'lien_creer_compte', + 'pre-registration', + 'pre_registration', + + 'facettes_message', + 'tags_message', + 'barre_nav']; /** * @var array diff --git a/library/Class/Profil/I18nStringUpdator.php b/library/Class/Profil/I18nStringUpdator.php index 35eed66d428bfe088ef6da8a1c77ebae4a3015c3..b169f3162a76d7ace3e85b20ebe9a4a256ed633a 100644 --- a/library/Class/Profil/I18nStringUpdator.php +++ b/library/Class/Profil/I18nStringUpdator.php @@ -71,4 +71,9 @@ class Class_Profil_I18nStringUpdator extends Class_Profil_I18n { public function hasError() { return !empty($this->_errors); } + + + public function getErrors() { + return $this->_errors; + } } \ No newline at end of file diff --git a/library/ZendAfi/Form/Admin/I18n/UpdateString.php b/library/ZendAfi/Form/Admin/I18n/UpdateString.php index 7876336bd4581f866239c8453d8271b05f41fe64..e535c73c7c638afc7ad2c1e4d030af6db82355ca 100644 --- a/library/ZendAfi/Form/Admin/I18n/UpdateString.php +++ b/library/ZendAfi/Form/Admin/I18n/UpdateString.php @@ -29,9 +29,12 @@ class ZendAfi_Form_Admin_I18n_UpdateString extends ZendAfi_Form { 'from', ['label' => $this->_('Chaîne de caratères à remplacer'), 'disabled' => 'disabled']) + ->addElement('text', 'to', - ['label' => $this->_('par')]) + ['label' => $this->_('par'), + 'allowEmpty' => false, + 'required' => true]) ->addUniqDisplayGroup('update-string'); } diff --git a/tests/application/modules/admin/controllers/I18nControllerTest.php b/tests/application/modules/admin/controllers/I18nControllerTest.php index da8bdb8b9f8fbe157d9005d80049f9838e13c22d..1e52d902c776f08b99727c520e3dee92dc114994 100644 --- a/tests/application/modules/admin/controllers/I18nControllerTest.php +++ b/tests/application/modules/admin/controllers/I18nControllerTest.php @@ -156,6 +156,8 @@ class I18nControllerUpdateStringTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('LANGUES', 'fr;en;es'); + $profil_8 = $this->fixture('Class_Profil', ['id' => 8]); @@ -169,20 +171,25 @@ class I18nControllerUpdateStringTest extends Admin_AbstractControllerTestCase { $profil_8->setCfgAccueil($simple_widgets)->save(); $profil_9->setCfgAccueil($simple_widgets)->save(); + } + /** @test */ + public function linkToUpdateStringShouldBePresent() { + $this->dispatch('/admin/I18n/index', true); + $this->assertXPath('//a[contains(@href, "/admin/I18n/update-string/from/Bienvenue")]', $this->_response->getBody()); } /** @test */ - public function dispatchShouldRenderForm() { + public function dispatchUpdateStringShouldRenderForm() { $this->dispatch('/admin/I18n/update-string/from/Bienvenue', true); $this->assertXPath('//form//input[@name="from"]'); } /** @test */ - public function afterPostDipatchkiosqueInProfile8TitreShouldBeBienvenido() { + public function updateStringPostDipatchkiosqueInProfile8TitreShouldBeBienvenido() { $this->postDispatch('/admin/I18n/update-string/from/Bienvenue', ['to' => 'Bienvenido']); $widget = (new Class_Systeme_Widget_Widget()) @@ -190,5 +197,8 @@ class I18nControllerUpdateStringTest extends Admin_AbstractControllerTestCase { ->setProfileId(8) ->load(); $this->assertEquals('Bienvenido', $widget->gettitre()); + + $this->assertRedirect(); + $this->assertFlashMessengerContentContains('enregistrée'); } } \ No newline at end of file