mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
W.I.P. migration of mainscreen to et2
This commit is contained in:
parent
bb369167e2
commit
c9ec548a53
@ -5,11 +5,15 @@
|
|||||||
* @link http://www.egroupware.org
|
* @link http://www.egroupware.org
|
||||||
* @package admin
|
* @package admin
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
|
* @author Hadi Nategh <hn@egroupware.org>
|
||||||
|
* @copyright (c) 2018, Hadi Nategh <hn@egroupware.org>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use EGroupware\Api;
|
use EGroupware\Api;
|
||||||
use EGroupware\Api\Framework;
|
use EGroupware\Api\Framework;
|
||||||
|
use EGroupware\Api\Etemplate;
|
||||||
|
use EGroupware\Api\Egw;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mainscreen and login message
|
* Mainscreen and login message
|
||||||
@ -18,125 +22,62 @@ class admin_messages
|
|||||||
{
|
{
|
||||||
var $public_functions = array('index' => True);
|
var $public_functions = array('index' => True);
|
||||||
|
|
||||||
function index()
|
var $sections = array ('mainscreen', 'loginscreen');
|
||||||
{
|
|
||||||
$section = $_POST['section'];
|
|
||||||
$select_lang = $_POST['select_lang'];
|
|
||||||
$message = get_magic_quotes_gpc() ? stripslashes($_POST['message']) : $_POST['message'];
|
|
||||||
$acl_ok = array();
|
|
||||||
if (!$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin'))
|
|
||||||
{
|
|
||||||
$acl_ok['mainscreen'] = True;
|
|
||||||
}
|
|
||||||
if (!$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin'))
|
|
||||||
{
|
|
||||||
$acl_ok['loginscreen'] = True;
|
|
||||||
}
|
|
||||||
if ($_POST['cancel'] && !isset($_POST['message']) ||
|
|
||||||
!count($acl_ok) || $_POST['submit'] && !isset($acl_ok[$section]))
|
|
||||||
{
|
|
||||||
$GLOBALS['egw']->redirect_link('/admin/index.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
Framework::includeJS('vendor/egroupware/ckeditor/ckeditor.js');
|
const MAINSCREEN = 'mainscreen';
|
||||||
|
const LOGINSCREEN = 'loginscreen';
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_file(array('message' => 'mainscreen_message.tpl'));
|
function index ($content = null)
|
||||||
$GLOBALS['egw']->template->set_block('message','form','form');
|
|
||||||
$GLOBALS['egw']->template->set_block('message','row','row');
|
|
||||||
$GLOBALS['egw']->template->set_block('message','row_2','row_2');
|
|
||||||
|
|
||||||
if ($_POST['save'])
|
|
||||||
{
|
{
|
||||||
Api\Translation::write($select_lang,$section,$section.'_message',$message);
|
$tpl = new Etemplate('admin.mainscreen_message');
|
||||||
|
|
||||||
|
$acls = array (
|
||||||
|
self::MAINSCREEN => !$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin'),
|
||||||
|
self::LOGINSCREEN => !$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!is_array($content))
|
||||||
|
{
|
||||||
|
|
||||||
|
$content = array(
|
||||||
|
'html' => true,
|
||||||
|
'lang' => $GLOBALS['egw_info']['user']['preferences']['common']['lang']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
list($button) = @each($content['button']);
|
||||||
|
|
||||||
|
if ($button)
|
||||||
|
{
|
||||||
|
switch($button)
|
||||||
|
{
|
||||||
|
case 'apply':
|
||||||
|
case 'save':
|
||||||
|
foreach (self::$sections as $section)
|
||||||
|
{
|
||||||
|
$prefix = $content['html'] == true ? 'html_' : 'text_';
|
||||||
|
if ($content[$prefix.$section] && $content[$prefix.$section])
|
||||||
|
{
|
||||||
|
Api\Translation::write($content['lang'], $section, $section.'_message',$content[$prefix.$section]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Framework::message(lang('message has been updated'));
|
Framework::message(lang('message has been updated'));
|
||||||
|
if ($button == 'apply') break;
|
||||||
$section = '';
|
//fall through
|
||||||
}
|
|
||||||
if ($_POST['cancel']) // back to section/lang-selection
|
|
||||||
{
|
|
||||||
$message = $section = '';
|
|
||||||
}
|
|
||||||
switch ($section)
|
|
||||||
{
|
|
||||||
case 'mainscreen':
|
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit main screen message') . ': '.strtoupper($select_lang);
|
|
||||||
break;
|
|
||||||
case 'loginscreen':
|
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit login screen message') . ': '.strtoupper($select_lang);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Main screen message');
|
Egw::redirect_link('/index.php', array(
|
||||||
break;
|
'menuaction' => 'admin.admin_ui.index',
|
||||||
|
'ajax' => 'true'
|
||||||
|
), 'admin');
|
||||||
}
|
}
|
||||||
if (empty($section))
|
|
||||||
{
|
|
||||||
echo $GLOBALS['egw']->framework->header();
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.admin_messages.index'));
|
|
||||||
$GLOBALS['egw']->template->set_var('value',' ');
|
|
||||||
$GLOBALS['egw']->template->fp('rows','row_2',True);
|
|
||||||
|
|
||||||
$langs = Api\Translation::get_installed_langs();
|
|
||||||
$langs['en'] .= ' ('.lang('All languages').')';
|
|
||||||
$lang_select = Api\Html::select('select_lang', 'en', $langs);
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_var('label',lang('Language'));
|
|
||||||
$GLOBALS['egw']->template->set_var('value',$lang_select);
|
|
||||||
$GLOBALS['egw']->template->fp('rows','row',True);
|
|
||||||
|
|
||||||
$select_section = '<select name="section">'."\n";
|
|
||||||
foreach(array_keys($acl_ok) as $key)
|
|
||||||
{
|
|
||||||
$select_section .= ' <option value="'.$key.'"'.
|
|
||||||
($key == $_POST['section'] ? ' selected' : '') . '>' .
|
|
||||||
($key == 'mainscreen' ? lang('Main screen') : lang("Login screen")) . "</option>\n";
|
|
||||||
}
|
}
|
||||||
$select_section .= '</select>';
|
|
||||||
$GLOBALS['egw']->template->set_var('label',lang('Section'));
|
|
||||||
$GLOBALS['egw']->template->set_var('value',$select_section);
|
|
||||||
$GLOBALS['egw']->template->fp('rows','row',True);
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_var('value',
|
|
||||||
Api\Html::submit_button('edit', lang('Edit'))."\n".Api\Html::submit_button('cancel', lang('Cancel')));
|
|
||||||
$GLOBALS['egw']->template->fp('rows','row_2',True);
|
|
||||||
}
|
}
|
||||||
else
|
$readonlys = array(
|
||||||
{
|
'tabs' => array(
|
||||||
$current_message = Api\Translation::read($select_lang,$section,$section.'_message');
|
self::MAINSCREEN => !$acls[self::MAINSCREEN],
|
||||||
if ($_POST['no']) $current_message = strip_tags($current_message);
|
self::LOGINSCREEN => !$acls[self::LOGINSCREEN]
|
||||||
if (empty($_POST['no']) && ($_POST['yes'] || empty($current_message) ||
|
)
|
||||||
strlen($current_message) != strlen(strip_tags($current_message))))
|
);
|
||||||
{
|
$tpl->exec('admin.admin_messages.index', $content, array(), $readonlys);
|
||||||
$text_or_htmlarea = Api\Html::fckEditorQuick('message','advanced',$current_message,'400px','800px');
|
|
||||||
$htmlarea_button = Api\Html::submit_button("no", lang('disable WYSIWYG-editor'));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$text_or_htmlarea='<textarea name="message" style="width:100%; min-width:350px; height:300px;" wrap="virtual">' .
|
|
||||||
Api\Html::htmlspecialchars($current_message) . '</textarea>';
|
|
||||||
$htmlarea_button = Api\Html::submit_button("yes", lang('activate WYSIWYG-editor'));
|
|
||||||
}
|
|
||||||
echo $GLOBALS['egw']->framework->header();
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_var('form_action',$GLOBALS['egw']->link('/index.php','menuaction=admin.admin_messages.index'));
|
|
||||||
$GLOBALS['egw']->template->set_var('select_lang',$select_lang);
|
|
||||||
$GLOBALS['egw']->template->set_var('section',$section);
|
|
||||||
$GLOBALS['egw']->template->set_var('value',' ');
|
|
||||||
$GLOBALS['egw']->template->fp('rows','row_2',True);
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_var('value',$text_or_htmlarea);
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->fp('rows','row_2',True);
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_var('value',
|
|
||||||
Api\Html::submit_button('save', lang('Save'))."\n".Api\Html::submit_button('cancel', lang('Cancel')).
|
|
||||||
"\n".$htmlarea_button);
|
|
||||||
$GLOBALS['egw']->template->fp('rows','row_2',True);
|
|
||||||
}
|
|
||||||
|
|
||||||
$GLOBALS['egw']->template->set_var('lang_cancel',lang('Cancel'));
|
|
||||||
$GLOBALS['egw']->template->pparse('out','form');
|
|
||||||
|
|
||||||
echo $GLOBALS['egw']->framework->footer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
admin/templates/default/mainscreen_message.xet
Normal file
51
admin/templates/default/mainscreen_message.xet
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
|
||||||
|
<!-- $Id$ -->
|
||||||
|
<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]"/>
|
||||||
|
</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]"/>
|
||||||
|
</vbox>
|
||||||
|
</template>
|
||||||
|
<template id="admin.mainscreen_message" template="" lang="" group="0" version="18.1">
|
||||||
|
<grid width="100%" height="600">
|
||||||
|
<columns>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<select-lang id="lang" onchange="widget.getInstanceManager().submit()"/>
|
||||||
|
<checkbox id="html" onchange="widget.getInstanceManager().submit()" label="html/plaintext"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<tabbox id="tabs" class="et2_nowrap" width="100%" span="all" tab_height="550">
|
||||||
|
<tabs>
|
||||||
|
<tab id="mainscreen" label="Main screen"/>
|
||||||
|
<tab id="loginscreen" label="Login screen"/>
|
||||||
|
</tabs>
|
||||||
|
<tabpanels>
|
||||||
|
<template id="admin.mainscreen_message.mainscreen"/>
|
||||||
|
<template id="admin.mainscreen_message.loginscreen"/>
|
||||||
|
</tabpanels>
|
||||||
|
</tabbox>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<hbox span="all">
|
||||||
|
<button statustext="Save changes" label="Save" id="button[save]" image="save" background_image="1"/>
|
||||||
|
<button statustext="Apply changes" label="Apply" id="button[apply]" image="check" background_image="1"/>
|
||||||
|
<button statustext="Cancel changes" label="Cancel" id="button[cancel]" image="cancel" background_image="1"/>
|
||||||
|
</hbox>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
</template>
|
||||||
|
</overlay>
|
Loading…
Reference in New Issue
Block a user