| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  | // This file is part of GNU social - https://www.gnu.org/software/social
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // GNU social 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.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // GNU social 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 GNU social.  If not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  | defined('GNUSOCIAL') || die(); | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Class comment | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |  * @category  Plugin | 
					
						
							|  |  |  |  * @package   SearchSubPlugin | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  |  * @author    Evan Prodromou <evan@status.net> | 
					
						
							|  |  |  |  * @copyright 2011 StatusNet, Inc. | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |  * @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org | 
					
						
							|  |  |  |  * @license   https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-07-07 12:06:56 -04:00
										 |  |  | class SearchSubMenu extends MoreMenu | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     protected $user; | 
					
						
							|  |  |  |     protected $searches; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |     public function __construct($out, $user, $searches) | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         parent::__construct($out); | 
					
						
							|  |  |  |         $this->user = $user; | 
					
						
							|  |  |  |         $this->searches = $searches; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |     public function tag() | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2011-07-07 12:06:56 -04:00
										 |  |  |         return 'searchsubs'; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |     public function seeAllItem() | 
					
						
							| 
									
										
										
										
											2011-07-07 12:06:56 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         return array('searchsubs', | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |             array('nickname' => $this->user->nickname), | 
					
						
							|  |  |  |             _('See all'), | 
					
						
							|  |  |  |             _('See all searches you are following')); | 
					
						
							| 
									
										
										
										
											2011-07-07 12:06:56 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |     public function getItems() | 
					
						
							| 
									
										
										
										
											2011-07-07 12:06:56 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         $items = array(); | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  |         foreach ($this->searches as $search) { | 
					
						
							|  |  |  |             if (!empty($search)) { | 
					
						
							| 
									
										
										
										
											2011-07-07 12:06:56 -04:00
										 |  |  |                 $items[] = array('noticesearch', | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |                     array('q' => $search), | 
					
						
							|  |  |  |                     sprintf('"%s"', $search), | 
					
						
							|  |  |  |                     sprintf(_('Notices including %s'), $search));; | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-07 12:06:56 -04:00
										 |  |  |         return $items; | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-09-15 11:00:27 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |     public function item($actionName, array $args, $label, $description, $id = null, $cls = null) | 
					
						
							| 
									
										
										
										
											2011-09-15 11:00:27 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (empty($id)) { | 
					
						
							|  |  |  |             $id = $this->menuItemID($actionName, $args); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-18 19:20:28 -04:00
										 |  |  |         if ($actionName == 'noticesearch') { | 
					
						
							| 
									
										
										
										
											2011-09-18 17:32:13 -04:00
										 |  |  |             // Add 'q' as a search param, not part of the url path
 | 
					
						
							|  |  |  |             $url = common_local_url($actionName, array(), $args); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $url = common_local_url($actionName, $args); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2011-09-15 11:00:27 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-11 04:11:27 +01:00
										 |  |  |         $this->out->menuItem( | 
					
						
							|  |  |  |             $url, | 
					
						
							|  |  |  |             $label, | 
					
						
							|  |  |  |             $description, | 
					
						
							|  |  |  |             $this->isCurrent($actionName, $args), | 
					
						
							|  |  |  |             $id, | 
					
						
							|  |  |  |             $cls | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2011-09-15 11:00:27 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-04-05 18:45:37 -04:00
										 |  |  | } |