Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
trigger_condition_asset_tagged.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
19 
32 {
33 
34 
52  public static function evaluate($settings, &$state)
53  {
54  $tag_manager = $GLOBALS['SQ_SYSTEM']->getTagManager();
55 
56  $assetid = $state['assetid']; // event broadcaster
57  $tagids = array_get_index($settings, 'tagids');
58  $is_strict = array_get_index($settings, 'is_strict', FALSE);
59 
60  if (empty($tagids)) {
61  trigger_localised_error('TRIG0004', E_USER_WARNING);
62  return FALSE;
63  }
64  return $tag_manager->isAssetTaggedWith($assetid, $tagids, $is_strict);
65 
66  }//end evaluate()
67 
68 
79  public static function getInterface($settings, $prefix, $write_access=FALSE)
80  {
81  // check settings, set defaults if necessary
82  $tagids = array_get_index($settings, 'tagids', Array());
83  $is_strict = array_get_index($settings, 'is_strict', FALSE);
84 
85 
86  ob_start();
87  $strict_options[TRUE] = translate('all');
88  $strict_options[FALSE] = translate('some');
89 
90  if ($write_access) {
91  combo_box($prefix.'[is_strict]', $strict_options, FALSE, $is_strict);
92  } else {
93  echo '<strong>'.$strict_options[$is_strict].'</strong>';
94  }
95 
96  echo ' '.translate('tags_must_be_assigned');
97  echo '<br />';
98  echo '<br />';
99 
100  $interface = ob_get_contents();
101  ob_end_clean();
102 
103  ob_start();
104 
105  if ($write_access) {
106  multiple_asset_finder($prefix.'[tagids]', $tagids, Array('thesaurus_term'=>'D'));
107  } else {
108  foreach ($tagids as $tagid) {
109  echo get_asset_tag_line($tagid).'&nbsp; &nbsp;';
110  }
111  }
112 
113  $interface .= ob_get_contents();
114  ob_end_clean();
115 
116 
117  return $interface;
118 
119  }//end getInterface()
120 
121 
131  public static function processInterface(&$settings, $request_data)
132  {
133  $tagids = array_get_index($request_data, 'tagids', Array());
134  $settings['is_strict'] = (boolean) array_get_index($request_data, 'is_strict', FALSE);
135 
136  foreach ($tagids as $tag) {
137  if (empty($tag['assetid'])) continue;
138  $settings['tagids'][$tag['assetid']] = $tag['assetid'];
139  }
140 
141  return FALSE;
142 
143  }//end processInterface()
144 
145 
146 }//end class
147 
148 ?>