Skip to content
This repository was archived by the owner on May 11, 2018. It is now read-only.

implemented search operator selection for multiselect and checkbox groups #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Admin/field/chbxgroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
<option value="mselect" label="FM.MSELECT_LIST_OPT" />
</values>
</field>
<field type="select" name="field.searchOperator" selected="field.searchOperator" label="FM.SEARCH_OPERATOR" multi="false" class="input-large">
<values>
<option value="and" label="FM.SEARCH_OPERATOR_AND" />
<option value="or" label="FM.SEARCH_OPERATOR_OR" />
</values>
</field>
<field type="text" name="field.ssize" value="field.ssize" label="FMN.SEL.SIZE_IN_SEARCH" maxlength="10" class="input-mini">
<add where="after">
<call function="Sobi::Txt">
Expand Down
6 changes: 6 additions & 0 deletions Admin/field/multiselect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@
<option value="mselect" label="FM.MSELECT_LIST_OPT" />
</values>
</field>
<field type="select" name="field.searchOperator" selected="field.searchOperator" label="FM.SEARCH_OPERATOR" multi="false" class="input-large">
<values>
<option value="and" label="FM.SEARCH_OPERATOR_AND" />
<option value="or" label="FM.SEARCH_OPERATOR_OR" />
</values>
</field>
<field type="text" name="field.ssize" value="field.ssize" label="FMN.SEL.SIZE_IN_SEARCH" maxlength="10" class="input-mini">
<add where="after">
<call function="Sobi::Txt">
Expand Down
10 changes: 8 additions & 2 deletions Site/opt/fields/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class SPField_Select extends SPFieldType implements SPFieldInterface
protected $multi = false;
/** * @var string */
protected $searchMethod = 'general';
/** * @var string */
protected $searchOperator = 'and';
/** * @var int */
protected $swidth = 350;
/** * @var int */
Expand Down Expand Up @@ -349,7 +351,7 @@ protected function sortOpt( $options )
*/
protected function getAttr()
{
return [ 'suggesting', 'width', 'size', 'selectLabel', 'searchMethod', 'swidth', 'ssize', 'itemprop', 'dependencyDefinition', 'dependency', 'allowParents', 'metaSeparator', 'cssClassView', 'cssClassSearch', 'cssClassEdit', 'showEditLabel', 'defaultValue', 'bsWidth', 'bsSearchWidth' ];
return [ 'suggesting', 'width', 'size', 'selectLabel', 'searchMethod', 'searchOperator', 'swidth', 'ssize', 'itemprop', 'dependencyDefinition', 'dependency', 'allowParents', 'metaSeparator', 'cssClassView', 'cssClassSearch', 'cssClassEdit', 'showEditLabel', 'defaultValue', 'bsWidth', 'bsSearchWidth' ];
}

protected function fetchData( $data, $request = 'post' )
Expand Down Expand Up @@ -882,7 +884,11 @@ public function searchData( $request, $section )
}
else {
$cids = $db->loadResultArray();
$results = array_intersect( $results, $cids );
if ($this->searchOperator === 'and') {
$results = array_intersect( $results, $cids );
} else {
$results = array_merge( $results, $cids );
}
}
}
$sids = $results;
Expand Down
3 changes: 3 additions & 0 deletions Site/usr/locale/adm/en-GB.com_sobipro.ini
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ SP.FM.SEARCH_METHOD = "Search Method"
SP.FM.CHECKBOX_GROUP_OPT = "Checkbox Group"
SP.FM.RADIO_BUTTONS_OPT = "Radio Buttons"
SP.FM.MSELECT_LIST_OPT = "Multiple Select List"
SP.FM.SEARCH_OPERATOR="Searchoperator"
SP.FM.SEARCH_OPERATOR_AND="And"
SP.FM.SEARCH_OPERATOR_OR="Or"
SP.FM.SEARCH_PRIORITY = "Search Priority"
SP.FM.FILTER = "Filter"
SP.FM.MAX_LENGTH = "Max. Length"
Expand Down