2010-10-01 06:46:32 +09: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-10-01 06:52:00 +09:00
|
|
|
* @package SlicedFavoritesPlugin
|
2010-10-01 06:46:32 +09:00
|
|
|
* @maintainer Brion Vibber <brion@status.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('STATUSNET')) { exit(1); }
|
|
|
|
|
|
|
|
class SlicedFavoritesPlugin extends Plugin
|
|
|
|
{
|
2019-06-03 09:56:52 +09:00
|
|
|
const PLUGIN_VERSION = '2.0.0';
|
|
|
|
|
2010-10-01 06:46:32 +09:00
|
|
|
/**
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* addPlugin('SlicedFavorites', array(
|
|
|
|
* 'slices' => array(
|
|
|
|
* // show only pop's notices on /favorited
|
|
|
|
* 'default' => array('include' => array('pop')),
|
2010-10-02 05:15:26 +09:00
|
|
|
*
|
2010-10-01 06:46:32 +09:00
|
|
|
* // show only son's notices on /favorited/blog
|
|
|
|
* 'blog' => array('include' => array('son')),
|
2010-10-02 05:15:26 +09:00
|
|
|
*
|
2010-10-01 06:46:32 +09:00
|
|
|
* // show all favorited notices except pop's and son's on /favorited/submitted
|
|
|
|
* 'submitted' => array('exclude' => array('pop', 'son')),
|
2010-10-02 05:15:26 +09:00
|
|
|
*
|
2010-10-01 06:46:32 +09:00
|
|
|
* // show all favorited notices on /favorited/everybody
|
|
|
|
* 'everybody' => array(),
|
|
|
|
* )
|
|
|
|
* ));
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $slices = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook for RouterInitialized event.
|
|
|
|
*
|
2014-11-07 23:24:05 +09:00
|
|
|
* @param URLMapper $m path-to-action mapper
|
2010-10-01 06:46:32 +09:00
|
|
|
* @return boolean hook return
|
|
|
|
*/
|
2014-11-07 23:24:05 +09:00
|
|
|
public function onRouterInitialized(URLMapper $m)
|
2010-10-01 06:46:32 +09:00
|
|
|
{
|
|
|
|
$m->connect('favorited/:slice',
|
|
|
|
array('action' => 'favoritedslice'),
|
|
|
|
array('slice' => '[a-zA-Z0-9]+'));
|
|
|
|
|
|
|
|
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-02 05:15:26 +09: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
|
|
|
|
*/
|
2015-06-07 05:04:01 +09:00
|
|
|
function onPluginVersion(array &$versions)
|
2010-10-02 05:15:26 +09:00
|
|
|
{
|
2016-01-23 01:38:42 +09:00
|
|
|
$url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/SlicedFavorites';
|
2010-10-02 05:15:26 +09:00
|
|
|
|
|
|
|
$versions[] = array('name' => 'SlicedFavorites',
|
2019-06-03 09:56:52 +09:00
|
|
|
'version' => self::PLUGIN_VERSION,
|
2010-10-02 05:15:26 +09:00
|
|
|
'author' => 'Brion Vibber',
|
|
|
|
'homepage' => $url,
|
|
|
|
'rawdescription' =>
|
|
|
|
// TRANS: Plugin description.
|
2010-10-02 05:21:12 +09:00
|
|
|
_m('Shows timelines of popular notices for defined subsets of users.'));
|
2010-10-02 05:15:26 +09:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-10-01 06:46:32 +09:00
|
|
|
}
|