]> git.mxchange.org Git - friendica.git/blob - src/Module/Admin/Addons/Index.php
Remove deprecated App::query_string - replace with DI::args()->getQueryString()
[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                 // reload active themes
18                 if (!empty($_GET['action'])) {
19                         parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't');
20
21                         switch ($_GET['action']) {
22                                 case 'reload':
23                                         Addon::reload();
24                                         info('Addons reloaded');
25                                         break;
26
27                                 case 'toggle' :
28                                         $addon = $_GET['addon'] ?? '';
29                                         if (Addon::isEnabled($addon)) {
30                                                 Addon::uninstall($addon);
31                                                 info(L10n::t('Addon %s disabled.', $addon));
32                                         } elseif (Addon::install($addon)) {
33                                                 info(L10n::t('Addon %s enabled.', $addon));
34                                         } else {
35                                                 info(L10n::t('Addon %s failed to install.', $addon));
36                                         }
37
38                                         break;
39
40                         }
41
42                         DI::baseUrl()->redirect('admin/addons');
43                 }
44
45                 $addons = Addon::getAvailableList();
46
47                 $t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
48                 return Renderer::replaceMacros($t, [
49                         '$title' => L10n::t('Administration'),
50                         '$page' => L10n::t('Addons'),
51                         '$submit' => L10n::t('Save Settings'),
52                         '$reload' => L10n::t('Reload active addons'),
53                         '$baseurl' => DI::baseUrl()->get(true),
54                         '$function' => 'addons',
55                         '$addons' => $addons,
56                         '$pcount' => count($addons),
57                         '$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'),
58                         '$form_security_token' => parent::getFormSecurityToken('admin_addons'),
59                 ]);
60         }
61 }