aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php31
1 files changed, 2 insertions, 29 deletions
diff --git a/index.php b/index.php
index 04ec0d73..c0e0c66d 100644
--- a/index.php
+++ b/index.php
@@ -451,35 +451,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
451 451
452 // -------- User clicks on a tag in result count: Remove the tag from the list of searched tags (searchtags=...) 452 // -------- User clicks on a tag in result count: Remove the tag from the list of searched tags (searchtags=...)
453 if (isset($_GET['removetag'])) { 453 if (isset($_GET['removetag'])) {
454 // Get previous URL (http_referer) and remove the tag from the searchtags parameters in query. 454 header('Location: ./remove-tag/'. $_GET['removetag']);
455 if (empty($_SERVER['HTTP_REFERER'])) {
456 header('Location: ?');
457 exit;
458 }
459
460 // In case browser does not send HTTP_REFERER
461 parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $params);
462
463 // Prevent redirection loop
464 if (isset($params['removetag'])) {
465 unset($params['removetag']);
466 }
467
468 if (isset($params['searchtags'])) {
469 $tags = explode(' ', $params['searchtags']);
470 // Remove value from array $tags.
471 $tags = array_diff($tags, array($_GET['removetag']));
472 $params['searchtags'] = implode(' ', $tags);
473
474 if (empty($params['searchtags'])) {
475 unset($params['searchtags']);
476 }
477
478 // We also remove page (keeping the same page has no sense, since
479 // the results are different)
480 unset($params['page']);
481 }
482 header('Location: ?'.http_build_query($params));
483 exit; 455 exit;
484 } 456 }
485 457
@@ -1576,6 +1548,7 @@ $app->group('', function () {
1576 $this->get('/open-search', '\Shaarli\Front\Controller\OpenSearchController:index')->setName('opensearch'); 1548 $this->get('/open-search', '\Shaarli\Front\Controller\OpenSearchController:index')->setName('opensearch');
1577 1549
1578 $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag'); 1550 $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag');
1551 $this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\TagController:removeTag')->setName('remove-tag');
1579})->add('\Shaarli\Front\ShaarliMiddleware'); 1552})->add('\Shaarli\Front\ShaarliMiddleware');
1580 1553
1581$response = $app->run(true); 1554$response = $app->run(true);