#110 [WIP] Add namespaces and, in particular, fix Conflict with Event class and PHP Event module

Offen
senooken möchte 176 Commits von senooken/fix-event-class-conflict nach diogo/nightly zusammenführen

+ 15 - 45
CHANGELOG.md

@@ -12,6 +12,16 @@ Load and Storage:
 - New media handling system
 - GS is now structurely divided in includes and public
 - OEmbed upgraded to Embed plugin (Now we provide Open Graph information too)
+- Added Redis based caching and queues
+- Improved memcached support
+
+Federation:
+- Added ActivityPub support
+- RemoteFollow: Remote follow ActivityPub and OStatus remote actors via the click of a button
+- ActorLists: Allow to create collections of Actors and to interact with them - supports both OStatus and ActivityPub
+- The Free Network: Automagically migrate internal remote profiles between Free Network protocols
+- Enabled the search box to import remote notices and profiles
+- Improvements on Nodeinfo (and new route)
 
 General:
 - Composer was integrated
@@ -19,57 +29,17 @@ General:
 Modules:
 - Restored built-in plugins
 - New modules system: core plugins and plugins physically separated
-- Refactor of Plugin API to better illustrate the idea of modules
 - Bug fixes of core modules logic
-
-#### TODO before alpha:
-
-Load and Storage:
-- Upgrade STOMP queue
-- Add Redis based caching and queues
-- Review memcached based cache
-- Port PEAR DB to PDO_DataObject
-- Support PostgreSQL
-
-Network:
-- Port PEAR HTTP to Guzzle
-- Port PEAR Mail to PHPSendMail
-- Add OAuth2 support (deprecate OAuth1)
-- Add shinny new Plugins management interface for sysadmins together with a new doc for devs
-
-Federation:
-- Add ActivityPub support
-  - Fix audience targeting
-  - Add Group Actor Type
-- OstatusSub: Remote follow OS and AP profiles via OStatusSub
-- ActorLists: Allow to create collections of Actors and to interact with them - supports both OS and AP
-- The Free Network: Automagically migrate internal remote profiles between Free Network protocols (check Nodeinfo)
-- Enable the search box to import remote notices and profiles
-
-General:
-- Fix failling unit tests
-- Improve Cronish
-  - Run session garbage collection
-  - Cleanup Email Registration
-- Refactoring of confirmation codes
-- Refactoring of Exceptions
-
-Modules:
-- Document conversion of older plugins to the new GS 2
-- Create installer for v2 plugins
-- Introduce new metadata for plugins (category and thumb)
-- Improve plugin management tool (add install form and better UI that makes use of new metadata)
-- Add plugin management tool as a install step
-- Allow to install remote plugins and suggest popular trusted ones
+- Improved plugin management tool (now all available plugins are shown and third party can be uploaded and deleted)
 
 ## v1.20.9release - The Invicta Crusade
 
-Release name chosen after Porto city. Porto is one of the oldest cities in Europe and thanks to its fierce resistance
-during two battles and sieges in history, it has earned the epithet of ‘Cidade Invicta’ (Invincible City). The dev team
-behind this release studies in Porto, Portugal.
-
 Dropped Support for PHP5.6.x. Minimum PHP version now is 7.0.0.
 
+Release name chosen after Porto city. Porto is one of the oldest cities in Europe and thanks to its fierce resistance during
+two battles and sieges in history, it has earned the epithet of ‘Cidade Invicta’ (Invincible City). The dev team behind this
+release studies in Porto, Portugal.
+
 Major changes from previous release:
 
 - Various patches on PEAR related components

+ 1 - 2
CREDITS.md

@@ -46,7 +46,7 @@ Additional Contributors
 * Blaine Cook
 * Henry Story
 * Melvin Carvalho
-* chimo
+* Stéphane Bérubé
 * Akio
 * Maiyannah Bishop
 * Bob Mottram
@@ -55,7 +55,6 @@ Additional Contributors
 * Moonman
 * Normandy
 * Verius
-* Alexei Sorokin
 * Daniel Supernault
 
 Credits for StatusNet

+ 19 - 6
DOCUMENTATION/DEVELOPERS/EVENTS.txt

@@ -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)
 - $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
 - $action: action object being shown
 
