17 require_once SQ_CORE_PACKAGE_PATH.
'/system/conditions/condition/condition_edit_fns.inc';
42 parent::__construct();
61 if (empty($condition_data)) {
62 $condition_data = Array(
'logical_keywords' => Array(
'logical_keyword_1' =>
''),
'operator' =>
'ALL');
65 if (empty($allowed_keywords)) {
67 $dummy_asset =
new Asset();
68 $allowed_keywords = array_keys($dummy_asset->getAvailableKeywords());
70 $allowed_keywords = array_merge($allowed_keywords, array_keys(get_available_global_keywords()));
73 <table
class=
"no-borders">
75 $selected_keywords = array();
76 if (isset($condition_data[
'logical_keywords'])) {
77 $selected_keywords = array_keys($condition_data[
'logical_keywords']);
80 $selected_keywords[
'-- none --'] =
'-- '.strtolower(translate(
'none')).
' --';
83 $keyword_options = Array();
84 foreach ($allowed_keywords as $keyword) {
85 $keyword_options[$keyword] = $keyword;
90 if (!empty($allowed_keywords)) {
91 foreach ($selected_keywords as $keyword) {
92 $special_option = Array();
93 if ($i == (count($selected_keywords) - 1)) {
94 $special_option = Array(
'none' =>
'-- '.strtolower(translate(
'none')).
' --');
96 $special_option = Array(
'none' =>
'-- '.strtolower(translate(
'remove')).
' --');
99 $keyword_info = self::_getKeywordInfo($keyword, $allowed_keywords);
102 <td><strong><?php echo translate(
'logical_keyword').
' '.$i; ?></strong> </td>
106 combo_box($prefix.
'[keyword'.$i.
']', array_merge($special_option, $keyword_options), FALSE, $keyword_info[
'constant_part']);
110 if ($keyword_info[
'is_variable']) {
111 text_box($prefix.
'[name_extension_'.$i.
']', $keyword_info[
'variable_part'], 30);
114 echo ($keyword_info[
'constant_part']).array_get_index($keyword_info,
'variable_part',
'');
123 echo(translate(
'core_keyword_list_empty'));
127 <td><strong><?php echo translate(
'operator'); ?></strong></td>
131 if(isset($condition_data[
'operator'])) {
132 $operator = $condition_data[
'operator'];
135 combo_box($prefix.
'[operator]', Array(
'ALL' =>
'AND',
'ANY' =>
'OR'), FALSE, $operator);
143 Keywords are considered TRUE
if their value is non-empty and nonzero. Keywords are considered FALSE
if their value is empty or zero.
161 if (empty($allowed_keywords)) {
163 $dummy_asset =
new Asset();
164 $allowed_keywords = array_keys($dummy_asset->getAvailableKeywords());
166 $allowed_keywords = array_merge($allowed_keywords, array_keys(get_available_global_keywords()));
168 $logical_keywords = Array();
170 for ($i = 0; $i < 100; $i++) {
171 if (isset($_POST[$prefix][
'keyword'.$i])) {
172 $keyword_name = $_POST[$prefix][
'keyword'.$i];
173 if ($keyword_name !=
'none') {
174 $keyword_info = self::_getKeywordInfo($keyword_name, $allowed_keywords);
175 if ($keyword_info[
'is_variable']) {
176 if (!empty($_POST[$prefix][
'name_extension_'.$i])) {
177 $name_extension = trim($_POST[$prefix][
'name_extension_'.$i]);
178 if (!empty($name_extension)) {
179 $keyword_name = $keyword_info[
'constant_part'].$name_extension;
183 $logical_keywords[$keyword_name] =
'';
188 if (empty($logical_keywords)) {
189 $logical_keywords = Array(
'logical_keyword_1' =>
'');
193 'logical_keywords' => $logical_keywords,
194 'operator' => $_POST[$prefix][
'operator'],
225 $ret = Array(
'is_variable' => FALSE,
'constant_part' => $keyword_name,
'variable_part' =>
'');
227 $keyword_parts = Array();
228 foreach ($allowed_keywords as $allowed_keyword) {
229 if (preg_match(
'/_$/', $allowed_keyword)) {
231 if (preg_match(
'/^'.$allowed_keyword.
'(.*)$/', $keyword_name, $keyword_parts)) {
233 $ret = Array(
'is_variable' => TRUE,
'constant_part' => $allowed_keyword,
'variable_part' => $keyword_parts[1]);