aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php24
1 files changed, 11 insertions, 13 deletions
diff --git a/index.php b/index.php
index cddc9eeb..ab1e30da 100644
--- a/index.php
+++ b/index.php
@@ -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 */
710function renderPage($conf, $pluginManager, $LINKSDB) 710function 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,13 +728,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
728 die($e->getMessage()); 728 die($e->getMessage());
729 } 729 }
730 730
731 try { 731 $PAGE = new PageBuilder($conf, $LINKSDB);
732 $history = new History($conf->get('resource.history'));
733 } catch(Exception $e) {
734 die($e->getMessage());
735 }
736
737 $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));
740 $PAGE->assign('plugin_errors', $pluginManager->getErrors()); 734 $PAGE->assign('plugin_errors', $pluginManager->getErrors());
@@ -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 }
@@ -1177,7 +1170,6 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1177 if ($targetPage == Router::$PAGE_CHANGETAG) 1170 if ($targetPage == Router::$PAGE_CHANGETAG)
1178 { 1171 {
1179 if (empty($_POST['fromtag']) || (empty($_POST['totag']) && isset($_POST['renametag']))) { 1172 if (empty($_POST['fromtag']) || (empty($_POST['totag']) && isset($_POST['renametag']))) {
1180 $PAGE->assign('tags', $LINKSDB->allTags());
1181 $PAGE->renderPage('changetag'); 1173 $PAGE->renderPage('changetag');
1182 exit; 1174 exit;
1183 } 1175 }
@@ -1578,7 +1570,6 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1578 1570
1579 // Plugin administration form action 1571 // Plugin administration form action
1580 if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) { 1572 if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) {
1581 $history->updateSettings();
1582 try { 1573 try {
1583 if (isset($_POST['parameters_form'])) { 1574 if (isset($_POST['parameters_form'])) {
1584 unset($_POST['parameters_form']); 1575 unset($_POST['parameters_form']);
@@ -1590,6 +1581,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1590 $conf->set('general.enabled_plugins', save_plugin_config($_POST)); 1581 $conf->set('general.enabled_plugins', save_plugin_config($_POST));
1591 } 1582 }
1592 $conf->write(isLoggedIn()); 1583 $conf->write(isLoggedIn());
1584 $history->updateSettings();
1593 } 1585 }
1594 catch (Exception $e) { 1586 catch (Exception $e) {
1595 error_log( 1587 error_log(
@@ -1707,7 +1699,6 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1707 'visibility' => ! empty($_SESSION['privateonly']) ? 'private' : '', 1699 'visibility' => ! empty($_SESSION['privateonly']) ? 'private' : '',
1708 'redirector' => $conf->get('redirector.url'), // Optional redirector URL. 1700 'redirector' => $conf->get('redirector.url'), // Optional redirector URL.
1709 'links' => $linkDisp, 1701 'links' => $linkDisp,
1710 'tags' => $LINKSDB->allTags(),
1711 ); 1702 );
1712 1703
1713 // If there is only a single link, we change on-the-fly the title of the page. 1704 // If there is only a single link, we change on-the-fly the title of the page.
@@ -2240,9 +2231,16 @@ $linkDb = new LinkDB(
2240 $conf->get('redirector.encode_url') 2231 $conf->get('redirector.encode_url')
2241); 2232);
2242 2233
2234try {
2235 $history = new History($conf->get('resource.history'));
2236} catch(Exception $e) {
2237 die($e->getMessage());
2238}
2239
2243$container = new \Slim\Container(); 2240$container = new \Slim\Container();
2244$container['conf'] = $conf; 2241$container['conf'] = $conf;
2245$container['plugins'] = $pluginManager; 2242$container['plugins'] = $pluginManager;
2243$container['history'] = $history;
2246$app = new \Slim\App($container); 2244$app = new \Slim\App($container);
2247 2245
2248// REST API routes 2246// REST API routes
@@ -2262,7 +2260,7 @@ $response = $app->run(true);
2262if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { 2260if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) {
2263 // We use UTF-8 for proper international characters handling. 2261 // We use UTF-8 for proper international characters handling.
2264 header('Content-Type: text/html; charset=utf-8'); 2262 header('Content-Type: text/html; charset=utf-8');
2265 renderPage($conf, $pluginManager, $linkDb); 2263 renderPage($conf, $pluginManager, $linkDb, $history);
2266} else { 2264} else {
2267 $app->respond($response); 2265 $app->respond($response);
2268} 2266}