Switch the 'modify' code of admin/field.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 'language_edit'
25 );
26
27 require_once('./global.php');
28 require_once('./includes/api_language.php');
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->setCondition();
49 $language->delete();
50
51 admin_flash_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_flash_redirect('language.php?do=modify');
74 }
75
76 // ###################################################################
77
78 if ($_REQUEST['do'] == 'add')
79 {
80 BSTemplate::fetch('language_edit')->evaluate()->flush();
81 }
82
83 // ###################################################################
84
85 if ($_POST['do'] == 'update')
86 {
87 $language = new LanguageAPI();
88 $language->set('languageid', $input->in['languageid']);
89 $language->setCondition();
90 $language->set('title', $input->in['title']);
91 $language->set('charset', $input->in['charset']);
92 $language->set('direction', $input->in['direction']);
93 $language->set('userselect', $input->in['userselect']);
94 $language->set('langcode', $input->in['langcode']);
95 $language->update();
96
97 admin_flash_redirect('language.php?do=modify');
98 }
99
100 // ###################################################################
101
102 if ($_REQUEST['do'] == 'edit')
103 {
104 $languageapi = new LanguageAPI();
105 $languageapi->set('languageid', $input->in['languageid']);
106 $languageapi->setCondition();
107 $languageapi->fetch();
108
109 $admin = new BSTemplate('language_edit');
110 $admin->vars['language'] = $language->record;
111 $admin->evaluate()->flush();
112 }
113
114 // ###################################################################
115
116 if ($_REQUEST['do'] == 'modify')
117 {
118 $admin = new BSTemplate('language');
119 $admin->vars['languages'] = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
120 $admin->evaluate()->flush();
121 }
122
123 ?>