3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Admin\Addons;
24 use Friendica\Core\Addon;
25 use Friendica\Core\Renderer;
27 use Friendica\Module\BaseAdmin;
29 class Index extends BaseAdmin
31 public static function content(array $parameters = [])
33 parent::content($parameters);
35 // reload active themes
36 if (!empty($_GET['action'])) {
37 parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't');
39 switch ($_GET['action']) {
42 info('Addons reloaded');
46 $addon = $_GET['addon'] ?? '';
47 if (Addon::isEnabled($addon)) {
48 Addon::uninstall($addon);
49 info(DI::l10n()->t('Addon %s disabled.', $addon));
50 } elseif (Addon::install($addon)) {
51 info(DI::l10n()->t('Addon %s enabled.', $addon));
53 notice(DI::l10n()->t('Addon %s failed to install.', $addon));
60 DI::baseUrl()->redirect('admin/addons');
63 $addons = Addon::getAvailableList();
65 $t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
66 return Renderer::replaceMacros($t, [
67 '$title' => DI::l10n()->t('Administration'),
68 '$page' => DI::l10n()->t('Addons'),
69 '$submit' => DI::l10n()->t('Save Settings'),
70 '$reload' => DI::l10n()->t('Reload active addons'),
71 '$baseurl' => DI::baseUrl()->get(true),
72 '$function' => 'addons',
74 '$pcount' => count($addons),
75 '$noplugshint' => DI::l10n()->t('There are currently no addons available on your node. You can find the official addon repository at %1$s and might find other interesting addons in the open addon registry at %2$s', 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'),
76 '$form_security_token' => parent::getFormSecurityToken('admin_addons'),