Introduce new DI container

- Adding Friendica\DI class for getting dynamic classes
- Replacing BaseObject::getApp() with this class
This commit is contained in:
Philipp Holzer 2019-12-15 22:34:11 +01:00
parent a9220aa83b
commit 1de3f186d7
No known key found for this signature in database
GPG Key ID: D8365C3D36B77D90
132 changed files with 377 additions and 270 deletions

View File

@ -37,7 +37,7 @@ $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]);
\Friendica\BaseObject::setDependencyInjection($dice); \Friendica\BaseObject::setDependencyInjection($dice);
$a = \Friendica\BaseObject::getApp(); $a = \Friendica\DI::app();
if ($a->getMode()->isInstall()) { if ($a->getMode()->isInstall()) {
die("Friendica isn't properly installed yet.\n"); die("Friendica isn't properly installed yet.\n");

View File

@ -36,7 +36,7 @@ $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);
BaseObject::setDependencyInjection($dice); BaseObject::setDependencyInjection($dice);
$a = BaseObject::getApp(); $a = Friendica\DI::app();
// Check the database structure and possibly fixes it // Check the database structure and possibly fixes it
Update::check($a->getBasePath(), true, $a->getMode()); Update::check($a->getBasePath(), true, $a->getMode());

View File

@ -23,8 +23,8 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Term; use Friendica\Model\Term;
use Friendica\Util\BasePath; use Friendica\Util\BasePath;
@ -241,12 +241,12 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) {
* Useful in functions which require it but don't get it passed to them * Useful in functions which require it but don't get it passed to them
* *
* @deprecated since version 2018.09 * @deprecated since version 2018.09
* @see BaseObject::getApp() * @see DI::app()
* @return App * @return App
*/ */
function get_app() function get_app()
{ {
return BaseObject::getApp(); return DI::app();
} }
/** /**

View File

@ -1370,7 +1370,7 @@ function api_get_item(array $condition)
*/ */
function api_users_show($type) function api_users_show($type)
{ {
$a = BaseObject::getApp(); $a = Friendica\DI::app();
$user_info = api_get_user($a); $user_info = api_get_user($a);
@ -2968,7 +2968,7 @@ function api_format_items_profiles($profile_row)
*/ */
function api_format_items($items, $user_info, $filter_user = false, $type = "json") function api_format_items($items, $user_info, $filter_user = false, $type = "json")
{ {
$a = BaseObject::getApp(); $a = Friendica\DI::app();
$ret = []; $ret = [];
@ -3002,7 +3002,7 @@ function api_format_items($items, $user_info, $filter_user = false, $type = "jso
*/ */
function api_format_item($item, $type = "json", $status_user = null, $author_user = null, $owner_user = null) function api_format_item($item, $type = "json", $status_user = null, $author_user = null, $owner_user = null)
{ {
$a = BaseObject::getApp(); $a = Friendica\DI::app();
if (empty($status_user) || empty($author_user) || empty($owner_user)) { if (empty($status_user) || empty($author_user) || empty($owner_user)) {
list($status_user, $author_user, $owner_user) = api_item_get_user($a, $item); list($status_user, $author_user, $owner_user) = api_item_get_user($a, $item);

View File

@ -344,7 +344,7 @@ function drop_items(array $items)
function drop_item($id, $return = '') function drop_item($id, $return = '')
{ {
$a = BaseObject::getApp(); $a = Friendica\DI::app();
// locate item to be deleted // locate item to be deleted

View File

@ -17,7 +17,7 @@ $dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode
\Friendica\BaseObject::setDependencyInjection($dice); \Friendica\BaseObject::setDependencyInjection($dice);
$a = \Friendica\BaseObject::getApp(); $a = \Friendica\DI::app();
$a->runFrontend( $a->runFrontend(
$dice->create(\Friendica\App\Module::class), $dice->create(\Friendica\App\Module::class),

View File

@ -31,18 +31,7 @@ class BaseObject
public static function setDependencyInjection(Dice $dice) public static function setDependencyInjection(Dice $dice)
{ {
self::$dice = $dice; self::$dice = $dice;
} DI::init($dice);
/**
* Get the app
*
* Same as get_app from boot.php
*
* @return App
*/
public static function getApp()
{
return self::getClass(App::class);
} }
/** /**

View File

@ -57,7 +57,7 @@ HELP;
protected function doExecute() protected function doExecute()
{ {
$a = \Friendica\BaseObject::getApp(); $a = \Friendica\DI::app();
if ($this->getOption($this->helpOptions)) { if ($this->getOption($this->helpOptions)) {
$this->out($this->getHelp()); $this->out($this->getHelp());

View File

@ -19,6 +19,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Event; use Friendica\Model\Event;
use Friendica\Model\Photo; use Friendica\Model\Photo;
@ -1093,7 +1094,7 @@ class BBCode extends BaseObject
$text = Cache::get($cache_key); $text = Cache::get($cache_key);
if (is_null($text)) { if (is_null($text)) {
$a = self::getApp(); $a = DI::app();
$stamp1 = microtime(true); $stamp1 = microtime(true);
@ -1149,7 +1150,7 @@ class BBCode extends BaseObject
private static function cleanPictureLinksCallback($match) private static function cleanPictureLinksCallback($match)
{ {
$a = self::getApp(); $a = DI::app();
// When the picture link is the own photo path then we can avoid fetching the link // 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($a->getBaseURL()) . '/photos/');
@ -1253,7 +1254,7 @@ class BBCode extends BaseObject
*/ */
public static function convert($text, $try_oembed = true, $simple_html = 0, $for_plaintext = false) public static function convert($text, $try_oembed = true, $simple_html = 0, $for_plaintext = false)
{ {
$a = self::getApp(); $a = DI::app();
/* /*
* preg_match_callback function to replace potential Oembed tags with Oembed content * preg_match_callback function to replace potential Oembed tags with Oembed content
@ -2010,7 +2011,7 @@ class BBCode extends BaseObject
*/ */
public static function toMarkdown($text, $for_diaspora = true) public static function toMarkdown($text, $for_diaspora = true)
{ {
$a = self::getApp(); $a = DI::app();
$original_text = $text; $original_text = $text;

View File

@ -8,6 +8,7 @@ namespace Friendica\Content\Text;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
/** /**
@ -43,7 +44,7 @@ class Markdown extends BaseObject
$html = $MarkdownParser->transform($text); $html = $MarkdownParser->transform($text);
self::getApp()->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack()); DI::app()->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
return $html; return $html;
} }

View File

@ -9,6 +9,7 @@ namespace Friendica\Core;
use Friendica\App\Page; use Friendica\App\Page;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
@ -35,7 +36,7 @@ class ACL extends BaseObject
*/ */
public static function getSuggestContactSelectHTML($selname, $selclass, array $options = [], array $preselected = []) public static function getSuggestContactSelectHTML($selname, $selclass, array $options = [], array $preselected = [])
{ {
$a = self::getApp(); $a = DI::app();
$networks = null; $networks = null;
@ -145,7 +146,7 @@ class ACL extends BaseObject
*/ */
public static function getMessageContactSelectHTML($selname, $selclass, array $preselected = [], $size = 4, $tabindex = null) public static function getMessageContactSelectHTML($selname, $selclass, array $preselected = [], $size = 4, $tabindex = null)
{ {
$a = self::getApp(); $a = DI::app();
$o = ''; $o = '';

View File

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
/** /**
@ -177,7 +178,7 @@ class Addon extends BaseObject
@include_once('addon/' . $addon . '/' . $addon . '.php'); @include_once('addon/' . $addon . '/' . $addon . '.php');
if (function_exists($addon . '_install')) { if (function_exists($addon . '_install')) {
$func = $addon . '_install'; $func = $addon . '_install';
$func(self::getApp()); $func(DI::app());
$addon_admin = (function_exists($addon . "_addon_admin") ? 1 : 0); $addon_admin = (function_exists($addon . "_addon_admin") ? 1 : 0);
@ -234,11 +235,11 @@ class Addon extends BaseObject
if (function_exists($addon . '_uninstall')) { if (function_exists($addon . '_uninstall')) {
$func = $addon . '_uninstall'; $func = $addon . '_uninstall';
$func(self::getApp()); $func(DI::app());
} }
if (function_exists($addon . '_install')) { if (function_exists($addon . '_install')) {
$func = $addon . '_install'; $func = $addon . '_install';
$func(self::getApp()); $func(DI::app());
} }
DBA::update('addon', ['timestamp' => $t], ['id' => $i['id']]); DBA::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
} }
@ -267,7 +268,7 @@ class Addon extends BaseObject
*/ */
public static function getInfo($addon) public static function getInfo($addon)
{ {
$a = self::getApp(); $a = DI::app();
$addon = Strings::sanitizeFilePathItem($addon); $addon = Strings::sanitizeFilePathItem($addon);

View File

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
/** /**
@ -75,7 +76,7 @@ class Hook extends BaseObject
*/ */
public static function register($hook, $file, $function, $priority = 0) public static function register($hook, $file, $function, $priority = 0)
{ {
$file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file); $file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
if (DBA::exists('hook', $condition)) { if (DBA::exists('hook', $condition)) {
@ -98,7 +99,7 @@ class Hook extends BaseObject
*/ */
public static function unregister($hook, $file, $function) public static function unregister($hook, $file, $function)
{ {
$relative_file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file); $relative_file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
// This here is only needed for fixing a problem that existed on the develop branch // This here is only needed for fixing a problem that existed on the develop branch
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
@ -148,7 +149,7 @@ class Hook extends BaseObject
if ($hook[0] != $fork_hook[0]) { if ($hook[0] != $fork_hook[0]) {
continue; continue;
} }
self::callSingle(self::getApp(), 'hook_fork', $fork_hook, $hookdata); self::callSingle(DI::app(), 'hook_fork', $fork_hook, $hookdata);
} }
if (!$hookdata['execute']) { if (!$hookdata['execute']) {
@ -175,7 +176,7 @@ class Hook extends BaseObject
{ {
if (array_key_exists($name, self::$hooks)) { if (array_key_exists($name, self::$hooks)) {
foreach (self::$hooks[$name] as $hook) { foreach (self::$hooks[$name] as $hook) {
self::callSingle(self::getApp(), $name, $hook, $data); self::callSingle(DI::app(), $name, $hook, $data);
} }
} }
} }

View File

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Exception; use Exception;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Render\FriendicaSmarty; use Friendica\Render\FriendicaSmarty;
use Friendica\Render\ITemplateEngine; use Friendica\Render\ITemplateEngine;
@ -61,7 +62,7 @@ class Renderer extends BaseObject
public static function replaceMacros($s, array $vars = []) public static function replaceMacros($s, array $vars = [])
{ {
$stamp1 = microtime(true); $stamp1 = microtime(true);
$a = self::getApp(); $a = DI::app();
// pass $baseurl to all templates if it isn't set // pass $baseurl to all templates if it isn't set
$vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars); $vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars);
@ -92,7 +93,7 @@ class Renderer extends BaseObject
public static function getMarkupTemplate($s, $root = '') public static function getMarkupTemplate($s, $root = '')
{ {
$stamp1 = microtime(true); $stamp1 = microtime(true);
$a = self::getApp(); $a = DI::app();
$t = self::getTemplateEngine(); $t = self::getTemplateEngine();
try { try {

View File

@ -4,6 +4,7 @@ namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -92,7 +93,7 @@ class Search extends BaseObject
*/ */
public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1) public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1)
{ {
$config = self::getApp()->getConfig(); $config = DI::app()->getConfig();
$server = $config->get('system', 'directory', self::DEFAULT_DIRECTORY); $server = $config->get('system', 'directory', self::DEFAULT_DIRECTORY);
$searchUrl = $server . '/search'; $searchUrl = $server . '/search';
@ -158,7 +159,7 @@ class Search extends BaseObject
*/ */
public static function getContactsFromLocalDirectory($search, $type = self::TYPE_ALL, $start = 0, $itemPage = 80) public static function getContactsFromLocalDirectory($search, $type = self::TYPE_ALL, $start = 0, $itemPage = 80)
{ {
$config = self::getApp()->getConfig(); $config = DI::app()->getConfig();
$diaspora = $config->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::DFRN; $diaspora = $config->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::DFRN;
$ostatus = !$config->get('system', 'ostatus_disabled') ? Protocol::OSTATUS : Protocol::DFRN; $ostatus = !$config->get('system', 'ostatus_disabled') ? Protocol::OSTATUS : Protocol::DFRN;

View File

@ -6,6 +6,7 @@ namespace Friendica\Core;
use Friendica\App\BaseURL; use Friendica\App\BaseURL;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -43,7 +44,7 @@ class System extends BaseObject
*/ */
public static function removedBaseUrl(string $orig_url) public static function removedBaseUrl(string $orig_url)
{ {
return self::getApp()->removeBaseURL($orig_url); return DI::app()->removeBaseURL($orig_url);
} }
/** /**
@ -184,7 +185,7 @@ class System extends BaseObject
if (is_bool($prefix) && !$prefix) { if (is_bool($prefix) && !$prefix) {
$prefix = ''; $prefix = '';
} elseif (empty($prefix)) { } elseif (empty($prefix)) {
$prefix = hash('crc32', self::getApp()->getHostName()); $prefix = hash('crc32', DI::app()->getHostName());
} }
while (strlen($prefix) < ($size - 13)) { while (strlen($prefix) < ($size - 13)) {

View File

@ -7,6 +7,7 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -194,7 +195,7 @@ class Theme
*/ */
public static function getPathForFile($file) public static function getPathForFile($file)
{ {
$a = BaseObject::getApp(); $a = DI::app();
$theme = $a->getCurrentTheme(); $theme = $a->getCurrentTheme();
@ -232,7 +233,7 @@ class Theme
return 'view/theme/' . $theme . '/style.css'; return 'view/theme/' . $theme . '/style.css';
} }
$a = BaseObject::getApp(); $a = DI::app();
$query_params = []; $query_params = [];

View File

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Core; use Friendica\Core;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Process; use Friendica\Model\Process;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -1232,11 +1233,11 @@ class Worker
*/ */
public static function defer() public static function defer()
{ {
if (empty(BaseObject::getApp()->queue)) { if (empty(DI::app()->queue)) {
return false; return false;
} }
$queue = BaseObject::getApp()->queue; $queue = DI::app()->queue;
$retrial = $queue['retrial']; $retrial = $queue['retrial'];
$id = $queue['id']; $id = $queue['id'];

33
src/DI.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace Friendica;
use Dice\Dice;
/**
* This class is capable of getting all dynamic created classes
*
* There has to be a "method" phpDoc for each new class, containing result class for a proper matching
*
* @method static App app()
*/
class DI
{
/** @var Dice */
private static $dice;
public static function init(Dice $dice)
{
self::$dice = $dice;
}
public static function __callStatic($name, $arguments)
{
switch ($name) {
case 'app':
return self::$dice->create(App::class, $arguments);
default:
return null;
}
}
}

View File

@ -67,7 +67,7 @@ class LegacyModule extends BaseModule
$function_name = static::$moduleName . '_' . $function_suffix; $function_name = static::$moduleName . '_' . $function_suffix;
if (\function_exists($function_name)) { if (\function_exists($function_name)) {
$a = self::getApp(); $a = DI::app();
return $function_name($a); return $function_name($a);
} else { } else {
return parent::{$function_suffix}($parameters); return parent::{$function_suffix}($parameters);

View File

@ -11,6 +11,7 @@ use Friendica\Core\StorageManager;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Storage\IStorage; use Friendica\Model\Storage\IStorage;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -31,7 +32,7 @@ class Attach extends BaseObject
*/ */
private static function getFields() private static function getFields()
{ {
$allfields = DBStructure::definition(self::getApp()->getBasePath(), false); $allfields = DBStructure::definition(DI::app()->getBasePath(), false);
$fields = array_keys($allfields['attach']['fields']); $fields = array_keys($allfields['attach']['fields']);
array_splice($fields, array_search('data', $fields), 1); array_splice($fields, array_search('data', $fields), 1);
return $fields; return $fields;

View File

@ -16,6 +16,7 @@ use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
@ -1733,7 +1734,7 @@ class Contact extends BaseObject
*/ */
public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0) public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0)
{ {
$a = self::getApp(); $a = DI::app();
$cid = self::getIdForURL($contact_url); $cid = self::getIdForURL($contact_url);

View File

@ -21,6 +21,7 @@ use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
@ -2513,7 +2514,7 @@ class Item extends BaseObject
$guid = System::createUUID(); $guid = System::createUUID();
} }
return self::getApp()->getBaseURL() . '/objects/' . $guid; return DI::app()->getBaseURL() . '/objects/' . $guid;
} }
/** /**
@ -3474,7 +3475,7 @@ class Item extends BaseObject
*/ */
private static function addRedirToImageTags(array &$item) private static function addRedirToImageTags(array &$item)
{ {
$app = self::getApp(); $app = DI::app();
$matches = []; $matches = [];
$cnt = preg_match_all('|\[img\](http[^\[]*?/photo/[a-fA-F0-9]+?(-[0-9]\.[\w]+?)?)\[\/img\]|', $item['body'], $matches, PREG_SET_ORDER); $cnt = preg_match_all('|\[img\](http[^\[]*?/photo/[a-fA-F0-9]+?(-[0-9]\.[\w]+?)?)\[\/img\]|', $item['body'], $matches, PREG_SET_ORDER);
@ -3509,7 +3510,7 @@ class Item extends BaseObject
*/ */
public static function prepareBody(array &$item, $attach = false, $is_preview = false) public static function prepareBody(array &$item, $attach = false, $is_preview = false)
{ {
$a = self::getApp(); $a = DI::app();
Hook::callAll('prepare_body_init', $item); Hook::callAll('prepare_body_init', $item);
// In order to provide theme developers more possibilities, event items // In order to provide theme developers more possibilities, event items
@ -3647,7 +3648,7 @@ class Item extends BaseObject
*/ */
public static function getPlink($item) public static function getPlink($item)
{ {
$a = self::getApp(); $a = DI::app();
if ($a->user['nickname'] != "") { if ($a->user['nickname'] != "") {
$ret = [ $ret = [

View File

@ -5,6 +5,7 @@ namespace Friendica\Model;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
/** /**
* Model interaction for the nodeinfo * Model interaction for the nodeinfo
@ -18,7 +19,7 @@ class Nodeinfo extends BaseObject
*/ */
public static function update() public static function update()
{ {
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
$logger = $app->getLogger(); $logger = $app->getLogger();

View File

@ -12,6 +12,7 @@ use Friendica\Core\L10n\L10n;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
@ -515,7 +516,7 @@ final class Notify extends BaseObject
$ident = self::PERSONAL; $ident = self::PERSONAL;
$notifies = []; $notifies = [];
$myurl = str_replace('http://', '', self::getApp()->contact['nurl']); $myurl = str_replace('http://', '', DI::app()->contact['nurl']);
$diasp_url = str_replace('/profile/', '/u/', $myurl); $diasp_url = str_replace('/profile/', '/u/', $myurl);
$condition = ["NOT `wall` AND `uid` = ? AND (`item`.`author-id` = ? OR `item`.`tag` REGEXP ? OR `item`.`tag` REGEXP ?)", $condition = ["NOT `wall` AND `uid` = ? AND (`item`.`author-id` = ? OR `item`.`tag` REGEXP ? OR `item`.`tag` REGEXP ?)",
@ -669,7 +670,7 @@ final class Notify extends BaseObject
// We have to distinguish between these two because they use different data. // We have to distinguish between these two because they use different data.
// Contact suggestions // Contact suggestions
if ($intro['fid']) { if ($intro['fid']) {
$return_addr = bin2hex(self::getApp()->user['nickname'] . '@' . $return_addr = bin2hex(DI::app()->user['nickname'] . '@' .
$this->baseUrl->getHostName() . $this->baseUrl->getHostName() .
(($this->baseUrl->getURLPath()) ? '/' . $this->baseUrl->getURLPath() : '')); (($this->baseUrl->getURLPath()) ? '/' . $this->baseUrl->getURLPath() : ''));

View File

@ -15,6 +15,7 @@ use Friendica\Core\StorageManager;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Storage\IStorage; use Friendica\Model\Storage\IStorage;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -202,7 +203,7 @@ class Photo extends BaseObject
*/ */
private static function getFields() private static function getFields()
{ {
$allfields = DBStructure::definition(self::getApp()->getBasePath(), false); $allfields = DBStructure::definition(DI::app()->getBasePath(), false);
$fields = array_keys($allfields["photo"]["fields"]); $fields = array_keys($allfields["photo"]["fields"]);
array_splice($fields, array_search("data", $fields), 1); array_splice($fields, array_search("data", $fields), 1);
return $fields; return $fields;

View File

@ -6,6 +6,7 @@ use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -15,7 +16,7 @@ class Details extends BaseAdminModule
{ {
parent::post($parameters); parent::post($parameters);
$a = self::getApp(); $a = DI::app();
if ($a->argc > 2) { if ($a->argc > 2) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
@ -39,7 +40,7 @@ class Details extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
$addons_admin = Addon::getAdminList(); $addons_admin = Addon::getAdminList();

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin\Addons;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
class Index extends BaseAdminModule class Index extends BaseAdminModule
@ -13,7 +14,7 @@ class Index extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
// reload active themes // reload active themes
if (!empty($_GET['action'])) { if (!empty($_GET['action'])) {

View File

@ -6,6 +6,7 @@ use Friendica\Content\Pager;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Model; use Friendica\Model;
@ -38,14 +39,14 @@ class Contact extends BaseAdminModule
notice(L10n::tt('%s contact unblocked', '%s contacts unblocked', count($contacts))); notice(L10n::tt('%s contact unblocked', '%s contacts unblocked', count($contacts)));
} }
self::getApp()->internalRedirect('admin/blocklist/contact'); DI::app()->internalRedirect('admin/blocklist/contact');
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
$condition = ['uid' => 0, 'blocked' => true]; $condition = ['uid' => 0, 'blocked' => true];

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin\Blocklist;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -47,14 +48,14 @@ class Server extends BaseAdminModule
info(L10n::t('Site blocklist updated.') . EOL); info(L10n::t('Site blocklist updated.') . EOL);
} }
self::getApp()->internalRedirect('admin/blocklist/server'); DI::app()->internalRedirect('admin/blocklist/server');
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
$blocklist = Config::get('system', 'blocklist'); $blocklist = Config::get('system', 'blocklist');
$blocklistform = []; $blocklistform = [];

View File

@ -8,6 +8,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Update; use Friendica\Core\Update;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
class DBSync extends BaseAdminModule class DBSync extends BaseAdminModule
@ -16,7 +17,7 @@ class DBSync extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
$o = ''; $o = '';

View File

@ -6,6 +6,7 @@ use Friendica\Content\Feature;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
class Features extends BaseAdminModule class Features extends BaseAdminModule
@ -39,7 +40,7 @@ class Features extends BaseAdminModule
} }
} }
self::getApp()->internalRedirect('admin/features'); DI::app()->internalRedirect('admin/features');
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])

View File

@ -4,6 +4,7 @@ namespace Friendica\Module\Admin\Item;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -33,7 +34,7 @@ class Delete extends BaseAdminModule
} }
info(L10n::t('Item marked for deletion.') . EOL); info(L10n::t('Item marked for deletion.') . EOL);
self::getApp()->internalRedirect('admin/item/delete'); DI::app()->internalRedirect('admin/item/delete');
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])

View File

@ -4,6 +4,7 @@ namespace Friendica\Module\Admin\Item;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
@ -17,7 +18,7 @@ class Source extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
$guid = null; $guid = null;
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin\Logs;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
@ -34,14 +35,14 @@ class Settings extends BaseAdminModule
} }
info(L10n::t("Log settings updated.")); info(L10n::t("Log settings updated."));
self::getApp()->internalRedirect('admin/logs'); DI::app()->internalRedirect('admin/logs');
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
$log_choices = [ $log_choices = [
LogLevel::ERROR => 'Error', LogLevel::ERROR => 'Error',

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Arrays; use Friendica\Util\Arrays;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -23,7 +24,7 @@ class Queue extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$deferred = $a->argc > 2 && $a->argv[2] == 'deferred'; $deferred = $a->argc > 2 && $a->argv[2] == 'deferred';

View File

@ -10,6 +10,7 @@ use Friendica\Core\StorageManager;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Module\Register; use Friendica\Module\Register;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
@ -27,7 +28,7 @@ class Site extends BaseAdminModule
self::checkFormSecurityTokenRedirectOnError('/admin/site', 'admin_site'); self::checkFormSecurityTokenRedirectOnError('/admin/site', 'admin_site');
$a = self::getApp(); $a = DI::app();
if (!empty($_POST['republish_directory'])) { if (!empty($_POST['republish_directory'])) {
Worker::add(PRIORITY_LOW, 'Directory'); Worker::add(PRIORITY_LOW, 'Directory');
@ -416,7 +417,7 @@ class Site extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
/* Installed langs */ /* Installed langs */
$lang_choices = L10n::getAvailableLanguages(); $lang_choices = L10n::getAvailableLanguages();

View File

@ -10,6 +10,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Update; use Friendica\Core\Update;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Register; use Friendica\Model\Register;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Network\HTTPException\InternalServerErrorException;
@ -24,7 +25,7 @@ class Summary extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
// are there MyISAM tables in the DB? If so, trigger a warning message // are there MyISAM tables in the DB? If so, trigger a warning message
$warningtext = []; $warningtext = [];
@ -208,7 +209,7 @@ class Summary extends BaseAdminModule
private static function checkSelfHostMeta() private static function checkSelfHostMeta()
{ {
// Fetch the host-meta to check if this really is a vital server // Fetch the host-meta to check if this really is a vital server
return Network::curl(self::getApp()->getBaseURL() . '/.well-known/host-meta')->isSuccess(); return Network::curl(DI::app()->getBaseURL() . '/.well-known/host-meta')->isSuccess();
} }
} }

View File

@ -6,6 +6,7 @@ use Friendica\Content\Text\Markdown;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -15,7 +16,7 @@ class Details extends BaseAdminModule
{ {
parent::post($parameters); parent::post($parameters);
$a = self::getApp(); $a = DI::app();
if ($a->argc > 2) { if ($a->argc > 2) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
@ -43,7 +44,7 @@ class Details extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
if ($a->argc > 2) { if ($a->argc > 2) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router

View File

@ -4,6 +4,7 @@ namespace Friendica\Module\Admin\Themes;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -11,7 +12,7 @@ class Embed extends BaseAdminModule
{ {
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if ($a->argc > 2) { if ($a->argc > 2) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
@ -27,7 +28,7 @@ class Embed extends BaseAdminModule
{ {
parent::post($parameters); parent::post($parameters);
$a = self::getApp(); $a = DI::app();
if ($a->argc > 2) { if ($a->argc > 2) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
@ -57,7 +58,7 @@ class Embed extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
if ($a->argc > 2) { if ($a->argc > 2) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router

View File

@ -6,6 +6,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -15,7 +16,7 @@ class Index extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
$allowed_themes = Theme::getAllowedList(); $allowed_themes = Theme::getAllowedList();

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
class Tos extends BaseAdminModule class Tos extends BaseAdminModule
@ -29,7 +30,7 @@ class Tos extends BaseAdminModule
info(L10n::t('The Terms of Service settings have been updated.')); info(L10n::t('The Terms of Service settings have been updated.'));
self::getApp()->internalRedirect('admin/tos'); DI::app()->internalRedirect('admin/tos');
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])

View File

@ -7,6 +7,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Register; use Friendica\Model\Register;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\BaseAdminModule; use Friendica\Module\BaseAdminModule;
@ -19,7 +20,7 @@ class Users extends BaseAdminModule
{ {
parent::post($parameters); parent::post($parameters);
$a = self::getApp(); $a = DI::app();
$pending = $_POST['pending'] ?? []; $pending = $_POST['pending'] ?? [];
$users = $_POST['user'] ?? []; $users = $_POST['user'] ?? [];
@ -135,7 +136,7 @@ class Users extends BaseAdminModule
{ {
parent::content($parameters); parent::content($parameters);
$a = self::getApp(); $a = DI::app();
if ($a->argc > 3) { if ($a->argc > 3) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router

View File

@ -7,6 +7,7 @@ use Friendica\Content\ContactSelector;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
@ -18,7 +19,7 @@ class AllFriends extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
if (!local_user()) { if (!local_user()) {
throw new HTTPException\ForbiddenException(); throw new HTTPException\ForbiddenException();

View File

@ -7,6 +7,7 @@ use Friendica\Content\Nav;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
/** /**
* Shows the App menu * Shows the App menu
@ -17,7 +18,7 @@ class Apps extends BaseModule
{ {
$privateaddons = Config::get('config', 'private_addons'); $privateaddons = Config::get('config', 'private_addons');
if ($privateaddons === "1" && !local_user()) { if ($privateaddons === "1" && !local_user()) {
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
} }

View File

@ -10,6 +10,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Attach as MAttach; use Friendica\Model\Attach as MAttach;
/** /**
@ -22,7 +23,7 @@ class Attach extends BaseModule
*/ */
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if ($a->argc != 2) { if ($a->argc != 2) {
throw new \Friendica\Network\HTTPException\BadRequestException(); throw new \Friendica\Network\HTTPException\BadRequestException();
} }

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Base;
use Friendica\App\Arguments; use Friendica\App\Arguments;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\DI;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
require_once __DIR__ . '/../../../include/api.php'; require_once __DIR__ . '/../../../include/api.php';
@ -41,7 +42,7 @@ class Api extends BaseModule
throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.')); throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.'));
} }
$a = self::getApp(); $a = DI::app();
if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) { if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
throw new HTTPException\ForbiddenException(L10n::t('Permission denied.')); throw new HTTPException\ForbiddenException(L10n::t('Permission denied.'));
@ -67,7 +68,7 @@ class Api extends BaseModule
*/ */
protected static function login() protected static function login()
{ {
api_login(self::getApp()); api_login(DI::app());
self::$current_user_id = api_user(); self::$current_user_id = api_user();
@ -86,7 +87,7 @@ class Api extends BaseModule
*/ */
protected static function getUser($contact_id = null) protected static function getUser($contact_id = null)
{ {
return api_get_user(self::getApp(), $contact_id); return api_get_user(DI::app(), $contact_id);
} }
protected static function format($root_element, $data) protected static function format($root_element, $data)

View File

@ -7,6 +7,7 @@ use Friendica\Core\Addon;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\HTTPException\ForbiddenException; use Friendica\Network\HTTPException\ForbiddenException;
require_once 'boot.php'; require_once 'boot.php';
@ -50,7 +51,7 @@ abstract class BaseAdminModule extends BaseModule
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if (!is_site_admin()) { if (!is_site_admin()) {
notice(L10n::t('Please login to continue.')); notice(L10n::t('Please login to continue.'));

View File

@ -9,6 +9,7 @@ use Friendica\Content\Pager;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Object\Search\ContactResult; use Friendica\Object\Search\ContactResult;
@ -33,7 +34,7 @@ class BaseSearchModule extends BaseModule
*/ */
public static function performContactSearch($search, $prefix = '') public static function performContactSearch($search, $prefix = '')
{ {
$a = self::getApp(); $a = DI::app();
$config = $a->getConfig(); $config = $a->getConfig();
$type = Search::TYPE_ALL; $type = Search::TYPE_ALL;
@ -97,7 +98,7 @@ class BaseSearchModule extends BaseModule
return ''; return '';
} }
$a = self::getApp(); $a = DI::app();
$id = 0; $id = 0;
$entries = []; $entries = [];

View File

@ -6,12 +6,13 @@ use Friendica\BaseModule;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
class BaseSettingsModule extends BaseModule class BaseSettingsModule extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$tpl = Renderer::getMarkupTemplate('settings/head.tpl'); $tpl = Renderer::getMarkupTemplate('settings/head.tpl');
$a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [ $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [

View File

@ -5,6 +5,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\ACL; use Friendica\Core\ACL;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\DI;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -19,7 +20,7 @@ class Bookmarklet extends BaseModule
{ {
$_GET['mode'] = 'minimal'; $_GET['mode'] = 'minimal';
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
if (!local_user()) { if (!local_user()) {

View File

@ -17,6 +17,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\BadRequestException;
@ -78,7 +79,7 @@ class Contact extends BaseModule
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if (!local_user()) { if (!local_user()) {
return; return;
@ -247,7 +248,7 @@ class Contact extends BaseModule
return Login::form($_SERVER['REQUEST_URI']); return Login::form($_SERVER['REQUEST_URI']);
} }
$a = self::getApp(); $a = DI::app();
$nets = $_GET['nets'] ?? ''; $nets = $_GET['nets'] ?? '';
$rel = $_GET['rel'] ?? ''; $rel = $_GET['rel'] ?? '';

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Protocol; use Friendica\Protocol;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -18,7 +19,7 @@ class Feed extends BaseModule
{ {
if (!local_user()) { if (!local_user()) {
info(L10n::t('You must be logged in to use this module')); info(L10n::t('You must be logged in to use this module'));
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
} }

View File

@ -4,6 +4,7 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -18,7 +19,7 @@ class ItemBody extends BaseModule
throw new HTTPException\UnauthorizedException(L10n::t('Access denied.')); throw new HTTPException\UnauthorizedException(L10n::t('Access denied.'));
} }
$app = self::getApp(); $app = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0); $itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Installer; use Friendica\Core\Installer;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\DI;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
@ -17,13 +18,13 @@ class Localtime extends BaseModule
$bd_format = L10n::t('l F d, Y \@ g:i A'); $bd_format = L10n::t('l F d, Y \@ g:i A');
if (!empty($_POST['timezone'])) { if (!empty($_POST['timezone'])) {
self::getApp()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format); DI::app()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
} }
} }
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
$time = ($_REQUEST['time'] ?? '') ?: 'now'; $time = ($_REQUEST['time'] ?? '') ?: 'now';

View File

@ -9,6 +9,7 @@ use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPException\ForbiddenException; use Friendica\Network\HTTPException\ForbiddenException;
@ -25,7 +26,7 @@ class Delegation extends BaseModule
} }
$uid = local_user(); $uid = local_user();
$orig_record = self::getApp()->user; $orig_record = DI::app()->user;
if (Session::get('submanage')) { if (Session::get('submanage')) {
$user = User::getById(Session::get('submanage')); $user = User::getById(Session::get('submanage'));
@ -82,7 +83,7 @@ class Delegation extends BaseModule
/** @var Authentication $authentication */ /** @var Authentication $authentication */
$authentication = self::getClass(Authentication::class); $authentication = self::getClass(Authentication::class);
$authentication->setForUser(self::getApp(), $user, true, true); $authentication->setForUser(DI::app(), $user, true, true);
if ($limited_id) { if ($limited_id) {
Session::set('submanage', $original_id); Session::set('submanage', $original_id);
@ -91,7 +92,7 @@ class Delegation extends BaseModule
$ret = []; $ret = [];
Hook::callAll('home_init', $ret); Hook::callAll('home_init', $ret);
self::getApp()->internalRedirect('profile/' . self::getApp()->user['nickname']); DI::app()->internalRedirect('profile/' . DI::app()->user['nickname']);
// NOTREACHED // NOTREACHED
} }
@ -101,7 +102,7 @@ class Delegation extends BaseModule
throw new ForbiddenException(L10n::t('Permission denied.')); throw new ForbiddenException(L10n::t('Permission denied.'));
} }
$identities = self::getApp()->identities; $identities = DI::app()->identities;
//getting additinal information for each identity //getting additinal information for each identity
foreach ($identities as $key => $identity) { foreach ($identities as $key => $identity) {
@ -112,7 +113,7 @@ class Delegation extends BaseModule
$identities[$key]['thumb'] = $thumb['thumb']; $identities[$key]['thumb'] = $thumb['thumb'];
$identities[$key]['selected'] = ($identity['nickname'] === self::getApp()->user['nickname']); $identities[$key]['selected'] = ($identity['nickname'] === DI::app()->user['nickname']);
$condition = ["`uid` = ? AND `msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", $identity['uid'], NOTIFY_INTRO, NOTIFY_MAIL]; $condition = ["`uid` = ? AND `msg` != '' AND NOT (`type` IN (?, ?)) AND NOT `seen`", $identity['uid'], NOTIFY_INTRO, NOTIFY_MAIL];
$params = ['distinct' => true, 'expression' => 'parent']; $params = ['distinct' => true, 'expression' => 'parent'];

View File

@ -5,6 +5,7 @@ namespace Friendica\Module\Diaspora;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -19,7 +20,7 @@ class Fetch extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($app->argc != 3) || (!in_array($app->argv[1], ["post", "status_message", "reshare"]))) { if (($app->argc != 3) || (!in_array($app->argv[1], ["post", "status_message", "reshare"]))) {

View File

@ -10,6 +10,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -23,7 +24,7 @@ class Directory extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
if (($config->get('system', 'block_public') && !Session::isAuthenticated()) || if (($config->get('system', 'block_public') && !Session::isAuthenticated()) ||

View File

@ -3,6 +3,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
/** /**
@ -25,7 +26,7 @@ class Feed extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$last_update = $_GET['last_update'] ?? ''; $last_update = $_GET['last_update'] ?? '';
$nocache = !empty($_GET['nocache']) && local_user(); $nocache = !empty($_GET['nocache']) && local_user();

View File

@ -3,6 +3,7 @@
namespace Friendica\Module\Filer; namespace Friendica\Module\Filer;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Model\FileTag; use Friendica\Model\FileTag;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -18,7 +19,7 @@ class RemoveTag extends BaseModule
throw new HTTPException\ForbiddenException(); throw new HTTPException\ForbiddenException();
} }
$app = self::getApp(); $app = DI::app();
$logger = $app->getLogger(); $logger = $app->getLogger();
$item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0); $item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0);

View File

@ -6,6 +6,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -18,13 +19,13 @@ class SaveTag extends BaseModule
{ {
if (!local_user()) { if (!local_user()) {
info(L10n::t('You must be logged in to use this module')); info(L10n::t('You must be logged in to use this module'));
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
} }
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$logger = $a->getLogger(); $logger = $a->getLogger();
$term = XML::unescape(trim($_GET['term'] ?? '')); $term = XML::unescape(trim($_GET['term'] ?? ''));

View File

@ -4,6 +4,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Model\Introduction; use Friendica\Model\Introduction;
use Friendica\DI;
/** /**
* Process follow request confirmations * Process follow request confirmations
@ -12,7 +13,7 @@ class FollowConfirm extends BaseModule
{ {
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$uid = local_user(); $uid = local_user();
if (!$uid) { if (!$uid) {

View File

@ -6,6 +6,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
@ -16,7 +17,7 @@ class Followers extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (empty($a->argv[1])) { if (empty($a->argv[1])) {

View File

@ -6,6 +6,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
@ -16,7 +17,7 @@ class Following extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (empty($a->argv[1])) { if (empty($a->argv[1])) {

View File

@ -7,6 +7,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
/** /**
@ -17,7 +18,7 @@ class Friendica extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
$visibleAddonList = Addon::getVisibleList(); $visibleAddonList = Addon::getVisibleList();
@ -90,7 +91,7 @@ class Friendica extends BaseModule
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($app->argc <= 1 || ($app->argv[1] !== 'json')) { if ($app->argc <= 1 || ($app->argv[1] !== 'json')) {

View File

@ -12,6 +12,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -21,7 +22,7 @@ class Group extends BaseModule
{ {
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if ($a->isAjax()) { if ($a->isAjax()) {
self::ajaxPost(); self::ajaxPost();
@ -71,7 +72,7 @@ class Group extends BaseModule
public static function ajaxPost() public static function ajaxPost()
{ {
try { try {
$a = self::getApp(); $a = DI::app();
if (!local_user()) { if (!local_user()) {
throw new \Exception(L10n::t('Permission denied.'), 403); throw new \Exception(L10n::t('Permission denied.'), 403);
@ -134,7 +135,7 @@ class Group extends BaseModule
throw new \Friendica\Network\HTTPException\ForbiddenException(); throw new \Friendica\Network\HTTPException\ForbiddenException();
} }
$a = self::getApp(); $a = DI::app();
$a->page['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone')); $a->page['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));

View File

@ -6,6 +6,7 @@ use Friendica\BaseModule;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Text\Markdown; use Friendica\Content\Text\Markdown;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\DI;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -21,7 +22,7 @@ class Help extends BaseModule
$text = ''; $text = '';
$filename = ''; $filename = '';
$a = self::getApp(); $a = DI::app();
$config = $a->getConfig(); $config = $a->getConfig();
$lang = $config->get('system', 'language'); $lang = $config->get('system', 'language');

View File

@ -6,6 +6,7 @@ use Friendica\BaseModule;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
/** /**
@ -15,7 +16,7 @@ class Home extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
// currently no returned data is used // currently no returned data is used

View File

@ -10,6 +10,7 @@ use Friendica\Core\Config;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -21,7 +22,7 @@ class Inbox extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$postdata = Network::postdata(); $postdata = Network::postdata();

View File

@ -8,6 +8,7 @@ use Friendica\Core;
use Friendica\Core\Config\Cache\ConfigCache; use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\BasePath; use Friendica\Util\BasePath;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -48,7 +49,7 @@ class Install extends BaseModule
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if (!$a->getMode()->isInstall()) { if (!$a->getMode()->isInstall()) {
throw new HTTPException\ForbiddenException(); throw new HTTPException\ForbiddenException();
@ -78,7 +79,7 @@ class Install extends BaseModule
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$configCache = $a->getConfigCache(); $configCache = $a->getConfigCache();
switch (self::$currentWizardStep) { switch (self::$currentWizardStep) {
@ -151,7 +152,7 @@ class Install extends BaseModule
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$configCache = $a->getConfigCache(); $configCache = $a->getConfigCache();
$output = ''; $output = '';

View File

@ -6,6 +6,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
@ -24,7 +25,7 @@ class Invite extends BaseModule
self::checkFormSecurityTokenRedirectOnError('/', 'send_invite'); self::checkFormSecurityTokenRedirectOnError('/', 'send_invite');
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
$max_invites = intval($config->get('system', 'max_invites')); $max_invites = intval($config->get('system', 'max_invites'));
@ -110,7 +111,7 @@ class Invite extends BaseModule
throw new HTTPException\ForbiddenException(L10n::t('Permission denied.')); throw new HTTPException\ForbiddenException(L10n::t('Permission denied.'));
} }
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
$inviteOnly = false; $inviteOnly = false;

View File

@ -12,6 +12,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\FileTag; use Friendica\Model\FileTag;
use Friendica\Model\Group; use Friendica\Model\Group;
@ -29,7 +30,7 @@ class Compose extends BaseModule
if (!empty($_REQUEST['body'])) { if (!empty($_REQUEST['body'])) {
$_REQUEST['return'] = 'network'; $_REQUEST['return'] = 'network';
require_once 'mod/item.php'; require_once 'mod/item.php';
item_post(self::getApp()); item_post(DI::app());
} else { } else {
notice(L10n::t('Please enter a post body.')); notice(L10n::t('Please enter a post body.'));
} }
@ -41,7 +42,7 @@ class Compose extends BaseModule
return Login::form('compose', false); return Login::form('compose', false);
} }
$a = self::getApp(); $a = DI::app();
if ($a->getCurrentTheme() !== 'frio') { if ($a->getCurrentTheme() !== 'frio') {
throw new NotImplementedException(L10n::t('This feature is only available with the frio theme.')); throw new NotImplementedException(L10n::t('This feature is only available with the frio theme.'));

View File

@ -8,6 +8,7 @@ use Friendica\Core\L10n\L10n;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -69,7 +70,7 @@ class Ignore extends BaseModule
$rand = "?$rand"; $rand = "?$rand";
} }
self::getApp()->internalRedirect($return_path . $rand); DI::app()->internalRedirect($return_path . $rand);
} }
// the json doesn't really matter, it will either be 0 or 1 // the json doesn't really matter, it will either be 0 or 1

View File

@ -3,6 +3,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -25,7 +26,7 @@ class Like extends BaseModule
$verb = 'like'; $verb = 'like';
} }
$app = self::getApp(); $app = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0); $itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0);

View File

@ -8,6 +8,7 @@ use Friendica\BaseModule;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -22,7 +23,7 @@ class Magic extends BaseModule
{ {
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$ret = ['success' => false, 'url' => '', 'message' => '']; $ret = ['success' => false, 'url' => '', 'message' => ''];
Logger::log('magic mdule: invoked', Logger::DEBUG); Logger::log('magic mdule: invoked', Logger::DEBUG);
@ -48,7 +49,7 @@ class Magic extends BaseModule
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]); $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site. // 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(self::getApp()->getBaseURL())) !== false) { if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(DI::app()->getBaseURL())) !== false) {
if ($test) { if ($test) {
$ret['success'] = true; $ret['success'] = true;
$ret['message'] .= 'Local site - you are already authenticated.' . EOL; $ret['message'] .= 'Local site - you are already authenticated.' . EOL;

View File

@ -5,6 +5,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -16,7 +17,7 @@ class Maintenance extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$config = self::getApp()->getConfig(); $config = DI::app()->getConfig();
$reason = $config->get('system', 'maintenance_reason'); $reason = $config->get('system', 'maintenance_reason');

View File

@ -4,12 +4,13 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI;
class Manifest extends BaseModule class Manifest extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
$config = $app->getConfig(); $config = $app->getConfig();
$tpl = Renderer::getMarkupTemplate('manifest.tpl'); $tpl = Renderer::getMarkupTemplate('manifest.tpl');

View File

@ -6,6 +6,7 @@ use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
/** /**
* Standardized way of exposing metadata about a server running one of the distributed social networks. * Standardized way of exposing metadata about a server running one of the distributed social networks.
@ -15,7 +16,7 @@ class NodeInfo extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
if ($parameters['version'] == '1.0') { if ($parameters['version'] == '1.0') {
self::printNodeInfo1($app); self::printNodeInfo1($app);

View File

@ -6,6 +6,7 @@ use Friendica\BaseModule;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Notify as ModelNotify; use Friendica\Model\Notify as ModelNotify;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -23,7 +24,7 @@ class Notify extends BaseModule
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') { if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
@ -47,7 +48,7 @@ class Notify extends BaseModule
*/ */
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) { if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {

View File

@ -7,6 +7,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
@ -17,7 +18,7 @@ class Objects extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if (empty($a->argv[1])) { if (empty($a->argv[1])) {
throw new \Friendica\Network\HTTPException\NotFoundException(); throw new \Friendica\Network\HTTPException\NotFoundException();

View File

@ -4,6 +4,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content; use Friendica\Content;
use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
/** /**
@ -19,7 +20,7 @@ class Oembed extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// Unused form: /oembed/b2h?url=... // Unused form: /oembed/b2h?url=...
if ($a->argv[1] == 'b2h') { if ($a->argv[1] == 'b2h') {

View File

@ -5,6 +5,7 @@ namespace Friendica\Module;
use DOMDocument; use DOMDocument;
use DOMElement; use DOMElement;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Util\XML; use Friendica\Util\XML;
/** /**
@ -20,8 +21,8 @@ class OpenSearch extends BaseModule
{ {
header('Content-type: application/opensearchdescription+xml'); header('Content-type: application/opensearchdescription+xml');
$hostname = self::getApp()->getHostName(); $hostname = DI::app()->getHostName();
$baseUrl = self::getApp()->getBaseURL(); $baseUrl = DI::app()->getBaseURL();
/** @var DOMDocument $xml */ /** @var DOMDocument $xml */
$xml = null; $xml = null;

View File

@ -6,6 +6,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
@ -16,7 +17,7 @@ class Outbox extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (empty($a->argv[1])) { if (empty($a->argv[1])) {

View File

@ -9,6 +9,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Photo as MPhoto; use Friendica\Model\Photo as MPhoto;
use Friendica\Object\Image; use Friendica\Object\Image;
@ -25,7 +26,7 @@ class Photo extends BaseModule
*/ */
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc <= 1 || $a->argc > 4) { if ($a->argc <= 1 || $a->argc > 4) {
throw new \Friendica\Network\HTTPException\BadRequestException(); throw new \Friendica\Network\HTTPException\BadRequestException();

View File

@ -3,6 +3,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
/** /**
@ -30,7 +31,7 @@ class Pinned extends BaseModule
$returnPath = $_REQUEST['return'] ?? ''; $returnPath = $_REQUEST['return'] ?? '';
if (!empty($returnPath)) { if (!empty($returnPath)) {
$rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand'; $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand';
self::getApp()->internalRedirect($returnPath . $rand); DI::app()->internalRedirect($returnPath . $rand);
} }
// the json doesn't really matter, it will either be 0 or 1 // the json doesn't really matter, it will either be 0 or 1

View File

@ -14,6 +14,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact as ContactModel; use Friendica\Model\Contact as ContactModel;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
@ -36,7 +37,7 @@ class Profile extends BaseModule
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc < 2) { if ($a->argc < 2) {
@ -78,7 +79,7 @@ class Profile extends BaseModule
public static function content(array $parameters = [], $update = 0) public static function content(array $parameters = [], $update = 0)
{ {
$a = self::getApp(); $a = DI::app();
if (!$update) { if (!$update) {
ProfileModel::load($a, self::$which, self::$profile); ProfileModel::load($a, self::$which, self::$profile);

View File

@ -12,6 +12,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Proxy as ProxyUtils;
@ -24,7 +25,7 @@ class Contacts extends BaseModule
throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('User not found.')); throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('User not found.'));
} }
$a = self::getApp(); $a = DI::app();
//@TODO: Get value from router parameters //@TODO: Get value from router parameters
$nickname = $a->argv[1]; $nickname = $a->argv[1];

View File

@ -9,6 +9,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
@ -33,7 +34,7 @@ class Proxy extends BaseModule
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
// Set application instance here // Set application instance here
$a = self::getApp(); $a = DI::app();
/* /*
* Pictures are stored in one of the following ways: * Pictures are stored in one of the following ways:
@ -156,7 +157,7 @@ class Proxy extends BaseModule
*/ */
private static function getRequestInfo() private static function getRequestInfo()
{ {
$a = self::getApp(); $a = DI::app();
$size = 1024; $size = 1024;
$sizetype = ''; $sizetype = '';
@ -230,7 +231,7 @@ class Proxy extends BaseModule
*/ */
private static function setupDirectCache() private static function setupDirectCache()
{ {
$a = self::getApp(); $a = DI::app();
$basepath = $a->getBasePath(); $basepath = $a->getBasePath();
// If the cache path isn't there, try to create it // If the cache path isn't there, try to create it

View File

@ -4,6 +4,7 @@ namespace Friendica\Module;
use ASN_BASE; use ASN_BASE;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\BadRequestException;
@ -14,7 +15,7 @@ class PublicRSAKey extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = self::getApp(); $app = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($app->argc !== 2) { if ($app->argc !== 2) {

View File

@ -3,6 +3,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
@ -13,7 +14,7 @@ class RandomProfile extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
$contactUrl = GContact::getRandomUrl(); $contactUrl = GContact::getRandomUrl();

View File

@ -3,6 +3,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Util\XML; use Friendica\Util\XML;
/** /**
@ -15,7 +16,7 @@ class ReallySimpleDiscovery extends BaseModule
{ {
header('Content-Type: text/xml'); header('Content-Type: text/xml');
$app = self::getApp(); $app = DI::app();
$xml = null; $xml = null;
echo XML::fromArray([ echo XML::fromArray([
'rsd' => [ 'rsd' => [

View File

@ -14,6 +14,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -123,7 +124,7 @@ class Register extends BaseModule
'$ask_password' => $ask_password, '$ask_password' => $ask_password,
'$password1' => ['password1', L10n::t('New Password:'), '', L10n::t('Leave empty for an auto generated password.')], '$password1' => ['password1', L10n::t('New Password:'), '', L10n::t('Leave empty for an auto generated password.')],
'$password2' => ['confirm', L10n::t('Confirm:'), '', ''], '$password2' => ['confirm', L10n::t('Confirm:'), '', ''],
'$nickdesc' => L10n::t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "<strong>nickname@%s</strong>".', self::getApp()->getHostName()), '$nickdesc' => L10n::t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be "<strong>nickname@%s</strong>".', DI::app()->getHostName()),
'$nicklabel' => L10n::t('Choose a nickname: '), '$nicklabel' => L10n::t('Choose a nickname: '),
'$photo' => $photo, '$photo' => $photo,
'$publish' => $profile_publish, '$publish' => $profile_publish,
@ -131,7 +132,7 @@ class Register extends BaseModule
'$username' => $username, '$username' => $username,
'$email' => $email, '$email' => $email,
'$nickname' => $nickname, '$nickname' => $nickname,
'$sitename' => self::getApp()->getHostName(), '$sitename' => DI::app()->getHostName(),
'$importh' => L10n::t('Import'), '$importh' => L10n::t('Import'),
'$importt' => L10n::t('Import your profile to this friendica instance'), '$importt' => L10n::t('Import your profile to this friendica instance'),
'$showtoslink' => Config::get('system', 'tosdisplay'), '$showtoslink' => Config::get('system', 'tosdisplay'),
@ -156,7 +157,7 @@ class Register extends BaseModule
{ {
BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register'); BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register');
$a = self::getApp(); $a = DI::app();
$arr = ['post' => $_POST]; $arr = ['post' => $_POST];
Hook::callAll('register_post', $arr); Hook::callAll('register_post', $arr);

View File

@ -4,6 +4,7 @@ namespace Friendica\Module\Search;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\DI;
use Friendica\Module\BaseSearchModule; use Friendica\Module\BaseSearchModule;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -22,7 +23,7 @@ class Directory extends BaseSearchModule
$search = Strings::escapeTags(trim(rawurldecode($_REQUEST['search'] ?? ''))); $search = Strings::escapeTags(trim(rawurldecode($_REQUEST['search'] ?? '')));
$a = self::getApp(); $a = DI::app();
if (empty($a->page['aside'])) { if (empty($a->page['aside'])) {
$a->page['aside'] = ''; $a->page['aside'] = '';

View File

@ -16,6 +16,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Term; use Friendica\Model\Term;
@ -68,7 +69,7 @@ class Index extends BaseSearchModule
} }
if (local_user()) { if (local_user()) {
self::getApp()->page['aside'] .= Widget\SavedSearches::getHTML('search?q=' . urlencode($search), $search); DI::app()->page['aside'] .= Widget\SavedSearches::getHTML('search?q=' . urlencode($search), $search);
} }
Nav::setSelected('search'); Nav::setSelected('search');
@ -190,7 +191,7 @@ class Index extends BaseSearchModule
Logger::info('Start Conversation.', ['q' => $search]); Logger::info('Start Conversation.', ['q' => $search]);
$o .= conversation(self::getApp(), $r, $pager, 'search', false, false, 'commented', local_user()); $o .= conversation(DI::app(), $r, $pager, 'search', false, false, 'commented', local_user());
$o .= $pager->renderMinimal(count($r)); $o .= $pager->renderMinimal(count($r));

View File

@ -6,6 +6,7 @@ use Friendica\App\Arguments;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
class Saved extends BaseModule class Saved extends BaseModule
@ -39,6 +40,6 @@ class Saved extends BaseModule
} }
} }
self::getApp()->internalRedirect($return_url); DI::app()->internalRedirect($return_url);
} }
} }

View File

@ -13,6 +13,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Register; use Friendica\Module\Register;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -25,7 +26,7 @@ class Login extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = self::getApp(); $a = DI::app();
if (local_user()) { if (local_user()) {
$a->internalRedirect(); $a->internalRedirect();
@ -57,7 +58,7 @@ class Login extends BaseModule
/** @var Authentication $authentication */ /** @var Authentication $authentication */
$authentication = self::getClass(Authentication::class); $authentication = self::getClass(Authentication::class);
$authentication->withPassword( $authentication->withPassword(
self::getApp(), DI::app(),
trim($_POST['username']), trim($_POST['username']),
trim($_POST['password']), trim($_POST['password']),
!empty($_POST['remember']) !empty($_POST['remember'])
@ -81,7 +82,7 @@ class Login extends BaseModule
*/ */
public static function form($return_path = null, $register = false, $hiddens = []) public static function form($return_path = null, $register = false, $hiddens = [])
{ {
$a = self::getApp(); $a = DI::app();
$o = ''; $o = '';
$noid = Config::get('system', 'no_openid'); $noid = Config::get('system', 'no_openid');
@ -133,7 +134,7 @@ class Login extends BaseModule
$o .= Renderer::replaceMacros( $o .= Renderer::replaceMacros(
$tpl, $tpl,
[ [
'$dest_url' => self::getApp()->getBaseURL(true) . '/login', '$dest_url' => DI::app()->getBaseURL(true) . '/login',
'$logout' => L10n::t('Logout'), '$logout' => L10n::t('Logout'),
'$login' => L10n::t('Login'), '$login' => L10n::t('Login'),

View File

@ -12,6 +12,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Profile; use Friendica\Model\Profile;
/** /**
@ -39,7 +40,7 @@ class Logout extends BaseModule
System::externalRedirect($visitor_home); System::externalRedirect($visitor_home);
} else { } else {
info(L10n::t('Logged out.')); info(L10n::t('Logged out.'));
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
} }
} }

View File

@ -7,6 +7,7 @@ use Friendica\App\Authentication;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\TwoFactor\RecoveryCode; use Friendica\Model\TwoFactor\RecoveryCode;
/** /**
@ -32,7 +33,7 @@ class Recovery extends BaseModule
if (($_POST['action'] ?? '') == 'recover') { if (($_POST['action'] ?? '') == 'recover') {
self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery'); self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery');
$a = self::getApp(); $a = DI::app();
$recovery_code = $_POST['recovery_code'] ?? ''; $recovery_code = $_POST['recovery_code'] ?? '';
@ -54,12 +55,12 @@ class Recovery extends BaseModule
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
if (!local_user()) { if (!local_user()) {
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
// Already authenticated with 2FA token // Already authenticated with 2FA token
if (Session::get('2fa')) { if (Session::get('2fa')) {
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/recovery.tpl'), [ return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/recovery.tpl'), [

View File

@ -8,6 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\DI;
use PragmaRX\Google2FA\Google2FA; use PragmaRX\Google2FA\Google2FA;
/** /**
@ -28,7 +29,7 @@ class Verify extends BaseModule
if (($_POST['action'] ?? '') == 'verify') { if (($_POST['action'] ?? '') == 'verify') {
self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_verify'); self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_verify');
$a = self::getApp(); $a = DI::app();
$code = $_POST['verify_code'] ?? ''; $code = $_POST['verify_code'] ?? '';
@ -51,12 +52,12 @@ class Verify extends BaseModule
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
if (!local_user()) { if (!local_user()) {
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
// Already authenticated with 2FA token // Already authenticated with 2FA token
if (Session::get('2fa')) { if (Session::get('2fa')) {
self::getApp()->internalRedirect(); DI::app()->internalRedirect();
} }
return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/verify.tpl'), [ return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/verify.tpl'), [

View File

@ -10,6 +10,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\BaseSettingsModule; use Friendica\Module\BaseSettingsModule;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -22,7 +23,7 @@ class Delegation extends BaseSettingsModule
{ {
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
if (!local_user() || !empty(self::getApp()->user['uid']) && self::getApp()->user['uid'] != local_user()) { if (!local_user() || !empty(DI::app()->user['uid']) && DI::app()->user['uid'] != local_user()) {
throw new HTTPException\ForbiddenException(L10n::t('Permission denied.')); throw new HTTPException\ForbiddenException(L10n::t('Permission denied.'));
} }
@ -64,7 +65,7 @@ class Delegation extends BaseSettingsModule
if ($action === 'add' && $user_id) { if ($action === 'add' && $user_id) {
if (Session::get('submanage')) { if (Session::get('submanage')) {
notice(L10n::t('Delegated administrators can view but not change delegation permissions.')); notice(L10n::t('Delegated administrators can view but not change delegation permissions.'));
self::getApp()->internalRedirect('settings/delegation'); DI::app()->internalRedirect('settings/delegation');
} }
$user = User::getById($user_id, ['nickname']); $user = User::getById($user_id, ['nickname']);
@ -80,17 +81,17 @@ class Delegation extends BaseSettingsModule
notice(L10n::t('Delegate user not found.')); notice(L10n::t('Delegate user not found.'));
} }
self::getApp()->internalRedirect('settings/delegation'); DI::app()->internalRedirect('settings/delegation');
} }
if ($action === 'remove' && $user_id) { if ($action === 'remove' && $user_id) {
if (Session::get('submanage')) { if (Session::get('submanage')) {
notice(L10n::t('Delegated administrators can view but not change delegation permissions.')); notice(L10n::t('Delegated administrators can view but not change delegation permissions.'));
self::getApp()->internalRedirect('settings/delegation'); DI::app()->internalRedirect('settings/delegation');
} }
DBA::delete('manage', ['uid' => $user_id, 'mid' => local_user()]); DBA::delete('manage', ['uid' => $user_id, 'mid' => local_user()]);
self::getApp()->internalRedirect('settings/delegation'); DI::app()->internalRedirect('settings/delegation');
} }
// find everybody that currently has delegated management to this account/page // find everybody that currently has delegated management to this account/page

Some files were not shown because too many files have changed in this diff Show More