Move addon admin list generation to Core\Addon
This commit is contained in:
parent
9774c95b80
commit
9f4fb4906a
|
@ -27,6 +27,14 @@ class Addon extends BaseObject
|
||||||
*/
|
*/
|
||||||
private static $addons = [];
|
private static $addons = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of available addons with their current status and info.
|
||||||
|
* This list is made from scanning the addon/ folder.
|
||||||
|
* Unsupported addons are excluded unless they already are enabled or system.show_unsupported_addon is set.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public static function getAvailableList()
|
public static function getAvailableList()
|
||||||
{
|
{
|
||||||
$addons = [];
|
$addons = [];
|
||||||
|
@ -50,6 +58,30 @@ class Addon extends BaseObject
|
||||||
return $addons;
|
return $addons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of addons that can be configured at the node level.
|
||||||
|
* The list is formatted for display in the admin panel aside.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public static function getAdminList()
|
||||||
|
{
|
||||||
|
$addons_admin = [];
|
||||||
|
$addonsAdminStmt = DBA::select('addon', ['name'], ['plugin_admin' => 1], ['order' => ['name']]);
|
||||||
|
while ($addon = DBA::fetch($addonsAdminStmt)) {
|
||||||
|
$addons_admin[$addon['name']] = [
|
||||||
|
'url' => 'admin/addons/' . $addon['name'],
|
||||||
|
'name' => $addon['name'],
|
||||||
|
'class' => 'addon'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
DBA::close($addonsAdminStmt);
|
||||||
|
|
||||||
|
return $addons_admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Synchronize addons:
|
* @brief Synchronize addons:
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,7 +6,6 @@ use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\Module\BaseAdminModule;
|
use Friendica\Module\BaseAdminModule;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -42,13 +41,7 @@ class Details extends BaseAdminModule
|
||||||
|
|
||||||
$a = self::getApp();
|
$a = self::getApp();
|
||||||
|
|
||||||
$addons_admin = [];
|
$addons_admin = Addon::getAdminList();
|
||||||
$addonsAdminStmt = DBA::select('addon', ['name'], ['plugin_admin' => 1], ['order' => ['name']]);
|
|
||||||
foreach (DBA::toArray($addonsAdminStmt) as $addon) {
|
|
||||||
$addonName = $addon['name'];
|
|
||||||
// temp addons with admin
|
|
||||||
$addons_admin[] = $addonName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($a->argc > 2) {
|
if ($a->argc > 2) {
|
||||||
// @TODO: Replace with parameter from router
|
// @TODO: Replace with parameter from router
|
||||||
|
@ -93,7 +86,7 @@ class Details extends BaseAdminModule
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin_form = '';
|
$admin_form = '';
|
||||||
if (in_array($addon, $addons_admin)) {
|
if (array_key_exists($addon, $addons_admin)) {
|
||||||
require_once "addon/$addon/$addon.php";
|
require_once "addon/$addon/$addon.php";
|
||||||
$func = $addon . '_addon_admin';
|
$func = $addon . '_addon_admin';
|
||||||
$func($a, $admin_form);
|
$func($a, $admin_form);
|
||||||
|
@ -126,4 +119,4 @@ class Details extends BaseAdminModule
|
||||||
|
|
||||||
$a->internalRedirect('admin/addons');
|
$a->internalRedirect('admin/addons');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,9 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Admin\Addons;
|
namespace Friendica\Module\Admin\Addons;
|
||||||
|
|
||||||
use Friendica\Content\Text\Markdown;
|
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\Module\BaseAdminModule;
|
use Friendica\Module\BaseAdminModule;
|
||||||
|
|
||||||
class Index extends BaseAdminModule
|
class Index extends BaseAdminModule
|
||||||
|
@ -46,12 +43,6 @@ class Index extends BaseAdminModule
|
||||||
$a->internalRedirect('admin/addons');
|
$a->internalRedirect('admin/addons');
|
||||||
}
|
}
|
||||||
|
|
||||||
$addons_admin = [];
|
|
||||||
$addonsAdminStmt = DBA::select('addon', ['name'], ['plugin_admin' => 1], ['order' => ['name']]);
|
|
||||||
foreach (DBA::toArray($addonsAdminStmt) as $addon) {
|
|
||||||
$addons_admin[] = $addon['name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$addons = Addon::getAvailableList();
|
$addons = Addon::getAvailableList();
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
|
$t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
@ -97,15 +98,9 @@ abstract class BaseAdminModule extends BaseModule
|
||||||
]],
|
]],
|
||||||
];
|
];
|
||||||
|
|
||||||
$addons_admin = [];
|
|
||||||
$addonsAdminStmt = DBA::select('addon', ['name'], ['plugin_admin' => 1], ['order' => ['name']]);
|
|
||||||
foreach (DBA::toArray($addonsAdminStmt) as $addon) {
|
|
||||||
$addons_admin[] = ['admin/addons/' . $addon['name'], $addon['name'], 'addon'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('admin/aside.tpl');
|
$t = Renderer::getMarkupTemplate('admin/aside.tpl');
|
||||||
$a->page['aside'] .= Renderer::replaceMacros($t, [
|
$a->page['aside'] .= Renderer::replaceMacros($t, [
|
||||||
'$admin' => ['addons_admin' => $addons_admin],
|
'$admin' => ['addons_admin' => Addon::getAdminList()],
|
||||||
'$subpages' => $aside_sub,
|
'$subpages' => $aside_sub,
|
||||||
'$admtxt' => L10n::t('Admin'),
|
'$admtxt' => L10n::t('Admin'),
|
||||||
'$plugadmtxt' => L10n::t('Addon Features'),
|
'$plugadmtxt' => L10n::t('Addon Features'),
|
||||||
|
|
|
@ -43,9 +43,9 @@
|
||||||
<h3>{{$plugadmtxt}}</h3>
|
<h3>{{$plugadmtxt}}</h3>
|
||||||
<ul role="menu">
|
<ul role="menu">
|
||||||
{{foreach $admin.addons_admin as $name => $item}}
|
{{foreach $admin.addons_admin as $name => $item}}
|
||||||
<li role="menuitem" class="{{$item.2}}">
|
<li role="menuitem" class="{{$item.class}}">
|
||||||
<a href="{{$item.0}}" {{if $item.accesskey}}accesskey="{{$item.accesskey}}"{{/if}}>
|
<a href="{{$item.url}}" {{if $item.accesskey}}accesskey="{{$item.accesskey}}"{{/if}}>
|
||||||
{{$item.1}}
|
{{$item.name}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user