@@ -355,6 +349,12 @@ EndAvatarSaveForm: after saving the avatar
 StartNewQueueManager: before trying to start a new queue manager; good for plugins implementing new queue manager classes
 - $qm: empty queue manager to set
 
+StartInitializeQueueManager: about to register queue handlers in the queue manager; good for plugins to register own handlers
+- $qm: queue manager
+
+EndInitializeQueueManager: after registering queue handlers in the queue manager; good for plugins to register own handlers
+- $qm: queue manager
+
 RedirectToLogin: event when we force a redirect to login (like when going to a settings page on a remembered login)
 - $action: action object being shown
 - $user: current user
@@ -1496,3 +1496,16 @@ StartDocNav: Before outputting the docs Nav
 
 EndDocNav: After outputting the docs Nav
 - $nav: The DoclNav widget
+
+StartNoticeSearch: Before finding notices that match the given query
+- string $query: The text query
+
+StartNoticeSearchShowResults: Before displaying notices matching the query
+- $out:     HTMLOutputter used to output
+- $query:   The text query
+- $notices: Array of DB notice objects
+
+EndNoticeSearchShowResults: After displaying notices matching the query
+- $out:     HTMLOutputter used to output
+- $query:   The text query
+- $notices: Array of DB notice objects

+ 68 - 73
DOCUMENTATION/DEVELOPERS/Plugins/README.md

@@ -1,8 +1,8 @@
 Plugin Development
-=======================
+==================
 
 SamplePlugin.php
------------------------
+----------------
 
 Each plugin requires a main class to interact with the GNU social system.
 
@@ -15,7 +15,7 @@ have pre-defined arguments, based on which event they're handling. A typical
 event handler:
 
 ```php
-function onSomeEvent($paramA, &$paramB)
+public function onSomeEvent($paramA, &$paramB): bool
 {
     if ($paramA == 'jed') {
         throw new Exception(sprintf(_m("Invalid parameter %s"), $paramA));
@@ -26,7 +26,7 @@ function onSomeEvent($paramA, &$paramB)
 ```
 
 Event Handlers
------------------------
+--------------
 
 Event handlers must return a Boolean value.
 
@@ -41,50 +41,43 @@ If the handler throws an exception, processing will stop, and the exception's
 error will be shown to the user.
 
 Installation
-------------------
+------------
 
-To install a plugin (like this one), site admins add the following code to their
+To enable a plugin (like the SamplePlugin), site admins add the following code to their
 config.php file:
 
 ```php
 addPlugin('Sample');
 ```
 
-Plugins must be installed in one of the following directories:
-
-* local/plugins/{$pluginclass}.php
-* local/plugins/{$name}/{$pluginclass}.php
-* local/{$pluginclass}.php
-* local/{$name}/{$pluginclass}.php
-* plugins/{$pluginclass}.php
-* plugins/{$name}/{$pluginclass}.php
+Third Party Plugins must be installed in `local/plugins/{$name}/{$pluginclass}.php`
 
 Here, `{$name}` is the name of the plugin, like 'Sample', and `{$pluginclass}`
 is the name of the main class, like 'SamplePlugin'. Plugins that are part of
 the main GNU social distribution go in 'plugins' and third-party or local ones
 go in 'local'.
 
-Simple plugins can be implemented as a single module. Others are more complex
-and require additional modules; these should use their own directory, like
+Simple plugins can be implemented as a single plugin. Others are more complex
+and require additional plugins; these should use their own directory, like
 'local/plugins/{$name}/'. All files related to the plugin, including images,
-JavaScript, CSS, external libraries or PHP modules should go in the plugin
+JavaScript, CSS, external libraries or PHP plugins should go in the plugin
 directory.
 
 Plugin Configuration
-------------------
+--------------------
 
 Plugins are configured using public instance attributes. To set their values,
 site administrators use this syntax:
 
 ```php
-addPlugin('Sample', ('attr1' => 'foo', 'attr2' => 'bar'));
+addPlugin('Sample', ['attr1' => 'foo', 'attr2' => 'bar']);
 ```
 
 The same plugin class can be initialized multiple times with different arguments:
 
 ```php
-addPlugin('EmailNotify', array('sendTo' => 'evan@status.net'));
-addPlugin('EmailNotify', array('sendTo' => 'brionv@status.net'));
+addPlugin('EmailNotify', ['sendTo' => 'evan@status.net']);
+addPlugin('EmailNotify', ['sendTo' => 'brionv@status.net']);
 ```
 
 ```php
@@ -96,34 +89,34 @@ class SamplePlugin extends Plugin
 ```
 
 Initialization
