From ac83f9d4d9cc607cc914c4e8e6f764f65dae4726 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 17 Dec 2008 04:20:31 +0000 Subject: [PATCH] MINOR Added todo and phpDoc to Text->ContextSummary() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69348 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/fieldtypes/Text.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/model/fieldtypes/Text.php b/core/model/fieldtypes/Text.php index 44a2f0b2c..f0ccd6c16 100644 --- a/core/model/fieldtypes/Text.php +++ b/core/model/fieldtypes/Text.php @@ -246,6 +246,22 @@ class Text extends DBField { } } + /** + * Perform context searching to give some context to searches, optionally + * highlighting the search term. + * + * @todo Would be useful for this to highlight each individual search keyword + * instead of the entire search query. + * + * @todo Allow selection of where the search query is coming from, instead of + * hardcoding $_REQUEST['Search'] + * + * @param int $characters Number of characters in the summary + * @param boolean $string + * @param boolean $striphtml Strip HTML? + * @param boolean $highlight Add a highlight element around search query? + * @return string + */ function ContextSummary($characters = 500, $string = false, $striphtml = true, $highlight = true) { if(!$string) { // If no string is supplied, use the string from a SearchForm @@ -261,7 +277,6 @@ class Text extends DBField { // We want to search string to be in the middle of our block to give it some context $position = max(0, $position - ($characters / 2)); - if($position > 0) { // We don't want to start mid-word $position = max((int) strrpos(substr($text, 0, $position), ' '), (int) strrpos(substr($text, 0, $position), "\n"));