]> src.bluestatic.org Git - bugdar.git/blob - admin/language.php
r836: Implementing user API in userctrl.php
[bugdar.git] / admin / language.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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/functions_datastore.php');
24
25 if (!can_perform('canadmintools'))
26 {
27 admin_login();
28 }
29
30 // ###################################################################
31
32 if (empty($_REQUEST['do']))
33 {
34 $_REQUEST['do'] = 'modify';
35 }
36
37 // ###################################################################
38
39 if ($_REQUEST['do'] == 'kill')
40 {
41 $count = $db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "language");
42 if ($count['count'] < 2)
43 {
44 $admin->error($lang->string('At least one language needs to be present. Deleting this language would violate that.'));
45 }
46
47 if ($bugsys->options['defaultlanguage'] == intval($bugsys->in['languageid']))
48 {
49 $admin->error($lang->string('You cannot delete the default language. Please select another language to be the default language and then delete this one.'));
50 }
51
52 $db->query("DELETE FROM " . TABLE_PREFIX . "language WHERE languageid = " . intval($bugsys->in['languageid']));
53 $db->query("DELETE FROM " . TABLE_PREFIX . "localization WHERE languageid = " . intval($bugsys->in['languageid']));
54 build_languages();
55 $admin->redirect('language.php?do=modify');
56 }
57
58 // ###################################################################
59
60 if ($_REQUEST['do'] == 'delete')
61 {
62 $admin->page_confirm($lang->string('Are you sure you want to delete this language?'), 'language.php?do=kill&amp;languageid=' . intval($bugsys->in['languageid']));
63 }
64
65 // ###################################################################
66
67 if ($_POST['do'] == 'insert')
68 {
69 $languageid = $db->query("
70 INSERT INTO " . TABLE_PREFIX . "language
71 (title, charset, direction, userselect, debug, filename)
72 VALUES
73 ('" . $bugsys->in['title'] . "', '" . $bugsys->in['charset'] . "',
74 '" . $bugsys->in['direction'] . "', " . intval($bugsys->in['userselect']) . ",
75 " . intval($bugsys->in['debug']) . ", '" . $bugsys->in['filename'] . "'
76 )"
77 );
78
79 build_languages();
80
81 build_language_cache($db->insert_id());
82
83 $admin->redirect('language.php?do=modify');
84 }
85
86 // ###################################################################
87
88 if ($_REQUEST['do'] == 'add')
89 {
90 $admin->page_start($lang->string('New Language'));
91
92 $admin->form_start('language.php', 'insert');
93 $admin->table_start();
94 $admin->table_head($lang->string('New Language'), 2, 'language_edit');
95
96 $admin->row_input($lang->string('Title'), 'title');
97 $admin->row_input($lang->string('Character Set'), 'charset', 'utf-8');
98 $admin->list_item($lang->string('Left-to-Right'), 'ltr', true);
99 $admin->list_item($lang->string('Right-to-Left'), 'rtl');
100 $admin->row_list($lang->string('Direction'), 'direction');
101 $admin->row_input($lang->string('Path to XML'), 'filename');
102 $admin->row_yesno($lang->string('User Selectable'), 'userselect', true);
103 $admin->row_yesno($lang->string('Debug Mode (run directly from XML)'), 'langdebug', false);
104
105 $admin->row_submit();
106 $admin->table_end();
107 $admin->form_end();
108
109 $admin->page_end();
110 }
111
112 // ###################################################################
113
114 if ($_POST['do'] == 'update')
115 {
116 $db->query("
117 UPDATE " . TABLE_PREFIX . "language
118 SET title = '" . $bugsys->in['title'] . "',
119 charset = '" . $bugsys->in['charset'] . "',
120 direction = '" . $bugsys->in['direction'] . "',
121 userselect = " . intval($bugsys->in['userselect']) . ",
122 debug = " . intval($bugsys->in['langdebug']) . ",
123 filename = '" . $bugsys->in['filename'] . "'
124 WHERE languageid = " . intval($bugsys->in['languageid'])
125 );
126
127 build_languages();
128
129 $admin->redirect('language.php?do=modify');
130 }
131
132 // ###################################################################
133
134 if ($_REQUEST['do'] == 'edit')
135 {
136 $language = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "language WHERE languageid = " . intval($bugsys->in['languageid']));
137 if (!$language)
138 {
139 $admin->error($lang->getlex('error_invalid_id'));
140 }
141
142 $admin->page_start($lang->string('Edit Language'));
143
144 $admin->form_start('language.php', 'update');
145 $admin->table_start();
146 $admin->table_head(sprintf($lang->string('Edit Language - %1$s'), $language['title']), 2, 'language_edit');
147
148 $admin->form_hidden_field('languageid', $language['languageid']);
149
150 $admin->row_input($lang->string('Title'), 'title', $language['title']);
151 $admin->row_input($lang->string('Character Set'), 'charset', $language['charset']);
152 $admin->list_item($lang->string('Left-to-Right'), 'ltr', (($language['direction'] == 'ltr') ? true : false));
153 $admin->list_item($lang->string('Right-to-Left'), 'rtl', (($language['direction'] == 'rtl') ? true : false));
154 $admin->row_list($lang->string('Direction'), 'direction');
155 $admin->row_input($lang->string('Path to XML'), 'filename', $language['filename']);
156 $admin->row_yesno($lang->string('User Selectable'), 'userselect', $language['userselect']);
157 $admin->row_yesno($lang->string('Debug Mode (run directly from XML)'), 'langdebug', (bool)$language['debug']);
158
159 $admin->row_submit('<a href="language.php?do=delete&amp;languageid=' . $language['languageid'] . '">[' . $lang->string('Delete') . ']</a>');
160 $admin->table_end();
161 $admin->form_end();
162
163 $admin->page_end();
164 }
165
166 // ###################################################################
167
168 if ($_REQUEST['do'] == 'reload')
169 {
170 $language = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "language WHERE languageid = " . intval($bugsys->in['languageid']));
171 if (!$language)
172 {
173 $admin->error($lang->getlex('error_invalid_id'));
174 }
175
176 build_language_cache($language['languageid']);
177
178 $admin->redirect('language.php?do=modify');
179 }
180
181 // ###################################################################
182
183 if ($_REQUEST['do'] == 'modify')
184 {
185 $admin->page_start($lang->string('Manage Languages'));
186
187 $admin->table_start();
188 $admin->table_head($lang->string('Manage Languages'), 4, 'language_manage');
189
190 $admin->table_column_head(array($lang->string('Title'), $lang->string('Charset'), $lang->string('Options'), $lang->string('Actions')));
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 $language['title'] => 'l',
197 $language['charset'] => 'c',
198 (($bugsys->options['defaultlanguage'] == $language['languageid']) ? '<strong>' . $lang->string('DEFAULT LANGUAGE') . '</strong> / ' : '') . ($language['userselect'] ? $lang->string('User Selectable') : $lang->string('Private')) => 'c',
199 "<a href=\"language.php?do=edit&amp;languageid=$language[languageid]\">[" . $lang->string('Edit Settings') . "]</a> <a href=\"language.php?do=reload&amp;languageid=$language[languageid]\">[" . $lang->string('Reload XML') . "]</a>" => 'c'
200 ));
201 }
202
203 $admin->row_span('<a href="language.php?do=add">[' . $lang->string('Add New Language') . ']</a>', 'tfoot', 'center', 4);
204 $admin->table_end();
205
206 $admin->page_end();
207 }
208
209 /*=====================================================================*\
210 || ###################################################################
211 || # $HeadURL$
212 || # $Id$
213 || ###################################################################
214 \*=====================================================================*/
215 ?>