51 public static function evaluate($settings, &$state)
55 if (!isset($state[
'asset_type'])) {
56 if (isset($state[
'asset'])) {
57 $state[
'asset_type'] = $state[
'asset']->type();
64 if (empty($settings[
'asset_type']))
return FALSE;
67 $selected_types = array_get_index($settings,
'asset_type', Array(
'page'));
69 if (!is_array($selected_types)) {
70 $selected_types = Array($selected_types);
73 $descendant_flags = array_get_index($settings,
'descendants', Array(FALSE));
74 if (!is_array($descendant_flags)) {
75 $descendant_flags = Array($descendant_flags);
78 foreach ($selected_types as $key => $type) {
79 if ($descendant_flags[$key]) {
80 $type_desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type, TRUE);
81 if (in_array($state[
'asset_type'], $type_desc)) {
85 if ($type == $state[
'asset_type'])
return TRUE;
106 public static function getInterface($settings, $prefix, $write_access=FALSE)
108 $selected_types = array_get_index($settings,
'asset_type', Array(
'page'));
111 if (!is_array($selected_types)) {
112 $selected_types = Array($selected_types);
115 $descendant_flags = array_get_index($settings,
'descendants', Array(FALSE));
116 if (!is_array($descendant_flags)) {
117 $descendant_flags = Array($descendant_flags);
122 asset_type_chooser($prefix, TRUE, Array(
'type_code' => $selected_types,
'inherit' => $descendant_flags), NULL, FALSE, TRUE);
124 foreach ($selected_types as $key => $type) {
127 if ($descendant_flags[$key]) {
128 echo
' ('.translate(
'or_decendant_types').
')';
134 $interface = ob_get_contents();
137 return translate(
'trigger_asset_type', $interface);
154 if (empty($request_data)) {
155 return translate(
'trigger_input_data_error');
158 $asset_type = array_get_index($request_data,
'type_code', FALSE);
160 return translate(
'trigger_type_code_not_supplied');
164 $descendants = array_get_index($request_data,
'inherit', FALSE);
166 $settings[
'asset_type'] = $asset_type;
167 $settings[
'descendants'] = $descendants;
184 public static function setHash(&$settings, &$hash)
186 if (isset($settings[
'asset_type']) && isset($settings[
'descendants'])) {
187 foreach ($settings[
'asset_type'] as $key => $type) {
188 if (empty($type))
continue;
189 $hash->setAssetType($type, ($settings[
'descendants'][$key] ==
'1' ? TRUE : FALSE));