66f2d78b3cdbfe6d6257726afa87cd80c35e6e8c
[atutor.git] / docs / mods / _core / modules / add_new.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_MODULES);
17 require(AT_INCLUDE_PATH.'../mods/_core/modules/classes/ModuleParser.class.php');
18
19 if (isset($_GET['mod'])) {
20         $dir_name = str_replace(array('.','..'), '', $_GET['mod']);
21
22         if (isset($_GET['install'])) {
23                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/details.php?mod='.urlencode($dir_name).SEP.'new=1');
24                 exit;
25         }
26
27 } else if (isset($_GET['install'])) {
28         $msg->addError('NO_ITEM_SELECTED');
29 }
30
31 require(AT_INCLUDE_PATH.'header.inc.php'); 
32 $module_list = $moduleFactory->getModules(AT_MODULE_STATUS_UNINSTALLED | AT_MODULE_STATUS_MISSING | AT_MODULE_STATUS_PARTIALLY_UNINSTALLED, AT_MODULE_TYPE_EXTRA);
33 $keys = array_keys($module_list);
34 natsort($keys);
35
36 ?>
37
38 <div class="input-form">
39         <div class="row">
40                 <?php echo _AT('install_module_text', realpath('./../../../mods')); ?>          
41         </div>
42 </div>
43
44 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" name="installform">
45 <table class="data" summary="" rules="cols" style="width:80%;">
46 <thead>
47 <tr>
48         <th scope="col">&nbsp;</th>
49         <th scope="col"><?php echo _AT('module_name'); ?></th>
50         <th scope="col"><?php echo _AT('directory_name'); ?></th>
51         <th scope="col"><?php echo _AT('description'); ?></th>
52 </tr>
53 </thead>
54 <tfoot>
55 <tr>
56         <td colspan="4">
57                 <input type="submit" name="install"  value="<?php echo _AT('install'); ?>" />
58         </td>
59 </tr>
60 </tfoot>
61 <tbody>
62 <?php if (!empty($keys)): ?>
63         <?php foreach($keys as $dir_name) : $module =& $module_list[$dir_name]; ?>
64                 <tr onmousedown="document.installform['m_<?php echo $dir_name; ?>'].checked = true; rowselect(this);" id="r_<?php echo $dir_name; ?>">
65                         <td valign="top"><input type="radio" id="m_<?php echo $dir_name; ?>" name="mod" value="<?php echo $dir_name; ?>" /></td>
66                         <td valign="top"><label for="m_<?php echo $row['dir_name']; ?>"><?php echo $module->getName(); ?></label></td>
67                         <td valign="top"><code><?php echo $dir_name; ?>/</code></td>
68                         <td valign="top"><?php echo $module->getDescription($_SESSION['lang']); ?></td>
69                 </tr>
70         <?php endforeach; ?>
71 <?php else: ?>
72         <tr>
73                 <td colspan="4"><?php echo _AT('none_found'); ?></td>
74         </tr>
75 <?php endif; ?>
76 </tbody>
77 </table>
78 </form>
79
80 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>