1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-30 17:50:12 +02:00

Fixed PHP warnings in search class

This commit is contained in:
Cameron
2014-02-04 09:22:34 -08:00
parent 47c546c2fb
commit 3ca9052f69

View File

@@ -271,61 +271,72 @@ class e_search
$endcrop = FALSE; $endcrop = FALSE;
$output = '<!-- Start Search Results -->'; $output = '<!-- Start Search Results -->';
$title = TRUE; $title = TRUE;
foreach ($matches as $this -> text) {
$this -> text = nl2br($this -> text); if(!empty($matches))
$t_search = $tp -> search; {
$t_replace = $tp -> replace; foreach ($matches as $this -> text)
$s_search = array('<br />', '[', ']');
$s_replace = array(' ', '<', '>');
$search = array_merge($t_search, $s_search);
$replace = array_merge($t_replace, $s_replace);
$this -> text = strip_tags(str_replace($search, $replace, $this -> text));
foreach ($this -> keywords['match'] as $match_id => $this -> query)
{ {
$boundary = $search_prefs['boundary'] ? '\b' : ''; $this -> text = nl2br($this -> text);
if ($this -> keywords['wildcard'][$match_id]) { $t_search = $tp -> search;
$regex_append = ".*?".$boundary.")"; $t_replace = $tp -> replace;
} else { $s_search = array('<br />', '[', ']');
$regex_append = $boundary.")"; $s_replace = array(' ', '<', '>');
} $search = array_merge($t_search, $s_search);
if (($match_start = $tp->ustristr($this -> text, $this -> query)) !== FALSE) { $replace = array_merge($t_replace, $s_replace);
$this -> pos = $tp->ustrlen($this -> text) - $tp->ustrlen($match_start);
if (!$endcrop && !$title) { $this -> text = strip_tags(str_replace($search, $replace, $this -> text));
$this -> parsesearch_crop();
$endcrop = TRUE;
if(!empty($this->keywords['match']))
{
foreach ($this -> keywords['match'] as $match_id => $this -> query)
{
$boundary = $search_prefs['boundary'] ? '\b' : '';
if ($this -> keywords['wildcard'][$match_id]) {
$regex_append = ".*?".$boundary.")";
} else {
$regex_append = $boundary.")";
}
if (($match_start = $tp->ustristr($this -> text, $this -> query)) !== FALSE)
{
$this -> pos = $tp->ustrlen($this -> text) - $tp->ustrlen($match_start);
if (!$endcrop && !$title) {
$this -> parsesearch_crop();
$endcrop = TRUE;
}
$key = $tp->usubstr($this -> text, $this->pos, $tp->ustrlen($this -> query));
$this -> text = preg_replace("#(".$boundary.$this -> query.$regex_append."#i", "<span class='searchhighlight'>\\1</span>", $this -> text);
}
} }
$key = $tp->usubstr($this -> text, $this->pos, $tp->ustrlen($this -> query));
$this -> text = preg_replace("#(".$boundary.$this -> query.$regex_append."#i", "<span class='searchhighlight'>\\1</span>", $this -> text);
}
}
if ($title)
{
if ($pre_title == 0)
{
$pre_title_output = "";
}
else if ($pre_title == 1)
{
$pre_title_output = $res['pre_title'];
}
else if ($pre_title == 2)
{
$pre_title_output = $pre_title;
} }
$this -> text = $this -> bullet." <b><a class='visit' href='".$res['link']."'>".$pre_title_output.$this -> text."</a></b><br />".$res['pre_summary'];
} if($title)
else if (!$endcrop) {
{ if ($pre_title == 0)
$this -> parsesearch_crop(); {
$pre_title_output = "";
}
else if ($pre_title == 1)
{
$pre_title_output = $res['pre_title'];
}
else if ($pre_title == 2)
{
$pre_title_output = $pre_title;
}
$this -> text = $this -> bullet." <b><a class='visit' href='".$res['link']."'>".$pre_title_output.$this -> text."</a></b><br />".$res['pre_summary'];
}
elseif (!$endcrop)
{
$this -> parsesearch_crop();
}
$output .= $this -> text;
$title = FALSE;
} }
$output .= $this -> text;
$title = FALSE;
} }
$display_rel = $search_prefs['relevance'] ? " | ".LAN_SEARCH_69.": ".round($row['relevance'], 1) : ""; $display_rel = $search_prefs['relevance'] ? " | ".LAN_SEARCH_69.": ".round($row['relevance'], 1) : "";
$output_array['text'][] = $output.$res['post_summary']."<br /><small>".$res['detail'].$display_rel."</small><br /><br />"; $output_array['text'][] = $output.$res['post_summary']."<br /><small>".$res['detail'].$display_rel."</small><br /><br />";
} }