2016-08-27 22:24:25 +09:00
|
|
|
<?php
|
2019-08-11 12:21:26 +09: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/>.
|
|
|
|
|
2016-08-27 22:24:25 +09:00
|
|
|
/**
|
|
|
|
* GNU social plugin for "tag clouds" in the UI
|
|
|
|
*
|
|
|
|
* @category UI
|
|
|
|
* @package GNUsocial
|
|
|
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
2019-08-11 12:21:26 +09:00
|
|
|
* @copyright 2016 Free Software Foundation, Inc http://www.fsf.org
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2016-08-27 22:24:25 +09:00
|
|
|
*/
|
|
|
|
|
2019-08-11 12:21:26 +09:00
|
|
|
defined('GNUSOCIAL') || die();
|
2016-08-27 22:24:25 +09:00
|
|
|
|
|
|
|
class TagCloudPlugin extends Plugin {
|
2019-06-03 09:56:52 +09:00
|
|
|
const PLUGIN_VERSION = '2.0.0';
|
2016-08-27 22:24:25 +09:00
|
|
|
|
|
|
|
public function onRouterInitialized(URLMapper $m)
|
|
|
|
{
|
2019-07-12 03:14:03 +09:00
|
|
|
$m->connect('tags/', ['action' => 'publictagcloud']);
|
|
|
|
$m->connect('tag/', ['action' => 'publictagcloud']);
|
|
|
|
$m->connect('tags', ['action' => 'publictagcloud']);
|
|
|
|
$m->connect('tag', ['action' => 'publictagcloud']);
|
2016-08-27 22:24:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public function onEndPublicGroupNav(Menu $menu)
|
|
|
|
{
|
|
|
|
// TRANS: Menu item in search group navigation panel.
|
|
|
|
$menu->out->menuItem(common_local_url('publictagcloud'), _m('MENU','Recent tags'),
|
2019-08-11 12:21:26 +09:00
|
|
|
// TRANS: Menu item title in search group navigation panel.
|
|
|
|
_('Recent tags'), $menu->actionName === 'publictagcloud', 'nav_recent-tags');
|
2016-08-27 22:24:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public function onEndShowSections(Action $action)
|
|
|
|
{
|
|
|
|
$cloud = null;
|
|
|
|
|
|
|
|
switch (true) {
|
2019-08-11 12:21:26 +09:00
|
|
|
case $action instanceof AllAction:
|
|
|
|
$cloud = new InboxTagCloudSection($action, $action->getTarget());
|
|
|
|
break;
|
|
|
|
case $action instanceof AttachmentAction:
|
|
|
|
$cloud = new AttachmentTagCloudSection($action);
|
|
|
|
break;
|
|
|
|
case $action instanceof PublicAction:
|
|
|
|
$cloud = new PublicTagCloudSection($action);
|
|
|
|
break;
|
|
|
|
case $action instanceof ShowstreamAction:
|
|
|
|
$cloud = new PersonalTagCloudSection($action, $action->getTarget());
|
|
|
|
break;
|
|
|
|
case $action instanceof GroupAction:
|
|
|
|
$cloud = new GroupTagCloudSection($action, $action->getGroup());
|
2016-08-27 22:24:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_null($cloud)) {
|
|
|
|
$cloud->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-12 23:03:30 +09:00
|
|
|
public function onPluginVersion(array &$versions): bool
|
2016-08-27 22:24:25 +09:00
|
|
|
{
|
2019-08-11 12:21:26 +09:00
|
|
|
$versions[] = [
|
|
|
|
'name' => 'TagCloud',
|
|
|
|
'version' => self::PLUGIN_VERSION,
|
|
|
|
'author' => 'Mikael Nordfeldth',
|
2019-11-21 09:21:22 +09:00
|
|
|
'homepage' => GNUSOCIAL_ENGINE_URL,
|
2019-08-11 12:21:26 +09:00
|
|
|
'description' =>
|
|
|
|
// TRANS: Module description.
|
|
|
|
_m('Adds tag clouds to stream pages')
|
|
|
|
];
|
2016-08-27 22:24:25 +09:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|