r1062: Okay. Domain isn't the right word. So I'll change it agian.
[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('langcode', $bugsys->in['langcode']);
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(_('Gettext Language Code (<em><a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_15.html">language</a></em>_<em><a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html">COUNTRY</a></em>)'), 'langcode');
93 $admin->row_input(_('Character Set'), 'charset', 'utf-8');
94 $admin->list_item(_('Left-to-Right'), 'ltr', true);
95 $admin->list_item(_('Right-to-Left'), 'rtl');
96 $admin->row_list(_('Direction'), 'direction');
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('langcode', $bugsys->in['langcode']);
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(_('Gettext Language Code (<em><a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_15.html">language</a></em>_<em><a href="http://www.gnu.org/software/gettext/manual/html_chapter/gettext_16.html">COUNTRY</a></em>)'), 'langcode', $language['langcode']);
149 $admin->row_input(_('Character Set'), 'charset', $language['charset']);
150 $admin->list_item(_('Left-to-Right'), 'ltr', (($language['direction'] == 'ltr') ? true : false));
151 $admin->list_item(_('Right-to-Left'), 'rtl', (($language['direction'] == 'rtl') ? true : false));
152 $admin->row_list(_('Direction'), 'direction');
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'] == 'modify')
166 {
167 NavLinks::languagesAdd();
168 $navigator->set_focus('link', 'options-pages-languages', 'options-pages');
169
170 $admin->page_start(_('Manage Languages'));
171
172 $admin->table_start();
173 $admin->table_head(_('Manage Languages'), 3, 'language_manage');
174
175 $admin->table_column_head(array(_('Title'), _('Language Code / Charset'), _('Options')));
176
177 $languages = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
178 while ($language = $db->fetch_array($languages))
179 {
180 $admin->row_multi_item(array(
181 "<a href=\"language.php?do=edit&amp;languageid=$language[languageid]\">$language[title]</a>" => 'l',
182 $language['langcode'] . ' / ' . $language['charset'] => 'c',
183 (($bugsys->options['defaultlanguage'] == $language['languageid']) ? '<strong>' . _('DEFAULT LANGUAGE') . '</strong> / ' : '') . ($language['userselect'] ? _('User Selectable') : _('Private')) => 'c'
184 ));
185 }
186
187 $admin->table_end();
188
189 $admin->page_end();
190 }
191
192 /*=====================================================================*\
193 || ###################################################################
194 || # $HeadURL$
195 || # $Id$
196 || ###################################################################
197 \*=====================================================================*/
198 ?>