made a copy
[atutor.git] / tools / ims / index.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg        */
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
18 require(AT_INCLUDE_PATH.'header.inc.php');
19
20 if (!isset($_main_menu)) {
21         $_main_menu = $contentManager->getContent();
22 }
23
24 function print_menu_sections(&$menu, $parent_content_id = 0, $depth = 0, $ordering = '') {
25         $my_children = $menu[$parent_content_id];
26         $cid = $_GET['cid'];
27
28         if (!is_array($my_children)) {
29                 return;
30         }
31         foreach ($my_children as $children) {
32                 /* test content association, we don't want to display the test pages
33                  * as part of the menu section.  If test, skip it.
34                  */
35                 if (isset($children['test_id'])){
36                         continue;
37                 }
38
39                 echo '<option value="'.$children['content_id'].'"';
40                 if ($cid == $children['content_id']) {
41                         echo ' selected="selected"';
42                 }
43                 echo '>';
44                 echo str_pad('', $depth, '-') . ' ';
45                 if ($parent_content_id == 0) {
46                         $new_ordering = $children['ordering'];
47                         echo $children['ordering'];
48                 } else {
49                         $new_ordering = $ordering.'.'.$children['ordering'];
50                         echo $ordering . '.'. $children['ordering'];
51                 }
52                 echo ' '.$children['title'].'</option>';
53
54                 print_menu_sections($menu, $children['content_id'], $depth+1, $new_ordering);
55         }
56 }
57
58 if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) && ($_SESSION['packaging'] == 'none')) {
59         echo '<p>'._AT('content_packaging_disabled').'</p>';
60         require (AT_INCLUDE_PATH.'footer.inc.php'); 
61         exit;
62 } else if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) && ($_SESSION['packaging'] == 'top')) {
63         $_main_menu = array($_main_menu[0]);
64 }
65 ?>
66 <form name="exportForm" method="post" action="tools/ims/ims_export.php">
67 <div class="input-form">
68         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('export_content'); ?></legend>
69         <div class="row">
70                 <p><?php echo _AT('export_content_info'); ?></p>
71         </div>
72
73 <?php if ($_main_menu[0]): ?>
74         <div class="row">
75                 <label for="select_cid"><?php echo _AT('export_content_package_what'); ?></label><br />
76                 <select name="cid" id="select_cid">
77                         <option value="0"><?php echo _AT('export_entire_course_or_chap'); ?></option>
78                         <option value="0"></option>
79                         <?php
80                                 print_menu_sections($_main_menu);
81                         ?>
82                 </select>
83         </div>
84
85         <?php if (authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)): ?>
86                         <div class="row">
87                                 <input type="radio" name="export_as" id="to_cp" value="1" checked="checked" onclick="changeFormAction('cp');" />
88                                 <label for="to_cp"><?php echo _AT('content_package'); ?></label> <br />
89                                 <input type="radio" name="export_as" id="to_cc" value="1" onclick="changeFormAction('cc');" />
90                                 <label for="to_cc"><?php echo _AT('common_cartridge'); ?> </label>
91                         </div>
92                         <div class="row">
93                                 <!--<input type="checkbox" name="to_tile" id="to_tile" value="1" />
94                                 <label for="to_tile"><?php echo _AT('tile_export'); ?></label> <br /> -->
95                                 <input type="checkbox" name="to_a4a" id="to_a4a" value="1" />
96                                 <label for="to_a4a"><?php echo _AT('a4a_export'); ?></label>
97                         </div>
98         <?php endif; ?>
99         
100         <div class="row buttons">
101                 <input type="submit" name="submit" value="<?php echo _AT('export'); ?>" />
102                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
103         </div>
104         </fieldset>
105 <?php else: ?>
106         <div class="row">
107                 <strong><?php echo _AT('none_found'); ?></strong>
108         </div>
109 <?php endif; ?>
110
111 </div>
112 </form>
113
114 <?php if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
115                 require (AT_INCLUDE_PATH.'footer.inc.php'); 
116                 exit;
117 }
118 ?>
119 <br /><br />
120
121
122 <form name="form1" method="post" action="tools/ims/ims_import.php" enctype="multipart/form-data" onsubmit="openWindow('<?php echo AT_BASE_HREF; ?>tools/prog.php');">
123 <div class="input-form">
124         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('import_content'); ?></legend>
125         <div class="row">
126
127                 <p><?php echo _AT('import_content_info'); ?></p>
128         </div>
129
130         <div class="row">
131                 <label for="select_cid2"><?php echo _AT('import_content_package_where'); ?></label><br />
132                 <select name="cid" id="select_cid2">
133                         <option value="0"><?php echo _AT('import_content_package_bottom_subcontent'); ?></option>
134                         <option value="0"></option>
135                         <?php
136                                 print_menu_sections($_main_menu);
137                         ?>
138                 </select>
139         </div>
140
141         <div class="row">
142                 <input type="checkbox" name="allow_test_import" id="allow_test_import" checked="checked" />
143                 <label for="allow_test_import"><?php echo _AT('test_import_package'); ?></label> <br />
144                 <input type="checkbox" name="allow_a4a_import" id="allow_a4a_import" checked="checked" />
145                 <label for="allow_a4a_import"><?php echo _AT('a4a_import_package'); ?></label>          
146         </div>
147         
148         <div class="row">
149                 <label for="to_file"><?php echo _AT('upload_content_package'); ?></label><br />
150                 <input type="file" name="file" id="to_file" />
151         </div>
152
153         <div class="row">
154                 <label for="to_url"><?php echo _AT('specify_url_to_content_package'); ?></label><br />
155                 <input type="text" name="url" value="http://" size="40" id="to_url" />
156         </div>
157
158         <div class="row buttons">
159                 <input type="submit" name="submit" onclick="setClickSource('submit');" value="<?php echo _AT('import'); ?>" />
160                 <input type="submit" name="cancel" onclick="document.form1.enctype='';setClickSource('cancel');" value="<?php echo _AT('cancel'); ?>" />
161         </div>
162 </div>
163 </form>
164
165 <script language="javascript" type="text/javascript">
166
167 var but_src;
168 function setClickSource(name) {
169         but_src = name;
170 }
171
172 function openWindow(page) {
173         if (but_src != "cancel") {
174                 newWindow = window.open(page, "progWin", "width=400,height=200,toolbar=no,location=no");
175                 newWindow.focus();
176         }
177 }
178
179 //Change form action 
180 function changeFormAction(type){
181         var obj = document.exportForm;
182         if (type=="cc"){
183                 obj.action = "tools/imscc/ims_export.php";
184         } else if (type=="cp"){
185                 obj.action = "tools/ims/ims_export.php";
186         }
187 }
188
189 </script>
190
191 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>