PHP Class Bolt\Helpers\Excerpt

Afficher le fichier Open project: bolt/bolt Class Usage Examples

Protected Properties

Свойство Type Description
$body Bolt\Legacy\Content | array | string
$title string

Méthodes publiques

Méthode Description
__construct ( Content | array | string $body, string | null $title = null ) Constructor.
getExcerpt ( integer $length = 200, boolean $includeTitle = false, array | string | null $focus = null ) : string | null Get the excerpt of a given piece of text.

Private Methods

Méthode Description
determineSnipLocation ( array $locations, integer $prevCount ) : integer Work out which is the most relevant portion to display This is done by looping over each match and finding the smallest distance between two found strings. The idea being that the closer the terms are the better match the snippet would be.
extractLocations ( array $words, string $fulltext ) : array Find the locations of each of the words.
extractRelevant ( string | array $words, string $fulltext, integer $relLength = 300 ) : mixed | string Center on, and highlight search terms in excerpts.

Method Details

__construct() public méthode

Constructor.
public __construct ( Content | array | string $body, string | null $title = null )
$body Bolt\Legacy\Content | array | string
$title string | null

getExcerpt() public méthode

Get the excerpt of a given piece of text.
public getExcerpt ( integer $length = 200, boolean $includeTitle = false, array | string | null $focus = null ) : string | null
$length integer
$includeTitle boolean
$focus array | string | null
Résultat string | null

Property Details

$body protected_oe property

protected Content,Bolt\Legacy|array|string $body
Résultat Bolt\Legacy\Content | array | string

$title protected_oe property

protected string $title
Résultat string