]> src.bluestatic.org Git - bugdar.git/blob - admin/language.php
Merge branch 'isso3' to do all 2.0 work on 'master'
[bugdar.git] / admin / language.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2008 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 2 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 APIError(array(new API_Error_Handler($admin), 'admin_error'));
26
27 NavLinks::optionsPages();
28 $navigator->set_focus('tab', 'options', null);
29
30 if (!can_perform('canadmintools'))
31 {
32 admin_login();
33 }
34
35 // ###################################################################
36
37 if (empty($_REQUEST['do']))
38 {
39 $_REQUEST['do'] = 'modify';
40 }
41
42 // ###################################################################
43
44 if ($_REQUEST['do'] == 'kill')
45 {
46 $language = new LanguageAPI();
47 $language->set('languageid', $input->in['languageid']);
48 $language->set_condition();
49 $language->delete();
50
51 $admin->redirect('language.php?do=modify');
52 }
53
54 // ###################################################################
55
56 if ($_REQUEST['do'] == 'delete')
57 {
58 $admin->page_confirm(T('Are you sure you want to delete this language?'), 'language.php', 'kill', array('languageid' => $input->inputClean('languageid', TYPE_UINT)));
59 }
60
61 // ###################################################################
62
63 if ($_POST['do'] == 'insert')
64 {
65 $language = new LanguageAPI();
66 $language->set('title', $input->in['title']);
67 $language->set('charset', $input->in['charset']);
68 $language->set('direction', $input->in['direction']);
69 $language->set('userselect', $input->in['userselect']);
70 $language->set('langcode', $input->in['langcode']);
71 $language->insert();
72
73 $admin->redirect('language.php?do=modify');
74 }
75
76 // ###################################################################
77
78 if ($_REQUEST['do'] == 'add')
79 {
80 NavLinks::languagesAdd();
81 $navigator->set_focus('link', 'options-languages-add', 'options-languages');
82
83 $admin->page_start(T('New Language'));
84
85 $admin->form_start('language.php', 'insert');
86 $admin->table_start();
87 $admin->table_head(T('New Language'));
88
89 $admin->row_input(T('Title'), 'title');
90 $admin->row_input(T('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');
91 $admin->row_input(T('Character Set'), 'charset', 'utf-8');
92 $admin->list_item(T('Left-to-Right'), 'ltr', true);
93 $admin->list_item(T('Right-to-Left'), 'rtl');
94 $admin->row_list(T('Direction'), 'direction');
95 $admin->row_yesno(T('User Selectable'), 'userselect', true);
96
97 $admin->row_submit();
98 $admin->table_end();
99 $admin->form_end();
100
101 $admin->page_end();
102 }
103
104 // ###################################################################
105
106 if ($_POST['do'] == 'update')
107 {
108 $language = new LanguageAPI();
109 $language->set('languageid', $input->in['languageid']);
110 $language->set_condition();
111 $language->set('title', $input->in['title']);
112 $language->set('charset', $input->in['charset']);
113 $language->set('direction', $input->in['direction']);
114 $language->set('userselect', $input->in['userselect']);
115 $language->set('langcode', $input->in['langcode']);
116 $language->update();
117
118 $admin->redirect('language.php?do=modify');
119 }
120
121 // ###################################################################
122
123 if ($_REQUEST['do'] == 'edit')
124 {
125 NavLinks::languagesEdit($input->in['languageid']);
126 $navigator->set_focus('link', 'options-languages-edit', 'options-languages');
127
128 $languageapi = new LanguageAPI();
129 $languageapi->set('languageid', $input->in['languageid']);
130 $languageapi->set_condition();
131 $languageapi->fetch();
132
133 $language =& $languageapi->record;
134
135 $admin->page_start(T('Edit Language'));
136
137 $admin->form_start('language.php', 'update');
138 $admin->table_start();
139 $admin->table_head(sprintf(T('Edit Language - %1$s'), $language['title']));
140
141 $admin->form_hidden_field('languageid', $language['languageid']);
142
143 $admin->row_input(T('Title'), 'title', $language['title']);
144 $admin->row_input(T('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']);
145 $admin->row_input(T('Character Set'), 'charset', $language['charset']);
146 $admin->list_item(T('Left-to-Right'), 'ltr', (($language['direction'] == 'ltr') ? true : false));
147 $admin->list_item(T('Right-to-Left'), 'rtl', (($language['direction'] == 'rtl') ? true : false));
148 $admin->row_list(T('Direction'), 'direction');
149 $admin->row_yesno(T('User Selectable'), 'userselect', $language['userselect']);
150
151 $admin->row_submit();
152 $admin->table_end();
153 $admin->form_end();
154
155 $admin->page_end();
156 }
157
158 // ###################################################################
159
160 if ($_REQUEST['do'] == 'modify')
161 {
162 NavLinks::languagesAdd();
163 $navigator->set_focus('link', 'options-pages-languages', 'options-pages');
164
165 $admin->page_start(T('Manage Languages'));
166
167 $admin->table_start();
168 $admin->table_head(T('Manage Languages'), 3, 'language_manage');
169
170 $admin->table_column_head(array(T('Title'), T('Language Code / Charset'), T('Options')));
171
172 $languages = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
173 foreach ($languages as $language)
174 {
175 $admin->row_multi_item(array(
176 "<a href=\"language.php?do=edit&amp;languageid=$language[languageid]\">$language[title]</a>" => 'l',
177 $language['langcode'] . ' / ' . $language['charset'] => 'c',
178 ((bugdar::$options['defaultlanguage'] == $language['languageid']) ? '<strong>' . T('DEFAULT LANGUAGE') . '</strong> / ' : '') . ($language['userselect'] ? T('User Selectable') : T('Private')) => 'c'
179 ));
180 }
181
182 $admin->table_end();
183
184 $admin->page_end();
185 }
186
187 ?>