]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1270 from ArthurHoaro/hotfix/sticky-warning
authorArthurHoaro <arthur@hoa.ro>
Sun, 24 Feb 2019 10:30:35 +0000 (11:30 +0100)
committerGitHub <noreply@github.com>
Sun, 24 Feb 2019 10:30:35 +0000 (11:30 +0100)
Fix a warning if links sticky status isn't set

1  2 
application/bookmark/LinkDB.php
index.php

index 266632e30da3ed45a0015dbcfc278878809e80e1,41d5591fe11a5dcfaf3f0ca796e9436fccf47746..efde8468fca97e896f1da161e444993bdd711b4d
@@@ -29,10 -29,10 +29,10 @@@ use Shaarli\FileUtils
   *  - private:  Is this link private? 0=no, other value=yes
   *  - tags:     tags attached to this entry (separated by spaces)
   *  - title     Title of the link
 - *  - url       URL of the link. Used for displayable links (no redirector, relative, etc.).
 - *              Can be absolute or relative.
 - *              Relative URLs are permalinks (e.g.'?m-ukcw')
 - *  - real_url  Absolute processed URL.
 + *  - url       URL of the link. Used for displayable links.
 + *              Can be absolute or relative in the database but the relative links
 + *              will be converted to absolute ones in templates.
 + *  - real_url  Raw URL in stored in the DB (absolute or relative).
   *  - shorturl  Permalink smallhash
   *
   * Implements 3 interfaces:
@@@ -88,6 -88,19 +88,6 @@@ class LinkDB implements Iterator, Count
      // Hide public links
      private $hidePublicLinks;
  
 -    // link redirector set in user settings.
 -    private $redirector;
 -
 -    /**
 -     * Set this to `true` to urlencode link behind redirector link, `false` to leave it untouched.
 -     *
 -     * Example:
 -     *   anonym.to needs clean URL while dereferer.org needs urlencoded URL.
 -     *
 -     * @var boolean $redirectorEncode parameter: true or false
 -     */
 -    private $redirectorEncode;
 -
      /**
       * Creates a new LinkDB
       *
       * @param string  $datastore        datastore file path.
       * @param boolean $isLoggedIn       is the user logged in?
       * @param boolean $hidePublicLinks  if true all links are private.
 -     * @param string  $redirector       link redirector set in user settings.
 -     * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true).
       */
      public function __construct(
          $datastore,
          $isLoggedIn,
 -        $hidePublicLinks,
 -        $redirector = '',
 -        $redirectorEncode = true
 +        $hidePublicLinks
      ) {
      
          $this->datastore = $datastore;
          $this->loggedIn = $isLoggedIn;
          $this->hidePublicLinks = $hidePublicLinks;
 -        $this->redirector = $redirector;
 -        $this->redirectorEncode = $redirectorEncode === true;
          $this->check();
          $this->read();
      }
@@@ -252,7 -271,8 +252,8 @@@ You use the community supported versio
              ),
              'private' => 0,
              'created' => new DateTime(),
-             'tags' => 'opensource software'
+             'tags' => 'opensource software',
+             'sticky' => false,
          );
          $link['shorturl'] = link_small_hash($link['created'], $link['id']);
          $this->links[1] = $link;
              'private' => 1,
              'created' => new DateTime('1 minute ago'),
              'tags' => 'secretstuff',
+             'sticky' => false,
          );
          $link['shorturl'] = link_small_hash($link['created'], $link['id']);
          $this->links[0] = $link;
                  $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']);
              }
  
 -            // Do not use the redirector for internal links (Shaarli note URL starting with a '?').
 -            if (!empty($this->redirector) && !startsWith($link['url'], '?')) {
 -                $link['real_url'] = $this->redirector;
 -                if ($this->redirectorEncode) {
 -                    $link['real_url'] .= urlencode(unescape($link['url']));
 -                } else {
 -                    $link['real_url'] .= $link['url'];
 -                }
 -            } else {
 -                $link['real_url'] = $link['url'];
 -            }
 +            $link['real_url'] = $link['url'];
  