-------------------
+--------------
 
 Plugins overload this method to do any initialization they need, like connecting
-to remote servers or creating paths or so on. @return boolean hook value; true
+to remote servers or creating paths or so on. @return bool hook value; true
 means continue processing, false means stop.
 
 ```php
-function initialize()
+public function initialize(): bool
 {
     return true;
 }
 ```
 
 Clean Up
-------------------
+--------
 
 Plugins overload this method to do any cleanup they need, like disconnecting from
 remote servers or deleting temp files or so on.
 
 ```php
-function cleanup()
+public function cleanup(): bool
 {
     return true;
 }
 ```
 
 Database schema setup
-------------------
+---------------------
 
 Plugins can add their own tables to the GNU social database. Plugins should use
 GNU social's schema interface to add or delete tables. The ensureTable() method
@@ -135,25 +128,26 @@ the checkschema.php script is run, greatly improving performance. However, they
 need to remember to run that script after installing or upgrading a plugin!
 
 ```php
-function onCheckSchema()
+public function onCheckSchema(): bool
 {
     $schema = Schema::get();
 
     // '''For storing user-submitted flags on profiles'''
 
-    $schema->ensureTable('user_greeting_count',
-                          array(new ColumnDef('user_id', 'integer', null,
-                                              true, 'PRI'),
-                                new ColumnDef('greeting_count', 'integer')));
+    $schema->ensureTable('user_greeting_count',[
+            new ColumnDef('user_id', 'integer', null, true, 'PRI'),
+            new ColumnDef('greeting_count', 'integer')
+        ]
+    );
 
     return true;
 }
 ```
 
-Load related modules when needed
-------------------
+Load related plugins when needed
+--------------------------------
 
-Most non-trivial plugins will require extra modules to do their work. Typically
+Most non-trivial plugins will require extra plugins to do their work. Typically
 these include data classes, action classes, widget classes, or external libraries.
 
 This method receives a class name and loads the PHP file related to that class.
@@ -166,26 +160,26 @@ in this plugin! So, make sure to return true by default to let other plugins,
 and the core code, get a chance.
 
 ```php
-function onAutoload($cls)
+public function onAutoload($cls): bool
 {
-    $dir = dirname(__FILE__);
+    $dir = __DIR__;
 
     switch ($cls)
     {
-    case 'HelloAction':
-        include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
-        return false;
-    case 'User_greeting_count':
-        include_once $dir . '/'.$cls.'.php';
-        return false;
-    default:
-        return true;
+        case 'HelloAction':
+            include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
+            return false;
+        case 'User_greeting_count':
+            include_once $dir . '/'.$cls.'.php';
+            return false;
+        default:
+            return true;
     }
 }
 ```
 
 Map URLs to actions
-------------------
+-------------------
 
 This event handler lets the plugin map URLs on the site to actions (and thus an
 action handler class). Note that the action handler class for an action will be
@@ -193,28 +187,28 @@ named 'FoobarAction', where action = 'foobar'. The class must be loaded in the
 onAutoload() method.
 
 ```php
-function onRouterInitialized($m)
+public function onRouterInitialized($m): bool
 {
     $m->connect('main/hello',
-                array('action' => 'hello'));
+                ['action' => 'hello']);
     return true;
 }
 ```
 
 Modify the default menu to link to our custom action
-------------------
+-----------------------------------------------------
 
 Using event handlers, it's possible to modify the default UI for pages almost
 without limit. In this method, we add a menu item to the default primary menu
 for the interface to link to our action.
 
 Action Class
-------------------
+------------
 
 The Action class provides a rich set of events to hook, as well as output methods.
 
 ```php
-function onEndPrimaryNav($action)
+public function onEndPrimaryNav($action): bool
 {
     // '''common_local_url()''' gets the correct URL for the action name we provide
 
@@ -223,20 +217,22 @@ function onEndPrimaryNav($action)
     return true;
 }
 
-function onPluginVersion(&$versions)
+public function onPluginVersion(&$versions): bool
 {
-    $versions[] = array('name' => 'Sample',
-                        'version' => STATUSNET_VERSION,
-                        'author' => 'Brion Vibber, Evan Prodromou',
-                        'homepage' => 'http://example.org/plugin',
-                        'rawdescription' =>
-                        _m('A sample plugin to show basics of development for new hackers.'));
+    $versions[] = [
+        'name' => 'Sample',
+        'version' => GNUSOCIAL_VERSION,
+        'author' => 'Brion Vibber, Evan Prodromou',
+        'homepage' => 'http://example.org/plugin',
+        'rawdescription' =>
+        _m('A sample plugin to show basics of development for new hackers.')
+    ];
     return true;
 }
 ```
 
 hello.php
