aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-01-18 17:59:37 +0100
committerGitHub <noreply@github.com>2020-01-18 17:59:37 +0100
commit1001cc108fec759b076c9f6e12b71dea5d49fe9b (patch)
treed7b57a982129b2006d388c2f9d25d29eceee891a /index.php
parent12523aea3458504be91854ce2f37d4f5991ccea2 (diff)
parenta39acb2518f272df8a601af72c13eabe2719dcb8 (diff)
downloadShaarli-1001cc108fec759b076c9f6e12b71dea5d49fe9b.tar.gz
Shaarli-1001cc108fec759b076c9f6e12b71dea5d49fe9b.tar.zst
Shaarli-1001cc108fec759b076c9f6e12b71dea5d49fe9b.zip
Fix an issue with private tags and fix nomarkdown tag (#1399)
Fix an issue with private tags and fix nomarkdown tag
Diffstat (limited to 'index.php')
-rw-r--r--index.php39
1 files changed, 24 insertions, 15 deletions
diff --git a/index.php b/index.php
index 013b01af..a39fc762 100644
--- a/index.php
+++ b/index.php
@@ -70,6 +70,7 @@ use Shaarli\Bookmark\BookmarkFileService;
70use \Shaarli\Config\ConfigManager; 70use \Shaarli\Config\ConfigManager;
71use \Shaarli\Feed\CachedPage; 71use \Shaarli\Feed\CachedPage;
72use \Shaarli\Feed\FeedBuilder; 72use \Shaarli\Feed\FeedBuilder;
73use Shaarli\Formatter\BookmarkMarkdownFormatter;
73use Shaarli\Formatter\FormatterFactory; 74use Shaarli\Formatter\FormatterFactory;
74use \Shaarli\History; 75use \Shaarli\History;
75use \Shaarli\Languages; 76use \Shaarli\Languages;
@@ -351,7 +352,7 @@ function showDailyRSS($bookmarkService, $conf, $loginManager)
351 echo '<language>en-en</language>'; 352 echo '<language>en-en</language>';
352 echo '<copyright>'. $pageaddr .'</copyright>'. PHP_EOL; 353 echo '<copyright>'. $pageaddr .'</copyright>'. PHP_EOL;
353 354
354 $factory = new FormatterFactory($conf); 355 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
355 $formatter = $factory->getFormatter(); 356 $formatter = $factory->getFormatter();
356 $formatter->addContextData('index_url', index_url($_SERVER)); 357 $formatter->addContextData('index_url', index_url($_SERVER));
357 // For each day. 358 // For each day.
@@ -441,7 +442,7 @@ function showDaily($pageBuilder, $bookmarkService, $conf, $pluginManager, $login
441 $linksToDisplay = []; 442 $linksToDisplay = [];
442 } 443 }
443 444
444 $factory = new FormatterFactory($conf); 445 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
445 $formatter = $factory->getFormatter(); 446 $formatter = $factory->getFormatter();
446 // We pre-format some fields for proper output. 447 // We pre-format some fields for proper output.
447 foreach ($linksToDisplay as $key => $bookmark) { 448 foreach ($linksToDisplay as $key => $bookmark) {
@@ -630,7 +631,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
630 631
631 // Get only bookmarks which have a thumbnail. 632 // Get only bookmarks which have a thumbnail.
632 // Note: we do not retrieve thumbnails here, the request is too heavy. 633 // Note: we do not retrieve thumbnails here, the request is too heavy.
633 $factory = new FormatterFactory($conf); 634 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
634 $formatter = $factory->getFormatter(); 635 $formatter = $factory->getFormatter();
635 foreach ($links as $key => $link) { 636 foreach ($links as $key => $link) {
636 if ($link->getThumbnail() !== false) { 637 if ($link->getThumbnail() !== false) {
@@ -753,7 +754,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
753 exit; 754 exit;
754 } 755 }
755 756
756 $factory = new FormatterFactory($conf); 757 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
757 // Generate data. 758 // Generate data.
758 $feedGenerator = new FeedBuilder( 759 $feedGenerator = new FeedBuilder(
759 $bookmarkService, 760 $bookmarkService,
@@ -1183,7 +1184,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1183 $bookmarkService->addOrSet($bookmark, false); 1184 $bookmarkService->addOrSet($bookmark, false);
1184 1185
1185 // To preserve backward compatibility with 3rd parties, plugins still use arrays 1186 // To preserve backward compatibility with 3rd parties, plugins still use arrays
1186 $factory = new FormatterFactory($conf); 1187 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1187 $formatter = $factory->getFormatter('raw'); 1188 $formatter = $factory->getFormatter('raw');
1188 $data = $formatter->format($bookmark); 1189 $data = $formatter->format($bookmark);
1189 $pluginManager->executeHooks('save_link', $data); 1190 $pluginManager->executeHooks('save_link', $data);
@@ -1230,7 +1231,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1230 if (!count($ids)) { 1231 if (!count($ids)) {
1231 die('no id provided'); 1232 die('no id provided');
1232 } 1233 }
1233 $factory = new FormatterFactory($conf); 1234 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1234 $formatter = $factory->getFormatter('raw'); 1235 $formatter = $factory->getFormatter('raw');
1235 foreach ($ids as $id) { 1236 foreach ($ids as $id) {
1236 $id = (int) escape($id); 1237 $id = (int) escape($id);
@@ -1286,7 +1287,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1286 } else { 1287 } else {
1287 $private = $_GET['newVisibility'] === 'private'; 1288 $private = $_GET['newVisibility'] === 'private';
1288 } 1289 }
1289 $factory = new FormatterFactory($conf); 1290 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1290 $formatter = $factory->getFormatter('raw'); 1291 $formatter = $factory->getFormatter('raw');
1291 foreach ($ids as $id) { 1292 foreach ($ids as $id) {
1292 $id = (int) escape($id); 1293 $id = (int) escape($id);
@@ -1324,14 +1325,18 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1324 exit; 1325 exit;
1325 } 1326 }
1326 1327
1327 $factory = new FormatterFactory($conf); 1328 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1328 $formatter = $factory->getFormatter('raw'); 1329 $formatter = $factory->getFormatter('raw');
1329 $formattedLink = $formatter->format($link); 1330 $formattedLink = $formatter->format($link);
1331 $tags = $bookmarkService->bookmarksCountPerTag();
1332 if ($conf->get('formatter') === 'markdown') {
1333 $tags[BookmarkMarkdownFormatter::NO_MD_TAG] = 1;
1334 }
1330 $data = array( 1335 $data = array(
1331 'link' => $formattedLink, 1336 'link' => $formattedLink,
1332 'link_is_new' => false, 1337 'link_is_new' => false,
1333 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''), 1338 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
1334 'tags' => $bookmarkService->bookmarksCountPerTag(), 1339 'tags' => $tags,
1335 ); 1340 );
1336 $pluginManager->executeHooks('render_editlink', $data); 1341 $pluginManager->executeHooks('render_editlink', $data);
1337 1342
@@ -1391,17 +1396,21 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1391 'private' => $private, 1396 'private' => $private,
1392 ]; 1397 ];
1393 } else { 1398 } else {
1394 $factory = new FormatterFactory($conf); 1399 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1395 $formatter = $factory->getFormatter('raw'); 1400 $formatter = $factory->getFormatter('raw');
1396 $link = $formatter->format($bookmark); 1401 $link = $formatter->format($bookmark);
1397 } 1402 }
1398 1403
1404 $tags = $bookmarkService->bookmarksCountPerTag();
1405 if ($conf->get('formatter') === 'markdown') {
1406 $tags[BookmarkMarkdownFormatter::NO_MD_TAG] = 1;
1407 }
1399 $data = [ 1408 $data = [
1400 'link' => $link, 1409 'link' => $link,
1401 'link_is_new' => $link_is_new, 1410 'link_is_new' => $link_is_new,
1402 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''), 1411 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
1403 'source' => (isset($_GET['source']) ? $_GET['source'] : ''), 1412 'source' => (isset($_GET['source']) ? $_GET['source'] : ''),
1404 'tags' => $bookmarkService->bookmarksCountPerTag(), 1413 'tags' => $tags,
1405 'default_private_links' => $conf->get('privacy.default_private_links', false), 1414 'default_private_links' => $conf->get('privacy.default_private_links', false),
1406 ]; 1415 ];
1407 $pluginManager->executeHooks('render_editlink', $data); 1416 $pluginManager->executeHooks('render_editlink', $data);
@@ -1451,7 +1460,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1451 } 1460 }
1452 1461
1453 try { 1462 try {
1454 $factory = new FormatterFactory($conf); 1463 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1455 $formatter = $factory->getFormatter('raw'); 1464 $formatter = $factory->getFormatter('raw');
1456 $PAGE->assign( 1465 $PAGE->assign(
1457 'links', 1466 'links',
@@ -1633,7 +1642,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1633 $bookmark->setThumbnail($thumbnailer->get($bookmark->getUrl())); 1642 $bookmark->setThumbnail($thumbnailer->get($bookmark->getUrl()));
1634 $bookmarkService->set($bookmark); 1643 $bookmarkService->set($bookmark);
1635 1644
1636 $factory = new FormatterFactory($conf); 1645 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1637 echo json_encode($factory->getFormatter('raw')->format($bookmark)); 1646 echo json_encode($factory->getFormatter('raw')->format($bookmark));
1638 exit; 1647 exit;
1639 } 1648 }
@@ -1655,7 +1664,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
1655 */ 1664 */
1656function buildLinkList($PAGE, $linkDb, $conf, $pluginManager, $loginManager) 1665function buildLinkList($PAGE, $linkDb, $conf, $pluginManager, $loginManager)
1657{ 1666{
1658 $factory = new FormatterFactory($conf); 1667 $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
1659 $formatter = $factory->getFormatter(); 1668 $formatter = $factory->getFormatter();
1660 1669
1661 // Used in templates 1670 // Used in templates