==== Wikka Mod 014 ==== Type: Feature Addition ---- ===Credit:=== Heavyk, (k m r @ h e a v y k . o r g) [[http://web.archive.org/web/20040817142536/http://www.wakkawiki.com/TextSearchImproved | TextSearchImproved @ WakkaWiki]] ---- ====Text search improved==== This update improves the output of the basic textsearch action. The default action with Wakka Wiki is to just return a listing of the WikiWords that matched the search. However, this wasn't nearly enough information to determine what link to click on, especially if there are many search results. The new output includes a portion of the matching text with the search phrase highlighted. ---- **actions/textsearch.php** %%(php) FormOpen("", "", "GET") ?>
Search for:  " />
FormClose(); ?> "); if ($results = $this->FullTextSearch($phrase)) { print("Search results for \"$phrase\":

\n"); print ""; $STORE_FORMATING_AS_TEXT = 1; foreach ($results as $i => $page) { //print(($i+1).". ".$this->Link($page["tag"])."
\n"); //print implode($this->LoadPage($page["tag"])); //$matchString = preg_match("/(.{0,40}$phrase.{0,40})/",implode($this->LoadPage($page['tag']))); /* display portion of the matching body and highlight the search term */ preg_match("/(.{0,120}$phrase.{0,120})/is",$page['body'],$matchString); $text = $matchString[0]; include("formatters/wakka.php"); $highlightMatch = preg_replace("/($phrase)/i","$1",$text,-1); $matchText = "...$highlightMatch..."; print " "; } print "
".($i+1)."
".$this->Link($page["tag"])." $page[time]
  $matchText
 
"; } else { print("No results for \"$phrase\"."); } } ?> %% In order to properly format the matching text the following small modification must be made to the **formatters/wakka.php** file. Modify the last line of the file. It should originally read print($text); The new version should read if (!$STORE_FORMATING_AS_TEXT) print($text); ---- Heavyk, 3/8/04 (k m r @ h e a v y k . o r g)