本文整理汇总了PHP中FlexicontentFields::indexedField_getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::indexedField_getValues方法的具体用法?PHP FlexicontentFields::indexedField_getValues怎么用?PHP FlexicontentFields::indexedField_getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::indexedField_getValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createIndexRecords
static function createIndexRecords(&$field, &$values, &$item, $required_props = array(), $search_props = array(), $props_spacer = ' ', $filter_func = null, $for_advsearch = 0)
{
$fi = FlexicontentFields::getPropertySupport($field->field_type, $field->iscore);
$db = JFactory::getDBO();
// * Per language handlers e.g. word segmenter objects (add spaces between words for language without spaces)
static $lang_handlers = array();
if (!$for_advsearch) {
// Check if field type supports text search, this will also skip fields wrongly marked as text searchable
if (!$fi->supportsearch || !$field->issearch) {
$field->search = array();
return;
}
} else {
$field->ai_query_vals = array();
// Check if field type supports advanced search text searchable or filterable, this will also skip fields wrongly marked
if (!($fi->supportadvsearch && $field->isadvsearch) && !($fi->supportadvfilter && $field->isadvfilter)) {
return;
}
}
// A null indicates to retrieve values
if ($values === null) {
$items_values = FlexicontentFields::searchIndex_getFieldValues($field, $item, $for_advsearch);
} else {
$items_values = !is_array($values) ? array($values) : $values;
$items_values = array($field->item_id => $items_values);
}
// Make sure posted data is an array
$unserialize = isset($field->unserialize) ? $field->unserialize : count($required_props) || count($search_props);
// Create the new search data
foreach ($items_values as $itemid => $item_values) {
// Get item language: (a) multi-item indexing via the search indexer or (b) single item indexing via the item save task (e.g. item form)
$language = isset($field->items_data) ? $field->items_data[$itemid]->language : $item->language;
if (!isset($lang_handlers[$language])) {
$lang_handlers[$language] = FlexicontentFields::getLangHandler($language);
}
$lang_handler = $lang_handlers[$language];
if (@$field->isindexed) {
// Get Elements of the field these will be cached if they do not depend on the item ...
$field->item_id = $itemid;
// in case it needs to be loaded to replace item properties in a SQL query
$item_pros = false;
$elements = FlexicontentFields::indexedField_getElements($field, $item, $field->extra_props, $item_pros, $createFilter = true);
// Map index field vlaues to their real properties
$item_values = FlexicontentFields::indexedField_getValues($field, $elements, $item_values, $prepost_prop = '');
}
$searchindex = array();
foreach ($item_values as $vi => $v) {
// Make sure multi-property data are unserialized
if ($unserialize) {
$data = @unserialize($v);
$v = $v === 'b:0;' || $data !== false ? $data : $v;
}
// Check value that current should not be included in search index
if (!is_array($v) && !strlen($v)) {
continue;
}
foreach ($required_props as $cp) {
if (!@$v[$cp]) {
continue;
}
}
// Create search value
$search_value = array();
foreach ($search_props as $sp) {
if (isset($v[$sp]) && strlen($v[$sp])) {
$search_value[] = $v[$sp];
}
}
if (count($search_props) && !count($search_value)) {
continue;
}
// all search properties were empty, skip this value
$searchindex[$vi] = count($search_props) ? implode($props_spacer, $search_value) : $v;
$searchindex[$vi] = $filter_func ? $filter_func($searchindex[$vi]) : $searchindex[$vi];
}
// * Use word segmenter (if it was created) to add spaces between words
if ($lang_handler) {
foreach ($searchindex as $i => $_searchindex) {
$searchindex[$i] = implode(' ', $lang_handler->get_segment_array($clear_previous = true, $_searchindex));
}
}
if (!$for_advsearch) {
$field->search[$itemid] = implode(' | ', $searchindex);
} else {
$n = 0;
foreach ($searchindex as $vi => $search_text) {
// Add new search value into the DB
$query_val = "( " . $field->id . "," . $itemid . "," . $n++ . "," . $db->Quote($search_text) . "," . $db->Quote($vi) . ")";
$field->ai_query_vals[] = $query_val;
}
}
}
//echo $field->name . ": "; print_r($values);echo "<br/>";
//echo if ( !empty($searchindex) ) implode(' | ', $searchindex) ."<br/><br/>";
}