5e069a734e46e9e4eb24b077e8a69c0624366039
[atutor.git] / docs / mods / _core / languages / language.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
18 require_once(AT_INCLUDE_PATH.'../mods/_core/languages/classes/LanguageEditor.class.php');
19 require_once(AT_INCLUDE_PATH.'../mods/_core/languages/classes/LanguagesParser.class.php');
20
21 if ( (isset($_POST['delete']) || isset($_POST['export']) || isset($_POST['edit'])) && !isset($_POST['id'])){
22         $msg->addError('NO_ITEM_SELECTED');
23 } else if (isset($_POST['delete'])) {
24         // check if this language is the only one that exists:
25         if ($languageManager->getNumLanguages() == 1) {
26                 $msg->addError('LAST_LANGUAGE');
27         } else {
28                 header('Location: language_delete.php?lang_code='.$_POST['id']);
29                 exit;
30         }
31 } else if (isset($_POST['export'])) {
32         $language = $languageManager->getLanguage($_POST['id']);
33         if ($language === FALSE) {
34                 $msg->addError('ITEM_NOT_FOUND');
35         } else {
36                 $languageEditor = new LanguageEditor($language);
37                 $languageEditor->export();
38         }
39 } else if (isset($_POST['edit'])) {
40         header('Location: language_edit.php?lang_code='.$_POST['id']);
41         exit;
42 }
43
44 if (AT_DEVEL_TRANSLATE == 1) { 
45         $msg->addWarning('TRANSLATE_ON');       
46 }
47
48 require(AT_INCLUDE_PATH.'header.inc.php');
49
50 $savant->display('admin/system_preferences/language.tmpl.php');
51 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>