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 \*=====================================================================*/
13 require_once('./global.php');
14 require_once('./includes/functions_datastore.php');
16 if (!can_perform('canadmintools'))
21 // ###################################################################
23 if (empty($_REQUEST['do']))
25 $_REQUEST['do'] = 'modify';
28 // ###################################################################
30 if ($_REQUEST['do'] == 'kill')
32 $count = $db->query_first("SELECT COUNT(*) AS count FROM language");
33 if ($count['count'] < 2)
35 $admin->error($lang->string('At least one language needs to be present. Deleting this language would violate that.'));
38 $language = $db->query_first("SELECT * FROM language WHERE languageid = " . intval($bugsys->in
['languageid']));
39 if ($language['default'])
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.'));
44 $db->query("DELETE FROM language WHERE languageid = " . intval($bugsys->in
['languageid']));
45 $db->query("DELETE FROM localization WHERE languageid = " . intval($bugsys->in
['languageid']));
47 $admin->redirect('language.php?do=modify');
50 // ###################################################################
52 if ($_REQUEST['do'] == 'delete')
54 $admin->page_confirm($lang->string('Are you sure you want to delete this language?'), 'language.php?do=kill&languageid=' . intval($bugsys->in
['languageid']));
57 // ###################################################################
59 if ($_POST['do'] == 'insert')
61 $languageid = $db->query("
63 (title, charset, direction, userselect, debug, filename)
65 ('" . $bugsys->in
['title'] . "', '" . $bugsys->in
['charset'] . "',
66 '" . $bugsys->in
['direction'] . "', " . intval($bugsys->in
['userselect']) . ",
67 " . intval($bugsys->in
['debug']) . ", '" . $bugsys->in
['filename'] . "'
73 build_language_cache($languageid);
76 // ###################################################################
78 if ($_REQUEST['do'] == 'add')
80 $admin->page_start($lang->string('New Language'));
82 $admin->form_start('language.php', 'update');
83 $admin->table_start();
84 $admin->table_head($lang->string('New Language'));
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
);
102 // ###################################################################
104 if ($_POST['do'] == 'update')
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'])
119 $admin->redirect('language.php?do=modify');
122 // ###################################################################
124 if ($_REQUEST['do'] == 'edit')
126 $language = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "language WHERE languageid = " . intval($bugsys->in
['languageid']));
129 $admin->error($lang->getlex('error_invalid_id'));
132 $admin->page_start($lang->string('Edit Language'));
134 $admin->form_start('language.php', 'update');
135 $admin->table_start();
136 $admin->table_head(sprintf($lang->string('Edit Language - %1$s'), $language['title']));
138 $admin->form_hidden_field('languageid', $language['languageid']);
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']);
149 $admin->row_submit();
156 // ###################################################################
158 if ($_REQUEST['do'] == 'reload')
160 $language = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "language WHERE languageid = " . intval($bugsys->in
['languageid']));
163 $admin->error($lang->getlex('error_invalid_id'));
166 build_language_cache($language['languageid']);
168 $admin->redirect('language.php?do=modify');
171 // ###################################################################
173 if ($_REQUEST['do'] == 'modify')
175 $admin->page_start($lang->string('Manage Languages'));
177 $admin->table_start();
178 $admin->table_head($lang->string('Manage Languages'), 4);
180 $admin->table_column_head(array($lang->string('Title'), $lang->string('Charset'), $lang->string('Options'), $lang->string('Actions')));
182 $languages = $db->query("SELECT * FROM " . TABLE_PREFIX
. "language ORDER BY languageid ASC");
183 while ($language = $db->fetch_array($languages))
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&languageid=$language[languageid]\">[" . $lang->string('Edit Settings') . "]</a> <a href=\"language.php?do=reload&languageid=$language[languageid]\">[" . $lang->string('Reload Language XML') . "]</a>" => 'c'
193 $admin->row_span('<a href="language.php?do=add">[' . $lang->string('Add New Language') . ']</a>', 'tfoot', 'center', 4);
199 /*=====================================================================*\
200 || ###################################################################
203 || ###################################################################
204 \*=====================================================================*/