diff --git a/plugins/ConversationTree/ConversationTreePlugin.php b/plugins/ConversationTree/ConversationTreePlugin.php index 4b24e540a5..94a7534a00 100644 --- a/plugins/ConversationTree/ConversationTreePlugin.php +++ b/plugins/ConversationTree/ConversationTreePlugin.php @@ -1,47 +1,54 @@ . - */ - -if (!defined('GNUSOCIAL')) { exit(1); } +// 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 . /** - * @package UI - * @maintainer Mikael Nordfeldth + * The ConversationTree plugin displays conversation replies in a hierarchical + * manner like StatusNet pre-v1.0 used to. + * + * @category UI + * @package ConversationTreePlugin + * @author Mikael Nordfeldth + * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ + +defined('GNUSOCIAL') || die(); + class ConversationTreePlugin extends Plugin { const PLUGIN_VERSION = '2.0.0'; - public function onStartShowConversation(Action $action, Conversation $conv, Profile $scoped=null) { + public function onStartShowConversation(Action $action, Conversation $conv, Profile $scoped = null): bool + { $nl = new ConversationTree($conv->getNotices($action->getScoped()), $action); - $cnt = $nl->show(); + $nl->show(); return false; } public function onPluginVersion(array &$versions): bool { - $versions[] = array('name' => 'ConversationTree', - 'version' => self::PLUGIN_VERSION, - 'author' => 'Mikael Nordfeldth', - 'homepage' => 'http://gnu.io/', - 'rawdescription' => - // TRANS: Plugin description. - _m('Enables conversation tree view.')); + $versions[] = [ + 'name' => 'ConversationTree', + 'version' => self::PLUGIN_VERSION, + 'author' => 'Evan Prodromou, Mikael Nordfeldth', + 'homepage' => 'http://gnu.io/', + 'rawdescription' => + // TRANS: Module description. + _m('Enables conversation tree view.') + ]; return true; } diff --git a/plugins/ConversationTree/lib/conversationtree.php b/plugins/ConversationTree/lib/conversationtree.php index ff39b3e4f4..8d6e0dd097 100644 --- a/plugins/ConversationTree/lib/conversationtree.php +++ b/plugins/ConversationTree/lib/conversationtree.php @@ -1,64 +1,50 @@ . - * - * @category Widget - * @package StatusNet - * @author Evan Prodromou - * @copyright 2011 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 - * @link http://status.net/ - */ +// 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 . -if (!defined('GNUSOCIAL')) { exit(1); } +defined('GNUSOCIAL') || die(); /** * Conversation tree * * The widget class for displaying a hierarchical list of notices. * - * @category Widget - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://status.net/ + * @category Widget + * @package ConversationTreePlugin + * @author Evan Prodromou + * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ class ConversationTree extends NoticeList { - var $tree = null; - var $table = null; + public $tree = null; + public $table = null; /** * Show the tree of notices * - * @return void + * @return int */ - function show() + public function show(): int { $cnt = $this->_buildTree(); - $this->out->elementStart('div', array('id' =>'notices_primary')); + $this->out->elementStart('div', ['id' => 'notices_primary']); // TRANS: Header on conversation page. Hidden by default (h2). $this->out->element('h2', null, _('Notices')); - $this->out->elementStart('ol', array('class' => 'notices xoxo old-school')); + $this->out->elementStart('ol', ['class' => 'notices xoxo old-school']); if (array_key_exists('root', $this->tree)) { $rootid = $this->tree['root'][0]; @@ -71,28 +57,27 @@ class ConversationTree extends NoticeList return $cnt; } - function _buildTree() + public function _buildTree(): int { $cnt = 0; - $this->tree = array(); - $this->table = array(); + $this->tree = []; + $this->table = []; while ($this->notice->fetch()) { - $cnt++; - $id = $this->notice->id; + $id = $this->notice->id; $notice = clone($this->notice); $this->table[$id] = $notice; if (is_null($notice->reply_to)) { - $this->tree['root'] = array($notice->id); - } else if (array_key_exists($notice->reply_to, $this->tree)) { + $this->tree['root'] = [$notice->id]; + } elseif (array_key_exists($notice->reply_to, $this->tree)) { $this->tree[$notice->reply_to][] = $notice->id; } else { - $this->tree[$notice->reply_to] = array($notice->id); + $this->tree[$notice->reply_to] = [$notice->id]; } } @@ -106,12 +91,12 @@ class ConversationTree extends NoticeList * * @return void */ - function showNoticePlus($id) + public function showNoticePlus($id): void { $notice = $this->table[$id]; - $this->out->elementStart('li', array('class' => 'h-entry notice', - 'id' => 'notice-' . $id)); + $this->out->elementStart('li', ['class' => 'h-entry notice', + 'id' => 'notice-' . $id]); $item = $this->newListItem($notice); $item->show(); @@ -119,7 +104,7 @@ class ConversationTree extends NoticeList if (array_key_exists($id, $this->tree)) { $children = $this->tree[$id]; - $this->out->elementStart('ol', array('class' => 'notices threaded-replies xoxo')); + $this->out->elementStart('ol', ['class' => 'notices threaded-replies xoxo']); sort($children); @@ -138,9 +123,9 @@ class ConversationTree extends NoticeList * * @param Notice $notice Notice to display * - * @return NoticeListItem a list item to show + * @return ConversationTreeItem a list item to show */ - function newListItem(Notice $notice) + public function newListItem(Notice $notice): ConversationTreeItem { return new ConversationTreeItem($notice, $this->out); } diff --git a/plugins/ConversationTree/lib/conversationtreeitem.php b/plugins/ConversationTree/lib/conversationtreeitem.php index 65911dfc48..4d8ec71853 100644 --- a/plugins/ConversationTree/lib/conversationtreeitem.php +++ b/plugins/ConversationTree/lib/conversationtreeitem.php @@ -1,45 +1,31 @@ . - * - * @category Widget - * @package StatusNet - * @author Evan Prodromou - * @copyright 2011 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 - * @link http://status.net/ - */ +// 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 . -if (!defined('GNUSOCIAL')) { exit(1); } +defined('GNUSOCIAL') || die(); /** * Conversation tree list item * * Special class of NoticeListItem for use inside conversation trees. * - * @category Widget - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 - * @link http://status.net/ + * @category Widget + * @package ConversationTreePlugin + * @author Evan Prodromou + * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ class ConversationTreeItem extends NoticeListItem { @@ -51,7 +37,7 @@ class ConversationTreeItem extends NoticeListItem * * @return void */ - function showStart() + public function showStart(): void { return; } @@ -64,7 +50,7 @@ class ConversationTreeItem extends NoticeListItem * * @return void */ - function showEnd() + public function showEnd(): void { return; } @@ -76,7 +62,7 @@ class ConversationTreeItem extends NoticeListItem * * @return void */ - function showAddressees() + public function showAddressees(): void { return; }