mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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
This commit is contained in:
parent
8bacc8b8ff
commit
ac83f9d4d9
@ -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 <span> element around search query?
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function ContextSummary($characters = 500, $string = false, $striphtml = true, $highlight = true) {
|
function ContextSummary($characters = 500, $string = false, $striphtml = true, $highlight = true) {
|
||||||
if(!$string) {
|
if(!$string) {
|
||||||
// If no string is supplied, use the string from a SearchForm
|
// 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
|
// We want to search string to be in the middle of our block to give it some context
|
||||||
$position = max(0, $position - ($characters / 2));
|
$position = max(0, $position - ($characters / 2));
|
||||||
|
|
||||||
|
|
||||||
if($position > 0) {
|
if($position > 0) {
|
||||||
// We don't want to start mid-word
|
// We don't want to start mid-word
|
||||||
$position = max((int) strrpos(substr($text, 0, $position), ' '), (int) strrpos(substr($text, 0, $position), "\n"));
|
$position = max((int) strrpos(substr($text, 0, $position), ' '), (int) strrpos(substr($text, 0, $position), "\n"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user