made a copy
[atutor.git] / admin / modules / create.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto                  */
7 /* http://atutor.ca                                                                                                             */
8 /*                                                                                                                                              */
9 /* This program is free software. You can redistribute it and/or                */
10 /* modify it under the terms of the GNU General Public License                  */
11 /* as published by the Free Software Foundation.                                                */
12 /************************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_ADMIN);
18
19 unset($module_xml);
20
21 if (isset($_POST['submit'])) {
22         require('./module.template.php');
23         
24         $maintainers_xml = '';
25         if (isset($_POST['name_1'], $_POST['email_1']) && $_POST['name_1'] && $_POST['email_1']) {
26                 $maintainers_xml .= str_replace(array('{NAME}', '{EMAIL}'), array($stripslashes($_POST['name_1']), $stripslashes($_POST['email_1'])), $maintainer_xml);
27         }
28
29         if (isset($_POST['name_2'], $_POST['email_2']) && $_POST['name_2'] && $_POST['email_2']) {
30                 $maintainers_xml .= str_replace(array('{NAME}', '{EMAIL}'), array($stripslashes($_POST['name_2']), $stripslashes($_POST['email_2'])), $maintainer_xml);
31         }
32         $maintainers_xml .= "\n";
33         $tokens = array('{NAME}', '{DESCRIPTION}', '{MAINTAINERS}', '{URL}', '{VERSION}', '{USER_PRIVILEGE}', '{DATE}', '{LICENSE}', '{STATE}', '{NOTES}');
34         $replace = array($stripslashes($_POST['name']),
35                                         $stripslashes($_POST['description']),
36                                         $maintainers_xml, 
37                                         $stripslashes($_POST['url']),
38                                         $stripslashes($_POST['version']),
39                                         $stripslashes($_POST['priv']),
40                                         $stripslashes($_POST['date']),
41                                         $stripslashes($_POST['license']),
42                                         $stripslashes($_POST['state']),
43                                         $stripslashes($_POST['notes']));
44
45         $module_xml = str_replace($tokens, $replace, $module_xml);
46 }
47
48 require(AT_INCLUDE_PATH.'header.inc.php');
49
50 if (isset($module_xml)) :  ?>
51         <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
52         <div class="input-form">
53                 <div class="input-form">
54                         <div class="row"><pre><?php highlight_string($module_xml); ?></pre></div>
55                 </div>
56
57                 <div class="row buttons">
58                         <input type="submit" name="submit" value="<?php echo _AT('back'); ?>" />
59                 </div>
60         </div>
61         </form>
62 <?php else: ?>
63
64 [[ this form is used to generate the module.xml file which must be packaged with each module ]]
65
66 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
67 <div class="input-form">
68         <h3><?php echo _AT('module_details'); ?></h3>
69
70         <div class="row">
71                 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="name"><?php echo _AT('module_name'); ?></label><br />
72                 <input type="text" name="name" id="name" size="40" value="" />
73         </div>
74
75         <div class="row">
76                 <label for="desc"><?php echo _AT('description'); ?></label><br />
77                 <textarea name="description" id="desc" cols="10" rows="2"></textarea>
78         </div>
79
80         <div class="row">
81                 <?php echo _AT('maintainers'); ?>
82                 <ol style="margin-top: 0px; margin-bottom: 0px;">
83                         <li style="margin-bottom: 5px;"><label for="name_1"><?php echo _AT('name'); ?></label> <input type="text" name="name_1" id="name_1" size="25" value="" />
84                                 <label for="email_1"><?php echo _AT('email'); ?></label> <input type="text" name="email_1" id="email_1" size="35" value="" /></li>
85
86                         <li><label for="name_2"><?php echo _AT('name'); ?></label> <input type="text" name="name_2" id="name_2" size="25" value="" />
87                 <label for="email_2"><?php echo _AT('email'); ?></label> <input type="text" name="email_2" id="email_2" size="35" value="" /></li>
88                 </ol>
89         </div>
90
91         <div class="row">
92                 <label for="url"><?php echo _AT('url'); ?></label><br />
93                 <input type="text" name="url" id="url" size="50" value="http://" />
94         </div>
95
96         <div class="row">
97                 <label for="license"><?php echo _AT('license'); ?></label><br />
98                 <input type="text" name="license" id="license" size="65" value="GPL" />
99         </div>
100
101
102         <h3><?php echo _AT('release_details'); ?></h3>
103
104         <div class="row">
105                 <label for="version"><?php echo _AT('version'); ?></label><br />
106                 <input type="text" name="version" id="version" size="5" value="" />
107         </div>
108
109         <div class="row">
110                 <?php echo _AT('use_custom_privilege'); ?><br />
111                 <input type="radio" name="priv" value="false" id="priv_1" checked="checked" /><label for="priv_1"><?php echo _AT('no'); ?></label>, 
112                 <input type="radio" name="priv" value="true"  id="priv_2" /><label for="priv_2"><?php echo _AT('yes'); ?></label>
113         </div>
114
115         <div class="row">
116                 <label for="date"><?php echo _AT('date'); ?></label><br />
117                 <input type="text" name="date" id="date" value="" />
118         </div>
119
120         <div class="row">
121                 <?php echo _AT('state'); ?><br />
122                         <input type="radio" name="state" value="stable"       id="state_1" checked="checked" /><label for="state_1"><?php echo _AT('stable'); ?></label>, 
123                         <input type="radio" name="state" value="beta"         id="state_2" /><label for="state_2"><?php echo _AT('beta'); ?></label>,
124                         <input type="radio" name="state" value="experimental" id="state_3" /><label for="state_3"><?php echo _AT('experimental'); ?></label>
125         </div>
126
127         <div class="row">
128                 <label for="notes"><?php echo _AT('notes'); ?></label><br />
129                 <textarea name="notes" id="notes" cols="10" rows="2"></textarea>
130         </div>
131
132         <div class="row buttons">
133                 <input type="submit" name="submit" value="<?php echo _AT('submit'); ?>" />
134         </div>
135 </div>
136 </form>
137 <?php endif; ?>
138 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>