From 48baa0be4b662b7c3d2afebad3b78324677fec14 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sat, 4 Jan 2020 23:59:20 +0100 Subject: [PATCH 1/2] Remove get_server() in favor of Search::getGlobalDirectory() --- boot.php | 11 ----------- mod/dfrn_request.php | 3 ++- mod/match.php | 5 +++-- src/Core/Search.php | 12 +++++++++++- src/Core/System.php | 1 - src/Model/GContact.php | 3 ++- src/Module/Admin/Site.php | 3 ++- src/Module/BaseSearchModule.php | 4 +--- src/Worker/SearchDirectory.php | 3 ++- view/theme/vier/theme.php | 3 ++- 10 files changed, 25 insertions(+), 23 deletions(-) diff --git a/boot.php b/boot.php index fa99a7bb3..119624fa7 100644 --- a/boot.php +++ b/boot.php @@ -469,17 +469,6 @@ function curPageURL() return $pageURL; } -function get_server() -{ - $server = Config::get("system", "directory"); - - if ($server == "") { - $server = "https://dir.friendica.social"; - } - - return $server; -} - function get_temppath() { $temppath = Config::get("system", "temppath"); diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 38a3f310a..3f900cc63 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -18,6 +18,7 @@ use Friendica\Core\L10n; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; +use Friendica\Core\Search; use Friendica\Core\System; use Friendica\Core\Session; use Friendica\Database\DBA; @@ -634,7 +635,7 @@ function dfrn_request_content(App $a) $page_desc = L10n::t("Please enter your 'Identity Address' from one of the following supported communications networks:"); - $invite_desc = L10n::t('If you are not yet a member of the free social web, follow this link to find a public Friendica site and join us today.', get_server() . '/servers'); + $invite_desc = L10n::t('If you are not yet a member of the free social web, follow this link to find a public Friendica site and join us today.', Search::getGlobalDirectory() . '/servers'); $o = Renderer::replaceMacros($tpl, [ '$header' => L10n::t('Friend/Connection Request'), diff --git a/mod/match.php b/mod/match.php index 0e9be2819..6fa31f013 100644 --- a/mod/match.php +++ b/mod/match.php @@ -8,6 +8,7 @@ use Friendica\Content\Widget; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\Renderer; +use Friendica\Core\Search; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -56,7 +57,7 @@ function match_content(App $a) $params['n'] = 100; if (strlen(Config::get('system', 'directory'))) { - $host = get_server(); + $host = Search::getGlobalDirectory(); } else { $host = DI::baseUrl(); } @@ -79,7 +80,7 @@ function match_content(App $a) } // Workaround for wrong directory photo URL - $profile->photo = str_replace('http:///photo/', get_server() . '/photo/', $profile->photo); + $profile->photo = str_replace('http:///photo/', Search::getGlobalDirectory() . '/photo/', $profile->photo); $connlnk = DI::baseUrl() . '/follow/?url=' . $profile->url; $photo_menu = [ diff --git a/src/Core/Search.php b/src/Core/Search.php index c10b5f6d6..d187e9395 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -272,7 +272,7 @@ class Search $return = GContact::searchByName($search, $mode); } else { $p = $page > 1 ? 'p=' . $page : ''; - $curlResult = Network::curl(get_server() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']); + $curlResult = Network::curl(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']); if ($curlResult->isSuccess()) { $searchResult = json_decode($curlResult->getBody(), true); if (!empty($searchResult['profiles'])) { @@ -283,4 +283,14 @@ class Search return $return ?? []; } + + /** + * Returns the global directory name, used in this node + * + * @return string + */ + public static function getGlobalDirectory() + { + return Config::get('system', 'directory', self::DEFAULT_DIRECTORY); + } } diff --git a/src/Core/System.php b/src/Core/System.php index 709864492..4da4f8b86 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -290,7 +290,6 @@ class System function notice($s) function info($s) function is_site_admin() - function get_server() function get_temppath() function get_cachefile($file, $writemode = true) function get_itemcachepath() diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 67519d01d..6dac33bfb 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -12,6 +12,7 @@ use Friendica\Core\Config; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\System; +use Friendica\Core\Search; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Network\Probe; @@ -508,7 +509,7 @@ class GContact $done[] = DI::baseUrl() . '/poco'; if (strlen(Config::get('system', 'directory'))) { - $x = Network::fetchUrl(get_server() . '/pubsites'); + $x = Network::fetchUrl(Search::getGlobalDirectory() . '/pubsites'); if (!empty($x)) { $j = json_decode($x); if (!empty($j->entries)) { diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index ed16a65b7..cb9772561 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\Renderer; +use Friendica\Core\Search; use Friendica\Core\StorageManager; use Friendica\Core\Theme; use Friendica\Core\Worker; @@ -584,7 +585,7 @@ class Site extends BaseAdminModule '$banner' => ['banner', L10n::t('Banner/Logo'), $banner, ''], '$shortcut_icon' => ['shortcut_icon', L10n::t('Shortcut icon'), Config::get('system', 'shortcut_icon'), L10n::t('Link to an icon that will be used for browsers.')], '$touch_icon' => ['touch_icon', L10n::t('Touch icon'), Config::get('system', 'touch_icon'), L10n::t('Link to an icon that will be used for tablets and mobiles.')], - '$additional_info' => ['additional_info', L10n::t('Additional Info'), $additional_info, L10n::t('For public servers: you can add additional information here that will be listed at %s/servers.', get_server())], + '$additional_info' => ['additional_info', L10n::t('Additional Info'), $additional_info, L10n::t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory()], '$language' => ['language', L10n::t('System language'), Config::get('system', 'language'), '', $lang_choices], '$theme' => ['theme', L10n::t('System theme'), Config::get('system', 'theme'), L10n::t('Default system theme - may be over-ridden by user profiles - Change default theme settings'), $theme_choices], '$theme_mobile' => ['theme_mobile', L10n::t('Mobile system theme'), Config::get('system', 'mobile-theme', '---'), L10n::t('Theme for mobile devices'), $theme_choices_mobile], diff --git a/src/Module/BaseSearchModule.php b/src/Module/BaseSearchModule.php index cf0159cc2..2c1b2dc8d 100644 --- a/src/Module/BaseSearchModule.php +++ b/src/Module/BaseSearchModule.php @@ -2,7 +2,6 @@ namespace Friendica\Module; -use Friendica\App\Arguments; use Friendica\BaseModule; use Friendica\Content\ContactSelector; use Friendica\Content\Pager; @@ -15,7 +14,6 @@ use Friendica\Network\HTTPException; use Friendica\Object\Search\ContactResult; use Friendica\Object\Search\ResultList; use Friendica\Util\Proxy as ProxyUtils; -use Friendica\Util\Strings; /** * Base class for search modules @@ -136,7 +134,7 @@ class BaseSearchModule extends BaseModule $photo_menu['follow'] = [L10n::t("Connect/Follow"), $connLink]; } - $photo = str_replace("http:///photo/", get_server() . "/photo/", $result->getPhoto()); + $photo = str_replace("http:///photo/", Search::getGlobalDirectory() . "/photo/", $result->getPhoto()); $entry = [ 'alt_text' => $alt_text, diff --git a/src/Worker/SearchDirectory.php b/src/Worker/SearchDirectory.php index d489acb7f..4503f21ca 100644 --- a/src/Worker/SearchDirectory.php +++ b/src/Worker/SearchDirectory.php @@ -8,6 +8,7 @@ use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Logger; use Friendica\Core\Protocol; +use Friendica\Core\Search; use Friendica\Database\DBA; use Friendica\Model\GContact; use Friendica\Model\GServer; @@ -34,7 +35,7 @@ class SearchDirectory } } - $x = Network::fetchUrl(get_server() . '/lsearch?p=1&n=500&search=' . urlencode($search)); + $x = Network::fetchUrl(Search::getGlobalDirectory() . '/lsearch?p=1&n=500&search=' . urlencode($search)); $j = json_decode($x); if (!empty($j->results)) { diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 98e8b6807..b331116df 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -16,6 +16,7 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Renderer; +use Friendica\Core\Search; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -183,7 +184,7 @@ function vier_community_info() $nv['random'] = L10n::t('Random Profile'); $nv['inv'] = L10n::t('Invite Friends'); $nv['directory'] = L10n::t('Global Directory'); - $nv['global_dir'] = get_server(); + $nv['global_dir'] = Search::getGlobalDirectory(); $nv['local_directory'] = L10n::t('Local Directory'); $aside['$nv'] = $nv; From 8878b3864fb3b809e4a3cb2f339d84607666ae5b Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 Jan 2020 02:19:02 +0000 Subject: [PATCH 2/2] Fix an error and a notice --- src/Model/GServer.php | 1 + src/Protocol/Feed.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Model/GServer.php b/src/Model/GServer.php index 044880724..fe5ef6d6f 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -10,6 +10,7 @@ use DOMDocument; use DOMXPath; use Friendica\Core\Config; use Friendica\Core\Protocol; +use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Module\Register; use Friendica\Network\CurlResult; diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 751a0f1e9..e277f99d9 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -460,7 +460,7 @@ class Feed { $item["body"] = '[abstract]' . HTML::toBBCode($summary, $basepath) . "[/abstract]\n" . $item["body"]; } - if ($contact["fetch_further_information"] == 3) { + if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] == 3)) { if (!empty($tags)) { $item["tag"] = $tags; } else {