Remove deprecated App::getBaseURL() - process methods to DI::baseUrl()->get()

This commit is contained in:
Philipp Holzer 2019-12-16 01:05:15 +01:00
parent e57a87f224
commit e944d7bed6
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
43 changed files with 76 additions and 120 deletions

View file

@ -437,7 +437,7 @@ function dfrn_request_post(App $a)
}
// "Homecoming" - send the requestor back to their site to record the introduction.
$dfrn_url = bin2hex($a->getBaseURL() . '/profile/' . $nickname);
$dfrn_url = bin2hex(DI::baseUrl()->get() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
System::externalRedirect($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"

View file

@ -126,7 +126,7 @@ function profile_photo_post(App $a)
info(L10n::t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
// Update global directory in background
if ($path && strlen(Config::get('system', 'directory'))) {
Worker::add(PRIORITY_LOW, "Directory", $a->getBaseURL() . '/' . $path);
Worker::add(PRIORITY_LOW, "Directory", DI::baseUrl()->get() . '/' . $path);
}
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());

View file

@ -16,8 +16,6 @@ use Friendica\Module\Security\Login;
function user_allow($hash)
{
$a = \get_app();
$register = Register::getByHash($hash);
if (!DBA::isResult($register)) {
return false;
@ -45,7 +43,7 @@ function user_allow($hash)
$l10n,
$user,
Config::get('config', 'sitename'),
$a->getBaseUrl(),
DI::baseUrl()->get(),
($register['password'] ?? '') ?: 'Sent in a previous email'
);

View file

@ -80,7 +80,7 @@ function removeme_content(App $a)
$tpl = Renderer::getMarkupTemplate('removeme.tpl');
$o = Renderer::replaceMacros($tpl, [
'$basedir' => $a->getBaseURL(),
'$basedir' => DI::baseUrl()->get(),
'$hash' => $hash,
'$title' => L10n::t('Remove My Account'),
'$desc' => L10n::t('This will completely remove your account. Once this has been done it is not recoverable.'),

View file

@ -721,7 +721,7 @@ function settings_content(App $a)
$tpl = Renderer::getMarkupTemplate('settings/oauth.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$title' => L10n::t('Connected Apps'),
'$add' => L10n::t('Add application'),
'$edit' => L10n::t('Edit'),

View file

@ -271,20 +271,6 @@ class App
return $this->baseURL->getScheme();
}
/**
* Retrieves the Friendica instance base URL
*
* @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN
*
* @return string Friendica server base URL
*
* @deprecated 2019.09 - use BaseUrl->get($ssl) instead
*/
public function getBaseURL($ssl = false)
{
return $this->baseURL->get($ssl);
}
/**
* Returns the current UserAgent as a String
*
@ -298,7 +284,7 @@ class App
FRIENDICA_CODENAME . "' " .
FRIENDICA_VERSION . '-' .
DB_UPDATE_VERSION . '; ' .
$this->getBaseURL();
$this->baseURL->get();
}
/**
@ -478,8 +464,8 @@ class App
// and www.example.com vs example.com.
// We will only change the url to an ip address if there is no existing setting
if (empty($url) || (!Util\Strings::compareLink($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->baseURL->getHostname()))) {
$this->config->set('system', 'url', $this->getBaseURL());
if (empty($url) || (!Util\Strings::compareLink($url, $this->baseURL->get())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->baseURL->getHostname()))) {
$this->config->set('system', 'url', $this->baseURL->get());
}
}

View file

@ -1152,7 +1152,7 @@ class BBCode
$a = DI::app();
// When the picture link is the own photo path then we can avoid fetching the link
$own_photo_url = preg_quote(Strings::normaliseLink($a->getBaseURL()) . '/photos/');
$own_photo_url = preg_quote(Strings::normaliseLink(DI::baseUrl()->get()) . '/photos/');
if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) {
if (!empty($match[3])) {
$text = '[img=' . str_replace('-1.', '-0.', $match[2]) . ']' . $match[3] . '[/img]';

View file

@ -61,10 +61,9 @@ class Renderer
public static function replaceMacros($s, array $vars = [])
{
$stamp1 = microtime(true);
$a = DI::app();
// pass $baseurl to all templates if it isn't set
$vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars);
$vars = array_merge(['$baseurl' => DI::baseUrl()->get()], $vars);
$t = self::getTemplateEngine();

View file

@ -2511,7 +2511,7 @@ class Item
$guid = System::createUUID();
}
return DI::app()->getBaseURL() . '/objects/' . $guid;
return DI::baseUrl()->get() . '/objects/' . $guid;
}
/**

View file

@ -679,8 +679,7 @@ class Photo
*/
public static function getGUID($name)
{
$a = \get_app();
$base = $a->getBaseURL();
$base = DI::baseUrl()->get();
$guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name));
@ -725,8 +724,7 @@ class Photo
*/
public static function isLocalPage($name)
{
$a = \get_app();
$base = $a->getBaseURL();
$base = DI::baseUrl()->get();
$guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
$guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);

View file

@ -337,7 +337,7 @@ class Profile
if (isset($profile['url'])) {
$profile_url = $profile['url'];
} else {
$profile_url = $a->getBaseURL() . '/profile/' . $profile['nickname'];
$profile_url = DI::baseUrl()->get() . '/profile/' . $profile['nickname'];
}
$follow_link = null;
@ -1080,13 +1080,13 @@ class Profile
$query = rtrim(str_replace($addr_request, '', $a->query_string), '?&');
// The other instance needs to know where to redirect.
$dest = urlencode($a->getBaseURL() . '/' . $query);
$dest = urlencode(DI::baseUrl()->get() . '/' . $query);
// We need to extract the basebath from the profile url
// to redirect the visitors '/magic' module.
$basepath = Contact::getBasepath($contact['url']);
if ($basepath != $a->getBaseURL() && !strstr($dest, '/magic')) {
if ($basepath != DI::baseUrl()->get() && !strstr($dest, '/magic')) {
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
// We have to check if the remote server does understand /magic without invoking something

View file

@ -101,7 +101,7 @@ class Details extends BaseAdminModule
'$page' => L10n::t('Addons'),
'$toggle' => L10n::t('Toggle'),
'$settings' => L10n::t('Settings'),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$addon' => $addon,
'$status' => $status,

View file

@ -14,8 +14,6 @@ class Index extends BaseAdminModule
{
parent::content($parameters);
$a = DI::app();
// reload active themes
if (!empty($_GET['action'])) {
parent::checkFormSecurityTokenRedirectOnError('/admin/addons', 'admin_addons', 't');
@ -52,7 +50,7 @@ class Index extends BaseAdminModule
'$page' => L10n::t('Addons'),
'$submit' => L10n::t('Save Settings'),
'$reload' => L10n::t('Reload active addons'),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$function' => 'addons',
'$addons' => $addons,
'$pcount' => count($addons),

View file

@ -76,7 +76,7 @@ class Contact extends BaseAdminModule
'$form_security_token' => parent::getFormSecurityToken('admin_contactblock'),
// values //
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$contacts' => $contacts,
'$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total),

View file

@ -55,8 +55,6 @@ class Server extends BaseAdminModule
{
parent::content($parameters);
$a = DI::app();
$blocklist = Config::get('system', 'blocklist');
$blocklistform = [];
if (is_array($blocklist)) {
@ -91,7 +89,7 @@ class Server extends BaseAdminModule
'$threason' => L10n::t('Reason for the block'),
'$delentry' => L10n::t('Delete entry from blocklist'),
'$entries' => $blocklistform,
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$confirm_delete' => L10n::t('Delete entry from blocklist?'),
'$form_security_token' => parent::getFormSecurityToken("admin_blocklist")
]);

View file

@ -88,13 +88,13 @@ class DBSync extends BaseAdminModule
if (!count($failed)) {
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/structure_check.tpl'), [
'$base' => $a->getBaseURL(true),
'$base' => DI::baseUrl()->get(true),
'$banner' => L10n::t('No failed updates.'),
'$check' => L10n::t('Check database structure'),
]);
} else {
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('admin/dbsync/failed_updates.tpl'), [
'$base' => $a->getBaseURL(true),
'$base' => DI::baseUrl()->get(true),
'$banner' => L10n::t('Failed Updates'),
'$desc' => L10n::t('This does not include updates prior to 1139, which did not return a status.'),
'$mark' => L10n::t("Mark success \x28if update was manually applied\x29"),

View file

@ -42,8 +42,6 @@ class Settings extends BaseAdminModule
{
parent::content($parameters);
$a = DI::app();
$log_choices = [
LogLevel::ERROR => 'Error',
LogLevel::WARNING => 'Warning',
@ -65,7 +63,7 @@ class Settings extends BaseAdminModule
'$page' => L10n::t('Logs'),
'$submit' => L10n::t('Save Settings'),
'$clear' => L10n::t('Clear'),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$logname' => Config::get('system', 'logfile'),
// see /help/smarty3-templates#1_1 on any Friendica node
'$debugging' => ['debugging', L10n::t("Enable Debugging"), Config::get('system', 'debugging'), ""],

View file

@ -56,7 +56,7 @@ class Site extends BaseAdminModule
* send relocate for every local user
* */
$old_url = $a->getBaseURL(true);
$old_url = DI::baseUrl()->get(true);
// Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace("http://", "@", Strings::normaliseLink($new_url));
@ -417,8 +417,6 @@ class Site extends BaseAdminModule
{
parent::content($parameters);
$a = DI::app();
/* Installed langs */
$lang_choices = L10n::getAvailableLanguages();
@ -578,7 +576,7 @@ class Site extends BaseAdminModule
'$relay_title' => L10n::t('Message Relay'),
'$relocate' => L10n::t('Relocate Instance'),
'$relocate_warning' => L10n::t('Warning! Advanced function. Could make this server unreachable.'),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
// name, label, value, help string, extra data...
'$sitename' => ['sitename', L10n::t('Site name'), Config::get('config', 'sitename'), ''],
@ -661,14 +659,14 @@ class Site extends BaseAdminModule
'$proxy_disabled' => ['proxy_disabled', L10n::t('Disable picture proxy'), Config::get('system', 'proxy_disabled'), L10n::t('The picture proxy increases performance and privacy. It shouldn\'t be used on systems with very low bandwidth.')],
'$only_tag_search' => ['only_tag_search', L10n::t('Only search in tags'), Config::get('system', 'only_tag_search'), L10n::t('On large systems the text search can slow down the system extremely.')],
'$relocate_url' => ['relocate_url', L10n::t('New base url'), $a->getBaseURL(), L10n::t('Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.')],
'$relocate_url' => ['relocate_url', L10n::t('New base url'), DI::baseUrl()->get(), L10n::t('Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.')],
'$rino' => ['rino', L10n::t('RINO Encryption'), intval(Config::get('system', 'rino_encrypt')), L10n::t('Encryption layer between nodes.'), [0 => L10n::t('Disabled'), 1 => L10n::t('Enabled')]],
'$worker_queues' => ['worker_queues', L10n::t('Maximum number of parallel workers'), Config::get('system', 'worker_queues'), L10n::t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)],
'$worker_dont_fork' => ['worker_dont_fork', L10n::t('Don\'t use "proc_open" with the worker'), Config::get('system', 'worker_dont_fork'), L10n::t('Enable this if your system doesn\'t allow the use of "proc_open". This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.')],
'$worker_fastlane' => ['worker_fastlane', L10n::t('Enable fastlane'), Config::get('system', 'worker_fastlane'), L10n::t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],
'$worker_frontend' => ['worker_frontend', L10n::t('Enable frontend worker'), Config::get('system', 'frontend_worker'), L10n::t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', $a->getBaseURL())],
'$worker_frontend' => ['worker_frontend', L10n::t('Enable frontend worker'), Config::get('system', 'frontend_worker'), L10n::t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', DI::baseUrl()->get())],
'$relay_subscribe' => ['relay_subscribe', L10n::t('Subscribe to relay'), Config::get('system', 'relay_subscribe'), L10n::t('Enables the receiving of public posts from the relay. They will be included in the search, subscribed tags and on the global community page.')],
'$relay_server' => ['relay_server', L10n::t('Relay server'), Config::get('system', 'relay_server', 'https://relay.diasp.org'), L10n::t('Address of the relay server where public posts should be send to. For example https://relay.diasp.org')],

View file

@ -63,18 +63,18 @@ class Summary extends BaseAdminModule
// Legacy config file warning
if (file_exists('.htconfig.php')) {
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', $a->getBaseURL() . '/help/Config');
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>.htconfig.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', DI::baseUrl()->get() . '/help/Config');
}
if (file_exists('config/local.ini.php')) {
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>config/local.ini.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', $a->getBaseURL() . '/help/Config');
$warningtext[] = L10n::t('Friendica\'s configuration now is stored in config/local.config.php, please copy config/local-sample.config.php and move your config from <code>config/local.ini.php</code>. See <a href="%s">the Config help page</a> for help with the transition.', DI::baseUrl()->get() . '/help/Config');
}
// Check server vitality
if (!self::checkSelfHostMeta()) {
$well_known = $a->getBaseURL() . '/.well-known/host-meta';
$well_known = DI::baseUrl()->get() . '/.well-known/host-meta';
$warningtext[] = L10n::t('<a href="%s">%s</a> is not reachable on your system. This is a severe configuration issue that prevents server to server communication. See <a href="%s">the installation page</a> for help.',
$well_known, $well_known, $a->getBaseURL() . '/help/Install');
$well_known, $well_known, DI::baseUrl()->get() . '/help/Install');
}
// Check logfile permission
@ -208,7 +208,7 @@ class Summary extends BaseAdminModule
private static function checkSelfHostMeta()
{
// Fetch the host-meta to check if this really is a vital server
return Network::curl(DI::app()->getBaseURL() . '/.well-known/host-meta')->isSuccess();
return Network::curl(DI::baseUrl()->get() . '/.well-known/host-meta')->isSuccess();
}
}

View file

@ -106,7 +106,7 @@ class Details extends BaseAdminModule
'$page' => L10n::t('Themes'),
'$toggle' => L10n::t('Toggle'),
'$settings' => L10n::t('Settings'),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$addon' => $theme,
'$status' => $status,
'$action' => $action,

View file

@ -16,13 +16,11 @@ class Index extends BaseAdminModule
{
parent::content($parameters);
$a = DI::app();
$allowed_themes = Theme::getAllowedList();
// reload active themes
if (!empty($_GET['action'])) {
parent::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/themes', 'admin_themes', 't');
parent::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get() . '/admin/themes', 'admin_themes', 't');
switch ($_GET['action']) {
case 'reload':
@ -97,7 +95,7 @@ class Index extends BaseAdminModule
'$page' => L10n::t('Themes'),
'$submit' => L10n::t('Save Settings'),
'$reload' => L10n::t('Reload active themes'),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$function' => 'themes',
'$addons' => $addons,
'$pcount' => count($themes),

View file

@ -20,8 +20,6 @@ class Users extends BaseAdminModule
{
parent::post($parameters);
$a = DI::app();
$pending = $_POST['pending'] ?? [];
$users = $_POST['user'] ?? [];
$nu_name = $_POST['new_user_name'] ?? '';
@ -78,7 +76,7 @@ class Users extends BaseAdminModule
Thank you and welcome to %4$s.'));
$preamble = sprintf($preamble, $user['username'], Config::get('config', 'sitename'));
$body = sprintf($body, $a->getBaseURL(), $user['nickname'], $result['password'], Config::get('config', 'sitename'));
$body = sprintf($body, DI::baseUrl()->get(), $user['nickname'], $result['password'], Config::get('config', 'sitename'));
notification([
'type' => SYSTEM_EMAIL,
@ -306,7 +304,7 @@ class Users extends BaseAdminModule
'$form_security_token' => parent::getFormSecurityToken('admin_users'),
// values //
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$pending' => $pending,
'deleted' => $deleted,

View file

@ -70,7 +70,7 @@ class AllFriends extends BaseModule
$friend['id'] = $friend['cid'];
$photoMenu = Model\Contact::photoMenu($friend);
} else {
$connlnk = $app->getBaseURL() . '/follow/?url=' . $friend['url'];
$connlnk = DI::baseUrl()->get() . '/follow/?url=' . $friend['url'];
$photoMenu = [
'profile' => [L10n::t('View Profile'), Model\Contact::magicLinkbyId($friend['id'], $friend['url'])],
'follow' => [L10n::t('Connect/Follow'), $connlnk]

View file

@ -97,8 +97,6 @@ class BaseSearchModule extends BaseModule
return '';
}
$a = DI::app();
$id = 0;
$entries = [];
foreach ($results->getResults() as $result) {
@ -131,7 +129,7 @@ class BaseSearchModule extends BaseModule
$photo_menu = [];
}
} else {
$connLink = $a->getBaseURL() . '/follow/?url=' . $result->getUrl();
$connLink = DI::baseUrl()->get() . '/follow/?url=' . $result->getUrl();
$connTxt = L10n::t('Connect');
$photo_menu['profile'] = [L10n::t("View Profile"), Model\Contact::magicLink($result->getUrl())];

View file

@ -30,7 +30,7 @@ class Bookmarklet extends BaseModule
}
$referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
$page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet");
$page = Strings::normaliseLink(DI::baseUrl()->get() . "/bookmarklet");
if (!strstr($referer, $page)) {
if (empty($_REQUEST["url"])) {

View file

@ -351,7 +351,7 @@ class Contact extends BaseModule
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
]);
$sort_type = 0;
@ -473,7 +473,7 @@ class Contact extends BaseModule
$contact = $a->data['contact'];
$a->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('contact_head.tpl'), [
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
]);
$contact['blocked'] = Model\Contact::isBlockedByUser($contact['id'], local_user());

View file

@ -40,7 +40,7 @@ class Localtime extends BaseModule
$output .= '<p>' . L10n::t('Converted localtime: %s', $app->data['mod-localtime']) . '</p>';
}
$output .= '<form action ="' . $app->getBaseURL() . '/localtime?time=' . $time . '" method="post" >';
$output .= '<form action ="' . DI::baseUrl()->get() . '/localtime?time=' . $time . '" method="post" >';
$output .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
$output .= Temporal::getTimezoneSelect(($_REQUEST['timezone'] ?? '') ?: Installer::DEFAULT_TZ);
$output .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';

View file

@ -47,7 +47,7 @@ class Fetch extends BaseModule
}
$host = $parts["scheme"] . "://" . $parts["host"];
if (Strings::normaliseLink($host) != Strings::normaliseLink($app->getBaseURL())) {
if (Strings::normaliseLink($host) != Strings::normaliseLink(DI::baseUrl()->get())) {
$location = $host . "/fetch/" . $app->argv[1] . "/" . urlencode($guid);
System::externalRedirect($location, 301);
}

View file

@ -18,7 +18,6 @@ class Friendica extends BaseModule
{
public static function content(array $parameters = [])
{
$app = DI::app();
$config = DI::config();
$visibleAddonList = Addon::getVisibleList();
@ -48,7 +47,7 @@ class Friendica extends BaseModule
}
$tos = ($config->get('system', 'tosdisplay')) ?
L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', $app->getBaseURL()) :
L10n::t('Read about the <a href="%1$s/tos">Terms of Service</a> of this node.', DI::baseUrl()->get()) :
'';
$blockList = $config->get('system', 'blocklist');
@ -75,7 +74,7 @@ class Friendica extends BaseModule
return Renderer::replaceMacros($tpl, [
'about' => L10n::t('This is Friendica, version %s that is running at the web location %s. The database version is %s, the post update version is %s.',
'<strong>' . FRIENDICA_VERSION . '</strong>',
$app->getBaseURL(),
DI::baseUrl()->get(),
'<strong>' . DB_UPDATE_VERSION . '</strong>',
'<strong>' . $config->get('system', 'post_update_version') . '</strong>'),
'friendica' => L10n::t('Please visit <a href="https://friendi.ca">Friendi.ca</a> to learn more about the Friendica project.'),
@ -125,7 +124,7 @@ class Friendica extends BaseModule
if (!empty($administrator)) {
$admin = [
'name' => $administrator['username'],
'profile' => $app->getBaseURL() . '/profile/' . $administrator['nickname'],
'profile' => DI::baseUrl()->get() . '/profile/' . $administrator['nickname'],
];
}
}
@ -147,7 +146,7 @@ class Friendica extends BaseModule
$data = [
'version' => FRIENDICA_VERSION,
'url' => $app->getBaseURL(),
'url' => DI::baseUrl()->get(),
'addons' => $visible_addons,
'locked_features' => $locked_features,
'explicit_content' => intval($config->get('system', 'explicit_content', 0)),
@ -157,7 +156,7 @@ class Friendica extends BaseModule
'site_name' => $config->get('config', 'sitename'),
'platform' => FRIENDICA_PLATFORM,
'info' => $config->get('config', 'info'),
'no_scrape_url' => $app->getBaseURL() . '/noscrape',
'no_scrape_url' => DI::baseUrl()->get() . '/noscrape',
];
header('Content-type: application/json; charset=utf-8');

View file

@ -87,7 +87,7 @@ class Help extends BaseModule
$idNum[$level] ++;
$href = $a->getBaseURL() . "/help/{$filename}#{$anchor}";
$href = DI::baseUrl()->get() . "/help/{$filename}#{$anchor}";
$toc .= "<li><a href=\"{$href}\">" . strip_tags($line) . "</a></li>";
$id = implode("_", array_slice($idNum, 1, $level));
$line = "<a name=\"{$id}\"></a>" . $line;

View file

@ -42,7 +42,7 @@ class Home extends BaseModule
$customHome = $homeFilePath;
if (file_exists($cssFilePath)) {
$app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $app->getBaseURL() . '/home.css' . '" media="all" />';
$app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/home.css' . '" media="all" />';
}
}

View file

@ -71,7 +71,7 @@ class Install extends BaseModule
// We overwrite current theme css, because during install we may not have a working mod_rewrite
// so we may not have a css at all. Here we set a static css file for the install procedure pages
Renderer::$theme['stylesheet'] = $a->getBaseURL() . '/view/install/style.css';
Renderer::$theme['stylesheet'] = DI::baseUrl()->get() . '/view/install/style.css';
self::$currentWizardStep = ($_POST['pass'] ?? '') ?: self::SYSTEM_CHECK;
}
@ -162,7 +162,7 @@ class Install extends BaseModule
case self::SYSTEM_CHECK:
$php_path = $configCache->get('config', 'php_path');
$status = self::$installer->checkEnvironment($a->getBaseURL(), $php_path);
$status = self::$installer->checkEnvironment(DI::baseUrl()->get(), $php_path);
$tpl = Renderer::getMarkupTemplate('install_checks.tpl');
$output .= Renderer::replaceMacros($tpl, [
@ -303,7 +303,7 @@ class Install extends BaseModule
'$title' => $install_title,
'$checks' => self::$installer->getChecks(),
'$pass' => L10n::t('Installation finished'),
'$text' => $db_return_text . self::whatNext($a),
'$text' => $db_return_text . self::whatNext(),
]);
break;
@ -315,14 +315,12 @@ class Install extends BaseModule
/**
* Creates the text for the next steps
*
* @param App $a The global App
*
* @return string The text for the next steps
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function whatNext($a)
private static function whatNext()
{
$baseurl = $a->getBaseUrl();
$baseurl = DI::baseUrl()->get();
return
L10n::t('<h1>What next</h1>')
. "<p>" . L10n::t('IMPORTANT: You will need to [manually] setup a scheduled task for the worker.')

View file

@ -129,14 +129,14 @@ class Invite extends BaseModule
if ($config->get('config', 'register_policy') === Register::CLOSED) {
$linkTxt = L10n::t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirLocation . '/servers');
} else {
$linkTxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', $app->getBaseURL())
$linkTxt = L10n::t('To accept this invitation, please visit and register at %s or any other public Friendica website.', DI::baseUrl()->get())
. "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.', $dirLocation . '/servers');
}
} else { // there is no global directory URL defined
if ($config->get('config', 'register_policy') === Register::CLOSED) {
return L10n::t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
} else {
$linkTxt = L10n::t('To accept this invitation, please visit and register at %s.', $app->getBaseURL()
$linkTxt = L10n::t('To accept this invitation, please visit and register at %s.', DI::baseUrl()->get()
. "\r\n" . "\r\n" . L10n::t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks.'));
}
}
@ -152,7 +152,7 @@ class Invite extends BaseModule
L10n::t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n"
. $linkTxt
. "\r\n" . "\r\n" . (($inviteOnly) ? L10n::t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . L10n::t('Once you have registered, please connect with me via my profile page at:')
. "\r\n" . "\r\n" . $app->getBaseURL() . '/profile/' . $app->user['nickname']
. "\r\n" . "\r\n" . DI::baseUrl()->get() . '/profile/' . $app->user['nickname']
. "\r\n" . "\r\n" . L10n::t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n",
],
'$submit' => L10n::t('Submit')

View file

@ -49,7 +49,7 @@ class Magic extends BaseModule
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site.
if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(DI::app()->getBaseURL())) !== false) {
if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) {
if ($test) {
$ret['success'] = true;
$ret['message'] .= 'Local site - you are already authenticated.' . EOL;

View file

@ -22,7 +22,7 @@ class OpenSearch extends BaseModule
header('Content-type: application/opensearchdescription+xml');
$hostname = DI::baseUrl()->getHostname()();
$baseUrl = DI::app()->getBaseURL();
$baseUrl = DI::baseUrl()->get();
/** @var DOMDocument $xml */
$xml = null;

View file

@ -16,7 +16,6 @@ class ReallySimpleDiscovery extends BaseModule
{
header('Content-Type: text/xml');
$app = DI::app();
$xml = null;
echo XML::fromArray([
'rsd' => [
@ -32,7 +31,7 @@ class ReallySimpleDiscovery extends BaseModule
'@attributes' => [
'name' => 'Twitter',
'preferred' => 'true',
'apiLink' => $app->getBaseURL(),
'apiLink' => DI::baseUrl()->get(),
'blogID' => '',
],
'settings' => [

View file

@ -104,7 +104,7 @@ class Login extends BaseModule
$a->page['htmlhead'] .= Renderer::replaceMacros(
Renderer::getMarkupTemplate('login_head.tpl'),
[
'$baseurl' => $a->getBaseURL(true)
'$baseurl' => DI::baseUrl()->get(true)
]
);
@ -127,7 +127,7 @@ class Login extends BaseModule
$o .= Renderer::replaceMacros(
$tpl,
[
'$dest_url' => DI::app()->getBaseURL(true) . '/login',
'$dest_url' => DI::baseUrl()->get(true) . '/login',
'$logout' => L10n::t('Logout'),
'$login' => L10n::t('Login'),

View file

@ -16,7 +16,6 @@ class HostMeta extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
$config = DI::config();
header('Content-type: text/xml');
@ -31,8 +30,8 @@ class HostMeta extends BaseModule
$tpl = Renderer::getMarkupTemplate('xrd_host.tpl');
echo Renderer::replaceMacros($tpl, [
'$zhost' => DI::baseUrl()->getHostname()(),
'$zroot' => $app->getBaseURL(),
'$domain' => $app->getBaseURL(),
'$zroot' => DI::baseUrl()->get(),
'$domain' => DI::baseUrl()->get(),
'$bigkey' => Salmon::salmonKey($config->get('system', 'site_pubkey'))
]);

View file

@ -2,7 +2,6 @@
namespace Friendica\Module\WellKnown;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\DI;
@ -14,26 +13,22 @@ class NodeInfo extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
self::printWellKnown($app);
self::printWellKnown();
}
/**
* Prints the well-known nodeinfo redirect
*
* @param App $app
*
* @throws \Friendica\Network\HTTPException\NotFoundException
*/
private static function printWellKnown(App $app)
private static function printWellKnown()
{
$nodeinfo = [
'links' => [
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
'href' => $app->getBaseURL() . '/nodeinfo/1.0'],
'href' => DI::baseUrl()->get() . '/nodeinfo/1.0'],
['rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
'href' => $app->getBaseURL() . '/nodeinfo/2.0'],
'href' => DI::baseUrl()->get() . '/nodeinfo/2.0'],
]
];

View file

@ -14,7 +14,6 @@ class XSocialRelay extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
$config = DI::config();
$subscribe = $config->get('system', 'relay_subscribe', false);
@ -50,10 +49,10 @@ class XSocialRelay extends BaseModule
'tags' => $tagList,
'protocols' => [
'diaspora' => [
'receive' => $app->getBaseURL() . '/receive/public'
'receive' => DI::baseUrl()->get() . '/receive/public'
],
'dfrn' => [
'receive' => $app->getBaseURL() . '/dfrn_notify'
'receive' => DI::baseUrl()->get() . '/dfrn_notify'
]
]
];

View file

@ -75,9 +75,9 @@ class Xrd extends BaseModule
}
if ($mode == 'xml') {
self::printXML($alias, $app->getBaseURL(), $user, $owner, $avatar);
self::printXML($alias, DI::baseUrl()->get(), $user, $owner, $avatar);
} else {
self::printJSON($alias, $app->getBaseURL(), $owner, $avatar);
self::printJSON($alias, DI::baseUrl()->get(), $owner, $avatar);
}
}

View file

@ -204,7 +204,7 @@ class Transmitter
{
return ['type' => 'Service',
'name' => FRIENDICA_PLATFORM . " '" . FRIENDICA_CODENAME . "' " . FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'url' => DI::app()->getBaseURL()];
'url' => DI::baseUrl()->get()];
}
/**

View file

@ -2372,7 +2372,7 @@ class DFRN
/// @todo Do we really need this check for HTML elements? (It was copied from the old function)
if ((strpos($item['body'], '<') !== false) && (strpos($item['body'], '>') !== false)) {
$base_url = \get_app()->getBaseURL();
$base_url = DI::baseUrl()->get();
$item['body'] = HTML::relToAbs($item['body'], $base_url);
$item['body'] = HTML::toBBCodeVideo($item['body']);