diff options
author | zotlabs <mike@macgirvin.com> | 2016-08-28 12:32:32 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-28 12:32:32 +1000 |
commit | 391d7fed523b47e9cceb2f27be7c91bdf47b535c (patch) | |
tree | 8fc0a973e1fbcdc945533e94cb0c98176da0e97e /include | |
parent | 381b1a066d83198c6f13f8aa920a6e4537f9404f (diff) | |
parent | 07e28a9757d23b4bffa44f54937fe914a6a106db (diff) | |
download | volse-hubzilla-391d7fed523b47e9cceb2f27be7c91bdf47b535c.tar.gz volse-hubzilla-391d7fed523b47e9cceb2f27be7c91bdf47b535c.tar.bz2 volse-hubzilla-391d7fed523b47e9cceb2f27be7c91bdf47b535c.zip |
Merge pull request #501 from anaqreon/doc-search
Display text around the searched query in documentation search
Diffstat (limited to 'include')
-rw-r--r-- | include/help.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/help.php b/include/help.php index 7f57f3334..4bcc09670 100644 --- a/include/help.php +++ b/include/help.php @@ -40,8 +40,13 @@ function search_doc_files($s) { $r = fetch_post_tags($r,true); for($x = 0; $x < count($r); $x ++) { - - $r[$x]['text'] = $r[$x]['body']; + $position = stripos($r[$x]['body'], $s); + $dislen = 300; + $start = $position-floor($dislen/2); + if ( $start < 0) { + $start = 0; + } + $r[$x]['text'] = substr($r[$x]['body'], $start, $dislen); $r[$x]['rank'] = 0; if($r[$x]['term']) { |