moved code up one level to eliminate the docs subdirectory
[acontent.git] / home / editor / import_export_content.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
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
13 define('TR_INCLUDE_PATH', '../../include/');
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
15
16 global $_course_id, $_content_id;
17
18 Utility::authenticate(TR_PRIV_ISAUTHOR);
19
20 require(TR_INCLUDE_PATH.'header.inc.php');
21 if (!isset($_main_menu)) {
22         $_main_menu = $contentManager->getContent();
23 }
24
25 // The length of the content/folder title to display. 
26 // This is to fix the issue that, when any one of the content title is too long, 
27 // the dropdown box for the export selection stretches out of the "export" fieldset border.
28 $len_of_title_to_display = 65;
29
30 function print_menu_sections(&$menu, $only_print_content_folder = false, $parent_content_id = 0, $depth = 0, $ordering = '') {
31         global $len_of_title_to_display;
32         
33         $my_children = $menu[$parent_content_id];
34         $cid = $_GET['cid'];
35
36         if (!is_array($my_children)) {
37                 return;
38         }
39         foreach ($my_children as $children) {
40                 /* test content association, we don't want to display the test pages
41                  * as part of the menu section.  If test, skip it.
42                  */
43                 if (isset($children['test_id'])){
44                         continue;
45                 }
46                 if ($only_print_content_folder && $children['content_type'] != CONTENT_TYPE_FOLDER) {
47                         continue;
48                 }
49
50                 echo '<option value="'.$children['content_id'].'"';
51                 if ($cid == $children['content_id']) {
52                         echo ' selected="selected"';
53                 }
54                 echo '>';
55                 echo str_pad('', $depth, '-') . ' ';
56                 if ($parent_content_id == 0) {
57                         $new_ordering = $children['ordering'];
58                         echo $children['ordering'];
59                 } else {
60                         $new_ordering = $ordering.'.'.$children['ordering'];
61                         echo $ordering . '.'. $children['ordering'];
62                 }
63                 if (strlen($children['title']) > $len_of_title_to_display) {
64                         $title = substr($children['title'], 0, $len_of_title_to_display).' ...';
65                 } else {
66                         $title = $children['title'];
67                 }
68                 
69                 echo ' '.$title.'</option>';
70
71                 print_menu_sections($menu, $only_print_content_folder, $children['content_id'], $depth+1, $new_ordering);
72         }
73 }
74
75 ?>
76 <form name="exportForm" method="post" action="home/ims/ims_export.php">
77 <div class="input-form">
78         <input type="hidden" name="_course_id" value="<?php echo $_course_id; ?>" />
79         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('export_content'); ?></legend>
80         <div class="row">
81                 <p><?php echo _AT('export_content_info'); ?></p>
82         </div>
83
84 <?php if ($_main_menu[0]): ?>
85         <div class="row">
86                 <label for="select_cid"><?php echo _AT('export_content_package_what'); ?></label><br />
87                 <select name="cid" id="select_cid">
88                         <option value="0"><?php echo _AT('export_entire_course_or_chap'); ?></option>
89                         <option value="0"></option>
90                         <?php
91                                 print_menu_sections($_main_menu);
92                         ?>
93                 </select>
94         </div>
95
96         <div class="row">
97                 <input type="radio" name="export_as" id="to_cp" value="1" checked="checked" onclick="changeFormAction('cp');" />
98                 <label for="to_cp"><?php echo _AT('content_package'); ?></label> <br />
99                 <input type="radio" name="export_as" id="to_cc" value="1" onclick="changeFormAction('cc');" />
100                 <label for="to_cc"><?php echo _AT('common_cartridge'); ?> </label>
101         </div>
102         <div class="row">
103                 <input type="checkbox" name="to_a4a" id="to_a4a" value="1" />
104                 <label for="to_a4a"><?php echo _AT('a4a_export'); ?></label>
105         </div>
106         
107         <div class="row buttons">
108                 <input type="submit" name="submit" value="<?php echo _AT('export'); ?>" />
109                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
110         </div>
111         </fieldset>
112 <?php else: ?>
113         <div class="row">
114                 <strong><?php echo _AT('none_found'); ?></strong>
115         </div>
116 <?php endif; ?>
117
118 </div>
119 </form>
120
121 <form name="form1" method="post" action="home/ims/ims_import.php" enctype="multipart/form-data" onsubmit="openWindow('<?php echo TR_BASE_HREF; ?>home/prog.php');">
122 <div class="input-form">
123         <input type="hidden" name="_course_id" value="<?php echo $_course_id; ?>" />
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, true);
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><br />
146                 <input type="checkbox" name="ignore_validation" id="ignore_validation" value="1" />
147                 <label for="ignore_validation"><?php echo _AT('ignore_validation'); ?></label> <br />
148         </div>
149         
150         <div class="row">
151                 <label for="to_file"><?php echo _AT('upload_content_package'); ?></label><br />
152                 <input type="file" name="file" id="to_file" />
153         </div>
154
155         <div class="row">
156                 <label for="to_url"><?php echo _AT('specify_url_to_content_package'); ?></label><br />
157                 <input type="text" name="url" value="http://" size="40" id="to_url" />
158         </div>
159
160         <div class="row buttons">
161                 <input type="submit" name="submit" onclick="setClickSource('submit');" value="<?php echo _AT('import'); ?>" />
162                 <input type="submit" name="cancel" onclick="document.form1.enctype='';setClickSource('cancel');" value="<?php echo _AT('cancel'); ?>" />
163         </div>
164 </div>
165 </form>
166
167 <script language="javascript" type="text/javascript">
168
169 var but_src;
170 function setClickSource(name) {
171         but_src = name;
172 }
173
174 function openWindow(page) {
175         if (but_src != "cancel") {
176                 newWindow = window.open(page, "progWin", "width=400,height=200,toolbar=no,location=no");
177                 newWindow.focus();
178         }
179 }
180
181 //Change form action 
182 function changeFormAction(type){
183         var obj = document.exportForm;
184         if (type=="cc"){
185                 obj.action = "home/imscc/ims_export.php";
186         } else if (type=="cp"){
187                 obj.action = "home/ims/ims_export.php";
188         }
189 }
190
191 </script>
192
193 <?php require (TR_INCLUDE_PATH.'footer.inc.php'); ?>