diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-05-07 17:40:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-07 17:40:17 +0200 |
commit | b4189928f84758e1589715dfe04e2d966a4f3b88 (patch) | |
tree | f17b8fa91fe8244fed7a913d64ce3220551916ff /index.php | |
parent | a4af59f47103a3f9c903eeddb1e30ab9cb7344f0 (diff) | |
parent | b86aeccf6a99a9617c66cded7252a33b1df560cd (diff) | |
download | Shaarli-b4189928f84758e1589715dfe04e2d966a4f3b88.tar.gz Shaarli-b4189928f84758e1589715dfe04e2d966a4f3b88.tar.zst Shaarli-b4189928f84758e1589715dfe04e2d966a4f3b88.zip |
Merge pull request #858 from ArthurHoaro/api/history-entries
Add history entries for API endpoint
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -707,7 +707,7 @@ function showLinkList($PAGE, $LINKSDB, $conf, $pluginManager) { | |||
707 | * @param PluginManager $pluginManager Plugin Manager instance, | 707 | * @param PluginManager $pluginManager Plugin Manager instance, |
708 | * @param LinkDB $LINKSDB | 708 | * @param LinkDB $LINKSDB |
709 | */ | 709 | */ |
710 | function renderPage($conf, $pluginManager, $LINKSDB) | 710 | function renderPage($conf, $pluginManager, $LINKSDB, $history) |
711 | { | 711 | { |
712 | $updater = new Updater( | 712 | $updater = new Updater( |
713 | read_updates_file($conf->get('resource.updates')), | 713 | read_updates_file($conf->get('resource.updates')), |
@@ -728,12 +728,6 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
728 | die($e->getMessage()); | 728 | die($e->getMessage()); |
729 | } | 729 | } |
730 | 730 | ||
731 | try { | ||
732 | $history = new History($conf->get('resource.history')); | ||
733 | } catch(Exception $e) { | ||
734 | die($e->getMessage()); | ||
735 | } | ||
736 | |||
737 | $PAGE = new PageBuilder($conf); | 731 | $PAGE = new PageBuilder($conf); |
738 | $PAGE->assign('linkcount', count($LINKSDB)); | 732 | $PAGE->assign('linkcount', count($LINKSDB)); |
739 | $PAGE->assign('privateLinkcount', count_private($LINKSDB)); | 733 | $PAGE->assign('privateLinkcount', count_private($LINKSDB)); |
@@ -1167,7 +1161,6 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1167 | $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false)); | 1161 | $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false)); |
1168 | $PAGE->assign('api_enabled', $conf->get('api.enabled', true)); | 1162 | $PAGE->assign('api_enabled', $conf->get('api.enabled', true)); |
1169 | $PAGE->assign('api_secret', $conf->get('api.secret')); | 1163 | $PAGE->assign('api_secret', $conf->get('api.secret')); |
1170 | $history->updateSettings(); | ||
1171 | $PAGE->renderPage('configure'); | 1164 | $PAGE->renderPage('configure'); |
1172 | exit; | 1165 | exit; |
1173 | } | 1166 | } |
@@ -1578,7 +1571,6 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1578 | 1571 | ||
1579 | // Plugin administration form action | 1572 | // Plugin administration form action |
1580 | if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { | 1573 | if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { |
1581 | $history->updateSettings(); | ||
1582 | try { | 1574 | try { |
1583 | if (isset($_POST['parameters_form'])) { | 1575 | if (isset($_POST['parameters_form'])) { |
1584 | unset($_POST['parameters_form']); | 1576 | unset($_POST['parameters_form']); |
@@ -1590,6 +1582,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) | |||
1590 | $conf->set('general.enabled_plugins', save_plugin_config($_POST)); | 1582 | $conf->set('general.enabled_plugins', save_plugin_config($_POST)); |
1591 | } | 1583 | } |
1592 | $conf->write(isLoggedIn()); | 1584 | $conf->write(isLoggedIn()); |
1585 | $history->updateSettings(); | ||
1593 | } | 1586 | } |
1594 | catch (Exception $e) { | 1587 | catch (Exception $e) { |
1595 | error_log( | 1588 | error_log( |
@@ -2240,9 +2233,16 @@ $linkDb = new LinkDB( | |||
2240 | $conf->get('redirector.encode_url') | 2233 | $conf->get('redirector.encode_url') |
2241 | ); | 2234 | ); |
2242 | 2235 | ||
2236 | try { | ||
2237 | $history = new History($conf->get('resource.history')); | ||
2238 | } catch(Exception $e) { | ||
2239 | die($e->getMessage()); | ||
2240 | } | ||
2241 | |||
2243 | $container = new \Slim\Container(); | 2242 | $container = new \Slim\Container(); |
2244 | $container['conf'] = $conf; | 2243 | $container['conf'] = $conf; |
2245 | $container['plugins'] = $pluginManager; | 2244 | $container['plugins'] = $pluginManager; |
2245 | $container['history'] = $history; | ||
2246 | $app = new \Slim\App($container); | 2246 | $app = new \Slim\App($container); |
2247 | 2247 | ||
2248 | // REST API routes | 2248 | // REST API routes |
@@ -2262,7 +2262,7 @@ $response = $app->run(true); | |||
2262 | if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { | 2262 | if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { |
2263 | // We use UTF-8 for proper international characters handling. | 2263 | // We use UTF-8 for proper international characters handling. |
2264 | header('Content-Type: text/html; charset=utf-8'); | 2264 | header('Content-Type: text/html; charset=utf-8'); |
2265 | renderPage($conf, $pluginManager, $linkDb); | 2265 | renderPage($conf, $pluginManager, $linkDb, $history); |
2266 | } else { | 2266 | } else { |
2267 | $app->respond($response); | 2267 | $app->respond($response); |
2268 | } | 2268 | } |