]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #819 from ArthurHoaro/feature/multi-delete
authorArthurHoaro <arthur@hoa.ro>
Thu, 25 May 2017 13:03:32 +0000 (15:03 +0200)
committerGitHub <noreply@github.com>
Thu, 25 May 2017 13:03:32 +0000 (15:03 +0200)
Bulk deletion

1  2 
index.php
tpl/default/css/shaarli.css

diff --combined index.php
index fb8b96b56cce50166fa786511339e99b9b6d1b86,5e61cbb00f4095af34883310f4354fb269b9e204..40539a04666c1c16acbad9c604a5e7a2cef48cc0
+++ b/index.php
@@@ -225,6 -225,27 +225,6 @@@ function setup_login_state($conf
  }
  $userIsLoggedIn = setup_login_state($conf);
  
 -/**
 - * PubSubHubbub protocol support (if enabled)  [UNTESTED]
 - * (Source: http://aldarone.fr/les-flux-rss-shaarli-et-pubsubhubbub/ )
 - *
 - * @param ConfigManager $conf Configuration Manager instance.
 - */
 -function pubsubhub($conf)
 -{
 -    $pshUrl = $conf->get('config.PUBSUBHUB_URL');
 -    if (!empty($pshUrl))
 -    {
 -        include_once './publisher.php';
 -        $p = new Publisher($pshUrl);
 -        $topic_url = array (
 -            index_url($_SERVER).'?do=atom',
 -            index_url($_SERVER).'?do=rss'
 -        );
 -        $p->publish_update($topic_url);
 -    }
 -}
 -
  // ------------------------------------------------------------------------------------------
  // Session management
  
@@@ -790,9 -811,7 +790,9 @@@ function renderPage($conf, $pluginManag
      // -------- Tag cloud
      if ($targetPage == Router::$PAGE_TAGCLOUD)
      {
 -        $tags= $LINKSDB->allTags();
 +        $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all';
 +        $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : array();
 +        $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility);
  
          // We sort tags alphabetically, then choose a font size according to count.
          // First, find max value.
          }
  
          $data = array(
 +            'search_tags' => implode(' ', $filteringTags),
              'tags' => $tagList,
          );
          $pluginManager->executeHooks('render_tagcloud', $data, array('loggedin' => isLoggedIn()));
      // -------- User clicked the "Delete" button when editing a link: Delete link from database.
      if ($targetPage == Router::$PAGE_DELETELINK)
      {
-         // We do not need to ask for confirmation:
-         // - confirmation is handled by JavaScript
-         // - we are protected from XSRF by the token.
          if (! tokenOk($_GET['token'])) {
              die('Wrong token.');
          }
  
-         $id = intval(escape($_GET['lf_linkdate']));
-         $link = $LINKSDB[$id];
-         $pluginManager->executeHooks('delete_link', $link);
-         unset($LINKSDB[$id]);
+         if (strpos($_GET['lf_linkdate'], ' ') !== false) {
+             $ids = array_values(array_filter(preg_split('/\s+/', escape($_GET['lf_linkdate']))));
+         } else {
+             $ids = [$_GET['lf_linkdate']];
+         }
+         foreach ($ids as $id) {
+             $id = (int) escape($id);
+             $link = $LINKSDB[$id];
+             $pluginManager->executeHooks('delete_link', $link);
+             unset($LINKSDB[$id]);
+         }
          $LINKSDB->save($conf->get('resource.page_cache')); // save to disk
          $history->deleteLink($link);
  
              'link' => $link,
              'link_is_new' => false,
              'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
 -            'tags' => $LINKSDB->allTags(),
 +            'tags' => $LINKSDB->linksCountPerTag(),
          );
          $pluginManager->executeHooks('render_editlink', $data);
  
              'link_is_new' => $link_is_new,
              'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''),
              'source' => (isset($_GET['source']) ? $_GET['source'] : ''),
 -            'tags' => $LINKSDB->allTags(),
 +            'tags' => $LINKSDB->linksCountPerTag(),
              'default_private_links' => $conf->get('privacy.default_private_links', false),
          );
          $pluginManager->executeHooks('render_editlink', $data);
index ef9ee23b28a2152f75d35dd5c6253654081a454d,efdf06d4d35a677b9ad4b155c978de16e8e53426..4415a1b70f5a32fb0133cc9d0979b0961ba3fac8
@@@ -211,7 -211,7 +211,7 @@@ body, .pure-g [class*="pure-u"] 
      }
  }
  
 -#search, #search-linklist {
 +#search, #search-linklist, #search-tagcloud {
      text-align: center;
      width: 100%;
  }
  }
  
  #search button,
 +#search-tagcloud button,
  #search-linklist button {
      background: transparent;
      border: none;
  #search-linklist button:hover {
      color: #fff;
  }
 +#search-tagcloud button:hover {
 +    color: #d0d0d0;
 +}
  
  #search-linklist {
      padding: 5px 0;
      }
  }
  
+ .subheader-form a.button {
+     color: #f5f5f5;
+     font-weight: bold;
+     text-decoration: none;
+     border: 2px solid #f5f5f5;
+     border-radius: 5px;
+     padding: 3px 10px;
+ }
+ .linklist-item-editbuttons .delete-checkbox {
+     display: none;
+ }
  #header-login-form input[type="text"], #header-login-form input[type="password"] {
      width: 200px;
  }