18 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
19 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
54 public static function execute($settings, &$state)
57 if (empty($settings[
'file_path']) || !file_exists($settings[
'file_path'])) {
63 if (empty($state[
'asset'])) {
65 if (empty($state[
'assetid'])) {
68 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
72 if (is_null($state[
'asset']))
return FALSE;
74 $asset =& $state[
'asset'];
75 $edit_fns = $asset->getEditFns();
77 $parse_file = $asset->data_path.
'/parse.txt';
81 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
84 if (is_file($parse_file)) {
86 if (!unlink($parse_file)) {
87 trigger_localised_error(
'CORE0164', E_USER_WARNING);
93 if (copy_file($settings[
'file_path'], $parse_file)) {
95 $asset->_tmp[
'update_customisations'] = TRUE;
96 $asset->_tmp[
'generate_design'] = TRUE;
97 $changes = $edit_fns->parseAndProcessFile($asset);
100 $parse_file = $asset->data_path.
'/parse.txt';
101 $str = file_to_string($parse_file);
102 $contents = $edit_fns->_parseString($asset, $str);
104 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
105 $changes = (!is_null($contents) && $edit_fns->_processContents($asset, $contents) && $asset->saveAttributes());
106 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
110 $file_status = $fv->upToDate($parse_file);
111 if (FUDGE_FV_MODIFIED & $file_status) {
112 if (!$fv->commit($parse_file,
'')) {
113 trigger_localised_error(
'CORE0160', E_USER_WARNING);
118 if (!$fv->add($asset->data_path_suffix, $parse_file,
'')) {
119 trigger_localised_error(
'CORE1057', E_USER_WARNING);
125 if (!$fv->checkOut($asset->data_path_suffix.
'/parse.txt', $asset->data_path)) {
126 trigger_localised_error(
'CORE0158', E_USER_WARNING);
130 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
131 $asset->generateDesignFile(TRUE);
132 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
135 'assetid' => $state[
'asset']->
id,
151 public static function getInterface($settings, $prefix, $write_access=FALSE)
153 $file_path = array_get_index($settings,
'file_path',
'');
158 <td valign=
"top"><b><?php echo
'Path to the associated file for the design'; ?></b></td>
159 <td valign=
"top" style=
"padding-bottom: 10px;"><?php
162 echo text_box($prefix.
'[file_path]', $file_path,
'50');
164 echo $file_path.
' ';
172 return ob_get_clean();
190 $file_path = array_get_index($request_data,
'file_path',
'');
191 $file_path = trim($file_path);
192 if ($file_path ==
'') {
193 return 'file path is not specified.';
195 $settings[
'file_path'] = $file_path;
211 public static function getLocks($settings, &$state)
214 $state[
'assetid'] => Array(