diff options
author | ArthurHoaro <arthur@hoa.ro> | 2015-11-18 17:40:42 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-01-31 18:54:48 +0100 |
commit | dea0ba28f950867532eae572e7bcda49e81bbcf0 (patch) | |
tree | 8a9c4f9d7525a2ba249bbaaabe456c2d0941293b /index.php | |
parent | 423e2a8b13dc0069c83f3e540f576aa1b89fe5d5 (diff) | |
download | Shaarli-dea0ba28f950867532eae572e7bcda49e81bbcf0.tar.gz Shaarli-dea0ba28f950867532eae572e7bcda49e81bbcf0.tar.zst Shaarli-dea0ba28f950867532eae572e7bcda49e81bbcf0.zip |
Fixes #378 - Plugin administration UI.
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -1770,6 +1770,54 @@ HTML; | |||
1770 | exit; | 1770 | exit; |
1771 | } | 1771 | } |
1772 | 1772 | ||
1773 | // Plugin administration page | ||
1774 | if ($targetPage == Router::$PAGE_PLUGINSADMIN) { | ||
1775 | $pluginMeta = $pluginManager->getPluginsMeta(); | ||
1776 | |||
1777 | // Split plugins into 2 arrays: ordered enabled plugins and disabled. | ||
1778 | $enabledPlugins = array_filter($pluginMeta, function($v) { return $v['order'] !== false; }); | ||
1779 | // Load parameters. | ||
1780 | $enabledPlugins = load_plugin_parameter_values($enabledPlugins, $GLOBALS['plugins']); | ||
1781 | uasort( | ||
1782 | $enabledPlugins, | ||
1783 | function($a, $b) { return $a['order'] - $b['order']; } | ||
1784 | ); | ||
1785 | $disabledPlugins = array_filter($pluginMeta, function($v) { return $v['order'] === false; }); | ||
1786 | |||
1787 | $PAGE->assign('enabledPlugins', $enabledPlugins); | ||
1788 | $PAGE->assign('disabledPlugins', $disabledPlugins); | ||
1789 | $PAGE->renderPage('pluginsadmin'); | ||
1790 | exit; | ||
1791 | } | ||
1792 | |||
1793 | // Plugin administration form action | ||
1794 | if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { | ||
1795 | try { | ||
1796 | if (isset($_POST['parameters_form'])) { | ||
1797 | unset($_POST['parameters_form']); | ||
1798 | foreach ($_POST as $param => $value) { | ||
1799 | $GLOBALS['plugins'][$param] = escape($value); | ||
1800 | } | ||
1801 | } | ||
1802 | else { | ||
1803 | $GLOBALS['config']['ENABLED_PLUGINS'] = save_plugin_config($_POST); | ||
1804 | } | ||
1805 | writeConfig($GLOBALS, isLoggedIn()); | ||
1806 | } | ||
1807 | catch (Exception $e) { | ||
1808 | error_log( | ||
1809 | 'ERROR while saving plugin configuration:.' . PHP_EOL . | ||
1810 | $e->getMessage() | ||
1811 | ); | ||
1812 | |||
1813 | // TODO: do not handle exceptions/errors in JS. | ||
1814 | echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do=pluginsadmin\';</script>'; | ||
1815 | exit; | ||
1816 | } | ||
1817 | header('Location: ?do='. Router::$PAGE_PLUGINSADMIN); | ||
1818 | exit; | ||
1819 | } | ||
1820 | |||
1773 | // -------- Otherwise, simply display search form and links: | 1821 | // -------- Otherwise, simply display search form and links: |
1774 | showLinkList($PAGE, $LINKSDB); | 1822 | showLinkList($PAGE, $LINKSDB); |
1775 | exit; | 1823 | exit; |