From: Michael Date: Sun, 17 May 2020 13:51:56 +0000 (+0000) Subject: Issue 8514: Make paging for searcg items work again X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a3c4021f12263f30b2f88986f9ffa8aba8c2cba3;p=friendica.git Issue 8514: Make paging for searcg items work again Fixes #8514 --- diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index 593be7d5f9..b35924b338 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -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) { diff --git a/src/Content/Widget/SavedSearches.php b/src/Content/Widget/SavedSearches.php index 355f41f730..6bc363a81a 100644 --- a/src/Content/Widget/SavedSearches.php +++ b/src/Content/Widget/SavedSearches.php @@ -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'], ]; diff --git a/src/Core/Search.php b/src/Core/Search.php index 4742ac5993..32090733c4 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -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); + } + } } diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index 27074fa82a..aca2934f65 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -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'); diff --git a/src/Module/Search/Saved.php b/src/Module/Search/Saved.php index 7b8c8d012f..73372b03a0 100644 --- a/src/Module/Search/Saved.php +++ b/src/Module/Search/Saved.php @@ -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) { diff --git a/view/templates/widget/saved_searches.tpl b/view/templates/widget/saved_searches.tpl index 6957e706d2..3ccb1273c6 100644 --- a/view/templates/widget/saved_searches.tpl +++ b/view/templates/widget/saved_searches.tpl @@ -11,7 +11,7 @@ {{foreach $saved as $search}} {{/foreach}} diff --git a/view/theme/frio/templates/widget/saved_searches.tpl b/view/theme/frio/templates/widget/saved_searches.tpl index 88a6906678..03623b03b0 100644 --- a/view/theme/frio/templates/widget/saved_searches.tpl +++ b/view/theme/frio/templates/widget/saved_searches.tpl @@ -12,7 +12,7 @@ - {{$search.term}} + {{$search.term}} {{/foreach}} diff --git a/view/theme/quattro/templates/widget/saved_searches.tpl b/view/theme/quattro/templates/widget/saved_searches.tpl index ce99d521d9..1c293ea834 100644 --- a/view/theme/quattro/templates/widget/saved_searches.tpl +++ b/view/theme/quattro/templates/widget/saved_searches.tpl @@ -4,7 +4,7 @@