remove old readme
[atutor.git] / docs / 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 $savant->assign('lang', $lang);
64 $savant->display('admin/system_preferences/language_edit.tmpl.php');
65 require(AT_INCLUDE_PATH.'footer.inc.php');  ?>