[GroupFavorited] Fix plugin
This commit is contained in:
parent
0795a39459
commit
1459f10803
|
@ -229,12 +229,6 @@ StartPersonalGroupNav: beginning of personal group nav menu
|
||||||
EndPersonalGroupNav: end of personal group nav menu (good place to add a menu item)
|
EndPersonalGroupNav: end of personal group nav menu (good place to add a menu item)
|
||||||
- $action: action object being shown
|
- $action: action object being shown
|
||||||
|
|
||||||
StartGroupGroupNav: Showing the group nav menu
|
|
||||||
- $action: the current action
|
|
||||||
|
|
||||||
EndGroupGroupNav: At the end of the group nav menu
|
|
||||||
- $action: the current action
|
|
||||||
|
|
||||||
StartEndHTML: just before the </html> tag
|
StartEndHTML: just before the </html> tag
|
||||||
- $action: action object being shown
|
- $action: action object being shown
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ class NoticeList extends Widget
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*
|
*
|
||||||
* @param Notice $notice stream of notices from DB_DataObject
|
* @param mixed $notice stream of notices from DB_DataObject (may be a Notice but can also be something like an ArrayWrapper)
|
||||||
*/
|
*/
|
||||||
function __construct(Notice $notice, $out=null, array $prefs=array())
|
function __construct($notice, $out = null, array $prefs = [])
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
$this->notice = $notice;
|
$this->notice = $notice;
|
||||||
|
|
|
@ -101,7 +101,7 @@ class PeopletagNav extends Menu
|
||||||
sprintf(_m('TOOLTIP','Lists by %s.'), $nickname),
|
sprintf(_m('TOOLTIP','Lists by %s.'), $nickname),
|
||||||
$action_name == 'peopletagsbyuser',
|
$action_name == 'peopletagsbyuser',
|
||||||
'nav_lists_by');
|
'nav_lists_by');
|
||||||
Event::handle('EndGroupGroupNav', array($this));
|
Event::handle('EndPeopletagGroupNav', array($this));
|
||||||
}
|
}
|
||||||
$this->out->elementEnd('ul');
|
$this->out->elementEnd('ul');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +1,71 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
* StatusNet - the distributed open-source microblogging tool
|
//
|
||||||
* Copyright (C) 2010, StatusNet, Inc.
|
// 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
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
// (at your option) any later version.
|
||||||
* 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
|
||||||
* This program is distributed in the hope that it will be useful,
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// GNU Affero General Public License for more details.
|
||||||
* 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/>.
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The GroupFavorited plugin adds a menu item for popular notices in groups.
|
||||||
|
*
|
||||||
* @package GroupFavoritedPlugin
|
* @package GroupFavoritedPlugin
|
||||||
* @maintainer Brion Vibber <brion@status.net>
|
* @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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) { exit(1); }
|
defined('GNUSOCIAL') || die();
|
||||||
|
|
||||||
class GroupFavoritedPlugin extends Plugin
|
class GroupFavoritedPlugin extends Plugin
|
||||||
{
|
{
|
||||||
const PLUGIN_VERSION = '2.0.0';
|
const PLUGIN_VERSION = '2.0.1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook for RouterInitialized event.
|
* Hook for RouterInitialized event.
|
||||||
*
|
*
|
||||||
* @param URLMapper $m path-to-action mapper
|
* @param URLMapper $m path-to-action mapper
|
||||||
* @return boolean hook return
|
* @return boolean hook return
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function onRouterInitialized(URLMapper $m)
|
public function onRouterInitialized(URLMapper $m)
|
||||||
{
|
{
|
||||||
$m->connect('group/:nickname/favorited',
|
$m->connect(
|
||||||
|
'group/:nickname/favorited',
|
||||||
['action' => 'groupfavorited'],
|
['action' => 'groupfavorited'],
|
||||||
['nickname' => '[a-zA-Z0-9]+']);
|
['nickname' => '[a-zA-Z0-9]+']
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndGroupGroupNav(Menu $nav)
|
public function onEndGroupActionsList(GroupProfileBlock $nav, User_group $group)
|
||||||
{
|
{
|
||||||
$action_name = $nav->action->trimmed('action');
|
$nav->out->elementStart('li', 'entity_popular');
|
||||||
$nickname = $nav->group->nickname;
|
$nav->out->element(
|
||||||
$nav->out->menuItem(common_local_url('groupfavorited', array('nickname' =>
|
'a',
|
||||||
$nickname)),
|
[
|
||||||
// TRANS: Menu item in the group navigation page.
|
'href' => common_local_url(
|
||||||
_m('MENU', 'Popular'),
|
'groupfavorited',
|
||||||
|
['nickname' => $group->nickname]
|
||||||
|
),
|
||||||
// TRANS: Tooltip for menu item in the group navigation page.
|
// TRANS: Tooltip for menu item in the group navigation page.
|
||||||
// TRANS: %s is the nickname of the group.
|
// TRANS: %s is the nickname of the group.
|
||||||
sprintf(_m('TOOLTIP','Popular notices in %s group'), $nickname),
|
'title' => sprintf(_m('TOOLTIP', 'Popular notices in %s group'), $group->nickname)
|
||||||
$action_name == 'groupfavorited',
|
],
|
||||||
'nav_group_group');
|
// TRANS: Menu item in the group navigation page.
|
||||||
|
_m('MENU', 'Popular')
|
||||||
|
);
|
||||||
|
$nav->out->elementEnd('li');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,36 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
|
// 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/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
* The GroupFavorited plugin adds a menu item for popular notices in groups.
|
||||||
*
|
*
|
||||||
* List of popular notices
|
* @package GroupFavoritedPlugin
|
||||||
*
|
* @author Brion Vibber <brion@status.net>
|
||||||
* PHP version 5
|
* @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||||
*
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||||
* LICENCE: 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/>.
|
|
||||||
*
|
|
||||||
* @category Public
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Zach Copley <zach@status.net>
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @copyright 2008-2009 StatusNet, Inc.
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
defined('GNUSOCIAL') || die();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
class GroupFavoritedAction extends ShowgroupAction
|
class GroupFavoritedAction extends ShowgroupAction
|
||||||
{
|
{
|
||||||
|
@ -38,8 +31,9 @@ class GroupFavoritedAction extends ShowgroupAction
|
||||||
* Title of the page
|
* Title of the page
|
||||||
*
|
*
|
||||||
* @return string page title, with page number
|
* @return string page title, with page number
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function title()
|
public function title()
|
||||||
{
|
{
|
||||||
$base = $this->group->getFancyName();
|
$base = $this->group->getFancyName();
|
||||||
|
|
||||||
|
@ -48,9 +42,11 @@ class GroupFavoritedAction extends ShowgroupAction
|
||||||
return sprintf(_m('Popular posts in %s group'), $base);
|
return sprintf(_m('Popular posts in %s group'), $base);
|
||||||
} else {
|
} else {
|
||||||
// TRANS: %1$s is a group name, %2$s is a group number.
|
// TRANS: %1$s is a group name, %2$s is a group number.
|
||||||
return sprintf(_m('Popular posts in %1$s group, page %2$d'),
|
return sprintf(
|
||||||
|
_m('Popular posts in %1$s group, page %2$d'),
|
||||||
$base,
|
$base,
|
||||||
$this->page);
|
$this->page
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,12 +57,14 @@ class GroupFavoritedAction extends ShowgroupAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function showContent()
|
public function showContent()
|
||||||
{
|
{
|
||||||
$groupId = intval($this->group->id);
|
$groupId = (int)$this->group->id;
|
||||||
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
|
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
|
||||||
$cutoff = sprintf("fave.modified > '%s'",
|
$cutoff = sprintf(
|
||||||
common_sql_date(time() - common_config('popular', 'cutoff')));
|
"fave.modified > '%s'",
|
||||||
|
common_sql_date(time() - common_config('popular', 'cutoff'))
|
||||||
|
);
|
||||||
|
|
||||||
$qry = 'SELECT notice.*, ' .
|
$qry = 'SELECT notice.*, ' .
|
||||||
$weightexpr . ' as weight ' .
|
$weightexpr . ' as weight ' .
|
||||||
|
@ -86,20 +84,26 @@ class GroupFavoritedAction extends ShowgroupAction
|
||||||
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice = Memcached_DataObject::cachedQuery('Notice',
|
$notice = Memcached_DataObject::cachedQuery(
|
||||||
|
'Notice',
|
||||||
$qry,
|
$qry,
|
||||||
600);
|
600
|
||||||
|
);
|
||||||
|
|
||||||
$nl = new NoticeList($notice, $this);
|
$nl = new NoticeList($notice, $this);
|
||||||
|
|
||||||
$cnt = $nl->show();
|
$cnt = $nl->show();
|
||||||
|
|
||||||
if ($cnt == 0) {
|
/*if ($cnt == 0) {
|
||||||
//$this->showEmptyList();
|
$this->showEmptyList();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
|
$this->pagination(
|
||||||
$this->page, 'groupfavorited',
|
$this->page > 1,
|
||||||
array('nickname' => $this->group->nickname));
|
$cnt > NOTICES_PER_PAGE,
|
||||||
|
$this->page,
|
||||||
|
'groupfavorited',
|
||||||
|
array('nickname' => $this->group->nickname)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user