The tag for ATutor 2.0.3 release.
[atutor.git] / mods / _core / languages / language_edit.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_LANGUAGES);
17 if (!AT_DEVEL_TRANSLATE) { exit; }
18
19 require_once(AT_INCLUDE_PATH . '../mods/_core/languages/classes/LanguageEditor.class.php'); 
20
21 $lang = $languageManager->getLanguage($_GET['lang_code']);
22 if ($lang === FALSE) {
23         require(AT_INCLUDE_PATH.'header.inc.php'); 
24         echo '<h3>'._AT('edit_language').'</h3>';
25         $msg->addError('NO_LANGUAGE');
26         
27         $msg->printAll();
28
29         require(AT_INCLUDE_PATH.'footer.inc.php'); 
30         exit;
31 }
32
33 if (isset($_POST['cancel'])) {
34         $msg->addFeedback('CANCELLED');
35         header('Location: language.php');
36         exit;
37 } else if (isset($_POST['submit'])) {
38         $languageEditor = new LanguageEditor($_GET['lang_code']);
39         $state = $languageEditor->updateLanguage($_POST, $languageManager->exists($_POST['code'], $_POST['locale']));
40
41         if (!$msg->containsErrors() && $state !== FALSE) {
42                 $msg->addFeedback('LANG_UPDATED');
43                 header('Location: language.php');
44                 exit;
45         }
46 }
47
48 require(AT_INCLUDE_PATH.'header.inc.php'); 
49
50
51 $msg->printAll();
52
53 if (!isset($_POST['submit'])) {
54         $_POST['code']         = $lang->getParentCode();
55         $_POST['locale']       = $lang->getLocale();
56         $_POST['charset']      = $lang->getCharacterSet();
57         $_POST['direction']    = $lang->getDirection();
58         $_POST['reg_exp']      = $lang->getRegularExpression();
59         $_POST['native_name']  = $lang->getNativeName();
60         $_POST['english_name'] = $lang->getEnglishName();
61 }
62
63 ?>
64
65 <form method="post" action="<?php echo $_SERVER['PHP_SELF'] . '?lang_code=' . $_GET['lang_code']; ?>">
66
67 <input type="hidden" name="old_code" value="<?php echo $lang->getCode(); ?>" />
68
69 <div class="input-form" style="width:95%">
70         <div class="row">
71                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="code"><?php echo _AT('lang_code'); ?></label><br />
72                 <input id="code" name="code" type="text" size="2" maxlength="2" class="formfield" value="<?php echo $_POST['code']; ?>" />
73         </div>
74
75         <div class="row">
76                 <label for="locale"><?php echo _AT('locale'); ?></label><br />
77                 <input id="locale" name="locale" type="text" size="2" maxlength="2" class="formfield" value="<?php echo $_POST['locale']; ?>" />
78         </div>
79
80         <div class="row">
81                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="charset"><?php echo _AT('charset'); ?></label><br />
82                 <input id="charset" name="charset" type="text" size="31" maxlength="20" class="formfield" value="<?php echo $_POST['charset']; ?>" />
83         </div>
84
85         <div class="row">
86                 <label for="ltr"><?php echo _AT('direction'); ?></label><br />
87                 <?php 
88                         if ($_POST['direction'] == 'rtl') { 
89                                 $rtl = 'checked="checked"';  
90                                 $ltr='';  
91                         } else { 
92                                 $rtl = '';  
93                                 $ltr='checked="checked"'; 
94                         }
95                 ?>
96                 <input id="ltr" name="direction" type="radio" value="ltr" <?php echo $ltr; ?> /><label for="ltr"><?php echo _AT('ltr'); ?></label>, <input id="rtl" name="direction" type="radio" value="rtl" <?php echo $rtl; ?> /><label for="rtl"><?php echo _AT('rtl'); ?></label>
97         </div>
98
99         <div class="row">
100                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="reg_exp"><?php echo _AT('reg_exp'); ?></label><br />
101                 <input id="reg_exp" name="reg_exp" type="text" size="31" class="formfield" value="<?php echo $_POST['reg_exp']; ?>" />
102         </div>
103
104         <div class="row">
105                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="nname"><?php echo _AT('name_in_language'); ?></label><br />
106                 <input id="nname" name="native_name" type="text" size="31" maxlength="20" class="formfield" value="<?php echo $_POST['native_name']; ?>" />
107         </div>
108
109         <div class="row">
110                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="ename"><?php echo _AT('name_in_english'); ?></label><br />
111                 <input id="ename" name="english_name" type="text" size="31" maxlength="20" class="formfield" value="<?php echo $_POST['english_name'];?>" />
112         </div>
113
114
115         <div class="row buttons">
116                 <input type="submit" name="submit" value="<?php echo _AT('submit'); ?>" /> <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />           
117         </div>
118 </div>
119 </form>
120
121 <?php require(AT_INCLUDE_PATH.'footer.inc.php');  ?>