Browse Source

Merge pull request #8019 from nupplaphil/task/replace_getClass

Introduce new way of static/dynamic bridge / CleanUp deprecated methods
pull/8032/head
Hypolite Petovan 2 years ago
committed by GitHub
parent
commit
03038e7a3b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      bin/auth_ejabberd.php
  2. 7
      bin/daemon.php
  3. 12
      bin/worker.php
  4. 11
      boot.php
  5. 4
      doc/Addons.md
  6. 58
      include/api.php
  7. 31
      include/conversation.php
  8. 3
      include/enotify.php
  9. 24
      include/items.php
  10. 6
      index.php
  11. 7
      mod/api.php
  12. 9
      mod/cal.php
  13. 3
      mod/common.php
  14. 5
      mod/community.php
  15. 5
      mod/dfrn_confirm.php
  16. 25
      mod/dfrn_poll.php
  17. 25
      mod/dfrn_request.php
  18. 5
      mod/display.php
  19. 18
      mod/events.php
  20. 15
      mod/follow.php
  21. 32
      mod/item.php
  22. 6
      mod/lockview.php
  23. 7
      mod/lostpass.php
  24. 3
      mod/match.php
  25. 19
      mod/message.php
  26. 34
      mod/network.php
  27. 3
      mod/notes.php
  28. 18
      mod/notifications.php
  29. 3
      mod/ostatus_subscribe.php
  30. 56
      mod/photos.php
  31. 9
      mod/profile_photo.php
  32. 17
      mod/profiles.php
  33. 2
      mod/pubsub.php
  34. 7
      mod/redir.php
  35. 11
      mod/regmod.php
  36. 7
      mod/removeme.php
  37. 3
      mod/repair_ostatus.php
  38. 27
      mod/settings.php
  39. 7
      mod/suggest.php
  40. 17
      mod/tagrm.php
  41. 2
      mod/uimport.php
  42. 19
      mod/unfollow.php
  43. 11
      mod/videos.php
  44. 3
      mod/wallmessage.php
  45. 259
      src/App.php
  46. 21
      src/App/Authentication.php
  47. 8
      src/App/BaseURL.php
  48. 14
      src/App/Module.php
  49. 16
      src/App/Page.php
  50. 11
      src/BaseModel.php
  51. 4
      src/BaseModule.php
  52. 69
      src/BaseObject.php
  53. 4
      src/Console/AutomaticInstallation.php
  54. 6
      src/Console/Config.php
  55. 6
      src/Console/Maintenance.php
  56. 8
      src/Console/PostUpdate.php
  57. 18
      src/Console/ServerBlock.php
  58. 6
      src/Console/Typo.php
  59. 7
      src/Content/Nav.php
  60. 20
      src/Content/Text/BBCode.php
  61. 6
      src/Content/Text/Markdown.php
  62. 16
      src/Core/ACL.php
  63. 14
      src/Core/Addon.php
  64. 15
      src/Core/Cache.php
  65. 4
      src/Core/Cache/MemcacheCache.php
  66. 4
      src/Core/Cache/MemcachedCache.php
  67. 4
      src/Core/Cache/RedisCache.php
  68. 13
      src/Core/Config.php
  69. 62
      src/Core/Config/Configuration.php
  70. 73
      src/Core/Config/IConfiguration.php
  71. 82
      src/Core/Config/IPConfiguration.php
  72. 66
      src/Core/Config/PConfiguration.php
  73. 2
      src/Core/Console.php
  74. 12
      src/Core/Hook.php
  75. 18
      src/Core/L10n.php
  76. 4
      src/Core/L10n/L10n.php
  77. 13
      src/Core/Lock.php
  78. 38
      src/Core/Logger.php
  79. 13
      src/Core/PConfig.php
  80. 6
      src/Core/Process.php
  81. 13
      src/Core/Renderer.php
  82. 9
      src/Core/Search.php
  83. 29
      src/Core/Session.php
  84. 12
      src/Core/System.php
  85. 9
      src/Core/Theme.php
  86. 6
      src/Core/UserImport.php
  87. 26
      src/Core/Worker.php
  88. 88
      src/DI.php
  89. 78
      src/Database/DBA.php
  90. 6
      src/Factory/CacheFactory.php
  91. 4
      src/Factory/ConfigFactory.php
  92. 6
      src/Factory/LockFactory.php
  93. 10
      src/Factory/LoggerFactory.php
  94. 7
      src/Factory/SessionFactory.php
  95. 2
      src/LegacyModule.php
  96. 3
      src/Model/APContact.php
  97. 6
      src/Model/Attach.php
  98. 15
      src/Model/Contact.php
  99. 3
      src/Model/Event.php
  100. 3
      src/Model/Group.php

