3 namespace Friendica\Module\Admin\Addons;
\r
5 use Friendica\Content\Text\Markdown;
\r
6 use Friendica\Core\Addon;
\r
7 use Friendica\Core\L10n;
\r
8 use Friendica\Core\Renderer;
\r
9 use Friendica\Module\BaseAdminModule;
\r
10 use Friendica\Util\Strings;
\r
12 class Details extends BaseAdminModule
\r
14 public static function post()
\r
18 $a = self::getApp();
\r
21 // @TODO: Replace with parameter from router
\r
22 $addon = $a->argv[2];
\r
23 $addon = Strings::sanitizeFilePathItem($addon);
\r
24 if (is_file('addon/' . $addon . '/' . $addon . '.php')) {
\r
25 include_once 'addon/' . $addon . '/' . $addon . '.php';
\r
26 if (function_exists($addon . '_addon_admin_post')) {
\r
27 $func = $addon . '_addon_admin_post';
\r
31 $a->internalRedirect('admin/addons/' . $addon);
\r
35 $a->internalRedirect('admin/addons');
\r
38 public static function content()
\r
42 $a = self::getApp();
\r
44 $addons_admin = Addon::getAdminList();
\r
47 // @TODO: Replace with parameter from router
\r
48 $addon = $a->argv[2];
\r
49 $addon = Strings::sanitizeFilePathItem($addon);
\r
50 if (!is_file("addon/$addon/$addon.php")) {
\r
51 notice(L10n::t('Item not found.'));
\r
52 $a->internalRedirect('admin/addons');
\r
55 if (defaults($_GET, 'action', '') == 'toggle') {
\r
56 parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't');
\r
58 // Toggle addon status
\r
59 if (Addon::isEnabled($addon)) {
\r
60 Addon::uninstall($addon);
\r
61 info(L10n::t('Addon %s disabled.', $addon));
\r
63 Addon::install($addon);
\r
64 info(L10n::t('Addon %s enabled.', $addon));
\r
67 Addon::saveEnabledList();
\r
69 $a->internalRedirect('admin/addons/' . $addon);
\r
72 // display addon details
\r
73 if (Addon::isEnabled($addon)) {
\r
75 $action = L10n::t('Disable');
\r
78 $action = L10n::t('Enable');
\r
82 if (is_file("addon/$addon/README.md")) {
\r
83 $readme = Markdown::convert(file_get_contents("addon/$addon/README.md"), false);
\r
84 } elseif (is_file("addon/$addon/README")) {
\r
85 $readme = '<pre>' . file_get_contents("addon/$addon/README") . '</pre>';
\r
89 if (array_key_exists($addon, $addons_admin)) {
\r
90 require_once "addon/$addon/$addon.php";
\r
91 $func = $addon . '_addon_admin';
\r
92 $func($a, $admin_form);
\r
95 $t = Renderer::getMarkupTemplate('admin/addons/details.tpl');
\r
97 return Renderer::replaceMacros($t, [
\r
98 '$title' => L10n::t('Administration'),
\r
99 '$page' => L10n::t('Addons'),
\r
100 '$toggle' => L10n::t('Toggle'),
\r
101 '$settings' => L10n::t('Settings'),
\r
102 '$baseurl' => $a->getBaseURL(true),
\r
104 '$addon' => $addon,
\r
105 '$status' => $status,
\r
106 '$action' => $action,
\r
107 '$info' => Addon::getInfo($addon),
\r
108 '$str_author' => L10n::t('Author: '),
\r
109 '$str_maintainer' => L10n::t('Maintainer: '),
\r
111 '$admin_form' => $admin_form,
\r
112 '$function' => 'addons',
\r
113 '$screenshot' => '',
\r
114 '$readme' => $readme,
\r
116 '$form_security_token' => parent::getFormSecurityToken('admin_themes'),
\r
120 $a->internalRedirect('admin/addons');
\r