forked from GNUsocial/gnu-social
[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:
parent
350cde08d8
commit
8c0601816f
@ -39,7 +39,7 @@ $default =
|
||||
'logperf' => false, // Enable to dump performance counters to syslog
|
||||
'logperf_detail' => false, // Enable to dump every counter hit
|
||||
'fancy' => false,
|
||||
'locale_path' => INSTALLDIR.'/locale',
|
||||
'locale_path' => INSTALLDIR . '/locale',
|
||||
'language' => 'en',
|
||||
'langdetect' => true,
|
||||
'languages' => get_all_languages(),
|
||||
@ -110,7 +110,7 @@ $default =
|
||||
'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
|
||||
'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.
|
||||
// Specify as <group>/<queue> or <group>/<queue>/<site>,
|
||||
// using nickname identifier as site.
|
||||
@ -131,10 +131,10 @@ $default =
|
||||
'params' => null,
|
||||
'domain_check' => true),
|
||||
'nickname' =>
|
||||
array('blacklist' => array(),
|
||||
'featured' => array()),
|
||||
array('blacklist' => [],
|
||||
'featured' => []),
|
||||
'profile' =>
|
||||
array('banned' => array(),
|
||||
array('banned' => [],
|
||||
'biolimit' => null,
|
||||
'changenick' => false,
|
||||
'allowprivate' => false, // whether to allow setting stream to private ("only followers can read")
|
||||
@ -156,12 +156,12 @@ $default =
|
||||
),
|
||||
'public' =>
|
||||
array('localonly' => false,
|
||||
'blacklist' => array(),
|
||||
'autosource' => array()),
|
||||
'blacklist' => [],
|
||||
'autosource' => []),
|
||||
'theme' =>
|
||||
array('server' => null,
|
||||
'dir' => null,
|
||||
'path'=> null,
|
||||
'path' => null,
|
||||
'ssl' => null),
|
||||
'usertheme' =>
|
||||
array('linkcolor' => 'black',
|
||||
@ -170,7 +170,7 @@ $default =
|
||||
array('enabled' => extension_loaded('zip')),
|
||||
'javascript' =>
|
||||
array('server' => null,
|
||||
'path'=> null,
|
||||
'path' => null,
|
||||
'ssl' => null,
|
||||
'bustframes' => true),
|
||||
'local' => // To override path/server for themes in 'local' dir (not currently applied to local plugins)
|
||||
@ -210,7 +210,7 @@ $default =
|
||||
'cache' =>
|
||||
array('base' => null),
|
||||
'ping' =>
|
||||
array('notify' => array(),
|
||||
array('notify' => [],
|
||||
'timeout' => 2),
|
||||
'inboxes' =>
|
||||
array('enabled' => true), # ignored after 0.9.x
|
||||
@ -326,46 +326,46 @@ $default =
|
||||
'sharedefault' => false),
|
||||
'logincommand' =>
|
||||
array('disabled' => true),
|
||||
'plugins' =>
|
||||
array('core' => array(
|
||||
'ActivityVerb' => array(),
|
||||
'ActivityVerbPost' => array(),
|
||||
'ActivityModeration' => array(),
|
||||
'AuthCrypt' => array(),
|
||||
'Cronish' => array(),
|
||||
'Favorite' => array(),
|
||||
'HTMLPurifierSchemes' => array(),
|
||||
'Share' => array(),
|
||||
'LRDD' => array(),
|
||||
),
|
||||
'default' => array(
|
||||
'Activity' => array(),
|
||||
'AntiBrute' => array(),
|
||||
'Blacklist' => array(),
|
||||
'Bookmark' => array(),
|
||||
'ClientSideShorten' => array(),
|
||||
'DefaultLayout' => array(),
|
||||
'Directory' => array(),
|
||||
'DirectMessage' => array(),
|
||||
'EmailAuthentication' => array(),
|
||||
'Event' => array(),
|
||||
'Embed' => array(),
|
||||
'OpenID' => array(),
|
||||
'OpportunisticQM' => array(),
|
||||
'ActivityPub' => array(),
|
||||
'OStatus' => array(),
|
||||
'Poll' => array(),
|
||||
'SimpleCaptcha' => array(),
|
||||
'TagSub' => array(),
|
||||
'WebFinger' => array(),
|
||||
'Nodeinfo' => array(),
|
||||
),
|
||||
'plugins' =>[
|
||||
'core' => [
|
||||
'Activity' => [],
|
||||
'ActivityModeration' => [],
|
||||
'ActivityVerb' => [],
|
||||
'ActivityVerbPost' => [],
|
||||
'AuthCrypt' => [],
|
||||
'Favorite' => [],
|
||||
'HTMLPurifierSchemes' => [],
|
||||
'Share' => [],
|
||||
],
|
||||
'default' => [
|
||||
'AntiBrute' => [],
|
||||
'Blacklist' => [],
|
||||
'Bookmark' => [],
|
||||
'ClientSideShorten' => [],
|
||||
'Cronish' => [],
|
||||
'DefaultLayout' => [],
|
||||
'DirectMessage' => [],
|
||||
'Directory' => [],
|
||||
'EmailAuthentication' => [],
|
||||
'Embed' => [],
|
||||
'Event' => [],
|
||||
'LRDD' => [],
|
||||
'Nodeinfo' => [],
|
||||
'OpenID' => [],
|
||||
'OpportunisticQM' => [],
|
||||
'ActivityPub' => [], // The order is important here (IT HAS TO COME BEFORE OSTATUS)
|
||||
'OStatus' => [],
|
||||
'Poll' => [],
|
||||
'SimpleCaptcha' => [],
|
||||
'TagSub' => [],
|
||||
'WebFinger' => [],
|
||||
],
|
||||
'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories
|
||||
'server' => null,
|
||||
'sslserver' => null,
|
||||
'path' => null,
|
||||
'sslpath' => null,
|
||||
),
|
||||
],
|
||||
'admin' =>
|
||||
array('panels' => array('site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license', 'plugins')),
|
||||
'singleuser' =>
|
||||
|
@ -82,7 +82,7 @@ class Event {
|
||||
* on results of handlers.
|
||||
*/
|
||||
|
||||
public static function handle($name, array $args=array()) {
|
||||
public static function handle($name, array $args = []) {
|
||||
$result = null;
|
||||
if (array_key_exists($name, Event::$_handlers)) {
|
||||
foreach (Event::$_handlers[$name] as $handler) {
|
||||
|
@ -30,7 +30,7 @@ class GNUsocial
|
||||
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.
|
||||
* Note that initialization events won't be fired until later.
|
||||
*
|
||||
@ -39,7 +39,7 @@ class GNUsocial
|
||||
*
|
||||
* @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);
|
||||
|
||||
@ -54,12 +54,16 @@ class GNUsocial
|
||||
|
||||
if (!class_exists($pluginclass)) {
|
||||
|
||||
$files = array("local/plugins/{$pluginclass}.php",
|
||||
$files = [
|
||||
"local/plugins/{$pluginclass}.php",
|
||||
"local/plugins/{$name}/{$pluginclass}.php",
|
||||
"local/{$pluginclass}.php",
|
||||
"local/{$name}/{$pluginclass}.php",
|
||||
"modules/{$pluginclass}.php",
|
||||
"modules/{$name}/{$pluginclass}.php",
|
||||
"plugins/{$pluginclass}.php",
|
||||
"plugins/{$name}/{$pluginclass}.php");
|
||||
"plugins/{$name}/{$pluginclass}.php"
|
||||
];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$fullpath = INSTALLDIR.'/'.$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.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @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) {
|
||||
$cls = basename($cls);
|
||||
$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)) {
|
||||
$basedir = INSTALLDIR . '/plugins/' . mb_substr(get_called_class(), 0, -6);
|
||||
}
|
||||
@ -92,17 +95,17 @@ class Plugin
|
||||
|
||||
if (preg_match('/^(\w+)(Action|Form)$/', $cls, $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)) {
|
||||
$file = "$basedir/classes/{$cls}.php";
|
||||
$file = "{$basedir}/classes/{$cls}.php";
|
||||
|
||||
// library files can be put into subdirs ('_'->'/' conversion)
|
||||
// such as LRDDMethod_WebFinger -> lib/lrddmethod/webfinger.php
|
||||
if (!file_exists($file)) {
|
||||
$type = strtolower($cls);
|
||||
$type = str_replace('_', '/', $type);
|
||||
$file = "$basedir/lib/{$type}.php";
|
||||
$file = "{$basedir}/lib/{$type}.php";
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,9 +130,12 @@ class Plugin
|
||||
if (!$path) {
|
||||
// @fixme this will fail for things installed in local/plugins
|
||||
// ... but then so will web links so far.
|
||||
$path = INSTALLDIR . "/plugins/$name/locale";
|
||||
$path = INSTALLDIR . "/plugins/{$name}/locale";
|
||||
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)) {
|
||||
@ -206,8 +212,10 @@ class Plugin
|
||||
|
||||
if (empty($path)) {
|
||||
// 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/';
|
||||
} elseif (@file_exists(PUBLICDIR . '/modules/' . $plugin . '/' . $relative)) {
|
||||
$path = common_config('site', 'path') . '/modules/';
|
||||
} else {
|
||||
$path = common_config('site', 'path') . '/plugins/';
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user