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