Index: branches/RC/core/units/general/helpers/search_helper.php =================================================================== diff -u -r11259 -r11290 --- branches/RC/core/units/general/helpers/search_helper.php (.../search_helper.php) (revision 11259) +++ branches/RC/core/units/general/helpers/search_helper.php (.../search_helper.php) (revision 11290) @@ -11,6 +11,14 @@ */ function splitKeyword($keyword) { + if ($this->Application->ConfigValue('CheckStopWords')) { + $keyword_after_remove = $this->_removeStopWords($keyword); + if ($keyword_after_remove) { + // allow to search through stop word grid + $keyword = $keyword_after_remove; + } + } + $quotes_re = '/([+\-]?)"(.*?)"/'; $no_quotes_re = '/([+\-]?)([^ ]+)/'; @@ -115,6 +123,32 @@ } /** + * Removes stop words from keyword + * + * @param string $keyword + * @return string + */ + function _removeStopWords($keyword) + { + static $stop_words = Array (); + + if (!$stop_words) { + $sql = 'SELECT StopWord + FROM ' . $this->Application->getUnitOption('stop-word', 'TableName') . ' + ORDER BY LENGTH(StopWord) DESC, StopWord ASC'; + $stop_words = $this->Conn->GetCol($sql); + + foreach ($stop_words as $index => $stop_word) { + $stop_words[$index] = '/(^| )' . preg_quote($stop_word, '/') . '( |$)/'; + } + } + + $keyword = preg_replace($stop_words, ' ', $keyword); + + return trim( preg_replace('/[ ]+/', ' ', $keyword) ); + } + + /** * Enter description here... * * @param kEvent $event