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