aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-01-31 19:00:13 +0100
committerArthur <arthur@hoa.ro>2016-01-31 19:00:13 +0100
commit53603f582300fc2709932b62652a5acfed088910 (patch)
tree9dbc383bf66cf9881a9b22d2437545740e26f7c1 /index.php
parent893338f0d407a0989454d5e3c0e43c97f7eface5 (diff)
parentdea0ba28f950867532eae572e7bcda49e81bbcf0 (diff)
downloadShaarli-53603f582300fc2709932b62652a5acfed088910.tar.gz
Shaarli-53603f582300fc2709932b62652a5acfed088910.tar.zst
Shaarli-53603f582300fc2709932b62652a5acfed088910.zip
Merge pull request #388 from ArthurHoaro/pluginadmin
Fixes #378 - Plugin administration UI.
Diffstat (limited to 'index.php')
-rw-r--r--index.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/index.php b/index.php
index beba9c32..51b7b391 100644
--- a/index.php
+++ b/index.php
@@ -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;