Index: trunk/core/units/general/cat_tag_processor.php =================================================================== diff -u -N -r8718 -r8734 --- trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8718) +++ trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8734) @@ -413,6 +413,43 @@ return $ret; } + + function RelevanceIndicator($params) + { + $object =& $this->getObject($params); + + $search_results_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search'; + $sql = 'SELECT Relevance + FROM '.$search_results_table.' + WHERE ResourceId = '.$object->GetDBField('ResourceId'); + + $percents_off = (int)(100 - (100 * $this->Conn->GetOne($sql))); + $percents_off = ($percents_off < 0) ? 0 : $percents_off; + if ($percents_off) { + $params['percent_off'] = $percents_off; + $params['percent_on'] = 100 - $percents_off; + $params['name'] = $this->SelectParam($params, 'relevance_normal_render_as,block_relevance_normal'); + } + else { + $params['name'] = $this->SelectParam($params, 'relevance_full_render_as,block_relevance_full'); + } + return $this->Application->ParseBlock($params); + } + + function SearchResultField($params) + { + $ret = $this->Field($params); + + $keywords = unserialize( $this->Application->RecallVar('highlight_keywords') ); + $opening = $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'highlight_opening_render_as,block_highlight_opening')) ); + $closing = $this->Application->ParseBlock( Array('name' => $this->SelectParam($params, 'highlight_closing_render_as,block_highlight_closing')) ); + + foreach ($keywords as $index => $keyword) { + $keywords[$index] = preg_quote($keyword, '/'); + } + + return preg_replace('/('.implode('|', $keywords).')/i', $opening.'\\1'.$closing, $ret); + } } ?> \ No newline at end of file