gnu-social/plugins/GroupFavorited/GroupFavoritedPlugin.php

96 lines
3.1 KiB
PHP
Raw Normal View History

<?php
2019-08-10 20:21:09 +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/>.
/**
2019-08-10 20:21:09 +01:00
* The GroupFavorited plugin adds a menu item for popular notices in groups.
*
* @package GroupFavoritedPlugin
* @author Brion Vibber <brion@status.net>
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
2019-08-10 20:21:09 +01:00
defined('GNUSOCIAL') || die();
class GroupFavoritedPlugin extends Plugin
{
2019-08-10 20:21:09 +01:00
const PLUGIN_VERSION = '2.0.1';
/**
* Hook for RouterInitialized event.
*
* @param URLMapper $m path-to-action mapper
* @return boolean hook return
2019-08-10 20:21:09 +01:00
* @throws Exception
*/
2019-08-10 20:21:09 +01:00
public function onRouterInitialized(URLMapper $m)
{
2019-08-10 20:21:09 +01:00
$m->connect(
'group/:nickname/favorited',
['action' => 'groupfavorited'],
['nickname' => '[a-zA-Z0-9]+']
);
return true;
}
2019-08-10 20:21:09 +01:00
public function onEndGroupActionsList(GroupProfileBlock $nav, User_group $group)
{
2019-08-10 20:21:09 +01:00
$nav->out->elementStart('li', 'entity_popular');
$nav->out->element(
'a',
[
'href' => common_local_url(
'groupfavorited',
['nickname' => $group->nickname]
),
// TRANS: Tooltip for menu item in the group navigation page.
// TRANS: %s is the nickname of the group.
'title' => sprintf(_m('TOOLTIP', 'Popular notices in %s group'), $group->nickname)
],
// TRANS: Menu item in the group navigation page.
_m('MENU', 'Popular')
);
$nav->out->elementEnd('li');
}
2010-10-01 21:01:18 +01: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 bool hook value
2010-10-01 21:01:18 +01:00
*/
public function onPluginVersion(array &$versions): bool
2010-10-01 21:01:18 +01:00
{
$url = GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/GroupFavorited';
2010-10-01 21:01:18 +01:00
$versions[] = ['name' => 'GroupFavorited',
'version' => self::PLUGIN_VERSION,
2010-10-01 21:01:18 +01:00
'author' => 'Brion Vibber',
'homepage' => $url,
'rawdescription' =>
// TRANS: Plugin description.
_m('This plugin adds a menu item for popular notices in groups.')
];
2010-10-01 21:01:18 +01:00
return true;
}
}