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