';
- //if (count($filter_cats) > 1) {$output .= $this->parseTpl(array('[+cat_name+]'), array($cat_name), $filterCatName);}
$output = '';
- $tv_elements = $this->getDefaultTVValues($tmp);
- $tv_types = $this->getTVNames(implode(',', array_keys($tmp)), 'type');
- $tv_captions = $this->getTVNames(implode(',', array_keys($tmp)), 'caption');
- foreach ($tmp as $tv_id => $tmp2) {
- $filters[$tv_id]['name'] = $filters[$tv_id]['name'] ?: ($tv_captions[$tv_id] ?: '');
- $filters[$tv_id]['name'] = $this->translate($filters[$tv_id]['name']);
- if (isset($filter_values_full[$tv_id])) {
- if (!empty($tv_types) && $tv_types[$tv_id] == 'custom_tv:selector') {
- $selectorDLParams = [
- 'documents' => implode(",", array_keys($filter_values_full[$tv_id])),
- 'returnDLObject' => 1,
- 'selectFields' => 'c.id,c.pagetitle',
- 'orderBy' => 'menuindex ASC',
- 'makeUrl' => 0,
- ];
- if(!empty($this->params['blang'])) {
- $selectorDLParams['controller'] = 'lang_content';
- }
- $selector_elements = $this->modx->runSnippet("DocLister", $selectorDLParams)->getDocs();
- foreach($selector_elements as $row) {
- $tv_elements[$tv_id][ $row['id'] ] = $row['pagetitle'];
+ $fc = 0;
+ $categoryWrapper = '';
+ $isEmpty = true;
+ foreach ($filter_cats as $cat_name => $tmp) {
+ //$output .= '
';
+ //if (count($filter_cats) > 1) {$output .= $this->parseTpl(array('[+cat_name+]'), array($cat_name), $filterCatName);}
+ $output = '';
+ $tv_elements = $this->getDefaultTVValues($tmp);
+ $tv_types = $this->getTVNames(implode(',', array_keys($tmp)), 'type');
+ $tv_captions = $this->getTVNames(implode(',', array_keys($tmp)), 'caption');
+ foreach ($tmp as $tv_id => $tmp2) {
+ $filters[$tv_id]['name'] = $filters[$tv_id]['name'] ?: ($tv_captions[$tv_id] ?: '');
+ $filters[$tv_id]['name'] = $this->translate($filters[$tv_id]['name']);
+ if (isset($filter_values_full[$tv_id])) {
+ if (!empty($tv_types) && $tv_types[$tv_id] == 'custom_tv:selector') {
+ $selectorDLParams = [
+ 'documents' => implode(",", array_keys($filter_values_full[$tv_id])),
+ 'returnDLObject' => 1,
+ 'selectFields' => 'c.id,c.pagetitle',
+ 'orderBy' => 'menuindex ASC',
+ 'makeUrl' => 0,
+ ];
+ if(!empty($this->params['blang'])) {
+ $selectorDLParams['controller'] = 'lang_content';
+ }
+ $selector_elements = $this->modx->runSnippet("DocLister", $selectorDLParams)->getDocs();
+ foreach($selector_elements as $row) {
+ $tv_elements[$tv_id][ $row['id'] ] = $row['pagetitle'];
+ }
}
- }
- if (in_array($tv_id, $this->sort_by_count_tv_id) || (isset($this->sort_by_count_tv_id[0]) && $this->sort_by_count_tv_id[0] == 'all')) {
- //сортируем все возможные значения по максимально возможному количеству
- uasort($filter_values_full[$tv_id], function ($a, $b) {
- if ($a['count'] == $b['count']) return 0;
- return (int)$a['count'] > (int)$b['count'] ? -1 : 1;
- });
- //если какие-то значения выбраны и есть динамическая сортировка,
- //применяем сортировку по данным количествам
- if(!empty($filter_values[$tv_id]) && !empty($this->params['sortByCountDynamic'])) {
- uasort($filter_values[$tv_id], function( $a,$b ) {
- if($a['count'] == $b['count']) return 0;
+ if (in_array($tv_id, $this->sort_by_count_tv_id) || (isset($this->sort_by_count_tv_id[0]) && $this->sort_by_count_tv_id[0] == 'all')) {
+ //сортируем все возможные значения по максимально возможному количеству
+ uasort($filter_values_full[$tv_id], function ($a, $b) {
+ if ($a['count'] == $b['count']) return 0;
return (int)$a['count'] > (int)$b['count'] ? -1 : 1;
});
- $tmp_sort = [];
- //сначала собираем те, что есть в $filter_values[$tv_id] в порядке их следования
- foreach($filter_values[$tv_id] as $k => $v) {
- if(isset($filter_values_full[$tv_id][$k])) {
- $tmp_sort[$k] = $v;
+ //если какие-то значения выбраны и есть динамическая сортировка,
+ //применяем сортировку по данным количествам
+ if(!empty($filter_values[$tv_id]) && !empty($this->params['sortByCountDynamic'])) {
+ uasort($filter_values[$tv_id], function( $a,$b ) {
+ if($a['count'] == $b['count']) return 0;
+ return (int)$a['count'] > (int)$b['count'] ? -1 : 1;
+ });
+ $tmp_sort = [];
+ //сначала собираем те, что есть в $filter_values[$tv_id] в порядке их следования
+ foreach($filter_values[$tv_id] as $k => $v) {
+ if(isset($filter_values_full[$tv_id][$k])) {
+ $tmp_sort[$k] = $v;
+ }
}
+ //затем все остальные из исходных значений в порядке их следования
+ foreach($filter_values_full[$tv_id] as $k => $v) {
+ if(!isset($filter_values[$tv_id][$k])) {
+ $tmp_sort[$k] = $v;
+ }
+ }
+ $filter_values_full[$tv_id] = $tmp_sort;
}
- //затем все остальные из исходных значений в порядке их следования
- foreach($filter_values_full[$tv_id] as $k => $v) {
- if(!isset($filter_values[$tv_id][$k])) {
- $tmp_sort[$k] = $v;
+ } else if (in_array($tv_id, $this->nosort_tv_id) || (isset($this->nosort_tv_id[0]) && $this->nosort_tv_id[0] == 'all')) {
+ $sort_tmp = array();
+ foreach($tv_elements[$tv_id] as $k => $v) {
+ if ( $filter_values_full[$tv_id][$k] ) {
+ $sort_tmp[$k] = $filter_values_full[$tv_id][$k];
}
}
- $filter_values_full[$tv_id] = $tmp_sort;
- }
- } else if (in_array($tv_id, $this->nosort_tv_id) || (isset($this->nosort_tv_id[0]) && $this->nosort_tv_id[0] == 'all')) {
- $sort_tmp = array();
- foreach($tv_elements[$tv_id] as $k => $v) {
- if ( $filter_values_full[$tv_id][$k] ) {
- $sort_tmp[$k] = $filter_values_full[$tv_id][$k];
- }
- }
- $filter_values_full[$tv_id] = $sort_tmp;
- unset($sort_tmp);
- } else {
- uksort($filter_values_full[$tv_id], function($a, $b) {
+ $filter_values_full[$tv_id] = $sort_tmp;
+ unset($sort_tmp);
+ } else {
+ uksort($filter_values_full[$tv_id], function($a, $b) {
return is_numeric($a) && is_numeric($b) ? ($a < $b ? -1 : ($a > $b ? 1 : 0)) : strcasecmp(strtolower($a), strtolower($b));
}
- );
- }
- $wrapper = '';
- $count = '';
- //||Чекбокс==1||Список==2||Диапазон==3||Флажок==4||Мультиселект==5
- if(
- (empty($filters[$tv_id]['type']) || in_array($filters[$tv_id]['type'], [ 1, 2, 4, 5, 7, 8])) &&
- count($filter_values_full[$tv_id]) < 2 &&
- !empty($this->params['hideSingleVariant'])) {
- continue;
- }
- switch ($filters[$tv_id]['type']) {
- case '1'://чекбоксы
- $tplRow = $tplRowCheckbox;
- $tplOuter = $tplOuterCheckbox;
- $i = 0;
- $active_block_class = '';
- foreach ($filter_values_full[$tv_id] as $k => $v) {
- $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
- if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
- $tv_val_name = '
' . $tv_val_name . '';
- }
- $selected = ' ';
- if (isset ($this->fp[$tv_id])) {
- $flag = false;
- if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
- $flag = true;
+ );
+ }
+ $wrapper = '';
+ $count = '';
+ //||Чекбокс==1||Список==2||Диапазон==3||Флажок==4||Мультиселект==5
+ if(
+ (empty($filters[$tv_id]['type']) || in_array($filters[$tv_id]['type'], [ 1, 2, 4, 5, 7, 8])) &&
+ count($filter_values_full[$tv_id]) < 2 &&
+ !empty($this->params['hideSingleVariant'])) {
+ continue;
+ }
+ switch ($filters[$tv_id]['type']) {
+ case '1'://чекбоксы
+ $tplRow = $tplRowCheckbox;
+ $tplOuter = $tplOuterCheckbox;
+ $i = 0;
+ $active_block_class = '';
+ foreach ($filter_values_full[$tv_id] as $k => $v) {
+ $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
+ if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
+ $tv_val_name = '
' . $tv_val_name . '';
+ }
+ $selected = ' ';
+ if (isset ($this->fp[$tv_id])) {
+ $flag = false;
+ if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
+ $flag = true;
+ } else {
+ $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ }
+ if ($flag) {
+ $selected = 'checked="checked" ';
+ $active_block_class = $this->active_block_class;
+ }
+ }
+ $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
+ if ($disabled == '') {
+ $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
} else {
- $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ $count = $this->zero;
}
- if ($flag) {
- $selected = 'checked="checked" ';
- $active_block_class = $this->active_block_class;
+ if ($this->params['removeDisabled'] == '0' || $disabled == '') {
+ $i++;
+ $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
+ array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
+ $tplRow
+ ) : '';
}
}
- $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
- if ($disabled == '') {
- $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
- } else {
- $count = $this->zero;
- }
- if ($this->params['removeDisabled'] == '0' || $disabled == '') {
- $i++;
- $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
- array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
- $tplRow
- ) : '';
- }
- }
- if ($this->hideEmptyBlock && $wrapper == '') break;
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '2': //селекты
- $tplRow = $tplRowSelect;
- $tplOuter = $tplOuterSelect;
- $i = 0;
- $active_block_class = '';
- foreach ($filter_values_full[$tv_id] as $k => $v) {
- $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
- $selected = ' ';
- if (isset ($this->fp[$tv_id])) {
- $flag = false;
- if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
- $flag = true;
+ if ($this->hideEmptyBlock && $wrapper == '') break;
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '2': //селекты
+ $tplRow = $tplRowSelect;
+ $tplOuter = $tplOuterSelect;
+ $i = 0;
+ $active_block_class = '';
+ foreach ($filter_values_full[$tv_id] as $k => $v) {
+ $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
+ $selected = ' ';
+ if (isset ($this->fp[$tv_id])) {
+ $flag = false;
+ if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
+ $flag = true;
+ } else {
+ $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ }
+ if ($flag) {
+ $selected = 'selected="selected" ';
+ $active_block_class = $this->active_block_class;
+ }
+ }
+ $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
+ if ($disabled == '') {
+ $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
} else {
- $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ $count = $this->zero;
}
- if ($flag) {
- $selected = 'selected="selected" ';
- $active_block_class = $this->active_block_class;
+ if ($this->params['removeDisabled'] == '0' || $disabled == '') {
+ $i++;
+ $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
+ array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
+ $tplRow
+ ) : '';
}
}
- $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
- if ($disabled == '') {
- $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
- } else {
- $count = $this->zero;
+ if ($this->hideEmptyBlock && $wrapper == '') break;
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '3': //диапазон
+ //исходя из запроса $_GET
+ $minval = '';
+ $maxval = '';
+ //смотрим мин. и макс. значения исходя из списка доступных contentid и запроса $_GET
+ //т.е. реальный доступный диапазон значений "от и до"
+ $minvalcurr = '';
+ $maxvalcurr = '';
+ $active_block_class = '';
+
+ if (isset($this->curr_filter_values[$tv_id]['content_ids']) && $this->curr_filter_values[$tv_id]['content_ids'] != '') {
+ $content_ids = $this->curr_filter_values[$tv_id]['content_ids'] == 'all' ? $this->content_ids : $this->curr_filter_values[$tv_id]['content_ids'];
+ $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS UNSIGNED) ) as min, MAX( CAST( `value` AS UNSIGNED) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE contentid IN(" . $content_ids . ") AND tmplvarid = {$tv_id}");
+ $minmax = $this->modx->db->getRow($q);
+ $minvalcurr = $minmax['min'];
+ $maxvalcurr = $minmax['max'];
}
- if ($this->params['removeDisabled'] == '0' || $disabled == '') {
- $i++;
- $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
- array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
- $tplRow
- ) : '';
- }
- }
- if ($this->hideEmptyBlock && $wrapper == '') break;
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '3': //диапазон
- //исходя из запроса $_GET
- $minval = '';
- $maxval = '';
- //смотрим мин. и макс. значения исходя из списка доступных contentid и запроса $_GET
- //т.е. реальный доступный диапазон значений "от и до"
- $minvalcurr = '';
- $maxvalcurr = '';
- $active_block_class = '';
-
- if (isset($this->curr_filter_values[$tv_id]['content_ids']) && $this->curr_filter_values[$tv_id]['content_ids'] != '') {
- $content_ids = $this->curr_filter_values[$tv_id]['content_ids'] == 'all' ? $this->content_ids : $this->curr_filter_values[$tv_id]['content_ids'];
- $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS UNSIGNED) ) as min, MAX( CAST( `value` AS UNSIGNED) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE contentid IN(" . $content_ids . ") AND tmplvarid = {$tv_id}");
- $minmax = $this->modx->db->getRow($q);
- $minvalcurr = $minmax['min'];
- $maxvalcurr = $minmax['max'];
- }
- $tplRow = $tplRowInterval;
- $tplOuter = $tplOuterInterval;
- $minvalcurr = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 && (int)$this->fp[$tv_id]['min'] >= (int)$minvalcurr ? (int)$this->fp[$tv_id]['min'] : $minvalcurr;
- $maxvalcurr = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 && (int)$this->fp[$tv_id]['max'] <= (int)$maxvalcurr ? (int)$this->fp[$tv_id]['max'] : $maxvalcurr;
- $minval = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 ? (int)$this->fp[$tv_id]['min'] : $minval;
- $maxval = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 ? (int)$this->fp[$tv_id]['max'] : $maxval;
- $wrapper .= $this->parseTpl(
- array('[+tv_id+]', '[+minval+]', '[+maxval+]', '[+minvalcurr+]', '[+maxvalcurr+]'),
- array($tv_id, $minval, $maxval, $minvalcurr, $maxvalcurr),
- $tplRow
- );
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '4': //radio
- $tplRow = $tplRowRadio;
- $tplOuter = $tplOuterRadio;
- $i = 0;
- $active_block_class = '';
- foreach ($filter_values_full[$tv_id] as $k => $v) {
- $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
- if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
- $tv_val_name = '
' . $tv_val_name . '';
- }
- $selected = ' ';
- if (isset ($this->fp[$tv_id])) {
- $flag = false;
- if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
- $flag = true;
+ $tplRow = $tplRowInterval;
+ $tplOuter = $tplOuterInterval;
+ $minvalcurr = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 && (int)$this->fp[$tv_id]['min'] >= (int)$minvalcurr ? (int)$this->fp[$tv_id]['min'] : $minvalcurr;
+ $maxvalcurr = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 && (int)$this->fp[$tv_id]['max'] <= (int)$maxvalcurr ? (int)$this->fp[$tv_id]['max'] : $maxvalcurr;
+ $minval = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 ? (int)$this->fp[$tv_id]['min'] : $minval;
+ $maxval = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 ? (int)$this->fp[$tv_id]['max'] : $maxval;
+ $wrapper .= $this->parseTpl(
+ array('[+tv_id+]', '[+minval+]', '[+maxval+]', '[+minvalcurr+]', '[+maxvalcurr+]'),
+ array($tv_id, $minval, $maxval, $minvalcurr, $maxvalcurr),
+ $tplRow
+ );
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '4': //radio
+ $tplRow = $tplRowRadio;
+ $tplOuter = $tplOuterRadio;
+ $i = 0;
+ $active_block_class = '';
+ foreach ($filter_values_full[$tv_id] as $k => $v) {
+ $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
+ if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
+ $tv_val_name = '
' . $tv_val_name . '';
+ }
+ $selected = ' ';
+ if (isset ($this->fp[$tv_id])) {
+ $flag = false;
+ if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
+ $flag = true;
+ } else {
+ $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ }
+ if ($flag) {
+ $selected = 'checked="checked" ';
+ $active_block_class = $this->active_block_class;
+ }
+ }
+ $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
+ if ($disabled == '') {
+ $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
} else {
- $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ $count = $this->zero;
}
- if ($flag) {
- $selected = 'checked="checked" ';
- $active_block_class = $this->active_block_class;
+ if ($this->params['removeDisabled'] == '0' || $disabled == '') {
+ $i++;
+ $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
+ array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
+ $tplRow
+ ) : '';
}
}
- $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
- if ($disabled == '') {
- $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
- } else {
- $count = $this->zero;
- }
- if ($this->params['removeDisabled'] == '0' || $disabled == '') {
- $i++;
- $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
- array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
- $tplRow
- ) : '';
- }
- }
- if ($this->hideEmptyBlock && $wrapper == '') break;
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '5': //мультиселекты
- $tplRow = $tplRowMultySelect;
- $tplOuter = $tplOuterMultySelect;
- $active_block_class = '';
- foreach ($filter_values_full[$tv_id] as $k => $v) {
- $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
- $selected = ' ';
- if (isset ($this->fp[$tv_id])) {
- $flag = false;
- if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
- $flag = true;
+ if ($this->hideEmptyBlock && $wrapper == '') break;
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '5': //мультиселекты
+ $tplRow = $tplRowMultySelect;
+ $tplOuter = $tplOuterMultySelect;
+ $active_block_class = '';
+ foreach ($filter_values_full[$tv_id] as $k => $v) {
+ $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
+ $selected = ' ';
+ if (isset ($this->fp[$tv_id])) {
+ $flag = false;
+ if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
+ $flag = true;
+ } else {
+ $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ }
+ if ($flag) {
+ $selected = 'selected="selected" ';
+ $active_block_class = $this->active_block_class;
+ }
+ }
+ $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
+ if ($disabled == '') {
+ $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
} else {
- $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ $count = $this->zero;
}
- if ($flag) {
- $selected = 'selected="selected" ';
- $active_block_class = $this->active_block_class;
+ if ($this->params['removeDisabled'] == '0' || $disabled == '') {
+ $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]'),
+ array($tv_id, $k, $tv_val_name, $selected, $disabled, $count),
+ $tplRow
+ ) : '';
}
}
- $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
- if ($disabled == '') {
- $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
- } else {
- $count = $this->zero;
+ if ($this->hideEmptyBlock && $wrapper == '') break;
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '6': //слайдер-диапазон
+ //исходя из запроса $_GET
+ $minval = '';
+ $maxval = '';
+ //смотрим мин. и макс. значения исходя из списка доступных contentid и запроса $_GET
+ //т.е. реальный доступный диапазон значений "от и до"
+ $minvalcurr = '';
+ $maxvalcurr = '';
+ $active_block_class = '';
+
+ if (isset($this->curr_filter_values[$tv_id]['content_ids']) && $this->curr_filter_values[$tv_id]['content_ids'] != '' && $this->changeInterval) {
+ $content_ids = $this->curr_filter_values[$tv_id]['content_ids'] == 'all' ? $this->content_ids : $this->curr_filter_values[$tv_id]['content_ids'];
+ $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS DECIMAL(14, 2)) ) as min, MAX( CAST( `value` AS DECIMAL(14, 2)) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE contentid IN(" . $content_ids . ") AND tmplvarid = {$tv_id}");
+ $minmax = $this->modx->db->getRow($q);
+ $minvalcurr = floor($minmax['min']);
+ $maxvalcurr = ceil($minmax['max']);
+ } else if (isset($this->content_ids_full) && $this->content_ids_full != '') {
+ $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS DECIMAL(14, 2)) ) as min, MAX( CAST( `value` AS DECIMAL(14, 2)) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE tmplvarid = {$tv_id} AND contentid IN (" . $this->content_ids_full . ")");
+ $minmax = $this->modx->db->getRow($q);
+ $minvalcurr = floor($minmax['min']);
+ $maxvalcurr = ceil($minmax['max']);
+ } else { //фикс если ничего не выбрано - берем просто мин и макс цену
+ $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS DECIMAL(14, 2)) ) as min, MAX( CAST( `value` AS DECIMAL(14, 2)) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE tmplvarid = {$tv_id}");
+ $minmax = $this->modx->db->getRow($q);
+ $minvalcurr = floor($minmax['min']);
+ $maxvalcurr = ceil($minmax['max']);
}
- if ($this->params['removeDisabled'] == '0' || $disabled == '') {
- $wrapper .= ($k != '' || ($k == '0' && isset($this->params['allowZero']))) ? $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]'),
- array($tv_id, $k, $tv_val_name, $selected, $disabled, $count),
- $tplRow
- ) : '';
+ if ($minvalcurr == $maxvalcurr) { //фикс - если цена одинаковая то делаем мин.диапазон
+ $minvalcurr = $minvalcurr - 1;
+ $maxvalcurr = $maxvalcurr + 1;
}
- }
- if ($this->hideEmptyBlock && $wrapper == '') break;
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '6': //слайдер-диапазон
- //исходя из запроса $_GET
- $minval = '';
- $maxval = '';
- //смотрим мин. и макс. значения исходя из списка доступных contentid и запроса $_GET
- //т.е. реальный доступный диапазон значений "от и до"
- $minvalcurr = '';
- $maxvalcurr = '';
- $active_block_class = '';
-
- if (isset($this->curr_filter_values[$tv_id]['content_ids']) && $this->curr_filter_values[$tv_id]['content_ids'] != '' && $this->changeInterval) {
- $content_ids = $this->curr_filter_values[$tv_id]['content_ids'] == 'all' ? $this->content_ids : $this->curr_filter_values[$tv_id]['content_ids'];
- $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS DECIMAL(14, 2)) ) as min, MAX( CAST( `value` AS DECIMAL(14, 2)) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE contentid IN(" . $content_ids . ") AND tmplvarid = {$tv_id}");
- $minmax = $this->modx->db->getRow($q);
- $minvalcurr = floor($minmax['min']);
- $maxvalcurr = ceil($minmax['max']);
- } else if (isset($this->content_ids_full) && $this->content_ids_full != '') {
- $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS DECIMAL(14, 2)) ) as min, MAX( CAST( `value` AS DECIMAL(14, 2)) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE tmplvarid = {$tv_id} AND contentid IN (" . $this->content_ids_full . ")");
- $minmax = $this->modx->db->getRow($q);
- $minvalcurr = floor($minmax['min']);
- $maxvalcurr = ceil($minmax['max']);
- } else { //фикс если ничего не выбрано - берем просто мин и макс цену
- $q = $this->modx->db->query("SELECT MIN( CAST( `value` AS DECIMAL(14, 2)) ) as min, MAX( CAST( `value` AS DECIMAL(14, 2)) ) as max FROM " . $this->modx->getFullTableName('site_tmplvar_contentvalues') . " WHERE tmplvarid = {$tv_id}");
- $minmax = $this->modx->db->getRow($q);
- $minvalcurr = floor($minmax['min']);
- $maxvalcurr = ceil($minmax['max']);
- }
- if ($minvalcurr == $maxvalcurr) { //фикс - если цена одинаковая то делаем мин.диапазон
- $minvalcurr = $minvalcurr - 1;
- $maxvalcurr = $maxvalcurr + 1;
- }
- $maxvalcurr = $maxvalcurr != '' ? ceil($maxvalcurr) : '';
-
- if(empty($minval)) { $minval = $minvalcurr; }
- if(empty($maxval)) { $maxval = $maxvalcurr; }
-
- $tplRow = $tplRowSlider;
- $tplOuter = $tplOuterSlider;
- /*$minvalcurr = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 && (int)$this->fp[$tv_id]['min'] >= (int)$minvalcurr ? (int)$this->fp[$tv_id]['min'] : $minvalcurr;
- $maxvalcurr = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 && (int)$this->fp[$tv_id]['max'] <= (int)$maxvalcurr ? (int)$this->fp[$tv_id]['max'] : $maxvalcurr;*/
- $minval = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 ? (int)$this->fp[$tv_id]['min'] : $minval;
- $maxval = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 ? (int)$this->fp[$tv_id]['max'] : $maxval;
- $maxval = $maxval != '' ? ceil($maxval) : '';
- $wrapper .= $this->parseTpl(
- array('[+tv_id+]', '[+minval+]', '[+maxval+]', '[+minvalcurr+]', '[+maxvalcurr+]'),
- array($tv_id, $minval, $maxval, $minvalcurr, $maxvalcurr),
- $tplRow
- );
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '7'://Цвет
- $tplRow = $tplRowColors;
- $tplOuter = $tplOuterColors;
- $i = 0;
- $active_block_class = '';
- foreach ($filter_values_full[$tv_id] as $k => $v) {
- $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
- if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
- $tv_val_name = '
' . $tv_val_name . '';
- }
- $selected = ' ';
- $label_selected = '';
- if (isset ($this->fp[$tv_id])) {
- $flag = false;
- if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
- $flag = true;
+ $maxvalcurr = $maxvalcurr != '' ? ceil($maxvalcurr) : '';
+
+ if(empty($minval)) { $minval = $minvalcurr; }
+ if(empty($maxval)) { $maxval = $maxvalcurr; }
+
+ $tplRow = $tplRowSlider;
+ $tplOuter = $tplOuterSlider;
+ /*$minvalcurr = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 && (int)$this->fp[$tv_id]['min'] >= (int)$minvalcurr ? (int)$this->fp[$tv_id]['min'] : $minvalcurr;
+ $maxvalcurr = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 && (int)$this->fp[$tv_id]['max'] <= (int)$maxvalcurr ? (int)$this->fp[$tv_id]['max'] : $maxvalcurr;*/
+ $minval = isset($this->fp[$tv_id]['min']) && (int)$this->fp[$tv_id]['min'] != 0 ? (int)$this->fp[$tv_id]['min'] : $minval;
+ $maxval = isset($this->fp[$tv_id]['max']) && (int)$this->fp[$tv_id]['max'] != 0 ? (int)$this->fp[$tv_id]['max'] : $maxval;
+ $maxval = $maxval != '' ? ceil($maxval) : '';
+ $wrapper .= $this->parseTpl(
+ array('[+tv_id+]', '[+minval+]', '[+maxval+]', '[+minvalcurr+]', '[+maxvalcurr+]'),
+ array($tv_id, $minval, $maxval, $minvalcurr, $maxvalcurr),
+ $tplRow
+ );
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '7'://Цвет
+ $tplRow = $tplRowColors;
+ $tplOuter = $tplOuterColors;
+ $i = 0;
+ $active_block_class = '';
+ foreach ($filter_values_full[$tv_id] as $k => $v) {
+ $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
+ if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
+ $tv_val_name = '
' . $tv_val_name . '';
+ }
+ $selected = ' ';
+ $label_selected = '';
+ if (isset ($this->fp[$tv_id])) {
+ $flag = false;
+ if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
+ $flag = true;
+ } else {
+ $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ }
+ if ($flag) {
+ $selected = 'checked="checked" ';
+ $label_selected = 'active';
+ $active_block_class = $this->active_block_class;
+ }
+ }
+ $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
+ if ($disabled == '') {
+ $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
} else {
- $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ $count = $this->zero;
}
- if ($flag) {
- $selected = 'checked="checked" ';
- $label_selected = 'active';
- $active_block_class = $this->active_block_class;
+ if ($this->params['removeDisabled'] == '0' || $disabled == '') {
+ $i++;
+ $wrapper .= $k != '' ? $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+label_selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
+ array($tv_id, $k, $tv_val_name, $selected, $label_selected, $disabled, $count, $i),
+ $tplRow
+ ) : '';
}
}
- $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
- if ($disabled == '') {
- $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
- } else {
- $count = $this->zero;
- }
- if ($this->params['removeDisabled'] == '0' || $disabled == '') {
- $i++;
- $wrapper .= $k != '' ? $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+label_selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
- array($tv_id, $k, $tv_val_name, $selected, $label_selected, $disabled, $count, $i),
- $tplRow
- ) : '';
- }
- }
- if ($this->hideEmptyBlock && $wrapper == '') break;
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '8'://Паттерны
- $tplRow = $tplRowPattern;
- $tplOuter = $tplOuterPattern;
- $i = 0;
- $active_block_class = '';
- foreach ($filter_values_full[$tv_id] as $k => $v) {
- $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
- if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
- $tv_val_name = '
' . $tv_val_name . '';
- }
- $selected = ' ';
- $label_selected = '';
- if (isset ($this->fp[$tv_id])) {
- $flag = false;
- if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
- $flag = true;
+ if ($this->hideEmptyBlock && $wrapper == '') break;
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '8'://Паттерны
+ $tplRow = $tplRowPattern;
+ $tplOuter = $tplOuterPattern;
+ $i = 0;
+ $active_block_class = '';
+ foreach ($filter_values_full[$tv_id] as $k => $v) {
+ $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
+ if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
+ $tv_val_name = '
' . $tv_val_name . '';
+ }
+ $selected = ' ';
+ $label_selected = '';
+ if (isset ($this->fp[$tv_id])) {
+ $flag = false;
+ if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
+ $flag = true;
+ } else {
+ $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ }
+ if ($flag) {
+ $selected = 'checked="checked" ';
+ $label_selected = 'active';
+ $active_block_class = $this->active_block_class;
+ }
+ }
+ $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
+ if ($disabled == '') {
+ $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
} else {
- $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ $count = $this->zero;
}
- if ($flag) {
- $selected = 'checked="checked" ';
- $label_selected = 'active';
- $active_block_class = $this->active_block_class;
+ if ($this->params['removeDisabled'] == '0' || $disabled == '') {
+ $i++;
+ $wrapper .= $k != '' ? $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+label_selected+]', '[+disabled+]', '[+count+]', '[+pattern_folder+]', '[+iteration+]'),
+ array($tv_id, $k, $tv_val_name, $selected, $label_selected, $disabled, $count, $this->pattern_folder, $i),
+ $tplRow
+ ) : '';
}
}
- $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
- if ($disabled == '') {
- $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
+ if ($this->hideEmptyBlock && $wrapper == '') break;
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ case '9'://одиночный чекбокс
+ $tplRow = $tplRowSingleCheckbox;
+ $tplOuter = $tplOuterSingleCheckbox;
+ $active_block_class = '';
+ $selected = '';
+ $count = 0;
+ if(empty($this->fp)) {
+ foreach ($filter_values_full[$tv_id] as $k => $v) {
+ $count += $v['count'] ?? 0;
+ }
} else {
- $count = $this->zero;
+ foreach ($filter_values[$tv_id] as $k => $v) {
+ $count += $v['count'] ?? 0;
+ }
}
- if ($this->params['removeDisabled'] == '0' || $disabled == '') {
- $i++;
- $wrapper .= $k != '' ? $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+label_selected+]', '[+disabled+]', '[+count+]', '[+pattern_folder+]', '[+iteration+]'),
- array($tv_id, $k, $tv_val_name, $selected, $label_selected, $disabled, $count, $this->pattern_folder, $i),
- $tplRow
- ) : '';
+ if (!empty($this->fp[$tv_id])) {
+ $selected = 'checked="checked" ';
+ $active_block_class = $this->active_block_class;
}
- }
- if ($this->hideEmptyBlock && $wrapper == '') break;
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- case '9'://одиночный чекбокс
- $tplRow = $tplRowSingleCheckbox;
- $tplOuter = $tplOuterSingleCheckbox;
- $active_block_class = '';
- $selected = '';
- $count = 0;
- if(empty($this->fp)) {
+ $disabled = empty($count) ? 'disabled' : '';
+ $wrapper = $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]', '[+block_name+]'),
+ array($tv_id, 1, $this->params['singleCheckboxTitle'] ?? 'есть', $selected, $disabled, $count, 1, $filters[$tv_id]['name']),
+ $tplRow
+ );
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+
+ default: //по умолчанию - чекбоксы
+ $tplRow = $tplRowCheckbox;
+ $tplOuter = $tplOuterCheckbox;
+ $i = 0;
+ $active_block_class = '';
foreach ($filter_values_full[$tv_id] as $k => $v) {
- $count += $v['count'] ?? 0;
- }
- } else {
- foreach ($filter_values[$tv_id] as $k => $v) {
- $count += $v['count'] ?? 0;
- }
- }
- if (!empty($this->fp[$tv_id])) {
- $selected = 'checked="checked" ';
- $active_block_class = $this->active_block_class;
- }
- $disabled = empty($count) ? 'disabled' : '';
- $wrapper = $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]', '[+block_name+]'),
- array($tv_id, 1, $this->params['singleCheckboxTitle'] ?? 'есть', $selected, $disabled, $count, 1, $filters[$tv_id]['name']),
- $tplRow
- );
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
-
- default: //по умолчанию - чекбоксы
- $tplRow = $tplRowCheckbox;
- $tplOuter = $tplOuterCheckbox;
- $i = 0;
- $active_block_class = '';
- foreach ($filter_values_full[$tv_id] as $k => $v) {
- $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
- if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
- $tv_val_name = '
' . $tv_val_name . '';
- }
- $selected = ' ';
- if (isset ($this->fp[$tv_id])) {
- $flag = false;
- if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
- $flag = true;
+ $tv_val_name = $this->translate($tv_elements[$tv_id][$k] ?? $k);
+ if ($filters[$tv_id]['href'] == '1' && is_int($k)) {
+ $tv_val_name = '
' . $tv_val_name . '';
+ }
+ $selected = ' ';
+ if (isset ($this->fp[$tv_id])) {
+ $flag = false;
+ if (is_array($this->fp[$tv_id]) && in_array($k, $this->fp[$tv_id])) {
+ $flag = true;
+ } else {
+ $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ }
+ if ($flag) {
+ $selected = 'checked="checked" ';
+ $active_block_class = $this->active_block_class;
+ }
+ }
+ $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
+ if ($disabled == '') {
+ $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
} else {
- $flag = ($this->fp[$tv_id] == $k) ? true : false;
+ $count = $this->zero;
}
- if ($flag) {
- $selected = 'checked="checked" ';
- $active_block_class = $this->active_block_class;
+ if ($this->params['removeDisabled'] == '0' || $disabled == '') {
+ $i++;
+ $wrapper .= $k != '' ? $this->parseTpl(
+ array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
+ array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
+ $tplRow
+ ) : '';
}
}
- $disabled = (!empty($filter_values) && !isset($filter_values[$tv_id][$k]) ? 'disabled' : '');
- if ($disabled == '') {
- $count = (isset($filter_values[$tv_id][$k]['count']) ? $filter_values[$tv_id][$k]['count'] : $filter_values_full[$tv_id][$k]['count']);
- } else {
- $count = $this->zero;
- }
- if ($this->params['removeDisabled'] == '0' || $disabled == '') {
- $i++;
- $wrapper .= $k != '' ? $this->parseTpl(
- array('[+tv_id+]', '[+value+]', '[+name+]', '[+selected+]', '[+disabled+]', '[+count+]', '[+iteration+]'),
- array($tv_id, $k, $tv_val_name, $selected, $disabled, $count, $i),
- $tplRow
- ) : '';
- }
- }
- if ($this->hideEmptyBlock && $wrapper == '') break;
- $output .= $this->parseTpl(
- array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
- array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
- $tplOuter
- );
- break;
- }
+ if ($this->hideEmptyBlock && $wrapper == '') break;
+ $output .= $this->parseTpl(
+ array('[+tv_id+]', '[+tv_name+]', '[+name+]', '[+wrapper+]', '[+active_block_class+]'),
+ array($tv_id, $this->filter_tv_names[$tv_id] ?? '', $filters[$tv_id]['name'], $wrapper, $active_block_class),
+ $tplOuter
+ );
+ break;
+ }
+ }
}
+ if ($output != '') {//есть, как минимум, одна непустая категория, т.е. фильтр надо выводить
+ $isEmpty = false;
+ }
+ $categoryWrapper .= $this->parseTpl(
+ array('[+cat_name+]', '[+iteration+]', '[+wrapper+]'),
+ array($this->translate($cat_name), $fc, $output),
+ $tplOuterCategory
+ );
+ $fc++;
+ //$output .= '
';
}
- if ($output != '') {//есть, как минимум, одна непустая категория, т.е. фильтр надо выводить
- $isEmpty = false;
+ $output = $categoryWrapper;
+ $tpl = $tplFilterForm;
+ $resetTpl = $tplFilterReset;
+ $tmp = explode('?', $_SERVER['REQUEST_URI']);
+ if (!empty($this->params['submitPage']) && is_numeric($this->params['submitPage'])) {
+ $form_url = $this->modx->makeUrl($this->params['submitPage']);
+ } else {
+ $form_url = (isset($tmp[0]) && !empty($tmp[0]) && !isset($this->params['submitDocPage'])) ? $tmp[0] : $this->modx->makeUrl($this->docid);
}
- $categoryWrapper .= $this->parseTpl(
- array('[+cat_name+]', '[+iteration+]', '[+wrapper+]'),
- array($this->translate($cat_name), $fc, $output),
- $tplOuterCategory
- );
- $fc++;
- //$output .= '