W.I.P. migration of mainscreen to et2:

- Fix data not being loaded on initiation
This commit is contained in:
Hadi Nategh 2018-10-29 17:50:55 +01:00
parent 95268be609
commit 631e554d56
2 changed files with 39 additions and 11 deletions

View File

@ -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'))
);
}
}
}

View File

@ -4,14 +4,14 @@
<overlay>
<template id ="admin.mainscreen_message.mainscreen" version="18.1">
<vbox>
<htmlarea id="html_mainscreen" height="500" width="100%" disabled="true"/>
<textbox id="text_mainscreen" disabled="$cont[html]"/>
<htmlarea id="html_mainscreen" height="500" width="100%" disabled="!$cont[html]"/>
<textbox id="text_mainscreen" disabled="$cont[html]" rows="25" cols="70" class="et2_fullWidth" multiline="true" height="500"/>
</vbox>
</template>
<template id ="admin.mainscreen_message.loginscreen" version="18.1">
<vbox>
<htmlarea id="html_loginscreen" height="500" width="100%" disabled="!$cont[html]"/>
<textbox id="text_loginscreen" disabled="$cont[html]"/>
<textbox id="text_loginscreen" disabled="$cont[html]" rows="25" cols="70" class="et2_fullWidth" multiline="true" height="500"/>
</vbox>
</template>
<template id="admin.mainscreen_message" template="" lang="" group="0" version="18.1">