From 72d0ee4e2546a789728ee6d2750a2eed560d265f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 3 Jul 2009 10:10:12 -0400 Subject: move peoplesearchresults class to action/peoplesearch --- actions/peoplesearch.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'actions') 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 + * @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)); + } +} + -- cgit v1.2.3-54-g00ecf From 04c713e671663a64b573a28912dd06cf0de3cb58 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 3 Jul 2009 10:37:39 -0400 Subject: fixed limit for conversations --- actions/conversation.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/conversation.php b/actions/conversation.php index 468409189..5049a2232 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -31,6 +31,11 @@ if (!defined('LACONICA')) { exit(1); } +// XXX: not sure how to do paging yet, +// so set a 60-notice limit + +define('CONVERSATION_LIMIT', 60); + require_once INSTALLDIR.'/lib/noticelist.php'; /** @@ -107,7 +112,7 @@ class ConversationAction extends Action function showContent() { - $notices = Notice::conversationStream($this->id, null); + $notices = Notice::conversationStream($this->id, null, CONVERSATION_LIMIT); $ct = new ConversationTree($notices, $this); -- cgit v1.2.3-54-g00ecf From e2f8b8d65d3018ba8bee9e6be51f5ce445d433ef Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 3 Jul 2009 10:40:23 -0400 Subject: no limit on conversation stream --- actions/conversation.php | 4 +--- classes/Notice.php | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'actions') diff --git a/actions/conversation.php b/actions/conversation.php index 5049a2232..4c4471f83 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -34,8 +34,6 @@ if (!defined('LACONICA')) { // XXX: not sure how to do paging yet, // so set a 60-notice limit -define('CONVERSATION_LIMIT', 60); - require_once INSTALLDIR.'/lib/noticelist.php'; /** @@ -112,7 +110,7 @@ class ConversationAction extends Action function showContent() { - $notices = Notice::conversationStream($this->id, null, CONVERSATION_LIMIT); + $notices = Notice::conversationStream($this->id, 0, null); $ct = new ConversationTree($notices, $this); diff --git a/classes/Notice.php b/classes/Notice.php index 2ba2f31b1..8a018068a 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1187,6 +1187,7 @@ class Notice extends Memcached_DataObject if (empty($cache) || $since_id != 0 || $max_id != 0 || (!is_null($since) && $since > 0) || + is_null($limit) || ($offset + $limit) > NOTICE_CACHE_WINDOW) { return call_user_func_array($fn, array_merge($args, array($offset, $limit, $since_id, $max_id, $since))); -- cgit v1.2.3-54-g00ecf From 088fa6befcf93607020fa2c77fcfdc952239efb8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 3 Jul 2009 10:48:15 -0400 Subject: null for both args in conversation --- actions/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/conversation.php b/actions/conversation.php index 4c4471f83..0eb0d86d6 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -110,7 +110,7 @@ class ConversationAction extends Action function showContent() { - $notices = Notice::conversationStream($this->id, 0, null); + $notices = Notice::conversationStream($this->id, null, null); $ct = new ConversationTree($notices, $this); -- cgit v1.2.3-54-g00ecf