From ffe54b8662089d0f44bed5a725c98f00eab2bfc7 Mon Sep 17 00:00:00 2001 From: steinm Date: Fri, 25 Jan 2013 09:39:37 +0000 Subject: [PATCH] - added method markQuery() which was previosly globally defined in op.Search.php --- views/bootstrap/class.Search.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index 51b9c2f30..7729ec1af 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -31,10 +31,20 @@ require_once("class.Bootstrap.php"); */ class LetoDMS_View_Search extends LetoDMS_Bootstrap_Style { + function markQuery($str, $tag = "b") { + $querywords = preg_split("/ /", $this->query); + + foreach ($querywords as $queryword) + $str = str_ireplace("($queryword)", "<" . $tag . ">\\1", $str); + + return $str; + } + function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $folder = $this->params['folder']; + $this->query = $this->params['query']; $entries = $this->params['searchhits']; $totalpages = $this->params['totalpages']; $pageNumber = $this->params['pagenumber']; @@ -76,14 +86,14 @@ class LetoDMS_View_Search extends LetoDMS_Bootstrap_Style { $previewer->createPreview($lc); if (in_array(3, $searchin)) - $comment = markQuery(htmlspecialchars($document->getComment())); + $comment = $this->markQuery(htmlspecialchars($document->getComment())); else $comment = htmlspecialchars($document->getComment()); if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "..."; print ""; //print ""; if (in_array(2, $searchin)) { - $docName = markQuery(htmlspecialchars($document->getName()), "i"); + $docName = $this->markQuery(htmlspecialchars($document->getName()), "i"); } else { $docName = htmlspecialchars($document->getName()); } @@ -132,7 +142,7 @@ class LetoDMS_View_Search extends LetoDMS_Bootstrap_Style { $folder = $entry; $foldercount++; if (in_array(2, $searchin)) { - $folderName = markQuery(htmlspecialchars($folder->getName()), "i"); + $folderName = $this->markQuery(htmlspecialchars($folder->getName()), "i"); } else { $folderName = htmlspecialchars($folder->getName()); } @@ -151,7 +161,7 @@ class LetoDMS_View_Search extends LetoDMS_Bootstrap_Style { print "".htmlspecialchars($owner->getFullName()).""; print ""; print ""; - if (in_array(3, $searchin)) $comment = markQuery(htmlspecialchars($folder->getComment())); + if (in_array(3, $searchin)) $comment = $this->markQuery(htmlspecialchars($folder->getComment())); else $comment = htmlspecialchars($folder->getComment()); if (strlen($comment) > 50) $comment = substr($comment, 0, 47) . "..."; print "".$comment."";