17 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
18 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
55 public static function execute($settings, &$state)
58 if (empty($settings[
'path']))
return FALSE;
60 if (empty($state[
'asset'])) {
62 if (empty($state[
'assetid'])) {
65 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
69 if (is_null($state[
'asset']))
return FALSE;
72 $web_path = self::replaceKeywordsInWebPath($settings[
'path'], $state[
'asset']);
73 $valid_paths = make_valid_web_paths(Array($web_path));
74 $web_path = array_shift($valid_paths);
77 if (!empty($settings[
'make_lowercase'])) {
78 $web_path = strtolower($web_path);
82 $web_paths_new = $web_paths_old = $state[
'asset']->getWebPaths();
83 if (!in_array($web_path, $web_paths_new)) {
84 $web_paths_new[] = $web_path;
88 if (!empty($settings[
'remove_all'])) {
89 $web_paths_new = Array($web_path);
93 $add_auto_remaps = !isset($settings[
'dont_add_remap']) || !$settings[
'dont_add_remap'];
97 if ($web_paths_new !== $web_paths_old) {
98 if (!$state[
'asset']->
saveWebPaths($web_paths_new, $add_auto_remaps)) {
109 if(!empty($settings[
'update_children'])){
110 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
111 $vars = Array(
'assetids' => Array($state[
'asset']->
id));
112 $lookup_errors = $hh->freestyleHipo(
'hipo_job_update_lookups', $vars);
113 if (!empty($lookup_errors)) {
119 'assetid' => $state[
'asset']->
id,
141 replace_global_keywords($web_path);
144 $keywords = retrieve_keywords_replacements($web_path);
145 $replacements = Array();
146 foreach ($keywords as $keyword) {
149 replace_keywords($web_path, $replacements);
166 public static function getInterface($settings, $prefix, $write_access=FALSE)
170 $web_path = array_get_index($settings,
'path',
'');
171 echo translate(
'add_web_path').
' ';
173 text_box($prefix.
'[path]', $web_path, 40);
175 echo
'<b>'.$web_path.
'</b>';
178 echo
'<div class="sq-backend-section-note">'.translate(
'trigger_add_web_path_note').
'</div>';
179 check_box($prefix.
'[remove_all]',
'1', array_get_index($settings,
'remove_all',
'0'),
'', ($write_access ?
'' :
'disabled="disabled"'));
180 echo
'<label for='.$prefix.
'[remove_all]'.
'>'.translate(
'trigger_add_web_path_remove_all').
'.</label>';
182 check_box($prefix.
'[make_lowercase]',
'1', array_get_index($settings,
'make_lowercase',
'0'),
'', ($write_access ?
'' :
'disabled="disabled"'));
183 echo
'<label for='.$prefix.
'[make_lowercase]'.
'>'.translate(
'trigger_add_web_path_make_lowercase').
'.</label>';
185 check_box($prefix.
'[update_children]',
'1', array_get_index($settings,
'update_children',
'0'),
'', ($write_access ?
'' :
'disabled="disabled"'));
186 echo
'<label for='.$prefix.
'[update_children]'.
'>'.translate(
'trigger_add_web_path_update_children').
'.</label>';
188 check_box($prefix.
'[dont_add_remap]',
'1', array_get_index($settings,
'dont_add_remap',
'0'),
'', ($write_access ?
'' :
'disabled="disabled"'));
189 echo
'<label for='.$prefix.
'[dont_add_remap]'.
'>'.translate(
'trigger_add_web_path_dont_add_remap').
'.</label>';
190 return ob_get_clean();
208 $web_path = array_get_index($request_data,
'path',
'');
209 $web_path = trim($web_path);
210 if ($web_path ==
'') {
211 return translate(
'web_path_not_specified');
213 $settings[
'path'] = $web_path;
214 $settings[
'remove_all'] = array_get_index($request_data,
'remove_all',
'');
215 $settings[
'make_lowercase'] = array_get_index($request_data,
'make_lowercase',
'');
216 $settings[
'update_children'] = array_get_index($request_data,
'update_children',
'');
217 $settings[
'dont_add_remap'] = array_get_index($request_data,
'dont_add_remap',
'');
232 public static function getLocks($settings, &$state)
234 return Array($state[
'assetid'] => Array(
'lookups'));