3
bin/auth_ejabberd.php

@ -34,7 +34,6 @@
use Dice\Dice;
use Friendica\App\Mode;
use Friendica\BaseObject;
use Friendica\Util\ExAuth;
use Psr\Log\LoggerInterface;
@ -57,7 +56,7 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['auth_ejabberd']]);
BaseObject::setDependencyInjection($dice);
\Friendica\DI::init($dice);
$appMode = $dice->create(Mode::class);

7
bin/daemon.php

@ -12,6 +12,7 @@ use Friendica\Core\Config;
use Friendica\Core\Logger;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Psr\Log\LoggerInterface;
// Get options
@ -36,10 +37,10 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]);
\Friendica\BaseObject::setDependencyInjection($dice);
$a = \Friendica\BaseObject::getApp();
DI::init($dice);
$a = DI::app();
if ($a->getMode()->isInstall()) {
if (DI::mode()->isInstall()) {
die("Friendica isn't properly installed yet.\n");
}

12
bin/worker.php

@ -7,10 +7,10 @@
use Dice\Dice;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Update;
use Friendica\Core\Worker;
use Friendica\DI;
use Psr\Log\LoggerInterface;
// Get options
@ -35,18 +35,18 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);
BaseObject::setDependencyInjection($dice);
$a = BaseObject::getApp();
DI::init($dice);
$a = DI::app();
// Check the database structure and possibly fixes it
Update::check($a->getBasePath(), true, $a->getMode());
Update::check($a->getBasePath(), true, DI::mode());
// Quit when in maintenance
if (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED)) {
if (!DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
return;
}
$a->setBaseURL(Config::get('system', 'url'));
DI::baseUrl()->saveByURL(Config::get('system', 'url'));
$spawn = array_key_exists('s', $options) || array_key_exists('spawn', $options);

11
boot.php

@ -18,13 +18,12 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Term;
use Friendica\Util\BasePath;
@ -241,12 +240,12 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) {
* Useful in functions which require it but don't get it passed to them
*
* @deprecated since version 2018.09
* @see BaseObject::getApp()
* @see DI::app()
* @return App
*/
function get_app()
{
return BaseObject::getApp();
return DI::app();
}
/**
@ -483,8 +482,6 @@ function get_server()
function get_temppath()
{
$a = \get_app();
$temppath = Config::get("system", "temppath");
if (($temppath != "") && System::isDirectoryUsable($temppath)) {
@ -501,7 +498,7 @@ function get_temppath()
$temppath = BasePath::getRealPath($temppath);
// To avoid any interferences with other systems we create our own directory
$new_temppath = $temppath . "/" . $a->getHostName();
$new_temppath = $temppath . "/" . DI::baseUrl()->getHostname();
if (!is_dir($new_temppath)) {
/// @TODO There is a mkdir()+chmod() upwards, maybe generalize this (+ configurable) into a function/method?
mkdir($new_temppath);

4
doc/Addons.md

@ -104,7 +104,7 @@ function <addon>_install()
function <addon>_head(App $a)
{
$a->registerStylesheet(__DIR__ . '/relative/path/to/addon/stylesheet.css');
\Friendica\DI::page()->registerStylesheet(__DIR__ . '/relative/path/to/addon/stylesheet.css');
}
```
@ -126,7 +126,7 @@ function <addon>_install()
function <addon>_footer(App $a)
{
$a->registerFooterScript(__DIR__ . '/relative/path/to/addon/script.js');
\Friendica\DI::page()->registerFooterScript(__DIR__ . '/relative/path/to/addon/script.js');
}
```

58
include/api.php

@ -7,12 +7,10 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\App\Authentication;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
@ -23,11 +21,11 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Mail;
use Friendica\Model\Notify;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Model\User;
@ -254,9 +252,7 @@ function api_login(App $a)
throw new UnauthorizedException("This API requires login");
}
/** @var Authentication $authentication */
$authentication = BaseObject::getClass(Authentication::class);
$authentication->setForUser($a, $record);
DI::auth()->setForUser($a, $record);
$_SESSION["allow_api"] = true;
@ -287,30 +283,35 @@ function api_check_method($method)
* @brief Main API entry point
*
* @param App $a App
* @param App\Arguments $args The app arguments (optional, will retrieved by the DI-Container in case of missing)
* @return string|array API call result
* @throws Exception
*/
function api_call(App $a)
function api_call(App $a, App\Arguments $args = null)
{
global $API, $called_api;
if ($args == null) {
$args = DI::args();
}
$type = "json";
if (strpos($a->query_string, ".xml") > 0) {
if (strpos($args->getQueryString(), ".xml") > 0) {
$type = "xml";
}
if (strpos($a->query_string, ".json") > 0) {
if (strpos($args->getQueryString(), ".json") > 0) {
$type = "json";
}
if (strpos($a->query_string, ".rss") > 0) {
if (strpos($args->getQueryString(), ".rss") > 0) {
$type = "rss";
}
if (strpos($a->query_string, ".atom") > 0) {
if (strpos($args->getQueryString(), ".atom") > 0) {
$type = "atom";
}
try {
foreach ($API as $p => $info) {
if (strpos($a->query_string, $p) === 0) {
if (strpos($args->getQueryString(), $p) === 0) {
if (!api_check_method($info['method'])) {
throw new MethodNotAllowedException();
}
@ -332,7 +333,7 @@ function api_call(App $a)
Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]);
$a->getProfiler()->saveLog($a->getLogger(), API_LOG_PREFIX . 'performance');
DI::profiler()->saveLog(DI::logger(), API_LOG_PREFIX . 'performance');
if (false === $return) {
/*
@ -369,11 +370,11 @@ function api_call(App $a)
}
}
Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call', 'query' => $a->query_string]);
Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call', 'query' => DI::args()->getQueryString()]);
throw new NotImplementedException();
} catch (HTTPException $e) {
header("HTTP/1.1 {$e->getCode()} {$e->httpdesc}");
return api_error($type, $e);
return api_error($type, $e, $args);
}
}
@ -382,18 +383,17 @@ function api_call(App $a)
*
* @param string $type Return type (xml, json, rss, as)
* @param object $e HTTPException Error object
* @param App\Arguments $args The App arguments
* @return string|array error message formatted as $type
*/
function api_error($type, $e)
function api_error($type, $e, App\Arguments $args)
{
$a = \get_app();
$error = ($e->getMessage() !== "" ? $e->getMessage() : $e->httpdesc);
/// @TODO: https://dev.twitter.com/overview/api/response-codes
$error = ["error" => $error,
"code" => $e->getCode() . " " . $e->httpdesc,
"request" => $a->query_string];
"request" => $args->getQueryString()];
$return = api_format_data('status', $type, ['status' => $error]);
@ -438,7 +438,7 @@ function api_rss_extra(App $a, $arr, $user_info)
$arr['$user'] = $user_info;
$arr['$rss'] = [
'alternate' => $user_info['url'],
'self' => System::baseUrl() . "/" . $a->query_string,
'self' => System::baseUrl() . "/" . DI::args()->getQueryString(),
'base' => System::baseUrl(),
'updated' => api_date(null),
'atom_updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
@ -1370,7 +1370,7 @@ function api_get_item(array $condition)
*/
function api_users_show($type)
{
$a = BaseObject::getApp();
$a = Friendica\DI::app();
$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")
{
$a = BaseObject::getApp();
$a = Friendica\DI::app();
$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)
{
$a = BaseObject::getApp();
$a = Friendica\DI::app();
if (empty($status_user) || empty($author_user) || empty($owner_user)) {
list($status_user, $author_user, $owner_user) = api_item_get_user($a, $item);
@ -3567,10 +3567,8 @@ api_register_func('api/friendships/incoming', 'api_friendships_incoming', true);
*/
function api_statusnet_config($type)
{
$a = \get_app();
$name = Config::get('config', 'sitename');
$server = $a->getHostName();
$server = DI::baseUrl()->getHostname();
$logo = System::baseUrl() . '/images/friendica-64.png';
$email = Config::get('config', 'admin_email');
$closed = intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 'true' : 'false';
@ -5909,10 +5907,7 @@ function api_friendica_notification($type)
if ($a->argc!==3) {
throw new BadRequestException("Invalid argument count");
}
/** @var Notify $nm */
$nm = BaseObject::getClass(Notify::class);
$notes = $nm->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);
$notes = DI::notify()->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);
if ($type == "xml") {
$xmlnotes = [];
@ -5954,8 +5949,7 @@ function api_friendica_notification_seen($type)
$id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
/** @var Notify $nm */
$nm = BaseObject::getClass(Notify::class);
$nm = DI::notify();
$note = $nm->getByID($id);
if (is_null($note)) {
throw new BadRequestException("Invalid argument");

31
include/conversation.php

@ -4,10 +4,8 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Item as ContentItem;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Config;
@ -20,6 +18,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Profile;
@ -141,8 +140,7 @@ function localize_item(&$item)
During the further steps of the database restructuring I would like to address this issue.
*/
/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);
$activity = DI::activity();
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
if ($activity->match($item['verb'], Activity::LIKE)
@ -399,8 +397,7 @@ function count_descendants($item) {
function visible_activity($item) {
/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);
$activity = DI::activity();
if (empty($item['verb']) || $activity->isHidden($item['verb'])) {
return false;
@ -483,7 +480,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
*/
$live_update_div = '<div id="live-network"></div>' . "\r\n"
. "<script> var profile_uid = " . $_SESSION['uid']
. "; var netargs = '" . substr($a->cmd, 8)
. "; var netargs = '" . substr(DI::args()->getCommand(), 8)
. '?f='
. (!empty($_GET['cid']) ? '&cid=' . rawurlencode($_GET['cid']) : '')
. (!empty($_GET['search']) ? '&search=' . rawurlencode($_GET['search']) : '')
@ -543,7 +540,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
if (!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '" . substr($a->cmd, 10)
. "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 10)
."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
}
} elseif ($mode === 'contacts') {
@ -552,7 +549,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
if (!$update) {
$live_update_div = '<div id="live-contacts"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '" . substr($a->cmd, 9)
. "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 9)
."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
}
} elseif ($mode === 'search') {
@ -562,7 +559,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
$page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
if (!$update) {
$_SESSION['return_path'] = $a->query_string;
$_SESSION['return_path'] = DI::args()->getQueryString();
}
$cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview];
@ -668,10 +665,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
$body = Item::prepareBody($item, true, $preview);
/** @var ContentItem $contItem */
$contItem = BaseObject::getClass(ContentItem::class);
list($categories, $folders) = $contItem->determineCategoriesTerms($item);
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);
@ -786,7 +780,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
$o = Renderer::replaceMacros($page_template, [
'$baseurl' => System::baseUrl($ssl_state),
'$return_path' => $a->query_string,
'$return_path' => DI::args()->getQueryString(),
'$live_update' => $live_update_div,
'$remove' => L10n::t('remove'),
'$mode' => $mode,
@ -1031,10 +1025,7 @@ function builtin_activity_puller($item, &$conv_responses) {
return;
}
/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);
if (!empty($item['verb']) && $activity->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
$url = Contact::magicLinkByContact($author);
@ -1202,7 +1193,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
$private_post = 0;
}
$query_str = $a->query_string;
$query_str = DI::args()->getQueryString();
if (strpos($query_str, 'public=1') !== false) {
$query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str);
}

3
include/enotify.php

@ -12,6 +12,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
@ -68,7 +69,7 @@ function notification($params)
}
$sender_name = $sitename;
$hostname = $a->getHostName();
$hostname = DI::baseUrl()->getHostname();
if (strpos($hostname, ':')) {
$hostname = substr($hostname, 0, strpos($hostname, ':'));
}

24
include/items.php

@ -3,27 +3,23 @@
* @file include/items.php
*/
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Feed;
use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
require_once __DIR__ . '/../mod/share.php';
@ -344,7 +340,7 @@ function drop_items(array $items)
function drop_item($id, $return = '')
{
$a = BaseObject::getApp();
$a = DI::app();
// locate item to be deleted
@ -353,7 +349,7 @@ function drop_item($id, $return = '')
if (!DBA::isResult($item)) {
notice(L10n::t('Item not found.') . EOL);
$a->internalRedirect('network');
DI::baseUrl()->redirect('network');
}
if ($item['deleted']) {
@ -372,7 +368,7 @@ function drop_item($id, $return = '')
if (!empty($_REQUEST['confirm'])) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$query = explode_querystring(DI::args()->getQueryString());
$inputs = [];
foreach ($query['args'] as $arg) {
@ -394,7 +390,7 @@ function drop_item($id, $return = '')
}
// Now check how the user responded to the confirmation query
if (!empty($_REQUEST['canceled'])) {
$a->internalRedirect('display/' . $item['guid']);
DI::baseUrl()->redirect('display/' . $item['guid']);
}
$is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false;
@ -416,28 +412,28 @@ function drop_item($id, $return = '')
if ($is_comment) {
// Return to parent guid
if (!empty($parentitem)) {
$a->internalRedirect('display/' . $parentitem['guid']);
DI::baseUrl()->redirect('display/' . $parentitem['guid']);
//NOTREACHED
}
// In case something goes wrong
else {
$a->internalRedirect('network');
DI::baseUrl()->redirect('network');
//NOTREACHED
}
}
else {
// if unknown location or deleting top level post called from display
if (empty($return_url) || strpos($return_url, 'display') !== false) {
$a->internalRedirect('network');
DI::baseUrl()->redirect('network');
//NOTREACHED
} else {
$a->internalRedirect($return_url);
DI::baseUrl()->redirect($return_url);
//NOTREACHED
}
}
} else {
notice(L10n::t('Permission denied.') . EOL);
$a->internalRedirect('display/' . $item['guid']);
DI::baseUrl()->redirect('display/' . $item['guid']);
//NOTREACHED
}
}

6
index.php

@ -15,13 +15,13 @@ require __DIR__ . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php');
$dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $_SERVER], Dice::CHAIN_CALL]]]);
\Friendica\BaseObject::setDependencyInjection($dice);
\Friendica\DI::init($dice);
$a = \Friendica\BaseObject::getApp();
$a = \Friendica\DI::app();
$a->runFrontend(
$dice->create(\Friendica\App\Module::class),
$dice->create(\Friendica\App\Router::class),
$dice->create(\Friendica\Core\Config\PConfiguration::class),
$dice->create(\Friendica\Core\Config\IPConfiguration::class),
$dice->create(\Friendica\App\Authentication::class)
);

7
mod/api.php

@ -8,6 +8,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Security\Login;
require_once __DIR__ . '/../include/api.php';
@ -44,7 +45,7 @@ function api_post(App $a)
function api_content(App $a)
{
if ($a->cmd == 'api/oauth/authorize') {
if (DI::args()->getCommand() == 'api/oauth/authorize') {
/*
* api/oauth/authorize interact with the user. return a standard page
*/
@ -76,7 +77,7 @@ function api_content(App $a)
if (strstr($consumer->callback_url, $glue)) {
$glue = "?";
}
$a->internalRedirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier));
DI::baseUrl()->redirect($consumer->callback_url . $glue . 'oauth_token=' . OAuthUtil::urlencode_rfc3986($params['oauth_token']) . '&oauth_verifier=' . OAuthUtil::urlencode_rfc3986($verifier));
exit();
}
@ -93,7 +94,7 @@ function api_content(App $a)
if (!local_user()) {
/// @TODO We need login form to redirect to this page
notice(L10n::t('Please login to continue.') . EOL);
return Login::form($a->query_string, false, $request->get_parameters());
return Login::form(DI::args()->getQueryString(), false, $request->get_parameters());
}
//FKOAuth1::loginUser(4);

9
mod/cal.php

@ -16,12 +16,11 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Event;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
@ -222,7 +221,7 @@ function cal_content(App $a)
foreach ($r as $rr) {
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
if (empty($links[$j])) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
$links[$j] = System::baseUrl() . '/' . DI::args()->getCommand() . '#link-' . $j;
}
}
}
@ -289,7 +288,7 @@ function cal_content(App $a)
// Respect the export feature setting for all other /cal pages if it's not the own profile
if ((local_user() !== $owner_uid) && !Feature::isEnabled($owner_uid, "export_calendar")) {
notice(L10n::t('Permission denied.') . EOL);
$a->internalRedirect('cal/' . $nick);
DI::baseUrl()->redirect('cal/' . $nick);
}
// Get the export data by uid
@ -310,7 +309,7 @@ function cal_content(App $a)
$return_path = "cal/" . $nick;
}
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
// If nothing went wrong we can echo the export content

3
mod/common.php

@ -9,6 +9,7 @@ use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
use Friendica\Module;
use Friendica\Util\Proxy as ProxyUtils;
@ -91,7 +92,7 @@ function common_content(App $a)
return $o;
}
$pager = new Pager($a->query_string);
$pager = new Pager(DI::args()->getQueryString());
if ($cid) {
$common_friends = Model\GContact::commonFriends($uid, $cid, $pager->getStart(), $pager->getItemsPerPage());

5
mod/community.php

@ -15,6 +15,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\User;
@ -136,7 +137,7 @@ function community_content(App $a, $update = 0)
}
// check if we serve a mobile device and get the user settings accordingly
if ($a->is_mobile) {
if (DI::mode()->isMobile()) {
$itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 20);
} else {
$itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 40);
@ -148,7 +149,7 @@ function community_content(App $a, $update = 0)
$itemspage_network = $a->force_max_items;
}
$pager = new Pager($a->query_string, $itemspage_network);
$pager = new Pager(DI::args()->getQueryString(), $itemspage_network);
$r = community_getitems($pager->getStart(), $pager->getItemsPerPage(), $content, $accounttype);

5
mod/dfrn_confirm.php

@ -24,6 +24,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\User;
@ -331,7 +332,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
// Let's send our user to the contact editor in case they want to
// do anything special with this new friend.
if ($handsfree === null) {
$a->internalRedirect('contact/' . intval($contact_id));
DI::baseUrl()->redirect('contact/' . intval($contact_id));
} else {
return;
}
@ -551,6 +552,6 @@ function dfrn_confirm_post(App $a, $handsfree = null)
}
// somebody arrived here by mistake or they are fishing. Send them to the homepage.
$a->internalRedirect();
DI::baseUrl()->redirect();
// NOTREACHED
}

25
mod/dfrn_poll.php

@ -5,14 +5,13 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\App\Authentication;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
@ -22,9 +21,7 @@ use Friendica\Util\XML;
function dfrn_poll_init(App $a)
{
/** @var Authentication $authentication */
$authentication = BaseObject::getClass(Authentication::class);
$authentication->withSession($a);
DI::auth()->withSession($a);
$dfrn_id = $_GET['dfrn_id'] ?? '';
$type = ($_GET['type'] ?? '') ?: 'data';
@ -94,7 +91,7 @@ function dfrn_poll_init(App $a)
$my_id = '0:' . $dfrn_id;
break;
default:
$a->internalRedirect();
DI::baseUrl()->redirect();
break; // NOTREACHED
}
@ -141,10 +138,10 @@ function dfrn_poll_init(App $a)
if (!empty($destination_url)) {
System::externalRedirect($destination_url);
} else {
$a->internalRedirect('profile/' . $profile);
DI::baseUrl()->redirect('profile/' . $profile);
}
}
$a->internalRedirect();
DI::baseUrl()->redirect();
}
if ($type === 'profile-check' && $dfrn_version < 2.2) {
@ -328,7 +325,7 @@ function dfrn_poll_post(App $a)
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", DBA::escape($dfrn_id));
break;
default:
$a->internalRedirect();
DI::baseUrl()->redirect();
break; // NOTREACHED
}
@ -448,7 +445,7 @@ function dfrn_poll_content(App $a)
$my_id = '0:' . $dfrn_id;
break;
default:
$a->internalRedirect();
DI::baseUrl()->redirect();
break; // NOTREACHED
}
@ -544,18 +541,18 @@ function dfrn_poll_content(App $a)
switch ($destination_url) {
case 'profile':
$a->internalRedirect('profile/' . $profile . '?f=&tab=profile');
DI::baseUrl()->redirect('profile/' . $profile . '?f=&tab=profile');
break;
case 'photos':
$a->internalRedirect('photos/' . $profile);
DI::baseUrl()->redirect('photos/' . $profile);
break;
case 'status':
case '':
$a->internalRedirect('profile/' . $profile);
DI::baseUrl()->redirect('profile/' . $profile);
break;
default:
$appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
$a->redirect($destination_url . $appendix);
DI::baseUrl()->redirect($destination_url . $appendix);
break;
}
// NOTREACHED

