Browse Source

Remove get_server() in favor of Search::getGlobalDirectory()

pull/8055/head
nupplaPhil 1 year ago
parent
commit
48baa0be4b
No known key found for this signature in database GPG Key ID: D8365C3D36B77D90
10 changed files with 25 additions and 23 deletions
  1. +0
    -11
      boot.php
  2. +2
    -1
      mod/dfrn_request.php
  3. +3
    -2
      mod/match.php
  4. +11
    -1
      src/Core/Search.php
  5. +0
    -1
      src/Core/System.php
  6. +2
    -1
      src/Model/GContact.php
  7. +2
    -1
      src/Module/Admin/Site.php
  8. +1
    -3
      src/Module/BaseSearchModule.php
  9. +2
    -1
      src/Worker/SearchDirectory.php
  10. +2
    -1
      view/theme/vier/theme.php

+ 0
- 11
boot.php View File

@ -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");


+ 2
- 1
mod/dfrn_request.php View File

@ -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, <a href="%s">follow this link to find a public Friendica site and join us today</a>.', get_server() . '/servers');
$invite_desc = L10n::t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica site and join us today</a>.', Search::getGlobalDirectory() . '/servers');
$o = Renderer::replaceMacros($tpl, [
'$header' => L10n::t('Friend/Connection Request'),


+ 3
- 2
mod/match.php View File

@ -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 = [


+ 11
- 1
src/Core/Search.php View File

@ -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);
}
}

+ 0
- 1
src/Core/System.php View File

@ -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()


+ 2
- 1
src/Model/GContact.php View File

@ -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)) {


+ 2
- 1
src/Module/Admin/Site.php View File

@ -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 - <a href="/admin/themes" id="cnftheme">Change default theme settings</a>'), $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],


+ 1
- 3
src/Module/BaseSearchModule.php View File

@ -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,


+ 2
- 1
src/Worker/SearchDirectory.php View File

@ -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)) {


+ 2
- 1
view/theme/vier/theme.php View File

@ -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;


Loading…
Cancel
Save