/** * Generates the filter rules based upon the given filter url. * * @param IMetaModelFilter $objFilter The filter to append the rules to. * * @param string[string] $arrFilterUrl The parameters to evaluate. * * @return void */ public function prepareRules(IMetaModelFilter $objFilter, $arrFilterUrl) { $objFilterRule = new MetaModelFilterRuleOR($this->get('stop_after_match')); foreach ($this->arrChilds as $objChildSetting) { $objSubFilter = new MetaModelFilter($this->getMetaModel()); $objChildSetting->prepareRules($objSubFilter, $arrFilterUrl); $objFilterRule->addChild($objSubFilter); } $objFilter->addFilterRule($objFilterRule); }
/** * prepare the filter rule * @param IMetaModelFilter $objFilter * @param $arrFilterUrl */ public function prepareRules(IMetaModelFilter $objFilter, $arrFilterUrl) { $objMetaModel = $this->getMetaModel(); $strParamName = $this->getParamName(); $strParamValue = $arrFilterUrl[$strParamName]; $strTextsearch = $this->get('textsearch'); $arrAttributes = deserialize($this->get('textcombine_attributes')); // react on wildcard, overriding the search type if (strpos($strParamValue, '*') !== false) { $strTextsearch = 'exact'; } // type of search switch ($strTextsearch) { case 'beginswith': $strWhat = $strParamValue . '%'; break; case 'endswith': $strWhat = '%' . $strParamValue; break; case 'exact': $strWhat = $strParamValue; break; default: $strWhat = '%' . $strParamValue . '%'; break; } if ($strParamName && $strParamValue) { if ($this->get('textcombine_operator') == 'and') { $objParentRule = new MetaModelFilterRuleAND(); } if ($this->get('textcombine_operator') == 'or') { $objParentRule = new MetaModelFilterRuleOR(); } foreach ($arrAttributes as $intAttribute) { $objAttribute = $objMetaModel->getAttributeById($intAttribute); if ($objAttribute) { $objSubFilter = new MetaModelFilter($objMetaModel); $objSubFilter->addFilterRule(new MetaModelFilterRuleSearchAttribute($objAttribute, $strWhat)); $objParentRule->addChild($objSubFilter); } } $objFilter->addFilterRule($objParentRule); return; } $objFilter->addFilterRule(new MetaModelFilterRuleStaticIdList(NULL)); }