SVN tag for release should only contain scripts in "docs" folder without "mods",...
[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
51 <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
52
53 <table summary="" class="data" rules="cols">
54 <colgroup>
55         <col />
56         <col class="sort" />
57         <col span="3" />
58 </colgroup>
59 <thead>
60 <tr>
61         <th scope="col">&nbsp;</th>
62         <th scope="col"><?php echo _AT('name_in_language'); ?></th>
63         <th scope="col"><?php echo _AT('name_in_english'); ?></th>
64         <th scope="col"><?php echo _AT('lang_code'); ?></th>
65         <th scope="col"><?php echo _AT('charset'); ?></th>
66 </tr>
67 </thead>
68 <tfoot>
69 <tr>
70         <td colspan="5">
71                 <?php if (defined('AT_DEVEL_TRANSLATE') && AT_DEVEL_TRANSLATE): ?>
72                         <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />  
73                         <input type="submit" name="export" value="<?php echo _AT('export'); ?>"  /> 
74                         <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /> 
75                         <?php echo _AT('or'); ?> <a href="mods/_core/languages/language_add.php"><?php echo _AT('add_a_new_language'); ?></a>
76                 <?php else: ?>
77                         <input type="submit" name="export" value="<?php echo _AT('export'); ?>" /> 
78                         <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" />
79                 <?php endif; ?>
80         </td>
81 </tr>
82 </tfoot>
83 <tbody>
84         <?php foreach ($languageManager->getAvailableLanguages() as $codes): ?>
85                 <?php $language = current($codes); ?>
86                 <tr onmousedown="document.form['m<?php echo $language->getCode(); ?>'].checked = true; rowselect(this);" id="r_<?php echo $language->getCode(); ?>">
87                         <td><input type="radio" name="id" value="<?php echo $language->getCode(); ?>" id="m<?php echo $language->getCode(); ?>" /></td>
88                         <td><label for="m<?php echo $language->getCode(); ?>"><?php echo $language->getNativeName(); ?></label></td>
89                         <td><?php echo $language->getEnglishName(); ?></td>
90                         <td><?php echo strtolower($language->getCode()); ?></td>
91                         <td><?php echo strtolower($language->getCharacterSet()); ?></td>
92                 </tr>
93         <?php endforeach; ?>
94 </tbody>
95 </table>
96 </form>
97
98 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>