]>
src.bluestatic.org Git - bugdar.git/blob - admin/language.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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.
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
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 \*=====================================================================*/
22 // #*# create API for language.php
24 require_once ( './global.php' );
25 require_once ( './includes/functions_datastore.php' );
27 NavLinks
:: optionsPages ();
28 $navigator- > set_focus ( 'tab' , 'options' , null );
30 if (! can_perform ( 'canadmintools' ))
35 // ###################################################################
37 if ( empty ( $_REQUEST [ 'do' ]))
39 $_REQUEST [ 'do' ] = 'modify' ;
42 // ###################################################################
44 if ( $_REQUEST [ 'do' ] == 'kill' )
46 $bugsys- > input_clean ( 'languageid' , TYPE_UINT
);
47 $count = $db- > query_first ( "SELECT COUNT(*) AS count FROM " . TABLE_PREFIX
. "language" );
48 if ( $count [ 'count' ] < 2 )
50 $admin- > error ( $lang- > string ( 'At least one language needs to be present. Deleting this language would violate that.' ));
53 if ( $bugsys- > options
[ 'defaultlanguage' ] == $bugsys- > in
[ 'languageid' ])
55 $admin- > error ( $lang- > string ( 'You cannot delete the default language. Please select another language to be the default language and then delete this one.' ));
58 $db- > query ( "DELETE FROM " . TABLE_PREFIX
. "language WHERE languageid = " . $bugsys- > in
[ 'languageid' ]);
59 $db- > query ( "DELETE FROM " . TABLE_PREFIX
. "localization WHERE languageid = " . $bugsys- > in
[ 'languageid' ]);
61 $admin- > redirect ( 'language.php?do=modify' );
64 // ###################################################################
66 if ( $_REQUEST [ 'do' ] == 'delete' )
68 $admin- > page_confirm ( $lang- > string ( 'Are you sure you want to delete this language?' ), 'language.php?do=kill&languageid=' . $bugsys- > input_clean ( 'languageid' , TYPE_UINT
));
71 // ###################################################################
73 if ( $_POST [ 'do' ] == 'insert' )
75 $languageid = $db- > query ( "
76 INSERT INTO " . TABLE_PREFIX
. "language
77 (title, charset, direction, userselect, debug, filename)
79 ('" . $bugsys- > in
[ 'title' ] . "', '" . $bugsys- > in
[ 'charset' ] . "',
80 '" . $bugsys- > in
[ 'direction' ] . "', " . $bugsys- > input_clean ( 'userselect' , TYPE_UINT
) . ",
81 " . $bugsys- > input_clean ( 'debug' , TYPE_UINT
) . ", '" . $bugsys- > in
[ 'filename' ] . "'
87 build_language_cache ( $db- > insert_id ());
89 $admin- > redirect ( 'language.php?do=modify' );
92 // ###################################################################
94 if ( $_REQUEST [ 'do' ] == 'add' )
96 NavLinks
:: languagesAdd ();
97 $navigator- > set_focus ( 'link' , 'options-languages-add' , 'options-languages' );
99 $admin- > page_start ( $lang- > string ( 'New Language' ));
101 $admin- > form_start ( 'language.php' , 'insert' );
102 $admin- > table_start ();
103 $admin- > table_head ( $lang- > string ( 'New Language' ));
105 $admin- > row_input ( $lang- > string ( 'Title' ), 'title' );
106 $admin- > row_input ( $lang- > string ( 'Character Set' ), 'charset' , 'utf-8' );
107 $admin- > list_item ( $lang- > string ( 'Left-to-Right' ), 'ltr' , true );
108 $admin- > list_item ( $lang- > string ( 'Right-to-Left' ), 'rtl' );
109 $admin- > row_list ( $lang- > string ( 'Direction' ), 'direction' );
110 $admin- > row_input ( $lang- > string ( 'Path to XML' ), 'filename' );
111 $admin- > row_yesno ( $lang- > string ( 'User Selectable' ), 'userselect' , true );
112 $admin- > row_yesno ( $lang- > string ( 'Debug Mode (run directly from XML)' ), 'langdebug' , false );
114 $admin- > row_submit ();
121 // ###################################################################
123 if ( $_POST [ 'do' ] == 'update' )
126 UPDATE " . TABLE_PREFIX
. "language
127 SET title = '" . $bugsys- > in
[ 'title' ] . "',
128 charset = '" . $bugsys- > in
[ 'charset' ] . "',
129 direction = '" . $bugsys- > in
[ 'direction' ] . "',
130 userselect = " . $bugsys- > input_clean ( 'userselect' , TYPE_UINT
) . ",
131 debug = " . $bugsys- > input_clean ( 'langdebug' , TYPE_UINT
) . ",
132 filename = '" . $bugsys- > in
[ 'filename' ] . "'
133 WHERE languageid = " . $bugsys- > input_clean ( 'languageid' , TYPE_UINT
)
138 $admin- > redirect ( 'language.php?do=modify' );
141 // ###################################################################
143 if ( $_REQUEST [ 'do' ] == 'edit' )
145 $bugsys- > input_clean ( 'languageid' , TYPE_UINT
);
147 NavLinks
:: languagesEdit ( $bugsys- > in
[ 'languageid' ]);
148 $navigator- > set_focus ( 'link' , 'options-languages-edit' , 'options-languages' );
150 $language = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "language WHERE languageid = " . $bugsys- > in
[ 'languageid' ]);
153 $admin- > error ( $lang- > getlex ( 'error_invalid_id' ));
156 $admin- > page_start ( $lang- > string ( 'Edit Language' ));
158 $admin- > form_start ( 'language.php' , 'update' );
159 $admin- > table_start ();
160 $admin- > table_head ( sprintf ( $lang- > string ( 'Edit Language - %1 $s' ), $language [' title
']));
162 $admin- >form_hidden_field(' languageid
', $language [' languageid
']);
164 $admin- >row_input( $lang- >string(' Title
'), ' title
', $language [' title
']);
165 $admin- >row_input( $lang- >string(' Character Set
'), ' charset
', $language [' charset
']);
166 $admin- >list_item( $lang- >string(' Left
- to
- Right
'), ' ltr
', (( $language [' direction
'] == ' ltr
') ? true : false));
167 $admin- >list_item( $lang- >string(' Right
- to
- Left
'), ' rtl
', (( $language [' direction
'] == ' rtl
') ? true : false));
168 $admin- >row_list( $lang- >string(' Direction
'), ' direction
');
169 $admin- >row_input( $lang- >string(' Path to XML
'), ' filename
', $language [' filename
']);
170 $admin- >row_yesno( $lang- >string(' User Selectable
'), ' userselect
', $language [' userselect
']);
171 $admin- >row_yesno( $lang- >string(' Debug
Mode ( run directly from XML
) '), ' langdebug
', (bool) $language [' debug
']);
173 $admin- >row_submit();
180 // ###################################################################
182 if ( $_REQUEST [' do '] == ' reload
')
184 $language = $db- >query_first("SELECT * FROM " . TABLE_PREFIX . "language WHERE languageid = " . $bugsys- >input_clean(' languageid
', TYPE_UINT));
187 $admin- >error( $lang- >getlex(' error_invalid_id
'));
190 build_language_cache( $language [' languageid
']);
192 $admin- >redirect(' language
. php
? do = modify
');
195 // ###################################################################
197 if ( $_REQUEST [' do '] == ' modify
')
199 NavLinks::languagesAdd();
200 $navigator- >set_focus(' link
', ' options
- pages
- languages
', ' options
- pages
');
202 $admin- >page_start( $lang- >string(' Manage Languages
'));
204 $admin- >table_start();
205 $admin- >table_head( $lang- >string(' Manage Languages
'), 4, ' language_manage
');
207 $admin- >table_column_head(array( $lang- >string(' Title
'), $lang- >string(' Charset
'), $lang- >string(' Options
'), $lang- >string(' Actions
')));
209 $languages = $db- >query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC");
210 while ( $language = $db- >fetch_array( $languages ))
212 $admin- >row_multi_item(array(
213 $language [' title
'] => ' l
',
214 $language [' charset
'] => ' c
',
215 (( $bugsys- >options[' defaultlanguage
'] == $language [' languageid
']) ? ' < strong
> ' . $lang- >string(' DEFAULT LANGUAGE
') . ' </ strong
> / ' : ' ') . ( $language [' userselect
'] ? $lang- >string(' User Selectable
') : $lang- >string(' Private ')) => ' c
',
216 "<a href= \" language.php?do=edit&languageid= $language [languageid] \" >[" . $lang- >string(' Edit Settings
') . "]</a> <a href= \" language.php?do=reload&languageid= $language [languageid] \" >[" . $lang- >string(' Reload XML
') . "]</a>" => ' c
'
225 /*=====================================================================*\
226 || ###################################################################
229 || ###################################################################
230 \*=====================================================================*/