diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-03 10:10:12 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-03 10:10:12 -0400 |
commit | 72d0ee4e2546a789728ee6d2750a2eed560d265f (patch) | |
tree | 727ec15cfa2ff36778512c624c6d97edc4be26ef /actions/peoplesearch.php | |
parent | f73d93fa7ae79f1e0b47d73fbdc1b214c6e559ae (diff) |
move peoplesearchresults class to action/peoplesearch
Diffstat (limited to 'actions/peoplesearch.php')
-rw-r--r-- | actions/peoplesearch.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index c61e0e273..60ddb6a82 100644 --- a/actions/peoplesearch.php +++ b/actions/peoplesearch.php @@ -87,3 +87,47 @@ class PeoplesearchAction extends SearchAction } } +/** + * People search results class + * + * Derivative of ProfileList with specialization for highlighting search terms. + * + * @category Widget + * @package Laconica + * @author Evan Prodromou <evan@controlyourself.ca> + * @author Robin Millette <millette@controlyourself.ca> + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * + * @see PeoplesearchAction + */ + +class PeopleSearchResults extends ProfileList +{ + var $terms = null; + var $pattern = null; + + function __construct($profile, $terms, $action) + { + parent::__construct($profile, $action); + + $this->terms = array_map('preg_quote', + array_map('htmlspecialchars', $terms)); + + $this->pattern = '/('.implode('|',$terms).')/i'; + } + + function newProfileItem($profile) + { + return new PeopleSearchResultItem($profile, $this->action); + } +} + +class PeopleSearchResultItem extends ProfileListItem +{ + function highlight($text) + { + return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text)); + } +} + |