ATutor 2.0
[atutor.git] / mods / _core / modules / details.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: details.php 8901 2009-11-11 19:10:19Z cindy $
13
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_ADMIN);
17
18 require(AT_INCLUDE_PATH.'../mods/_core/modules/classes/ModuleParser.class.php');
19
20
21 if (isset($_POST['submit_no'])) {
22         $msg->addFeedback('CANCELLED');
23         header('Location: '.AT_BASE_HREF.'mods/_core/modules/add_new.php');
24         exit;
25 } else if (isset($_POST['mod']) && isset($_POST['submit_yes'])) {
26         $module = $moduleFactory->getModule($_POST['mod']);
27         $module->load();
28         $module->install();
29
30         if ($msg->containsErrors()) {
31                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/details.php?mod='.$addslashes($_POST['mod']).SEP.'new=1');
32         } else {
33                 $msg->addFeedback('MOD_INSTALLED');
34                 header('Location: '.AT_BASE_HREF.'mods/_core/modules/index.php');
35         }
36         exit;
37 } else if (isset($_GET['submit'])) {
38         $args = '';
39
40         if (isset($_GET['enabled'])  && $_GET['enabled'])  {  $args .= 'enabled=1';      }
41         if (isset($_GET['disabled']) && $_GET['disabled']) {  $args .= SEP.'disabled=1'; }
42         if (isset($_GET['missing'])  && $_GET['missing'])  {  $args .= SEP.'missing=1';  }
43         if (isset($_GET['core'])     && $_GET['core'])     {  $args .= SEP.'core=1';     }
44         if (isset($_GET['standard']) && $_GET['standard']) {  $args .= SEP.'standard=1'; }
45         if (isset($_GET['extra'])    && $_GET['extra'])    {  $args .= SEP.'extra=1';    }
46
47         header('Location: index.php?'. $args);
48         exit;
49 }
50
51 require(AT_INCLUDE_PATH.'header.inc.php'); 
52
53 $moduleParser = new ModuleParser();
54
55 $_REQUEST['mod'] = str_replace(array('.','..'), '', $_REQUEST['mod']);
56
57 if (!file_exists('../../../mods/'.$_GET['mod'].'/module.xml')) {
58 ?>
59 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
60 <input type="hidden" name="mod" value="<?php echo $_GET['mod']; ?>" />
61 <input type="hidden" name="new" value="<?php echo $_GET['new']; ?>" />
62 <div class="input-form">
63         <div class="row">
64                 <h3><?php echo $_GET['mod']; ?></h3>
65         </div>
66
67         <div class="row">
68                 <?php echo _AT('missing_info'); ?>
69         </div>
70
71         <div class="row buttons">
72                 <input type="submit" name="submit" value="<?php echo _AT('back'); ?>" />
73                 <?php if (isset($_GET['new']) && $_GET['new']): ?>
74                         <input type="submit" name="install" value="<?php echo _AT('install'); ?>" />
75                 <?php endif; ?>
76         </div>
77
78 </div>
79 </form>
80 <?php
81         require(AT_INCLUDE_PATH.'footer.inc.php');
82         exit;
83 }
84
85 $moduleParser->parse(file_get_contents('../../../mods/'.$_GET['mod'].'/module.xml'));
86
87 $module = $moduleFactory->getModule($_GET['mod']);
88
89 $properties = $module->getProperties(array('maintainers', 'url', 'date', 'license', 'state', 'notes', 'version'));
90 ?>
91 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
92 <input type="hidden" name="mod" value="<?php echo $_GET['mod']; ?>" />
93 <input type="hidden" name="new" value="<?php echo $_GET['new']; ?>" />
94
95 <input type="hidden" name="enabled" value="<?php echo (int) isset($_GET['enabled']); ?>" />
96 <input type="hidden" name="disabled" value="<?php echo (int) isset($_GET['disabled']); ?>" />
97 <input type="hidden" name="core" value="<?php echo (int) isset($_GET['core']); ?>" />
98 <input type="hidden" name="standard" value="<?php echo (int) isset($_GET['standard']); ?>" />
99 <input type="hidden" name="extra" value="<?php echo (int) isset($_GET['extra']); ?>" />
100 <input type="hidden" name="missing" value="<?php echo (int) isset($_GET['missing']); ?>" />
101
102 <div class="input-form">
103         <div class="row">
104                 <h3><?php echo $module->getName(); ?></h3>
105         </div>
106
107         <div class="row">
108                 <?php echo _AT('description'); ?><br />
109                 <?php echo nl2br($module->getDescription($_SESSION['lang'])); ?>
110         </div>
111
112         <div class="row">
113                 <?php echo _AT('maintainers'); ?><br />
114                         <ul class="horizontal">
115                                 <?php foreach ($properties['maintainers'] as $maintainer): ?>
116                                         <li><?php echo $maintainer['name'] .' &lt;'.$maintainer['email'].'&gt;'; ?></li>
117                                 <?php endforeach; ?>
118                         </ul>
119         </div>
120
121         <div class="row">
122                 <?php echo _AT('url'); ?><br />
123                 <?php echo $properties['url']; ?>
124         </div>
125
126         <div class="row">
127                 <?php echo _AT('version'); ?><br />
128                 <?php echo $properties['version']; ?>
129         </div>
130
131         <div class="row">
132                 <?php echo _AT('date'); ?><br />
133                 <?php echo $properties['date']; ?>
134         </div>
135
136         <div class="row">
137                 <?php echo _AT('license'); ?><br />
138                 <?php echo $properties['license']; ?>
139         </div>
140
141         <div class="row">
142                 <?php echo _AT('state'); ?><br />
143                 <?php echo $properties['state']; ?>
144         </div>
145
146         <div class="row">
147                 <?php echo _AT('notes'); ?><br />
148                 <?php echo nl2br($properties['notes']); ?>
149         </div>
150
151         <?php if (is_array($module->_pages)): ?>
152                 <div class="row">
153                         <?php if (!isset($_GET['files'])): ?>
154                                 <a href="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES).SEP; ?>files#files"><?php echo _AT('files'); ?></a><br />
155                         <?php else: ?>
156                                 <?php $module_pages = array_keys($module->_pages); ?>
157                                 <?php natsort($module_pages); ?>
158                                 <a name="files"></a><?php echo _AT('files'); ?><br />
159                                 <ul style="margin-top: 0px;">
160                                         <?php foreach ($module_pages as $key): ?>
161                                                 <?php if (defined($key)) : continue; endif; ?>
162                                                 <li><kbd><?php echo $key; ?></kbd></li>
163                                         <?php endforeach; ?>
164                                 </ul>
165                         <?php endif; ?>
166                 </div>
167         <?php endif; ?>
168
169 <?php if (!isset($_REQUEST['new'])): ?>
170         <div class="row buttons">
171                 <input type="submit" name="submit" value="<?php echo _AT('back'); ?>" />
172         </div>
173 <?php endif; ?>
174 </div>
175 </form>
176 <?php if (isset($_REQUEST['new'])): ?>
177         <?php
178                 $hidden_vars['mod'] = $_REQUEST['mod'];
179                 $hidden_vars['new'] = '1';
180                 $msg->addConfirm(array('ADD_MODULE', $_REQUEST['mod']), $hidden_vars);
181                 $msg->printConfirm();
182         ?>
183 <?php endif; ?>
184
185 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>