Update the admin/language.php to use templates
[bugdar.git] / admin / language.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2009 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 $fetchtemplates = array(
23 'language'
24 );
25
26 require_once('./global.php');
27 require_once('./includes/api_language.php');
28
29 if (!can_perform('canadmintools'))
30 {
31 admin_login();
32 }
33
34 // ###################################################################
35
36 if (empty($_REQUEST['do']))
37 {
38 $_REQUEST['do'] = 'modify';
39 }
40
41 // ###################################################################
42
43 if ($_REQUEST['do'] == 'kill')
44 {
45 $language = new LanguageAPI();
46 $language->set('languageid', $input->in['languageid']);
47 $language->setCondition();
48 $language->delete();
49
50 admin_flash_redirect('language.php?do=modify');
51 }
52
53 // ###################################################################
54
55 if ($_REQUEST['do'] == 'delete')
56 {
57 $admin->page_confirm(T('Are you sure you want to delete this language?'), 'language.php', 'kill', array('languageid' => $input->inputClean('languageid', TYPE_UINT)));
58 }
59
60 // ###################################################################
61
62 if ($_POST['do'] == 'insert')
63 {
64 $language = new LanguageAPI();
65 $language->set('title', $input->in['title']);
66 $language->set('charset', $input->in['charset']);
67 $language->set('direction', $input->in['direction']);
68 $language->set('userselect', $input->in['userselect']);
69 $language->set('langcode', $input->in['langcode']);
70 $language->insert();
71
72 admin_flash_redirect('language.php?do=modify');
73 }
74
75 // ###################################################################
76
77 if ($_REQUEST['do'] == 'add')
78 {
79 BSTemplate::fetch('language_edit')->evaluate()->flush();
80 }
81
82 // ###################################################################
83
84 if ($_POST['do'] == 'update')
85 {
86 $language = new LanguageAPI();
87 $language->set('languageid', $input->in['languageid']);
88 $language->setCondition();
89 $language->set('title', $input->in['title']);
90 $language->set('charset', $input->in['charset']);
91 $language->set('direction', $input->in['direction']);
92 $language->set('userselect', $input->in['userselect']);
93 $language->set('langcode', $input->in['langcode']);
94 $language->update();
95
96 admin_flash_redirect('language.php?do=modify');
97 }
98
99 // ###################################################################
100
101 if ($_REQUEST['do'] == 'edit')
102 {
103 $languageapi = new LanguageAPI();
104 $languageapi->set('languageid', $input->in['languageid']);
105 $languageapi->setCondition();
106 $languageapi->fetch();
107
108 $admin = new BSTemplate('language_edit');
109 $admin->vars['language'] = $language->record;
110 $admin->evaluate()->flush();
111 }
112
113 // ###################################################################
114
115 if ($_REQUEST['do'] == 'modify')
116 {
117 $admin = new BSTemplate('language');
118 $admin->vars['languages'] = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
119 $admin->evaluate()->flush();
120 }
121
122 ?>