| 
									
										
										
										
											2008-07-09 19:10:31 -04:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Base search action class. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * PHP version 5 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category Action | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * @package  StatusNet | 
					
						
							| 
									
										
										
										
											2009-08-25 18:19:04 -04:00
										 |  |  |  * @author   Evan Prodromou <evan@status.net> | 
					
						
							|  |  |  |  * @author   Robin Millette <millette@status.net> | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 | 
					
						
							| 
									
										
										
										
											2009-08-25 18:16:46 -04:00
										 |  |  |  * @link     http://status.net/ | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2009-08-25 18:14:12 -04:00
										 |  |  |  * StatusNet - the distributed open-source microblogging tool | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * Copyright (C) 2008, 2009, StatusNet, Inc. | 
					
						
							| 
									
										
										
										
											2008-07-09 19:10:31 -04:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU Affero General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-25 18:42:34 -04:00
										 |  |  | if (!defined('STATUSNET')) { | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |     exit(1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require_once INSTALLDIR.'/lib/searchgroupnav.php'; | 
					
						
							| 
									
										
										
										
											2008-07-09 19:10:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Base search action class. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category Action | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * @package  StatusNet | 
					
						
							| 
									
										
										
										
											2009-08-25 18:19:04 -04:00
										 |  |  |  * @author   Evan Prodromou <evan@status.net> | 
					
						
							|  |  |  |  * @author   Robin Millette <millette@status.net> | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 | 
					
						
							| 
									
										
										
										
											2009-08-25 18:16:46 -04:00
										 |  |  |  * @link     http://status.net/ | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-12-23 14:49:23 -05:00
										 |  |  | class SearchAction extends Action | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Return true if read only. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return boolean true | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2009-04-13 15:49:26 -04:00
										 |  |  |     function isReadOnly($args) | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-07-22 17:20:56 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     function handle($args) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         parent::handle($args); | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |         $this->showPage(); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-07-09 19:10:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Show tabset for this page | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * Uses the SearchGroupNav widget | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return void | 
					
						
							|  |  |  |      * @see SearchGroupNav | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function showLocalNav() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:00:06 +01:00
										 |  |  |         $nav = new SearchGroupNav($this, $this->trimmed('q')); | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |         $nav->show(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function showTop($arr=null) | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-02-20 16:51:39 -05:00
										 |  |  |         $error = null; | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         if ($arr) { | 
					
						
							|  |  |  |             $error = $arr[1]; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-02-20 16:51:39 -05:00
										 |  |  |         if (!empty($error)) { | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |             $this->element('p', 'error', $error); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |             $instr = $this->getInstructions(); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |             $output = common_markup_to_html($instr); | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |             $this->elementStart('div', 'instructions'); | 
					
						
							|  |  |  |             $this->raw($output); | 
					
						
							|  |  |  |             $this->elementEnd('div'); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-07-09 19:10:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |     function title() | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2008-12-23 14:21:29 -05:00
										 |  |  |         return null; | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-07-09 19:42:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |     function showNoticeForm() { | 
					
						
							|  |  |  |         // remote post notice form
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function showContent() { | 
					
						
							|  |  |  |         $this->showTop(); | 
					
						
							|  |  |  |         $this->showForm(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function showForm($error=null) | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         $q = $this->trimmed('q'); | 
					
						
							|  |  |  |         $page = $this->trimmed('page', 1); | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |         $this->elementStart('form', array('method' => 'get', | 
					
						
							| 
									
										
										
										
											2009-01-24 00:58:12 +00:00
										 |  |  |                                            'id' => 'form_search', | 
					
						
							|  |  |  |                                            'class' => 'form_settings', | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |                                            'action' => common_local_url($this->trimmed('action')))); | 
					
						
							| 
									
										
										
										
											2009-01-24 00:58:12 +00:00
										 |  |  |         $this->elementStart('fieldset'); | 
					
						
							|  |  |  |         $this->element('legend', null, _('Search site')); | 
					
						
							|  |  |  |         $this->elementStart('ul', 'form_data'); | 
					
						
							|  |  |  |         $this->elementStart('li'); | 
					
						
							| 
									
										
										
										
											2009-03-09 20:01:35 -05:00
										 |  |  |         if (!common_config('site', 'fancy')) { | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |             $this->hidden('action', $this->trimmed('action')); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-01-24 00:58:12 +00:00
										 |  |  |         $this->input('q', 'Keyword(s)', $q); | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |         $this->submit('search', 'Search'); | 
					
						
							| 
									
										
										
										
											2009-01-24 00:58:12 +00:00
										 |  |  |         $this->elementEnd('li'); | 
					
						
							|  |  |  |         $this->elementEnd('ul'); | 
					
						
							|  |  |  |         $this->elementEnd('fieldset'); | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |         $this->elementEnd('form'); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         if ($q) { | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  |             $this->showResults($q, $page); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-04-06 01:14:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     function searchSuggestions($q) { | 
					
						
							|  |  |  |         $qe = urlencode($q); | 
					
						
							|  |  |  |         $message = sprintf(_(<<<E_O_T | 
					
						
							|  |  |  | * Make sure all words are spelled correctly. | 
					
						
							|  |  |  | * Try different keywords. | 
					
						
							|  |  |  | * Try more general keywords. | 
					
						
							|  |  |  | * Try fewer keywords. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You can also try your search on other engines: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | * [Twingly](http://www.twingly.com/search?q=%s&content=microblog&site=identi.ca) | 
					
						
							|  |  |  | * [Tweet scan](http://www.tweetscan.com/indexi.php?s=%s) | 
					
						
							| 
									
										
										
										
											2009-04-06 05:04:11 +00:00
										 |  |  | * [Google](http://www.google.com/search?q=site%%3A%%%%site.server%%%%+%s) | 
					
						
							|  |  |  | * [Yahoo](http://search.yahoo.com/search?p=site%%3A%%%%site.server%%%%+%s) | 
					
						
							| 
									
										
										
										
											2009-06-21 11:11:12 -07:00
										 |  |  | * [Collecta](http://collecta.com/#q=%s)
 | 
					
						
							| 
									
										
										
										
											2009-04-06 01:14:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | E_O_T | 
					
						
							| 
									
										
										
										
											2009-06-21 11:11:12 -07:00
										 |  |  | ), $qe, $qe, $qe, $qe, $qe); | 
					
						
							| 
									
										
										
										
											2009-04-07 21:02:47 +00:00
										 |  |  |         $this->elementStart('dl', array('id' => 'help_search', 'class' => 'help')); | 
					
						
							|  |  |  |         $this->element('dt', null, _('Search help')); | 
					
						
							|  |  |  |         $this->elementStart('dd', 'instructions'); | 
					
						
							| 
									
										
										
										
											2009-04-06 01:14:59 +00:00
										 |  |  |         $this->raw(common_markup_to_html($message)); | 
					
						
							| 
									
										
										
										
											2009-04-07 21:02:47 +00:00
										 |  |  |         $this->elementEnd('dd'); | 
					
						
							| 
									
										
										
										
											2009-04-06 01:14:59 +00:00
										 |  |  |         $this->elementEnd('div'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-07-09 19:10:31 -04:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-01-23 01:00:57 +00:00
										 |  |  | 
 |