]> git.mxchange.org Git - friendica.git/blob - src/Module/Admin/Addons/Index.php
Introduce new DI container
[friendica.git] / src / Module / Admin / Addons / Index.php
1 <?php
2
3 namespace Friendica\Module\Admin\Addons;
4
5 use Friendica\Core\Addon;
6 use Friendica\Core\L10n;
7 use Friendica\Core\Renderer;
8 use Friendica\DI;
9 use Friendica\Module\BaseAdminModule;
10
11 class Index extends BaseAdminModule
12 {
13         public static function content(array $parameters = [])
14         {
15                 parent::content($parameters);
16
17                 $a = DI::app();
18
19                 // reload active themes
20                 if (!empty($_GET['action'])) {
21                         parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't');
22
23                         switch ($_GET['action']) {
24                                 case 'reload':
25                                         Addon::reload();
26                                         info('Addons reloaded');
27                                         break;
28
29                                 case 'toggle' :
30                                         $addon = $_GET['addon'] ?? '';
31                                         if (Addon::isEnabled($addon)) {
32                                                 Addon::uninstall($addon);
33                                                 info(L10n::t('Addon %s disabled.', $addon));
34                                         } elseif (Addon::install($addon)) {
35                                                 info(L10n::t('Addon %s enabled.', $addon));
36                                         } else {
37                                                 info(L10n::t('Addon %s failed to install.', $addon));
38                                         }
39
40                                         break;
41
42                         }
43
44                         $a->internalRedirect('admin/addons');
45                 }
46
47                 $addons = Addon::getAvailableList();
48
49                 $t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
50                 return Renderer::replaceMacros($t, [
51                         '$title' => L10n::t('Administration'),
52                         '$page' => L10n::t('Addons'),
53                         '$submit' => L10n::t('Save Settings'),
54                         '$reload' => L10n::t('Reload active addons'),
55                         '$baseurl' => $a->getBaseURL(true),
56                         '$function' => 'addons',
57                         '$addons' => $addons,
58                         '$pcount' => count($addons),
59                         '$noplugshint' => 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'),
60                         '$form_security_token' => parent::getFormSecurityToken('admin_addons'),
61                 ]);
62         }
63 }