From 99fe3e5a52154a94b1199c2ff9d45098399f9009 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Fri, 2 Aug 2019 02:50:48 +0100 Subject: [PATCH] [CORE] Move plugin superclasses from /lib/ to /lib/modules/ --- lib/framework.php | 42 ++++++++++--------- .../ActivityHandlerPlugin.php} | 0 .../modules/ActivityVerbHandlerPlugin.php | 0 .../AuthenticationPlugin.php} | 0 .../AuthorizationPlugin.php} | 0 lib/{implugin.php => modules/ImPlugin.php} | 2 +- .../MicroAppPlugin.php} | 0 lib/{plugin.php => modules/Plugin.php} | 2 +- lib/{uapplugin.php => modules/UAPPlugin.php} | 0 .../UrlShortenerPlugin.php} | 0 .../ActivityModerationPlugin.php | 2 +- modules/ActivityVerb/ActivityVerbPlugin.php | 2 +- .../ActivityVerbPostPlugin.php | 2 +- modules/Favorite/FavoritePlugin.php | 4 +- modules/Share/SharePlugin.php | 4 +- 15 files changed, 32 insertions(+), 28 deletions(-) rename lib/{activityhandlerplugin.php => modules/ActivityHandlerPlugin.php} (100%) rename modules/ActivityVerb/lib/activityverbhandlerplugin.php => lib/modules/ActivityVerbHandlerPlugin.php (100%) rename lib/{authenticationplugin.php => modules/AuthenticationPlugin.php} (100%) rename lib/{authorizationplugin.php => modules/AuthorizationPlugin.php} (100%) rename lib/{implugin.php => modules/ImPlugin.php} (99%) rename lib/{microappplugin.php => modules/MicroAppPlugin.php} (100%) rename lib/{plugin.php => modules/Plugin.php} (99%) rename lib/{uapplugin.php => modules/UAPPlugin.php} (100%) rename lib/{urlshortenerplugin.php => modules/UrlShortenerPlugin.php} (100%) diff --git a/lib/framework.php b/lib/framework.php index 65ebdb8bf4..7b09edf0a9 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -19,10 +19,11 @@ * * @package GNUsocial * @author Evan Prodromou - * @author Shashi Gowda - * @author Neil E. Hodges - * @author Brion Vibber + * @author Shashi Gowda + * @author Neil E. Hodges <47hasbegun@gmail.com> + * @author Brion Vibber * @author Mikael Nordfeldth + * @author Diogo Cordeiro * @copyright 2010-2019 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ @@ -73,10 +74,10 @@ define('NOTICE_INBOX_SOURCE_GATEWAY', -1); * Some of those characters can be troublesome when auto-linking plain text. Such as "http://some.com/)" * URL encoding should be used whenever a weird character is used, the following strings are not definitive. */ -define('URL_REGEX_VALID_PATH_CHARS', '\pN\pL\,\!\.\:\-\_\+\/\@\=\;\%\~\*\(\)'); -define('URL_REGEX_VALID_QSTRING_CHARS', URL_REGEX_VALID_PATH_CHARS . '\&'); -define('URL_REGEX_VALID_FRAGMENT_CHARS', URL_REGEX_VALID_QSTRING_CHARS . '\?\#'); -define('URL_REGEX_EXCLUDED_END_CHARS', '\?\.\,\!\#\:\''); // don't include these if they are directly after a URL +define('URL_REGEX_VALID_PATH_CHARS', '\pN\pL\,\!\.\:\-\_\+\/\@\=\;\%\~\*\(\)'); +define('URL_REGEX_VALID_QSTRING_CHARS', URL_REGEX_VALID_PATH_CHARS . '\&'); +define('URL_REGEX_VALID_FRAGMENT_CHARS', URL_REGEX_VALID_QSTRING_CHARS . '\?\#'); +define('URL_REGEX_EXCLUDED_END_CHARS', '\?\.\,\!\#\:\''); // don't include these if they are directly after a URL define('URL_REGEX_DOMAIN_NAME', '(?:(?!-)[A-Za-z0-9\-]{1,63}(?\(\)* * and is available here: http://www.php-fig.org/psr/psr-0/ -*/ -spl_autoload_register(function($class){ + */ +spl_autoload_register(function ($class) { $class_base = preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')); - $file = INSTALLDIR."/extlib/{$class_base}.php"; + $file = INSTALLDIR . "/extlib/{$class_base}.php"; if (file_exists($file)) { require_once $file; return; @@ -159,9 +162,9 @@ spl_autoload_register(function($class){ return; } }); -require_once INSTALLDIR.'/lib/util.php'; -require_once INSTALLDIR.'/lib/action.php'; -require_once INSTALLDIR.'/lib/mail.php'; +require_once INSTALLDIR . '/lib/util.php'; +require_once INSTALLDIR . '/lib/action.php'; +require_once INSTALLDIR . '/lib/mail.php'; //set PEAR error handling to use regular PHP exceptions function PEAR_ErrorToPEAR_Exception(PEAR_Error $err) @@ -173,7 +176,7 @@ function PEAR_ErrorToPEAR_Exception(PEAR_Error $err) return; } - $msg = $err->getMessage(); + $msg = $err->getMessage(); $userInfo = $err->getUserInfo(); // Log this; push the message up as an exception @@ -194,3 +197,4 @@ function PEAR_ErrorToPEAR_Exception(PEAR_Error $err) } throw new PEAR_Exception($err->getMessage()); } + diff --git a/lib/activityhandlerplugin.php b/lib/modules/ActivityHandlerPlugin.php similarity index 100% rename from lib/activityhandlerplugin.php rename to lib/modules/ActivityHandlerPlugin.php diff --git a/modules/ActivityVerb/lib/activityverbhandlerplugin.php b/lib/modules/ActivityVerbHandlerPlugin.php similarity index 100% rename from modules/ActivityVerb/lib/activityverbhandlerplugin.php rename to lib/modules/ActivityVerbHandlerPlugin.php diff --git a/lib/authenticationplugin.php b/lib/modules/AuthenticationPlugin.php similarity index 100% rename from lib/authenticationplugin.php rename to lib/modules/AuthenticationPlugin.php diff --git a/lib/authorizationplugin.php b/lib/modules/AuthorizationPlugin.php similarity index 100% rename from lib/authorizationplugin.php rename to lib/modules/AuthorizationPlugin.php diff --git a/lib/implugin.php b/lib/modules/ImPlugin.php similarity index 99% rename from lib/implugin.php rename to lib/modules/ImPlugin.php index 74bb593fd2..a86b7a2f9b 100644 --- a/lib/implugin.php +++ b/lib/modules/ImPlugin.php @@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { } /** - * Superclass for plugins that do authentication + * Superclass for plugins that do IM transport * * Implementations will likely want to override onStartIoManagerClasses() so that their * IO manager is used diff --git a/lib/microappplugin.php b/lib/modules/MicroAppPlugin.php similarity index 100% rename from lib/microappplugin.php rename to lib/modules/MicroAppPlugin.php diff --git a/lib/plugin.php b/lib/modules/Plugin.php similarity index 99% rename from lib/plugin.php rename to lib/modules/Plugin.php index e80bf6a0d0..48c830699d 100644 --- a/lib/plugin.php +++ b/lib/modules/Plugin.php @@ -19,7 +19,7 @@ defined('GNUSOCIAL') || die(); /** * Base class for plugins * - * A base class for StatusNet plugins. Mostly a light wrapper around + * A base class for GNU social modules. Mostly a light wrapper around * the Event framework. * * Subclasses of Plugin will automatically handle an event if they define diff --git a/lib/uapplugin.php b/lib/modules/UAPPlugin.php similarity index 100% rename from lib/uapplugin.php rename to lib/modules/UAPPlugin.php diff --git a/lib/urlshortenerplugin.php b/lib/modules/UrlShortenerPlugin.php similarity index 100% rename from lib/urlshortenerplugin.php rename to lib/modules/UrlShortenerPlugin.php diff --git a/modules/ActivityModeration/ActivityModerationPlugin.php b/modules/ActivityModeration/ActivityModerationPlugin.php index ba53a13a8a..25a790ebe6 100644 --- a/modules/ActivityModeration/ActivityModerationPlugin.php +++ b/modules/ActivityModeration/ActivityModerationPlugin.php @@ -112,7 +112,7 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin return true; } - // FIXME: Put this in lib/activityhandlerplugin.php when we're ready + // FIXME: Put this in lib/modules/ActivityHandlerPlugin.php when we're ready // with the other microapps/activityhandlers as well. // Also it should be StartNoticeAsActivity (with a prepped Activity, including ->context etc.) public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null) diff --git a/modules/ActivityVerb/ActivityVerbPlugin.php b/modules/ActivityVerb/ActivityVerbPlugin.php index 22b12a680f..2c6c7ad558 100644 --- a/modules/ActivityVerb/ActivityVerbPlugin.php +++ b/modules/ActivityVerb/ActivityVerbPlugin.php @@ -38,7 +38,7 @@ class ActivityVerbPlugin extends Plugin $unsupported = ['delete', 'share']; foreach ($unsupported as $idx => $verb) { - $unsupported[$idx] = "(?!".$verb.")"; + $unsupported[$idx] = "(?!{$verb})"; } // not all verbs are currently handled by ActivityVerb Plugins, diff --git a/modules/ActivityVerbPost/ActivityVerbPostPlugin.php b/modules/ActivityVerbPost/ActivityVerbPostPlugin.php index 0185d534d7..ca6dc5f0c5 100644 --- a/modules/ActivityVerbPost/ActivityVerbPostPlugin.php +++ b/modules/ActivityVerbPost/ActivityVerbPostPlugin.php @@ -50,7 +50,7 @@ class ActivityVerbPostPlugin extends ActivityVerbHandlerPlugin return array(ActivityVerb::POST); } - // FIXME: Set this to abstract public in lib/activityhandlerplugin.php when all plugins have migrated! + // FIXME: Set this to abstract public in lib/ActivityHandlerPlugin.php when all plugins have migrated! protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array()) { assert($this->isMyActivity($act)); diff --git a/modules/Favorite/FavoritePlugin.php b/modules/Favorite/FavoritePlugin.php index 415671cce1..93e591a88b 100644 --- a/modules/Favorite/FavoritePlugin.php +++ b/modules/Favorite/FavoritePlugin.php @@ -187,7 +187,7 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin 'format' => '(xml|json)']); } - // FIXME: Set this to abstract public in lib/activityhandlerplugin.php ddwhen all plugins have migrated! + // FIXME: Set this to abstract public in lib/modules/ActivityHandlerPlugin.php when all plugins have migrated! protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array()) { assert($this->isMyActivity($act)); @@ -200,7 +200,7 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin return $object; } - // FIXME: Put this in lib/activityhandlerplugin.php when we're ready + // FIXME: Put this in lib/modules/ActivityHandlerPlugin.php when we're ready // with the other microapps/activityhandlers as well. // Also it should be StartNoticeAsActivity (with a prepped Activity, including ->context etc.) public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null) diff --git a/modules/Share/SharePlugin.php b/modules/Share/SharePlugin.php index 31bc55038f..d2326a8808 100644 --- a/modules/Share/SharePlugin.php +++ b/modules/Share/SharePlugin.php @@ -79,7 +79,7 @@ class SharePlugin extends ActivityVerbHandlerPlugin 'format' => '(xml|json)']); } - // FIXME: Set this to abstract public in lib/activityhandlerplugin.php when all plugins have migrated! + // FIXME: Set this to abstract public in lib/modules/ActivityHandlerPlugin.php when all plugins have migrated! protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array()) { assert($this->isMyActivity($act)); @@ -139,7 +139,7 @@ class SharePlugin extends ActivityVerbHandlerPlugin return true; } - // FIXME: Put this in lib/activityhandlerplugin.php when we're ready + // FIXME: Put this in lib/modules/ActivityHandlerPlugin.php when we're ready // with the other microapps/activityhandlers as well. // Also it should be StartNoticeAsActivity (with a prepped Activity, including ->context etc.) public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)