[FORMAT] Ran php-cs-fixer on the handlers of notice items and streams
This was to keep the following two commits readable - actions/showstream.php - actions/userbyid.php - lib/modules/ActivityHandlerModule.php - lib/modules/ActivityHandlerPlugin.php - lib/notices/conversationnoticestream.php - lib/notices/noticelistitem.php - lib/notices/noticestream.php - lib/notices/threadednoticelistitem.php
This commit is contained in:
parent
3951ccbef7
commit
684a1a4143
|
@ -1,34 +1,31 @@
|
|||
<?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
|
||||
*
|
||||
* User profile page
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 Personal
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Sarven Capadisli <csarven@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/
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* User profile page
|
||||
|
@ -58,7 +55,7 @@ class ShowstreamAction extends NoticestreamAction
|
|||
return $stream;
|
||||
}
|
||||
|
||||
function title()
|
||||
public function title()
|
||||
{
|
||||
$base = $this->target->getFancyName();
|
||||
if (!empty($this->tag)) {
|
||||
|
@ -77,9 +74,11 @@ class ShowstreamAction extends NoticestreamAction
|
|||
} else {
|
||||
// TRANS: Extended page title showing tagged notices in one user's timeline.
|
||||
// TRANS: %1$s is the username, %2$d is the page number.
|
||||
return sprintf(_('Notices by %1$s, page %2$d'),
|
||||
return sprintf(
|
||||
_('Notices by %1$s, page %2$d'),
|
||||
$base,
|
||||
$this->page);
|
||||
$this->page
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,79 +88,120 @@ class ShowstreamAction extends NoticestreamAction
|
|||
$this->showNotices();
|
||||
}
|
||||
|
||||
function showProfileBlock()
|
||||
public function showProfileBlock()
|
||||
{
|
||||
$block = new AccountProfileBlock($this, $this->target);
|
||||
$block->show();
|
||||
}
|
||||
|
||||
function showPageNoticeBlock()
|
||||
public function showPageNoticeBlock()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
function getFeeds()
|
||||
public function getFeeds()
|
||||
{
|
||||
if (!empty($this->tag)) {
|
||||
return array(new Feed(Feed::RSS1,
|
||||
common_local_url('userrss',
|
||||
array('nickname' => $this->target->getNickname(),
|
||||
'tag' => $this->tag)),
|
||||
return [new Feed(
|
||||
Feed::RSS1,
|
||||
common_local_url(
|
||||
'userrss',
|
||||
[
|
||||
'nickname' => $this->target->getNickname(),
|
||||
'tag' => $this->tag,
|
||||
]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %1$s is a user nickname, %2$s is a hashtag.
|
||||
sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
|
||||
$this->target->getNickname(), $this->tag)));
|
||||
sprintf(
|
||||
_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
|
||||
$this->target->getNickname(),
|
||||
$this->tag
|
||||
)
|
||||
)];
|
||||
}
|
||||
|
||||
if (!$this->target->isLocal()) {
|
||||
// remote profiles at least have Atom, but we can't guarantee anything else
|
||||
return array(
|
||||
new Feed(Feed::ATOM,
|
||||
return [new Feed(
|
||||
Feed::ATOM,
|
||||
$this->target->getAtomFeed(),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname()))
|
||||
);
|
||||
sprintf(
|
||||
_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
)];
|
||||
}
|
||||
|
||||
return array(new Feed(Feed::JSON,
|
||||
common_local_url('ApiTimelineUser',
|
||||
array(
|
||||
return [
|
||||
new Feed(
|
||||
Feed::JSON,
|
||||
common_local_url(
|
||||
'ApiTimelineUser',
|
||||
[
|
||||
'id' => $this->target->getID(),
|
||||
'format' => 'as')),
|
||||
'format' => 'as',
|
||||
]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (Activity Streams JSON)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::RSS1,
|
||||
common_local_url('userrss',
|
||||
array('nickname' => $this->target->getNickname())),
|
||||
sprintf(
|
||||
_('Notice feed for %s (Activity Streams JSON)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::RSS1,
|
||||
common_local_url(
|
||||
'userrss',
|
||||
['nickname' => $this->target->getNickname()]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (RSS 1.0)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::RSS2,
|
||||
common_local_url('ApiTimelineUser',
|
||||
array(
|
||||
sprintf(
|
||||
_('Notice feed for %s (RSS 1.0)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::RSS2,
|
||||
common_local_url(
|
||||
'ApiTimelineUser',
|
||||
[
|
||||
'id' => $this->target->getID(),
|
||||
'format' => 'rss')),
|
||||
'format' => 'rss',
|
||||
]
|
||||
),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (RSS 2.0)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::ATOM,
|
||||
sprintf(
|
||||
_('Notice feed for %s (RSS 2.0)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::ATOM,
|
||||
$this->target->getAtomFeed(),
|
||||
// TRANS: Title for link to notice feed.
|
||||
// TRANS: %s is a user nickname.
|
||||
sprintf(_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname())),
|
||||
new Feed(Feed::FOAF,
|
||||
common_local_url('foaf', array('nickname' =>
|
||||
$this->target->getNickname())),
|
||||
sprintf(
|
||||
_('Notice feed for %s (Atom)'),
|
||||
$this->target->getNickname()
|
||||
)
|
||||
),
|
||||
new Feed(
|
||||
Feed::FOAF,
|
||||
common_local_url(
|
||||
'foaf',
|
||||
['nickname' => $this->target->getNickname()]
|
||||
),
|
||||
// TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
|
||||
// TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
|
||||
sprintf(_('FOAF for %s'), $this->target->getNickname())));
|
||||
sprintf(_('FOAF for %s'), $this->target->getNickname())
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
public function extraHeaders()
|
||||
|
@ -175,28 +215,45 @@ class ShowstreamAction extends NoticestreamAction
|
|||
}
|
||||
}
|
||||
|
||||
function extraHead()
|
||||
public function extraHead()
|
||||
{
|
||||
if ($this->target->bio) {
|
||||
$this->element('meta', array('name' => 'description',
|
||||
'content' => $this->target->getDescription()));
|
||||
$this->element(
|
||||
'meta',
|
||||
[
|
||||
'name' => 'description',
|
||||
'content' => $this->target->getDescription(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$rsd = common_local_url('rsd',
|
||||
array('nickname' => $this->target->getNickname()));
|
||||
$rsd = common_local_url(
|
||||
'rsd',
|
||||
['nickname' => $this->target->getNickname()]
|
||||
);
|
||||
|
||||
// RSD, http://tales.phrasewise.com/rfc/rsd
|
||||
$this->element('link', array('rel' => 'EditURI',
|
||||
$this->element(
|
||||
'link',
|
||||
[
|
||||
'rel' => 'EditURI',
|
||||
'type' => 'application/rsd+xml',
|
||||
'href' => $rsd));
|
||||
'href' => $rsd,
|
||||
]
|
||||
);
|
||||
|
||||
if ($this->page != 1) {
|
||||
$this->element('link', array('rel' => 'canonical',
|
||||
'href' => $this->target->getUrl()));
|
||||
$this->element(
|
||||
'link',
|
||||
[
|
||||
'rel' => 'canonical',
|
||||
'href' => $this->target->getUrl(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function showEmptyListMessage()
|
||||
public function showEmptyListMessage()
|
||||
{
|
||||
// TRANS: First sentence of empty list message for a timeline. $1%s is a user nickname.
|
||||
$message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->target->getNickname()) . ' ';
|
||||
|
@ -210,8 +267,7 @@ class ShowstreamAction extends NoticestreamAction
|
|||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$message .= sprintf(_('You can try to nudge %1$s or [post something to them](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->target->getNickname(), '@' . $this->target->getNickname());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
|
||||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
|
||||
|
@ -222,7 +278,7 @@ class ShowstreamAction extends NoticestreamAction
|
|||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function showNotices()
|
||||
public function showNotices()
|
||||
{
|
||||
$pnl = new PrimaryNoticeList($this->notice, $this);
|
||||
$cnt = $pnl->show();
|
||||
|
@ -232,36 +288,46 @@ class ShowstreamAction extends NoticestreamAction
|
|||
|
||||
// either nickname or id will be used, depending on which action (showstream, userbyid...)
|
||||
$args = array('nickname' => $this->target->getNickname(), 'id' => $this->target->getID());
|
||||
if (!empty($this->tag))
|
||||
{
|
||||
if (!empty($this->tag)) {
|
||||
$args['tag'] = $this->tag;
|
||||
}
|
||||
$this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
|
||||
$this->getActionName(), $args);
|
||||
$this->pagination(
|
||||
$this->page > 1,
|
||||
$cnt > NOTICES_PER_PAGE,
|
||||
$this->page,
|
||||
$this->getActionName(),
|
||||
$args
|
||||
);
|
||||
}
|
||||
|
||||
function showAnonymousMessage()
|
||||
public function showAnonymousMessage()
|
||||
{
|
||||
if (!(common_config('site', 'closed') || common_config('site', 'inviteonly'))) {
|
||||
// TRANS: Announcement for anonymous users showing a timeline if site registrations are open.
|
||||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
$m = sprintf(
|
||||
_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool. ' .
|
||||
'[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
|
||||
$this->target->getNickname(), $this->target->getNickname());
|
||||
$this->target->getNickname(),
|
||||
$this->target->getNickname()
|
||||
);
|
||||
} else {
|
||||
// TRANS: Announcement for anonymous users showing a timeline if site registrations are closed or invite only.
|
||||
// TRANS: This message contains a Markdown link. Keep "](" together.
|
||||
$m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
$m = sprintf(
|
||||
_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
|
||||
'based on the Free Software [StatusNet](http://status.net/) tool.'),
|
||||
$this->target->getNickname(), $this->target->getNickname());
|
||||
$this->target->getNickname(),
|
||||
$this->target->getNickname()
|
||||
);
|
||||
}
|
||||
$this->elementStart('div', array('id' => 'anon_notice'));
|
||||
$this->raw(common_markup_to_html($m));
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
function noticeFormOptions()
|
||||
public function noticeFormOptions()
|
||||
{
|
||||
$options = parent::noticeFormOptions();
|
||||
|
||||
|
|
|
@ -1,44 +1,40 @@
|
|||
<?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/>.
|
||||
|
||||
/**
|
||||
* User by ID action class.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2008, 2009, 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/>.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* User by ID action class.
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Robin Millette <millette@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class UserbyidAction extends ShowstreamAction
|
||||
{
|
||||
|
@ -56,10 +52,12 @@ class UserbyidAction extends ShowstreamAction
|
|||
// ensure that only user-agents who specifically ask for RDF get it.
|
||||
$page_prefs = 'text/html,application/xhtml+xml,application/rdf+xml,application/xml;q=0.3,text/xml;q=0.2';
|
||||
$httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
|
||||
$type = common_negotiate_type(common_accept_to_prefs($httpaccept),
|
||||
common_accept_to_prefs($page_prefs));
|
||||
$page = $type === 'application/rdf+xml' ? 'foaf' : 'showstream';
|
||||
$url = common_local_url($page, array('nickname' => $this->target->getNickname()));
|
||||
$type = common_negotiate_type(
|
||||
common_accept_to_prefs($httpaccept),
|
||||
common_accept_to_prefs($page_prefs)
|
||||
);
|
||||
$page = ($type === 'application/rdf+xml') ? 'foaf' : 'showstream';
|
||||
$url = common_local_url($page, ['nickname' => $this->target->getNickname()]);
|
||||
common_redirect($url, 303);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
<?php
|
||||
/*
|
||||
* GNU Social - a federating social network
|
||||
* Copyright (C) 2014, Free Software Foundation, 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/>.
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Superclass for plugins which add Activity types and such
|
||||
|
@ -25,9 +29,8 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* @category Activity
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2014 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://gnu.io/social
|
||||
* @copyright 2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
abstract class ActivityHandlerModule extends Module
|
||||
{
|
||||
|
@ -38,7 +41,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @return string (compatible with HTML classes)
|
||||
*/
|
||||
abstract function tag();
|
||||
abstract public function tag();
|
||||
|
||||
/**
|
||||
* Return a list of ActivityStreams object type IRIs
|
||||
|
@ -51,7 +54,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @return array of strings
|
||||
*/
|
||||
abstract function types();
|
||||
abstract public function types();
|
||||
|
||||
/**
|
||||
* Return a list of ActivityStreams verb IRIs which
|
||||
|
@ -64,7 +67,8 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @return array of strings
|
||||
*/
|
||||
public function verbs() {
|
||||
public function verbs()
|
||||
{
|
||||
return array(ActivityVerb::POST);
|
||||
}
|
||||
|
||||
|
@ -80,7 +84,8 @@ abstract class ActivityHandlerModule extends Module
|
|||
* @param Activity $activity
|
||||
* @return boolean
|
||||
*/
|
||||
function isMyActivity(Activity $act) {
|
||||
public function isMyActivity(Activity $act)
|
||||
{
|
||||
return (count($act->objects) == 1
|
||||
&& ($act->objects[0] instanceof ActivityObject)
|
||||
&& $this->isMyVerb($act->verb)
|
||||
|
@ -98,16 +103,19 @@ abstract class ActivityHandlerModule extends Module
|
|||
* @param Notice $notice
|
||||
* @return boolean
|
||||
*/
|
||||
function isMyNotice(Notice $notice) {
|
||||
public function isMyNotice(Notice $notice)
|
||||
{
|
||||
return $this->isMyVerb($notice->verb) && $this->isMyType($notice->object_type);
|
||||
}
|
||||
|
||||
function isMyVerb($verb) {
|
||||
public function isMyVerb($verb)
|
||||
{
|
||||
$verb = $verb ?: ActivityVerb::POST; // post is the default verb
|
||||
return ActivityUtils::compareVerbs($verb, $this->verbs());
|
||||
}
|
||||
|
||||
function isMyType($type) {
|
||||
public function isMyType($type)
|
||||
{
|
||||
// Third argument to compareTypes is true, to allow for notices with empty object_type for example (verb-only)
|
||||
return count($this->types()) === 0 || ActivityUtils::compareTypes($type, $this->types());
|
||||
}
|
||||
|
@ -123,11 +131,11 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @param Activity $activity
|
||||
* @param Profile $actor
|
||||
* @param array $options=array()
|
||||
* @param array $options = []
|
||||
*
|
||||
* @return Notice the resulting notice
|
||||
*/
|
||||
public function saveNoticeFromActivity(Activity $activity, Profile $actor, array $options=array())
|
||||
public function saveNoticeFromActivity(Activity $activity, Profile $actor, array $options = [])
|
||||
{
|
||||
// Any plugin which has not implemented saveObjectFromActivity _must_
|
||||
// override this function until they are migrated (this function will
|
||||
|
@ -162,12 +170,12 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @param Activity $activity
|
||||
* @param Notice $stored The notice in our database for this certain object
|
||||
* @param array $options=array()
|
||||
* @param array $options = []
|
||||
*
|
||||
* @return object If the verb handling plugin creates an object, it can be returned here (otherwise true)
|
||||
* @throws exception On any error.
|
||||
*/
|
||||
protected function saveObjectFromActivity(Activity $activity, Notice $stored, array $options=array())
|
||||
protected function saveObjectFromActivity(Activity $activity, Notice $stored, array $options = [])
|
||||
{
|
||||
throw new ServerException('This function should be abstract when all plugins have migrated to saveObjectFromActivity');
|
||||
}
|
||||
|
@ -176,7 +184,8 @@ abstract class ActivityHandlerModule extends Module
|
|||
* This usually gets called from Notice::saveActivity after a Notice object has been created,
|
||||
* so it contains a proper id and a uri for the object to be saved.
|
||||
*/
|
||||
public function onStoreActivityObject(Activity $act, Notice $stored, array $options, &$object) {
|
||||
public function onStoreActivityObject(Activity $act, Notice $stored, array $options, &$object)
|
||||
{
|
||||
// $this->oldSaveNew is there during a migration period of plugins, to start using
|
||||
// Notice::saveActivity instead of Notice::saveNew
|
||||
if (!$this->isMyActivity($act) || isset($this->oldSaveNew)) {
|
||||
|
@ -208,7 +217,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @return ActivityObject
|
||||
*/
|
||||
abstract function activityObjectFromNotice(Notice $notice);
|
||||
abstract public function activityObjectFromNotice(Notice $notice);
|
||||
|
||||
/**
|
||||
* When a notice is deleted, you'll be called here for a chance
|
||||
|
@ -218,7 +227,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @param Notice $notice
|
||||
*/
|
||||
abstract function deleteRelated(Notice $notice);
|
||||
abstract public function deleteRelated(Notice $notice);
|
||||
|
||||
protected function notifyMentioned(Notice $stored, array &$mentioned_ids)
|
||||
{
|
||||
|
@ -242,7 +251,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
* @param ActivityObject $obj
|
||||
* @param XMLOutputter $out to add elements at end of object
|
||||
*/
|
||||
function activityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
public function activityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
{
|
||||
// default is a no-op
|
||||
}
|
||||
|
@ -313,7 +322,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @return boolean hook value
|
||||
*/
|
||||
function onStartActivityObjectFromNotice(Notice $notice, &$object)
|
||||
public function onStartActivityObjectFromNotice(Notice $notice, &$object)
|
||||
{
|
||||
if (!$this->isMyNotice($notice)) {
|
||||
return true;
|
||||
|
@ -331,7 +340,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @return boolean hook value
|
||||
*/
|
||||
function onStartHandleFeedEntryWithProfile(Activity $activity, Profile $profile, &$notice)
|
||||
public function onStartHandleFeedEntryWithProfile(Activity $activity, Profile $profile, &$notice)
|
||||
{
|
||||
if (!$this->isMyActivity($activity)) {
|
||||
return true;
|
||||
|
@ -342,11 +351,13 @@ abstract class ActivityHandlerModule extends Module
|
|||
|
||||
$object = $activity->objects[0];
|
||||
|
||||
$options = array('uri' => $object->id,
|
||||
$options = [
|
||||
'uri' => $object->id,
|
||||
'url' => $object->link,
|
||||
'self' => $object->selfLink,
|
||||
'is_local' => Notice::REMOTE,
|
||||
'source' => 'ostatus');
|
||||
'source' => 'ostatus',
|
||||
];
|
||||
|
||||
if (!isset($this->oldSaveNew)) {
|
||||
$notice = Notice::saveActivity($activity, $profile, $options);
|
||||
|
@ -366,7 +377,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
* @return boolean hook value
|
||||
*/
|
||||
|
||||
function onStartHandleSalmonTarget(Activity $activity, $target)
|
||||
public function onStartHandleSalmonTarget(Activity $activity, $target)
|
||||
{
|
||||
if (!$this->isMyActivity($activity)) {
|
||||
return true;
|
||||
|
@ -419,11 +430,13 @@ abstract class ActivityHandlerModule extends Module
|
|||
$object = $activity;
|
||||
}
|
||||
|
||||
$options = array('uri' => $object->id,
|
||||
$options = [
|
||||
'uri' => $object->id,
|
||||
'url' => $object->link,
|
||||
'self' => $object->selfLink,
|
||||
'is_local' => Notice::REMOTE,
|
||||
'source' => 'ostatus');
|
||||
'source' => 'ostatus',
|
||||
];
|
||||
|
||||
$notice = $this->saveNoticeFromActivity($activity, $actor, $options);
|
||||
|
||||
|
@ -463,7 +476,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
*
|
||||
* @return boolean hook value
|
||||
*/
|
||||
function onStartImportActivity($user, $author, Activity $activity, $trusted, &$done)
|
||||
public function onStartImportActivity($user, $author, Activity $activity, $trusted, &$done)
|
||||
{
|
||||
if (!$this->isMyActivity($activity)) {
|
||||
return true;
|
||||
|
@ -471,15 +484,19 @@ abstract class ActivityHandlerModule extends Module
|
|||
|
||||
$obj = $activity->objects[0];
|
||||
|
||||
$options = array('uri' => $object->id,
|
||||
$options = [
|
||||
'uri' => $object->id,
|
||||
'url' => $object->link,
|
||||
'self' => $object->selfLink,
|
||||
'source' => 'restore');
|
||||
'source' => 'restore',
|
||||
];
|
||||
|
||||
// $user->getProfile() is a Profile
|
||||
$saved = $this->saveNoticeFromActivity($activity,
|
||||
$saved = $this->saveNoticeFromActivity(
|
||||
$activity,
|
||||
$user->getProfile(),
|
||||
$options);
|
||||
$options
|
||||
);
|
||||
|
||||
if (!empty($saved)) {
|
||||
$done = true;
|
||||
|
@ -500,7 +517,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
* @param XMLOutputter $out to add elements at end of object
|
||||
* @return boolean hook return value
|
||||
*/
|
||||
function onEndActivityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
public function onEndActivityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
{
|
||||
if (in_array($obj->type, $this->types())) {
|
||||
$this->activityObjectOutputAtom($obj, $out);
|
||||
|
@ -520,7 +537,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
* @param array &$out JSON-targeted array which can be modified
|
||||
* @return boolean hook return value
|
||||
*/
|
||||
function onEndActivityObjectOutputJson(ActivityObject $obj, array &$out)
|
||||
public function onEndActivityObjectOutputJson(ActivityObject $obj, array &$out)
|
||||
{
|
||||
if (in_array($obj->type, $this->types())) {
|
||||
$this->activityObjectOutputJson($obj, $out);
|
||||
|
@ -536,7 +553,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
|
||||
$this->openNoticeListItemElement($nli);
|
||||
|
||||
Event::handle('EndOpenNoticeListItemElement', array($nli));
|
||||
Event::handle('EndOpenNoticeListItemElement', [$nli]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -548,7 +565,7 @@ abstract class ActivityHandlerModule extends Module
|
|||
|
||||
$this->closeNoticeListItemElement($nli);
|
||||
|
||||
Event::handle('EndCloseNoticeListItemElement', array($nli));
|
||||
Event::handle('EndCloseNoticeListItemElement', [$nli]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -564,8 +581,10 @@ abstract class ActivityHandlerModule extends Module
|
|||
} catch (Exception $e) {
|
||||
// either source or what we filtered out was a zero-length string
|
||||
}
|
||||
$nli->out->elementStart('li', array('class' => $class,
|
||||
'id' => 'notice-' . $id));
|
||||
$nli->out->elementStart(
|
||||
'li',
|
||||
['class' => $class, 'id' => 'notice-' . $id]
|
||||
);
|
||||
}
|
||||
|
||||
protected function closeNoticeListItemElement(NoticeListItem $nli)
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
<?php
|
||||
/*
|
||||
* GNU Social - a federating social network
|
||||
* Copyright (C) 2014, Free Software Foundation, 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/>.
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Superclass for plugins which add Activity types and such
|
||||
|
@ -25,9 +22,8 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* @category Activity
|
||||
* @package GNUsocial
|
||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||
* @copyright 2014 Free Software Foundation, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://gnu.io/social
|
||||
* @copyright 2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
abstract class ActivityHandlerPlugin extends Plugin
|
||||
{
|
||||
|
@ -38,7 +34,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @return string (compatible with HTML classes)
|
||||
*/
|
||||
abstract function tag();
|
||||
abstract public function tag();
|
||||
|
||||
/**
|
||||
* Return a list of ActivityStreams object type IRIs
|
||||
|
@ -51,7 +47,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @return array of strings
|
||||
*/
|
||||
abstract function types();
|
||||
abstract public function types();
|
||||
|
||||
/**
|
||||
* Return a list of ActivityStreams verb IRIs which
|
||||
|
@ -64,7 +60,8 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @return array of strings
|
||||
*/
|
||||
public function verbs() {
|
||||
public function verbs()
|
||||
{
|
||||
return array(ActivityVerb::POST);
|
||||
}
|
||||
|
||||
|
@ -80,7 +77,8 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
* @param Activity $activity
|
||||
* @return boolean
|
||||
*/
|
||||
function isMyActivity(Activity $act) {
|
||||
public function isMyActivity(Activity $act)
|
||||
{
|
||||
return (count($act->objects) == 1
|
||||
&& ($act->objects[0] instanceof ActivityObject)
|
||||
&& $this->isMyVerb($act->verb)
|
||||
|
@ -98,16 +96,19 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
* @param Notice $notice
|
||||
* @return boolean
|
||||
*/
|
||||
function isMyNotice(Notice $notice) {
|
||||
public function isMyNotice(Notice $notice)
|
||||
{
|
||||
return $this->isMyVerb($notice->verb) && $this->isMyType($notice->object_type);
|
||||
}
|
||||
|
||||
function isMyVerb($verb) {
|
||||
public function isMyVerb($verb)
|
||||
{
|
||||
$verb = $verb ?: ActivityVerb::POST; // post is the default verb
|
||||
return ActivityUtils::compareVerbs($verb, $this->verbs());
|
||||
}
|
||||
|
||||
function isMyType($type) {
|
||||
public function isMyType($type)
|
||||
{
|
||||
// Third argument to compareTypes is true, to allow for notices with empty object_type for example (verb-only)
|
||||
return count($this->types()) === 0 || ActivityUtils::compareTypes($type, $this->types());
|
||||
}
|
||||
|
@ -176,7 +177,8 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
* This usually gets called from Notice::saveActivity after a Notice object has been created,
|
||||
* so it contains a proper id and a uri for the object to be saved.
|
||||
*/
|
||||
public function onStoreActivityObject(Activity $act, Notice $stored, array $options, &$object) {
|
||||
public function onStoreActivityObject(Activity $act, Notice $stored, array $options, &$object)
|
||||
{
|
||||
// $this->oldSaveNew is there during a migration period of plugins, to start using
|
||||
// Notice::saveActivity instead of Notice::saveNew
|
||||
if (!$this->isMyActivity($act) || isset($this->oldSaveNew)) {
|
||||
|
@ -208,7 +210,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @return ActivityObject
|
||||
*/
|
||||
abstract function activityObjectFromNotice(Notice $notice);
|
||||
abstract public function activityObjectFromNotice(Notice $notice);
|
||||
|
||||
/**
|
||||
* When a notice is deleted, you'll be called here for a chance
|
||||
|
@ -218,7 +220,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @param Notice $notice
|
||||
*/
|
||||
abstract function deleteRelated(Notice $notice);
|
||||
abstract public function deleteRelated(Notice $notice);
|
||||
|
||||
protected function notifyMentioned(Notice $stored, array &$mentioned_ids)
|
||||
{
|
||||
|
@ -242,7 +244,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
* @param ActivityObject $obj
|
||||
* @param XMLOutputter $out to add elements at end of object
|
||||
*/
|
||||
function activityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
public function activityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
{
|
||||
// default is a no-op
|
||||
}
|
||||
|
@ -313,7 +315,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @return boolean hook value
|
||||
*/
|
||||
function onStartActivityObjectFromNotice(Notice $notice, &$object)
|
||||
public function onStartActivityObjectFromNotice(Notice $notice, &$object)
|
||||
{
|
||||
if (!$this->isMyNotice($notice)) {
|
||||
return true;
|
||||
|
@ -331,7 +333,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @return boolean hook value
|
||||
*/
|
||||
function onStartHandleFeedEntryWithProfile(Activity $activity, Profile $profile, &$notice)
|
||||
public function onStartHandleFeedEntryWithProfile(Activity $activity, Profile $profile, &$notice)
|
||||
{
|
||||
if (!$this->isMyActivity($activity)) {
|
||||
return true;
|
||||
|
@ -342,11 +344,13 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
|
||||
$object = $activity->objects[0];
|
||||
|
||||
$options = array('uri' => $object->id,
|
||||
$options = [
|
||||
'uri' => $object->id,
|
||||
'url' => $object->link,
|
||||
'self' => $object->selfLink,
|
||||
'is_local' => Notice::REMOTE,
|
||||
'source' => 'ostatus');
|
||||
'source' => 'ostatus',
|
||||
];
|
||||
|
||||
if (!isset($this->oldSaveNew)) {
|
||||
$notice = Notice::saveActivity($activity, $profile, $options);
|
||||
|
@ -366,7 +370,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
* @return boolean hook value
|
||||
*/
|
||||
|
||||
function onStartHandleSalmonTarget(Activity $activity, $target)
|
||||
public function onStartHandleSalmonTarget(Activity $activity, $target)
|
||||
{
|
||||
if (!$this->isMyActivity($activity)) {
|
||||
return true;
|
||||
|
@ -419,11 +423,13 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
$object = $activity;
|
||||
}
|
||||
|
||||
$options = array('uri' => $object->id,
|
||||
$options = [
|
||||
'uri' => $object->id,
|
||||
'url' => $object->link,
|
||||
'self' => $object->selfLink,
|
||||
'is_local' => Notice::REMOTE,
|
||||
'source' => 'ostatus');
|
||||
'source' => 'ostatus',
|
||||
];
|
||||
|
||||
$notice = $this->saveNoticeFromActivity($activity, $actor, $options);
|
||||
|
||||
|
@ -463,7 +469,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
*
|
||||
* @return boolean hook value
|
||||
*/
|
||||
function onStartImportActivity($user, $author, Activity $activity, $trusted, &$done)
|
||||
public function onStartImportActivity($user, $author, Activity $activity, $trusted, &$done)
|
||||
{
|
||||
if (!$this->isMyActivity($activity)) {
|
||||
return true;
|
||||
|
@ -471,15 +477,19 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
|
||||
$obj = $activity->objects[0];
|
||||
|
||||
$options = array('uri' => $object->id,
|
||||
$options = [
|
||||
'uri' => $object->id,
|
||||
'url' => $object->link,
|
||||
'self' => $object->selfLink,
|
||||
'source' => 'restore');
|
||||
'source' => 'restore',
|
||||
];
|
||||
|
||||
// $user->getProfile() is a Profile
|
||||
$saved = $this->saveNoticeFromActivity($activity,
|
||||
$saved = $this->saveNoticeFromActivity(
|
||||
$activity,
|
||||
$user->getProfile(),
|
||||
$options);
|
||||
$options
|
||||
);
|
||||
|
||||
if (!empty($saved)) {
|
||||
$done = true;
|
||||
|
@ -500,7 +510,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
* @param XMLOutputter $out to add elements at end of object
|
||||
* @return boolean hook return value
|
||||
*/
|
||||
function onEndActivityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
public function onEndActivityObjectOutputAtom(ActivityObject $obj, XMLOutputter $out)
|
||||
{
|
||||
if (in_array($obj->type, $this->types())) {
|
||||
$this->activityObjectOutputAtom($obj, $out);
|
||||
|
@ -520,7 +530,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
* @param array &$out JSON-targeted array which can be modified
|
||||
* @return boolean hook return value
|
||||
*/
|
||||
function onEndActivityObjectOutputJson(ActivityObject $obj, array &$out)
|
||||
public function onEndActivityObjectOutputJson(ActivityObject $obj, array &$out)
|
||||
{
|
||||
if (in_array($obj->type, $this->types())) {
|
||||
$this->activityObjectOutputJson($obj, $out);
|
||||
|
@ -536,7 +546,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
|
||||
$this->openNoticeListItemElement($nli);
|
||||
|
||||
Event::handle('EndOpenNoticeListItemElement', array($nli));
|
||||
Event::handle('EndOpenNoticeListItemElement', [$nli]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -548,7 +558,7 @@ abstract class ActivityHandlerPlugin extends Plugin
|
|||
|
||||
$this->closeNoticeListItemElement($nli);
|
||||
|
||||
Event::handle('EndCloseNoticeListItemElement', array($nli));
|
||||
Event::handle('EndCloseNoticeListItemElement', [$nli]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,51 +1,48 @@
|
|||
<?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
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* Notice stream for a conversation
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 NoticeStream
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Notice stream for a conversation
|
||||
*
|
||||
* @category Stream
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class ConversationNoticeStream extends ScopingNoticeStream
|
||||
{
|
||||
function __construct($id, Profile $scoped=null)
|
||||
public function __construct($id, Profile $scoped = null)
|
||||
{
|
||||
parent::__construct(new RawConversationNoticeStream($id),
|
||||
$scoped);
|
||||
parent::__construct(
|
||||
new RawConversationNoticeStream($id),
|
||||
$scoped
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,23 +50,22 @@ class ConversationNoticeStream extends ScopingNoticeStream
|
|||
* Notice stream for a conversation
|
||||
*
|
||||
* @category Stream
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class RawConversationNoticeStream extends NoticeStream
|
||||
{
|
||||
protected $id;
|
||||
|
||||
function __construct($id)
|
||||
public function __construct($id)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
function getNoticeIds($offset, $limit, $since_id=null, $max_id=null)
|
||||
public function getNoticeIds($offset, $limit, $since_id = null, $max_id = null)
|
||||
{
|
||||
$notice = new Notice();
|
||||
// SELECT
|
||||
|
|
|
@ -1,34 +1,30 @@
|
|||
<?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
|
||||
* Copyright (C) 2010, StatusNet, Inc.
|
||||
*
|
||||
* An item in a notice list
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 Widget
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* widget for displaying a single notice
|
||||
|
@ -40,23 +36,22 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* author info (since that's implicit by the data in the page).
|
||||
*
|
||||
* @category UI
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @see NoticeList
|
||||
* @see ProfileNoticeListItem
|
||||
*/
|
||||
class NoticeListItem extends Widget
|
||||
{
|
||||
/** The notice this item will show. */
|
||||
var $notice = null;
|
||||
public $notice = null;
|
||||
|
||||
/** The notice that was repeated. */
|
||||
var $repeat = null;
|
||||
public $repeat = null;
|
||||
|
||||
/** The profile of the author of the notice, extracted once for convenience. */
|
||||
var $profile = null;
|
||||
public $profile = null;
|
||||
|
||||
protected $addressees = true;
|
||||
protected $attachments = true;
|
||||
|
@ -72,8 +67,10 @@ class NoticeListItem extends Widget
|
|||
* Also initializes the profile attribute.
|
||||
*
|
||||
* @param Notice $notice The notice we'll display
|
||||
* @param Action|null $out
|
||||
* @param array $prefs
|
||||
*/
|
||||
function __construct(Notice $notice, Action $out=null, array $prefs=array())
|
||||
public function __construct(Notice $notice, Action $out = null, array $prefs = [])
|
||||
{
|
||||
parent::__construct($out);
|
||||
if (!empty($notice->repeat_of)) {
|
||||
|
@ -91,19 +88,19 @@ class NoticeListItem extends Widget
|
|||
$this->profile = $this->notice->getProfile();
|
||||
|
||||
// integer preferences
|
||||
foreach(array('maxchars') as $key) {
|
||||
foreach (['maxchars'] as $key) {
|
||||
if (array_key_exists($key, $prefs)) {
|
||||
$this->$key = (int)$prefs[$key];
|
||||
}
|
||||
}
|
||||
// boolean preferences
|
||||
foreach(array('addressees', 'attachments', 'options') as $key) {
|
||||
foreach (['addressees', 'attachments', 'options'] as $key) {
|
||||
if (array_key_exists($key, $prefs)) {
|
||||
$this->$key = (bool)$prefs[$key];
|
||||
}
|
||||
}
|
||||
// string preferences
|
||||
foreach(array('id_prefix', 'item_tag') as $key) {
|
||||
foreach (['id_prefix', 'item_tag'] as $key) {
|
||||
if (array_key_exists($key, $prefs)) {
|
||||
$this->$key = $prefs[$key];
|
||||
}
|
||||
|
@ -118,7 +115,7 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function show()
|
||||
public function show()
|
||||
{
|
||||
if (empty($this->notice)) {
|
||||
common_log(LOG_WARNING, "Trying to show missing notice; skipping.");
|
||||
|
@ -136,7 +133,7 @@ class NoticeListItem extends Widget
|
|||
$this->showEnd();
|
||||
}
|
||||
|
||||
function showNotice()
|
||||
public function showNotice()
|
||||
{
|
||||
if (Event::handle('StartShowNoticeItemNotice', array($this))) {
|
||||
$this->showNoticeHeaders();
|
||||
|
@ -146,9 +143,9 @@ class NoticeListItem extends Widget
|
|||
}
|
||||
}
|
||||
|
||||
function showNoticeHeaders()
|
||||
public function showNoticeHeaders()
|
||||
{
|
||||
$this->elementStart('section', array('class'=>'notice-headers'));
|
||||
$this->elementStart('section', ['class' => 'notice-headers']);
|
||||
$this->showNoticeTitle();
|
||||
$this->showAuthor();
|
||||
|
||||
|
@ -161,33 +158,44 @@ class NoticeListItem extends Widget
|
|||
} catch (InvalidUrlException $e) {
|
||||
// parent had an invalid URL so we can't show it
|
||||
}
|
||||
if ($this->addressees) { $this->showAddressees(); }
|
||||
if ($this->addressees) {
|
||||
$this->showAddressees();
|
||||
}
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
$this->elementEnd('section');
|
||||
}
|
||||
|
||||
function showNoticeFooter()
|
||||
public function showNoticeFooter()
|
||||
{
|
||||
$this->elementStart('footer');
|
||||
$this->showNoticeInfo();
|
||||
if ($this->options) { $this->showNoticeOptions(); }
|
||||
if ($this->attachments) { $this->showNoticeAttachments(); }
|
||||
if ($this->options) {
|
||||
$this->showNoticeOptions();
|
||||
}
|
||||
if ($this->attachments) {
|
||||
$this->showNoticeAttachments();
|
||||
}
|
||||
$this->elementEnd('footer');
|
||||
}
|
||||
|
||||
function showNoticeTitle()
|
||||
public function showNoticeTitle()
|
||||
{
|
||||
if (Event::handle('StartShowNoticeTitle', array($this))) {
|
||||
$nameClass = $this->notice->getTitle(false) ? 'p-name ' : '';
|
||||
$this->element('a', array('href' => $this->notice->getUri(),
|
||||
'class' => $nameClass . 'u-uid'),
|
||||
$this->notice->getTitle());
|
||||
$this->element(
|
||||
'a',
|
||||
[
|
||||
'href' => $this->notice->getUri(),
|
||||
'class' => $nameClass . 'u-uid',
|
||||
],
|
||||
$this->notice->getTitle()
|
||||
);
|
||||
Event::handle('EndShowNoticeTitle', array($this));
|
||||
}
|
||||
}
|
||||
|
||||
function showNoticeInfo()
|
||||
public function showNoticeInfo()
|
||||
{
|
||||
if (Event::handle('StartShowNoticeInfo', array($this))) {
|
||||
$this->showContextLink();
|
||||
|
@ -199,7 +207,7 @@ class NoticeListItem extends Widget
|
|||
}
|
||||
}
|
||||
|
||||
function showNoticeOptions()
|
||||
public function showNoticeOptions()
|
||||
{
|
||||
if (Event::handle('StartShowNoticeOptions', array($this))) {
|
||||
$user = common_current_user();
|
||||
|
@ -221,9 +229,9 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showStart()
|
||||
public function showStart()
|
||||
{
|
||||
if (Event::handle('StartOpenNoticeListItemElement', array($this))) {
|
||||
if (Event::handle('StartOpenNoticeListItemElement', [$this])) {
|
||||
$id = (empty($this->repeat)) ? $this->notice->id : $this->repeat->id;
|
||||
$class = 'h-entry notice';
|
||||
if ($this->notice->scope != 0 && $this->notice->scope != 1) {
|
||||
|
@ -235,9 +243,14 @@ class NoticeListItem extends Widget
|
|||
// either source or what we filtered out was a zero-length string
|
||||
}
|
||||
$id_prefix = (strlen($this->id_prefix) ? $this->id_prefix . '-' : '');
|
||||
$this->out->elementStart($this->item_tag, array('class' => $class,
|
||||
'id' => "${id_prefix}notice-${id}"));
|
||||
Event::handle('EndOpenNoticeListItemElement', array($this));
|
||||
$this->out->elementStart(
|
||||
$this->item_tag,
|
||||
[
|
||||
'class' => $class,
|
||||
'id' => "${id_prefix}notice-${id}",
|
||||
]
|
||||
);
|
||||
Event::handle('EndOpenNoticeListItemElement', [$this]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,12 +262,16 @@ class NoticeListItem extends Widget
|
|||
* @return void
|
||||
*/
|
||||
|
||||
function showAuthor()
|
||||
public function showAuthor()
|
||||
{
|
||||
$attrs = array('href' => $this->profile->getUrl(),
|
||||
$attrs = [
|
||||
'href' => $this->profile->getUrl(),
|
||||
'class' => 'h-card',
|
||||
'title' => $this->profile->getHtmlTitle());
|
||||
if(empty($this->repeat)) { $attrs['class'] .= ' p-author'; }
|
||||
'title' => $this->profile->getHtmlTitle(),
|
||||
];
|
||||
if (empty($this->repeat)) {
|
||||
$attrs['class'] .= ' p-author';
|
||||
}
|
||||
|
||||
if (Event::handle('StartShowNoticeItemAuthor', array($this->profile, $this->out, &$attrs))) {
|
||||
$this->out->elementStart('a', $attrs);
|
||||
|
@ -265,7 +282,7 @@ class NoticeListItem extends Widget
|
|||
}
|
||||
}
|
||||
|
||||
function showParent()
|
||||
public function showParent()
|
||||
{
|
||||
$this->out->element(
|
||||
'a',
|
||||
|
@ -278,7 +295,7 @@ class NoticeListItem extends Widget
|
|||
);
|
||||
}
|
||||
|
||||
function showAddressees()
|
||||
public function showAddressees()
|
||||
{
|
||||
$pa = $this->getProfileAddressees();
|
||||
|
||||
|
@ -296,9 +313,11 @@ class NoticeListItem extends Widget
|
|||
}
|
||||
}
|
||||
|
||||
function getProfileAddressees()
|
||||
public function getProfileAddressees()
|
||||
{
|
||||
if($this->pa) { return $this->pa; }
|
||||
if ($this->pa) {
|
||||
return $this->pa;
|
||||
}
|
||||
$this->pa = array();
|
||||
|
||||
$attentions = $this->getAttentionProfiles();
|
||||
|
@ -311,16 +330,18 @@ class NoticeListItem extends Widget
|
|||
$class = 'account';
|
||||
$profileurl = common_local_url('userbyid', array('id' => $attn->getID()));
|
||||
}
|
||||
$this->pa[] = array('href' => $profileurl,
|
||||
$this->pa[] = [
|
||||
'href' => $profileurl,
|
||||
'title' => $attn->getHtmlTitle(),
|
||||
'class' => "addressee {$class} p-name u-url",
|
||||
'text' => $attn->getStreamName());
|
||||
'text' => $attn->getStreamName(),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->pa;
|
||||
}
|
||||
|
||||
function getAttentionProfiles()
|
||||
public function getAttentionProfiles()
|
||||
{
|
||||
return $this->notice->getAttentionProfiles();
|
||||
}
|
||||
|
@ -332,11 +353,13 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showNickname()
|
||||
public function showNickname()
|
||||
{
|
||||
$this->out->raw('<span class="p-name">' .
|
||||
$this->out->raw(
|
||||
'<span class="p-name">' .
|
||||
htmlspecialchars($this->profile->getNickname()) .
|
||||
'</span>');
|
||||
'</span>'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -348,7 +371,7 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
public function showContent()
|
||||
{
|
||||
// FIXME: URL, image, video, audio
|
||||
$nameClass = $this->notice->getTitle(false) ? '' : 'p-name ';
|
||||
|
@ -364,7 +387,8 @@ class NoticeListItem extends Widget
|
|||
$this->out->elementEnd('article');
|
||||
}
|
||||
|
||||
function showNoticeAttachments() {
|
||||
public function showNoticeAttachments()
|
||||
{
|
||||
if (common_config('attachments', 'show_thumbs')) {
|
||||
$al = new InlineAttachmentList($this->notice, $this->out);
|
||||
$al->show();
|
||||
|
@ -378,12 +402,17 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showNoticeLink()
|
||||
public function showNoticeLink()
|
||||
{
|
||||
$this->out->element('time', array('class' => 'dt-published',
|
||||
$this->out->element(
|
||||
'time',
|
||||
[
|
||||
'class' => 'dt-published',
|
||||
'datetime' => common_date_iso8601($this->notice->created),
|
||||
'title' => common_exact_date($this->notice->created)),
|
||||
common_date_string($this->notice->created));
|
||||
'title' => common_exact_date($this->notice->created),
|
||||
],
|
||||
common_date_string($this->notice->created)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,7 +424,7 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showNoticeLocation()
|
||||
public function showNoticeLocation()
|
||||
{
|
||||
try {
|
||||
$location = Notice_location::locFromStored($this->notice);
|
||||
|
@ -429,8 +458,15 @@ class NoticeListItem extends Widget
|
|||
// TRANS: %5$s is longitude degrees, %6$s is longitude minutes,
|
||||
// TRANS: %7$s is longitude seconds, %8$s is E (east) or W (west) depending on longitude,
|
||||
_('%1$u°%2$u\'%3$u"%4$s %5$u°%6$u\'%7$u"%8$s'),
|
||||
$latdms['deg'],$latdms['min'], $latdms['sec'],($lat>0? $north:$south),
|
||||
$londms['deg'],$londms['min'], $londms['sec'],($lon>0? $east:$west));
|
||||
$latdms['deg'],
|
||||
$latdms['min'],
|
||||
$latdms['sec'],
|
||||
($lat > 0 ? $north : $south),
|
||||
$londms['deg'],
|
||||
$londms['min'],
|
||||
$londms['sec'],
|
||||
($lon > 0 ? $east : $west)
|
||||
);
|
||||
}
|
||||
|
||||
$url = $location->getUrl();
|
||||
|
@ -441,16 +477,25 @@ class NoticeListItem extends Widget
|
|||
$this->out->text(_('at'));
|
||||
$this->out->text(' ');
|
||||
if (empty($url)) {
|
||||
$this->out->element('abbr', array('class' => 'geo',
|
||||
'title' => $latlon),
|
||||
$name);
|
||||
$this->out->element(
|
||||
'abbr',
|
||||
[
|
||||
'class' => 'geo',
|
||||
'title' => $latlon,
|
||||
],
|
||||
$name
|
||||
);
|
||||
} else {
|
||||
$xstr = new XMLStringer(false);
|
||||
$xstr->elementStart('a', array('href' => $url,
|
||||
'rel' => 'external'));
|
||||
$xstr->element('abbr', array('class' => 'geo',
|
||||
'title' => $latlon),
|
||||
$name);
|
||||
$xstr->elementStart(
|
||||
'a',
|
||||
['href' => $url, 'rel' => 'external']
|
||||
);
|
||||
$xstr->element(
|
||||
'abbr',
|
||||
['class' => 'geo', 'title' => $latlon],
|
||||
$name
|
||||
);
|
||||
$xstr->elementEnd('a');
|
||||
$this->out->raw($xstr->getString());
|
||||
}
|
||||
|
@ -461,7 +506,7 @@ class NoticeListItem extends Widget
|
|||
* @param number $dec decimal degrees
|
||||
* @return array split into 'deg', 'min', and 'sec'
|
||||
*/
|
||||
function decimalDegreesToDMS($dec)
|
||||
public function decimalDegreesToDMS($dec)
|
||||
{
|
||||
$deg = intval($dec);
|
||||
$tempma = abs($dec) - abs($deg);
|
||||
|
@ -470,7 +515,7 @@ class NoticeListItem extends Widget
|
|||
$min = floor($tempma / 60);
|
||||
$sec = $tempma - ($min * 60);
|
||||
|
||||
return array("deg"=>$deg,"min"=>$min,"sec"=>$sec);
|
||||
return ['deg' => $deg, 'min' => $min, 'sec' => $sec];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -480,13 +525,14 @@ class NoticeListItem extends Widget
|
|||
* or one of other other channels.
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
function showNoticeSource()
|
||||
public function showNoticeSource()
|
||||
{
|
||||
$ns = $this->notice->getSource();
|
||||
|
||||
if (!$ns instanceof Notice_source) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// TRANS: A possible notice source (web interface).
|
||||
|
@ -538,7 +584,7 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showPermalink()
|
||||
public function showPermalink()
|
||||
{
|
||||
$class = 'permalink u-url';
|
||||
if (!$this->notice->isLocal()) {
|
||||
|
@ -547,10 +593,14 @@ class NoticeListItem extends Widget
|
|||
|
||||
try {
|
||||
if ($this->repeat) {
|
||||
$this->out->element('a',
|
||||
array('href' => $this->repeat->getUrl(),
|
||||
'class' => 'u-url'),
|
||||
'');
|
||||
$this->out->element(
|
||||
'a',
|
||||
[
|
||||
'href' => $this->repeat->getUrl(),
|
||||
'class' => 'u-url',
|
||||
],
|
||||
''
|
||||
);
|
||||
$class = str_replace('u-url', 'u-repost-of', $class);
|
||||
}
|
||||
} catch (InvalidUrlException $e) {
|
||||
|
@ -558,11 +608,15 @@ class NoticeListItem extends Widget
|
|||
}
|
||||
|
||||
try {
|
||||
$this->out->element('a',
|
||||
array('href' => $this->notice->getUrl(true),
|
||||
'class' => $class),
|
||||
$this->out->element(
|
||||
'a',
|
||||
[
|
||||
'href' => $this->notice->getUrl(true),
|
||||
'class' => $class,
|
||||
],
|
||||
// TRANS: Addition in notice list item for single-notice view.
|
||||
_('permalink'));
|
||||
_('permalink')
|
||||
);
|
||||
} catch (InvalidUrlException $e) {
|
||||
// no permalink available
|
||||
}
|
||||
|
@ -571,13 +625,18 @@ class NoticeListItem extends Widget
|
|||
/**
|
||||
* Show link to conversation view.
|
||||
*/
|
||||
function showContextLink()
|
||||
public function showContextLink()
|
||||
{
|
||||
$this->out->element('a', array('rel' => 'bookmark',
|
||||
$this->out->element(
|
||||
'a',
|
||||
[
|
||||
'rel' => 'bookmark',
|
||||
'class' => 'timestamp',
|
||||
'href' => Conversation::getUrlFromNotice($this->notice)),
|
||||
'href' => Conversation::getUrlFromNotice($this->notice),
|
||||
],
|
||||
// TRANS: A link to the conversation view of a notice, on the local server.
|
||||
_('In conversation'));
|
||||
_('In conversation')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -588,16 +647,26 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showReplyLink()
|
||||
public function showReplyLink()
|
||||
{
|
||||
if (common_logged_in()) {
|
||||
$this->out->text(' ');
|
||||
$reply_url = common_local_url('newnotice',
|
||||
array('replyto' => $this->profile->getNickname(), 'inreplyto' => $this->notice->id));
|
||||
$this->out->elementStart('a', array('href' => $reply_url,
|
||||
$reply_url = common_local_url(
|
||||
'newnotice',
|
||||
[
|
||||
'replyto' => $this->profile->getNickname(),
|
||||
'inreplyto' => $this->notice->id,
|
||||
]
|
||||
);
|
||||
$this->out->elementStart(
|
||||
'a',
|
||||
[
|
||||
'href' => $reply_url,
|
||||
'class' => 'notice_reply',
|
||||
// TRANS: Link title in notice list item to reply to a notice.
|
||||
'title' => _('Reply to this notice.')));
|
||||
'title' => _('Reply to this notice.'),
|
||||
]
|
||||
);
|
||||
// TRANS: Link text in notice list item to reply to a notice.
|
||||
$this->out->text(_('Reply'));
|
||||
$this->out->text(' ');
|
||||
|
@ -610,8 +679,9 @@ class NoticeListItem extends Widget
|
|||
* if the user is the author, let them delete the notice
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
function showDeleteLink()
|
||||
public function showDeleteLink()
|
||||
{
|
||||
$user = common_current_user();
|
||||
|
||||
|
@ -621,14 +691,21 @@ class NoticeListItem extends Widget
|
|||
!$this->notice->isVerb([ActivityVerb::DELETE]) &&
|
||||
($todel->profile_id == $user->id || $user->hasRight(Right::DELETEOTHERSNOTICE))) {
|
||||
$this->out->text(' ');
|
||||
$deleteurl = common_local_url('deletenotice',
|
||||
array('notice' => $todel->id));
|
||||
$this->out->element('a', array('href' => $deleteurl,
|
||||
$deleteurl = common_local_url(
|
||||
'deletenotice',
|
||||
['notice' => $todel->id]
|
||||
);
|
||||
$this->out->element(
|
||||
'a',
|
||||
[
|
||||
'href' => $deleteurl,
|
||||
'class' => 'notice_delete popup',
|
||||
// TRANS: Link title in notice list item to delete a notice.
|
||||
'title' => _('Delete this notice from the timeline.')),
|
||||
'title' => _m('Delete this notice from the timeline.'),
|
||||
],
|
||||
// TRANS: Link text in notice list item to delete a notice.
|
||||
_('Delete'));
|
||||
_m('Delete')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,11 +716,11 @@ class NoticeListItem extends Widget
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showEnd()
|
||||
public function showEnd()
|
||||
{
|
||||
if (Event::handle('StartCloseNoticeListItemElement', array($this))) {
|
||||
if (Event::handle('StartCloseNoticeListItemElement', [$this])) {
|
||||
$this->out->elementEnd('li');
|
||||
Event::handle('EndCloseNoticeListItemElement', array($this));
|
||||
Event::handle('EndCloseNoticeListItemElement', [$this]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -655,7 +732,7 @@ class NoticeListItem extends Widget
|
|||
* @return Notice The notice we're showing
|
||||
*/
|
||||
|
||||
function getNotice()
|
||||
public function getNotice()
|
||||
{
|
||||
return $this->notice;
|
||||
}
|
||||
|
|
|
@ -1,49 +1,46 @@
|
|||
<?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
|
||||
* Copyright (C) 2011, StatusNet, Inc.
|
||||
*
|
||||
* A stream of notices
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* 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 Stream
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Class for notice streams
|
||||
*
|
||||
* @category Stream
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
abstract class NoticeStream
|
||||
{
|
||||
protected $selectVerbs = array(ActivityVerb::POST => true,
|
||||
ActivityVerb::SHARE => true);
|
||||
protected $selectVerbs = [
|
||||
ActivityVerb::POST => true,
|
||||
ActivityVerb::SHARE => true,
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -54,23 +51,21 @@ abstract class NoticeStream
|
|||
}
|
||||
}
|
||||
|
||||
abstract function getNoticeIds($offset, $limit, $since_id, $max_id);
|
||||
abstract public function getNoticeIds($offset, $limit, $since_id, $max_id);
|
||||
|
||||
function getNotices($offset, $limit, $sinceId = null, $maxId = null)
|
||||
public function getNotices($offset, $limit, $sinceId = null, $maxId = null)
|
||||
{
|
||||
$ids = $this->getNoticeIds($offset, $limit, $sinceId, $maxId);
|
||||
|
||||
$notices = self::getStreamByIds($ids);
|
||||
|
||||
return $notices;
|
||||
return self::getStreamByIds($ids);
|
||||
}
|
||||
|
||||
static function getStreamByIds($ids)
|
||||
public static function getStreamByIds($ids)
|
||||
{
|
||||
return Notice::multiGet('id', $ids);
|
||||
}
|
||||
|
||||
static function filterVerbs(Notice $notice, array $selectVerbs)
|
||||
public static function filterVerbs(Notice $notice, array $selectVerbs)
|
||||
{
|
||||
$filter = array_keys(array_filter($selectVerbs));
|
||||
if (!empty($filter)) {
|
||||
|
@ -78,7 +73,9 @@ abstract class NoticeStream
|
|||
$notice->whereAddIn('verb', $filter, $notice->columnType('verb'));
|
||||
}
|
||||
|
||||
$filter = array_keys(array_filter($selectVerbs, function ($v) { return !$v; }));
|
||||
$filter = array_keys(array_filter($selectVerbs, function ($v) {
|
||||
return !$v;
|
||||
}));
|
||||
if (!empty($filter)) {
|
||||
// exclude verbs in selectVerbs with values that equate to false
|
||||
$notice->whereAddIn('!verb', $filter, $notice->columnType('verb'));
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
<?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/>.
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* widget for displaying a single notice
|
||||
* Widget for displaying a single notice.
|
||||
*
|
||||
* This widget has the core smarts for showing a single notice: what to display,
|
||||
* where, and under which circumstances. Its key method is show(); this is a recipe
|
||||
|
@ -12,10 +26,9 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
|||
* author info (since that's implicit by the data in the page).
|
||||
*
|
||||
* @category UI
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
* @see NoticeList
|
||||
* @see ProfileNoticeListItem
|
||||
*/
|
||||
|
@ -23,13 +36,13 @@ class ThreadedNoticeListItem extends NoticeListItem
|
|||
{
|
||||
protected $userProfile = null;
|
||||
|
||||
function __construct(Notice $notice, Action $out=null, $profile=null)
|
||||
public function __construct(Notice $notice, Action $out = null, $profile = null)
|
||||
{
|
||||
parent::__construct($notice, $out);
|
||||
$this->userProfile = $profile;
|
||||
}
|
||||
|
||||
function initialItems()
|
||||
public function initialItems()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
@ -41,17 +54,17 @@ class ThreadedNoticeListItem extends NoticeListItem
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function showEnd()
|
||||
public function showEnd()
|
||||
{
|
||||
$max = $this->initialItems();
|
||||
if (!$this->repeat instanceof Notice) {
|
||||
$stream = new ConversationNoticeStream($this->notice->conversation, $this->userProfile);
|
||||
$notice = $stream->getNotices(0, $max + 2);
|
||||
$notices = array();
|
||||
$notices = [];
|
||||
$cnt = 0;
|
||||
$moreCutoff = null;
|
||||
while ($notice->fetch()) {
|
||||
if (Event::handle('StartAddNoticeReply', array($this, $this->notice, $notice))) {
|
||||
if (Event::handle('StartAddNoticeReply', [$this, $this->notice, $notice])) {
|
||||
// Don't list repeats as separate notices in a conversation
|
||||
if (!empty($notice->repeat_of)) {
|
||||
continue;
|
||||
|
@ -69,11 +82,11 @@ class ThreadedNoticeListItem extends NoticeListItem
|
|||
$cnt++;
|
||||
if ($cnt > $max) {
|
||||
// boo-yah
|
||||
$moreCutoff = clone($notice);
|
||||
$moreCutoff = clone $notice;
|
||||
break;
|
||||
}
|
||||
$notices[] = clone($notice); // *grumble* inefficient as hell
|
||||
Event::handle('EndAddNoticeReply', array($this, $this->notice, $notice));
|
||||
$notices[] = clone $notice; // *grumble* inefficient as hell
|
||||
Event::handle('EndAddNoticeReply', [$this, $this->notice, $notice]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user