static function createFilter(&$filter, $value = '', $formName = 'adminForm', $indexed_elements = false, $search_prop = '') { static $apply_cache = null; static $faceted_overlimit_msg = null; $user = JFactory::getUser(); $mainframe = JFactory::getApplication(); //$cparams = $mainframe->getParams('com_flexicontent'); $cparams = JComponentHelper::getParams('com_flexicontent'); // createFilter maybe called in backend too ... $print_logging_info = $cparams->get('print_logging_info'); $option = JRequest::getVar('option'); $view = JRequest::getVar('view'); $is_fc_component = $option == 'com_flexicontent'; $isCategoryView = $is_fc_component && $view == 'category'; $isSearchView = $is_fc_component && $view == 'search'; if ($print_logging_info) { global $fc_run_times; $start_microtime = microtime(true); } // Apply caching to filters regardless of cache setting ... $apply_cache = FLEXI_CACHE; if ($apply_cache) { $itemcache = JFactory::getCache('com_flexicontent_filters'); // Get Joomla Cache of '...items' Caching Group $itemcache->setCaching(1); // Force cache ON $itemcache->setLifeTime(FLEXI_CACHE_TIME); // Set expire time (default is 1 hour) } $isdate = in_array($filter->field_type, array('date', 'created', 'modified')) || $filter->parameters->get('isdate', 0); $default_size = $isdate ? 15 : 30; $_s = $isSearchView ? '_s' : ''; // Some parameter shortcuts $label_filter = $filter->parameters->get('display_label_filter' . $_s, 0); // How to show filter label $size = $filter->parameters->get('text_filter_size', $default_size); // Size of filter $faceted_filter = $filter->parameters->get('faceted_filter' . $_s, 2); $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)); $require_all = !in_array($display_filter_as, array(1, 2, 3)) ? $filter->parameters->get('filter_values_require_all', 0) : 0; $combine_tip = $filter->parameters->get('filter_values_require_all_tip', 0); $show_matching_items = $filter->parameters->get('show_matching_items' . $_s, 1); $show_matches = $filter_as_range || !$faceted_filter ? 0 : $show_matching_items; $hide_disabled_values = $filter->parameters->get('hide_disabled_values' . $_s, 0); $get_filter_vals = in_array($display_filter_as, array(0, 2, 4, 5, 6)); $filter_ffname = 'filter_' . $filter->id; $filter_ffid = $formName . '_' . $filter->id . '_val'; // Make sure the current filtering values match the field filter configuration to single or multi-value if (in_array($display_filter_as, array(2, 3, 5, 6))) { if (!is_array($value)) { $value = strlen($value) ? array($value) : array(); } } else { if (is_array($value)) { $value = @$value[0]; } } //print_r($value); // Alter search property name (indexed fields only), remove underscore _ at start & end of it if ($indexed_elements && $search_prop) { preg_match("/^_([a-zA-Z_0-9]+)_\$/", $search_prop, $prop_matches); $search_prop = @$prop_matches[1]; } // Get filtering values, this can be cached if not filtering according to current category filters if ($get_filter_vals) { $view_join = ''; $view_where = ''; $filters_where = array(); // *** Limiting of displayed filter values according to current category filtering, but show all field values if filter is active if ($isCategoryView) { // category view, use parameter to decide if limitting filter values global $fc_catview; if ($faceted_filter) { $view_join = @$fc_catview['join_clauses']; $view_where = $fc_catview['where_conf_only']; $filters_where = $fc_catview['filters_where']; $view_total = isset($fc_catview['view_total']) ? $fc_catview['view_total'] : 0; if ($fc_catview['alpha_where']) { $filters_where['alpha'] = $fc_catview['alpha_where']; } // we use count bellow ... so add it only if it is non-empty } } else { if ($isSearchView) { // search view, use parameter to decide if limitting filter values global $fc_searchview; if (empty($fc_searchview)) { return array(); } // search view plugin disabled ? if ($faceted_filter) { $view_join = $fc_searchview['join_clauses']; $view_where = $fc_searchview['where_conf_only']; $filters_where = $fc_searchview['filters_where']; $view_total = isset($fc_searchview['view_total']) ? $fc_searchview['view_total'] : 0; } } } $createFilterValues = !$isSearchView ? 'createFilterValues' : 'createFilterValuesSearch'; // This is hack for filter core properties to be filterable in search view without being added to the adv search index if ($filter->field_type == 'coreprops' && $view == 'search') { $createFilterValues = 'createFilterValues'; } // Get filter values considering PAGE configuration (regardless of ACTIVE filters) if ($apply_cache) { $results_page = $itemcache->call(array('FlexicontentFields', $createFilterValues), $filter, $view_join, $view_where, array(), $indexed_elements, $search_prop); } else { if (!$isSearchView) { $results_page = FlexicontentFields::createFilterValues($filter, $view_join, $view_where, array(), $indexed_elements, $search_prop); } else { $results_page = FlexicontentFields::createFilterValuesSearch($filter, $view_join, $view_where, array(), $indexed_elements, $search_prop); } } // Get filter values considering ACTIVE filters, but only if there is at least ONE filter active $faceted_max_item_limit = 10000; if ($faceted_filter == 2 && count($filters_where)) { if ($view_total <= $faceted_max_item_limit) { // DO NOT cache at this point the filter combinations are endless, so they will produce big amounts of cached data, that will be rarely used ... if (!$isSearchView) { $results_active = FlexicontentFields::createFilterValues($filter, $view_join, $view_where, $filters_where, $indexed_elements, $search_prop); } else { $results_active = FlexicontentFields::createFilterValuesSearch($filter, $view_join, $view_where, $filters_where, $indexed_elements, $search_prop); } } else { if ($faceted_overlimit_msg === null) { // Set a notice message about not counting item per filter values and instead showing item TOTAL of current category / view $faceted_overlimit_msg = 1; $filter_messages = JRequest::getVar('filter_message', array()); $filter_messages[] = JText::sprintf('FLEXI_FACETED_ITEM_LIST_OVER_LIMIT', $faceted_max_item_limit, $view_total); JRequest::setVar('filter_messages', $filter_messages); } } } // Decide which results to show those based: (a) on active filters or (b) on page configuration // This depends if hiding disabled values (for FACETED: 2) AND if active filters exist $use_active_vals = $hide_disabled_values && isset($results_active); $results_shown = $use_active_vals ? $results_active : $results_page; $update_found = !$use_active_vals && isset($results_active); // Set usage counters $results = array(); foreach ($results_shown as $i => $result) { $results[$i] = $result; // FACETED: 0,1 or NOT showing usage // Set usage to non-zero value e.g. -1 ... which maybe used (e.g. disabling values) but not be displayed if (!$show_matches || $faceted_filter < 2) { $results[$i]->found = -1; } else { if ($update_found) { $results[$i]->found = (int) @$results_active[$i]->found; } else { } } // Append value usage to value's label if ($faceted_filter == 2 && $show_matches && $results[$i]->found) { $results[$i]->text .= ' (' . $results[$i]->found . ')'; } } } else { $faceted_filter = 0; // clear faceted filter flag } // Prepend Field's Label to filter HTML // Commented out because it was moved in to form template file //$filter->html = $label_filter==1 ? $filter->label.': ' : ''; $filter->html = ''; // *** Create the form field(s) used for filtering switch ($display_filter_as) { case 0: case 2: case 6: // 0: Select (single value selectable), 2: Dual select (value range), 6: Multi Select (multiple values selectable) $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 . ' -'); } // Make use of select2 lib flexicontent_html::loadFramework('select2'); $classes = " use_select2_lib"; $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 .= ' 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();"' : ''; foreach ($results as $result) { if (!strlen($result->value)) { continue; } $options[] = JHTML::_('select.option', $result->value, $result->text, 'value', 'text', $disabled = $faceted_filter == 2 && !$result->found); } if ($display_filter_as == 6 && $combine_tip) { $filter->html .= ' <span class="fc_filter_tip_inline">' . JText::_(!$require_all ? 'FLEXI_ANY_OF' : 'FLEXI_ALL_OF') . '</span> '; } if ($display_filter_as == 0 || $display_filter_as == 6) { $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[]', $attribs_str, 'value', 'text', $value, $filter_ffid); } else { $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[1]', $attribs_str, 'value', 'text', @$value[1], $filter_ffid . '1'); $filter->html .= '<span class="fc_range"></span>'; $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[2]', $attribs_str, 'value', 'text', @$value[2], $filter_ffid . '2'); } break; case 1: case 3: // (TODO: autocomplete) ... 1: Text input, 3: Dual text input (value range), both of these can be JS date calendars $_inner_lb = $label_filter == 2 ? $filter->label : JText::_($isdate ? 'FLEXI_CLICK_CALENDAR' : 'FLEXI_TYPE_TO_LIST'); $_inner_lb = flexicontent_html::escapeJsText($_inner_lb, 's'); $attribs_str = ' class="fc_field_filter fc_label_internal fc_iscalendar" data-fc_label_text="' . $_inner_lb . '"'; $attribs_arr = array('class' => 'fc_field_filter fc_label_internal fc_iscalendar', 'data-fc_label_text' => $_inner_lb); if ($display_filter_as == 1) { if ($isdate) { $filter->html .= FlexicontentFields::createCalendarField($value, $allowtime = 0, $filter_ffname, $filter_ffid, $attribs_arr); } else { $filter->html .= '<input id="' . $filter_ffid . '" name="' . $filter_ffname . '" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value . '" />'; } } else { if ($isdate) { $filter->html .= '<span class="fc_filter_element">'; $filter->html .= FlexicontentFields::createCalendarField(@$value[1], $allowtime = 0, $filter_ffname . '[1]', $filter_ffid . '1', $attribs_arr); $filter->html .= '</span>'; $filter->html .= '<span class="fc_range"></span>'; $filter->html .= '<span class="fc_filter_element">'; $filter->html .= FlexicontentFields::createCalendarField(@$value[2], $allowtime = 0, $filter_ffname . '[2]', $filter_ffid . '2', $attribs_arr); $filter->html .= '</span>'; } else { $size = (int) ($size / 2); $filter->html .= '<span class="fc_filter_element">'; $filter->html .= '<input name="' . $filter_ffname . '[1]" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value[1] . '" />'; $filter->html .= '</span>'; $filter->html .= '<span class="fc_range"></span>'; $filter->html .= '<span class="fc_filter_element">'; $filter->html .= '<input name="' . $filter_ffname . '[2]" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value[2] . '" />' . "\n"; $filter->html .= '</span>'; } } break; case 4: case 5: // 4: radio (single value selectable), 5: checkbox (multiple values selectable) $lf_min = 10; // add parameter for this ? $add_lf = count($results) >= $lf_min; if ($add_lf) { flexicontent_html::loadFramework('mCSB'); } $clear_values = 0; $value_style = $clear_values ? 'float:left; clear:both;' : ''; $i = 0; $checked = $display_filter_as == 5 ? !count($value) || !strlen(reset($value)) : !strlen($value); $checked_attr = $checked ? 'checked="checked"' : ''; $checked_class = $checked ? 'fc_highlight' : ''; $checked_class_li = $checked ? ' fc_checkradio_checked' : ''; $filter->html .= '<span class="fc_checkradio_group_wrapper fc_add_scroller' . ($add_lf ? ' fc_list_filter_wrapper' : '') . '">'; $filter->html .= '<ul class="fc_field_filter fc_checkradio_group' . ($add_lf ? ' fc_list_filter' : '') . '">'; $filter->html .= '<li class="fc_checkradio_option fc_checkradio_special' . $checked_class_li . '" style="' . $value_style . '">'; $filter->html .= $label_filter == 2 ? ' <span class="fc_filter_label_inline">' . $filter->label . '</span> ' : ''; if ($display_filter_as == 4) { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClassGrp(this, \'fc_highlight\', 1);" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="radio" name="' . $filter_ffname . '" '; $filter->html .= ' value="" ' . $checked_attr . ' class="fc_checkradio" />'; } else { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClass(this, \'fc_highlight\', 1);" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="checkbox" name="' . $filter_ffname . '[' . $i . ']" '; $filter->html .= ' value="" ' . $checked_attr . ' class="fc_checkradio" />'; } $filter->html .= '<label class="hasTip ' . $checked_class . '" for="' . $filter_ffid . $i . '" ' . ' title="::' . JText::_('FLEXI_REMOVE_ALL') . '"' . ($checked ? ' style="display:none!important;" ' : 'style="background:none!important; padding-left:0px!important;"') . '>' . '<span class="fc_delall_filters"></span>'; $filter->html .= '</label> ' . ($combine_tip ? ' <span class="fc_filter_tip_inline">' . JText::_(!$require_all ? 'FLEXI_ANY_OF' : 'FLEXI_ALL_OF') . '</span> ' : '') . ' </li>'; $i++; foreach ($results as $result) { if (!strlen($result->value)) { continue; } $checked = $display_filter_as == 5 ? in_array($result->value, $value) : $result->value == $value; $checked_attr = $checked ? ' checked=checked ' : ''; $disable_attr = $faceted_filter == 2 && !$result->found ? ' disabled=disabled ' : ''; $checked_class = $checked ? 'fc_highlight' : ''; $checked_class .= $faceted_filter == 2 && !$result->found ? ' fcdisabled ' : ''; $checked_class_li = $checked ? ' fc_checkradio_checked' : ''; $filter->html .= '<li class="fc_checkradio_option' . $checked_class_li . '" style="' . $value_style . '">'; if ($display_filter_as == 4) { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClassGrp(this, \'fc_highlight\');" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="radio" name="' . $filter_ffname . '" '; $filter->html .= ' value="' . $result->value . '" ' . $checked_attr . $disable_attr . ' class="fc_checkradio" />'; } else { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClass(this, \'fc_highlight\');" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="checkbox" name="' . $filter_ffname . '[' . $i . ']" '; $filter->html .= ' value="' . $result->value . '" ' . $checked_attr . $disable_attr . ' class="fc_checkradio" />'; } $filter->html .= '<label class="' . $checked_class . '" for="' . $filter_ffid . $i . '">'; $filter->html .= $result->text; $filter->html .= '</label>'; $filter->html .= '</li>'; $i++; } $filter->html .= '</ul>'; $filter->html .= '</span>'; break; } if ($print_logging_info) { $current_filter_creation = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; $flt_active_count = isset($filters_where) ? count($filters_where) : 0; $faceted_str = array(0 => 'non-FACETED ', 1 => 'FACETED: current view (cacheable) ', 2 => 'FACETED: current filters:' . " (" . $flt_active_count . ' active) '); $fc_run_times['create_filter'][$filter->name] = $current_filter_creation; if (isset($fc_run_times['_create_filter_init'])) { $fc_run_times['create_filter'][$filter->name] -= $fc_run_times['_create_filter_init']; $fc_run_times['create_filter_init'] = $fc_run_times['_create_filter_init']; unset($fc_run_times['_create_filter_init']); } $fc_run_times['create_filter_type'][$filter->name] = $faceted_str[$faceted_filter]; } //$filter_display_typestr = array(0=>'Single Select', 1=>'Single Text', 2=>'Range Dual Select', 3=>'Range Dual Text', 4=>'Radio Buttons', 5=>'Checkbox Buttons'); //echo "FIELD name: <b>". $filter->name ."</b> Field Type: <b>". $filter->field_type."</b> Filter Type: <b>". $filter_display_typestr[$display_filter_as] ."</b> (".$display_filter_as.") ".sprintf(" %.2f s",$current_filter_creation/1000000)." <br/>"; }
static function createFilter(&$filter, $value = '', $formName = 'adminForm', $indexed_elements = false, $search_prop = '') { static $apply_cache = null; static $faceted_overlimit_msg = null; $user = JFactory::getUser(); $cparams = JComponentHelper::getParams('com_flexicontent'); // createFilter maybe called in backend too ... $print_logging_info = $cparams->get('print_logging_info'); $option = JRequest::getVar('option'); $view = JRequest::getVar('view'); $is_fc_component = $option == 'com_flexicontent'; $isCategoryView = $is_fc_component && $view == 'category'; $isSearchView = $is_fc_component && $view == 'search'; if ($print_logging_info) { global $fc_run_times; $start_microtime = microtime(true); } // Apply caching to filters regardless of cache setting ... $apply_cache = FLEXI_CACHE; if ($apply_cache) { $itemcache = JFactory::getCache('com_flexicontent_filters'); // Get Joomla Cache of '...items' Caching Group $itemcache->setCaching(1); // Force cache ON $itemcache->setLifeTime(FLEXI_CACHE_TIME); // Set expire time (default is 1 hour) } $isDate = in_array($filter->field_type, array('date', 'created', 'modified')) || $filter->parameters->get('isdate', 0); $default_size = $isDate ? 15 : 30; $_s = $isSearchView ? '_s' : ''; // Some parameter shortcuts $label_filter = $filter->parameters->get('display_label_filter' . $_s, 0); // How to show filter label $size = $filter->parameters->get('text_filter_size', $default_size); // Size of filter $faceted_filter = $filter->parameters->get('faceted_filter' . $_s, 2); $display_filter_as = $filter->parameters->get('display_filter_as' . $_s, 0); // Filter Type of Display $isSlider = $display_filter_as == 7 || $display_filter_as == 8; $slider_display_config = $filter->parameters->get('slider_display_config' . $_s, 1); // Slider found values: 1 or custom values/labels: 2 $filter_vals_display = $filter->parameters->get('filter_vals_display' . $_s, 0); $isRange = in_array($display_filter_as, array(2, 3, 8)); $require_all_param = $filter->parameters->get('filter_values_require_all', 0); $require_all = count($value) > 1 && !$isRange ? $require_all_param : 0; $combine_tip = $filter->parameters->get('filter_values_require_all_tip', 0); $show_matching_items = $filter->parameters->get('show_matching_items' . $_s, 1); $show_matches = $isRange || !$faceted_filter ? 0 : $show_matching_items; $hide_disabled_values = $filter->parameters->get('hide_disabled_values' . $_s, 0); $get_filter_vals = in_array($display_filter_as, array(0, 2, 4, 5, 6)) || $isSlider && $slider_display_config == 1; $filter_ffname = 'filter_' . $filter->id; $filter_ffid = $formName . '_' . $filter->id . '_val'; // Make sure the current filtering values match the field filter configuration to single or multi-value if (in_array($display_filter_as, array(2, 3, 5, 6, 8))) { if (!is_array($value)) { $value = strlen($value) ? array($value) : array(); } } else { if (is_array($value)) { $value = @$value[0]; } } // Escape values for output if (!is_array($value)) { $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); } else { foreach ($value as $i => $v) { $value[$i] = htmlspecialchars($value[$i], ENT_COMPAT, 'UTF-8'); } } // Alter search property name (indexed fields only), remove underscore _ at start & end of it if ($indexed_elements && $search_prop) { preg_match("/^_([a-zA-Z_0-9]+)_\$/", $search_prop, $prop_matches); $search_prop = @$prop_matches[1]; } // Get filtering values, this can be cached if not filtering according to current category filters if ($get_filter_vals) { $view_join = ''; $view_join_n_text = ''; $view_where = ''; $filters_where = array(); $text_search = ''; $view_total = 0; // *** Limiting of displayed filter values according to current category filtering, but show all field values if filter is active if ($isCategoryView) { // category view, use parameter to decide if limitting filter values global $fc_catview; if ($faceted_filter) { $view_join = @$fc_catview['join_clauses']; $view_join_n_text = @$fc_catview['join_clauses_with_text']; $view_where = @$fc_catview['where_conf_only']; $filters_where = @$fc_catview['filters_where']; $text_search = $fc_catview['search']; $view_total = isset($fc_catview['view_total']) ? $fc_catview['view_total'] : 0; } } else { if ($isSearchView) { // search view, use parameter to decide if limitting filter values global $fc_searchview; if (empty($fc_searchview)) { return array(); } // search view plugin disabled ? if ($faceted_filter) { $view_join = $fc_searchview['join_clauses']; $view_join_n_text = $fc_searchview['join_clauses_with_text']; $view_where = $fc_searchview['where_conf_only']; $filters_where = $fc_searchview['filters_where']; $text_search = $fc_searchview['search']; $view_total = isset($fc_searchview['view_total']) ? $fc_searchview['view_total'] : 0; } } } $createFilterValues = !$isSearchView ? 'createFilterValues' : 'createFilterValuesSearch'; // This is hack for filter core properties to be filterable in search view without being added to the adv search index if ($filter->field_type == 'coreprops' && $view == 'search') { $createFilterValues = 'createFilterValues'; } // Get filter values considering PAGE configuration (regardless of ACTIVE filters) if ($apply_cache) { $results_page = $itemcache->call(array('FlexicontentFields', $createFilterValues), $filter, $view_join, $view_where, array(), $indexed_elements, $search_prop); } else { if (!$isSearchView) { $results_page = FlexicontentFields::createFilterValues($filter, $view_join, $view_where, array(), $indexed_elements, $search_prop); } else { $results_page = FlexicontentFields::createFilterValuesSearch($filter, $view_join, $view_where, array(), $indexed_elements, $search_prop); } } // Get filter values considering ACTIVE filters, but only if there is at least ONE filter active $faceted_max_item_limit = 10000; if ($faceted_filter == 2) { if ($view_total <= $faceted_max_item_limit) { // DO NOT cache at this point the filter combinations are endless, so they will produce big amounts of cached data, that will be rarely used ... // but if only a single filter is active we can get the cached result of it ... because its own filter_where is not used for the filter itself if (!$text_search && (count($filters_where) == 0 || count($filters_where) == 1 && isset($filters_where[$filter->id]))) { $results_active = $results_page; } else { if (!$isSearchView) { $results_active = FlexicontentFields::createFilterValues($filter, $view_join_n_text, $view_where, $filters_where, $indexed_elements, $search_prop); } else { $results_active = FlexicontentFields::createFilterValuesSearch($filter, $view_join_n_text, $view_where, $filters_where, $indexed_elements, $search_prop); } } } else { if ($faceted_overlimit_msg === null) { // Set a notice message about not counting item per filter values and instead showing item TOTAL of current category / view $faceted_overlimit_msg = 1; $filter_messages = JRequest::getVar('filter_message', array()); $filter_messages[] = JText::sprintf('FLEXI_FACETED_ITEM_LIST_OVER_LIMIT', $faceted_max_item_limit, $view_total); JRequest::setVar('filter_messages', $filter_messages); } } } // Decide which results to show those based: (a) on active filters or (b) on page configuration // This depends if hiding disabled values (for FACETED: 2) AND if active filters exist $use_active_vals = $hide_disabled_values && isset($results_active); $results_shown = $use_active_vals ? $results_active : $results_page; $update_found = !$use_active_vals && isset($results_active); // Set usage counters $add_usage_counters = $faceted_filter == 2 && $show_matches; $results = array(); foreach ($results_shown as $i => $result) { $results[$i] = $result; // FACETED: 0,1 or NOT showing usage // Set usage to non-zero value e.g. -1 ... which maybe used (e.g. disabling values) but not be displayed if (!$show_matches || $faceted_filter < 2) { $results[$i]->found = -1; } else { if ($update_found) { $results[$i]->found = (int) @$results_active[$i]->found; } else { } } // Append value usage to value's label if ($add_usage_counters && $results[$i]->found) { $results[$i]->text .= ' (' . $results[$i]->found . ')'; } // THESE for indexed fields should have been cloned, so it is ok to modify } } else { $add_usage_counters = false; $faceted_filter = 0; // clear faceted filter flag } // Prepend Field's Label to filter HTML // Commented out because it was moved in to form template file //$filter->html = $label_filter==1 ? $filter->label.': ' : ''; $filter->html = ''; // *** Create the form field(s) used for filtering switch ($display_filter_as) { case 0: case 2: case 6: // 0: Select (single value selectable), 2: Dual select (value range), 6: Multi Select (multiple values selectable) $options = array(); // MULTI-select does not has an internal label a drop-down list option if ($display_filter_as != 6) { if ($label_filter == -1) { // *** e.g. BACKEND ITEMS MANAGER custom filter $filter->html = '<span class="' . $filter->parameters->get('label_filter_css' . $_s, 'label') . '">' . $filter->label . '</span>'; $first_option_txt = ''; } else { if ($label_filter == 2) { $first_option_txt = $filter->label; } else { $first_option_txt = $filter->parameters->get('filter_usefirstoption' . $_s, 0) ? $filter->parameters->get('filter_firstoptiontext' . $_s, 'FLEXI_ALL') : 'FLEXI_ANY'; $first_option_txt = JText::_($first_option_txt); } } $options[] = JHTML::_('select.option', '', !$first_option_txt ? '-' : '- ' . $first_option_txt . ' -'); } foreach ($results as $result) { if (!strlen($result->value)) { continue; } $options[] = JHTML::_('select.option', $result->value, $result->text, 'value', 'text', $disabled = $faceted_filter == 2 && !$result->found); } // Make use of select2 lib flexicontent_html::loadFramework('select2'); $classes = " use_select2_lib"; $extra_param = ''; // MULTI-select: special label and prompts if ($display_filter_as == 6) { //$classes .= ' fc_label_internal fc_prompt_internal'; $classes .= ' 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 = ' placeholder="' . 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" ' : ''; if ($extra_attribs = $filter->parameters->get('filter_extra_attribs' . $_s, '')) { $attribs_str .= $extra_attribs; } //$attribs_str .= ($display_filter_as==0 || $display_filter_as==6) ? ' onchange="document.getElementById(\''.$formName.'\').submit();"' : ''; if ($display_filter_as == 6 && $combine_tip) { $filter->html .= ' <span class="fc_filter_tip_inline badge badge-info">' . JText::_(!$require_all_param ? 'FLEXI_ANY_OF' : 'FLEXI_ALL_OF') . '</span> '; } if ($display_filter_as == 0) { $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname, $attribs_str, 'value', 'text', $value, $filter_ffid); } else { if ($display_filter_as == 6) { $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[]', $attribs_str, 'value', 'text', $value, $filter_ffid); } else { $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[1]', $attribs_str, 'value', 'text', @$value[1], $filter_ffid . '1'); $filter->html .= '<span class="fc_range"></span>'; $filter->html .= JHTML::_('select.genericlist', $options, $filter_ffname . '[2]', $attribs_str, 'value', 'text', @$value[2], $filter_ffid . '2'); } } break; case 1: case 3: case 7: case 8: // (TODO: autocomplete) ... 1: Text input, 3: Dual text input (value range), both of these can be JS date calendars, 7: Slider, 8: Slider range if (!$isSlider) { $_inner_lb = $label_filter == 2 ? $filter->label : JText::_($isDate ? 'FLEXI_CLICK_CALENDAR' : ''); $_inner_lb = flexicontent_html::escapeJsText($_inner_lb, 's'); //$attribs_str = ' class="fc_field_filter fc_label_internal '.($isDate ? 'fc_iscalendar' : '').'" data-fc_label_text="'.$_inner_lb.'"'; //$attribs_arr = array('class'=>'fc_field_filter fc_label_internal '.($isDate ? 'fc_iscalendar' : '').'', 'data-fc_label_text' => $_inner_lb ); $attribs_str = ' class="fc_field_filter ' . ($isDate ? 'fc_iscalendar' : '') . '" placeholder="' . $_inner_lb . '"'; $attribs_arr = array('class' => 'fc_field_filter ' . ($isDate ? 'fc_iscalendar' : '') . '', 'placeholder' => $_inner_lb); } else { $attribs_str = ""; $value1 = $display_filter_as == 8 ? @$value[1] : $value; $value2 = @$value[2]; if ($isSlider && $slider_display_config == 1) { $start = $min = 0; $end = $max = -1; $step = 1; $step_values = array(0 => "''"); $step_labels = array(0 => JText::_('FLEXI_ANY')); $i = 1; foreach ($results as $result) { if (!strlen($result->value)) { continue; } $step_values[] = "'" . $result->value . "'"; $step_labels[] = $result->text; if ($result->value == $value1) { $start = $i; } if ($result->value == $value2) { $end = $i; } $i++; } // Set max according considering the skipped empty values $max = $i - 1 + ($display_filter_as == 7 ? 0 : 1); //count($results)-1; if ($end == -1) { $end = $max; } // Set end to last element if it was not set if ($display_filter_as == 8) { $step_values[] = "''"; $step_labels[] = JText::_('FLEXI_ANY'); } $step_range = "step: 1,\n\t\t\t\t\t\t\trange: {'min': " . $min . ", 'max': " . $max . "},"; } else { if ($isSlider) { $custom_range = $filter->parameters->get('slider_custom_range' . $_s, "'min': '', '25%': 500, '50%': 2000, '75%': 10000, 'max': ''"); $custom_labels = preg_split("/\\s*##\\s*/u", $filter->parameters->get('slider_custom_labels' . $_s, 'label_any ## label_500 ## label_2000 ## label_10000 ## label_any')); if ($filter->parameters->get('slider_custom_labels_jtext' . $_s, 0)) { foreach ($custom_labels as $i => $custom_label) { $custom_labels[$i] = JText::_($custom_label); } // Language filter the custom labels } $custom_vals = json_decode('{' . str_replace("'", '"', $custom_range) . '}', true); if (!$custom_vals) { $filter->html = ' <div class="alert"> Bad syntax for custom range for slider filter: ' . $filter->label . "\n\t\t\t\t\t\t\t\tEXAMPLE: <br/> 'min': 0, '25%': 500, '50%': 2000, '75%': 10000, 'max': 50000" . ' </div>'; break; } if (!strlen($custom_vals['min'])) { $custom_vals['min'] = "''"; } if (!strlen($custom_vals['max'])) { $custom_vals['max'] = "''"; } $start = 0; $end = count($custom_vals) - 1; $step_values = $custom_vals; $step_labels =& $custom_labels; $i = 0; $set_start = strlen($value1) > 0; $set_end = strlen($value1) > 0; foreach ($custom_vals as $n => $custom_val) { if ($set_start && $custom_val == $value1) { $start = $i; } if ($set_end && $custom_val == $value2) { $end = $i; } $custom_vals[$n] = $i++; } $step_range = ' snap: true, range: ' . json_encode($custom_vals) . ', '; } } flexicontent_html::loadFramework('nouislider'); $left_no = $display_filter_as == 7 ? '' : '1'; $rght_no = '2'; // sometimes unused $js = "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tvar slider = document.getElementById('" . $filter_ffid . "_nouislider');\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar input1 = document.getElementById('" . $filter_ffid . $left_no . "');\n\t\t\t\t\t\tvar input2 = document.getElementById('" . $filter_ffid . $rght_no . "');\n\t\t\t\t\t\tvar isSingle = " . ($display_filter_as == 7 ? '1' : '0') . ";\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar step_values = [" . implode(', ', $step_values) . "];\n\t\t\t\t\t\tvar step_labels = [\"" . implode('", "', array_map('addslashes', $step_labels)) . "\"];\n\t\t\t\t\t\t\n\t\t\t\t\t\tnoUiSlider.create(slider, {" . ($display_filter_as == 7 ? "\n\t\t\t\t\t\t\t\tstart: " . $start . ",\n\t\t\t\t\t\t\t\tconnect: false,\n\t\t\t\t\t\t\t" : "\n\t\t\t\t\t\t\t\tstart: [" . $start . ", " . $end . "],\n\t\t\t\t\t\t\t\tconnect: true,\n\t\t\t\t\t\t\t") . "\n\t\t\t\t\t\t\t\t" . $step_range . "\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar tipHandles = slider.getElementsByClassName('noUi-handle'),\n\t\t\t\t\t\ttooltips = [];\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Add divs to the slider handles.\n\t\t\t\t\t\tfor ( var i = 0; i < tipHandles.length; i++ ){\n\t\t\t\t\t\t\ttooltips[i] = document.createElement('span');\n\t\t\t\t\t\t\ttipHandles[i].appendChild(tooltips[i]);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\ttooltips[i].className += 'fc-sliderTooltip'; // Add a class for styling\n\t\t\t\t\t\t\ttooltips[i].innerHTML = '<span></span>'; // Add additional markup\n\t\t\t\t\t\t\ttooltips[i] = tooltips[i].getElementsByTagName('span')[0]; // Replace the tooltip reference with the span we just added\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t// When the slider changes, display the value in the tooltips and set it into the input form elements\n\t\t\t\t\t\tslider.noUiSlider.on('update', function( values, handle ) {\n\t\t\t\t\t\t\tvar value = parseInt(values[handle]);\n\t\t\t\t\t\t\tvar i = value;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif ( handle ) {\n\t\t\t\t\t\t\t\tinput2.value = typeof step_values[value] !== 'undefined' ? step_values[value] : value;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinput1.value = typeof step_values[value] !== 'undefined' ? step_values[value] : value;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar tooltip_text = typeof step_labels[value] !== 'undefined' ? step_labels[value] : value;\n\t\t\t\t\t\t\tvar max_len = 36;\n\t\t\t\t\t\t\ttooltips[handle].innerHTML = tooltip_text.length > max_len+4 ? tooltip_text.substring(0, max_len)+' ...' : tooltip_text;\n\t\t\t\t\t\t\tvar left = jQuery(tooltips[handle]).closest('.noUi-origin').position().left;\n\t\t\t\t\t\t\tvar width = jQuery(tooltips[handle]).closest('.noUi-base').width();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t//window.console.log ('handle: ' + handle + ', left : ' + left + ', width : ' + width);\n\t\t\t\t\t\t\tif (isSingle) {\n\t\t\t\t\t\t\t\tleft<(50/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-left').addClass('fc-right') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-right').addClass('fc-left');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (handle) {\n\t\t\t\t\t\t\t\tleft<=(76/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-left').addClass('fc-right') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-right').addClass('fc-left');\n\t\t\t\t\t\t\t\tleft<=(49/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().addClass('fc-bottom') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-bottom');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tleft>=(24/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-right').addClass('fc-left') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-left').addClass('fc-right');\n\t\t\t\t\t\t\t\tleft>=(51/100)*width ?\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().addClass('fc-bottom') :\n\t\t\t\t\t\t\t\t\tjQuery(tooltips[handle]).parent().removeClass('fc-bottom');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t// Handle form autosubmit\n\t\t\t\t\t\tslider.noUiSlider.on('change', function() {\n\t\t\t\t\t\t\tvar slider = jQuery('#" . $filter_ffid . "_nouislider');\n\t\t\t\t\t\t\tvar jform = slider.closest('form');\n\t\t\t\t\t\t\tvar form = jform.get(0);\n\t\t\t\t\t\t\tadminFormPrepare(form, parseInt(jform.attr('data-fc-autosubmit')));\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tinput1.addEventListener('change', function(){\n\t\t\t\t\t\t\tvar value = 0; // default is first value = empty\n\t\t\t\t\t\t\tfor(var i=1; i<step_values.length-1; i++) {\n\t\t\t\t\t\t\t\tif (step_values[i] == this.value) { value=i; break; }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tslider.noUiSlider.set([value, null]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t" . ($display_filter_as == 8 ? "\n\t\t\t\t\t\tinput2.addEventListener('change', function(){\n\t\t\t\t\t\t\tvar value = step_values.length-1; // default is last value = empty\n\t\t\t\t\t\t\tfor(var i=1; i<step_values.length-1; i++) {\n\t\t\t\t\t\t\t\tif (step_values[i] == this.value) { value=i; break; }\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tslider.noUiSlider.set([null, value]);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t" : "") . "\n\t\t\t\t\t});\n\t\t\t\t"; JFactory::getDocument()->addScriptDeclaration($js); //JFactory::getDocument()->addStyleDeclaration(""); } if ($display_filter_as == 1 || $display_filter_as == 7) { if ($isDate && !$isSlider) { $filter->html .= ' <span class="fc_filter_element"> ' . FlexicontentFields::createCalendarField($value, $allowtime = 0, $filter_ffname, $filter_ffid, $attribs_arr) . ' </span>'; } else { $filter->html .= ($isSlider ? '<div id="' . $filter_ffid . '_nouislider" class="fcfilter_with_nouislider"></div><div class="fc_slider_input_box">' : '') . ' <span class="fc_filter_element"> <input id="' . $filter_ffid . '" name="' . $filter_ffname . '" ' . $attribs_str . ' type="text" size="' . $size . '" value="' . @$value . '" /> </span> ' . ($isSlider ? '</div>' : ''); } } else { if ($isDate && !$isSlider) { $filter->html .= ' <span class="fc_filter_element"> ' . FlexicontentFields::createCalendarField(@$value[1], $allowtime = 0, $filter_ffname . '[1]', $filter_ffid . '1', $attribs_arr) . ' </span> <span class="fc_range"></span> <span class="fc_filter_element"> ' . FlexicontentFields::createCalendarField(@$value[2], $allowtime = 0, $filter_ffname . '[2]', $filter_ffid . '2', $attribs_arr) . ' </span>'; } else { $size = (int) ($size / 2); $filter->html .= ($isSlider ? '<div id="' . $filter_ffid . '_nouislider" class="fcfilter_with_nouislider"></div><div class="fc_slider_input_box">' : '') . ' <span class="fc_filter_element"> <input name="' . $filter_ffname . '[1]" ' . $attribs_str . ' id="' . $filter_ffid . '1" type="text" size="' . $size . '" value="' . @$value[1] . '" /> </span> <span class="fc_range"></span> <span class="fc_filter_element"> <input name="' . $filter_ffname . '[2]" ' . $attribs_str . ' id="' . $filter_ffid . '2" type="text" size="' . $size . '" value="' . @$value[2] . '" /> </span> ' . ($isSlider ? '</div>' : ''); } } break; case 4: case 5: // 4: radio (single value selectable), 5: checkbox (multiple values selectable) $lf_min = 10; // add parameter for this ? $add_lf = count($results) >= $lf_min; if ($add_lf) { flexicontent_html::loadFramework('mCSB'); } $clear_values = 0; $value_style = $clear_values ? 'float:left; clear:both;' : ''; $i = 0; $checked = $display_filter_as == 5 ? !count($value) || !strlen(reset($value)) : !strlen($value); $checked_attr = $checked ? 'checked="checked"' : ''; $checked_class = $checked ? 'fc_highlight' : ''; $checked_class_li = $checked ? ' fc_checkradio_checked' : ''; $filter->html .= '<div class="fc_checkradio_group_wrapper fc_add_scroller' . ($add_lf ? ' fc_list_filter_wrapper' : '') . '">'; $filter->html .= '<ul class="fc_field_filter fc_checkradio_group' . ($add_lf ? ' fc_list_filter' : '') . '">'; $filter->html .= '<li class="fc_checkradio_option fc_checkradio_special' . $checked_class_li . '" style="' . $value_style . '">'; $filter->html .= $label_filter == 2 ? ' <span class="fc_filter_label_inline">' . $filter->label . '</span> ' : ''; if ($display_filter_as == 4) { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClassGrp(this, \'fc_highlight\', 1);" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="radio" name="' . $filter_ffname . '" '; $filter->html .= ' value="" ' . $checked_attr . ' class="fc_checkradio" />'; } else { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClass(this, \'fc_highlight\', 1);" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="checkbox" name="' . $filter_ffname . '[' . $i . ']" '; $filter->html .= ' value="" ' . $checked_attr . ' class="fc_checkradio" />'; } $tooltip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $tooltip_title = flexicontent_html::getToolTip('FLEXI_REMOVE_ALL', '', $translate = 1, $escape = 1); $filter->html .= '<label class="' . $checked_class . $tooltip_class . '" for="' . $filter_ffid . $i . '" ' . ' title="' . $tooltip_title . '" ' . ($checked ? ' style="display:none!important;" ' : ' style="background:none!important; padding-left:0px!important;" ') . '>' . '<span class="fc_delall_filters"></span>'; $filter->html .= '</label> ' . ($combine_tip ? ' <span class="fc_filter_tip_inline badge badge-info">' . JText::_(!$require_all_param ? 'FLEXI_ANY_OF' : 'FLEXI_ALL_OF') . '</span> ' : '') . ' </li>'; $i++; foreach ($results as $result) { if (!strlen($result->value)) { continue; } $checked = $display_filter_as == 5 ? in_array($result->value, $value) : $result->value == $value; $checked_attr = $checked ? ' checked=checked ' : ''; $disable_attr = $faceted_filter == 2 && !$result->found ? ' disabled=disabled ' : ''; $checked_class = $checked ? 'fc_highlight' : ''; $checked_class .= $faceted_filter == 2 && !$result->found ? ' fcdisabled ' : ''; $checked_class_li = $checked ? ' fc_checkradio_checked' : ''; $filter->html .= '<li class="fc_checkradio_option' . $checked_class_li . '" style="' . $value_style . '">'; // *** PLACE image before label (and e.g. (default) above the label) if ($filter_vals_display == 2) { $filter->html .= "<span class='fc_filter_val_img'><img onclick=\"jQuery(this).closest('li').find('input').click();\" src='" . $result->image_url . "' /></span>"; } if ($display_filter_as == 4) { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClassGrp(this, \'fc_highlight\');" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="radio" name="' . $filter_ffname . '" '; $filter->html .= ' value="' . $result->value . '" ' . $checked_attr . $disable_attr . ' class="fc_checkradio" />'; } else { $filter->html .= ' <input href="javascript:;" onchange="fc_toggleClass(this, \'fc_highlight\');" '; $filter->html .= ' id="' . $filter_ffid . $i . '" type="checkbox" name="' . $filter_ffname . '[' . $i . ']" '; $filter->html .= ' value="' . $result->value . '" ' . $checked_attr . $disable_attr . ' class="fc_checkradio" />'; } $filter->html .= '<label class="fc_filter_val fc_cleared ' . $checked_class . '" for="' . $filter_ffid . $i . '">'; if ($filter_vals_display == 0 || $filter_vals_display == 2) { $filter->html .= "<span class='fc_filter_val_lbl'>" . $result->text . "</span>"; } else { if ($add_usage_counters && $result->found) { $filter->html .= "<span class='fc_filter_val_lbl'>(" . $result->found . ")</span>"; } } $filter->html .= '</label>'; // *** PLACE image after label (and e.g. (default) next to the label) if ($filter_vals_display == 1) { $filter->html .= "<span class='fc_filter_val_img'>" . "<img onclick=\"jQuery(this).closest('li').find('input').click();\" src='" . $result->image_url . "' />" . "</span>"; } $filter->html .= '</li>'; $i++; } $filter->html .= '</ul>'; $filter->html .= '</div>'; break; } if ($print_logging_info) { $current_filter_creation = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; $flt_active_count = isset($filters_where) ? count($filters_where) : 0; $faceted_str = array(0 => 'non-FACETED ', 1 => 'FACETED: current view (cacheable) ', 2 => 'FACETED: current filters:' . " (" . $flt_active_count . ' active) '); $fc_run_times['create_filter'][$filter->name] = $current_filter_creation + (!empty($fc_run_times['create_filter'][$filter->name]) ? $fc_run_times['create_filter'][$filter->name] : 0); if (isset($fc_run_times['_create_filter_init'])) { $fc_run_times['create_filter'][$filter->name] -= $fc_run_times['_create_filter_init']; $fc_run_times['create_filter_init'] = $fc_run_times['_create_filter_init'] + (!empty($fc_run_times['create_filter_init']) ? $fc_run_times['create_filter_init'] : 0); unset($fc_run_times['_create_filter_init']); } $fc_run_times['create_filter_type'][$filter->name] = $faceted_str[$faceted_filter]; } //$filter_display_typestr = array(0=>'Single Select', 1=>'Single Text', 2=>'Range Dual Select', 3=>'Range Dual Text', 4=>'Radio Buttons', 5=>'Checkbox Buttons'); //echo "FIELD name: <b>". $filter->name ."</b> Field Type: <b>". $filter->field_type."</b> Filter Type: <b>". $filter_display_typestr[$display_filter_as] ."</b> (".$display_filter_as.") ".sprintf(" %.2f s",$current_filter_creation/1000000)." <br/>"; }
function onDisplayField(&$field, &$item) { if (!in_array($field->field_type, self::$field_types)) { return; } $field->label = JText::_($field->label); $use_ingroup = $field->parameters->get('use_ingroup', 0); if ($use_ingroup) { $field->formhidden = 3; } if ($use_ingroup && empty($field->ingroup)) { return; } $date_source = $field->parameters->get('date_source', 0); if ($date_source) { $date_source_str = 'Automatic field (shows this content \'s %s publication date)'; $date_source_str = sprintf($date_source_str, $date_source == 1 ? '<b>start</b>' : '<b>end</b>'); $_value = $date_source == 1 ? $item->publish_up : $item->publish_down; $field->html = '<div style="float:left">' . ' <div class="alert alert-info fc-small fc-iblock">' . $date_source_str . '</div><div class="clear"></div>' . $_value . '</div>'; return; } // initialize framework objects and other variables $document = JFactory::getDocument(); $config = JFactory::getConfig(); $app = JFactory::getApplication(); $user = JFactory::getUser(); // **************** // Number of values // **************** $multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0); $max_values = $use_ingroup ? 0 : (int) $field->parameters->get('max_values', 0); $required = $field->parameters->get('required', 0); $required = $required ? ' required' : ''; $add_position = (int) $field->parameters->get('add_position', 3); // Input field display size & max characters $size = (int) $field->parameters->get('size', 30); $disable_keyboardinput = (int) $field->parameters->get('disable_keyboardinput', 0); // ******************************************* // Find timezone and create user instructions, // both according to given configuration // ******************************************* $show_usage = $field->parameters->get('show_usage', 0); $date_allowtime = $field->parameters->get('date_allowtime', 1); $use_editor_tz = $field->parameters->get('use_editor_tz', 0); $use_editor_tz = $date_allowtime ? $use_editor_tz : 0; $timezone = 'UTC'; // Default is not to use TIMEZONE $append_str = ''; if ($date_allowtime) { $append_str = JText::_('FLEXI_DATE_CAN_ENTER_TIME'); $append_str .= $date_allowtime == 2 ? '<br/>' . JText::_('FLEXI_DATE_USE_ZERO_TIME_ON_EMPTY') : ''; if ($use_editor_tz == 0) { // Raw date storing, ignoring timezone. NOTE: this is OLD BEHAVIOUR $timezone = 'UTC'; $append_str .= '<br/>' . JText::_('FLEXI_DATE_TIMEZONE_USAGE_DISABLED'); } else { $append_str .= '<br/>' . JText::_('FLEXI_DATE_TIMEZONE_USAGE_ENABLED'); // Use timezone of editor, unlogged editor will use site's default timezone $timezone = $user->getParam('timezone', $config->get('offset')); $tz = new DateTimeZone($timezone); $tz_offset = $tz->getOffset(new JDate()) / 3600; $tz_info = $tz_offset > 0 ? ' UTC +' . $tz_offset : ' UTC ' . $tz_offset; $append_str .= '<br/>' . JText::_($user->id ? 'FLEXI_DATE_ENTER_HOURS_IN_YOUR_TIMEZONE' : 'FLEXI_DATE_ENTER_HOURS_IN_TIMEZONE') . ': ' . $tz_info; } } $append_str = $append_str ? '<b>' . JText::_('FLEXI_NOTES') . '</b>: ' . $append_str : ''; // Initialise property with default value if (!$field->value) { $field->value = array(); $field->value[0] = ''; } // CSS classes of value container $value_classes = 'fcfieldval_container valuebox fcfieldval_container_' . $field->id; // Field name and HTML TAG id $fieldname = 'custom[' . $field->name . ']'; $elementid = 'custom_' . $field->name; $js = ""; $css = ""; if ($multiple) { // Add the drag and drop sorting feature if (!$use_ingroup) { $js .= "\n\t\t\tjQuery(document).ready(function(){\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\n\t\t\t\t\thandle: '.fcfield-drag-handle',\n\t\t\t\t\tcontainment: 'parent',\n\t\t\t\t\ttolerance: 'pointer'\n\t\t\t\t});\n\t\t\t});\n\t\t\t"; } if ($max_values) { JText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true); } $js .= "\n\t\t\tvar uniqueRowNum" . $field->id . "\t= " . count($field->value) . "; // Unique row number incremented only\n\t\t\tvar rowCount" . $field->id . "\t= " . count($field->value) . "; // Counts existing rows to be able to limit a max number of values\n\t\t\tvar maxValues" . $field->id . " = " . $max_values . ";\n\t\t\t\n\t\t\tfunction addField" . $field->id . "(el, groupval_box, fieldval_box, params)\n\t\t\t{\n\t\t\t\tvar insert_before = (typeof params!== 'undefined' && typeof params.insert_before !== 'undefined') ? params.insert_before : 0;\n\t\t\t\tvar remove_previous = (typeof params!== 'undefined' && typeof params.remove_previous !== 'undefined') ? params.remove_previous : 0;\n\t\t\t\tvar scroll_visible = (typeof params!== 'undefined' && typeof params.scroll_visible !== 'undefined') ? params.scroll_visible : 1;\n\t\t\t\tvar animate_visible = (typeof params!== 'undefined' && typeof params.animate_visible !== 'undefined') ? params.animate_visible : 1;\n\t\t\t\t\n\t\t\t\tif((rowCount" . $field->id . " >= maxValues" . $field->id . ") && (maxValues" . $field->id . " != 0)) {\n\t\t\t\t\talert(Joomla.JText._('FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED') + maxValues" . $field->id . ");\n\t\t\t\t\treturn 'cancel';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvar lastField = fieldval_box ? fieldval_box : jQuery(el).prev().children().last();\n\t\t\t\tvar newField = lastField.clone();\n\t\t\t\t\n\t\t\t\t// Update the new text field\n\t\t\t\tvar theInput = newField.find('input.fcfield_textval').first();\n\t\t\t\ttheInput.val('');\n\t\t\t\ttheInput.attr('name', '" . $fieldname . "['+uniqueRowNum" . $field->id . "+']');\n\t\t\t\ttheInput.attr('id', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");\n\t\t\t\t\n\t\t\t\t// Update date picker\n\t\t\t\tvar thePicker = theInput.next();\n\t\t\t\tthePicker.attr('id', '" . $elementid . "_' +uniqueRowNum" . $field->id . " +'_img');\n\t\t\t\t\n\t\t\t\t"; // Disable keyboard input if so configured if ($disable_keyboardinput) { $js .= "\n\t\t\t\ttheInput.on('keydown keypress keyup', false);\n\t\t\t\t\t"; } // Add new field to DOM $js .= "\n\t\t\t\tlastField ?\n\t\t\t\t\t(insert_before ? newField.insertBefore( lastField ) : newField.insertAfter( lastField ) ) :\n\t\t\t\t\tnewField.appendTo( jQuery('#sortables_" . $field->id . "') ) ;\n\t\t\t\tif (remove_previous) lastField.remove();\n\t\t\t\t\n\t\t\t\t// This needs to be after field is added to DOM (unlike e.g. select2 / inputmask JS scripts)\n\t\t\t\tCalendar.setup({\n\t\t\t\t\tinputField:\ttheInput.attr('id'),\n\t\t\t\t\tifFormat:\t\t'%Y-%m-%d',\n\t\t\t\t\tbutton:\t\t\tthePicker.attr('id'),\n\t\t\t\t\talign:\t\t\t'Tl',\n\t\t\t\t\tsingleClick:\ttrue\n\t\t\t\t});\n\t\t\t\t"; // Add new element to sortable objects (if field not in group) if (!$use_ingroup) { $js .= "\n\t\t\t\t//jQuery('#sortables_" . $field->id . "').sortable('refresh'); // Refresh was done appendTo ?\n\t\t\t\t"; } // Show new field, increment counters $js .= "\n\t\t\t\t//newField.fadeOut({ duration: 400, easing: 'swing' }).fadeIn({ duration: 200, easing: 'swing' });\n\t\t\t\tif (scroll_visible) fc_scrollIntoView(newField, 1);\n\t\t\t\tif (animate_visible) newField.css({opacity: 0.1}).animate({ opacity: 1 }, 800);\n\t\t\t\t\n\t\t\t\t// Enable tooltips on new element\n\t\t\t\tnewField.find('.hasTooltip').tooltip({'html': true,'container': newField});\n\t\t\t\t\n\t\t\t\trowCount" . $field->id . "++; // incremented / decremented\n\t\t\t\tuniqueRowNum" . $field->id . "++; // incremented only\n\t\t\t}\n\n\t\t\tfunction deleteField" . $field->id . "(el, groupval_box, fieldval_box)\n\t\t\t{\n\t\t\t\t// Find field value container\n\t\t\t\tvar row = fieldval_box ? fieldval_box : jQuery(el).closest('li');\n\t\t\t\t\n\t\t\t\t// Add empty container if last element, instantly removing the given field value container\n\t\t\t\tif(rowCount" . $field->id . " == 1)\n\t\t\t\t\taddField" . $field->id . "(null, groupval_box, row, {remove_previous: 1, scroll_visible: 0, animate_visible: 0});\n\t\t\t\t\n\t\t\t\t// Remove if not last one, if it is last one, we issued a replace (copy,empty new,delete old) above\n\t\t\t\tif(rowCount" . $field->id . " > 1) {\n\t\t\t\t\t// Destroy the remove/add/etc buttons, so that they are not reclicked, while we do the hide effect (before DOM removal of field value)\n\t\t\t\t\trow.find('.fcfield-delvalue').remove();\n\t\t\t\t\trow.find('.fcfield-insertvalue').remove();\n\t\t\t\t\trow.find('.fcfield-drag-handle').remove();\n\t\t\t\t\t// Do hide effect then remove from DOM\n\t\t\t\t\trow.slideUp(400, function(){ jQuery(this).remove(); });\n\t\t\t\t\trowCount" . $field->id . "--;\n\t\t\t\t}\n\t\t\t}\n\t\t\t"; $css .= ''; $remove_button = '<span class="fcfield-delvalue" title="' . JText::_('FLEXI_REMOVE_VALUE') . '" onclick="deleteField' . $field->id . '(this);"></span>'; $move2 = '<span class="fcfield-drag-handle" title="' . JText::_('FLEXI_CLICK_TO_DRAG') . '"></span>'; $add_here = ''; $add_here .= $add_position == 2 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_before" onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 1});" title="' . JText::_('FLEXI_ADD_BEFORE') . '"></span> ' : ''; $add_here .= $add_position == 1 || $add_position == 3 ? '<span class="fcfield-insertvalue fc_after" onclick="addField' . $field->id . '(null, jQuery(this).closest(\'ul\'), jQuery(this).closest(\'li\'), {insert_before: 0});" title="' . JText::_('FLEXI_ADD_AFTER') . '"></span> ' : ''; } else { $remove_button = ''; $move2 = ''; $add_here = ''; $js .= ''; $css .= ''; } if ($js) { $document->addScriptDeclaration($js); } if ($css) { $document->addStyleDeclaration($css); } // ***************************************** // Create field's HTML display for item form // ***************************************** $field->html = array(); $n = 0; $skipped_vals = array(); //if ($use_ingroup) {print_r($field->value);} foreach ($field->value as $value) { if (!strlen($value) && !$use_ingroup && $n) { continue; } // If at least one added, skip empty if not in field group $fieldname_n = $fieldname . '[' . $n . ']'; $elementid_n = $elementid . '_' . $n; $calendar = FlexicontentFields::createCalendarField($value, $date_allowtime, $fieldname_n, $elementid_n, $attribs_arr = array('class' => 'fcfield_textval' . $required), $skip_on_invalid = true, $timezone); if (!$calendar) { $skipped_vals[] = $value; if (!$use_ingroup) { continue; } $calendar = FlexicontentFields::createCalendarField('', $date_allowtime, $fieldname_n, $elementid_n, $attribs_arr = array('class' => 'fcfield_textval' . $required), $skip_on_invalid = true, $timezone); } $field->html[] = ' ' . $calendar . ' ' . ($use_ingroup ? '' : $move2) . ' ' . ($use_ingroup ? '' : $remove_button) . ' ' . ($use_ingroup || !$add_position ? '' : $add_here) . ' '; if ($disable_keyboardinput) { $document->addScriptDeclaration("\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('#" . $elementid_n . "').on('keydown keypress keyup', false);\n\t\t\t\t\t});\n\t\t\t\t"); } $n++; if (!$multiple) { break; } // multiple values disabled, break out of the loop, not adding further values even if the exist } if ($use_ingroup) { // do not convert the array to string if field is in a group } else { if ($multiple) { // handle multiple records $field->html = !count($field->html) ? '' : '<li class="' . $value_classes . '">' . implode('</li><li class="' . $value_classes . '">', $field->html) . '</li>'; $field->html = '<ul class="fcfield-sortables" id="sortables_' . $field->id . '">' . $field->html . '</ul>'; if (!$add_position) { $field->html .= '<span class="fcfield-addvalue" onclick="addField' . $field->id . '(this);" title="' . JText::_('FLEXI_ADD_TO_BOTTOM') . '"></span>'; } } else { // handle single values $field->html = '<div class="fcfieldval_container valuebox fcfieldval_container_' . $field->id . '">' . $field->html[0] . '</div>'; } } if (!$use_ingroup) { $field->html = ($show_usage && $append_str ? ' <div class="alert alert-info fc-small fc-iblock">' . $append_str . '</div><div class="clear"></div>' : '') . $field->html; } if (count($skipped_vals)) { $app->enqueueMessage(JText::sprintf('FLEXI_FIELD_EDIT_VALUES_SKIPPED', $field->label, implode(',', $skipped_vals)), 'notice'); } }
function onDisplayField(&$field, &$item) { // execute the code only if the field type match the plugin type if (!in_array($field->field_type, self::$field_types)) { return; } $field->label = JText::_($field->label); $date_source = $field->parameters->get('date_source', 0); if ($date_source) { $date_source_str = 'Automatic field (shows this content \'s %s publication date)'; $date_source_str = sprintf($date_source_str, $date_source == 1 ? '<b>start</b>' : '<b>end</b>'); $_value = $date_source == 1 ? $item->publish_up : $item->publish_down; $field->html = '<div style="float:left">' . ' <div class="fc_mini_note_box">' . $date_source_str . '</div>' . $_value . '</div>'; return; } // initialize framework objects and other variables $document = JFactory::getDocument(); $config = JFactory::getConfig(); $app = JFactory::getApplication(); $user = JFactory::getUser(); // some parameter shortcuts $size = (int) $field->parameters->get('size', 30); $multiple = $field->parameters->get('allow_multiple', 1); $max_values = (int) $field->parameters->get('max_values', 0); $disable_keyboardinput = $field->parameters->get('disable_keyboardinput', 0); $required = $field->parameters->get('required', 0); $required = $required ? ' required' : ''; // find timezone and create user instructions, both according to given configuration $show_usage = $field->parameters->get('show_usage', 0); $date_allowtime = $field->parameters->get('date_allowtime', 1); $use_editor_tz = $field->parameters->get('use_editor_tz', 0); $use_editor_tz = $date_allowtime ? $use_editor_tz : 0; $timezone = false; $append_str = ''; if ($date_allowtime) { $append_str = JText::_('FLEXI_DATE_CAN_ENTER_TIME'); $append_str .= $date_allowtime == 2 ? '<br/>' . JText::_('FLEXI_DATE_USE_ZERO_TIME_ON_EMPTY') : ''; if ($use_editor_tz == 0) { // Raw date storing, ignoring timezone. NOTE: this is OLD BEHAVIOUR $timezone = FLEXI_J16GE ? 'UTC' : 0; $append_str .= '<br/>' . JText::_('FLEXI_DATE_TIMEZONE_USAGE_DISABLED'); } else { $append_str .= '<br/>' . JText::_('FLEXI_DATE_TIMEZONE_USAGE_ENABLED'); // Use timezone of editor, unlogged editor will use site's default timezone $timezone = $user->getParam('timezone', $config->get('offset')); if (FLEXI_J16GE) { $tz = new DateTimeZone($timezone); $tz_offset = $tz->getOffset(new JDate()) / 3600; } else { $tz_offset = $timezone; } $tz_info = $tz_offset > 0 ? ' UTC +' . $tz_offset : ' UTC ' . $tz_offset; $append_str .= '<br/>' . JText::_($user->id ? 'FLEXI_DATE_ENTER_HOURS_IN_YOUR_TIMEZONE' : 'FLEXI_DATE_ENTER_HOURS_IN_TIMEZONE') . ': ' . $tz_info; } } $append_str = $append_str ? '<b>' . JText::_('FLEXI_NOTES') . '</b>: ' . $append_str : ''; // Initialise property with default value if (!$field->value) { $field->value = array(); $field->value[0] = ''; } // Field name and HTML TAG id $fieldname = FLEXI_J16GE ? 'custom[' . $field->name . '][]' : $field->name . '[]'; $elementid = FLEXI_J16GE ? 'custom_' . $field->name : $field->name; $js = ""; if ($multiple) { if (!FLEXI_J16GE) { $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/sortables.js'); } // Add the drag and drop sorting feature $js .= "\r\n\t\t\tjQuery(document).ready(function(){\r\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\r\n\t\t\t\t\thandle: '.fcfield-drag',\r\n\t\t\t\t\tcontainment: 'parent',\r\n\t\t\t\t\ttolerance: 'pointer'\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t\t"; if ($max_values) { FLEXI_J16GE ? JText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true) : fcjsJText::script("FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED", true); } $js .= "\r\n\t\t\tvar uniqueRowNum" . $field->id . "\t= " . count($field->value) . "; // Unique row number incremented only\r\n\t\t\tvar rowCount" . $field->id . "\t= " . count($field->value) . "; // Counts existing rows to be able to limit a max number of values\r\n\t\t\tvar maxValues" . $field->id . " = " . $max_values . ";\r\n\r\n\t\t\tfunction addField" . $field->id . "(el) {\r\n\t\t\t\tif((rowCount" . $field->id . " >= maxValues" . $field->id . ") && (maxValues" . $field->id . " != 0)) {\r\n\t\t\t\t\talert(Joomla.JText._('FLEXI_FIELD_MAX_ALLOWED_VALUES_REACHED') + maxValues" . $field->id . ");\r\n\t\t\t\t\treturn 'cancel';\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tvar thisField \t = jQuery(el).prev().children().last();\r\n\t\t\t\tvar thisNewField = thisField.clone();\r\n\t\t\t\t\r\n\t\t\t\tjQuery(thisNewField).find('input').first().val(''); /* First element is the value input field, second is e.g remove button */\r\n\t\t\t\t\r\n\t\t\t\tjQuery(thisNewField).css('display', 'none');\r\n\t\t\t\tjQuery(thisNewField).insertAfter( jQuery(thisField) );\r\n\r\n\t\t\t\tvar input = jQuery(thisNewField).find('input').first();\r\n\t\t\t\tinput.attr('id', '" . $elementid . "_'+uniqueRowNum" . $field->id . ");\r\n\t\t\t\tvar img = input.next();\r\n\t\t\t\timg.attr('id', '" . $elementid . "_' +uniqueRowNum" . $field->id . " +'_img');\r\n\t\t\t\t\r\n\t\t\t\tCalendar.setup({\r\n\t\t\t\t\tinputField:\tinput.attr('id'),\r\n\t\t\t\t\tifFormat:\t\t'%Y-%m-%d',\r\n\t\t\t\t\tbutton:\t\t\timg.attr('id'),\r\n\t\t\t\t\talign:\t\t\t'Tl',\r\n\t\t\t\t\tsingleClick:\ttrue\r\n\t\t\t\t});\r\n\t\t\t"; if ($disable_keyboardinput) { $js .= "\r\n\t\t\t\t\tjQuery('#'+input.attr('id')).on('keydown keypress keyup', false);\r\n\t\t\t\t"; } $js .= "\r\n\t\t\t\tjQuery('#sortables_" . $field->id . "').sortable({\r\n\t\t\t\t\thandle: '.fcfield-drag',\r\n\t\t\t\t\tcontainment: 'parent',\r\n\t\t\t\t\ttolerance: 'pointer'\r\n\t\t\t\t});\r\n\t\t\t\t\r\n\t\t\t\tjQuery(thisNewField).show('slideDown');\r\n\t\t\t\t\r\n\t\t\t\trowCount" . $field->id . "++; // incremented / decremented\r\n\t\t\t\tuniqueRowNum" . $field->id . "++; // incremented only\r\n\t\t\t}\r\n\r\n\t\t\tfunction deleteField" . $field->id . "(el)\r\n\t\t\t{\r\n\t\t\t\tif(rowCount" . $field->id . " <= 1) return;\r\n\t\t\t\tvar row = jQuery(el).closest('li');\r\n\t\t\t\tjQuery(row).hide('slideUp', function() { this.remove(); } );\r\n\t\t\t\trowCount" . $field->id . "--;\r\n\t\t\t}\r\n\t\t\t"; $css = ' #sortables_' . $field->id . ' { float:left; margin: 0px; padding: 0px; list-style: none; white-space: nowrap; } #sortables_' . $field->id . ' li { clear: both; display: block; list-style: none; height: auto; position: relative; } #sortables_' . $field->id . ' li.sortabledisabled { background : transparent url(components/com_flexicontent/assets/images/move3.png) no-repeat 0px 1px; } #sortables_' . $field->id . ' li input { cursor: text;} #add' . $field->name . ' { margin-top: 5px; clear: both; display:block; } #sortables_' . $field->id . ' li .admintable { text-align: left; } #sortables_' . $field->id . ' li:only-child span.fcfield-drag, #sortables_' . $field->id . ' li:only-child input.fcfield-button { display:none; } '; $remove_button = '<input class="fcfield-button" type="button" value="' . JText::_('FLEXI_REMOVE_VALUE') . '" onclick="deleteField' . $field->id . '(this);" />'; $move2 = '<span class="fcfield-drag">' . JHTML::image(JURI::base() . 'components/com_flexicontent/assets/images/move2.png', JText::_('FLEXI_CLICK_TO_DRAG')) . '</span>'; } else { $remove_button = ''; $move2 = ''; $js = ''; $css = ''; } if ($js) { $document->addScriptDeclaration($js); } if ($css) { $document->addStyleDeclaration($css); } $field->html = array(); $n = 0; $skipped_vals = array(); foreach ($field->value as $value) { $elementid_n = $elementid . '_' . $n; $calendar = FlexicontentFields::createCalendarField($value, $date_allowtime, $fieldname, $elementid_n, $attribs_arr = array('class' => 'fcfield_textval' . $required), $skip_on_invalid = true, $timezone); if (!$calendar) { $skipped_vals[] = $value; continue; } $field->html[] = ' ' . $calendar . ' ' . $move2 . ' ' . $remove_button . ' '; if ($disable_keyboardinput) { $document->addScriptDeclaration("\r\n\t\t\t\t\tjQuery(document).ready(function(){\r\n\t\t\t\t\t\tjQuery('#" . $elementid_n . "').on('keydown keypress keyup', false);\r\n\t\t\t\t\t});\r\n\t\t\t\t"); } $n++; if (!$multiple) { break; } // multiple values disabled, break out of the loop, not adding further values even if the exist } if ($multiple) { // handle multiple records $_list = "<li>" . implode("</li>\n<li>", $field->html) . "</li>\n"; $field->html = ' <ul class="fcfield-sortables" id="sortables_' . $field->id . '">' . $_list . '</ul> <input type="button" class="fcfield-addvalue" onclick="addField' . $field->id . '(this);" value="' . JText::_('FLEXI_ADD_VALUE') . '" /> '; } else { // handle single values $field->html = '<div>' . $field->html[0] . '</div>'; } $field->html = '<div style="float:left">' . ($show_usage && $append_str ? ' <div class="fc_mini_note_box">' . $append_str . '</div>' : '') . $field->html . '</div>'; if (count($skipped_vals)) { $app->enqueueMessage(JText::sprintf('FLEXI_FIELD_EDIT_VALUES_SKIPPED', $field->label, implode(',', $skipped_vals)), 'notice'); } }