public function get_unique_terms($input_data) { /* Parses the input data to find the list of unique terms in the tag cloud */ $unique_terms = array(); foreach ($this->term_forms as $field_id => $field) { if (array_key_exists($field_id, $input_data)) { $input_data_field = array_key_exists($field_id, $input_data) ? $input_data[$field_id] : ''; if (is_string($input_data_field)) { $case_sensitive = array_key_exists('case_sensitive', $this->term_analysis[$field_id]) ? $this->term_analysis[$field_id]->case_sensitive : true; $token_mode = array_key_exists('token_mode', $this->term_analysis[$field_id]) ? $this->term_analysis[$field_id]->token_mode : 'all'; if ($token_mode != Predicate::TM_FULL_TERM) { $terms = parse_terms($input_data_field, $case_sensitive); } else { $terms = array(); } if ($token_mode != Predicate::TM_TOKENS) { array_push($terms, $case_sensitive ? $input_data_field : strtolower($input_data_field)); } $unique_terms[$field_id] = logistic_get_unique_terms($terms, $this->term_forms[$field_id], array_key_exists($field_id, $this->tag_clouds) ? $this->tag_clouds[$field_id] : array()); } else { $unique_terms[$field_id] = array(array($input_data_field, 1)); } unset($input_data[$field_id]); } } # the same for items fields foreach ($this->item_analysis as $field_id => $value) { if (array_key_exists($field_id, $input_data)) { $input_data_field = array_key_exists($field_id, $input_data) ? $input_data[$field_id] : ''; if (is_string($input_data_field)) { $separator = property_exists($this->item_analysis[$field_id], 'separator') ? $value->separator : ' '; $regexp = property_exists($this->item_analysis[$field_id], 'separator_regexp') ? $value->separator_regexp : null; if (is_null($regexp)) { $regexp = '' . preg_quote($separator); } $terms = parse_items($input_data_field, $regexp); $unique_terms[$field_id] = get_unique_terms($terms, array(), array_key_exists($field_id, $this->items) ? $this->items[$field_id] : array()); } else { $unique_terms[$field_id] = array(array($input_data_field, 1)); } unset($input_data[$field_id]); } } foreach ($this->categories as $field_id => $value) { if (array_key_exists($field_id, $input_data)) { $input_data_field = array_key_exists($field_id, $input_data) ? $input_data[$field_id] : ''; $unique_terms[$field_id] = array(array($input_data_field, 1)); unset($input_data[$field_id]); } } return array($unique_terms, $input_data); }
function get_unique_terms($input_data) { $unique_terms = array(); foreach ($this->term_forms as $field_id => $field) { if (array_key_exists($field_id, $input_data)) { $input_data_field = array_key_exists($field_id, $input_data) ? $input_data[$field_id] : ''; if (is_string($input_data_field)) { $case_sensitive = array_key_exists('case_sensitive', $this->term_analysis[$field_id]) ? $this->term_analysis[$field_id]->case_sensitive : true; $token_mode = array_key_exists('token_mode', $this->term_analysis[$field_id]) ? $this->term_analysis[$field_id]->token_mode : 'all'; if ($token_mode != Predicate::TM_FULL_TERM) { $terms = parse_terms($input_data_field, $case_sensitive); } else { $terms = array(); } if ($token_mode != Predicate::TM_TOKENS) { array_push($terms, $case_sensitive ? $input_data_field : strtolower($input_data_field)); } $unique_terms[$field_id] = get_unique_terms($terms, $this->term_forms[$field_id], array_key_exists($field_id, $this->tag_clouds) ? $this->tag_clouds[$field_id] : array()); } else { $unique_terms[$field_id] = $input_data_field; } unset($input_data[$field_id]); } } return array($unique_terms, $input_data); }