remove old readme
[atutor.git] / mods / _core / modules / create.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
18 unset($module_xml);
19
20 if (isset($_POST['submit'])) {
21         require('./module.template.php');
22         
23         $maintainers_xml = '';
24         if (isset($_POST['name_1'], $_POST['email_1']) && $_POST['name_1'] && $_POST['email_1']) {
25                 $maintainers_xml .= str_replace(array('{NAME}', '{EMAIL}'), array($stripslashes($_POST['name_1']), $stripslashes($_POST['email_1'])), $maintainer_xml);
26         }
27
28         if (isset($_POST['name_2'], $_POST['email_2']) && $_POST['name_2'] && $_POST['email_2']) {
29                 $maintainers_xml .= str_replace(array('{NAME}', '{EMAIL}'), array($stripslashes($_POST['name_2']), $stripslashes($_POST['email_2'])), $maintainer_xml);
30         }
31         $maintainers_xml .= "\n";
32         $tokens = array('{NAME}', '{DESCRIPTION}', '{MAINTAINERS}', '{URL}', '{VERSION}', '{USER_PRIVILEGE}', '{DATE}', '{LICENSE}', '{STATE}', '{NOTES}');
33         $replace = array($stripslashes($_POST['name']),
34                                         $stripslashes($_POST['description']),
35                                         $maintainers_xml, 
36                                         $stripslashes($_POST['url']),
37                                         $stripslashes($_POST['version']),
38                                         $stripslashes($_POST['priv']),
39                                         $stripslashes($_POST['date']),
40                                         $stripslashes($_POST['license']),
41                                         $stripslashes($_POST['state']),
42                                         $stripslashes($_POST['notes']));
43
44         $module_xml = str_replace($tokens, $replace, $module_xml);
45 }
46
47 require(AT_INCLUDE_PATH.'header.inc.php');
48
49 if (isset($module_xml)) :  ?>
50         <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
51         <div class="input-form">
52                 <div class="input-form">
53                         <div class="row"><pre><?php highlight_string($module_xml); ?></pre></div>
54                 </div>
55
56                 <div class="row buttons">
57                         <input type="submit" name="submit" value="<?php echo _AT('back'); ?>" />
58                 </div>
59         </div>
60         </form>
61 <?php else: ?>
62
63 [[ this form is used to generate the module.xml file which must be packaged with each module ]]
64
65 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
66 <div class="input-form">
67         <h3><?php echo _AT('module_details'); ?></h3>
68
69         <div class="row">
70                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="name"><?php echo _AT('module_name'); ?></label><br />
71                 <input type="text" name="name" id="name" size="40" value="" />
72         </div>
73
74         <div class="row">
75                 <label for="desc"><?php echo _AT('description'); ?></label><br />
76                 <textarea name="description" id="desc" cols="10" rows="2"></textarea>
77         </div>
78
79         <div class="row">
80                 <?php echo _AT('maintainers'); ?>
81                 <ol style="margin-top: 0px; margin-bottom: 0px;">
82                         <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="" />
83                                 <label for="email_1"><?php echo _AT('email'); ?></label> <input type="text" name="email_1" id="email_1" size="35" value="" /></li>
84
85                         <li><label for="name_2"><?php echo _AT('name'); ?></label> <input type="text" name="name_2" id="name_2" size="25" value="" />
86                 <label for="email_2"><?php echo _AT('email'); ?></label> <input type="text" name="email_2" id="email_2" size="35" value="" /></li>
87                 </ol>
88         </div>
89
90         <div class="row">
91                 <label for="url"><?php echo _AT('url'); ?></label><br />
92                 <input type="text" name="url" id="url" size="50" value="http://" />
93         </div>
94
95         <div class="row">
96                 <label for="license"><?php echo _AT('license'); ?></label><br />
97                 <input type="text" name="license" id="license" size="65" value="GPL" />
98         </div>
99
100
101         <h3><?php echo _AT('release_details'); ?></h3>
102
103         <div class="row">
104                 <label for="version"><?php echo _AT('version'); ?></label><br />
105                 <input type="text" name="version" id="version" size="5" value="" />
106         </div>
107
108         <div class="row">
109                 <?php echo _AT('use_custom_privilege'); ?><br />
110                 <input type="radio" name="priv" value="false" id="priv_1" checked="checked" /><label for="priv_1"><?php echo _AT('no'); ?></label>, 
111                 <input type="radio" name="priv" value="true"  id="priv_2" /><label for="priv_2"><?php echo _AT('yes'); ?></label>
112         </div>
113
114         <div class="row">
115                 <label for="date"><?php echo _AT('date'); ?></label><br />
116                 <input type="text" name="date" id="date" value="" />
117         </div>
118
119         <div class="row">
120                 <?php echo _AT('state'); ?><br />
121                         <input type="radio" name="state" value="stable"       id="state_1" checked="checked" /><label for="state_1"><?php echo _AT('stable'); ?></label>, 
122                         <input type="radio" name="state" value="beta"         id="state_2" /><label for="state_2"><?php echo _AT('beta'); ?></label>,
123                         <input type="radio" name="state" value="experimental" id="state_3" /><label for="state_3"><?php echo _AT('experimental'); ?></label>
124         </div>
125
126         <div class="row">
127                 <label for="notes"><?php echo _AT('notes'); ?></label><br />
128                 <textarea name="notes" id="notes" cols="10" rows="2"></textarea>
129         </div>
130
131         <div class="row buttons">
132                 <input type="submit" name="submit" value="<?php echo _AT('submit'); ?>" />
133         </div>
134 </div>
135 </form>
136 <?php endif; ?>
137 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>