本文整理汇总了PHP中FlexicontentFields::indexedField_getElements方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::indexedField_getElements方法的具体用法?PHP FlexicontentFields::indexedField_getElements怎么用?PHP FlexicontentFields::indexedField_getElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::indexedField_getElements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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/>";
}
示例2: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm', $isSearchView = 0)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
// Get indexed element values
$item_pros = false;
$elements = FlexicontentFields::indexedField_getElements($filter, $item = null, self::$extra_props, $item_pros, $create_filter = true);
$_s = $isSearchView ? '_s' : '';
$filter_vals_display = $filter->parameters->get('filter_vals_display' . $_s, 0);
$filter_as_images = in_array($filter_vals_display, array(1, 2));
if ($filter_as_images && $elements) {
// image specific variables
$imagedir = preg_replace('#^(/)*#', '', $filter->parameters->get('imagedir'));
$imgpath = JURI::root(true) . '/' . $imagedir;
foreach ($elements as $element) {
$element->image_url = $imgpath . $element->image;
}
}
// Check for error during getting indexed field elements
if (!$elements) {
$filter->html = '';
$sql_mode = $filter->parameters->get('sql_mode', 0);
// must retrieve variable here, and not before retrieving elements !
if ($sql_mode && $item_pros > 0) {
$filter->html = sprintf(JText::_('FLEXI_FIELD_ITEM_SPECIFIC_AS_FILTERABLE'), $filter->label);
} else {
if ($sql_mode) {
$filter->html = JText::_('FLEXI_FIELD_INVALID_QUERY');
} else {
$filter->html = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
}
}
return;
}
FlexicontentFields::createFilter($filter, $value, $formName, $elements);
}
示例3: renderFiltersHTML
/**
* Method to get fields values of the fields used as extra columns of the item list
*
* @access public
* @return object
*/
function renderFiltersHTML()
{
$app = JFactory::getApplication();
$jinput = $app->input;
$allowed_field_types = array_flip(array('select', 'selectmultiple', 'radio', 'radioimage', 'checkbox', 'checkboximage'));
$formName = 'adminForm';
// Set view to category before rendering the filters HTML
$view = $jinput->get('view');
$jinput->set('view', 'category');
foreach ($this->_custom_filters as $filter) {
if (!isset($allowed_field_types[$filter->field_type])) {
JFactory::getApplication()->enqueueMessage('Filter: ' . $field->name . ' is of type ' . $field->field_type . ' , allowed types for backend custom filters are: ' . implode(', ', array_keys($allowed_field_types)), 'warning');
$filter->html = '';
continue;
}
$item_pros = false;
$extra_props = $filter->field_type == 'radioimage' || $filter->field_type == 'checkboximage' ? array('image', 'valgroup') : array();
$elements = FlexicontentFields::indexedField_getElements($filter, $item = null, $extra_props, $item_pros, $create_filter = true);
$filter->parameters->set('faceted_filter', 0);
$filter->parameters->set('display_filter_as', 0);
$filter->parameters->set('display_label_filter', -1);
$filter->parameters->set('label_filter_css', 'label label-info');
$filter->parameters->set('filter_extra_attribs', ' onchange="document.adminForm.limitstart.value=0; Joomla.submitform()" ');
// Check for error during getting indexed field elements
if (!$elements) {
$filter->html = '';
$sql_mode = $filter->parameters->get('sql_mode', 0);
// must retrieve variable here, and not before retrieving elements !
if ($sql_mode && $item_pros > 0) {
$filter->html = sprintf(JText::_('FLEXI_FIELD_ITEM_SPECIFIC_AS_FILTERABLE'), $filter->label);
} else {
if ($sql_mode) {
$filter->html = JText::_('FLEXI_FIELD_INVALID_QUERY');
} else {
$filter->html = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
}
}
continue;
}
FlexicontentFields::createFilter($filter, $filter->value, $formName, $elements);
}
// Restore view
$jinput->set('view', $view);
}
示例4: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm')
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
// Get indexed element values
$item_pros = false;
$elements = FlexicontentFields::indexedField_getElements($filter, $item = null, self::$extra_props, $item_pros, $create_filter = true);
// Check for error during getting indexed field elements
if (!$elements) {
$filter->html = '';
$sql_mode = $filter->parameters->get('sql_mode', 0);
// must retrieve variable here, and not before retrieving elements !
if ($sql_mode && $item_pros > 0) {
$filter->html = sprintf(JText::_('FLEXI_FIELD_ITEM_SPECIFIC_AS_FILTERABLE'), $filter->label);
} else {
if ($sql_mode) {
$filter->html = JText::_('FLEXI_FIELD_INVALID_QUERY');
} else {
$filter->html = JText::_('FLEXI_FIELD_INVALID_ELEMENTS');
}
}
return;
}
FlexicontentFields::createFilter($filter, $value, $formName, $elements);
}
示例5: buildSelectOptions
function buildSelectOptions(&$field, &$item)
{
// Drop-down select elements depend on 'select_field_mode'
$select_field_mode = $field->parameters->get('select_field_mode', 0);
if ($select_field_mode == 0) {
// All existing values
$field_elements = ' SELECT DISTINCT value, value as text ' . ' FROM #__flexicontent_fields_item_relations ' . ' WHERE field_id={field->id} AND value != "" GROUP BY value';
} else {
// Predefined elements or Elements via an SQL query
$field_elements = $field->parameters->get('select_field_elements');
}
// Call function that parses or retrieves element via sql
$field->parameters->set('sql_mode', $select_field_mode == 0 || $select_field_mode == 2);
$field->parameters->set('field_elements', $field_elements);
$results = FlexicontentFields::indexedField_getElements($field, $item);
$options = array();
$default_prompt = $select_field_mode == 0 ? 'FLEXI_FIELD_SELECT_EXISTING_VALUE' : 'FLEXI_FIELD_SELECT_VALUE';
$field_prompt = $field->parameters->get('select_field_prompt', $default_prompt);
$options[] = JHTML::_('select.option', '', '-' . JText::_($field_prompt) . '-');
$lang_filter_values = $field->parameters->get('lang_filter_values', 0);
if ($results) {
foreach ($results as $result) {
if (!strlen($result->value)) {
continue;
}
$options[] = JHTML::_('select.option', $result->value, $lang_filter_values ? JText::_($result->text) : $result->text);
}
}
return $options;
}