source: branches/2.4/admin/inc/class.uimainscreen.inc.php @ 5333

Revision 5333, 8.0 KB checked in by niltonneto, 12 years ago (diff)

Ticket #663 - Alterado editor WYSIWYG para utilizar CKEditor da lib da API.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - administration                                              *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  *  This program is free software; you can redistribute it and/or modify it *
7  *  under the terms of the GNU General Public License as published by the   *
8  *  Free Software Foundation; either version 2 of the License, or (at your  *
9  *  option) any later version.                                              *
10  \**************************************************************************/
11
12
13        class uimainscreen
14        {
15                var $public_functions = array('index' => True);
16
17                function uimainscreen()
18                {
19                        $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
20                }
21
22                function index()
23                {
24
25                        $html = createObject('phpgwapi.html');
26                        $section     = addslashes($_POST['section']);
27                        $select_lang = addslashes($_POST['select_lang']);
28                        $message     = addslashes($_POST['message']);
29
30                        $acl_ok = array();
31                        if (!$GLOBALS['phpgw']->acl->check('mainscreen_message_access',1,'admin'))
32                        {
33                                $acl_ok['mainscreen'] = True;
34                        }
35                        if (!$GLOBALS['phpgw']->acl->check('mainscreen_message_access',2,'admin'))
36                        {
37                                $acl_ok['loginscreen'] = True;
38                        }
39                        if (!$GLOBALS['phpgw']->acl->check('mainscreen_message_access',3,'admin'))
40                        {
41                                $acl_ok['loginhelp'] = True;
42                        }
43                        if ($_POST['cancel'] && !isset($_POST['message']) ||
44                            !count($acl_ok) || $_POST['submit'] && !isset($acl_ok[$section]))
45                        {
46                                $GLOBALS['phpgw']->redirect_link('/admin/index.php');
47                        }
48
49                        $GLOBALS['phpgw']->template->set_file(array('message' => 'mainscreen_message.tpl'));
50                        $GLOBALS['phpgw']->template->set_block('message','form','form');
51                        $GLOBALS['phpgw']->template->set_block('message','row','row');
52                        $GLOBALS['phpgw']->template->set_block('message','row_2','row_2');
53
54                        if ($_POST['submit'])
55                        {
56                                $GLOBALS['phpgw']->db->query("DELETE FROM phpgw_lang WHERE message_id='$section" . "_message' AND app_name='"
57                                        . "$section' AND lang='$select_lang'",__LINE__,__FILE__);
58                                $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_lang (message_id,app_name,lang,content)VALUES ('$section" . "_message','$section','$select_lang','"
59                                        . $message . "')",__LINE__,__FILE__);
60                                        $feedback_message = '<center>'.lang('message has been updated').'</center>';
61                               
62                                $section = '';
63                        }
64                        if ($_POST['cancel'])   // back to section/lang-selection
65                        {
66                                $message = $section = '';
67                        }
68                        switch ($section)
69                        {
70                                case 'mainscreen':
71                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit main screen message') . ': '.strtoupper($select_lang);
72                                        break;
73                                case 'loginscreen':
74                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit login screen message') . ': '.strtoupper($select_lang);
75                                        break;
76                                case 'loginhelp':
77                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Edit login help message') . ': '.strtoupper($select_lang);
78                                        break;
79                                default:
80                                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin').' - '.lang('Main screen message');
81                                        break;
82                        }
83                        if(!@is_object($GLOBALS['phpgw']->js))
84                        {
85                                $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
86                        }
87
88                       
89
90                       
91                        if (empty($section))
92                        {
93
94                           $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin');
95                           $GLOBALS['phpgw']->common->phpgw_header();
96                           echo parse_navbar();
97                                 
98                           
99                           $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index'));
100                                $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw_info']['theme']['th_bg']);
101                                $GLOBALS['phpgw']->template->set_var('value','&nbsp;');
102                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
103
104                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
105                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
106
107                                $lang_select = '<select name="select_lang">';
108                                $GLOBALS['phpgw']->db->query("SELECT lang,phpgw_languages.lang_name,phpgw_languages.lang_id FROM phpgw_lang,phpgw_languages WHERE "
109                                        . "phpgw_lang.lang=phpgw_languages.lang_id GROUP BY lang,phpgw_languages.lang_name,"
110                                        . "phpgw_languages.lang_id ORDER BY lang",__LINE__,__FILE__);
111                                while ($GLOBALS['phpgw']->db->next_record())
112                                {
113                                        $lang = $GLOBALS['phpgw']->db->f('lang');
114                                        $lang_select .= '<option value="' . $lang . '"'.($lang == $select_lang ? ' selected' : '').'>' .
115                                                $lang . ' - ' . $GLOBALS['phpgw']->db->f('lang_name') . "</option>\n";
116                                }
117                                $lang_select .= '</select>';
118                                $GLOBALS['phpgw']->template->set_var('label',lang('Language'));
119                                $GLOBALS['phpgw']->template->set_var('value',$lang_select);
120                                $GLOBALS['phpgw']->template->fp('rows','row',True);
121
122                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
123                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
124                                $select_section = '<select name="section">'."\n";
125                                foreach($acl_ok as $key => $val)
126                                {
127                                        $select_section .= ' <option value="'.$key.'"'.
128                                                ($key == $_POST['section'] ? ' selected' : '') . '>' .
129                                                ($key == 'mainscreen' ? lang('Main screen') : lang($key)) . "</option>\n";
130                                }
131                                $select_section .= '</select>';
132                                $GLOBALS['phpgw']->template->set_var('label',lang('Section'));
133                                $GLOBALS['phpgw']->template->set_var('value',$select_section);
134                                $GLOBALS['phpgw']->template->fp('rows','row',True);
135
136                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
137                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
138                                $GLOBALS['phpgw']->template->set_var('value','<input type="submit" value="' . lang('Edit')
139                                        . '"><input type="submit" name="cancel" value="'. lang('cancel') .'">');
140                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
141                        }
142                        else
143                        {
144                           $GLOBALS['phpgw']->db->query("SELECT content FROM phpgw_lang WHERE lang='$select_lang' AND message_id='$section"
145                                . "_message'",__LINE__,__FILE__);
146                                $GLOBALS['phpgw']->db->next_record();
147                               
148                                $current_message = $GLOBALS['phpgw']->db->f('content');
149                               
150                                $text_or_htmlarea.= '<script type="text/javascript" src="./library/ckeditor/ckeditor.js"></script>';
151                                $text_or_htmlarea.= '<textarea name="message">'.$current_message.'</textarea>';                         
152                                $text_or_htmlarea.= '<script type="text/javascript">'.
153                                                'CKEDITOR.replace( \'message\',{'.
154                                                'removePlugins : \'elementspath\','.
155                                                'skin : \'office2003\','.
156                                                'toolbar : \'Full\''.
157                                                '}'.
158                                                ');</script>';
159
160                                $GLOBALS['phpgw']->common->phpgw_header();
161                                echo parse_navbar();
162                               
163                                $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.index'));
164                                $GLOBALS['phpgw']->template->set_var('select_lang',$select_lang);
165                                $GLOBALS['phpgw']->template->set_var('section',$section);
166                                $GLOBALS['phpgw']->template->set_var('tr_color',$GLOBALS['phpgw_info']['theme']['th_bg']);
167                                $GLOBALS['phpgw']->template->set_var('value','&nbsp;');
168                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
169
170                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
171                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
172
173                               
174                                $GLOBALS['phpgw']->template->set_var('value',$text_or_htmlarea);
175                               
176                               
177                               
178                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
179
180                                $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
181                                $GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
182                                $GLOBALS['phpgw']->template->set_var('value','<input type="submit" name="submit" value="' . lang('Save')
183                                . '"><input type="submit" name="cancel" value="'. lang('cancel') .'">');
184                                $GLOBALS['phpgw']->template->fp('rows','row_2',True);
185                        }
186
187                        $GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
188                        $GLOBALS['phpgw']->template->set_var('error_message',$feedback_message);
189                        $GLOBALS['phpgw']->template->pfp('out','form');
190                }
191        }
192?>
Note: See TracBrowser for help on using the repository browser.