24 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit',
'-1');
25 error_reporting(E_ALL);
26 if ((php_sapi_name() !=
'cli')) trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
28 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
29 if (empty($SYSTEM_ROOT)) {
30 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
34 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
35 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
39 define(
'SQ_SYSTEM_ROOT', realpath($SYSTEM_ROOT));
40 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
42 $root_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
45 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
46 echo
"ERROR: Failed logging in as root user\n";
51 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
52 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_OPEN);
54 $parse_asset_types = Array(
59 foreach ($parse_asset_types as $type_code => $strict) {
60 $designs = array_merge($designs, $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids($type_code, $strict));
63 foreach ($designs as $designid) {
65 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($designid);
66 if (is_null($design)) exit();
67 if (!($design instanceof
Design)) {
68 trigger_error(
'Asset #'.$design->id.
' is not a design', E_USER_ERROR);
71 printName(
'Checking Parse files "'.$design->name.
'" (#'.$design->id.
')');
73 $parse_file = $design->data_path.
'/parse.txt';
75 $file_status = $fv->upToDate($parse_file);
76 if (FUDGE_FV_MODIFIED & $file_status) {
77 if (!$fv->commit($parse_file,
'',
false)) {
78 trigger_error(
'Failed committing file version', E_USER_ERROR);
79 printUpdateStatus(
'UNABLE TO COMMIT PARSE FILE');
80 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($design);
85 printUpdateStatus(
'OK');
87 printName(
'Reparse '.$design->type().
' "'.$design->name.
'" (#'.$design->id.
')');
89 $edit_fns = $design->getEditFns();
90 if (!$edit_fns->parseAndProcessFile($design)) {
91 printUpdateStatus(
'FAILED');
94 $design->generateDesignFile(
false);
96 printUpdateStatus(
'OK');
99 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($design->id, SQ_LINK_TYPE_2,
'design_customisation',
true,
'major',
'customisation');
100 foreach($customisation_links as $link) {
101 $customisation = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
102 if (is_null($customisation))
continue;
103 printName(
'Reparse design customisation "'.$customisation->name.
'"');
105 if (!$customisation->updateFromParent($design)) {
106 printUpdateStatus(
'FAILED');
109 printUpdateStatus(
'OK');
111 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($customisation);
115 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($design);
119 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
124 function printName($name)
126 printf (
'%s%'.(50 - strlen($name)).
's', $name,
'');
131 function printUpdateStatus($status)
133 echo
"[ $status ]\n";