[CORE] Move core plugins to a new modules directory

For reference (raised by rozzin in IRC):

* http://foldoc.org/module
* http://foldoc.org/library
* http://foldoc.org/plugin

As noted by XRevan86, modules are not necessarily non-essential.
As we will keep the modules directory in GS root [therefore, near to
plugins/], it is evidenced the difference between both.

This is a simple yet fundamental structural change. It doesn't change
functionality but makes clearer the way we understand GNU social's
internals.
This commit is contained in:
Diogo Cordeiro 2019-07-23 09:30:05 +01:00 committed by Diogo Peralta Cordeiro
parent 8e7ab891a5
commit c18f26145c
446 changed files with 605 additions and 2357 deletions

View File

@ -39,7 +39,7 @@ $default =
'logperf' => false, // Enable to dump performance counters to syslog 'logperf' => false, // Enable to dump performance counters to syslog
'logperf_detail' => false, // Enable to dump every counter hit 'logperf_detail' => false, // Enable to dump every counter hit
'fancy' => false, 'fancy' => false,
'locale_path' => INSTALLDIR.'/locale', 'locale_path' => INSTALLDIR . '/locale',
'language' => 'en', 'language' => 'en',
'langdetect' => true, 'langdetect' => true,
'languages' => get_all_languages(), 'languages' => get_all_languages(),
@ -110,7 +110,7 @@ $default =
'softlimit' => '90%', // total size or % of memory_limit at which to restart queue threads gracefully 'softlimit' => '90%', // total size or % of memory_limit at which to restart queue threads gracefully
'spawndelay' => 1, // Wait at least N seconds between (re)spawns of child processes to avoid slamming the queue server with subscription startup 'spawndelay' => 1, // Wait at least N seconds between (re)spawns of child processes to avoid slamming the queue server with subscription startup
'debug_memory' => false, // true to spit memory usage to log 'debug_memory' => false, // true to spit memory usage to log
'breakout' => array(), // List queue specifiers to break out when using Stomp queue. 'breakout' => [], // List queue specifiers to break out when using Stomp queue.
// Default will share all queues for all sites within each group. // Default will share all queues for all sites within each group.
// Specify as <group>/<queue> or <group>/<queue>/<site>, // Specify as <group>/<queue> or <group>/<queue>/<site>,
// using nickname identifier as site. // using nickname identifier as site.
@ -131,10 +131,10 @@ $default =
'params' => null, 'params' => null,
'domain_check' => true), 'domain_check' => true),
'nickname' => 'nickname' =>
array('blacklist' => array(), array('blacklist' => [],
'featured' => array()), 'featured' => []),
'profile' => 'profile' =>
array('banned' => array(), array('banned' => [],
'biolimit' => null, 'biolimit' => null,
'changenick' => false, 'changenick' => false,
'allowprivate' => false, // whether to allow setting stream to private ("only followers can read") 'allowprivate' => false, // whether to allow setting stream to private ("only followers can read")
@ -156,12 +156,12 @@ $default =
), ),
'public' => 'public' =>
array('localonly' => false, array('localonly' => false,
'blacklist' => array(), 'blacklist' => [],
'autosource' => array()), 'autosource' => []),
'theme' => 'theme' =>
array('server' => null, array('server' => null,
'dir' => null, 'dir' => null,
'path'=> null, 'path' => null,
'ssl' => null), 'ssl' => null),
'usertheme' => 'usertheme' =>
array('linkcolor' => 'black', array('linkcolor' => 'black',
@ -170,7 +170,7 @@ $default =
array('enabled' => extension_loaded('zip')), array('enabled' => extension_loaded('zip')),
'javascript' => 'javascript' =>
array('server' => null, array('server' => null,
'path'=> null, 'path' => null,
'ssl' => null, 'ssl' => null,
'bustframes' => true), 'bustframes' => true),
'local' => // To override path/server for themes in 'local' dir (not currently applied to local plugins) 'local' => // To override path/server for themes in 'local' dir (not currently applied to local plugins)
@ -210,7 +210,7 @@ $default =
'cache' => 'cache' =>
array('base' => null), array('base' => null),
'ping' => 'ping' =>
array('notify' => array(), array('notify' => [],
'timeout' => 2), 'timeout' => 2),
'inboxes' => 'inboxes' =>
array('enabled' => true), # ignored after 0.9.x array('enabled' => true), # ignored after 0.9.x
@ -326,46 +326,46 @@ $default =
'sharedefault' => false), 'sharedefault' => false),
'logincommand' => 'logincommand' =>
array('disabled' => true), array('disabled' => true),
'plugins' => 'plugins' =>[
array('core' => array( 'core' => [
'ActivityVerb' => array(), 'Activity' => [],
'ActivityVerbPost' => array(), 'ActivityModeration' => [],
'ActivityModeration' => array(), 'ActivityVerb' => [],
'AuthCrypt' => array(), 'ActivityVerbPost' => [],
'Cronish' => array(), 'AuthCrypt' => [],
'Favorite' => array(), 'Favorite' => [],
'HTMLPurifierSchemes' => array(), 'HTMLPurifierSchemes' => [],
'Share' => array(), 'Share' => [],
'LRDD' => array(), ],
), 'default' => [
'default' => array( 'AntiBrute' => [],
'Activity' => array(), 'Blacklist' => [],
'AntiBrute' => array(), 'Bookmark' => [],
'Blacklist' => array(), 'ClientSideShorten' => [],
'Bookmark' => array(), 'Cronish' => [],
'ClientSideShorten' => array(), 'DefaultLayout' => [],
'DefaultLayout' => array(), 'DirectMessage' => [],
'Directory' => array(), 'Directory' => [],
'DirectMessage' => array(), 'EmailAuthentication' => [],
'EmailAuthentication' => array(), 'Embed' => [],
'Event' => array(), 'Event' => [],
'Embed' => array(), 'LRDD' => [],
'OpenID' => array(), 'Nodeinfo' => [],
'OpportunisticQM' => array(), 'OpenID' => [],
'ActivityPub' => array(), 'OpportunisticQM' => [],
'OStatus' => array(), 'ActivityPub' => [], // The order is important here (IT HAS TO COME BEFORE OSTATUS)
'Poll' => array(), 'OStatus' => [],
'SimpleCaptcha' => array(), 'Poll' => [],
'TagSub' => array(), 'SimpleCaptcha' => [],
'WebFinger' => array(), 'TagSub' => [],
'Nodeinfo' => array(), 'WebFinger' => [],
), ],
'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories 'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories
'server' => null, 'server' => null,
'sslserver' => null, 'sslserver' => null,
'path' => null, 'path' => null,
'sslpath' => null, 'sslpath' => null,
), ],
'admin' => 'admin' =>
array('panels' => array('site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license', 'plugins')), array('panels' => array('site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license', 'plugins')),
'singleuser' => 'singleuser' =>

