Merge pull request #12007 from annando/more-constants

The friendica constants have been moved to the app class
This commit is contained in:
Philipp 2022-10-17 14:27:59 +02:00 committed by GitHub
commit 8c084fedad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 57 additions and 47 deletions

View File

@ -29,10 +29,6 @@
use Friendica\Model\Contact;
define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Giant Rhubarb');
define('FRIENDICA_VERSION', '2022.12-dev');
/**
* Constant with a HTML line break.
*

View File

@ -58,6 +58,10 @@ use Psr\Log\LoggerInterface;
*/
class App
{
const PLATFORM = 'Friendica';
const CODENAME = 'Giant Rhubarb';
const VERSION = '2022.12-dev';
// Allow themes to control internal parameters
// by changing App values in theme.php
private $theme_info = [

View File

@ -202,7 +202,7 @@ class Page implements ArrayAccess
*/
public function registerStylesheet(string $path, string $media = 'screen')
{
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
$path = Network::appendQueryParam($path, ['v' => App::VERSION]);
if (mb_strpos($path, $this->basePath . DIRECTORY_SEPARATOR) === 0) {
$path = mb_substr($path, mb_strlen($this->basePath . DIRECTORY_SEPARATOR));
@ -277,7 +277,7 @@ class Page implements ArrayAccess
*/
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
'$local_user' => local_user(),
'$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
'$generator' => 'Friendica' . ' ' . App::VERSION,
'$delitem' => $l10n->t('Delete this item?'),
'$blockAuthor' => $l10n->t('Block this author? They won\'t be able to follow you nor see your public posts, and you won\'t be able to see their posts and their notifications.'),
'$update_interval' => $interval,
@ -395,7 +395,7 @@ class Page implements ArrayAccess
*/
public function registerFooterScript($path)
{
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
$path = Network::appendQueryParam($path, ['v' => App::VERSION]);
$url = str_replace($this->basePath . DIRECTORY_SEPARATOR, '', $path);
@ -543,7 +543,7 @@ class Page implements ArrayAccess
$page = $this->page;
header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("X-Friendica-Version: " . App::VERSION);
header("Content-type: text/html; charset=utf-8");
if ($config->get('system', 'hsts') && ($baseURL->getSSLPolicy() == BaseURL::SSL_POLICY_FULL)) {

View File

@ -23,6 +23,7 @@ namespace Friendica\Core;
use Dice\Dice;
use Friendica;
use Friendica\App;
/**
* Description of Console
@ -133,7 +134,7 @@ HELP;
$command = null;
if ($this->getOption('version')) {
$this->out('Friendica Console version ' . FRIENDICA_VERSION);
$this->out('Friendica Console version ' . App::VERSION);
return 0;
} elseif ((count($this->options) === 0 || $this->getOption($this->customHelpOptions) === true || $this->getOption($this->customHelpOptions) === 1) && count($this->args) === 0

View File

@ -21,6 +21,7 @@
namespace Friendica\Module\Admin;
use Friendica\App;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
@ -202,7 +203,7 @@ class Federation extends BaseAdmin
'$page' => DI::l10n()->t('Federation Statistics'),
'$intro' => $intro,
'$counts' => $counts,
'$version' => FRIENDICA_VERSION,
'$version' => App::VERSION,
'$legendtext' => DI::l10n()->tt('Currently this node is aware of %2$s node (%3$s active users last month, %4$s active users last six months, %5$s registered users in total) from the following platforms:', 'Currently this node is aware of %2$s nodes (%3$s active users last month, %4$s active users last six months, %5$s registered users in total) from the following platforms:', $total, number_format($total), number_format($month), number_format($halfyear), number_format($users)),
]);
}

View File

@ -21,6 +21,7 @@
namespace Friendica\Module\Admin;
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Logger;
@ -79,8 +80,8 @@ class Summary extends BaseAdmin
// the local version of Friendica. Check is opt-in, source may be stable or develop branch
if (DI::config()->get('system', 'check_new_version_url', 'none') != 'none') {
$gitversion = DI::config()->get('system', 'git_friendica_version');
if (version_compare(FRIENDICA_VERSION, $gitversion) < 0) {
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', FRIENDICA_VERSION, $gitversion);
if (version_compare(App::VERSION, $gitversion) < 0) {
$warningtext[] = DI::l10n()->t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s', App::VERSION, $gitversion);
}
}
@ -236,9 +237,9 @@ class Summary extends BaseAdmin
'$users' => [DI::l10n()->t('Registered users'), $users],
'$accounts' => $accounts,
'$pending' => [DI::l10n()->t('Pending registrations'), $pending],
'$version' => [DI::l10n()->t('Version'), FRIENDICA_VERSION],
'$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME,
'$version' => [DI::l10n()->t('Version'), App::VERSION],
'$platform' => App::PLATFORM,
'$codename' => App::CODENAME,
'$build' => DI::config()->get('system', 'build'),
'$addons' => [DI::l10n()->t('Active addons'), Addon::getEnabledList()],
'$serversettings' => $server_settings,

View File

@ -53,8 +53,8 @@ class Config extends BaseApi
'sslserver' => null,
'ssl' => DI::config()->get('system', 'ssl_policy') == App\BaseURL::SSL_POLICY_FULL ? 'always' : '0',
'friendica' => [
'FRIENDICA_PLATFORM' => FRIENDICA_PLATFORM,
'FRIENDICA_VERSION' => FRIENDICA_VERSION,
'FRIENDICA_PLATFORM' => App::PLATFORM,
'FRIENDICA_VERSION' => App::VERSION,
'DB_UPDATE_VERSION' => DB_UPDATE_VERSION,
]
],

View File

@ -21,6 +21,7 @@
namespace Friendica\Module;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\Hook;
@ -96,7 +97,7 @@ class Friendica extends BaseModule
return Renderer::replaceMacros($tpl, [
'about' => DI::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>',
'<strong>' . App::VERSION . '</strong>',
DI::baseUrl()->get(),
'<strong>' . $config->get('system', 'build') . '/' . DB_UPDATE_VERSION . '</strong>',
'<strong>' . $config->get('system', 'post_update_version') . '/' . PostUpdate::VERSION . '</strong>'),
@ -169,7 +170,7 @@ class Friendica extends BaseModule
}
$data = [
'version' => FRIENDICA_VERSION,
'version' => App::VERSION,
'url' => DI::baseUrl()->get(),
'addons' => $visible_addons,
'locked_features' => $locked_features,
@ -178,7 +179,7 @@ class Friendica extends BaseModule
'register_policy' => $register_policy,
'admin' => $admin,
'site_name' => $config->get('config', 'sitename'),
'platform' => strtolower(FRIENDICA_PLATFORM),
'platform' => strtolower(App::PLATFORM),
'info' => $config->get('config', 'info'),
'no_scrape_url' => DI::baseUrl()->get() . '/noscrape',
];

View File

@ -53,7 +53,7 @@ class NodeInfo110 extends BaseModule
'version' => '1.0',
'software' => [
'name' => 'friendica',
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
],
'protocols' => [
'inbound' => [

View File

@ -53,7 +53,7 @@ class NodeInfo120 extends BaseModule
'version' => '2.0',
'software' => [
'name' => 'friendica',
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
],
'protocols' => ['dfrn', 'activitypub'],
'services' => Nodeinfo::getServices(),

View File

@ -55,7 +55,7 @@ class NodeInfo210 extends BaseModule
'baseUrl' => $this->baseUrl->get(),
'name' => $this->config->get('config', 'sitename'),
'software' => 'friendica',
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
],
'organization' => Nodeinfo::getOrganization($this->config),
'protocols' => ['dfrn', 'activitypub'],

View File

@ -21,11 +21,11 @@
namespace Friendica\Module\Settings;
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
@ -253,7 +253,7 @@ class UserExport extends BaseSettings
);
$output = [
'version' => FRIENDICA_VERSION,
'version' => App::VERSION,
'schema' => DB_UPDATE_VERSION,
'baseurl' => DI::baseUrl(),
'user' => $user,

View File

@ -69,8 +69,8 @@ class Statistics extends BaseModule
$statistics = array_merge([
'name' => $this->config->get('config', 'sitename'),
'network' => FRIENDICA_PLATFORM,
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'network' => App::PLATFORM,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
'registrations_open' => $registration_open,
'total_users' => $this->config->get('nodeinfo', 'total_users'),
'active_users_halfyear' => $this->config->get('nodeinfo', 'active_users_halfyear'),

View File

@ -86,9 +86,9 @@ class HttpClient extends BaseFactory
$logger->notice('Curl redirect.', ['url' => $request->getUri(), 'to' => $uri, 'method' => $request->getMethod()]);
};
$userAgent = FRIENDICA_PLATFORM . " '" .
FRIENDICA_CODENAME . "' " .
FRIENDICA_VERSION . '-' .
$userAgent = App::PLATFORM . " '" .
App::CODENAME . "' " .
App::VERSION . '-' .
DB_UPDATE_VERSION . '; ' .
$this->baseUrl->get();

View File

@ -21,11 +21,11 @@
namespace Friendica\Object\Api\Mastodon;
use Friendica\App;
use Friendica\App\BaseURL;
use Friendica\BaseDataTransferObject;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Module\Register;
@ -87,7 +87,7 @@ class Instance extends BaseDataTransferObject
$this->title = $config->get('config', 'sitename');
$this->short_description = $this->description = $config->get('config', 'info');
$this->email = $config->get('config', 'admin_email');
$this->version = '2.8.0 (compatible; Friendica ' . FRIENDICA_VERSION . ')';
$this->version = '2.8.0 (compatible; Friendica ' . App::VERSION . ')';
$this->urls = null; // Not supported
$this->stats = new Stats($config, $database);
$this->thumbnail = $baseUrl->get() . ($config->get('system', 'shortcut_icon') ?? 'images/friendica-32.png');

View File

@ -21,6 +21,7 @@
namespace Friendica\Protocol\ActivityPub;
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Cache\Enum\Duration;
@ -416,7 +417,7 @@ class Transmitter
{
return [
'type' => 'Service',
'name' => FRIENDICA_PLATFORM . " '" . FRIENDICA_CODENAME . "' " . FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION,
'url' => DI::baseUrl()->get()
];
}

View File

@ -25,6 +25,7 @@ use DOMDocument;
use DOMElement;
use DOMNode;
use DOMXPath;
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
@ -369,8 +370,8 @@ class DFRN
XML::addElement($doc, $root, 'id', DI::baseUrl() . '/profile/' . $owner['nick']);
XML::addElement($doc, $root, 'title', $owner['name']);
$attributes = ['uri' => 'https://friendi.ca', 'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION];
XML::addElement($doc, $root, 'generator', FRIENDICA_PLATFORM, $attributes);
$attributes = ['uri' => 'https://friendi.ca', 'version' => App::VERSION . '-' . DB_UPDATE_VERSION];
XML::addElement($doc, $root, 'generator', App::PLATFORM, $attributes);
$attributes = ['rel' => 'license', 'href' => 'http://creativecommons.org/licenses/by/3.0/'];
XML::addElement($doc, $root, 'link', '', $attributes);

View File

@ -24,6 +24,7 @@ namespace Friendica\Protocol;
use DOMDocument;
use DOMElement;
use DOMXPath;
use Friendica\App;
use Friendica\Content\PageInfo;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
@ -1035,8 +1036,8 @@ class Feed
break;
}
$attributes = ['uri' => 'https://friendi.ca', 'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION];
XML::addElement($doc, $root, 'generator', FRIENDICA_PLATFORM, $attributes);
$attributes = ['uri' => 'https://friendi.ca', 'version' => App::VERSION . '-' . DB_UPDATE_VERSION];
XML::addElement($doc, $root, 'generator', App::PLATFORM, $attributes);
XML::addElement($doc, $root, 'id', DI::baseUrl() . '/profile/' . $owner['nick']);
XML::addElement($doc, $root, 'title', $title);
XML::addElement($doc, $root, 'subtitle', sprintf("Updates from %s on %s", $owner['name'], DI::config()->get('config', 'sitename')));

View File

@ -24,6 +24,7 @@ namespace Friendica\Protocol;
use DOMDocument;
use DOMElement;
use DOMXPath;
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Cache\Enum\Duration;
@ -1061,9 +1062,9 @@ class OStatus
$attributes = [
'uri' => 'https://friendi.ca',
'version' => FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION,
'version' => App::VERSION . '-' . DB_UPDATE_VERSION,
];
XML::addElement($doc, $root, 'generator', FRIENDICA_PLATFORM, $attributes);
XML::addElement($doc, $root, 'generator', App::PLATFORM, $attributes);
XML::addElement($doc, $root, 'id', DI::baseUrl() . '/profile/' . $owner['nick']);
XML::addElement($doc, $root, 'title', $title);
XML::addElement($doc, $root, 'subtitle', sprintf("Updates from %s on %s", $owner['name'], DI::config()->get('config', 'sitename')));

View File

@ -22,6 +22,7 @@
namespace Friendica\Util\EMailer;
use Exception;
use Friendica\App;
use Friendica\App\BaseURL;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
@ -79,8 +80,8 @@ abstract class MailBuilder
$this->headers = [
'Precedence' => ['list'],
'X-Friendica-Host' => [$hostname],
'X-Friendica-Platform' => [FRIENDICA_PLATFORM],
'X-Friendica-Version' => [FRIENDICA_VERSION],
'X-Friendica-Platform' => [App::PLATFORM],
'X-Friendica-Version' => [App::VERSION],
'List-ID' => ['<notification.' . $hostname . '>'],
'List-Archive' => ['<' . $baseUrl->get() . '/notifications/system>'],
];
@ -257,7 +258,7 @@ abstract class MailBuilder
$tpl = Renderer::getMarkupTemplate('email/html.tpl');
$msgHtml = Renderer::replaceMacros($tpl, [
'$title' => $this->l10n->t('Friendica Notification'),
'$product' => FRIENDICA_PLATFORM,
'$product' => App::PLATFORM,
'$htmlversion' => $msgHtml,
'$sitename' => $this->config->get('config', 'sitename'),
'$banner' => $this->config->get('system', 'email_banner',

View File

@ -22,6 +22,7 @@
namespace Friendica\Util\Writer;
use Exception;
use Friendica\App;
use Friendica\Database\Definition\DbaDefinition;
/**
@ -41,7 +42,7 @@ class DbaDefinitionSqlWriter
public static function create(DbaDefinition $definition): string
{
$sqlString = "-- ------------------------------------------\n";
$sqlString .= "-- " . FRIENDICA_PLATFORM . " " . FRIENDICA_VERSION . " (" . FRIENDICA_CODENAME . ")\n";
$sqlString .= "-- " . App::PLATFORM . " " . App::VERSION . " (" . App::CODENAME . ")\n";
$sqlString .= "-- DB_UPDATE_VERSION " . DB_UPDATE_VERSION . "\n";
$sqlString .= "-- ------------------------------------------\n\n\n";

View File

@ -21,12 +21,12 @@
namespace Friendica\Test\src\Module;
use Friendica\App;
use Friendica\Capabilities\ICanCreateResponses;
use Friendica\DI;
use Friendica\Module\NodeInfo110;
use Friendica\Module\NodeInfo120;
use Friendica\Module\NodeInfo210;
use Friendica\Module\Response;
use Friendica\Test\FixtureTest;
class NodeInfoTest extends FixtureTest
@ -44,7 +44,7 @@ class NodeInfoTest extends FixtureTest
self::assertEquals('1.0', $json->version);
self::assertEquals('friendica', $json->software->name);
self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
self::assertIsArray($json->protocols->inbound);
self::assertIsArray($json->protocols->outbound);
@ -65,7 +65,7 @@ class NodeInfoTest extends FixtureTest
self::assertEquals('2.0', $json->version);
self::assertEquals('friendica', $json->software->name);
self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->software->version);
self::assertIsArray($json->protocols);
self::assertIsArray($json->services->inbound);
@ -85,7 +85,7 @@ class NodeInfoTest extends FixtureTest
self::assertEquals('1.0', $json->version);
self::assertEquals('friendica', $json->server->software);
self::assertEquals(FRIENDICA_VERSION . '-' . DB_UPDATE_VERSION, $json->server->version);
self::assertEquals(App::VERSION . '-' . DB_UPDATE_VERSION, $json->server->version);
self::assertIsArray($json->protocols);
self::assertIsArray($json->services->inbound);