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