View File

@ -82,7 +82,7 @@ class Event {
* on results of handlers. * on results of handlers.
*/ */
public static function handle($name, array $args=array()) { public static function handle($name, array $args = []) {
$result = null; $result = null;
if (array_key_exists($name, Event::$_handlers)) { if (array_key_exists($name, Event::$_handlers)) {
foreach (Event::$_handlers[$name] as $handler) { foreach (Event::$_handlers[$name] as $handler) {

View File

@ -30,7 +30,7 @@ class GNUsocial
protected static $plugins = array(); protected static $plugins = array();
/** /**
* Configure and instantiate a plugin into the current configuration. * Configure and instantiate a plugin (or a core module) into the current configuration.
* Class definitions will be loaded from standard paths if necessary. * Class definitions will be loaded from standard paths if necessary.
* Note that initialization events won't be fired until later. * Note that initialization events won't be fired until later.
* *
@ -39,7 +39,7 @@ class GNUsocial
* *
* @throws ServerException if plugin can't be found * @throws ServerException if plugin can't be found
*/ */
public static function addPlugin($name, array $attrs=array()) public static function addPlugin($name, array $attrs = [])
{ {
$name = ucfirst($name); $name = ucfirst($name);
@ -54,12 +54,16 @@ class GNUsocial
if (!class_exists($pluginclass)) { if (!class_exists($pluginclass)) {
$files = array("local/plugins/{$pluginclass}.php", $files = [
"local/plugins/{$pluginclass}.php",
"local/plugins/{$name}/{$pluginclass}.php", "local/plugins/{$name}/{$pluginclass}.php",
"local/{$pluginclass}.php", "local/{$pluginclass}.php",
"local/{$name}/{$pluginclass}.php", "local/{$name}/{$pluginclass}.php",
"modules/{$pluginclass}.php",
"modules/{$name}/{$pluginclass}.php",
"plugins/{$pluginclass}.php", "plugins/{$pluginclass}.php",
"plugins/{$name}/{$pluginclass}.php"); "plugins/{$name}/{$pluginclass}.php"
];
foreach ($files as $file) { foreach ($files as $file) {
$fullpath = INSTALLDIR.'/'.$file; $fullpath = INSTALLDIR.'/'.$file;

View File

@ -64,9 +64,9 @@ class Plugin
} }
/** /**
* Load related modules when needed * Load related components when needed
* *
* Most non-trivial plugins will require extra modules to do their work. Typically * Most non-trivial plugins will require extra components to do their work. Typically
* these include data classes, action classes, widget classes, or external libraries. * 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. By * This method receives a class name and loads the PHP file related to that class. By
@ -79,11 +79,14 @@ class Plugin
* *
* @param string $cls Name of the class to be loaded * @param string $cls Name of the class to be loaded
* *
* @return boolean hook value; true means continue processing, false means stop. * @return bool hook value; true means continue processing, false means stop.
*/ */
public function onAutoload($cls) { public function onAutoload($cls) {
$cls = basename($cls); $cls = basename($cls);
$basedir = INSTALLDIR . '/local/plugins/' . mb_substr(get_called_class(), 0, -6); $basedir = INSTALLDIR . '/local/plugins/' . mb_substr(get_called_class(), 0, -6);
if (!file_exists($basedir)) {
$basedir = INSTALLDIR . '/modules/' . mb_substr(get_called_class(), 0, -6);
}
if (!file_exists($basedir)) { if (!file_exists($basedir)) {
$basedir = INSTALLDIR . '/plugins/' . mb_substr(get_called_class(), 0, -6); $basedir = INSTALLDIR . '/plugins/' . mb_substr(get_called_class(), 0, -6);
} }
@ -92,17 +95,17 @@ class Plugin
if (preg_match('/^(\w+)(Action|Form)$/', $cls, $type)) { if (preg_match('/^(\w+)(Action|Form)$/', $cls, $type)) {
$type = array_map('strtolower', $type); $type = array_map('strtolower', $type);
$file = "$basedir/{$type[2]}s/{$type[1]}.php"; $file = "{$basedir}/{$type[2]}s/{$type[1]}.php";
} }
if (!file_exists($file)) { if (!file_exists($file)) {
$file = "$basedir/classes/{$cls}.php"; $file = "{$basedir}/classes/{$cls}.php";
// library files can be put into subdirs ('_'->'/' conversion) // library files can be put into subdirs ('_'->'/' conversion)
// such as LRDDMethod_WebFinger -> lib/lrddmethod/webfinger.php // such as LRDDMethod_WebFinger -> lib/lrddmethod/webfinger.php
if (!file_exists($file)) { if (!file_exists($file)) {
$type = strtolower($cls); $type = strtolower($cls);
$type = str_replace('_', '/', $type); $type = str_replace('_', '/', $type);
$file = "$basedir/lib/{$type}.php"; $file = "{$basedir}/lib/{$type}.php";
} }
} }
@ -127,9 +130,12 @@ class Plugin
if (!$path) { if (!$path) {
// @fixme this will fail for things installed in local/plugins // @fixme this will fail for things installed in local/plugins
// ... but then so will web links so far. // ... but then so will web links so far.
$path = INSTALLDIR . "/plugins/$name/locale"; $path = INSTALLDIR . "/plugins/{$name}/locale";
if (!file_exists($path)) { if (!file_exists($path)) {
$path = INSTALLDIR . "/local/plugins/$name/locale"; $path = INSTALLDIR . "/modules/{$name}/locale";
}
if (!file_exists($path)) {
$path = INSTALLDIR . "/local/plugins/{$name}/locale";
} }
} }
if (file_exists($path) && is_dir($path)) { if (file_exists($path) && is_dir($path)) {
@ -206,8 +212,10 @@ class Plugin
if (empty($path)) { if (empty($path)) {
// XXX: extra stat(). // XXX: extra stat().
if (@file_exists(PUBLICDIR.'/local/plugins/'.$plugin.'/'.$relative)) { if (@file_exists(PUBLICDIR . '/local/plugins/' . $plugin . '/' . $relative)) {
$path = common_config('site', 'path') . '/local/plugins/'; $path = common_config('site', 'path') . '/local/plugins/';
} elseif (@file_exists(PUBLICDIR . '/modules/' . $plugin . '/' . $relative)) {
$path = common_config('site', 'path') . '/modules/';
} else { } else {
$path = common_config('site', 'path') . '/plugins/'; $path = common_config('site', 'path') . '/plugins/';
} }

Some files were not shown because too many files have changed in this diff Show More