2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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.
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
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 \*=====================================================================*/
22 require_once('./global.php');
23 require_once('./includes/functions_datastore.php');
25 if (!can_perform('canadmintools'))
30 // ###################################################################
32 if (empty($_REQUEST['do']))
34 $_REQUEST['do'] = 'modify';
37 // ###################################################################
39 if ($_REQUEST['do'] == 'kill')
41 $count = $db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX
. "language");
42 if ($count['count'] < 2)
44 $admin->error($lang->string('At least one language needs to be present. Deleting this language would violate that.'));
47 if ($bugsys->options
['defaultlanguage'] == intval($bugsys->in
['languageid']))
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.'));
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']));
55 $admin->redirect('language.php?do=modify');
58 // ###################################################################
60 if ($_REQUEST['do'] == 'delete')
62 $admin->page_confirm($lang->string('Are you sure you want to delete this language?'), 'language.php?do=kill&languageid=' . intval($bugsys->in
['languageid']));
65 // ###################################################################
67 if ($_POST['do'] == 'insert')
69 $languageid = $db->query("
70 INSERT INTO " . TABLE_PREFIX
. "language
71 (title, charset, direction, userselect, debug, filename)
73 ('" . $bugsys->in
['title'] . "', '" . $bugsys->in
['charset'] . "',
74 '" . $bugsys->in
['direction'] . "', " . intval($bugsys->in
['userselect']) . ",
75 " . intval($bugsys->in
['debug']) . ", '" . $bugsys->in
['filename'] . "'
81 build_language_cache($db->insert_id());
83 $admin->redirect('language.php?do=modify');
86 // ###################################################################
88 if ($_REQUEST['do'] == 'add')
90 $admin->page_start($lang->string('New Language'));
92 $admin->form_start('language.php', 'insert');
93 $admin->table_start();
94 $admin->table_head($lang->string('New Language'), 2, 'language_edit');
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
);
105 $admin->row_submit();
112 // ###################################################################
114 if ($_POST['do'] == 'update')
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'])
129 $admin->redirect('language.php?do=modify');
132 // ###################################################################
134 if ($_REQUEST['do'] == 'edit')
136 $language = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "language WHERE languageid = " . intval($bugsys->in
['languageid']));
139 $admin->error($lang->getlex('error_invalid_id'));
142 $admin->page_start($lang->string('Edit Language'));
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');
148 $admin->form_hidden_field('languageid', $language['languageid']);
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']);
159 $admin->row_submit('<a href="language.php?do=delete&languageid=' . $language['languageid'] . '">[' . $lang->string('Delete') . ']</a>');
166 // ###################################################################
168 if ($_REQUEST['do'] == 'reload')
170 $language = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "language WHERE languageid = " . intval($bugsys->in
['languageid']));
173 $admin->error($lang->getlex('error_invalid_id'));
176 build_language_cache($language['languageid']);
178 $admin->redirect('language.php?do=modify');
181 // ###################################################################
183 if ($_REQUEST['do'] == 'modify')
185 $admin->page_start($lang->string('Manage Languages'));
187 $admin->table_start();
188 $admin->table_head($lang->string('Manage Languages'), 4, 'language_manage');
190 $admin->table_column_head(array($lang->string('Title'), $lang->string('Charset'), $lang->string('Options'), $lang->string('Actions')));
192 $languages = $db->query("SELECT * FROM " . TABLE_PREFIX
. "language ORDER BY languageid ASC");
193 while ($language = $db->fetch_array($languages))
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&languageid=$language[languageid]\">[" . $lang->string('Edit Settings') . "]</a> <a href=\"language.php?do=reload&languageid=$language[languageid]\">[" . $lang->string('Reload XML') . "]</a>" => 'c'
203 $admin->row_span('<a href="language.php?do=add">[' . $lang->string('Add New Language') . ']</a>', 'tfoot', 'center', 4);
209 /*=====================================================================*\
210 || ###################################################################
213 || ###################################################################
214 \*=====================================================================*/