Exemple #1
0
 function highlight($query, $content)
 {
     $point_dl = 100;
     $query = string::utf2win($query);
     $content = string::utf2win($content);
     $content = strip_tags($content);
     $content_st = $content_and = '';
     $point = stripos($content, $query);
     $point1 = $point - $point_dl;
     if ($point1 < 0) {
         $point1 = 0;
     } else {
         $content_st = '...';
     }
     $len = strlen($content);
     $point2 = $point + $point_dl;
     if ($point2 < $len) {
         $content_end = '...';
     } else {
         $content_end = '';
     }
     $content = $content_st . substr($content, $point1, $point2) . $content_end;
     $content = str_ireplace($query, '<span style="background-color: yellow; color: black;">' . $query . '</span>', $content);
     $query = string::win2utf($query);
     $content = string::highlight(string::win2utf($content), $query);
     return $content;
 }
Exemple #2
0
echo Kohana::lang('search.results_for_pages');
?>
</h2>
<?php 
if (count($data2) > 0) {
    ?>
	<?php 
    foreach ($data2 as $row) {
        ?>
		<div class="result-item">
			<h3><?php 
        echo $row['heading'];
        ?>
</h3>
			<p><?php 
        echo string::highlight(string::return_relevant($row['text'], $form['value']), $form['value']);
        ?>
</p>
			<a href="/page/<?php 
        echo $row['url'];
        ?>
"><?php 
        echo Kohana::lang('search.more');
        ?>
</a>
		</div>
	<?php 
    }
} else {
    ?>
	<p><?php