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