mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Bugfix: plugin "readme" failed
Removed: plugin PreInit
This commit is contained in:
parent
93b1159a50
commit
46ff83c41d
3 changed files with 15 additions and 20 deletions
|
|
@ -877,7 +877,7 @@ trait Admin
|
||||||
{
|
{
|
||||||
$mResult = array(
|
$mResult = array(
|
||||||
'Name' => $sName,
|
'Name' => $sName,
|
||||||
'Readme' => file_exists($oPlugin->Path().'/README') ? file_get_contents($oPlugin->Path().'/README') : '',
|
'Readme' => $oPlugin->Description(),
|
||||||
'Config' => array()
|
'Config' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,12 @@ abstract class AbstractPlugin
|
||||||
return $this->sName;
|
return $this->sName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Description() : string
|
||||||
|
{
|
||||||
|
return static::DESCRIPTION;
|
||||||
|
// file_exists($oPlugin->Path().'/README') ? file_get_contents($oPlugin->Path().'/README') : ''
|
||||||
|
}
|
||||||
|
|
||||||
public function UseLangs(?bool $bLangs = null) : bool
|
public function UseLangs(?bool $bLangs = null) : bool
|
||||||
{
|
{
|
||||||
if (null !== $bLangs)
|
if (null !== $bLangs)
|
||||||
|
|
@ -146,11 +152,6 @@ abstract class AbstractPlugin
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function PreInit() : void
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function Init() : void
|
public function Init() : void
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,6 @@ class Manager
|
||||||
$oPlugin = $this->CreatePluginByName($sName);
|
$oPlugin = $this->CreatePluginByName($sName);
|
||||||
if ($oPlugin)
|
if ($oPlugin)
|
||||||
{
|
{
|
||||||
$oPlugin->PreInit();
|
|
||||||
$oPlugin->Init();
|
$oPlugin->Init();
|
||||||
|
|
||||||
$this->aPlugins[] = $oPlugin;
|
$this->aPlugins[] = $oPlugin;
|
||||||
|
|
@ -136,15 +135,13 @@ class Manager
|
||||||
{
|
{
|
||||||
foreach ($aGlob as $sPathName)
|
foreach ($aGlob as $sPathName)
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
$sName = \basename($sPathName);
|
$sName = \basename($sPathName);
|
||||||
$sClassName = $this->loadPluginByName($sName);
|
$sClassName = $this->loadPluginByName($sName);
|
||||||
|
if ($sClassName) {
|
||||||
$aList[] = array(
|
$aList[] = array(
|
||||||
$sName,
|
$sName,
|
||||||
$sClassName::VERSION
|
$sClassName::VERSION
|
||||||
);
|
);
|
||||||
} catch (\Throwable $e) {
|
|
||||||
\error_log($e->getMessage() . "\n\t{$sPathName}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -168,20 +165,17 @@ class Manager
|
||||||
public function loadPluginByName(string $sName) : ?string
|
public function loadPluginByName(string $sName) : ?string
|
||||||
{
|
{
|
||||||
if (\preg_match('/^[a-z0-9\-]+$/', $sName)
|
if (\preg_match('/^[a-z0-9\-]+$/', $sName)
|
||||||
&& \file_exists(APP_PLUGINS_PATH.$sName.'/index.php'))
|
&& \is_readable(APP_PLUGINS_PATH.$sName.'/index.php'))
|
||||||
{
|
{
|
||||||
$sClassName = $this->convertPluginFolderNameToClassName($sName);
|
$sClassName = $this->convertPluginFolderNameToClassName($sName);
|
||||||
if (!\class_exists($sClassName)) {
|
if (!\class_exists($sClassName)) {
|
||||||
include APP_PLUGINS_PATH.$sName.'/index.php';
|
include_once APP_PLUGINS_PATH.$sName.'/index.php';
|
||||||
}
|
}
|
||||||
if (\class_exists($sClassName) && \is_subclass_of($sClassName, 'RainLoop\\Plugins\\AbstractPlugin')) {
|
if (\class_exists($sClassName) && \is_subclass_of($sClassName, 'RainLoop\\Plugins\\AbstractPlugin')) {
|
||||||
return $sClassName;
|
return $sClassName;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
\trigger_error("Invalid plugin class {$sClassName}");
|
\trigger_error("Invalid plugin class {$sClassName}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -222,7 +216,7 @@ class Manager
|
||||||
$aJs = $bAdminScope ? $this->aAdminJs : $this->aJs;
|
$aJs = $bAdminScope ? $this->aAdminJs : $this->aJs;
|
||||||
foreach ($aJs as $sFile)
|
foreach ($aJs as $sFile)
|
||||||
{
|
{
|
||||||
if (\file_exists($sFile))
|
if (\is_readable($sFile))
|
||||||
{
|
{
|
||||||
$aResult[] = \file_get_contents($sFile);
|
$aResult[] = \file_get_contents($sFile);
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +241,7 @@ class Manager
|
||||||
$aTemplates = $bAdminScope ? $this->aAdminTemplates : $this->aTemplates;
|
$aTemplates = $bAdminScope ? $this->aAdminTemplates : $this->aTemplates;
|
||||||
foreach ($aTemplates as $sFile)
|
foreach ($aTemplates as $sFile)
|
||||||
{
|
{
|
||||||
if (\file_exists($sFile))
|
if (\is_readable($sFile))
|
||||||
{
|
{
|
||||||
$sTemplateName = \substr(\basename($sFile), 0, -5);
|
$sTemplateName = \substr(\basename($sFile), 0, -5);
|
||||||
$aList[$sTemplateName] = $sFile;
|
$aList[$sTemplateName] = $sFile;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue