Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/cat_event_handler.php
Show First 20 Lines • Show All 1312 Lines • ▼ Show 20 Line(s) | |||||
$weight = $config_elem['Priority']; | $weight = $config_elem['Priority']; | ||||
// search by whole words only ([[:<:]] - word boundary) | // search by whole words only ([[:<:]] - word boundary) | ||||
/*$revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.implode(' ', $positive_words).')[[:>:]]", '.$weight.', 0)'; | /*$revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.implode(' ', $positive_words).')[[:>:]]", '.$weight.', 0)'; | ||||
foreach ($positive_words as $keyword) { | foreach ($positive_words as $keyword) { | ||||
$revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)'; | $revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)'; | ||||
}*/ | }*/ | ||||
if ( count($positive_words) > 1 ) { | |||||
$condition = $field . ' LIKE "%' . implode(' ', $positive_words) . '%"'; | |||||
$revelance_parts[] = 'IF(' . $condition . ', ' . $weight_sum . ', 0)'; | |||||
} | |||||
// search by partial word matches too | // search by partial word matches too | ||||
$revelance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)'; | |||||
foreach ($positive_words as $keyword) { | foreach ( $positive_words as $keyword ) { | ||||
$revelance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$weight.', 0)'; | $revelance_parts[] = 'IF(' . $field . ' LIKE "%' . $keyword . '%", ' . $weight . ', 0)'; | ||||
} | } | ||||
} | } | ||||
$revelance_parts = array_unique($revelance_parts); | $revelance_parts = array_unique($revelance_parts); | ||||
$conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix'); | $conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix'); | ||||
$rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100; | $rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100; | ||||
$rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100; | $rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100; | ||||
▲ Show 20 Lines • Show All 1747 Lines • Show Last 20 Lines |