*/
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()
{
$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:
*
use Friendica\Core\Addon;\r
use Friendica\Core\L10n;\r
use Friendica\Core\Renderer;\r
-use Friendica\Database\DBA;\r
use Friendica\Module\BaseAdminModule;\r
use Friendica\Util\Strings;\r
\r
\r
$a = self::getApp();\r
\r
- $addons_admin = [];\r
- $addonsAdminStmt = DBA::select('addon', ['name'], ['plugin_admin' => 1], ['order' => ['name']]);\r
- foreach (DBA::toArray($addonsAdminStmt) as $addon) {\r
- $addonName = $addon['name'];\r
- // temp addons with admin\r
- $addons_admin[] = $addonName;\r
- }\r
+ $addons_admin = Addon::getAdminList();\r
\r
if ($a->argc > 2) {\r
// @TODO: Replace with parameter from router\r
}\r
\r
$admin_form = '';\r
- if (in_array($addon, $addons_admin)) {\r
+ if (array_key_exists($addon, $addons_admin)) {\r
require_once "addon/$addon/$addon.php";\r
$func = $addon . '_addon_admin';\r
$func($a, $admin_form);\r
\r
$a->internalRedirect('admin/addons');\r
}\r
-}
\ No newline at end of file
+}\r
\r
namespace Friendica\Module\Admin\Addons;\r
\r
-use Friendica\Content\Text\Markdown;\r
use Friendica\Core\Addon;\r
-use Friendica\Core\Config;\r
use Friendica\Core\L10n;\r
use Friendica\Core\Renderer;\r
-use Friendica\Database\DBA;\r
use Friendica\Module\BaseAdminModule;\r
\r
class Index extends BaseAdminModule\r
$a->internalRedirect('admin/addons');\r
}\r
\r
- $addons_admin = [];\r
- $addonsAdminStmt = DBA::select('addon', ['name'], ['plugin_admin' => 1], ['order' => ['name']]);\r
- foreach (DBA::toArray($addonsAdminStmt) as $addon) {\r
- $addons_admin[] = $addon['name'];\r
- }\r
-\r
$addons = Addon::getAvailableList();\r
\r
$t = Renderer::getMarkupTemplate('admin/addons/index.tpl');\r
namespace Friendica\Module;\r
\r
use Friendica\BaseModule;\r
+use Friendica\Core\Addon;\r
use Friendica\Core\L10n;\r
use Friendica\Core\Renderer;\r
use Friendica\Core\System;\r
]],\r
];\r
\r
- $addons_admin = [];\r
- $addonsAdminStmt = DBA::select('addon', ['name'], ['plugin_admin' => 1], ['order' => ['name']]);\r
- foreach (DBA::toArray($addonsAdminStmt) as $addon) {\r
- $addons_admin[] = ['admin/addons/' . $addon['name'], $addon['name'], 'addon'];\r
- }\r
-\r
$t = Renderer::getMarkupTemplate('admin/aside.tpl');\r
$a->page['aside'] .= Renderer::replaceMacros($t, [\r
- '$admin' => ['addons_admin' => $addons_admin],\r
+ '$admin' => ['addons_admin' => Addon::getAdminList()],\r
'$subpages' => $aside_sub,\r
'$admtxt' => L10n::t('Admin'),\r
'$plugadmtxt' => L10n::t('Addon Features'),\r
<h3>{{$plugadmtxt}}</h3>
<ul role="menu">
{{foreach $admin.addons_admin as $name => $item}}
- <li role="menuitem" class="{{$item.2}}">
- <a href="{{$item.0}}" {{if $item.accesskey}}accesskey="{{$item.accesskey}}"{{/if}}>
- {{$item.1}}
+ <li role="menuitem" class="{{$item.class}}">
+ <a href="{{$item.url}}" {{if $item.accesskey}}accesskey="{{$item.accesskey}}"{{/if}}>
+ {{$item.name}}
</a>
</li>
{{/foreach}}