r1052: Remove the localization table and the XML strings concept from the language...
[bugdar.git] / admin / language.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 require_once('./global.php');
23 require_once('./includes/api_language.php');
24
25 require_once('./includes/class_api_error.php');
26 APIError(array(new API_Error_Handler($admin), 'admin_error'));
27
28 NavLinks::optionsPages();
29 $navigator->set_focus('tab', 'options', null);
30
31 if (!can_perform('canadmintools'))
32 {
33 admin_login();
34 }
35
36 // ###################################################################
37
38 if (empty($_REQUEST['do']))
39 {
40 $_REQUEST['do'] = 'modify';
41 }
42
43 // ###################################################################
44
45 if ($_REQUEST['do'] == 'kill')
46 {
47 $language = new LanguageAPI($bugsys);
48 $language->set('languageid', $bugsys->in['languageid']);
49 $language->set_condition();
50 $language->insert();
51
52 $admin->redirect('language.php?do=modify');
53 }
54
55 // ###################################################################
56
57 if ($_REQUEST['do'] == 'delete')
58 {
59 $admin->page_confirm(_('Are you sure you want to delete this language?'), 'language.php?do=kill&amp;languageid=' . $bugsys->input_clean('languageid', TYPE_UINT));
60 }
61
62 // ###################################################################
63
64 if ($_POST['do'] == 'insert')
65 {
66 $language = new LanguageAPI($bugsys);
67 $language->set('title', $bugsys->in['title']);
68 $language->set('charset', $bugsys->in['charset']);
69 $language->set('direction', $bugsys->in['direction']);
70 $language->set('userselect', $bugsys->in['userselect']);
71 $language->set('debug', $bugsys->in['debug']);
72 $language->set('filename', $bugsys->in['filename']);
73 $language->insert();
74
75 $admin->redirect('language.php?do=modify');
76 }
77
78 // ###################################################################
79
80 if ($_REQUEST['do'] == 'add')
81 {
82 NavLinks::languagesAdd();
83 $navigator->set_focus('link', 'options-languages-add', 'options-languages');
84
85 $admin->page_start(_('New Language'));
86
87 $admin->form_start('language.php', 'insert');
88 $admin->table_start();
89 $admin->table_head(_('New Language'));
90
91 $admin->row_input(_('Title'), 'title');
92 $admin->row_input(_('Character Set'), 'charset', 'utf-8');
93 $admin->list_item(_('Left-to-Right'), 'ltr', true);
94 $admin->list_item(_('Right-to-Left'), 'rtl');
95 $admin->row_list(_('Direction'), 'direction');
96 $admin->row_input(_('Path to XML'), 'filename');
97 $admin->row_yesno(_('User Selectable'), 'userselect', true);
98 $admin->row_yesno(_('Debug Mode (run directly from XML)'), 'langdebug', false);
99
100 $admin->row_submit();
101 $admin->table_end();
102 $admin->form_end();
103
104 $admin->page_end();
105 }
106
107 // ###################################################################
108
109 if ($_POST['do'] == 'update')
110 {
111 $language = new LanguageAPI($bugsys);
112 $language->set('languageid', $bugsys->in['languageid']);
113 $language->set_condition();
114 $language->set('title', $bugsys->in['title']);
115 $language->set('charset', $bugsys->in['charset']);
116 $language->set('direction', $bugsys->in['direction']);
117 $language->set('userselect', $bugsys->in['userselect']);
118 $language->set('debug', $bugsys->in['debug']);
119 $language->set('filename', $bugsys->in['filename']);
120 $language->update();
121
122 $admin->redirect('language.php?do=modify');
123 }
124
125 // ###################################################################
126
127 if ($_REQUEST['do'] == 'edit')
128 {
129 NavLinks::languagesEdit($bugsys->in['languageid']);
130 $navigator->set_focus('link', 'options-languages-edit', 'options-languages');
131
132 $languageapi = new LanguageAPI($bugsys);
133 $languageapi->set('languageid', $bugsys->in['languageid']);
134 $languageapi->set_condition();
135 $languageapi->fetch();
136
137 $language =& $languageapi->objdata;
138
139 $admin->page_start(_('Edit Language'));
140
141 $admin->form_start('language.php', 'update');
142 $admin->table_start();
143 $admin->table_head(sprintf(_('Edit Language - %1$s'), $language['title']));
144
145 $admin->form_hidden_field('languageid', $language['languageid']);
146
147 $admin->row_input(_('Title'), 'title', $language['title']);
148 $admin->row_input(_('Character Set'), 'charset', $language['charset']);
149 $admin->list_item(_('Left-to-Right'), 'ltr', (($language['direction'] == 'ltr') ? true : false));
150 $admin->list_item(_('Right-to-Left'), 'rtl', (($language['direction'] == 'rtl') ? true : false));
151 $admin->row_list(_('Direction'), 'direction');
152 $admin->row_input(_('Path to XML'), 'filename', $language['filename']);
153 $admin->row_yesno(_('User Selectable'), 'userselect', $language['userselect']);
154 $admin->row_yesno(_('Debug Mode (run directly from XML)'), 'langdebug', (bool)$language['debug']);
155
156 $admin->row_submit();
157 $admin->table_end();
158 $admin->form_end();
159
160 $admin->page_end();
161 }
162
163 // ###################################################################
164
165 if ($_REQUEST['do'] == 'reload')
166 {
167 $language = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "language WHERE languageid = " . $bugsys->input_clean('languageid', TYPE_UINT));
168 if (!$language)
169 {
170 $admin->error($lang->getlex('error_invalid_id'));
171 }
172
173 build_language_cache($language['languageid']);
174
175 $admin->redirect('language.php?do=modify');
176 }
177
178 // ###################################################################
179
180 if ($_REQUEST['do'] == 'modify')
181 {
182 NavLinks::languagesAdd();
183 $navigator->set_focus('link', 'options-pages-languages', 'options-pages');
184
185 $admin->page_start(_('Manage Languages'));
186
187 $admin->table_start();
188 $admin->table_head(_('Manage Languages'), 3, 'language_manage');
189
190 $admin->table_column_head(array(_('Title'), _('Charset'), _('Options')));
191
192 $languages = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
193 while ($language = $db->fetch_array($languages))
194 {
195 $admin->row_multi_item(array(
196 "<a href=\"language.php?do=edit&amp;languageid=$language[languageid]\">$language[title]</a>" => 'l',
197 $language['charset'] => 'c',
198 (($bugsys->options['defaultlanguage'] == $language['languageid']) ? '<strong>' . _('DEFAULT LANGUAGE') . '</strong> / ' : '') . ($language['userselect'] ? _('User Selectable') : _('Private')) => 'c'
199 ));
200 }
201
202 $admin->table_end();
203
204 $admin->page_end();
205 }
206
207 /*=====================================================================*\
208 || ###################################################################
209 || # $HeadURL$
210 || # $Id$
211 || ###################################################################
212 \*=====================================================================*/
213 ?>