18 require_once SQ_SYSTEM_ROOT.
'/core/assets/system/tool/tool.inc';
19 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
20 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
47 $this->
Tool($assetid);
65 $import_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'import_tools_manager');
66 $locks = $GLOBALS[
'SQ_SYSTEM']->am->getLockInfo($import_mgr->id,
'attributes', TRUE, TRUE);
67 $userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
71 foreach ($locks as $lock) {
72 if (empty($lock))
continue;
73 if ($lock[
'lock_type'] ==
'attributes' && $lock[
'userid'] == $userid) {
75 }
else if ($lock[
'lock_type'] ==
'attributes' ) {
77 $userHasLockId = $lock[
'userid'];
83 echo (translate(
'tool_export_online_quiz_to_xml_can_not_acquire_lock', $userHasLockId));
88 $show_download = FALSE;
89 if (isset($_REQUEST[
'show_download'])) {
90 $show_download = TRUE;
91 }
else if (isset($_REQUEST[
'download'])) {
93 $export_dir = SQ_DATA_PATH.
'/private/export_assets';
94 if (!is_dir($export_dir)) {
95 if (!create_directory($export_dir))
return FALSE;
98 if (!file_exists($export_dir.
'/export.tgz')){
99 $command =
"cd $export_dir ; tar -czf export.tgz * --remove-files";
100 exec($command, $output, $return);
105 trigger_localised_error(
'EXP0001', E_USER_ERROR, $return);
111 $filesize = filesize($export_dir.
'/export.tgz');
113 trigger_localised_error(
'EXP0002', E_USER_ERROR);
117 require_once SQ_FUDGE_PATH.
'/standards_lists/mime_types.inc';
119 $type = (empty($standards_lists_mime_types[$ext])) ?
'text/plain' : $standards_lists_mime_types[$ext];
122 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($import_mgr->id,
'attributes');
125 header(
"Pragma: public");
126 header(
"Expires: 0");
127 header(
"Cache-Control: must-revalidate, post-check=0, pre-check=0");
128 header(
"Cache-Control: private", FALSE);
130 header(
'Content-Type: '.$type);
131 header(
'Content-Disposition: attachment; filename="export.tgz";');
132 header(
'Content-Length: '.$filesize);
134 readfile($export_dir.
'/export.tgz');
138 $tool_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code);
139 $o->openSection($tool_info[
'name']);
141 $o->openField(translate(
'tool_export_online_quiz_to_xml_root_node'));
142 asset_finder($type_code.
'_root_node');
143 $o->note(translate(
'tool_export_online_quiz_to_xml_root_node_note'));
146 $o->openField(translate(
'tool_export_online_quiz_to_xml_type_codes'));
147 $available_types = Array (
148 'page_standard' =>
'Standard Page',
149 'page_online_quiz' =>
'Online Quiz'
151 combo_box($type_code.
'_type_codes', $available_types, TRUE);
152 $o->note(translate(
'tool_export_online_quiz_to_xml_type_codes_note'));
155 if ($show_download) {
156 $o->openField(translate(
'download'));
157 $backend_url = $GLOBALS[
'SQ_SYSTEM']->backend->getBackendUrl();
158 $download_url = $backend_url.
'&backend_section=tools&tool_type_code='.$type_code.
'&download=1';
159 echo
'<a href="'.$download_url.
'" >'.translate(
'download').
'</a>';
182 $import_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'import_tools_manager');
183 if(!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($import_mgr->id,
'attributes')) {
184 trigger_localised_error(
'EXP0003', E_USER_ERROR);
189 $export_dir = SQ_DATA_PATH.
'/private/export_assets';
190 if (!is_dir($export_dir)) {
191 if (!create_directory($export_dir))
return FALSE;
195 if (!clear_directory($export_dir))
return FALSE;
197 $root_node = (!empty($_POST[$type_code.
'_root_node'][
'assetid'])) ? $_POST[$type_code.
'_root_node'][
'assetid'] : 0;
198 $type_codes = array_get_index($_POST, $type_code.
'_type_codes', Array());
200 if (empty($root_node)) {
201 trigger_error (
'There is no root node specified', E_USER_NOTICE);
205 if (empty($type_codes)) {
206 trigger_error (
'There is no type codes specified', E_USER_NOTICE);
211 $vars[
'export_dir'] = $export_dir;
212 $vars[
'root_node'] = $root_node;
213 $vars[
'type_codes'] = $type_codes;
217 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
218 $hh->queueHipo(
'hipo_job_export_online_quiz_to_xml', $vars,
'');
219 $backend_url = $GLOBALS[
'SQ_SYSTEM']->backend->getBackendUrl();
221 $url = $hh->runQueuedJobs($backend_url.
'&backend_section=tools&tool_type_code='.$type_code.
'&show_download=1');
223 if (!empty($url)) $o->setRedirect($url);
240 $o->openSection(translate(
'tool_export_online_quiz_to_xml_standard_page_settings'));
242 $o->openField(translate(
'tool_export_online_quiz_to_xml_paint_method'));
243 radio_button($type_code.
'_paint_method',
'raw', TRUE);
244 label(
'Raw (no Paint Layout)', $type_code.
'_page_standard_paint_method_raw');
246 radio_button($type_code.
'_paint_method',
'default_layout');
247 label(
'Using default Paint Layout (based on lookup rules)', $type_code.
'_page_standard_paint_method_default_layout');
250 $o->openField(translate(
'tool_export_online_quiz_to_xml_start_tag'));
251 text_box($type_code.
'_start_tag',
'<!-- START TAG -->');
254 $o->openField(translate(
'tool_export_online_quiz_to_xml_end_tag'));
255 text_box($type_code.
'_end_tag',
'<!-- END TAG -->');
258 $o->sectionNote(translate(
'tool_export_online_quiz_to_xml_standard_page_settings_note'));
276 $settings[
'start_tag'] = array_get_index($_POST, $type_code.
'_start_tag',
'');
277 $settings[
'end_tag'] = array_get_index($_POST, $type_code.
'_end_tag',
'');
278 $settings[
'paint_method'] = array_get_index($_POST, $type_code.
'_paint_method',
'raw');