25 error_reporting(E_ALL);
26 ini_set(
'display_errors', 1);
27 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit',
'-1');
29 if ((php_sapi_name() !=
'cli')) {
30 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
34 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
35 if (empty($SYSTEM_ROOT) || !is_dir($SYSTEM_ROOT)) {
36 trigger_error(
"You need to supply the path to the System Root as the first argument\n", E_USER_ERROR);
40 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
41 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
43 $root_node = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'';
44 if (empty($root_node) || !$GLOBALS[
'SQ_SYSTEM']->am->assetExists($root_node)) {
45 trigger_error(
"You need to supply a root node to the import files from as the second argument\n", E_USER_ERROR);
49 $parent_id = (isset($_SERVER[
'argv'][3])) ? $_SERVER[
'argv'][3] :
'';
50 if (empty($parent_id) || !$GLOBALS[
'SQ_SYSTEM']->am->assetExists($parent_id)) {
51 trigger_error(
"You need to supply the parent id to the import files to as the third argument\n", E_USER_ERROR);
55 $recursive = (isset($_SERVER[
'argv'][4]) && strtolower($_SERVER[
'argv'][4]) ==
'y') ? TRUE : FALSE;
58 $index_file = (isset($_SERVER[
'argv'][5]) && strtolower($_SERVER[
'argv'][5]) ==
'y') ? TRUE : FALSE;
60 echo
'START IMPORTING'.
"\n";
61 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user'));
62 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
63 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
65 'root_assetid' => Array($root_node),
66 'parent_assetid' => $parent_id,
67 'recursive' => $recursive,
68 'index_file' => $index_file,
70 $errors = $hh->freestyleHipo(
'hipo_job_import_file', $vars, SQ_PACKAGES_PATH.
'/filesystem/hipo_jobs');
71 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
72 $GLOBALS[
'SQ_SYSTEM']->restoreCurrentUser();
74 if (!empty($errors)) {
75 echo
'... with errors'.
"\n";
76 foreach ($errors as $error) {
77 echo is_array($error) ? implode($error,
"\n").
"\n" : $error.
"\n";