mirror of
https://github.com/friendica/friendica
synced 2024-11-13 07:02:54 +00:00
Use DI::baseUrl() for Search\Index.php
This commit is contained in:
parent
df0c05d635
commit
2660edbb48
1 changed files with 6 additions and 11 deletions
|
@ -40,9 +40,6 @@ class Index extends BaseSearchModule
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var BaseURL $baseURL */
|
|
||||||
$baseURL = self::getClass(BaseURL::class);
|
|
||||||
|
|
||||||
if (Config::get('system', 'permit_crawling') && !Session::isAuthenticated()) {
|
if (Config::get('system', 'permit_crawling') && !Session::isAuthenticated()) {
|
||||||
// Default values:
|
// Default values:
|
||||||
// 10 requests are "free", after the 11th only a call per minute is allowed
|
// 10 requests are "free", after the 11th only a call per minute is allowed
|
||||||
|
@ -97,13 +94,13 @@ class Index extends BaseSearchModule
|
||||||
$search = substr($search, 1);
|
$search = substr($search, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::tryRedirectToProfile($baseURL, $search);
|
self::tryRedirectToProfile($search);
|
||||||
|
|
||||||
if (strpos($search, '@') === 0 || strpos($search, '!') === 0) {
|
if (strpos($search, '@') === 0 || strpos($search, '!') === 0) {
|
||||||
return self::performContactSearch($search);
|
return self::performContactSearch($search);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::tryRedirectToPost($baseURL, $search);
|
self::tryRedirectToPost($search);
|
||||||
|
|
||||||
if (!empty($_GET['search-option'])) {
|
if (!empty($_GET['search-option'])) {
|
||||||
switch ($_GET['search-option']) {
|
switch ($_GET['search-option']) {
|
||||||
|
@ -207,12 +204,11 @@ class Index extends BaseSearchModule
|
||||||
* - user@domain
|
* - user@domain
|
||||||
* - Any fully-formed URL
|
* - Any fully-formed URL
|
||||||
*
|
*
|
||||||
* @param BaseURL $baseURL
|
|
||||||
* @param string $search
|
* @param string $search
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
private static function tryRedirectToProfile(BaseURL $baseURL, string $search)
|
private static function tryRedirectToProfile(string $search)
|
||||||
{
|
{
|
||||||
$isUrl = !empty(parse_url($search, PHP_URL_SCHEME));
|
$isUrl = !empty(parse_url($search, PHP_URL_SCHEME));
|
||||||
$isAddr = (bool)preg_match('/^@?([a-z0-9.-_]+@[a-z0-9.-_:]+)$/i', trim($search), $matches);
|
$isAddr = (bool)preg_match('/^@?([a-z0-9.-_]+@[a-z0-9.-_:]+)$/i', trim($search), $matches);
|
||||||
|
@ -246,18 +242,17 @@ class Index extends BaseSearchModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($contact_id)) {
|
if (!empty($contact_id)) {
|
||||||
$baseURL->redirect('contact/' . $contact_id);
|
DI::baseUrl()->redirect('contact/' . $contact_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch/search a post by URL and redirects to its local representation if it was found.
|
* Fetch/search a post by URL and redirects to its local representation if it was found.
|
||||||
*
|
*
|
||||||
* @param BaseURL $baseURL
|
|
||||||
* @param string $search
|
* @param string $search
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private static function tryRedirectToPost(BaseURL $baseURL, string $search)
|
private static function tryRedirectToPost(string $search)
|
||||||
{
|
{
|
||||||
if (parse_url($search, PHP_URL_SCHEME) == '') {
|
if (parse_url($search, PHP_URL_SCHEME) == '') {
|
||||||
return;
|
return;
|
||||||
|
@ -278,7 +273,7 @@ class Index extends BaseSearchModule
|
||||||
if (!empty($item_id)) {
|
if (!empty($item_id)) {
|
||||||
$item = Item::selectFirst(['guid'], ['id' => $item_id]);
|
$item = Item::selectFirst(['guid'], ['id' => $item_id]);
|
||||||
if (DBA::isResult($item)) {
|
if (DBA::isResult($item)) {
|
||||||
$baseURL->redirect('display/' . $item['guid']);
|
DI::baseUrl()->redirect('display/' . $item['guid']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue