View Issue Details

IDProjectCategoryView StatusLast Update
0000101WackoWikiactionpublic2009-10-13 16:03
Reporteradministrator Assigned Toadministrator  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.2 
Target Version5.0.betaFixed in Version5.0.beta 
Summary0000101: add preview_text in search
Descriptioncopy-paste and update of original search action.
displays pagenames and lines in page where the phrase was found.
new param – “clean”, if true – omits the phrase from result lines.
Additional Informationneeds update to wacko.php.
more info - http://wackowiki.org/Dev/PatchesHacks/SearchLine

update to wacko.php

<?php
function FullTextSearchWithBody($phrase,$filter)
{
    return $this->LoadAll("SELECT ".$this->pages_meta.", body FROM ".$this->config["table_prefix"]."pages WHERE latest = 'Y' AND (( match(body) against('".quote($this->dblink, $phrase)."') OR lower(tag) LIKE lower('%".quote($this->dblink, $phrase)."%')) ".($filter?"AND comment_on=''":"")." )");
}

?>

/actions/searchline.php
<?php

if (($topic == 1) || ($title == 1)) $mode = "topic"; else $mode = "full";
if ($_REQUEST["topic"] == "on") $mode = "topic";
//if (!$delim) $delim="---";
if (!in_array($style,array("br","ul","ol","comma"))) $style="ol";
$i = 0;
if ($filter!="pages") $filter = "all";
if (!isset($clean)) $clean = false;

if ($vars[0] != "") $phrase = $vars[0]; else { $phrase=""; $form=1; }

if ($phrase == "") $phrase = $_REQUEST["phrase"];
if ($phrase)
{

  if (strlen($phrase)>2)
  {

    if ($mode == "topic") $results = $this->TagSearch($phrase);
                     else $results = $this->FullTextSearchWithBody($phrase, ($filter=="all"?0:1));
    $phrase = htmlspecialchars($phrase);
    if ($results)
    {
      if (!$nomark) print( "<fieldset><legend>".
              $this->GetResourceValue(($mode=="topic"?"Topic":"")."SearchResults").
              " \"$phrase\":
</legend>");
      if ($style=="ul") print "<ul class=\"SearchResults\">\n";
      if ($style=="ol") print "<ol class=\"SearchResults\">\n";

      foreach ($results as $page)
      if (!$this->config["hide_locked"] || $this->HasAccess("read",$page["tag"]) && $page["tag"] != $this->getPageTag() )
      {
        if ($style=="ul" || $style=="ol") print "
  • ";
            if ($style=="comma" && $i>0) print ",\n";

            print($this->Link("/".$page["tag"],"",$page["tag"]));
            print(" " . getLineWithPhrase($phrase, $page["body"], $clean));

            if ($style=="br") print "
    \n";
            if ($style=="ul" || $style=="ol") print "
  • \n";
            $i++;
          }

          if ($style=="ul") print "";
          if ($style=="ol") print "";
          if (!$nomark) print("</fieldset>");
        }
        else
          if (!$nomark) echo $this->GetResourceValue("NoResultsFor")."\"$phrase\".";
      }
      else
        if (!$nomark) echo $this->GetResourceValue("NoResultsFor")."\"$phrase\".";
    }

    function getLineWithPhrase($phrase, $string, $cleanup)
    {
        $lines = split("\n", $string);
        $result = "";
        foreach ($lines as $line)
        {
            if (strpos($line, $phrase))
            {
                if ($result) $result .= "
    \n";
                $result .= $cleanup ? str_replace("$phrase", "", $line) : $line;
            }
        }
        return $result;
    }
    ?>
    TagsNo tags attached.

    Relationships

    related to 0000173 assignedadministrator Extended Search 

    Activities

    administrator

    2009-03-01 20:12

    administrator   ~0000582

    patch applied -> pre stage for 0000173

    Issue History

    Date Modified Username Field Change
    2007-10-10 20:52 administrator New Issue
    2007-10-10 20:53 administrator File Added: searchline.php
    2007-10-10 20:53 administrator Legacy => NPJ
    2007-12-01 15:36 Tann San Status new => assigned
    2007-12-01 15:36 Tann San Assigned To => Tann San
    2008-04-10 02:04 administrator Additional Information Updated
    2008-05-16 19:40 administrator Relationship added related to 0000173
    2008-08-01 23:40 administrator Additional Information Updated
    2008-08-01 23:43 administrator Description Updated
    2008-08-01 23:43 administrator Additional Information Updated
    2008-08-23 14:02 administrator Additional Information Updated
    2009-01-06 16:59 administrator Additional Information Updated
    2009-03-01 20:12 administrator Note Added: 0000582
    2009-03-01 20:12 administrator Assigned To Tann San => administrator
    2009-03-01 20:12 administrator Status assigned => resolved
    2009-03-01 20:12 administrator Resolution open => fixed
    2009-03-01 20:12 administrator Fixed in Version => 5.0.0
    2009-03-01 20:12 administrator Target Version => 5.0.0
    2009-03-01 20:12 administrator Additional Information Updated
    2009-03-01 20:14 administrator Summary new action - searchline => add preview_text in search
    2009-03-01 20:14 administrator File Deleted: searchline.php
    2009-03-01 20:16 administrator Additional Information Updated
    2009-10-13 16:00 administrator Target Version 5.0.0 => 5.0.beta
    2009-10-13 16:03 administrator Fixed in Version 5.0.0 => 5.0.beta
    2010-03-08 10:09 administrator Category Action => action