code/Extensions/SSGuru_ContentController.php
public function results($data, $form, $request)
    {
        $result     = null;
        $results = $form->getResults();
        $query     = $form->getSearchQuery();

        // Add context summaries based on the queries.
        foreach ($results as $result) {
            $contextualTitle         = new Text();
            $contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title);
            $result->ContextualTitle = $contextualTitle->ContextSummary(300, $query);

            if (!$result->Content && $result->ClassName == 'File') {
                // Fake some content for the files.
                $result->ContextualContent = "A file named \"$result->Name\" ($result->Size).";
            } else {
                // /(.?)\[embed(.*?)\](.+?)\[\/\s*embed\s*\](.?)/gi
                $valueField                     = $result->obj('Content');
                $valueField->setValue(ShortcodeParser::get_active()->parse($valueField->getValue()));
                $result->ContextualContent     = $valueField->ContextSummary(300, $query);
            }
        }

        $rssLink = HTTP::setGetVar('rss', '1');

        // Render the result.
        $context = array(
            'Results'     => $results,
            'Query'         => $query,
            'Title'         => _t('SearchForm.SearchResults', 'Search Results'),
            'RSSLink'     => $rssLink
        );

        // Choose the delivery method - rss or html.
        if (!$this->owner->request->getVar('rss')) {
            // Add RSS feed to normal search.
            RSSFeed::linkToFeed($rssLink, "Search results for query \"$query\".");

            $result = $this->owner->customise($context)->renderWith(array('Page_results', 'Page'));
        } else {
            // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context.
            $fullList = $results->getList()->sort('LastEdited', 'DESC');

            // Get some descriptive strings
            $siteName     = SiteConfig::current_site_config()->Title;
            $siteTagline = SiteConfig::current_site_config()->Tagline;
            if ($siteName) {
                $title = "$siteName search results for query \"$query\".";
            } else {
                $title = "Search results for query \"$query\".";
            }

            // Generate the feed content.
            $rss     = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null);
            $rss->setTemplate('Page_results_rss');
            $result     = $rss->outputToBrowser();
        }
        return $result;
    }
public function results($data, $form, $request)
    {
        $result     = null;
        $results = $form->getResults();
        $query     = $form->getSearchQuery();

        // Add context summaries based on the queries.
        foreach ($results as $result) {
            $contextualTitle         = new Text();
            $contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title);
            $result->ContextualTitle = $contextualTitle->ContextSummary(300, $query);

            if (!$result->Content && $result->ClassName == 'File') {
                // Fake some content for the files.
                $result->ContextualContent = "A file named \"$result->Name\" ($result->Size).";
            } else {
                // /(.?)\[embed(.*?)\](.+?)\[\/\s*embed\s*\](.?)/gi
                $valueField                     = $result->obj('Content');
                $valueField->setValue(ShortcodeParser::get_active()->parse($valueField->getValue()));
                $result->ContextualContent     = $valueField->ContextSummary(300, $query);
            }
        }

        $rssLink = HTTP::setGetVar('rss', '1');

        // Render the result.
        $context = array(
            'Results'     => $results,
            'Query'         => $query,
            'Title'         => _t('SearchForm.SearchResults', 'Search Results'),
            'RSSLink'     => $rssLink
        );

        // Choose the delivery method - rss or html.
        if (!$this->owner->request->getVar('rss')) {
            // Add RSS feed to normal search.
            RSSFeed::linkToFeed($rssLink, "Search results for query \"$query\".");

            $result = $this->owner->customise($context)->renderWith(array('Page_results', 'Page'));
        } else {
            // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context.
            $fullList = $results->getList()->sort('LastEdited', 'DESC');

            // Get some descriptive strings
            $siteName     = SiteConfig::current_site_config()->Title;
            $siteTagline = SiteConfig::current_site_config()->Tagline;
            if ($siteName) {
                $title = "$siteName search results for query \"$query\".";
            } else {
                $title = "Search results for query \"$query\".";
            }

            // Generate the feed content.
            $rss     = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null);
            $rss->setTemplate('Page_results_rss');
            $result     = $rss->outputToBrowser();
        }
        return $result;
    }
public function results ( $ data , $ form , $ request ) { $ result = null ; $ results = $ form -> getResults ( ) ; $ query = $ form -> getSearchQuery ( ) ; // Add context summaries based on the queries. foreach ( $ results as $ result ) { $ contextualTitle = new Text ( ) ; $ contextualTitle -> setValue ( $ result -> MenuTitle ? $ result -> MenuTitle : $ result -> Title ) ; $ result -> ContextualTitle = $ contextualTitle -> ContextSummary ( 300 , $ query ) ; if ( ! $ result -> Content && $ result -> ClassName == 'File' ) { // Fake some content for the files. $ result -> ContextualContent = "A file named \"$result->Name\" ($result->Size)." ; } else { // /(.?)\[embed(.*?)\](.+?)\[\/\s*embed\s*\](.?)/gi $ valueField = $ result -> obj ( 'Content' ) ; $ valueField -> setValue ( ShortcodeParser :: get_active ( ) -> parse ( $ valueField -> getValue ( ) ) ) ; $ result -> ContextualContent = $ valueField -> ContextSummary ( 300 , $ query ) ; } } $ rssLink = HTTP :: setGetVar ( 'rss' , '1' ) ; // Render the result. $ context = array ( 'Results' => $ results , 'Query' => $ query , 'Title' => _t ( 'SearchForm.SearchResults' , 'Search Results' ) , 'RSSLink' => $ rssLink ) ; // Choose the delivery method - rss or html. if ( ! $ this -> owner -> request -> getVar ( 'rss' ) ) { // Add RSS feed to normal search. RSSFeed :: linkToFeed ( $ rssLink , "Search results for query \"$query\"." ) ; $ result = $ this -> owner -> customise ( $ context ) -> renderWith ( array ( 'Page_results' , 'Page' ) ) ; } else { // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context. $ fullList = $ results -> getList ( ) -> sort ( 'LastEdited' , 'DESC' ) ; // Get some descriptive strings $ siteName = SiteConfig :: current_site_config ( ) -> Title ; $ siteTagline = SiteConfig :: current_site_config ( ) -> Tagline ; if ( $ siteName ) { $ title = "$siteName search results for query \"$query\"." ; } else { $ title = "Search results for query \"$query\"." ; } // Generate the feed content. $ rss = new RSSFeed ( $ fullList , $ this -> owner -> request -> getURL ( ) , $ title , $ siteTagline , "Title" , "ContextualContent" , null ) ; $ rss -> setTemplate ( 'Page_results_rss' ) ; $ result = $ rss -> outputToBrowser ( ) ; } return $ result ; }
Overrides the ContentControllerSearchExtension and adds snippets to results.

@param array $data
@param SearchForm $form
@param SS_HTTPRequest $request
@return HTMLText
Overrides the ContentControllerSearchExtension and adds snippets to results .