Index: branches/5.2.x/core/admin_templates/item_filters/item_filter_edit.tpl =================================================================== diff -u -N --- branches/5.2.x/core/admin_templates/item_filters/item_filter_edit.tpl (revision 0) +++ branches/5.2.x/core/admin_templates/item_filters/item_filter_edit.tpl (revision 14892) @@ -0,0 +1,81 @@ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + + + + + + +
+
+ + + + \ No newline at end of file Index: branches/5.2.x/core/units/filters/filters_config.php =================================================================== diff -u -N --- branches/5.2.x/core/units/filters/filters_config.php (revision 0) +++ branches/5.2.x/core/units/filters/filters_config.php (revision 14892) @@ -0,0 +1,130 @@ + 'item-filter', + 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), + 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), + 'EventHandlerClass' => Array ('class' => 'ItemFilterEventHandler', 'file' => 'item_filter_eh.php', 'build_event' => 'OnBuild'), + 'TagProcessorClass' => Array ('class' => 'ItemFilterTagProcessor', 'file' => 'item_filter_tp.php', 'build_event' => 'OnBuild'), + + 'AutoLoad' => true, + + 'QueryString' => Array ( + 1 => 'id', + 2 => 'Page', + 3 => 'PerPage', + 4 => 'event', + 5 => 'mode', + ), + + 'IDField' => 'FilterId', + + 'TableName' => TABLE_PREFIX . 'ItemFilters', + + 'TitleField' => 'FilterField', + 'StatusField' => Array ('Enabled'), + + 'TitlePresets' => Array ( + 'default' => Array ( + 'new_status_labels' => Array ('item-filter' => '!la_title_AddingItemFilter!'), + 'edit_status_labels' => Array ('item-filter' => '!la_title_EditingItemFilter!'), + ), + + 'item_filter_list' => Array ( + 'prefixes' => Array ('item-filter_List'), 'format' => "!la_title_ItemFilters!", + 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'view', 'dbl-click'), + ), + + 'item_filter_edit' => Array ( + 'prefixes' => Array ('item-filter'), 'format' => "#item-filter_status# '#item-filter_titlefield#'", + 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'), + ), + ), + + 'PermSection' => Array('main' => 'in-portal:item_filters'), + + 'Sections' => Array ( + 'in-portal:item_filters' => Array ( + 'parent' => 'in-portal:website_setting_folder', + 'icon' => 'conf_filters', + 'label' => 'la_title_ItemFilters', + 'url' => Array('t' => 'item_filters/item_filter_list', 'pass' => 'm'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), + 'priority' => 14, + 'type' => stTREE, + ), + ), + + 'ListSQLs' => Array ( + '' => ' SELECT %1$s.* %2$s FROM %1$s', + ), + + 'CalculatedFields' => Array ( + '' => Array ( + 'FilterKey' => 'CONCAT(%1$s.ItemPrefix, "_", %1$s.FilterField)', + ), + ), + + 'ListSortings' => Array ( + '' => Array ( + 'Sorting' => Array ('FilterId' => 'asc'), + ) + ), + + 'Fields' => Array ( + 'FilterId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), + 'ItemPrefix' => Array ( + 'type' => 'string', 'max_len' => 255, + 'error_msgs' => Array ('not_registered' => '!la_error_InvalidItemPrefix!'), + 'not_null' => 1, 'required' => 1, 'default' => '' + ), + 'FilterField' => Array ( + 'type' => 'string', 'max_len' => 255, + 'error_msgs' => Array ('non_existing' => '!la_error_InvalidFieldName!'), + 'not_null' => 1, 'required' => 1, 'default' => '' + ), + 'FilterType' => Array ( + 'type' => 'string', 'max_len' => 100, + 'formatter' => 'kOptionsFormatter', 'options' => Array ('text' => 'la_type_text', 'select' => 'la_type_select', 'radio' => 'la_type_radio', 'checkbox' => 'la_type_checkbox', 'range' => 'la_type_RangeSlider'), 'use_phrases' => 1, + 'not_null' => 1, 'required' => 1, 'default' => '' + ), + 'Enabled' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 1 + ), + 'RangeCount' => Array ('type' => 'int', 'default' => NULL), + ), + + 'VirtualFields' => Array ( + 'FilterKey' => Array ('type' => 'string', 'default' => ''), + ), + + 'Grids' => Array ( + 'Default' => Array ( + 'Icons' => Array ('default' => 'icon16_item.png', 0 => 'icon16_disabled.png'), + 'Fields' => Array ( + 'FilterId' => Array ('title' => 'column:la_fld_Id', 'filter_block' => 'grid_range_filter'), + 'ItemPrefix' => Array ('filter_block' => 'grid_like_filter'), + 'FilterField' => Array ('filter_block' => 'grid_like_filter'), + 'FilterType' => Array ('filter_block' => 'grid_options_filter'), + 'Enabled' => Array ('filter_block' => 'grid_options_filter'), + 'RangeCount' => Array ('filter_block' => 'grid_range_filter'), + ) + ) + ) +); \ No newline at end of file Index: branches/5.2.x/core/units/filters/item_filter_tp.php =================================================================== diff -u -N --- branches/5.2.x/core/units/filters/item_filter_tp.php (revision 0) +++ branches/5.2.x/core/units/filters/item_filter_tp.php (revision 14892) @@ -0,0 +1,230 @@ +Application->isAdmin ) { + return ; + } + + $block_params['filter_field'] = $object->GetDBField('FilterField'); + $block_params['filter_type'] = $object->GetDBField('FilterType'); + } + + /** + * Lists filter options + * + * @param Array $params + * @return string + * @access protected + */ + protected function ListFilterOptions($params) + { + static $cache = Array (); + + $object =& $this->getObject($params); + /* @var $object kDBItem */ + + // get item list to be filtered + $this->Application->ProcessParsedTag($params['prefix'], 'InitList', $params); + $tag_processor =& $this->Application->recallTagProcessor( $params['prefix'] ); + $item_list = $tag_processor->GetList($params); + + $filter_type = $object->GetDBField('FilterType'); + $filter_field = $object->GetDBField('FilterField'); + $cache_key = $filter_field . '_' . $filter_type; + + if ( !isset($cache[$cache_key]) ) { + $cache[$cache_key] = Array ('counts' => Array (), 'options' => Array ()); + + $field_sql = $item_list->isCalculatedField($filter_field) ? $item_list->extractCalculatedFields('`' . $filter_field . '`', 1, true) : '`' . $item_list->TableName . '`.`' . $filter_field . '`'; + $sql = $item_list->getCountSQL( $item_list->GetSelectSQL(true, false, $field_sql) ); + + if ( in_array($filter_type, Array ('select', 'radio', 'checkbox')) ) { + $options = $item_list->GetFieldOption($filter_field, 'options', false, Array ()); + + if ( $item_list->GetFieldOption($filter_field, 'use_phrases') ) { + $options = array_map(Array (&$this->Application, 'Phrase'), $options); + } + + $cache[$cache_key]['options'] = $options; + + $count_sql = str_replace('COUNT(*) AS count', 'COUNT(*), ' . $field_sql . ' AS GroupField', $sql) . ' GROUP BY GroupField'; + $cache[$cache_key]['counts'] = $this->Conn->GetCol($count_sql, 'GroupField'); + } + elseif ( $filter_type == 'range' ) { + // TODO: auto-scalable range alghoritm (used here) has several problems: + // 1. range values has meaningless values, e.g. 32, 56 and not 100, 200 as in original design + // 2. count of items from last range is displayed below filter scale + // 3. filter scale has fixed image background that allows only 10 positions + + $range_sql = str_replace('COUNT(*) AS count', 'MIN(' . $field_sql . ') AS MinValue, MAX(' . $field_sql . ') AS MaxValue', $sql); + $range_values = $this->Conn->GetRow($range_sql); + + if ( !$range_values['MinValue'] && !$range_values['MaxValue'] ) { + return ''; + } + + $range_start = $range_values['MinValue']; + $range_count = $object->GetDBField('RangeCount'); + $range_size = ceil( ($range_values['MaxValue'] - $range_values['MinValue']) / ($range_count /*+ 1*/) ); + $formatter_class = $item_list->GetFieldOption($filter_field, 'formatter'); + + $options = Array (); + $count_clause = ''; + $if_clause_mask = 'IF(%s BETWEEN %s AND %s, %s, %%s)'; + + if ( $formatter_class ) { + $formatter =& $this->Application->recallObject($formatter_class); + /* @var $formatter kFormatter */ + + for ($range_number = 0; $range_number < $range_count; $range_number++) { + $range_end = $range_start + $range_size; + $option_key = sprintf('%01.2f', $range_start) . '-' . sprintf('%01.2f', $range_end); + $options[$option_key] = $formatter->Format($range_start, $filter_field, $item_list)/* . ' - ' . $formatter->Format($range_end, $filter_field, $item_list)*/; + + $sql_part = sprintf($if_clause_mask, $field_sql, $range_start, $range_end, $this->Conn->qstr($option_key)); + $count_clause = $count_clause ? sprintf($count_clause, $sql_part) : $sql_part; + $range_start = $range_end; + } + } + else { + for ($range_number = 0; $range_number < $range_count; $range_number++) { + $range_end = $range_start + $range_size; + $option_key = sprintf('%01.2f', $range_start) . '-' . sprintf('%01.2f', $range_end); + $options[$option_key] = $range_start . ' - ' . $range_end; + + $sql_part = sprintf($if_clause_mask, $field_sql, $range_start, $range_end, $this->Conn->qstr($option_key)); + $count_clause = $count_clause ? sprintf($count_clause, $sql_part) : $sql_part; + $range_start = $range_end; + } + } + + + $cache[$cache_key]['range_values'] = $range_values; + $cache[$cache_key]['options'] = $options; + + $count_clause = sprintf($count_clause, $this->Conn->qstr($option_key)); + $count_sql = str_replace('COUNT(*) AS count', 'COUNT(*), ' . $count_clause . ' AS GroupField', $sql) . ' GROUP BY GroupField'; + $cache[$cache_key]['counts'] = $this->Conn->GetCol($count_sql, 'GroupField'); + } + } + + $options = $cache[$cache_key]['options']; + $counts = $cache[$cache_key]['counts']; + + if ( !$options ) { + return ''; + } + + if ( $filter_type != 'range' ) { + $counts[''] = array_sum($counts); + $options = kUtil::array_merge_recursive(Array ('' => 'All'), $options); + } + + $ret = ''; + $block_params = $this->prepareTagParams($params); + $block_params['name'] = $params['render_as']; + $selected_value = $this->getFilterValue($filter_field); + + foreach ($options as $option_key => $option_title) { + $block_params['key'] = $option_key; + $block_params['title'] = $option_title; + $block_params['count'] = isset($counts[$option_key]) ? $counts[$option_key] : 0; + + if ( strpos($selected_value, '|') === false ) { + $block_params['selected'] = "$selected_value" === "$option_key"; + } + else { + $block_params['selected'] = strpos($selected_value, '|' . $option_key . '|') !== false; + } + + $ret .= $this->Application->ParseBlock($block_params); + } + + // set global vars to be used by jQuery UI slider + if ( $filter_type == 'range' ) { + $range_count = $object->GetDBField('RangeCount'); + $range_values = $cache[$cache_key]['range_values']; + + $this->Application->SetVar('min_range_value', $range_values['MinValue']); + $this->Application->SetVar('max_range_value', $range_values['MaxValue']); + + $range_size = ceil( ($range_values['MaxValue'] - $range_values['MinValue']) / ($range_count + 1) ); + $this->Application->SetVar('range_step', $range_size); + } + + return $ret; + } + + /** + * Filter input name + * + * @param Array $params + * @return string + * @access protected + */ + protected function FilterInputName($params) + { + $field = $this->Application->Parser->GetParam('filter_field'); + + $ret = 'filters[' . $field . ']'; + + if (array_key_exists('as_preg', $params) && $params['as_preg']) { + $ret = preg_quote($ret, '/'); + } + + return $ret; + } + + /** + * Returns filter value + * + * @param Array $params + * @return string + * @access protected + */ + protected function FilterField($params) + { + $field = $this->Application->Parser->GetParam('filter_field'); + + return $this->getFilterValue($field); + } + + /** + * Returns filter value + * + * @param string $field + * @return string + * @access protected + */ + protected function getFilterValue($field) + { + $filters = $this->Application->GetVar('filters', Array ()); + + return array_key_exists($field, $filters) ? $filters[$field] : ''; + } +} Index: branches/5.2.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r14870 -r14892 --- branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 14870) +++ branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 14892) @@ -1,6 +1,6 @@ SelectParam($params, 'separator_render_as,block_separator'); for ($i = $split_start; $i <= $split_end; $i++) { - $from_record = ($i - 1) * $list->GetPerPage(true); - $to_record = $from_record + $list->GetPerPage(true); + $from_record = ($i - 1) * $list->GetPerPage(); + $to_record = $from_record + $list->GetPerPage(); if ( $to_record > $total_records ) { $to_record = $total_records; @@ -3003,4 +3003,21 @@ return $object->getFormName(); } + + /** + * Just reloads the object using given parameters + * + * @param Array $params + * @return string + * @access protected + */ + protected function ReloadItem($params) + { + $params['requery'] = 1; + + $object =& $this->getObject($params); + /* @var $object kDBItem */ + + return ''; + } } \ No newline at end of file Index: branches/5.2.x/core/kernel/db/dblist.php =================================================================== diff -u -N -r14865 -r14892 --- branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14865) +++ branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14892) @@ -1,6 +1,6 @@ SelectClause); $q = !$for_counting ? $this->addCalculatedFields($q, 0) : str_replace('%2$s', '', $q); @@ -697,7 +698,7 @@ $group = $this->GetGroupClause(); if ( $for_counting ) { - $optimizer = new LeftJoinOptimizer($q, $where . '|' . $having . '|' . $order . '|' . $group); + $optimizer = new LeftJoinOptimizer($q, $where . '|' . $having . '|' . $order . '|' . $group . '|' . $keep_clause); $q = $optimizer->simplify(); } @@ -1171,17 +1172,26 @@ } /** - * Returns total page count based on list per-page - * - * @param string - * @access public - */ + * Returns total page count based on list per-page + * + * @return int + * @access public + */ public function GetTotalPages() { - if (!$this->Counted) $this->CountRecs(); - if ($this->PerPage == -1) return 1; - $this->TotalPages = (($this->RecordsCount - ($this->RecordsCount % $this->PerPage)) / $this->PerPage) // integer part of division - + (($this->RecordsCount % $this->PerPage) != 0); // adds 1 if there is a reminder + if ( !$this->Counted ) { + $this->CountRecs(); + } + + if ( $this->PerPage == -1 ) { + return 1; + } + + $integer_part = ($this->RecordsCount - ($this->RecordsCount % $this->PerPage)) / $this->PerPage; + $reminder = ($this->RecordsCount % $this->PerPage) != 0; // adds 1 if there is a reminder + + $this->TotalPages = $integer_part + $reminder; + return $this->TotalPages; } Index: branches/5.2.x/core/admin_templates/item_filters/item_filter_list.tpl =================================================================== diff -u -N --- branches/5.2.x/core/admin_templates/item_filters/item_filter_list.tpl (revision 0) +++ branches/5.2.x/core/admin_templates/item_filters/item_filter_list.tpl (revision 14892) @@ -0,0 +1,59 @@ + + + + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file Index: branches/5.2.x/core/install/install_schema.sql =================================================================== diff -u -N -r14882 -r14892 --- branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14882) +++ branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14892) @@ -817,6 +817,18 @@ KEY `Status` (`Status`) ); +CREATE TABLE ItemFilters ( + FilterId int(11) NOT NULL AUTO_INCREMENT, + ItemPrefix varchar(255) NOT NULL, + FilterField varchar(255) NOT NULL, + FilterType varchar(100) NOT NULL, + Enabled tinyint(4) NOT NULL DEFAULT '1', + RangeCount int(11) DEFAULT NULL, + PRIMARY KEY (FilterId), + KEY ItemPrefix (ItemPrefix), + KEY Enabled (Enabled) +); + CREATE TABLE SpamReports ( ReportId int(11) NOT NULL AUTO_INCREMENT, ItemPrefix varchar(255) NOT NULL, Index: branches/5.2.x/core/install/remove_schema.sql =================================================================== diff -u -N -r14886 -r14892 --- branches/5.2.x/core/install/remove_schema.sql (.../remove_schema.sql) (revision 14886) +++ branches/5.2.x/core/install/remove_schema.sql (.../remove_schema.sql) (revision 14892) @@ -43,6 +43,7 @@ DROP TABLE Images; DROP TABLE ItemRating; DROP TABLE ItemReview; +DROP TABLE ItemFilters; DROP TABLE SpamReports; DROP TABLE ItemTypes; DROP TABLE ItemFiles; Index: branches/5.2.x/core/install/upgrades.sql =================================================================== diff -u -N -r14879 -r14892 --- branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14879) +++ branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14892) @@ -2412,4 +2412,16 @@ UPDATE ConfigurationValues SET VariableName = 'RunScheduledTasksFromCron' -WHERE VariableName = 'UseCronForRegularEvent'; \ No newline at end of file +WHERE VariableName = 'UseCronForRegularEvent'; + +CREATE TABLE ItemFilters ( + FilterId int(11) NOT NULL AUTO_INCREMENT, + ItemPrefix varchar(255) NOT NULL, + FilterField varchar(255) NOT NULL, + FilterType varchar(100) NOT NULL, + Enabled tinyint(4) NOT NULL DEFAULT '1', + RangeCount int(11) DEFAULT NULL, + PRIMARY KEY (FilterId), + KEY ItemPrefix (ItemPrefix), + KEY Enabled (Enabled) +); Index: branches/5.2.x/core/units/filters/item_filter_eh.php =================================================================== diff -u -N --- branches/5.2.x/core/units/filters/item_filter_eh.php (revision 0) +++ branches/5.2.x/core/units/filters/item_filter_eh.php (revision 14892) @@ -0,0 +1,149 @@ + Array ('self' => true), + ); + + $this->permMapping = array_merge($this->permMapping, $permissions); + } + + /** + * Apply any custom changes to list's sql query + * + * @param kEvent $event + * @return void + * @access protected + * @see kDBEventHandler::OnListBuild() + */ + protected function SetCustomQuery(&$event) + { + parent::SetCustomQuery($event); + + if ( !$this->Application->isAdmin ) { + $object =& $event->getObject(); + /* @var $object kDBList */ + + $prefix_info = $this->Application->processPrefix( $event->getEventParam('prefix') ); + + $object->addFilter('prefix_filter', '%1$s.ItemPrefix = ' . $this->Conn->qstr($prefix_info['prefix'])); + $object->addFilter('status_filter', '%1$s.Enabled = 1'); + + if ($event->Special == 'used') { + $filters = array_keys($this->Application->GetVar('filters', Array ())); + + if ( $filters ) { + $filters = $this->Conn->qstrArray($filters); + $object->addFilter('field_filter', '%1$s.FilterField IN (' . implode(',', $filters) . ')'); + } + else { + $object->addFilter('field_filter', 'FALSE'); + } + } + + if ( $event->getEventParam('per_page') === false ) { + $event->setEventParam('per_page', -1); + } + } + } + + /** + * Validates filter settings + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnBeforeItemValidate(kEvent &$event) + { + parent::OnBeforeItemValidate($event); + + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $prefix = $object->GetDBField('ItemPrefix'); + + if ( $prefix ) { + if ( !$this->Application->prefixRegistred($prefix) ) { + $object->SetError('ItemPrefix', 'not_registered'); + } + + $field = $object->GetDBField('FilterField'); + + if ( $field ) { + $fields = $this->Application->getUnitOption($prefix, 'Fields'); + $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields'); + + if ( !isset($fields[$field]) && !isset($virtual_fields[$field]) ) { + $object->SetError('FilterField', 'non_existing', null, Array ($prefix)); + } + } + } + + $object->setRequired('RangeCount', $object->GetDBField('FilterType') == 'range'); + } + + /** + * Load item if id is available + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function LoadItem(&$event) + { + static $cache = null; + + if ( $this->Application->isAdmin ) { + parent::LoadItem($event); + + return; + } + + $object =& $event->getObject(); + /* @var $object kDBItem */ + + if ( !isset($cache) ) { + $cache = $this->Conn->Query($object->GetSelectSQL(), 'FilterKey'); + } + + $filter_key = $event->getEventParam('prefix') . '_' . $event->getEventParam('field'); + + if ( isset($cache[$filter_key]) ) { + $object->LoadFromHash($cache[$filter_key]); + } + + if ( $object->isLoaded() ) { + $actions =& $this->Application->recallObject('kActions'); + /* @var $actions Params */ + + $actions->Set($event->getPrefixSpecial() . '_id', $object->GetID()); + } + else { + $object->setID(false); + } + } +} Index: branches/5.2.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r14870 -r14892 --- branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 14870) +++ branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 14892) @@ -1,6 +1,6 @@ getNavigationResource($object, $event->getEventParam('list'), $event->Special == 'next', $select_clause); } + elseif ( $event->Special == 'filter' ) { + // temporary object, used to print filter options only + return 0; + } if (preg_match('/^auto-(.*)/', $event->Special, $regs) && $this->Application->prefixRegistred($regs[1])) { // - returns field DateFormat value from language (LanguageId is extracted from current phrase object) @@ -1178,6 +1182,7 @@ } } + // add view filter $view_filter = $this->Application->RecallVar($event->getPrefixSpecial() . '_view_filter'); if ( $view_filter ) { @@ -1209,9 +1214,75 @@ $group_key++; } } + + // add item filter + if ( $object->isMainList() ) { + $this->applyItemFilters($event); + } } /** + * Applies item filters + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function applyItemFilters(&$event) + { + $filter_values = $this->Application->GetVar('filters', Array ()); + + if ( !$filter_values ) { + return; + } + + $object =& $event->getObject(); + /* @var $object kDBList */ + + $where_clause = Array ( + 'ItemPrefix = ' . $this->Conn->qstr($object->Prefix), + 'FilterField IN (' . implode(',', $this->Conn->qstrArray(array_keys($filter_values))) . ')', + 'Enabled = 1', + ); + + $sql = 'SELECT * + FROM ' . $this->Application->getUnitOption('item-filter', 'TableName') . ' + WHERE (' . implode(') AND (', $where_clause) . ')'; + $filters = $this->Conn->Query($sql, 'FilterField'); + + foreach ($filters as $filter_field => $filter_data) { + $filter_value = $filter_values[$filter_field]; + + if ( "$filter_value" === '' ) { + // ListManager don't pass empty values, but check here just in case + continue; + } + + $table_name = $object->isVirtualField($filter_field) ? '' : '%1$s.'; + + switch ($filter_data['FilterType']) { + case 'radio': + $filter_value = $table_name . '`' . $filter_field . '` = ' . $this->Conn->qstr($filter_value); + break; + + case 'checkbox': + $filter_value = explode('|', substr($filter_value, 1, -1)); + $filter_value = $this->Conn->qstrArray($filter_value, 'escape'); + + if ( $object->GetFieldOption($filter_field, 'multiple') ) { + $filter_value = $table_name . '`' . $filter_field . '` LIKE "%|' . implode('|%" OR ' . $table_name . '`' . $filter_field . '` LIKE "%|', $filter_value) . '|%"'; + } + else { + $filter_value = $table_name . '`' . $filter_field . '` IN (' . implode(',', $filter_value) . ')'; + } + break; + } + + $object->addFilter('item_filter_' . $filter_field, $filter_value); + } + } + + /** * Set's new sorting for list * * @param kEvent $event Index: branches/5.2.x/core/admin_templates/incs/form_blocks.tpl =================================================================== diff -u -N -r14696 -r14892 --- branches/5.2.x/core/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 14696) +++ branches/5.2.x/core/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 14892) @@ -930,6 +930,22 @@ + + .AddButton( + new ToolBarButton( + '', + + '::', + + '', + + function() { + + } + ) + ); + +