X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FAdmin%2FAddons%2FDetails.php;h=1fadf6768bbdf670062215c96df925cc87c18e22;hb=6bb418c5a7cdd71d28a8a572059efb14401b70bd;hp=25e538122ce214fa960e52f322a44080139b5f3a;hpb=9f4fb4906af351f56e4527ad8ba457b479c33281;p=friendica.git diff --git a/src/Module/Admin/Addons/Details.php b/src/Module/Admin/Addons/Details.php index 25e538122c..1fadf6768b 100644 --- a/src/Module/Admin/Addons/Details.php +++ b/src/Module/Admin/Addons/Details.php @@ -1,122 +1,123 @@ -argc > 2) { - // @TODO: Replace with parameter from router - $addon = $a->argv[2]; - $addon = Strings::sanitizeFilePathItem($addon); - if (is_file('addon/' . $addon . '/' . $addon . '.php')) { - include_once 'addon/' . $addon . '/' . $addon . '.php'; - if (function_exists($addon . '_addon_admin_post')) { - $func = $addon . '_addon_admin_post'; - $func($a); - } - - $a->internalRedirect('admin/addons/' . $addon); - } - } - - $a->internalRedirect('admin/addons'); - } - - public static function content() - { - parent::content(); - - $a = self::getApp(); - - $addons_admin = Addon::getAdminList(); - - if ($a->argc > 2) { - // @TODO: Replace with parameter from router - $addon = $a->argv[2]; - $addon = Strings::sanitizeFilePathItem($addon); - if (!is_file("addon/$addon/$addon.php")) { - notice(L10n::t('Item not found.')); - $a->internalRedirect('admin/addons'); - } - - if (defaults($_GET, 'action', '') == 'toggle') { - parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't'); - - // Toggle addon status - if (Addon::isEnabled($addon)) { - Addon::uninstall($addon); - info(L10n::t('Addon %s disabled.', $addon)); - } else { - Addon::install($addon); - info(L10n::t('Addon %s enabled.', $addon)); - } - - Addon::saveEnabledList(); - - $a->internalRedirect('admin/addons/' . $addon); - } - - // display addon details - if (Addon::isEnabled($addon)) { - $status = 'on'; - $action = L10n::t('Disable'); - } else { - $status = 'off'; - $action = L10n::t('Enable'); - } - - $readme = null; - if (is_file("addon/$addon/README.md")) { - $readme = Markdown::convert(file_get_contents("addon/$addon/README.md"), false); - } elseif (is_file("addon/$addon/README")) { - $readme = '
' . file_get_contents("addon/$addon/README") . ''; - } - - $admin_form = ''; - if (array_key_exists($addon, $addons_admin)) { - require_once "addon/$addon/$addon.php"; - $func = $addon . '_addon_admin'; - $func($a, $admin_form); - } - - $t = Renderer::getMarkupTemplate('admin/addons/details.tpl'); - - return Renderer::replaceMacros($t, [ - '$title' => L10n::t('Administration'), - '$page' => L10n::t('Addons'), - '$toggle' => L10n::t('Toggle'), - '$settings' => L10n::t('Settings'), - '$baseurl' => $a->getBaseURL(true), - - '$addon' => $addon, - '$status' => $status, - '$action' => $action, - '$info' => Addon::getInfo($addon), - '$str_author' => L10n::t('Author: '), - '$str_maintainer' => L10n::t('Maintainer: '), - - '$admin_form' => $admin_form, - '$function' => 'addons', - '$screenshot' => '', - '$readme' => $readme, - - '$form_security_token' => parent::getFormSecurityToken('admin_themes'), - ]); - } - - $a->internalRedirect('admin/addons'); - } -} +argc > 2) { + // @TODO: Replace with parameter from router + $addon = $a->argv[2]; + $addon = Strings::sanitizeFilePathItem($addon); + if (is_file('addon/' . $addon . '/' . $addon . '.php')) { + include_once 'addon/' . $addon . '/' . $addon . '.php'; + if (function_exists($addon . '_addon_admin_post')) { + $func = $addon . '_addon_admin_post'; + $func($a); + } + + $a->internalRedirect('admin/addons/' . $addon); + } + } + + $a->internalRedirect('admin/addons'); + } + + public static function content() + { + parent::content(); + + $a = self::getApp(); + + $addons_admin = Addon::getAdminList(); + + if ($a->argc > 2) { + // @TODO: Replace with parameter from router + $addon = $a->argv[2]; + $addon = Strings::sanitizeFilePathItem($addon); + if (!is_file("addon/$addon/$addon.php")) { + notice(L10n::t('Addon not found.')); + Addon::uninstall($addon); + $a->internalRedirect('admin/addons'); + } + + if (defaults($_GET, 'action', '') == 'toggle') { + parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_themes', 't'); + + // Toggle addon status + if (Addon::isEnabled($addon)) { + Addon::uninstall($addon); + info(L10n::t('Addon %s disabled.', $addon)); + } else { + Addon::install($addon); + info(L10n::t('Addon %s enabled.', $addon)); + } + + Addon::saveEnabledList(); + + $a->internalRedirect('admin/addons/' . $addon); + } + + // display addon details + if (Addon::isEnabled($addon)) { + $status = 'on'; + $action = L10n::t('Disable'); + } else { + $status = 'off'; + $action = L10n::t('Enable'); + } + + $readme = null; + if (is_file("addon/$addon/README.md")) { + $readme = Markdown::convert(file_get_contents("addon/$addon/README.md"), false); + } elseif (is_file("addon/$addon/README")) { + $readme = '
' . file_get_contents("addon/$addon/README") . ''; + } + + $admin_form = ''; + if (array_key_exists($addon, $addons_admin)) { + require_once "addon/$addon/$addon.php"; + $func = $addon . '_addon_admin'; + $func($a, $admin_form); + } + + $t = Renderer::getMarkupTemplate('admin/addons/details.tpl'); + + return Renderer::replaceMacros($t, [ + '$title' => L10n::t('Administration'), + '$page' => L10n::t('Addons'), + '$toggle' => L10n::t('Toggle'), + '$settings' => L10n::t('Settings'), + '$baseurl' => $a->getBaseURL(true), + + '$addon' => $addon, + '$status' => $status, + '$action' => $action, + '$info' => Addon::getInfo($addon), + '$str_author' => L10n::t('Author: '), + '$str_maintainer' => L10n::t('Maintainer: '), + + '$admin_form' => $admin_form, + '$function' => 'addons', + '$screenshot' => '', + '$readme' => $readme, + + '$form_security_token' => parent::getFormSecurityToken('admin_themes'), + ]); + } + + $a->internalRedirect('admin/addons'); + } +}