X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=index.php;h=ba1c2b2b4618a31a8a4054f6a622bb635363829d;hb=3108f2a8008280f857f56db50d6f0145d680b142;hp=76aa1ae0efbc1c9d5945b34b29c23ae576b06e34;hpb=eb6e729808e1c3d9787ad1183aa61ab2e375a537;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 76aa1ae0..ba1c2b2b 100644 --- a/index.php +++ b/index.php @@ -707,7 +707,7 @@ function showLinkList($PAGE, $LINKSDB, $conf, $pluginManager) { * @param PluginManager $pluginManager Plugin Manager instance, * @param LinkDB $LINKSDB */ -function renderPage($conf, $pluginManager, $LINKSDB) +function renderPage($conf, $pluginManager, $LINKSDB, $history) { $updater = new Updater( read_updates_file($conf->get('resource.updates')), @@ -728,12 +728,6 @@ function renderPage($conf, $pluginManager, $LINKSDB) die($e->getMessage()); } - try { - $history = new History($conf->get('resource.history')); - } catch(Exception $e) { - die($e->getMessage()); - } - $PAGE = new PageBuilder($conf); $PAGE->assign('linkcount', count($LINKSDB)); $PAGE->assign('privateLinkcount', count_private($LINKSDB)); @@ -1167,7 +1161,6 @@ function renderPage($conf, $pluginManager, $LINKSDB) $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false)); $PAGE->assign('api_enabled', $conf->get('api.enabled', true)); $PAGE->assign('api_secret', $conf->get('api.secret')); - $history->updateSettings(); $PAGE->renderPage('configure'); exit; } @@ -1578,7 +1571,6 @@ function renderPage($conf, $pluginManager, $LINKSDB) // Plugin administration form action if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { - $history->updateSettings(); try { if (isset($_POST['parameters_form'])) { unset($_POST['parameters_form']); @@ -1590,6 +1582,7 @@ function renderPage($conf, $pluginManager, $LINKSDB) $conf->set('general.enabled_plugins', save_plugin_config($_POST)); } $conf->write(isLoggedIn()); + $history->updateSettings(); } catch (Exception $e) { error_log( @@ -2240,9 +2233,16 @@ $linkDb = new LinkDB( $conf->get('redirector.encode_url') ); +try { + $history = new History($conf->get('resource.history')); +} catch(Exception $e) { + die($e->getMessage()); +} + $container = new \Slim\Container(); $container['conf'] = $conf; $container['plugins'] = $pluginManager; +$container['history'] = $history; $app = new \Slim\App($container); // REST API routes @@ -2251,6 +2251,9 @@ $app->group('/api/v1', function() { $this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks')->setName('getLinks'); $this->get('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:getLink')->setName('getLink'); $this->post('/links', '\Shaarli\Api\Controllers\Links:postLink')->setName('postLink'); + $this->put('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:putLink')->setName('putLink'); + $this->delete('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:deleteLink')->setName('deleteLink'); + $this->get('/history', '\Shaarli\Api\Controllers\History:getHistory')->setName('getHistory'); })->add('\Shaarli\Api\ApiMiddleware'); $response = $app->run(true); @@ -2259,7 +2262,7 @@ $response = $app->run(true); if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { // We use UTF-8 for proper international characters handling. header('Content-Type: text/html; charset=utf-8'); - renderPage($conf, $pluginManager, $linkDb); + renderPage($conf, $pluginManager, $linkDb, $history); } else { $app->respond($response); }