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';
21 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
49 $this->
Tool($assetid);
66 $tool_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code);
67 $o->openSection($tool_info[
'name']);
69 $o->openField(translate(
'tool_import_assets_from_xml_file_upload'));
70 file_upload($type_code.
'_file_upload');
71 $o->note(translate(
'tool_import_assets_from_xml_file_upload_note', sq_web_path(
'data').
'/asset_types/tool_import_assets_from_xml/files/example.xml'));
74 $o->openField(translate(
'tool_import_assets_from_xml_create_under'));
75 asset_finder($type_code.
'_create_under_assetid', 0, Array(
'asset' =>
'D'));
76 $o->note(translate(
'tool_import_assets_from_xml_create_under_note'));
97 $file_info = get_file_upload_info($type_code.
'_file_upload');
98 if (empty($file_info)) {
99 trigger_localised_error(
'IMP0002', E_USER_NOTICE);
104 $import_dir = SQ_DATA_PATH.
'/private/import_assets'.time();
106 if (!move_file($file_info[
'tmp_name'], $import_dir.
'/'.$file_info[
'name'])) {
107 trigger_error(
'Could not move uploaded file from tmp directory to data dir');
113 chmod($import_dir.
'/'.$file_info[
'name'], 0774);
117 if (substr($file_info[
'name'], -7) ==
'.tar.gz' || substr($file_info[
'name'], -4) ==
'.tgz') {
118 require_once
'Archive/Tar.php';
119 $tar_ball =
new Archive_Tar($import_dir.
'/'.$file_info[
'name']);
120 $tar_ball->extract($import_dir);
123 $temp_filename = array_shift(glob($import_dir.
'/*.xml'));
126 $root_node_id = $_POST[$type_code.
'_create_under_assetid'][
'assetid'];
129 if($root_node_id != 0) {
130 $root_node = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($root_node_id);
131 if (is_null($root_node)) {
132 trigger_localised_error(
'IMP0003', E_USER_NOTICE);
137 if (empty($temp_filename)) {
138 trigger_error(
'There is not xml file found');
143 $vars[
'file_info'] = $temp_filename;
144 $vars[
'create_under_assetid'] = $root_node_id;
145 $vars[
'delete_after_import'] = TRUE;
148 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
149 $hh->queueHipo(
'hipo_job_import_assets_from_xml', $vars,
'', SQ_PACKAGES_PATH.
'/import_tools/hipo_jobs');
150 $url = $hh->runQueuedJobs();
153 if (!empty($url)) $o->setRedirect($url);