X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fpeoplesearch.php;h=60ddb6a82863d80b0b78005c6dc2d5a9474f28df;hb=dd705ddaf751ee8132cdd52e47aeef259477912c;hp=c61e0e273957f5779a9730650bc7fec073d78c1b;hpb=6328add622641e5f5721cc34d27d4d872c86a561;p=quix0rs-gnu-social.git diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index c61e0e2739..60ddb6a828 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 + * @author Robin Millette + * @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, '\\1', htmlspecialchars($text)); + } +} +