| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  | <?php | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * StatusNet - the distributed open-source microblogging tool | 
					
						
							|  |  |  |  * Copyright (C) 2010, StatusNet, Inc. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2010-09-30 14:52:00 -07:00
										 |  |  |  * @package SlicedFavoritesPlugin | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  |  * @maintainer Brion Vibber <brion@status.net> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (!defined('STATUSNET')) { exit(1); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SlicedFavoritesPlugin extends Plugin | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-06-03 01:56:52 +01:00
										 |  |  |     const PLUGIN_VERSION = '2.0.0'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Example: | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      *   addPlugin('SlicedFavorites', array( | 
					
						
							|  |  |  |      *     'slices' => array( | 
					
						
							|  |  |  |      *       // show only pop's notices on /favorited
 | 
					
						
							|  |  |  |      *       'default' => array('include' => array('pop')), | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  |      *       // show only son's notices on /favorited/blog
 | 
					
						
							|  |  |  |      *       'blog' => array('include' => array('son')), | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  |      *       // show all favorited notices except pop's and son's on /favorited/submitted
 | 
					
						
							|  |  |  |      *       'submitted' => array('exclude' => array('pop', 'son')), | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  |      * | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  |      *       // show all favorited notices on /favorited/everybody
 | 
					
						
							|  |  |  |      *       'everybody' => array(), | 
					
						
							|  |  |  |      *     ) | 
					
						
							|  |  |  |      *   )); | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var array | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $slices = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Hook for RouterInitialized event. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2014-11-07 15:24:05 +01:00
										 |  |  |      * @param URLMapper $m path-to-action mapper | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  |      * @return boolean hook return | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2014-11-07 15:24:05 +01:00
										 |  |  |     public function onRouterInitialized(URLMapper $m) | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  |     { | 
					
						
							|  |  |  |         $m->connect('favorited/:slice', | 
					
						
							| 
									
										
										
										
											2019-07-11 19:14:03 +01:00
										 |  |  |                     ['action' => 'favoritedslice'], | 
					
						
							|  |  |  |                     ['slice' => '[a-zA-Z0-9]+']); | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Take over the default... :D
 | 
					
						
							|  |  |  |     function onArgsInitialize($args) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (array_key_exists('action', $args)) { | 
					
						
							|  |  |  |             $action = trim($args['action']); | 
					
						
							|  |  |  |             if ($action == 'favorited') { | 
					
						
							|  |  |  |                 common_redirect(common_local_url('favoritedslice', array('slice' => 'default'))); | 
					
						
							|  |  |  |                 exit(0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function onSlicedFavoritesGetSettings($slice, &$data) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (isset($this->slices[$slice])) { | 
					
						
							|  |  |  |             $data = $this->slices[$slice]; | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Provide plugin version information. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * This data is used when showing the version page. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param array &$versions array of version data arrays; see EVENTS.txt | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return boolean hook value | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2019-08-12 15:03:30 +01:00
										 |  |  |     public function onPluginVersion(array &$versions): bool | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-01-22 16:38:42 +00:00
										 |  |  |         $url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/SlicedFavorites'; | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $versions[] = array('name' => 'SlicedFavorites', | 
					
						
							| 
									
										
										
										
											2019-06-03 01:56:52 +01:00
										 |  |  |             'version' => self::PLUGIN_VERSION, | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  |             'author' => 'Brion Vibber', | 
					
						
							|  |  |  |             'homepage' => $url, | 
					
						
							|  |  |  |             'rawdescription' => | 
					
						
							|  |  |  |             // TRANS: Plugin description.
 | 
					
						
							| 
									
										
										
										
											2010-10-01 22:21:12 +02:00
										 |  |  |             _m('Shows timelines of popular notices for defined subsets of users.')); | 
					
						
							| 
									
										
										
										
											2010-10-01 22:15:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-09-30 14:46:32 -07:00
										 |  |  | } |