25
mod/dfrn_request.php

@ -21,6 +21,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
@ -68,7 +69,7 @@ function dfrn_request_post(App $a)
}
if (!empty($_POST['cancel'])) {
$a->internalRedirect();
DI::baseUrl()->redirect();
}
/*
@ -194,14 +195,14 @@ function dfrn_request_post(App $a)
}
// (ignore reply, nothing we can do it failed)
$a->internalRedirect($forward_path);
DI::baseUrl()->redirect($forward_path);
return; // NOTREACHED
}
}
// invalid/bogus request
notice(L10n::t('Unrecoverable protocol error.') . EOL);
$a->internalRedirect();
DI::baseUrl()->redirect();
return; // NOTREACHED
}
@ -334,19 +335,19 @@ function dfrn_request_post(App $a)
$url = Network::isUrlValid($url);
if (!$url) {
notice(L10n::t('Invalid profile URL.') . EOL);
$a->internalRedirect($a->cmd);
DI::baseUrl()->redirect(DI::args()->getCommand());
return; // NOTREACHED
}
if (!Network::isUrlAllowed($url)) {
notice(L10n::t('Disallowed profile URL.') . EOL);
$a->internalRedirect($a->cmd);
DI::baseUrl()->redirect(DI::args()->getCommand());
return; // NOTREACHED
}
if (Network::isUrlBlocked($url)) {
notice(L10n::t('Blocked domain') . EOL);
$a->internalRedirect($a->cmd);
DI::baseUrl()->redirect(DI::args()->getCommand());
return; // NOTREACHED
}
@ -354,7 +355,7 @@ function dfrn_request_post(App $a)
if (!count($parms)) {
notice(L10n::t('Profile location is not valid or does not contain profile information.') . EOL);
$a->internalRedirect($a->cmd);
DI::baseUrl()->redirect(DI::args()->getCommand());
} else {
if (empty($parms['fn'])) {
notice(L10n::t('Warning: profile location has no identifiable owner name.') . EOL);
@ -436,7 +437,7 @@ function dfrn_request_post(App $a)
}
// "Homecoming" - send the requestor back to their site to record the introduction.
$dfrn_url = bin2hex($a->getBaseURL() . '/profile/' . $nickname);
$dfrn_url = bin2hex(DI::baseUrl()->get() . '/profile/' . $nickname);
$aes_allow = ((function_exists('openssl_encrypt')) ? 1 : 0);
System::externalRedirect($parms['dfrn-request'] . "?dfrn_url=$dfrn_url"
@ -454,10 +455,10 @@ function dfrn_request_post(App $a)
// Diaspora needs the uri in the format user@domain.tld
// Diaspora will support the remote subscription in a future version
if ($network == Protocol::DIASPORA) {
$uri = $nickname . '@' . $a->getHostName();
$uri = $nickname . '@' . DI::baseUrl()->getHostname();
if ($a->getURLPath()) {
$uri .= '/' . $a->getURLPath();
if (DI::baseUrl()->getUrlPath()) {
$uri .= '/' . DI::baseUrl()->getUrlPath();
}
$uri = urlencode($uri);
@ -609,7 +610,7 @@ function dfrn_request_content(App $a)
} elseif (!empty($_GET['address'])) {
$myaddr = $_GET['address'];
} elseif (local_user()) {
if (strlen($a->getURLPath())) {
if (strlen(DI::baseUrl()->getUrlPath())) {
$myaddr = System::baseUrl() . '/profile/' . $a->user['nickname'];
} else {
$myaddr = $a->user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);

5
mod/display.php

@ -16,6 +16,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
@ -319,14 +320,14 @@ function display_content(App $a, $update = false, $update_uid = 0)
$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
}
$o .= conversation($a, [$item], new Pager($a->query_string), 'display', $update_uid, false, 'commented', $item_uid);
$o .= conversation($a, [$item], new Pager(DI::args()->getQueryString()), 'display', $update_uid, false, 'commented', $item_uid);
// Preparing the meta header
$description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true));
$title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true));
$author_name = $item["author-name"];
$image = $a->removeBaseURL($item["author-avatar"]);
$image = DI::baseUrl()->remove($item["author-avatar"]);
if ($title == "") {
$title = $author_name;

18
mod/events.php

@ -5,7 +5,6 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Nav;
use Friendica\Content\Widget\CalendarExport;
use Friendica\Core\ACL;
@ -16,9 +15,11 @@ use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Module\Security\Login;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat;
@ -123,7 +124,7 @@ function events_post(App $a)
echo L10n::t('Event can not end before it has started.');
exit();
}
$a->internalRedirect($onerror_path);
DI::baseUrl()->redirect($onerror_path);
}
if (!$summary || ($start === DBA::NULL_DATETIME)) {
@ -132,7 +133,7 @@ function events_post(App $a)
echo L10n::t('Event title and start time are required.');
exit();
}
$a->internalRedirect($onerror_path);
DI::baseUrl()->redirect($onerror_path);
}
$share = intval($_POST['share'] ?? 0);
@ -150,8 +151,7 @@ function events_post(App $a)
if ($share) {
/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();
$str_group_allow = $aclFormatter->toString($_POST['group_allow'] ?? '');
$str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? '');
@ -206,7 +206,7 @@ function events_post(App $a)
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item_id);
}
$a->internalRedirect('events');
DI::baseUrl()->redirect('events');
}
function events_content(App $a)
@ -217,7 +217,7 @@ function events_content(App $a)
}
if ($a->argc == 1) {
$_SESSION['return_path'] = $a->cmd;
$_SESSION['return_path'] = DI::args()->getCommand();
}
if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
@ -350,7 +350,7 @@ function events_content(App $a)
foreach ($r as $rr) {
$j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
if (empty($links[$j])) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
$links[$j] = System::baseUrl() . '/' . DI::args()->getCommand() . '#link-' . $j;
}
}
}
@ -579,6 +579,6 @@ function events_content(App $a)
info(L10n::t('Event removed') . EOL);
}
$a->internalRedirect('events');
DI::baseUrl()->redirect('events');
}
}

15
mod/follow.php

@ -8,6 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
@ -21,7 +22,7 @@ function follow_post(App $a)
}
if (isset($_REQUEST['cancel'])) {
$a->internalRedirect('contact');
DI::baseUrl()->redirect('contact');
}
$uid = local_user();
@ -38,14 +39,14 @@ function follow_post(App $a)
if ($result['message']) {
notice($result['message']);
}
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
} elseif ($result['cid']) {
$a->internalRedirect('contact/' . $result['cid']);
DI::baseUrl()->redirect('contact/' . $result['cid']);
}
info(L10n::t('The contact could not be added.'));
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}
@ -55,7 +56,7 @@ function follow_content(App $a)
if (!local_user()) {
notice(L10n::t('Permission denied.'));
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}
@ -70,7 +71,7 @@ function follow_content(App $a)
}
if (!$url) {
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
$submit = L10n::t('Submit Request');
@ -132,7 +133,7 @@ function follow_content(App $a)
if (!$r) {
notice(L10n::t('Permission denied.'));
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}

32
mod/item.php

@ -16,7 +16,6 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
@ -29,6 +28,7 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Attach;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
@ -39,7 +39,6 @@ use Friendica\Model\Term;
use Friendica\Protocol\Activity;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer;
use Friendica\Util\Security;
@ -126,7 +125,7 @@ function item_post(App $a) {
if (!DBA::isResult($toplevel_item)) {
notice(L10n::t('Unable to locate original post.') . EOL);
if (!empty($_REQUEST['return'])) {
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
exit();
}
@ -174,7 +173,7 @@ function item_post(App $a) {
notice(L10n::t('Permission denied.') . EOL);
if (!empty($_REQUEST['return'])) {
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
exit();
@ -273,8 +272,7 @@ function item_post(App $a) {
} else {
// use the posted permissions
/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();
$str_group_allow = $aclFormatter->toString($_REQUEST['group_allow'] ?? '');
$str_contact_allow = $aclFormatter->toString($_REQUEST['contact_allow'] ?? '');
@ -329,7 +327,7 @@ function item_post(App $a) {
}
info(L10n::t('Empty post discarded.') . EOL);
if (!empty($_REQUEST['return'])) {
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
exit();
}
@ -506,9 +504,7 @@ function item_post(App $a) {
$objecttype = Activity\ObjectType::BOOKMARK;
}
/** @var BBCode\Video $bbCodeVideo */
$bbCodeVideo = BaseObject::getClass(BBCode\Video::class);
$body = $bbCodeVideo->transform($body);
$body = DI::bbCodeVideo()->transform($body);
// Fold multi-line [code] sequences
$body = preg_replace('/\[\/code\]\s*\[code\]/ism', "\n", $body);
@ -671,7 +667,7 @@ function item_post(App $a) {
$datarray["item_id"] = -1;
$datarray["author-network"] = Protocol::DFRN;
$o = conversation($a, [array_merge($contact_record, $datarray)], new Pager($a->query_string), 'search', false, true);
$o = conversation($a, [array_merge($contact_record, $datarray)], new Pager(DI::args()->getQueryString()), 'search', false, true);
Logger::log('preview: ' . $o);
echo json_encode(['preview' => $o]);
exit();
@ -682,7 +678,7 @@ function item_post(App $a) {
<