]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fix an issue with private tags and fix nomarkdown tag (#1399)
authorArthurHoaro <arthur@hoa.ro>
Sat, 18 Jan 2020 16:59:37 +0000 (17:59 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Jan 2020 16:59:37 +0000 (17:59 +0100)
Fix an issue with private tags and fix nomarkdown tag

1  2 
index.php

diff --combined index.php
index 013b01af6c7f274fb1149ae3e8eb6b4d48da0cb0,bf75f7c914691ba84f9f3c1995b03e4bcb424208..a39fc762e23aaa0c9a7212e049adc7ef4c0c91eb
+++ b/index.php
@@@ -70,6 -70,7 +70,7 @@@ use Shaarli\Bookmark\BookmarkFileServic
  use \Shaarli\Config\ConfigManager;
  use \Shaarli\Feed\CachedPage;
  use \Shaarli\Feed\FeedBuilder;
+ use Shaarli\Formatter\BookmarkMarkdownFormatter;
  use Shaarli\Formatter\FormatterFactory;
  use \Shaarli\History;
  use \Shaarli\Languages;
@@@ -351,7 -352,7 +352,7 @@@ function showDailyRSS($bookmarkService
      echo '<language>en-en</language>';
      echo '<copyright>'. $pageaddr .'</copyright>'. PHP_EOL;
  
-     $factory = new FormatterFactory($conf);
+     $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
      $formatter = $factory->getFormatter();
      $formatter->addContextData('index_url', index_url($_SERVER));
      // For each day.
@@@ -441,7 -442,7 +442,7 @@@ function showDaily($pageBuilder, $bookm
          $linksToDisplay = [];
      }
  
-     $factory = new FormatterFactory($conf);
+     $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
      $formatter = $factory->getFormatter();
      // We pre-format some fields for proper output.
      foreach ($linksToDisplay as $key => $bookmark) {
@@@ -630,7 -631,7 +631,7 @@@ function renderPage($conf, $pluginManag
  
          // Get only bookmarks which have a thumbnail.
          // Note: we do not retrieve thumbnails here, the request is too heavy.
-         $factory = new FormatterFactory($conf);
+         $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
          $formatter = $factory->getFormatter();
          foreach ($links as $key => $link) {
              if ($link->getThumbnail() !== false) {
              exit;
          }
  
-         $factory = new FormatterFactory($conf);
+         $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
          // Generate data.
          $feedGenerator = new FeedBuilder(
              $bookmarkService,
          $bookmarkService->addOrSet($bookmark, false);
  
          // To preserve backward compatibility with 3rd parties, plugins still use arrays
-         $factory = new FormatterFactory($conf);
+         $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
          $formatter = $factory->getFormatter('raw');
          $data = $formatter->format($bookmark);
          $pluginManager->executeHooks('save_link', $data);
          if (!count($ids)) {
              die('no id provided');
          }
-         $factory = new FormatterFactory($conf);
+         $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
          $formatter = $factory->getFormatter('raw');
          foreach ($ids as $id) {
              $id = (int) escape($id);
          } else {
              $private = $_GET['newVisibility'] === 'private';
          }
-         $factory = new FormatterFactory($conf);
+         $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
          $formatter = $factory->getFormatter('raw');
          foreach ($ids as $id) {
              $id = (int) escape($id);
              exit;
          }
  
-         $factory = new FormatterFactory($conf);
+         $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
          $formatter = $factory->getFormatter('raw');
          $formattedLink = $formatter->format($link);
+         $tags = $bookmarkService->bookmarksCountPerTag();
+         if ($conf->get('formatter') === 'markdown') {
+             $tags[BookmarkMarkdownFormatter::NO_MD_TAG] = 1;
+         }
          $data = array(
              'link' => $formattedLink,
              'link_is_new' => false,
              'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
-             'tags' => $bookmarkService->bookmarksCountPerTag(),
+             'tags' => $tags,
          );
          $pluginManager->executeHooks('render_editlink', $data);
  
                  'private' => $private,
              ];
          } else {
-             $factory = new FormatterFactory($conf);
-         $formatter = $factory->getFormatter('raw');
+             $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
+             $formatter = $factory->getFormatter('raw');
              $link = $formatter->format($bookmark);
          }
  
+         $tags = $bookmarkService->bookmarksCountPerTag();
+         if ($conf->get('formatter') === 'markdown') {
+             $tags[BookmarkMarkdownFormatter::NO_MD_TAG] = 1;
+         }
          $data = [
              'link' => $link,
              'link_is_new' => $link_is_new,
              'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
              'source' => (isset($_GET['source']) ? $_GET['source'] : ''),
-             'tags' => $bookmarkService->bookmarksCountPerTag(),
+             'tags' => $tags,
              'default_private_links' => $conf->get('privacy.default_private_links', false),
          ];
          $pluginManager->executeHooks('render_editlink', $data);
          }
  
          try {
-             $factory = new FormatterFactory($conf);
+             $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
              $formatter = $factory->getFormatter('raw');
              $PAGE->assign(
                  'links',
          $bookmark->setThumbnail($thumbnailer->get($bookmark->getUrl()));
          $bookmarkService->set($bookmark);
  
-         $factory = new FormatterFactory($conf);
+         $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
          echo json_encode($factory->getFormatter('raw')->format($bookmark));
          exit;
      }
   */
  function buildLinkList($PAGE, $linkDb, $conf, $pluginManager, $loginManager)
  {
-     $factory = new FormatterFactory($conf);
+     $factory = new FormatterFactory($conf, $loginManager->isLoggedIn());
      $formatter = $factory->getFormatter();
  
      // Used in templates
          }
      } else {
          // Filter bookmarks according search parameters.
 -        $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
 +        $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : null;
          $request = [
              'searchtags' => $searchtags,
              'searchterm' => $searchterm,