Added search

This commit is contained in:
Michael 2019-07-18 06:37:33 +00:00
parent 931c190566
commit 13212e0d04

View File

@ -18,7 +18,6 @@ use Friendica\Module\BaseSearchModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
function search_saved_searches() { function search_saved_searches() {
$o = ''; $o = '';
$search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : ''); $search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
@ -50,12 +49,10 @@ function search_saved_searches() {
} }
return $o; return $o;
} }
function search_init(App $a) { function search_init(App $a) {
$search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : ''); $search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
if (local_user()) { if (local_user()) {
@ -83,13 +80,9 @@ function search_init(App $a) {
unset($_SESSION['theme']); unset($_SESSION['theme']);
unset($_SESSION['mobile-theme']); unset($_SESSION['mobile-theme']);
} }
} }
function search_content(App $a) { function search_content(App $a) {
if (Config::get('system','block_public') && !local_user() && !remote_user()) { if (Config::get('system','block_public') && !local_user() && !remote_user()) {
notice(L10n::t('Public access denied.') . EOL); notice(L10n::t('Public access denied.') . EOL);
return; return;
@ -154,6 +147,16 @@ function search_content(App $a) {
return BaseSearchModule::performSearch(); return BaseSearchModule::performSearch();
} }
if (parse_url($search, PHP_URL_SCHEME) != '') {
$id = Item::fetchByLink($search);
if (!empty($id)) {
$item = Item::selectFirst(['guid'], ['id' => $id]);
if (DBA::isResult($item)) {
$a->internalRedirect('display/' . $item['guid']);
}
}
}
if (!empty($_GET['search-option'])) if (!empty($_GET['search-option']))
switch($_GET['search-option']) { switch($_GET['search-option']) {
case 'fulltext': case 'fulltext':