+             $link['sticky'] = isset($link['sticky']) ? $link['sticky'] : false;
              // To be able to load links before running the update, and prepare the update
              if (!isset($link['created'])) {
                  $link['id'] = $link['linkdate'];
diff --combined index.php
index 9ea26c7c5f67a09d8d2ab0d115863d44bd324de6,1d505305ad31f1aa3ac3bd85efc6163648e41fea..3700504b8a9e86422b1570a315b76c207daa35b8
+++ b/index.php
@@@ -312,7 -312,9 +312,7 @@@ function showDailyRSS($conf, $loginMana
      $LINKSDB = new LinkDB(
          $conf->get('resource.datastore'),
          $loginManager->isLoggedIn(),
 -        $conf->get('privacy.hide_public_links'),
 -        $conf->get('redirector.url'),
 -        $conf->get('redirector.encode_url')
 +        $conf->get('privacy.hide_public_links')
      );
  
      /* Some Shaarlies may have very few links, so we need to look
  
          // We pre-format some fields for proper output.
          foreach ($links as &$link) {
 -            $link['formatedDescription'] = format_description(
 -                $link['description'],
 -                $conf->get('redirector.url'),
 -                $conf->get('redirector.encode_url')
 -            );
 +            $link['formatedDescription'] = format_description($link['description']);
              $link['timestamp'] = $link['created']->getTimestamp();
              if (startsWith($link['url'], '?')) {
                  $link['url'] = index_url($_SERVER) . $link['url'];  // make permalink URL absolute
@@@ -427,7 -433,11 +427,7 @@@ function showDaily($pageBuilder, $LINKS
          $taglist = explode(' ', $link['tags']);
          uasort($taglist, 'strcasecmp');
          $linksToDisplay[$key]['taglist']=$taglist;
 -        $linksToDisplay[$key]['formatedDescription'] = format_description(
 -            $link['description'],
 -            $conf->get('redirector.url'),
 -            $conf->get('redirector.encode_url')
 -        );
 +        $linksToDisplay[$key]['formatedDescription'] = format_description($link['description']);
          $linksToDisplay[$key]['timestamp'] =  $link['created']->getTimestamp();
      }
  
@@@ -1171,6 -1181,8 +1171,8 @@@ function renderPage($conf, $pluginManag
              $link['thumbnail'] = $thumbnailer->get($url);
          }
  
+         $link['sticky'] = isset($link['sticky']) ? $link['sticky'] : false;
          $pluginManager->executeHooks('save_link', $link);
  
          $LINKSDB[$id] = $link;
@@@ -1652,7 -1664,11 +1654,7 @@@ function buildLinkList($PAGE, $LINKSDB
      $linkDisp = array();
      while ($i<$end && $i<count($keys)) {
          $link = $linksToDisplay[$keys[$i]];
 -        $link['description'] = format_description(
 -            $link['description'],
 -            $conf->get('redirector.url'),
 -            $conf->get('redirector.encode_url')
 -        );
 +        $link['description'] = format_description($link['description']);
          $classLi =  ($i % 2) != 0 ? '' : 'publicLinkHightLight';
          $link['class'] = $link['private'] == 0 ? $classLi : 'private';
          $link['timestamp'] = $link['created']->getTimestamp();
          'search_term' => $searchterm,
          'search_tags' => $searchtags,
          'visibility' => ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '',
 -        'redirector' => $conf->get('redirector.url'),  // Optional redirector URL.
          'links' => $linkDisp,
      );
  
@@@ -1862,7 -1879,9 +1864,7 @@@ try 
  $linkDb = new LinkDB(
      $conf->get('resource.datastore'),
      $loginManager->isLoggedIn(),
 -    $conf->get('privacy.hide_public_links'),
 -    $conf->get('redirector.url'),
 -    $conf->get('redirector.encode_url')
 +    $conf->get('privacy.hide_public_links')
  );
  
  $container = new \Slim\Container();