-------------------
+---------
 
 This section is taken directly from the 'hello.php'. ( plugins/Sample/hello.php )
 
@@ -255,7 +251,7 @@ class HelloAction extends Action
 ```
 
 Take arguments for running
-------------------
+--------------------------
 
 This method is called first, and it lets the action class get all its arguments
 and validate them. It's also the time to fetch any relevant data from the database.
@@ -263,8 +259,8 @@ and validate them. It's also the time to fetch any relevant data from the databa
 Action classes should run parent::prepare(array $args = []) as the first line
 of this method to make sure the default argument-processing happens.
 
-```php     
-function prepare(array $args = [])
+```php
+public function prepare(array $args = []): bool
 {
     parent::prepare($args);
 
@@ -279,14 +275,14 @@ function prepare(array $args = [])
 ```
 
 Handle request
-------------------
+--------------
 
 This is the main method for handling a request. Note that most preparation
 should be done in the prepare() method; by the time handle() is called the
 action should be more or less ready to go.
 
 ```php
-function handle()
+public function handle(): void
 {
     parent::handle();
 
@@ -300,7 +296,7 @@ Title of this page
 Override this method to show a custom title.
 
 ```php
-function title()
+public function title(): string
 {
     if (empty($this->user)) {
         return _m('Hello');
@@ -311,7 +307,7 @@ function title()
 ```
 
 Show content in the content area
-------------------
+--------------------------------
 
 The default GNU social page has a lot of decorations: menus, logos, tabs, all
 that jazz. This method is used to show content in the content area of the
@@ -319,15 +315,15 @@ page; it's the main thing you want to overload. This method also demonstrates
 use of a plural localized string.
 
 ```php
-function showContent()
+public function showContent(): void
 {
     if (empty($this->user)) {
-        $this->element('p', array('class' => 'greeting'),
+        $this->element('p', ['class' => 'greeting'],
                        _m('Hello, stranger!'));
     } else {
-        $this->element('p', array('class' => 'greeting'),
+        $this->element('p', ['class' => 'greeting'],
                        sprintf(_m('Hello, %s'), $this->user->nickname));
-        $this->element('p', array('class' => 'greeting_count'),
+        $this->element('p', ['class' => 'greeting_count'],
                        sprintf(_m('I have greeted you %d time.',
                                   'I have greeted you %d times.',
                                   $this->gc->greeting_count),
@@ -337,7 +333,7 @@ function showContent()
 ```
 
 Return true if read only.
-------------------
+-------------------------
 
 Some actions only read from the database; others read and write. The simple
 database load-balancer built into GNU social will direct read-only actions to
@@ -347,9 +343,8 @@ This defaults to false to avoid data integrity issues, but you should make sure
 to overload it for performance gains.
 
 ```php
-function isReadOnly($args)
+public function isReadOnly($args): bool
 {
     return false;
 }
 ```
-

+ 90 - 0
DOCUMENTATION/DEVELOPERS/Plugins/Sample Plugins/Awesomeness/includes/AwesomenessPlugin.php

@@ -0,0 +1,90 @@
+<?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/>.
+
+defined('GNUSOCIAL') || die();
+
+/**
+ * Fun sample plugin: tweaks input data and adds a 'Cornify' widget to sidebar.
+ *
+ * @category Plugin
+ * @package  GNUsocial
+ * @author   Jeroen De Dauw <jeroendedauw@gmail.com>
+ * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
+ * @license   https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
+ */
+
+class AwesomenessPlugin extends Plugin
+{
+    const PLUGIN_VERSION = '13.37.42';
+
+    public function onPluginVersion(array &$versions): bool
+    {
+        $versions[] = [
+            'name' => 'Awesomeness',
+            'version' => self::PLUGIN_VERSION,
+            'author' => 'Jeroen De Dauw',
+            'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/Awesomeness',
+            // TRANS: Plugin description for a sample plugin.
+            'rawdescription' => _m('The Awesomeness plugin adds additional awesomeness ' .
+                'to a GNU social installation.')
+        ];
+        return true;
+    }
+
+    /**
+     * Add the conrnify button
+     *
+     * @param Action $action the current action
+     *
+     * @return void
+     */
+    public function onEndShowSections(Action $action)
+    {
+        $action->elementStart('div', ['id'    => 'cornify_section',
+                                      'class' => 'section']);
+
+        $action->raw(
+            <<<EOT
+                <a href="https://www.cornify.com" onclick="cornify_add();return false;">
+                <img src="https://www.cornify.com/assets/cornify.gif" width="61" height="16" border="0" alt="Cornify" />
+                </a>
+EOT
+        );
+
+        $action->elementEnd('div');
+    }
+
+    public function onEndShowScripts(Action $action)
+    {
+        $action->script($this->path('js/cornify.js'));
+    }
+
+    /**
+     * Hook for new-notice form processing to take our HTML goodies;
+     * won't affect API posting etc.
+     *
+     * @param NewNoticeAction $action
+     * @param User $user
+     * @param string $content
+     * @param array $options
+     * @return bool hook return
+     */
+    public function onStartSaveNewNoticeWeb($action, $user, &$content, &$options)
+    {
+        $content = htmlspecialchars($content);
+        $options['rendered'] = preg_replace("/(^|\s|-)((?:awesome|awesomeness)[\?!\.\,]?)(\s|$)/i", " <b>$2</b> ", $content);
+    }
+}

plugins/Awesomeness/README → DOCUMENTATION/DEVELOPERS/Plugins/Sample Plugins/Awesomeness/includes/README


+ 25 - 0
DOCUMENTATION/DEVELOPERS/Plugins/Sample Plugins/Awesomeness/includes/locale/Awesomeness.pot

@@ -0,0 +1,25 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2019-08-14 14:51+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. TRANS: Module description for a sample plugin.
+#: AwesomenessModule.php:67
+msgid ""
+"The Awesomeness plugin adds additional awesomeness to a GNU social "
+"installation."
+msgstr ""

+ 25 - 0
DOCUMENTATION/DEVELOPERS/Plugins/Sample Plugins/Awesomeness/includes/locale/af/LC_MESSAGES/Awesomeness.po

@@ -0,0 +1,25 @@
+# Translation file for GNU social - the free software social networking platform
+# Copyright (C) 2015 - 2019 Free Software Foundation, Inc http://www.fsf.org
+# This file is under https://www.gnu.org/licenses/agpl v3 or later
+# 
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: GNU social\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-02-02 17:47+0100\n"
+"PO-Revision-Date: 2015-02-06 14:56+0000\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: Afrikaans (http://www.transifex.com/gnu-social/gnu-social/language/af/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: af\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. TRANS: Plugin description for a sample plugin.
+#: AwesomenessPlugin.php:55
+msgid ""
+"The Awesomeness plugin adds additional awesomeness to a GNU social "
+"installation."
+msgstr ""

+ 25 - 0
DOCUMENTATION/DEVELOPERS/Plugins/Sample Plugins/Awesomeness/includes/locale/ar/LC_MESSAGES/Awesomeness.po

@@ -0,0 +1,25 @@
+# Translation file for GNU social - the free software social networking platform
+# Copyright (C) 2015 - 2019 Free Software Foundation, Inc http://www.fsf.org
+# This file is under https://www.gnu.org/licenses/agpl v3 or later
+# 
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: GNU social\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-02-02 17:47+0100\n"
+"PO-Revision-Date: 2015-02-06 14:56+0000\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: Arabic (http://www.transifex.com/gnu-social/gnu-social/language/ar/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: ar\n"
+"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"
+
+#. TRANS: Plugin description for a sample plugin.
+#: AwesomenessPlugin.php:55
+msgid ""
+"The Awesomeness plugin adds additional awesomeness to a GNU social "
+"installation."
+msgstr ""

+ 0 - 0
DOCUMENTATION/DEVELOPERS/Plugins/Sample Plugins/Awesomeness/includes/locale/arz/LC_MESSAGES/Awesomeness.po


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.