From 631e554d56bbdab5f402ae02ac2e6db68a369ff4 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 29 Oct 2018 17:50:55 +0100 Subject: [PATCH] W.I.P. migration of mainscreen to et2: - Fix data not being loaded on initiation --- admin/inc/class.admin_messages.inc.php | 44 +++++++++++++++---- .../templates/default/mainscreen_message.xet | 6 +-- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/admin/inc/class.admin_messages.inc.php b/admin/inc/class.admin_messages.inc.php index 850db6fb98..4c82d61db6 100644 --- a/admin/inc/class.admin_messages.inc.php +++ b/admin/inc/class.admin_messages.inc.php @@ -22,8 +22,6 @@ class admin_messages { var $public_functions = array('index' => True); - var $sections = array ('mainscreen', 'loginscreen'); - const MAINSCREEN = 'mainscreen'; const LOGINSCREEN = 'loginscreen'; @@ -38,13 +36,14 @@ class admin_messages if (!is_array($content)) { - - $content = array( + $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; + $content = array_merge(array( 'html' => true, - 'lang' => $GLOBALS['egw_info']['user']['preferences']['common']['lang'] - ); + 'lang' => $lang + ), $this->_getMessages($lang)); } - else { + else + { list($button) = @each($content['button']); if ($button) @@ -53,7 +52,7 @@ class admin_messages { case 'apply': case 'save': - foreach (self::$sections as $section) + foreach (array ('mainscreen', 'loginscreen') as $section) { $prefix = $content['html'] == true ? 'html_' : 'text_'; if ($content[$prefix.$section] && $content[$prefix.$section]) @@ -71,6 +70,10 @@ class admin_messages ), 'admin'); } } + else if ($content['lang']) + { + $content = array_merge($content, $this->_getMessages($content['lang'], $content['html'])); + } } $readonlys = array( 'tabs' => array( @@ -80,4 +83,29 @@ class admin_messages ); $tpl->exec('admin.admin_messages.index', $content, array(), $readonlys); } + + /** + * Get messages content + * + * @param type $lang + * @param type $html + * @return array returns an array of content + */ + private function _getMessages ($lang, $html = true) + { + if ($html) + { + return array ( + 'html_mainscreen' => Api\Translation::read($lang, self::MAINSCREEN, self::MAINSCREEN.'_message'), + 'html_loginscreen' => Api\Translation::read($lang, self::LOGINSCREEN, self::LOGINSCREEN.'_message'), + ); + } + else + { + return array ( + 'text_mainscreen' => strip_tags(Api\Translation::read($lang, self::MAINSCREEN, self::MAINSCREEN.'_message')), + 'text_loginscreen' => strip_tags(Api\Translation::read($lang, self::LOGINSCREEN, self::LOGINSCREEN.'_message')) + ); + } + } } diff --git a/admin/templates/default/mainscreen_message.xet b/admin/templates/default/mainscreen_message.xet index 002a95643e..00a6b07aa8 100644 --- a/admin/templates/default/mainscreen_message.xet +++ b/admin/templates/default/mainscreen_message.xet @@ -4,14 +4,14 @@