]> git.mxchange.org Git - friendica.git/commitdiff
Issue 8514: Make paging for searcg items work again
authorMichael <heluecht@pirati.ca>
Sun, 17 May 2020 13:51:56 +0000 (13:51 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 17 May 2020 13:51:56 +0000 (13:51 +0000)
Fixes #8514

src/Content/Text/HTML.php
src/Content/Widget/SavedSearches.php
src/Core/Search.php
src/Module/Search/Index.php
src/Module/Search/Saved.php
view/templates/widget/saved_searches.tpl
view/theme/frio/templates/widget/saved_searches.tpl
view/theme/quattro/templates/widget/saved_searches.tpl

index 593be7d5f967f14a704551728dde02f631874660..b35924b338445b921778474982920479c703cfcb 100644 (file)
@@ -26,6 +26,7 @@ use DOMXPath;
 use Friendica\Content\Widget\ContactBlock;
 use Friendica\Core\Hook;
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Util\Network;
@@ -917,7 +918,7 @@ class HTML
                        '$save_label'   => $save_label,
                        '$search_hint'  => DI::l10n()->t('@name, !forum, #tags, content'),
                        '$mode'         => $mode,
-                       '$return_url'   => urlencode('search?q=' . urlencode($s)),
+                       '$return_url'   => urlencode(Search::getSearchPath($s)),
                ];
 
                if (!$aside) {
index 355f41f73045bf097915a6f6705de078a515df84..6bc363a81a1ecba926b0177e250430bf83aa117e 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Content\Widget;
 
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\Database\DBA;
 use Friendica\DI;
 
@@ -45,6 +46,7 @@ class SavedSearches
                                        'id'          => $saved_search['id'],
                                        'term'        => $saved_search['term'],
                                        'encodedterm' => urlencode($saved_search['term']),
+                                       'searchpath'  => Search::getSearchPath($saved_search['term']),
                                        'delete'      => DI::l10n()->t('Remove term'),
                                        'selected'    => $search == $saved_search['term'],
                                ];
index 4742ac599359f1b9a6297a84264574bc04e67a58..32090733c4d692e4d9e07156bcb069ca5ecf5827 100644 (file)
@@ -311,4 +311,19 @@ class Search
        {
                return DI::config()->get('system', 'directory', self::DEFAULT_DIRECTORY);
        }
+
+       /**
+        * Return the search path (either fulltext search or tag search)
+        *
+        * @param string $search
+        * @return string search path
+        */
+       public static function getSearchPath(string $search)
+       {
+               if (substr($search, 0, 1) == '#') {
+                       return 'search?tag=' . urlencode(substr($search, 1));
+               } else {
+                       return 'search?q=' . urlencode($search);
+               }
+       }
 }
index 27074fa82a0e9308b39af7e1c5dcf8940ff1d1e1..aca2934f650d6739ba623fdd5dc8e09cbbaaa197 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\Content\Widget;
 use Friendica\Core\Cache\Duration;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -80,7 +81,7 @@ class Index extends BaseSearch
                }
 
                if (local_user()) {
-                       DI::page()['aside'] .= Widget\SavedSearches::getHTML('search?q=' . urlencode($search), $search);
+                       DI::page()['aside'] .= Widget\SavedSearches::getHTML(Search::getSearchPath($search), $search);
                }
 
                Nav::setSelected('search');
index 7b8c8d012f08f48e38ffe605ada2d3f8f4c21148..73372b03a0ef00c577684701f4d78595ecf7e863 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module\Search;
 
 use Friendica\BaseModule;
+use Friendica\Core\Search;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Util\Strings;
@@ -33,7 +34,7 @@ class Saved extends BaseModule
                $action = DI::args()->get(2, 'none');
                $search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? '')));
 
-               $return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search);
+               $return_url = $_GET['return_url'] ?? Search::getSearchPath($search);
 
                if (local_user() && $search) {
                        switch ($action) {
index 6957e706d2545ab899d62ee18f8b9276d830639d..3ccb1273c68f97691445789ee76635f00429f7bb 100644 (file)
@@ -11,7 +11,7 @@
                {{foreach $saved as $search}}
                <li role="menuitem" class="saved-search-li clear">
                        <a href="search/saved/remove?term={{$search.encodedterm}}&amp;return_url={{$return_url}}" title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="iconspacer savedsearchdrop"></a>
-                       <a href="search?q={{$search.encodedterm}}" id="saved-search-term-{{$search.id}}" class="savedsearchterm">{{$search.term}}</a>
+                       <a href="{{$search.searchpath}}" id="saved-search-term-{{$search.id}}" class="savedsearchterm">{{$search.term}}</a>
                </li>
                {{/foreach}}
        </ul>
index 88a69066787e424f9e6cdc56dbfae047e09336e2..03623b03b05412c422c475e3de059a481d96ce2c 100644 (file)
@@ -12,7 +12,7 @@
                        <a href="search/saved/remove?term={{$search.encodedterm}}&amp;return_url={{$return_url}}" title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="savedsearchdrop pull-right widget-action faded-icon">
                                <i class="fa fa-trash" aria-hidden="true"></i>
                        </a>
-                       <a href="search?q={{$search.encodedterm}}" id="saved-search-term-{{$search.id}}" class="savedsearchterm">{{$search.term}}</a>
+                       <a href="{{$search.searchpath}}" id="saved-search-term-{{$search.id}}" class="savedsearchterm">{{$search.term}}</a>
                </li>
                {{/foreach}}
        </ul>
index ce99d521d9dbfac402d6dde76b513769eee156cc..1c293ea8345ab3a0ddea160aa9a549891ca3d8b0 100644 (file)
@@ -4,7 +4,7 @@
        <ul id="saved-search-ul">
         {{foreach $saved as $search}}
                        <li class="tool {{if $search.selected}}selected{{/if}}">
-                               <a href="search?q={{$search.encodedterm}}" class="label">{{$search.term}}</a>
+                               <a href="{{$search.searchpath}}" class="label">{{$search.term}}</a>
                                <a href="search/saved/remove?term={{$search.encodedterm}}&amp;return_url={{$return_url}}" class="action icon s10 delete" title="{{$search.delete}}" onclick="return confirmDelete();"></a>
                        </li>
         {{/foreach}}