]> src.bluestatic.org Git - bugdar.git/blob - admin/language.php
r1384: It was actually bug 66...
[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->delete();
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', 'kill', array('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('langcode', $bugsys->in['langcode']);
72 $language->insert();
73
74 $admin->redirect('language.php?do=modify');
75 }
76
77 // ###################################################################
78
79 if ($_REQUEST['do'] == 'add')
80 {
81 NavLinks::languagesAdd();
82 $navigator->set_focus('link', 'options-languages-add', 'options-languages');
83
84 $admin->page_start(_('New Language'));
85
86 $admin->form_start('language.php', 'insert');
87 $admin->table_start();
88 $admin->table_head(_('New Language'));
89
90 $admin->row_input(_('Title'), 'title');
91 $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');
92 $admin->row_input(_('Character Set'), 'charset', 'utf-8');
93 $admin->list_item(_('Left-to-Right'), 'ltr', true);
94 $admin->list_item(_('Right-to-Left'), 'rtl');
95 $admin->row_list(_('Direction'), 'direction');
96 $admin->row_yesno(_('User Selectable'), 'userselect', true);
97
98 $admin->row_submit();
99 $admin->table_end();
100 $admin->form_end();
101
102 $admin->page_end();
103 }
104
105 // ###################################################################
106
107 if ($_POST['do'] == 'update')
108 {
109 $language = new LanguageAPI($bugsys);
110 $language->set('languageid', $bugsys->in['languageid']);
111 $language->set_condition();
112 $language->set('title', $bugsys->in['title']);
113 $language->set('charset', $bugsys->in['charset']);
114 $language->set('direction', $bugsys->in['direction']);
115 $language->set('userselect', $bugsys->in['userselect']);
116 $language->set('langcode', $bugsys->in['langcode']);
117 $language->update();
118
119 $admin->redirect('language.php?do=modify');
120 }
121
122 // ###################################################################
123
124 if ($_REQUEST['do'] == 'edit')
125 {
126 NavLinks::languagesEdit($bugsys->in['languageid']);
127 $navigator->set_focus('link', 'options-languages-edit', 'options-languages');
128
129 $languageapi = new LanguageAPI($bugsys);
130 $languageapi->set('languageid', $bugsys->in['languageid']);
131 $languageapi->set_condition();
132 $languageapi->fetch();
133
134 $language =& $languageapi->objdata;
135
136 $admin->page_start(_('Edit Language'));
137
138 $admin->form_start('language.php', 'update');
139 $admin->table_start();
140 $admin->table_head(sprintf(_('Edit Language - %1$s'), $language['title']));
141
142 $admin->form_hidden_field('languageid', $language['languageid']);
143
144 $admin->row_input(_('Title'), 'title', $language['title']);
145 $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']);
146 $admin->row_input(_('Character Set'), 'charset', $language['charset']);
147 $admin->list_item(_('Left-to-Right'), 'ltr', (($language['direction'] == 'ltr') ? true : false));
148 $admin->list_item(_('Right-to-Left'), 'rtl', (($language['direction'] == 'rtl') ? true : false));
149 $admin->row_list(_('Direction'), 'direction');
150 $admin->row_yesno(_('User Selectable'), 'userselect', $language['userselect']);
151
152 $admin->row_submit();
153 $admin->table_end();
154 $admin->form_end();
155
156 $admin->page_end();
157 }
158
159 // ###################################################################
160
161 if ($_REQUEST['do'] == 'modify')
162 {
163 NavLinks::languagesAdd();
164 $navigator->set_focus('link', 'options-pages-languages', 'options-pages');
165
166 $admin->page_start(_('Manage Languages'));
167
168 $admin->table_start();
169 $admin->table_head(_('Manage Languages'), 3, 'language_manage');
170
171 $admin->table_column_head(array(_('Title'), _('Language Code / Charset'), _('Options')));
172
173 $languages = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
174 while ($language = $db->fetch_array($languages))
175 {
176 $admin->row_multi_item(array(
177 "<a href=\"language.php?do=edit&amp;languageid=$language[languageid]\">$language[title]</a>" => 'l',
178 $language['langcode'] . ' / ' . $language['charset'] => 'c',
179 (($bugsys->options['defaultlanguage'] == $language['languageid']) ? '<strong>' . _('DEFAULT LANGUAGE') . '</strong> / ' : '') . ($language['userselect'] ? _('User Selectable') : _('Private')) => 'c'
180 ));
181 }
182
183 $admin->table_end();
184
185 $admin->page_end();
186 }
187
188 /*=====================================================================*\
189 || ###################################################################
190 || # $HeadURL$
191 || # $Id$
192 || ###################################################################
193 \*=====================================================================*/
194 ?>