本文整理汇总了PHP中FlexicontentFields::createFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::createFilter方法的具体用法?PHP FlexicontentFields::createFilter怎么用?PHP FlexicontentFields::createFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::createFilter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: onAdvSearchDisplayFilter
public function onAdvSearchDisplayFilter(&$filter, $value = '', $formName = 'searchForm')
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
$filter->parameters->set('display_filter_as_s', 1);
// Only supports a basic filter of single text search input
FlexicontentFields::createFilter($filter, $value, $formName);
}
示例3: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm', $isSearchView = 0)
{
if ($filter->iscore != 1) {
return;
}
// performance check
$db = JFactory::getDBO();
$formfieldname = 'filter_' . $filter->id;
$_s = $isSearchView ? '_s' : '';
$display_filter_as = $filter->parameters->get('display_filter_as' . $_s, 0);
// Filter Type of Display
$faceted_filter = $filter->parameters->get('faceted_filter' . $_s, 0);
// Filter Type of Display
$disable_keyboardinput = $filter->parameters->get('disable_keyboardinput', 0);
$filter_as_range = in_array($display_filter_as, array(2, 3, 8));
// Create first prompt option of drop-down select
$label_filter = $filter->parameters->get('display_label_filter' . $_s, 2);
$first_option_txt = $label_filter == 2 ? $filter->label : JText::_('FLEXI_ALL');
// Prepend Field's Label to filter HTML
//$filter->html = $label_filter==1 ? $filter->label.': ' : '';
$filter->html = '';
switch ($filter->field_type) {
case 'title':
$_inner_lb = $label_filter == 2 ? $filter->label : JText::_('FLEXI_TYPE_TO_LIST');
$_inner_lb = flexicontent_html::escapeJsText($_inner_lb, 's');
$attribs_str = ' class="fc_field_filter fc_label_internal" data-fc_label_text="' . $_inner_lb . '"';
$filter_ffname = 'filter_' . $filter->id;
$filter_ffid = $formName . '_' . $filter->id . '_val';
$filter->html .= '<input id="' . $filter_ffid . '" name="' . $filter_ffname . '" ' . $attribs_str . ' type="text" size="20" value="' . $value . '" />';
break;
case 'createdby':
// Authors
// WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
// partial SQL clauses
$filter->filter_valuesselect = ' i.created_by AS value, CASE WHEN usr.name IS NULL THEN CONCAT(\'' . JText::_('FLEXI_NOT_ASSIGNED') . ' ID:\', i.created_by) ELSE usr.name END AS text';
$filter->filter_valuesjoin = ' JOIN #__users AS usr ON usr.id = i.created_by';
$filter->filter_valueswhere = ' AND i.created_by <> 0';
// full SQL clauses
$filter->filter_groupby = ' GROUP BY i.created_by ';
$filter->filter_having = null;
// this indicates to use default, space is use empty
$filter->filter_orderby = ' ORDER by text';
// default will order by value and not by label
FlexicontentFields::createFilter($filter, $value, $formName);
break;
case 'modifiedby':
// Modifiers
// WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
// partial SQL clauses
$filter->filter_valuesselect = ' i.modified_by AS value, CASE WHEN usr.name IS NULL THEN CONCAT(\'' . JText::_('FLEXI_NOT_ASSIGNED') . ' ID:\', i.modified_by) ELSE usr.name END AS text';
$filter->filter_valuesjoin = ' JOIN #__users AS usr ON usr.id = i.modified_by';
$filter->filter_valueswhere = ' AND i.modified_by <> 0';
// full SQL clauses
$filter->filter_groupby = ' GROUP BY i.modified_by ';
$filter->filter_having = null;
// this indicates to use default, space is use empty
$filter->filter_orderby = ' ORDER by text';
// default will order by value and not by label
FlexicontentFields::createFilter($filter, $value, $formName);
break;
case 'type':
// Document Type
// WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
// partial SQL clauses
$filter->filter_valuesselect = ' ict.id AS value, ict.name AS text';
$filter->filter_valuesjoin = '' . ' JOIN #__flexicontent_items_ext AS iext ON iext.item_id = i.id' . ' JOIN #__flexicontent_types AS ict ON iext.type_id = ict.id';
$filter->filter_valueswhere = ' ';
// ... a space, (indicates not needed and prevents using default)
// full SQL clauses
$filter->filter_groupby = ' GROUP BY ict.id';
$filter->filter_having = null;
// this indicates to use default, space is use empty
$filter->filter_orderby = ' ORDER by text';
// default will order by value and not by label
FlexicontentFields::createFilter($filter, $value, $formName);
break;
case 'state':
$options = array();
$options[] = JHTML::_('select.option', '', '- ' . $first_option_txt . ' -');
$options[] = JHTML::_('select.option', 'P', JText::_('FLEXI_PUBLISHED'));
$options[] = JHTML::_('select.option', 'U', JText::_('FLEXI_UNPUBLISHED'));
$options[] = JHTML::_('select.option', 'PE', JText::_('FLEXI_PENDING'));
$options[] = JHTML::_('select.option', 'OQ', JText::_('FLEXI_TO_WRITE'));
$options[] = JHTML::_('select.option', 'IP', JText::_('FLEXI_IN_PROGRESS'));
$options[] = JHTML::_('select.option', 'A', JText::_('FLEXI_ARCHIVED'));
//$options[] = JHTML::_('select.option', 'T', JText::_( 'FLEXI_TRASHED' ) );
break;
case 'categories':
// Initialize options
$options = array();
// MULTI-select does not has an internal label a drop-down list option
if ($display_filter_as != 6) {
$first_option_txt = $label_filter == 2 ? $filter->label : JText::_('FLEXI_ANY');
$options[] = JHTML::_('select.option', '', '- ' . $first_option_txt . ' -');
}
// Get categories
global $globalcats;
$rootcatid = $filter->parameters->get('rootcatid', '');
$option = JRequest::getVar('option', '');
$view = JRequest::getVar('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: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm', $isSearchView = 0)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
// WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
// partial SQL clauses
$filter->filter_valuesselect = ' ct.id AS value, ct.title AS text';
$filter->filter_valuesfrom = null;
// use default
$filter->filter_valuesjoin = ' JOIN #__content AS ct ON ct.id = CAST(fi.value AS UNSIGNED)';
$filter->filter_valueswhere = null;
// use default
// full SQL clauses
$filter->filter_groupby = ' GROUP BY CAST(fi.value AS UNSIGNED) ';
// * will be be appended with , fi.item_id
$filter->filter_having = null;
// use default
$filter->filter_orderby = null;
// use default, no ordering done to improve speed, it will be done inside PHP code
FlexicontentFields::createFilter($filter, $value, $formName);
}
示例6: 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);
}
示例7: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm', $isSearchView = 0)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
$_s = $isSearchView ? '_s' : '';
$date_filter_group = $filter->parameters->get('date_filter_group' . $_s, 'month');
if ($date_filter_group == 'year') {
$date_valformat = '%Y';
} else {
if ($date_filter_group == 'month') {
$date_valformat = '%Y-%m';
} else {
$date_valformat = '%Y-%m-%d';
}
}
// Display date 'label' can be different than the (aggregated) date value
$date_filter_label_format = $filter->parameters->get('date_filter_label_format' . $_s, '');
$date_txtformat = $date_filter_label_format ? $date_filter_label_format : $date_valformat;
// If empty then same as value
$db = JFactory::getDBO();
$nullDate_quoted = $db->Quote($db->getNullDate());
$display_filter_as = $filter->parameters->get('display_filter_as' . $_s, 0);
// Filter Type of Display
$filter_as_range = in_array($display_filter_as, array(2, 3, 8));
// We don't want null date if using a range
$date_source = $filter->parameters->get('date_source', 0);
if (!$date_source) {
$valuecol = sprintf(' DATE_FORMAT(fi.value, "%s") ', $date_valformat);
$textcol = sprintf(' DATE_FORMAT(fi.value, "%s") ', $date_txtformat);
} else {
$_value_col = $date_source == 1 ? 'i.publish_up' : 'i.publish_down';
$valuecol = sprintf(' CASE WHEN %s=' . $nullDate_quoted . ' THEN ' . (!$filter_as_range ? $nullDate_quoted : $db->Quote('')) . ' ELSE DATE_FORMAT(%s, "%s") END ', $_value_col, $_value_col, $date_valformat);
$textcol = sprintf(' CASE WHEN %s=' . $nullDate_quoted . ' THEN "' . JText::_('FLEXI_NEVER') . '" ELSE DATE_FORMAT(%s, "%s") END ', $_value_col, $_value_col, $date_txtformat);
}
// WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
// partial SQL clauses
$filter->filter_valuesselect = ' ' . $valuecol . ' AS value, ' . $textcol . ' AS text';
$filter->filter_valuesjoin = null;
// use default
$filter->filter_valueswhere = null;
// use default
// full SQL clauses
$filter->filter_groupby = ' GROUP BY ' . $valuecol;
$filter->filter_having = null;
// use default
if ($isSearchView) {
$filter->filter_orderby_adv = ' ORDER BY value_id';
} else {
$filter->filter_orderby = ' ORDER BY ' . $valuecol;
}
FlexicontentFields::createFilter($filter, $value, $formName);
}
示例8: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm', $isSearchView = 0)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
FlexicontentFields::createFilter($filter, $value, $formName);
}
示例9: onDisplayFilter
function onDisplayFilter(&$filter, $value='', $formName='adminForm')
{
// execute the code only if the field type match the plugin type
if ( !in_array($filter->field_type, self::$field_types) ) return;
FlexicontentFields::createFilter($filter, $value, $formName);
}
示例10: onAdvSearchDisplayFilter
function onAdvSearchDisplayFilter(&$filter, $value='', $formName='searchForm')
{
// execute the code only if the field type match the plugin type
if ( !in_array($filter->field_type, self::$field_types) ) return;
$filter->parameters->set( 'display_filter_as_s', 1 ); // Only supports a basic filter of single text search input
FlexicontentFields::createFilter($filter, $value, $formName);
}
示例11: onDisplayFilter
function onDisplayFilter(&$filter, $value='', $formName='adminForm')
{
if ( !in_array($filter->field_type, self::$field_types) ) return;
$db = JFactory::getDBO();
$formfieldname = 'filter_'.$filter->id;
$display_filter_as = $filter->parameters->get( 'display_filter_as', 0 ); // Filter Type of Display
$filter_as_range = in_array($display_filter_as, array(2,3,)) ;
// Create first prompt option of drop-down select
$label_filter = $filter->parameters->get( 'display_label_filter', 2 ) ;
$first_option_txt = $label_filter==2 ? $filter->label : JText::_('FLEXI_ALL');
// Prepend Field's Label to filter HTML
//$filter->html = $label_filter==1 ? $filter->label.': ' : '';
$filter->html = '';
$props_type = $filter->parameters->get('props_type');
switch ($props_type)
{
case 'language': // Authors
// WARNING: we can not use column alias in from, join, where, group by, can use in having (mysql) and in order by
// partial SQL clauses
if (!FLEXI_J16GE) break;
$filter->filter_valuesselect = ' i.language AS value, CONCAT_WS(\': \', lg.title, lg.title_native) AS text';
$filter->filter_valuesjoin = ' JOIN #__languages AS lg ON i.language = lg.lang_code';
$filter->filter_valueswhere = ' AND lg.published <> 0';
// full SQL clauses
$filter->filter_groupby = ' GROUP BY i.language ';
$filter->filter_having = null; // this indicates to use default, space is use empty
$filter->filter_orderby = ' ORDER BY lg.title ASC ';
FlexicontentFields::createFilter($filter, $value, $formName);
break;
default:
$filter->html .= 'CORE property field of type: '.$props_type.' can not be used as search filter';
break;
}
// a. If field filter has defined a custom SQL query to create filter (drop-down select) options, execute it and then create the options
if ( !empty($query) ) {
$db->setQuery($query);
$lists = $db->loadObjectList();
$options = array();
$options[] = JHTML::_('select.option', '', '- '.$first_option_txt.' -');
foreach ($lists as $list) $options[] = JHTML::_('select.option', $list->value, $list->text . ($count_column ? ' ('.$list->found.')' : '') );
}
// b. If field filter has defined drop-down select options the create the drop-down select form field
if ( !empty($options) ) {
// Make use of select2 lib
flexicontent_html::loadFramework('select2');
$classes = " use_select2_lib". @ $extra_classes;
$extra_param = '';
// MULTI-select: special label and prompts
if ($display_filter_as == 6) {
$classes .= ' fc_label_internal fc_prompt_internal';
// Add field's LABEL internally or click to select PROMPT (via js)
$_inner_lb = $label_filter==2 ? $filter->label : JText::_('FLEXI_CLICK_TO_LIST');
// Add type to filter PROMPT (via js)
$extra_param = ' data-fc_label_text="'.flexicontent_html::escapeJsText($_inner_lb,'s').'"';
$extra_param .= ' data-fc_prompt_text="'.flexicontent_html::escapeJsText(JText::_('FLEXI_TYPE_TO_FILTER'),'s').'"';
}
// Create HTML tag attributes
$attribs_str = ' class="fc_field_filter'.$classes.'" '.$extra_param;
$attribs_str .= $display_filter_as==6 ? ' multiple="multiple" size="20" ' : '';
//$attribs_str .= ($display_filter_as==0 || $display_filter_as==6) ? ' onchange="document.getElementById(\''.$formName.'\').submit();"' : '';
// Filter name and id
$filter_ffname = 'filter_'.$filter->id;
$filter_ffid = $formName.'_'.$filter->id.'_val';
// Create filter
$filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname.'[]', $attribs_str, 'value', 'text', $value, $filter_ffid);
}
// Special CASE 'categories' filter, replace some tags in filter HTML ...
//if ( $props_type == 'alias') $filter->html = str_replace('_', ' ', $filter->html);
}
示例12: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm')
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
$date_filter_group = $filter->parameters->get('date_filter_group', 'month');
if ($date_filter_group == 'year') {
$date_valformat = '%Y';
$date_txtformat = '%Y';
} else {
if ($date_filter_group == 'month') {
$date_valformat = '%Y-%m';
$date_txtformat = '%Y-%b';
} else {
$date_valformat = '%Y-%m-%d';
$date_txtformat = '%Y-%b-%d';
}
}
$date_source = $filter->parameters->get('date_source', 0);
if (!$date_source) {
$valuecol = sprintf(' DATE_FORMAT(fi.value, "%s") ', $date_valformat);
$textcol = sprintf(' DATE_FORMAT(fi.value, "%s") ', $date_txtformat);
} else {
$db = JFactory::getDBO();
$nullDate = $db->getNullDate();
$_value_col = $date_source == 1 ? 'i.publish_up' : 'i.publish_down';
$valuecol = sprintf(' CASE WHEN %s=' . $db->Quote($nullDate) . ' THEN "' . JText::_('FLEXI_NEVER') . '" ELSE DATE_FORMAT(%s, "%s") END ', $_value_col, $_value_col, $date_valformat);
$textcol = sprintf(' CASE WHEN %s=' . $db->Quote($nullDate) . ' THEN "' . JText::_('FLEXI_NEVER') . '" ELSE DATE_FORMAT(%s, "%s") END ', $_value_col, $_value_col, $date_txtformat);
}
$display_filter_as = $filter->parameters->get('display_filter_as', 0);
// Filter Type of Display
$filter_as_range = in_array($display_filter_as, array(2, 3));
// WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order by
// partial SQL clauses
$filter->filter_valuesselect = ' ' . $valuecol . ' AS value, ' . $textcol . ' AS text';
$filter->filter_valuesjoin = null;
// use default
$filter->filter_valueswhere = null;
// use default
// full SQL clauses
$filter->filter_groupby = ' GROUP BY ' . $valuecol;
$filter->filter_having = null;
// use default
$filter->filter_orderby = ' ORDER BY ' . $valuecol;
FlexicontentFields::createFilter($filter, $value, $formName);
}
示例13: onDisplayFilter
function onDisplayFilter(&$filter, $value = '', $formName = 'adminForm', $isSearchView = 0)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
// WARNING: we can not use column alias in from, join, where, group by, can use in having (some DB e.g. mysql) and in order-by
// partial SQL clauses
$filter->filter_valuesselect = ' i.id AS value, i.title AS text';
$filter->filter_valuesjoin = null;
// use default
$filter->filter_valueswhere = null;
// use default
// full SQL clauses
$filter->filter_groupby = null;
// use default, which is 'value'
$filter->filter_having = null;
// use default
$filter->filter_orderby = null;
// use default, no ordering done to improve speed, it will be done inside PHP code
FlexicontentFields::createFilter($filter, $value, $formName);
}