Merge pull request #8019 from nupplaphil/task/replace_getClass

Introduce new way of static/dynamic bridge / CleanUp deprecated methods
This commit is contained in:
Hypolite Petovan 2019-12-29 17:47:28 -05:00 committed by GitHub
commit 03038e7a3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
264 changed files with 1631 additions and 1854 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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) {
if (!empty($datarray['cancel'])) {
Logger::log('mod_item: post cancelled by addon.');
if ($return_path) {
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
$json = ['cancel' => 1];
@ -717,7 +713,7 @@ function item_post(App $a) {
if (!empty($_REQUEST['return']) && strlen($return_path)) {
Logger::log('return: ' . $return_path);
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
exit();
}
@ -737,14 +733,14 @@ function item_post(App $a) {
if (!$post_id) {
Logger::log("Item wasn't stored.");
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
$datarray = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
if (!DBA::isResult($datarray)) {
Logger::log("Item with id ".$post_id." couldn't be fetched.");
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
// update filetags in pconfig
@ -859,7 +855,7 @@ function item_post_return($baseurl, $api_source, $return_path)
}
if ($return_path) {
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
}
$json = ['success' => 1];
@ -882,7 +878,7 @@ function item_content(App $a)
$o = '';
if (($a->argc >= 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) {
if ($a->isAjax()) {
if (DI::mode()->isAjax()) {
$o = Item::deleteForUser(['id' => $a->argv[2]], local_user());
} else {
if (!empty($a->argv[3])) {
@ -893,7 +889,7 @@ function item_content(App $a)
}
}
if ($a->isAjax()) {
if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>]
echo json_encode([intval($a->argv[2]), intval($o)]);
exit();

View File

@ -3,13 +3,12 @@
* @file mod/lockview.php
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Util\ACLFormatter;
function lockview_content(App $a)
{
@ -61,8 +60,7 @@ function lockview_content(App $a)
exit();
}
/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();
$allowed_users = $aclFormatter->expand($item['allow_cid']);
$allowed_groups = $aclFormatter->expand($item['allow_gid']);

View File

@ -10,6 +10,7 @@ use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
@ -18,14 +19,14 @@ function lostpass_post(App $a)
{
$loginame = Strings::escapeTags(trim($_POST['login-name']));
if (!$loginame) {
$a->internalRedirect();
DI::baseUrl()->redirect();
}
$condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame];
$user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'language'], $condition);
if (!DBA::isResult($user)) {
notice(L10n::t('No valid account found.') . EOL);
$a->internalRedirect();
DI::baseUrl()->redirect();
}
$pwdreset_token = Strings::getRandomName(12) . random_int(1000, 9999);
@ -77,7 +78,7 @@ function lostpass_post(App $a)
'body' => $body
]);
$a->internalRedirect();
DI::baseUrl()->redirect();
}
function lostpass_content(App $a)

View File

@ -11,6 +11,7 @@ use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Util\Network;
@ -38,7 +39,7 @@ function match_content(App $a)
$a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow();
$_SESSION['return_path'] = $a->cmd;
$_SESSION['return_path'] = DI::args()->getCommand();
$profile = Profile::getByUID(local_user());

View File

@ -13,6 +13,7 @@ use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Mail;
use Friendica\Module\Security\Login;
@ -88,7 +89,7 @@ function message_post(App $a)
$a->argc = 2;
$a->argv[1] = 'new';
} else {
$a->internalRedirect($a->cmd . '/' . $ret);
DI::baseUrl()->redirect(DI::args()->getCommand() . '/' . $ret);
}
}
@ -133,7 +134,7 @@ function message_content(App $a)
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) {
if (strpos($arg, 'confirm=') === false) {
@ -156,7 +157,7 @@ function message_content(App $a)
// Now check how the user responded to the confirmation query
if (!empty($_REQUEST['canceled'])) {
$a->internalRedirect('message');
DI::baseUrl()->redirect('message');
}
$cmd = $a->argv[1];
@ -164,7 +165,7 @@ function message_content(App $a)
$message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]);
if(!DBA::isResult($message)){
info(L10n::t('Conversation not found.') . EOL);
$a->internalRedirect('message');
DI::baseUrl()->redirect('message');
}
if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
@ -174,10 +175,10 @@ function message_content(App $a)
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]);
if(!DBA::isResult($conversation)){
info(L10n::t('Conversation removed.') . EOL);
$a->internalRedirect('message');
DI::baseUrl()->redirect('message');
}
$a->internalRedirect('message/' . $conversation['id'] );
DI::baseUrl()->redirectinternalRedirect('message/' . $conversation['id'] );
} else {
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]),
@ -190,7 +191,7 @@ function message_content(App $a)
info(L10n::t('Conversation removed.') . EOL);
}
}
$a->internalRedirect('message');
DI::baseUrl()->redirect('message');
}
}
@ -264,7 +265,7 @@ function message_content(App $a)
}
$_SESSION['return_path'] = $a->query_string;
$_SESSION['return_path'] = DI::args()->getQueryString();
if ($a->argc == 1) {
@ -281,7 +282,7 @@ function message_content(App $a)
$total = $r[0]['total'];
}
$pager = new Pager($a->query_string);
$pager = new Pager(DI::args()->getQueryString());
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage());

View File

@ -5,7 +5,6 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Content\Nav;
@ -22,6 +21,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
@ -52,12 +52,9 @@ function network_init(App $a)
$group_id = 0;
}
/** @var DateTimeFormat $dtFormat */
$dtFormat = BaseObject::getClass(DateTimeFormat::class);
if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) {
if ($dtFormat->isYearMonth($a->argv[$x])) {
if (DI::dtFormat()->isYearMonth($a->argv[$x])) {
$is_a_date_query = true;
break;
}
@ -66,7 +63,7 @@ function network_init(App $a)
// convert query string to array. remove friendica args
$query_array = [];
parse_str(parse_url($a->query_string, PHP_URL_QUERY), $query_array);
parse_str(parse_url(DI::args()->getQueryString(), PHP_URL_QUERY), $query_array);
// fetch last used network view and redirect if needed
if (!$is_a_date_query) {
@ -131,7 +128,7 @@ function network_init(App $a)
$redir_url = ($net_queries ? $net_baseurl . '?' . $net_queries : $net_baseurl);
$a->internalRedirect($redir_url);
DI::baseUrl()->redirect($redir_url);
}
}
@ -143,7 +140,7 @@ function network_init(App $a)
$a->page['aside'] .= ForumManager::widget(local_user(), $cid);
$a->page['aside'] .= Widget::postedByYear('network', local_user(), false);
$a->page['aside'] .= Widget::networks('network', $_GET['nets'] ?? '');
$a->page['aside'] .= Widget\SavedSearches::getHTML($a->query_string);
$a->page['aside'] .= Widget\SavedSearches::getHTML(DI::args()->getQueryString());
$a->page['aside'] .= Widget::fileAs('network', $_GET['file'] ?? '');
}
@ -231,7 +228,7 @@ function networkPager(App $a, Pager $pager, $update)
// 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');
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
} else {
@ -312,7 +309,7 @@ function network_content(App $a, $update = 0, $parent = 0)
}
/// @TODO Is this really necessary? $a is already available to hooks
$arr = ['query' => $a->query_string];
$arr = ['query' => DI::args()->getQueryString()];
Hook::callAll('network_content_init', $arr);
$flat_mode = false;
@ -392,7 +389,7 @@ function networkFlatView(App $a, $update = 0)
}
}
$pager = new Pager($a->query_string);
$pager = new Pager(DI::args()->getQueryString());
networkPager($a, $pager, $update);
@ -465,12 +462,9 @@ function networkThreadedView(App $a, $update, $parent)
$default_permissions = [];
/** @var DateTimeFormat $dtFormat */
$dtFormat = BaseObject::getClass(DateTimeFormat::class);
if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) {
if ($dtFormat->isYearMonth($a->argv[$x])) {
if (DI::dtFormat()->isYearMonth($a->argv[$x])) {
if ($datequery) {
$datequery2 = Strings::escapeHtml($a->argv[$x]);
} else {
@ -593,7 +587,7 @@ function networkThreadedView(App $a, $update, $parent)
exit();
}
notice(L10n::t('No such group') . EOL);
$a->internalRedirect('network/0');
DI::baseUrl()->redirect('network/0');
// NOTREACHED
}
@ -647,7 +641,7 @@ function networkThreadedView(App $a, $update, $parent)
}
} else {
notice(L10n::t('Invalid contact.') . EOL);
$a->internalRedirect('network');
DI::baseUrl()->redirect('network');
// NOTREACHED
}
}
@ -687,7 +681,7 @@ function networkThreadedView(App $a, $update, $parent)
$sql_range = '';
}
$pager = new Pager($a->query_string);
$pager = new Pager(DI::args()->getQueryString());
$pager_sql = networkPager($a, $pager, $update);
@ -875,7 +869,7 @@ function networkThreadedView(App $a, $update, $parent)
$date_offset = $_GET['offset'];
}
$query_string = $a->query_string;
$query_string = DI::args()->getQueryString();
if ($date_offset && !preg_match('/[?&].offset=/', $query_string)) {
$query_string .= '&offset=' . urlencode($date_offset);
}
@ -920,7 +914,7 @@ function network_tabs(App $a)
$all_active = 'active';
}
$cmd = $a->cmd;
$cmd = DI::args()->getCommand();
// tabs
$tabs = [

View File

@ -8,6 +8,7 @@ use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Profile;
@ -53,7 +54,7 @@ function notes_content(App $a, $update = false)
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
'contact-id'=> $a->contact['id']];
$pager = new Pager($a->query_string, 40);
$pager = new Pager(DI::args()->getQueryString(), 40);
$params = ['order' => ['created' => true],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];

View File

@ -13,14 +13,15 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Model\Contact;
use Friendica\Model\Introduction;
use Friendica\Model\Notify;
function notifications_post(App $a)
{
if (!local_user()) {
$a->internalRedirect();
DI::baseUrl()->redirect();
}
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
@ -30,9 +31,7 @@ function notifications_post(App $a)
}
if ($request_id) {
/** @var Introduction $Intro */
$Intro = \Friendica\BaseObject::getClass(Introduction::class);
$Intro->fetch(['id' => $request_id, 'uid' => local_user()]);
$Intro = DI::intro()->fetch(['id' => $request_id, 'uid' => local_user()]);
switch ($_POST['submit']) {
case L10n::t('Discard'):
@ -43,7 +42,7 @@ function notifications_post(App $a)
break;
}
$a->internalRedirect('notifications/intros');
DI::baseUrl()->redirect('notifications/intros');
}
}
@ -61,8 +60,7 @@ function notifications_content(App $a)
$json = (($a->argc > 1 && $a->argv[$a->argc - 1] === 'json') ? true : false);
/** @var Notify $nm */
$nm = \Friendica\BaseObject::getClass(Notify::class);
$nm = DI::notify();
$o = '';
// Get the nav tabs for the notification pages
@ -112,11 +110,11 @@ function notifications_content(App $a)
$notifs = $nm->getHomeList($show, $startrec, $perpage);
// fallback - redirect to main page
} else {
$a->internalRedirect('notifications');
DI::baseUrl()->redirect('notifications');
}
// Set the pager
$pager = new Pager($a->query_string, $perpage);
$pager = new Pager(DI::args()->getQueryString(), $perpage);
// Add additional informations (needed for json output)
$notifs['items_page'] = $pager->getItemsPerPage();

View File

@ -8,6 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
use Friendica\Util\Network;
@ -16,7 +17,7 @@ function ostatus_subscribe_content(App $a)
{
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
$a->internalRedirect('ostatus_subscribe');
DI::baseUrl()->redirect('ostatus_subscribe');
// NOTREACHED
}

View File

@ -4,7 +4,6 @@
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
@ -18,6 +17,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\Photo;
@ -26,7 +26,6 @@ use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
use Friendica\Util\ACLFormatter;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images;
@ -174,12 +173,12 @@ function photos_post(App $a)
if ($a->argc > 3 && $a->argv[2] === 'album') {
if (!Strings::isHex($a->argv[3])) {
$a->internalRedirect('photos/' . $a->data['user']['nickname'] . '/album');
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album');
}
$album = hex2bin($a->argv[3]);
if ($album === L10n::t('Profile Photos') || $album === 'Contact Photos' || $album === L10n::t('Contact Photos')) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
return; // NOTREACHED
}
@ -190,13 +189,13 @@ function photos_post(App $a)
if (!DBA::isResult($r)) {
notice(L10n::t('Album not found.') . EOL);
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
return; // NOTREACHED
}
// Check if the user has responded to a delete confirmation query
if (!empty($_REQUEST['canceled'])) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
// RENAME photo album
@ -210,7 +209,7 @@ function photos_post(App $a)
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
$a->internalRedirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum));
DI::baseUrl()->redirect('photos/' . $a->user['nickname'] . '/album/' . bin2hex($newalbum));
return; // NOTREACHED
}
@ -253,13 +252,13 @@ function photos_post(App $a)
}
}
$a->internalRedirect('photos/' . $a->argv[1]);
DI::baseUrl()->redirect('photos/' . $a->argv[1]);
}
if ($a->argc > 3 && $a->argv[2] === 'image') {
// Check if the user has responded to a delete confirmation query for a single photo
if (!empty($_POST['canceled'])) {
$a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
}
if (!empty($_POST['delete'])) {
@ -283,10 +282,10 @@ function photos_post(App $a)
notice('Successfully deleted the photo.');
} else {
notice('Failed to delete the photo.');
$a->internalRedirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
}
$a->internalRedirect('photos/' . $a->argv[1]);
DI::baseUrl()->redirect('photos/' . $a->argv[1]);
return; // NOTREACHED
}
}
@ -298,8 +297,7 @@ function photos_post(App $a)
$albname = !empty($_POST['albname']) ? Strings::escapeTags(trim($_POST['albname'])) : '';
$origaname = !empty($_POST['origaname']) ? Strings::escapeTags(trim($_POST['origaname'])) : '';
/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();
$str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : '';
$str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : '';
@ -593,7 +591,7 @@ function photos_post(App $a)
}
}
}
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
return; // NOTREACHED
}
@ -640,8 +638,7 @@ function photos_post(App $a)
$group_deny = $_REQUEST['group_deny'] ?? [];
$contact_deny = $_REQUEST['contact_deny'] ?? [];
/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();
$str_group_allow = $aclFormatter->toString(is_array($group_allow) ? $group_allow : explode(',', $group_allow));
$str_contact_allow = $aclFormatter->toString(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow));
@ -820,7 +817,7 @@ function photos_post(App $a)
// addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
// if they do not wish to be redirected
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
// NOTREACHED
}
@ -849,7 +846,7 @@ function photos_content(App $a)
$phototypes = Images::supportedTypes();
$_SESSION['photo_return'] = $a->cmd;
$_SESSION['photo_return'] = DI::args()->getCommand();
// Parse arguments
$datum = null;
@ -987,7 +984,7 @@ function photos_content(App $a)
// ACL permissions box
'$group_perms' => L10n::t('Show to Groups'),
'$contact_perms' => L10n::t('Show to Contacts'),
'$return_path' => $a->query_string,
'$return_path' => DI::args()->getQueryString(),
]);
return $o;
@ -997,7 +994,7 @@ function photos_content(App $a)
if ($datatype === 'album') {
// if $datum is not a valid hex, redirect to the default page
if (!Strings::isHex($datum)) {
$a->internalRedirect('photos/' . $a->data['user']['nickname']. '/album');
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname']. '/album');
}
$album = hex2bin($datum);
@ -1011,7 +1008,7 @@ function photos_content(App $a)
$total = count($r);
}
$pager = new Pager($a->query_string, 20);
$pager = new Pager(DI::args()->getQueryString(), 20);
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
$order_field = $_GET['order'] ?? '';
@ -1033,7 +1030,7 @@ function photos_content(App $a)
);
if ($cmd === 'drop') {
$drop_url = $a->query_string;
$drop_url = DI::args()->getQueryString();
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
'$method' => 'post',
@ -1140,7 +1137,7 @@ function photos_content(App $a)
}
if ($cmd === 'drop') {
$drop_url = $a->query_string;
$drop_url = DI::args()->getQueryString();
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
'$method' => 'post',
@ -1287,7 +1284,7 @@ function photos_content(App $a)
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
$total = DBA::count('item', $condition);
$pager = new Pager($a->query_string);
$pager = new Pager(DI::args()->getQueryString());
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
@ -1351,7 +1348,7 @@ function photos_content(App $a)
// ACL permissions box
'$group_perms' => L10n::t('Show to Groups'),
'$contact_perms' => L10n::t('Show to Contacts'),
'$return_path' => $a->query_string,
'$return_path' => DI::args()->getQueryString(),
]);
}
@ -1365,7 +1362,7 @@ function photos_content(App $a)
if (!empty($link_item['id']) && !empty($link_item['uri'])) {
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
$return_path = $a->cmd;
$return_path = DI::args()->getCommand();
if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
$like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
@ -1374,7 +1371,7 @@ function photos_content(App $a)
'$likethis' => L10n::t("I like this \x28toggle\x29"),
'$nolike' => L10n::t("I don't like this \x28toggle\x29"),
'$wait' => L10n::t('Please wait'),
'$return_path' => $a->query_string,
'$return_path' => DI::args()->getQueryString(),
]);
}
@ -1442,8 +1439,7 @@ function photos_content(App $a)
$template = $tpl;
$sparkle = '';
/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);
$activity = DI::activity();
if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) &&
@ -1553,7 +1549,7 @@ function photos_content(App $a)
$total = count($r);
}
$pager = new Pager($a->query_string, 20);
$pager = new Pager(DI::args()->getQueryString(), 20);
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`,

View File

@ -11,6 +11,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
@ -125,7 +126,7 @@ function profile_photo_post(App $a)
info(L10n::t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL);
// Update global directory in background
if ($path && strlen(Config::get('system', 'directory'))) {
Worker::add(PRIORITY_LOW, "Directory", $a->getBaseURL() . '/' . $path);
Worker::add(PRIORITY_LOW, "Directory", DI::baseUrl()->get() . '/' . $path);
}
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
@ -134,7 +135,7 @@ function profile_photo_post(App $a)
}
}
$a->internalRedirect($path);
DI::baseUrl()->redirect($path);
return; // NOTREACHED
}
@ -167,7 +168,7 @@ function profile_photo_post(App $a)
@unlink($src);
$imagecrop = profile_photo_crop_ui_head($a, $ph);
$a->internalRedirect('profile_photo/use/' . $imagecrop['hash']);
DI::baseUrl()->redirect('profile_photo/use/' . $imagecrop['hash']);
}
function profile_photo_content(App $a)
@ -222,7 +223,7 @@ function profile_photo_content(App $a)
Worker::add(PRIORITY_LOW, "Directory", $url);
}
$a->internalRedirect('profile/' . $a->user['nickname']);
DI::baseUrl()->redirect('profile/' . $a->user['nickname']);
return; // NOTREACHED
}
$ph = Photo::getImageForPhoto($r[0]);

View File

@ -16,6 +16,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
@ -41,7 +42,7 @@ function profiles_init(App $a) {
);
if (! DBA::isResult($r)) {
notice(L10n::t('Profile not found.') . EOL);
$a->internalRedirect('profiles');
DI::baseUrl()->redirect('profiles');
return; // NOTREACHED
}
@ -62,7 +63,7 @@ function profiles_init(App $a) {
info(L10n::t('Profile deleted.').EOL);
}
$a->internalRedirect('profiles');
DI::baseUrl()->redirect('profiles');
return; // NOTREACHED
}
@ -96,10 +97,10 @@ function profiles_init(App $a) {
info(L10n::t('New profile created.') . EOL);
if (DBA::isResult($r3) && count($r3) == 1) {
$a->internalRedirect('profiles/' . $r3[0]['id']);
DI::baseUrl()->redirect('profiles/' . $r3[0]['id']);
}
$a->internalRedirect('profiles');
DI::baseUrl()->redirect('profiles');
}
if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
@ -134,10 +135,10 @@ function profiles_init(App $a) {
);
info(L10n::t('New profile created.') . EOL);
if ((DBA::isResult($r3)) && (count($r3) == 1)) {
$a->internalRedirect('profiles/'.$r3[0]['id']);
DI::baseUrl()->redirect('profiles/'.$r3[0]['id']);
}
$a->internalRedirect('profiles');
DI::baseUrl()->redirect('profiles');
return; // NOTREACHED
}
@ -640,7 +641,7 @@ function profiles_content(App $a) {
);
if (DBA::isResult($r)) {
//Go to the default profile.
$a->internalRedirect('profiles/' . $r[0]['id']);
DI::baseUrl()->redirect('profiles/' . $r[0]['id']);
}
}
@ -654,7 +655,7 @@ function profiles_content(App $a) {
$profiles = '';
foreach ($r as $rr) {
$profiles .= Renderer::replaceMacros($tpl, [
'$photo' => $a->removeBaseURL($rr['thumb']),
'$photo' => DI::baseUrl()->remove($rr['thumb']),
'$id' => $rr['id'],
'$alt' => L10n::t('Profile Image'),
'$profile_name' => $rr['profile-name'],

View File

@ -86,7 +86,7 @@ function pubsub_post(App $a)
{
$xml = Network::postdata();
Logger::log('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']);
Logger::log('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . DI::args()->getCommand() . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']);
Logger::log('Data: ' . $xml, Logger::DATA);
$nick = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : '');

View File

@ -6,6 +6,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Util\Network;
@ -30,7 +31,7 @@ function redir_init(App $a) {
$contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]);
if (!DBA::isResult($contact)) {
notice(L10n::t('Contact not found.'));
$a->internalRedirect();
DI::baseUrl()->redirect();
}
$contact_url = $contact['url'];
@ -59,7 +60,7 @@ function redir_init(App $a) {
}
if (remote_user()) {
$host = substr($a->getBaseURL() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''), strpos($a->getBaseURL(), '://') + 3);
$host = substr(DI::baseUrl()->getUrlPath() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''), strpos(DI::baseUrl()->getUrlPath(), '://') + 3);
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
// On a local instance we have to check if the local user has already authenticated
@ -120,7 +121,7 @@ function redir_init(App $a) {
}
notice(L10n::t('Contact not found.'));
$a->internalRedirect();
DI::baseUrl()->redirect();
}
function redir_magic($a, $cid, $url)

View File

@ -9,14 +9,13 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Register;
use Friendica\Model\User;
use Friendica\Module\Security\Login;
function user_allow($hash)
{
$a = \get_app();
$register = Register::getByHash($hash);
if (!DBA::isResult($register)) {
return false;
@ -44,7 +43,7 @@ function user_allow($hash)
$l10n,
$user,
Config::get('config', 'sitename'),
$a->getBaseUrl(),
DI::baseUrl()->get(),
($register['password'] ?? '') ?: 'Sent in a previous email'
);
@ -81,7 +80,7 @@ function regmod_content(App $a)
{
if (!local_user()) {
info(L10n::t('Please login.') . EOL);
return Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
return Login::form(DI::args()->getQueryString(), intval(Config::get('config', 'register_policy')) === \Friendica\Module\Register::CLOSED ? 0 : 1);
}
if (!is_site_admin() || !empty($_SESSION['submanage'])) {
@ -98,11 +97,11 @@ function regmod_content(App $a)
if ($cmd === 'deny') {
user_deny($hash);
$a->internalRedirect('admin/users/');
DI::baseUrl()->redirect('admin/users/');
}
if ($cmd === 'allow') {
user_allow($hash);
$a->internalRedirect('admin/users/');
DI::baseUrl()->redirect('admin/users/');
}
}

View File

@ -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\Model\User;
use Friendica\Util\Strings;
@ -59,7 +60,7 @@ function removeme_post(App $a)
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
$a->internalRedirect();
DI::baseUrl()->redirect();
// NOTREACHED
}
}
@ -67,7 +68,7 @@ function removeme_post(App $a)
function removeme_content(App $a)
{
if (!local_user()) {
$a->internalRedirect();
DI::baseUrl()->redirect();
}
$hash = Strings::getRandomHex();
@ -79,7 +80,7 @@ function removeme_content(App $a)
$tpl = Renderer::getMarkupTemplate('removeme.tpl');
$o = Renderer::replaceMacros($tpl, [
'$basedir' => $a->getBaseURL(),
'$basedir' => DI::baseUrl()->get(),
'$hash' => $hash,
'$title' => L10n::t('Remove My Account'),
'$desc' => L10n::t('This will completely remove your account. Once this has been done it is not recoverable.'),

View File

@ -8,13 +8,14 @@ use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
function repair_ostatus_content(App $a) {
if (! local_user()) {
notice(L10n::t('Permission denied.') . EOL);
$a->internalRedirect('ostatus_repair');
DI::baseUrl()->redirect('ostatus_repair');
// NOTREACHED
}

View File

@ -5,7 +5,6 @@
use Friendica\App;
use Friendica\BaseModule;
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\ACL;
@ -20,14 +19,13 @@ use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\User;
use Friendica\Module\Security\Login;
use Friendica\Protocol\Email;
use Friendica\Util\ACLFormatter;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Friendica\Worker\Delivery;
@ -175,7 +173,7 @@ function settings_post(App $a)
$key = $_POST['remove'];
DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]);
$a->internalRedirect('settings/oauth/', true);
DI::baseUrl()->redirect('settings/oauth/', true);
return;
}
@ -221,7 +219,7 @@ function settings_post(App $a)
);
}
}
$a->internalRedirect('settings/oauth/', true);
DI::baseUrl()->redirect('settings/oauth/', true);
return;
}
@ -385,7 +383,7 @@ function settings_post(App $a)
}
Hook::callAll('display_settings_post', $_POST);
$a->internalRedirect('settings/display');
DI::baseUrl()->redirect('settings/display');
return; // NOTREACHED
}
@ -421,7 +419,7 @@ function settings_post(App $a)
if (!empty($_POST['resend_relocate'])) {
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
info(L10n::t("Relocate message has been send to your contacts"));
$a->internalRedirect('settings');
DI::baseUrl()->redirect('settings');
}
Hook::callAll('settings_post', $_POST);
@ -564,8 +562,7 @@ function settings_post(App $a)
date_default_timezone_set($timezone);
}
/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();
$str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : '';
$str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : '';
@ -641,7 +638,7 @@ function settings_post(App $a)
// Update the global contact for the user
GContact::updateForUser(local_user());
$a->internalRedirect('settings');
DI::baseUrl()->redirect('settings');
return; // NOTREACHED
}
@ -708,7 +705,7 @@ function settings_content(App $a)
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't');
DBA::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]);
$a->internalRedirect('settings/oauth/', true);
DI::baseUrl()->redirect('settings/oauth/', true);
return;
}
@ -724,7 +721,7 @@ function settings_content(App $a)
$tpl = Renderer::getMarkupTemplate('settings/oauth.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseModule::getFormSecurityToken("settings_oauth"),
'$baseurl' => $a->getBaseURL(true),
'$baseurl' => DI::baseUrl()->get(true),
'$title' => L10n::t('Connected Apps'),
'$add' => L10n::t('Add application'),
'$edit' => L10n::t('Edit'),
@ -1130,8 +1127,8 @@ function settings_content(App $a)
$tpl_addr = Renderer::getMarkupTemplate('settings/nick_set.tpl');
$prof_addr = Renderer::replaceMacros($tpl_addr,[
'$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->getHostName() . $a->getURLPath(), System::baseUrl() . '/profile/' . $nickname),
'$basepath' => $a->getHostName()
'$desc' => L10n::t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . DI::baseUrl()->getHostname() . DI::baseUrl()->getUrlPath(), System::baseUrl() . '/profile/' . $nickname),
'$basepath' => DI::baseUrl()->getHostname()
]);
$stpl = Renderer::getMarkupTemplate('settings/settings.tpl');
@ -1155,7 +1152,7 @@ function settings_content(App $a)
$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);
}

View File

@ -10,6 +10,7 @@ use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Util\Proxy as ProxyUtils;
@ -28,7 +29,7 @@ function suggest_post(App $a)
notice(L10n::t('Contact suggestion successfully ignored.'));
}
$a->internalRedirect('suggest');
DI::baseUrl()->redirect('suggest');
}
function suggest_content(App $a)
@ -40,7 +41,7 @@ function suggest_content(App $a)
return;
}
$_SESSION['return_path'] = $a->cmd;
$_SESSION['return_path'] = DI::args()->getCommand();
$a->page['aside'] .= Widget::findPeople();
$a->page['aside'] .= Widget::follow();
@ -57,7 +58,7 @@ function suggest_content(App $a)
if (!empty($_GET['ignore'])) {
// <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) {
if (strpos($arg, 'confirm=') === false) {

View File

@ -7,6 +7,7 @@ use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Term;
use Friendica\Util\Strings;
@ -14,11 +15,11 @@ use Friendica\Util\Strings;
function tagrm_post(App $a)
{
if (!local_user()) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
if (!empty($_POST['submit']) && ($_POST['submit'] === L10n::t('Cancel'))) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
$tags = [];
@ -30,7 +31,7 @@ function tagrm_post(App $a)
update_tags($item_id, $tags);
info(L10n::t('Tag(s) removed') . EOL);
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
// NOTREACHED
}
@ -71,31 +72,31 @@ function tagrm_content(App $a)
$o = '';
if (!local_user()) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
// NOTREACHED
}
if ($a->argc == 3) {
update_tags($a->argv[1], [Strings::escapeTags(trim(hex2bin($a->argv[2])))]);
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if (!$item_id) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
// NOTREACHED
}
$item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
if (!DBA::isResult($item)) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
$arr = explode(',', $item['tag']);
if (empty($item['tag'])) {
$a->internalRedirect($_SESSION['photo_return']);
DI::baseUrl()->redirect($_SESSION['photo_return']);
}
$o .= '<h3>' . L10n::t('Remove Item Tag') . '</h3>';

View File

@ -19,7 +19,7 @@ function uimport_post(App $a)
}
if (!empty($_FILES['accountfile'])) {
UserImport::importAccount($a, $_FILES['accountfile']);
UserImport::importAccount($_FILES['accountfile']);
return;
}
}

View File

@ -9,6 +9,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Model\User;
@ -20,7 +21,7 @@ function unfollow_post(App $a)
if (!local_user()) {
notice(L10n::t('Permission denied.'));
$a->internalRedirect('login');
DI::baseUrl()->redirect('login');
// NOTREACHED
}
@ -34,17 +35,17 @@ function unfollow_post(App $a)
if (!DBA::isResult($contact)) {
notice(L10n::t("You aren't following this contact."));
$a->internalRedirect($base_return_path);
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
if (!empty($_REQUEST['cancel'])) {
$a->internalRedirect($base_return_path . '/' . $contact['id']);
DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']);
}
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
notice(L10n::t('Unfollowing is currently not supported by your network.'));
$a->internalRedirect($base_return_path . '/' . $contact['id']);
DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']);
// NOTREACHED
}
@ -65,7 +66,7 @@ function unfollow_post(App $a)
}
info(L10n::t('Contact unfollowed'));
$a->internalRedirect($return_path);
DI::baseUrl()->redirect($return_path);
// NOTREACHED
}
@ -75,7 +76,7 @@ function unfollow_content(App $a)
if (!local_user()) {
notice(L10n::t('Permission denied.'));
$a->internalRedirect('login');
DI::baseUrl()->redirect('login');
// NOTREACHED
}
@ -90,13 +91,13 @@ function unfollow_content(App $a)
if (!DBA::isResult($contact)) {
notice(L10n::t("You aren't following this contact."));
$a->internalRedirect($base_return_path);
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}
if (!in_array($contact['network'], Protocol::NATIVE_SUPPORT)) {
notice(L10n::t('Unfollowing is currently not supported by your network.'));
$a->internalRedirect($base_return_path . '/' . $contact['id']);
DI::baseUrl()->redirect($base_return_path . '/' . $contact['id']);
// NOTREACHED
}
@ -107,7 +108,7 @@ function unfollow_content(App $a)
if (!DBA::isResult($self)) {
notice(L10n::t('Permission denied.'));
$a->internalRedirect($base_return_path);
DI::baseUrl()->redirect($base_return_path);
// NOTREACHED
}

View File

@ -12,6 +12,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Attach;
use Friendica\Model\Contact;
use Friendica\Model\Group;
@ -75,7 +76,7 @@ function videos_post(App $a)
$owner_uid = $a->data['user']['uid'];
if (local_user() != $owner_uid) {
$a->internalRedirect('videos/' . $a->data['user']['nickname']);
DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']);
}
if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
@ -92,11 +93,11 @@ function videos_post(App $a)
], local_user());
}
$a->internalRedirect('videos/' . $a->data['user']['nickname']);
DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']);
return; // NOTREACHED
}
$a->internalRedirect('videos/' . $a->data['user']['nickname']);
DI::baseUrl()->redirect('videos/' . $a->data['user']['nickname']);
}
function videos_content(App $a)
@ -123,7 +124,7 @@ function videos_content(App $a)
//$phototypes = Photo::supportedTypes();
$_SESSION['video_return'] = $a->cmd;
$_SESSION['video_return'] = DI::args()->getCommand();
//
// Parse arguments
@ -211,7 +212,7 @@ function videos_content(App $a)
$total = count($r);
}
$pager = new Pager($a->query_string, 20);
$pager = new Pager(DI::args()->getQueryString(), 20);
$r = q("SELECT hash, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`created`) AS `created`,
ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`filetype`) as `filetype`

View File

@ -8,6 +8,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Mail;
use Friendica\Model\Profile;
use Friendica\Util\Strings;
@ -72,7 +73,7 @@ function wallmessage_post(App $a) {
info(L10n::t('Message sent.') . EOL);
}
$a->internalRedirect('profile/'.$user['nickname']);
DI::baseUrl()->redirect('profile/'.$user['nickname']);
}

View File

@ -10,15 +10,13 @@ use Friendica\App\BaseURL;
use Friendica\App\Page;
use Friendica\App\Authentication;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Database\Database;
use Friendica\Model\Profile;
use Friendica\Module\Security\Login;
use Friendica\Module\Special\HTTPException as ModuleHTTPException;
use Friendica\Network\HTTPException;
use Friendica\Util\ConfigFileLoader;
@ -42,8 +40,6 @@ use Psr\Log\LoggerInterface;
*/
class App
{
/** @deprecated 2019.09 - use App\Arguments->getQueryString() */
public $query_string;
/**
* @var Page The current page environment
*/
@ -57,21 +53,13 @@ class App
public $page_contact;
public $content;
public $data = [];
/** @deprecated 2019.09 - use App\Arguments->getCommand() */
public $cmd = '';
/** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */
public $argv;
/** @deprecated 2019.09 - use App\Arguments->getArgc() */
public $argc;
/** @deprecated 2019.09 - Use App\Module->getName() instead */
public $module;
public $timezone;
public $interactive = true;
public $identities;
/** @deprecated 2019.09 - Use App\Mode->isMobile() instead */
public $is_mobile;
/** @deprecated 2019.09 - Use App\Mode->isTable() instead */
public $is_tablet;
public $theme_info = [];
public $category;
// Allow themes to control internal parameters
@ -100,7 +88,7 @@ class App
private $currentMobileTheme;
/**
* @var Configuration The config
* @var IConfiguration The config
*/
private $config;
@ -144,16 +132,6 @@ class App
return $this->config->getCache();
}
/**
* Returns the current config of this node
*
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* The basepath of this app
*
@ -165,67 +143,9 @@ class App
return $this->config->getCache()->get('system', 'basepath');
}
/**
* The Logger of this app
*
* @return LoggerInterface
*/
public function getLogger()
{
return $this->logger;
}
/**
* The profiler of this app
*
* @return Profiler
*/
public function getProfiler()
{
return $this->profiler;
}
/**
* Returns the Mode of the Application
*
* @return App\Mode The Application Mode
*/
public function getMode()
{
return $this->mode;
}
/**
* Returns the Database of the Application
*
* @return Database
*/
public function getDBA()
{
return $this->database;
}
/**
* @deprecated 2019.09 - use Page->registerStylesheet instead
* @see Page::registerStylesheet()
*/
public function registerStylesheet($path)
{
$this->page->registerStylesheet($path);
}
/**
* @deprecated 2019.09 - use Page->registerFooterScript instead
* @see Page::registerFooterScript()
*/
public function registerFooterScript($path)
{
$this->page->registerFooterScript($path);
}
/**
* @param Database $database The Friendica Database
* @param Configuration $config The Configuration
* @param IConfiguration $config The Configuration
* @param App\Mode $mode The mode of this Friendica app
* @param BaseURL $baseURL The full base URL of this Friendica app
* @param LoggerInterface $logger The current app logger
@ -234,7 +154,7 @@ class App
* @param App\Arguments $args The Friendica Arguments of the call
* @param Core\Process $process The process methods
*/
public function __construct(Database $database, Configuration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, App\Module $module, App\Page $page, Core\Process $process)
public function __construct(Database $database, IConfiguration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, App\Page $page, Core\Process $process)
{
$this->database = $database;
$this->config = $config;
@ -246,16 +166,10 @@ class App
$this->args = $args;
$this->process = $process;
$this->cmd = $args->getCommand();
$this->argv = $args->getArgv();
$this->argc = $args->getArgc();
$this->query_string = $args->getQueryString();
$this->module = $module->getName();
$this->page = $page;
$this->is_mobile = $mode->isMobile();
$this->is_tablet = $mode->isTablet();
$this->load();
}
@ -311,85 +225,6 @@ class App
}
}
/**
* Returns the scheme of the current call
*
* @return string
*
* @deprecated 2019.06 - use BaseURL->getScheme() instead
*/
public function getScheme()
{
return $this->baseURL->getScheme();
}
/**
* Retrieves the Friendica instance base URL
*
* @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN
*
* @return string Friendica server base URL
*
* @deprecated 2019.09 - use BaseUrl->get($ssl) instead
*/
public function getBaseURL($ssl = false)
{
return $this->baseURL->get($ssl);
}
/**
* @brief Initializes the baseurl components
*
* Clears the baseurl cache to prevent inconsistencies
*
* @param string $url
*
* @deprecated 2019.06 - use BaseURL->saveByURL($url) instead
*/
public function setBaseURL($url)
{
$this->baseURL->saveByURL($url);
}
/**
* Returns the current hostname
*
* @return string
*
* @deprecated 2019.06 - use BaseURL->getHostname() instead
*/
public function getHostName()
{
return $this->baseURL->getHostname();
}
/**
* Returns the sub-path of the full URL
*
* @return string
*
* @deprecated 2019.06 - use BaseURL->getUrlPath() instead
*/
public function getURLPath()
{
return $this->baseURL->getUrlPath();
}
/**
* @brief Removes the base url from an url. This avoids some mixed content problems.
*
* @param string $origURL
*
* @return string The cleaned url
*
* @deprecated 2019.09 - Use BaseURL->remove() instead
* @see BaseURL::remove()
*/
public function removeBaseURL(string $origURL)
{
return $this->baseURL->remove($origURL);
}
/**
* Returns the current UserAgent as a String
*
@ -403,31 +238,7 @@ class App
FRIENDICA_CODENAME . "' " .
FRIENDICA_VERSION . '-' .
DB_UPDATE_VERSION . '; ' .
$this->getBaseURL();
}
/**
* @deprecated 2019.09 - use Core\Process->isMaxProcessesReached() instead
*/
public function isMaxProcessesReached()
{
return $this->process->isMaxProcessesReached();
}
/**
* @deprecated 2019.09 - use Core\Process->isMinMemoryReached() instead
*/
public function isMinMemoryReached()
{
return $this->process->isMinMemoryReached();
}
/**
* @deprecated 2019.09 - use Core\Process->isMaxLoadReached() instead
*/
public function isMaxLoadReached()
{
return $this->process->isMaxLoadReached();
$this->baseURL->get();
}
/**
@ -593,25 +404,6 @@ class App
return Core\Theme::getStylesheetPath($this->getCurrentTheme());
}
/**
* @deprecated 2019.09 - use App\Mode->isAjax() instead
* @see App\Mode::isAjax()
*/
public function isAjax()
{
return $this->mode->isAjax();
}
/**
* @deprecated use Arguments->get() instead
*
* @see App\Arguments
*/
public function getArgumentValue($position, $default = '')
{
return $this->args->get($position, $default);
}
/**
* Sets the base url for use in cmdline programs which don't have
* $_SERVER variables
@ -626,8 +418,8 @@ class App
// and www.example.com vs example.com.
// We will only change the url to an ip address if there is no existing setting
if (empty($url) || (!Util\Strings::compareLink($url, $this->getBaseURL())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->baseURL->getHostname()))) {
$this->config->set('system', 'url', $this->getBaseURL());
if (empty($url) || (!Util\Strings::compareLink($url, $this->baseURL->get())) && (!preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/", $this->baseURL->getHostname()))) {
$this->config->set('system', 'url', $this->baseURL->get());
}
}
@ -641,12 +433,12 @@ class App
*
* @param App\Module $module The determined module
* @param App\Router $router
* @param PConfiguration $pconfig
* @param IPConfiguration $pconfig
* @param Authentication $auth The Authentication backend of the node
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public function runFrontend(App\Module $module, App\Router $router, PConfiguration $pconfig, Authentication $auth)
public function runFrontend(App\Module $module, App\Router $router, IPConfiguration $pconfig, Authentication $auth)
{
$moduleName = $module->getName();
@ -731,9 +523,9 @@ class App
// in install mode, any url loads install module
// but we need "view" module for stylesheet
if ($this->mode->isInstall() && $moduleName !== 'install') {
$this->internalRedirect('install');
$this->baseURL->redirect('install');
} elseif (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED) && $moduleName !== 'maintenance') {
$this->internalRedirect('maintenance');
$this->baseURL->redirect('maintenance');
} else {
$this->checkURL();
Core\Update::check($this->getBasePath(), false, $this->mode);
@ -743,35 +535,35 @@ class App
// Compatibility with the Android Diaspora client
if ($moduleName == 'stream') {
$this->internalRedirect('network?order=post');
$this->baseURL->redirect('network?order=post');
}
if ($moduleName == 'conversations') {
$this->internalRedirect('message');
$this->baseURL->redirect('message');
}
if ($moduleName == 'commented') {
$this->internalRedirect('network?order=comment');
$this->baseURL->redirect('network?order=comment');
}
if ($moduleName == 'liked') {
$this->internalRedirect('network?order=comment');
$this->baseURL->redirect('network?order=comment');
}
if ($moduleName == 'activity') {
$this->internalRedirect('network?conv=1');
$this->baseURL->redirect('network?conv=1');
}
if (($moduleName == 'status_messages') && ($this->args->getCommand() == 'status_messages/new')) {
$this->internalRedirect('bookmarklet');
$this->baseURL->redirect('bookmarklet');
}
if (($moduleName == 'user') && ($this->args->getCommand() == 'user/edit')) {
$this->internalRedirect('settings');
$this->baseURL->redirect('settings');
}
if (($moduleName == 'tag_followings') && ($this->args->getCommand() == 'tag_followings/manage')) {
$this->internalRedirect('search');
$this->baseURL->redirect('search');
}
// Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid
@ -782,7 +574,7 @@ class App
$module = $module->determineClass($this->args, $router, $this->config);
// Let the module run it's internal process (init, get, post, ...)
$module->run($this->l10n, $this, $this->logger, $_SERVER, $_POST);
$module->run($this->l10n, $this->baseURL, $this->logger, $_SERVER, $_POST);
} catch (HTTPException $e) {
ModuleHTTPException::rawContent($e);
}
@ -790,15 +582,6 @@ class App
$this->page->run($this, $this->baseURL, $this->mode, $module, $this->l10n, $this->config, $pconfig);
}
/**
* @deprecated 2019.12 use BaseUrl::redirect instead
* @see BaseURL::redirect()
*/
public function internalRedirect($toUrl = '', $ssl = false)
{
$this->baseURL->redirect($toUrl, $ssl);
}
/**
* Automatically redirects to relative or absolute URL
* Should only be used if it isn't clear if the URL is either internal or external

View File

@ -8,13 +8,14 @@ namespace Friendica\App;
use Exception;
use Friendica\App;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\PConfig;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Util\DateTimeFormat;
@ -29,8 +30,10 @@ use Psr\Log\LoggerInterface;
*/
class Authentication
{
/** @var Configuration */
/** @var IConfiguration */
private $config;
/** @var App\Mode */
private $mode;
/** @var App\BaseURL */
private $baseUrl;
/** @var L10n */
@ -47,7 +50,8 @@ class Authentication
/**
* Authentication constructor.
*
* @param Configuration $config
* @param IConfiguration $config
* @param App\Mode $mode
* @param App\BaseURL $baseUrl
* @param L10n $l10n
* @param Database $dba
@ -55,9 +59,10 @@ class Authentication
* @param User\Cookie $cookie
* @param Session\ISession $session
*/
public function __construct(Configuration $config, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
public function __construct(IConfiguration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
{
$this->config = $config;
$this->mode = $mode;
$this->baseUrl = $baseUrl;
$this->l10n = $l10n;
$this->dba = $dba;
@ -351,7 +356,7 @@ class Authentication
* The week ensures that sessions will expire after some inactivity.
*/;
if ($this->session->get('remember')) {
$a->getLogger()->info('Injecting cookie for remembered user ' . $user_record['nickname']);
$this->logger->info('Injecting cookie for remembered user ' . $user_record['nickname']);
$this->cookie->set($user_record['uid'], $user_record['password'], $user_record['prvkey']);
$this->session->remove('remember');
}
@ -374,7 +379,7 @@ class Authentication
if ($login_initial) {
Hook::callAll('logged_in', $a->user);
if ($a->module !== 'home' && $this->session->exists('return_path')) {
if (DI::module()->getName() !== 'home' && $this->session->exists('return_path')) {
$this->baseUrl->redirect($this->session->get('return_path'));
}
}
@ -404,10 +409,10 @@ class Authentication
}
// Case 2: No valid 2FA session: redirect to code verification page
if ($a->isAjax()) {
if ($this->mode->isAjax()) {
throw new HTTPException\ForbiddenException();
} else {
$a->internalRedirect('2fa');
$this->baseUrl->redirect('2fa');
}
}
}

View File

@ -2,7 +2,7 @@
namespace Friendica\App;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\System;
use Friendica\Util\Network;
use Friendica\Util\Strings;
@ -37,7 +37,7 @@ class BaseURL
/**
* The Friendica Config
*
* @var Configuration
* @var IConfiguration
*/
private $config;
@ -253,10 +253,10 @@ class BaseURL
}
/**
* @param Configuration $config The Friendica configuration
* @param IConfiguration $config The Friendica IConfiguration
* @param array $server The $_SERVER array
*/
public function __construct(Configuration $config, array $server)
public function __construct(IConfiguration $config, array $server)
{
$this->config = $config;
$this->server = $server;

View File

@ -3,7 +3,7 @@
namespace Friendica\App;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\BaseModule;
use Friendica\Core;
use Friendica\LegacyModule;
use Friendica\Module\Home;
@ -59,7 +59,7 @@ class Module
private $module;
/**
* @var BaseObject The module class
* @var BaseModule The module class
*/
private $module_class;
@ -151,13 +151,13 @@ class Module
*
* @param Arguments $args The Friendica execution arguments
* @param Router $router The Friendica routing instance
* @param Core\Config\Configuration $config The Friendica Configuration
* @param Core\Config\IConfiguration $config The Friendica Configuration
*
* @return Module The determined module of this call
*
* @throws \Exception
*/
public function determineClass(Arguments $args, Router $router, Core\Config\Configuration $config)
public function determineClass(Arguments $args, Router $router, Core\Config\IConfiguration $config)
{
$printNotAllowedAddon = false;
@ -208,14 +208,14 @@ class Module
* Run the determined module class and calls all hooks applied to
*
* @param Core\L10n\L10n $l10n The L10n instance
* @param App $app The whole Friendica app (for method arguments)
* @param App\BaseURL $baseUrl The Friendica Base URL
* @param LoggerInterface $logger The Friendica logger
* @param array $server The $_SERVER variable
* @param array $post The $_POST variables
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function run(Core\L10n\L10n $l10n, App $app, LoggerInterface $logger, array $server, array $post)
public function run(Core\L10n\L10n $l10n, App\BaseURL $baseUrl, LoggerInterface $logger, array $server, array $post)
{
if ($this->printNotAllowedAddon) {
info($l10n->t("You must be logged in to use addons. "));
@ -239,7 +239,7 @@ class Module
if (!empty($queryString) && ($queryString === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
$logger->info('index.php: dreamhost_error_hack invoked.', ['Original URI' => $server['REQUEST_URI']]);
$app->internalRedirect($server['REQUEST_URI']);
$baseUrl->redirect($server['REQUEST_URI']);
}
$logger->debug('index.php: page not found.', ['request_uri' => $server['REQUEST_URI'], 'address' => $server['REMOTE_ADDR'], 'query' => $server['QUERY_STRING']]);

View File

@ -7,8 +7,8 @@ use DOMDocument;
use DOMXPath;
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Renderer;
@ -171,12 +171,12 @@ class Page implements ArrayAccess
* @param App $app The Friendica App instance
* @param Module $module The loaded Friendica module
* @param L10n $l10n The l10n language instance
* @param Configuration $config The Friendica configuration
* @param PConfiguration $pConfig The Friendica personal configuration (for user)
* @param IConfiguration $config The Friendica configuration
* @param IPConfiguration $pConfig The Friendica personal configuration (for user)
*
* @throws HTTPException\InternalServerErrorException
*/
private function initHead(App $app, Module $module, L10n $l10n, Configuration $config, PConfiguration $pConfig)
private function initHead(App $app, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pConfig)
{
$interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
@ -347,12 +347,12 @@ class Page implements ArrayAccess
* @param Mode $mode The current node mode
* @param Module $module The loaded Friendica module
* @param L10n $l10n The l10n language class
* @param Configuration $config The Configuration of this node
* @param PConfiguration $pconfig The personal/user configuration
* @param IConfiguration $config The Configuration of this node
* @param IPConfiguration $pconfig The personal/user configuration
*
* @throws HTTPException\InternalServerErrorException
*/
public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, Configuration $config, PConfiguration $pconfig)
public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pconfig)
{
$moduleName = $module->getName();

View File

@ -32,10 +32,11 @@ abstract class BaseModel
*/
private $data = [];
public function __construct(Database $dba, LoggerInterface $logger)
public function __construct(Database $dba, LoggerInterface $logger, $data = [])
{
$this->dba = $dba;
$this->logger = $logger;
$this->data = $data;
}
/**
@ -71,15 +72,13 @@ abstract class BaseModel
*/
public function fetch(array $condition)
{
$intro = $this->dba->selectFirst(static::$table_name, [], $condition);
$data = $this->dba->selectFirst(static::$table_name, [], $condition);
if (!$intro) {
if (!$data) {
throw new HTTPException\NotFoundException(static::class . ' record not found.');
}
$this->data = $intro;
return $this;
return new static($this->dba, $this->logger, $data);
}
/**

View File

@ -14,7 +14,7 @@ use Friendica\Core\Logger;
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
abstract class BaseModule extends BaseObject
abstract class BaseModule
{
/**
* @brief Initialization method common to both content() and post()
@ -140,7 +140,7 @@ abstract class BaseModule extends BaseObject
Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA);
notice(self::getFormSecurityStandardErrorMessage());
$a->internalRedirect($err_redirect);
DI::baseUrl()->redirect($err_redirect);
}
}

View File

@ -1,69 +0,0 @@
<?php
/**
* @file src/BaseObject.php
*/
namespace Friendica;
require_once __DIR__ . '/../boot.php';
use Dice\Dice;
use Friendica\Network\HTTPException\InternalServerErrorException;
/**
* Basic object
*
* Contains what is useful to any object
*
* Act's like a global registry for classes
*/
class BaseObject
{
/**
* @var Dice The Dependency Injection library
*/
private static $dice;
/**
* Set's the dependency injection library for a global usage
*
* @param Dice $dice The dependency injection library
*/
public static function setDependencyInjection(Dice $dice)
{
self::$dice = $dice;
}
/**
* Get the app
*
* Same as get_app from boot.php
*
* @return App
*/
public static function getApp()
{
return self::getClass(App::class);
}
/**
* Returns the initialized class based on it's name
*
* @param string $name The name of the class
*
* @return object The initialized name
*
* @throws InternalServerErrorException
*/
public static function getClass(string $name)
{
if (empty(self::$dice)) {
throw new InternalServerErrorException('DICE isn\'t initialized.');
}
if (class_exists($name) || interface_exists($name)) {
return self::$dice->create($name);
} else {
throw new InternalServerErrorException('Class \'' . $name . '\' isn\'t valid.');
}
}
}

View File

@ -25,7 +25,7 @@ class AutomaticInstallation extends Console
private $configCache;
/**
* @var Config\Configuration
* @var Config\IConfiguration
*/
private $config;
@ -89,7 +89,7 @@ Examples
HELP;
}
public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\Configuration $config, Database $dba, array $argv = null)
public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfiguration $config, Database $dba, array $argv = null)
{
parent::__construct($argv);

View File

@ -4,7 +4,7 @@ namespace Friendica\Console;
use Asika\SimpleConsole\CommandArgsException;
use Friendica\App;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use RuntimeException;
/**
@ -40,7 +40,7 @@ class Config extends \Asika\SimpleConsole\Console
*/
private $appMode;
/**
* @var Configuration
* @var IConfiguration
*/
private $config;
@ -78,7 +78,7 @@ HELP;
return $help;
}
public function __construct(App\Mode $appMode, Configuration $config, array $argv = null)
public function __construct(App\Mode $appMode, IConfiguration $config, array $argv = null)
{
parent::__construct($argv);

View File

@ -3,7 +3,7 @@
namespace Friendica\Console;
use Friendica\App;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
/**
* @brief Sets maintenance mode for this node
@ -19,7 +19,7 @@ class Maintenance extends \Asika\SimpleConsole\Console
*/
private $appMode;
/**
* @var Configuration
* @var IConfiguration
*/
private $config;
@ -52,7 +52,7 @@ HELP;
return $help;
}
public function __construct(App\Mode $appMode, Configuration $config, $argv = null)
public function __construct(App\Mode $appMode, IConfiguration $config, $argv = null)
{
parent::__construct($argv);

View File

@ -3,7 +3,7 @@
namespace Friendica\Console;
use Friendica\App;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Update;
@ -24,7 +24,7 @@ class PostUpdate extends \Asika\SimpleConsole\Console
*/
private $appMode;
/**
* @var Configuration
* @var IConfiguration
*/
private $config;
/**
@ -46,7 +46,7 @@ HELP;
return $help;
}
public function __construct(App\Mode $appMode, Configuration $config, L10n $l10n, array $argv = null)
public function __construct(App\Mode $appMode, IConfiguration $config, L10n $l10n, array $argv = null)
{
parent::__construct($argv);
@ -57,7 +57,7 @@ HELP;
protected function doExecute()
{
$a = \Friendica\BaseObject::getApp();
$a = \Friendica\DI::app();
if ($this->getOption($this->helpOptions)) {
$this->out($this->getHelp());

View File

@ -5,7 +5,7 @@ namespace Friendica\Console;
use Asika\SimpleConsole\CommandArgsException;
use Asika\SimpleConsole\Console;
use Console_Table;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
/**
* @brief Manage blocked servers
@ -20,7 +20,7 @@ class ServerBlock extends Console
protected $helpOptions = ['h', 'help', '?'];
/**
* @var Configuration
* @var IConfiguration
*/
private $config;
@ -49,7 +49,7 @@ HELP;
return $help;
}
public function __construct(Configuration $config, $argv = null)
public function __construct(IConfiguration $config, $argv = null)
{
parent::__construct($argv);
@ -77,9 +77,9 @@ HELP;
/**
* Prints the whole list of blocked domains including the reason
*
* @param Configuration $config
* @param IConfiguration $config
*/
private function printBlockedServers(Configuration $config)
private function printBlockedServers(IConfiguration $config)
{
$table = new Console_Table();
$table->setHeaders(['Domain', 'Reason']);
@ -93,11 +93,11 @@ HELP;
/**
* Adds a server to the blocked list
*
* @param Configuration $config
* @param IConfiguration $config
*
* @return int The return code (0 = success, 1 = failed)
*/
private function addBlockedServer(Configuration $config)
private function addBlockedServer(IConfiguration $config)
{
if (count($this->args) < 2 || count($this->args) > 3) {
throw new CommandArgsException('Add needs a domain and optional a reason.');
@ -145,11 +145,11 @@ HELP;
/**
* Removes a server from the blocked list
*
* @param Configuration $config
* @param IConfiguration $config
*
* @return int The return code (0 = success, 1 = failed)
*/
private function removeBlockedServer(Configuration $config)
private function removeBlockedServer(IConfiguration $config)
{
if (count($this->args) !== 2) {
throw new CommandArgsException('Remove needs a second parameter.');

View File

@ -2,7 +2,7 @@
namespace Friendica\Console;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
/**
* Tired of chasing typos and finding them after a commit.
@ -15,7 +15,7 @@ class Typo extends \Asika\SimpleConsole\Console
protected $helpOptions = ['h', 'help', '?'];
/**
* @var Configuration
* @var IConfiguration
*/
private $config;
@ -36,7 +36,7 @@ HELP;
return $help;
}
public function __construct(Configuration $config, array $argv = null)
public function __construct(IConfiguration $config, array $argv = null)
{
parent::__construct($argv);

View File

@ -12,6 +12,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Model\User;
@ -152,7 +153,7 @@ class Nav
if (Session::isAuthenticated()) {
$nav['logout'] = ['logout', L10n::t('Logout'), '', L10n::t('End this session')];
} else {
$nav['login'] = ['login', L10n::t('Login'), ($a->module == 'login' ? 'selected' : ''), L10n::t('Sign in')];
$nav['login'] = ['login', L10n::t('Login'), (DI::module()->getName() == 'login' ? 'selected' : ''), L10n::t('Sign in')];
}
if (local_user()) {
@ -167,7 +168,7 @@ class Nav
// user info
$contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$userinfo = [
'icon' => (DBA::isResult($contact) ? $a->removeBaseURL($contact['micro']) : 'images/person-48.jpg'),
'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'],
];
}
@ -178,7 +179,7 @@ class Nav
$homelink = Session::get('visitor_home', '');
}
if (($a->module != 'home') && (! (local_user()))) {
if ((DI::module()->getName() != 'home') && (! (local_user()))) {
$nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')];
}

View File

@ -8,7 +8,6 @@ namespace Friendica\Content\Text;
use DOMDocument;
use DOMXPath;
use Exception;
use Friendica\BaseObject;
use Friendica\Content\OEmbed;
use Friendica\Content\Smilies;
use Friendica\Core\Cache;
@ -19,6 +18,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Event;
use Friendica\Model\Photo;
@ -33,7 +33,7 @@ use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\XML;
class BBCode extends BaseObject
class BBCode
{
/**
* @brief Fetches attachment data that were generated the old way
@ -1093,7 +1093,7 @@ class BBCode extends BaseObject
$text = Cache::get($cache_key);
if (is_null($text)) {
$a = self::getApp();
$a = DI::app();
$stamp1 = microtime(true);
@ -1104,7 +1104,7 @@ class BBCode extends BaseObject
@curl_exec($ch);
$curl_info = @curl_getinfo($ch);
$a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "network", System::callstack());
if (substr($curl_info['content_type'], 0, 6) == 'image/') {
$text = "[url=" . $match[1] . ']' . $match[1] . "[/url]";
@ -1149,10 +1149,10 @@ class BBCode extends BaseObject
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
$own_photo_url = preg_quote(Strings::normaliseLink($a->getBaseURL()) . '/photos/');
$own_photo_url = preg_quote(Strings::normaliseLink(DI::baseUrl()->get()) . '/photos/');
if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) {
if (!empty($match[3])) {
$text = '[img=' . str_replace('-1.', '-0.', $match[2]) . ']' . $match[3] . '[/img]';
@ -1178,7 +1178,7 @@ class BBCode extends BaseObject
@curl_exec($ch);
$curl_info = @curl_getinfo($ch);
$a->getProfiler()->saveTimestamp($stamp1, "network", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "network", System::callstack());
// if its a link to a picture then embed this picture
if (substr($curl_info['content_type'], 0, 6) == 'image/') {
@ -1253,7 +1253,7 @@ class BBCode extends BaseObject
*/
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
@ -2010,7 +2010,7 @@ class BBCode extends BaseObject
*/
public static function toMarkdown($text, $for_diaspora = true)
{
$a = self::getApp();
$a = DI::app();
$original_text = $text;
@ -2061,7 +2061,7 @@ class BBCode extends BaseObject
// Now convert HTML to Markdown
$text = HTML::toMarkdown($text);
$a->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "parser", System::callstack());
// Libertree has a problem with escaped hashtags.
$text = str_replace(['\#'], ['#'], $text);

View File

@ -6,8 +6,8 @@
namespace Friendica\Content\Text;
use Friendica\BaseObject;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
/**
@ -15,7 +15,7 @@ use Friendica\Model\Contact;
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Markdown extends BaseObject
class Markdown
{
/**
* Converts a Markdown string into HTML. The hardwrap parameter maximizes
@ -43,7 +43,7 @@ class Markdown extends BaseObject
$html = $MarkdownParser->transform($text);
self::getApp()->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "parser", System::callstack());
return $html;
}

View File

@ -7,8 +7,8 @@
namespace Friendica\Core;
use Friendica\App\Page;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
@ -17,7 +17,7 @@ use Friendica\Model\Group;
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class ACL extends BaseObject
class ACL
{
/**
* Returns a select input tag with all the contact of the local user
@ -35,7 +35,7 @@ class ACL extends BaseObject
*/
public static function getSuggestContactSelectHTML($selname, $selclass, array $options = [], array $preselected = [])
{
$a = self::getApp();
$a = DI::app();
$networks = null;
@ -109,7 +109,7 @@ class ACL extends BaseObject
$arr = ['contact' => $contacts, 'entry' => $o];
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
Hook::callAll($a->module . '_pre_' . $selname, $arr);
Hook::callAll(DI::module()->getName() . '_pre_' . $selname, $arr);
if (DBA::isResult($contacts)) {
foreach ($contacts as $contact) {
@ -127,7 +127,7 @@ class ACL extends BaseObject
$o .= '</select>' . PHP_EOL;
Hook::callAll($a->module . '_post_' . $selname, $o);
Hook::callAll(DI::module()->getName() . '_post_' . $selname, $o);
return $o;
}
@ -145,7 +145,7 @@ class ACL extends BaseObject
*/
public static function getMessageContactSelectHTML($selname, $selclass, array $preselected = [], $size = 4, $tabindex = null)
{
$a = self::getApp();
$a = DI::app();
$o = '';
@ -175,7 +175,7 @@ class ACL extends BaseObject
$arr = ['contact' => $contacts, 'entry' => $o];
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
Hook::callAll($a->module . '_pre_' . $selname, $arr);
Hook::callAll(DI::module()->getName() . '_pre_' . $selname, $arr);
$receiverlist = [];
@ -201,7 +201,7 @@ class ACL extends BaseObject
$o .= implode(', ', $receiverlist);
}
Hook::callAll($a->module . '_post_' . $selname, $o);
Hook::callAll(DI::module()->getName() . '_post_' . $selname, $o);
return $o;
}

View File

@ -5,14 +5,14 @@
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings;
/**
* Some functions to handle addons
*/
class Addon extends BaseObject
class Addon
{
/**
* The addon sub-directory
@ -177,7 +177,7 @@ class Addon extends BaseObject
@include_once('addon/' . $addon . '/' . $addon . '.php');
if (function_exists($addon . '_install')) {
$func = $addon . '_install';
$func(self::getApp());
$func(DI::app());
$addon_admin = (function_exists($addon . "_addon_admin") ? 1 : 0);
@ -234,11 +234,11 @@ class Addon extends BaseObject
if (function_exists($addon . '_uninstall')) {
$func = $addon . '_uninstall';
$func(self::getApp());
$func(DI::app());
}
if (function_exists($addon . '_install')) {
$func = $addon . '_install';
$func(self::getApp());
$func(DI::app());
}
DBA::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
}
@ -267,7 +267,7 @@ class Addon extends BaseObject
*/
public static function getInfo($addon)
{
$a = self::getApp();
$a = DI::app();
$addon = Strings::sanitizeFilePathItem($addon);
@ -286,7 +286,7 @@ class Addon extends BaseObject
$stamp1 = microtime(true);
$f = file_get_contents("addon/$addon/$addon.php");
$a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "file", System::callstack());
$r = preg_match("|/\*.*\*/|msU", $f, $m);

View File

@ -4,14 +4,13 @@
*/
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Cache\Cache as CacheClass;
use Friendica\Core\Cache\ICache;
use Friendica\DI;
/**
* @brief Class for storing data for a short time
*/
class Cache extends BaseObject
class Cache
{
/** @deprecated Use CacheClass::MONTH */
const MONTH = CacheClass::MONTH;
@ -42,7 +41,7 @@ class Cache extends BaseObject
*/
public static function getAllKeys($prefix = null)
{
return self::getClass(ICache::class)->getAllKeys($prefix);
return DI::cache()->getAllKeys($prefix);
}
/**
@ -55,7 +54,7 @@ class Cache extends BaseObject
*/
public static function get($key)
{
return self::getClass(ICache::class)->get($key);
return DI::cache()->get($key);
}
/**
@ -72,7 +71,7 @@ class Cache extends BaseObject
*/
public static function set($key, $value, $duration = CacheClass::MONTH)
{
return self::getClass(ICache::class)->set($key, $value, $duration);
return DI::cache()->set($key, $value, $duration);
}
/**
@ -85,7 +84,7 @@ class Cache extends BaseObject
*/
public static function delete($key)
{
return self::getClass(ICache::class)->delete($key);
return DI::cache()->delete($key);
}
/**
@ -98,6 +97,6 @@ class Cache extends BaseObject
*/
public static function clear($outdated = true)
{
return self::getClass(ICache::class)->clear($outdated);
return DI::cache()->clear($outdated);
}
}

View File

@ -3,7 +3,7 @@
namespace Friendica\Core\Cache;
use Exception;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Memcache;
/**
@ -25,7 +25,7 @@ class MemcacheCache extends Cache implements IMemoryCache
/**
* @throws Exception
*/
public function __construct(string $hostname, Configuration $config)
public function __construct(string $hostname, IConfiguration $config)
{
if (!class_exists('Memcache', false)) {
throw new Exception('Memcache class isn\'t available');

View File

@ -3,7 +3,7 @@
namespace Friendica\Core\Cache;
use Exception;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Memcached;
use Psr\Log\LoggerInterface;
@ -39,7 +39,7 @@ class MemcachedCache extends Cache implements IMemoryCache
*
* @throws \Exception
*/
public function __construct(string $hostname, Configuration $config, LoggerInterface $logger)
public function __construct(string $hostname, IConfiguration $config, LoggerInterface $logger)
{
if (!class_exists('Memcached', false)) {
throw new Exception('Memcached class isn\'t available');

View File

@ -3,7 +3,7 @@
namespace Friendica\Core\Cache;
use Exception;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Redis;
/**
@ -22,7 +22,7 @@ class RedisCache extends Cache implements IMemoryCache
/**
* @throws Exception
*/
public function __construct(string $hostname, Configuration $config)
public function __construct(string $hostname, IConfiguration $config)
{
if (!class_exists('Redis', false)) {
throw new Exception('Redis class isn\'t available');

View File

@ -8,8 +8,7 @@
*/
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Config\Configuration;
use Friendica\DI;
/**
* @brief Arbitrary system configuration storage
@ -18,7 +17,7 @@ use Friendica\Core\Config\Configuration;
* If we ever would decide to return exactly the variable type as entered,
* we will have fun with the additional features. :-)
*/
class Config extends BaseObject
class Config
{
/**
* @brief Loads all configuration values of family into a cached storage.
@ -29,7 +28,7 @@ class Config extends BaseObject
*/
public static function load($cat = "config")
{
self::getClass(Configuration::class)->load($cat);
DI::config()->load($cat);
}
/**
@ -45,7 +44,7 @@ class Config extends BaseObject
*/
public static function get($cat, $key, $default_value = null, $refresh = false)
{
return self::getClass(Configuration::class)->get($cat, $key, $default_value, $refresh);
return DI::config()->get($cat, $key, $default_value, $refresh);
}
/**
@ -63,7 +62,7 @@ class Config extends BaseObject
*/
public static function set($cat, $key, $value)
{
return self::getClass(Configuration::class)->set($cat, $key, $value);
return DI::config()->set($cat, $key, $value);
}
/**
@ -76,6 +75,6 @@ class Config extends BaseObject
*/
public static function delete($cat, $key)
{
return self::getClass(Configuration::class)->delete($cat, $key);
return DI::config()->delete($cat, $key);
}
}

View File

@ -10,7 +10,7 @@ use Friendica\Model;
* - The Config-Files (loaded into the FileCache @see Cache\ConfigCache)
* - The Config-DB-Table (per Config-DB-model @see Model\Config\Config)
*/
abstract class Configuration
abstract class Configuration implements IConfiguration
{
/**
* @var Cache\ConfigCache
@ -33,68 +33,10 @@ abstract class Configuration
}
/**
* Returns the Config Cache
*
* @return Cache\ConfigCache
* {@inheritDoc}
*/
public function getCache()
{
return $this->configCache;
}
/**
* @brief Loads all configuration values of family into a cached storage.
*
* All configuration values of the system are stored in the cache ( @see ConfigCache )
*
* @param string $cat The category of the configuration value
*
* @return void
*/
abstract public function load(string $cat = 'config');
/**
* @brief Get a particular user's config variable given the category name
* ($cat) and a $key.
*
* Get a particular config value from the given category ($cat)
* and the $key from a cached storage either from the $this->configAdapter
* (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
*
* @param string $cat The category of the configuration value
* @param string $key The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
abstract public function get(string $cat, string $key, $default_value = null, bool $refresh = false);
/**
* @brief Sets a configuration value for system config
*
* Stores a config value ($value) in the category ($cat) under the key ($key)
*
* Note: Please do not store booleans - convert to 0/1 integer values!
*
* @param string $cat The category of the configuration value
* @param string $key The configuration key to set
* @param mixed $value The value to store
*
* @return bool Operation success
*/
abstract public function set(string $cat, string $key, $value);
/**
* @brief Deletes the given key from the system configuration.
*
* Removes the configured value from the stored cache in $this->configCache
* (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
*
* @param string $cat The category of the configuration value
* @param string $key The configuration key to delete
*
* @return bool
*/
abstract public function delete(string $cat, string $key);
}

View File

@ -0,0 +1,73 @@
<?php
namespace Friendica\Core\Config;
/**
* Interface for accessing system wide configurations
*/
interface IConfiguration
{
/**
* @brief Loads all configuration values of family into a cached storage.
*
* All configuration values of the system are stored in the cache ( @see ConfigCache )
*
* @param string $cat The category of the configuration value
*
* @return void
*/
function load(string $cat = 'config');
/**
* @brief Get a particular user's config variable given the category name
* ($cat) and a $key.
*
* Get a particular config value from the given category ($cat)
* and the $key from a cached storage either from the $this->configAdapter
* (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
*
* @param string $cat The category of the configuration value
* @param string $key The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
function get(string $cat, string $key, $default_value = null, bool $refresh = false);
/**
* @brief Sets a configuration value for system config
*
* Stores a config value ($value) in the category ($cat) under the key ($key)
*
* Note: Please do not store booleans - convert to 0/1 integer values!
*
* @param string $cat The category of the configuration value
* @param string $key The configuration key to set
* @param mixed $value The value to store
*
* @return bool Operation success
*/
function set(string $cat, string $key, $value);
/**
* @brief Deletes the given key from the system configuration.
*
* Removes the configured value from the stored cache in $this->configCache
* (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
*
* @param string $cat The category of the configuration value
* @param string $key The configuration key to delete
*
* @return bool
*/
function delete(string $cat, string $key);
/**
* Returns the Config Cache
*
* @return Cache\ConfigCache
*/
function getCache();
}

View File

@ -0,0 +1,82 @@
<?php
namespace Friendica\Core\Config;
/**
* Interface for accessing user specific configurations
*/
interface IPConfiguration
{
/**
* Loads all configuration values of a user's config family into a cached storage.
*
* All configuration values of the given user are stored with the $uid in the cache
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
*
* @return void
* @see PConfigCache
*
*/
function load(int $uid, string $cat = 'config');
/**
* Get a particular user's config variable given the category name
* ($cat) and a key.
*
* Get a particular user's config value from the given category ($cat)
* and the $key with the $uid from a cached storage either from the $this->configAdapter
* (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
* @param string $key The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
/**
* Sets a configuration value for a user
*
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid.
*
* @note Please do not store booleans - convert to 0/1 integer values!
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
* @param string $key The configuration key to set
* @param mixed $value The value to store
*
* @return bool Operation success
*/
function set(int $uid, string $cat, string $key, $value);
/**
* Deletes the given key from the users's configuration.
*
* Removes the configured value from the stored cache in $this->configCache
* (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
* with the given $uid.
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
* @param string $key The configuration key to delete
*
* @return bool
*/
function delete(int $uid, string $cat, string $key);
/**
* Returns the Config Cache
*
* @return Cache\PConfigCache
*/
function getCache();
}

View File

@ -11,7 +11,7 @@ use Friendica\Model;
* The configuration cache (@see Cache\PConfigCache) is used for temporary caching of database calls. This will
* increase the performance.
*/
abstract class PConfiguration
abstract class PConfiguration implements IPConfiguration
{
/**
* @var Cache\PConfigCache
@ -42,68 +42,4 @@ abstract class PConfiguration
{
return $this->configCache;
}
/**
* Loads all configuration values of a user's config family into a cached storage.
*
* All configuration values of the given user are stored with the $uid in the cache
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
*
* @return void
* @see PConfigCache
*
*/
abstract public function load(int $uid, string $cat = 'config');
/**
* Get a particular user's config variable given the category name
* ($cat) and a key.
*
* Get a particular user's config value from the given category ($cat)
* and the $key with the $uid from a cached storage either from the $this->configAdapter
* (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
* @param string $key The configuration key to query
* @param mixed $default_value optional, The value to return if key is not set (default: null)
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
*
* @return mixed Stored value or null if it does not exist
*/
abstract public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
/**
* Sets a configuration value for a user
*
* Stores a config value ($value) in the category ($family) under the key ($key)
* for the user_id $uid.
*
* @note Please do not store booleans - convert to 0/1 integer values!
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
* @param string $key The configuration key to set
* @param mixed $value The value to store
*
* @return bool Operation success
*/
abstract public function set(int $uid, string $cat, string $key, $value);
/**
* Deletes the given key from the users's configuration.
*
* Removes the configured value from the stored cache in $this->configCache
* (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
* with the given $uid.
*
* @param int $uid The user_id
* @param string $cat The category of the configuration value
* @param string $key The configuration key to delete
*
* @return bool
*/
abstract public function delete(int $uid, string $cat, string $key);
}

View File

@ -146,7 +146,7 @@ HELP;
$className = $this->subConsoles[$command];
Friendica\BaseObject::setDependencyInjection($this->dice);
Friendica\DI::init($this->dice);
/** @var Console $subconsole */
$subconsole = $this->dice->create($className, [$subargs]);

View File

@ -5,14 +5,14 @@
namespace Friendica\Core;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings;
/**
* Some functions to handle hooks
*/
class Hook extends BaseObject
class Hook
{
/**
* Array of registered hooks
@ -75,7 +75,7 @@ class Hook extends BaseObject
*/
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];
if (DBA::exists('hook', $condition)) {
@ -98,7 +98,7 @@ class Hook extends BaseObject
*/
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
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
@ -148,7 +148,7 @@ class Hook extends BaseObject
if ($hook[0] != $fork_hook[0]) {
continue;
}
self::callSingle(self::getApp(), 'hook_fork', $fork_hook, $hookdata);
self::callSingle(DI::app(), 'hook_fork', $fork_hook, $hookdata);
}
if (!$hookdata['execute']) {
@ -175,7 +175,7 @@ class Hook extends BaseObject
{
if (array_key_exists($name, self::$hooks)) {
foreach (self::$hooks[$name] as $hook) {
self::callSingle(self::getApp(), $name, $hook, $data);
self::callSingle(DI::app(), $name, $hook, $data);
}
}
}

View File

@ -4,14 +4,14 @@
*/
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\L10n\L10n as L10nClass;
use Friendica\DI;
/**
* Provide Language, Translation, and Localization functions to the application
* Localization can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N").
*/
class L10n extends BaseObject
class L10n
{
/**
* Returns the current language code
@ -20,7 +20,7 @@ class L10n extends BaseObject
*/
public static function getCurrentLang()
{
return self::getClass(L10nClass::class)->getCurrentLang();
return DI::l10n()->getCurrentLang();
}
/**
@ -32,7 +32,7 @@ class L10n extends BaseObject
*/
public static function withLang(string $lang)
{
return self::getClass(L10nClass::class)->withLang($lang);
DI::l10n()->withLang($lang);
}
/**
@ -54,7 +54,7 @@ class L10n extends BaseObject
*/
public static function t($s, ...$vars)
{
return self::getClass(L10nClass::class)->t($s, ...$vars);
return DI::l10n()->t($s, ...$vars);
}
/**
@ -79,7 +79,7 @@ class L10n extends BaseObject
*/
public static function tt(string $singular, string $plural, int $count)
{
return self::getClass(L10nClass::class)->tt($singular, $plural, $count);
return DI::l10n()->tt($singular, $plural, $count);
}
/**
@ -107,7 +107,7 @@ class L10n extends BaseObject
*/
public static function getDay($s)
{
return self::getClass(L10nClass::class)->getDay($s);
return DI::l10n()->getDay($s);
}
/**
@ -119,7 +119,7 @@ class L10n extends BaseObject
*/
public static function getDayShort($s)
{
return self::getClass(L10nClass::class)->getDayShort($s);
return DI::l10n()->getDayShort($s);
}
/**
@ -131,6 +131,6 @@ class L10n extends BaseObject
*/
public static function getPokeVerbs()
{
return self::getClass(L10nClass::class)->getPokeVerbs();
return DI::l10n()->getPokeVerbs();
}
}

View File

@ -2,7 +2,7 @@
namespace Friendica\Core\L10n;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\Session\ISession;
use Friendica\Database\Database;
@ -41,7 +41,7 @@ class L10n
*/
private $logger;
public function __construct(Configuration $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get)
public function __construct(IConfiguration $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get)
{
$this->dba = $dba;
$this->logger = $logger;

View File

@ -7,14 +7,13 @@
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Lock\ILock;
use Friendica\DI;
/**
* This class contain Functions for preventing parallel execution of functions
*/
class Lock extends BaseObject
class Lock
{
/**
* @brief Acquires a lock for a given name
@ -28,7 +27,7 @@ class Lock extends BaseObject
*/
public static function acquire($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES)
{
return self::getClass(ILock::class)->acquireLock($key, $timeout, $ttl);
return DI::lock()->acquireLock($key, $timeout, $ttl);
}
/**
@ -37,12 +36,12 @@ class Lock extends BaseObject
* @param string $key Name of the lock
* @param bool $override Overrides the lock to get releases
*
* @return void
* @return bool
* @throws \Exception
*/
public static function release($key, $override = false)
{
return self::getClass(ILock::class)->releaseLock($key, $override);
return DI::lock()->releaseLock($key, $override);
}
/**
@ -52,6 +51,6 @@ class Lock extends BaseObject
*/
public static function releaseAll()
{
self::getClass(ILock::class)->releaseAll();
DI::lock()->releaseAll();
}
}

View File

@ -4,7 +4,7 @@
*/
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Util\Logger\WorkerLogger;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
@ -12,7 +12,7 @@ use Psr\Log\LogLevel;
/**
* @brief Logger functions
*/
class Logger extends BaseObject
class Logger
{
/**
* @see Logger::error()
@ -66,6 +66,18 @@ class Logger extends BaseObject
self::DATA => 'Data',
];
/**
* @return LoggerInterface
*/
private static function getWorker()
{
if (self::$type === self::TYPE_LOGGER) {
return DI::logger();
} else {
return DI::workerLogger();
}
}
/**
* Enable additional logging for worker usage
*
@ -76,7 +88,7 @@ class Logger extends BaseObject
public static function enableWorker(string $functionName)
{
self::$type = self::TYPE_WORKER;
self::getClass(self::$type)->setFunctionName($functionName);
self::getWorker()->setFunctionName($functionName);
}
/**
@ -100,7 +112,7 @@ class Logger extends BaseObject
*/
public static function emergency($message, $context = [])
{
self::getClass(self::$type)->emergency($message, $context);
self::getWorker()->emergency($message, $context);
}
/**
@ -118,7 +130,7 @@ class Logger extends BaseObject
*/
public static function alert($message, $context = [])
{
self::getClass(self::$type)->alert($message, $context);
self::getWorker()->alert($message, $context);
}
/**
@ -135,7 +147,7 @@ class Logger extends BaseObject
*/
public static function critical($message, $context = [])
{
self::getClass(self::$type)->critical($message, $context);
self::getWorker()->critical($message, $context);
}
/**
@ -151,7 +163,7 @@ class Logger extends BaseObject
*/
public static function error($message, $context = [])
{
self::getClass(self::$type)->error($message, $context);
self::getWorker()->error($message, $context);
}
/**
@ -169,7 +181,7 @@ class Logger extends BaseObject
*/
public static function warning($message, $context = [])
{
self::getClass(self::$type)->warning($message, $context);
self::getWorker()->warning($message, $context);
}
/**
@ -184,7 +196,7 @@ class Logger extends BaseObject
*/
public static function notice($message, $context = [])
{
self::getClass(self::$type)->notice($message, $context);
self::getWorker()->notice($message, $context);
}
/**
@ -201,7 +213,7 @@ class Logger extends BaseObject
*/
public static function info($message, $context = [])
{
self::getClass(self::$type)->info($message, $context);
self::getWorker()->info($message, $context);
}
/**
@ -216,7 +228,7 @@ class Logger extends BaseObject
*/
public static function debug($message, $context = [])
{
self::getClass(self::$type)->debug($message, $context);
self::getWorker()->debug($message, $context);
}
/**
@ -230,7 +242,7 @@ class Logger extends BaseObject
*/
public static function log($msg, $level = LogLevel::INFO)
{
self::getClass(self::$type)->log($level, $msg);
self::getWorker()->log($level, $msg);
}
/**
@ -245,6 +257,6 @@ class Logger extends BaseObject
*/
public static function devLog($msg, $level = LogLevel::DEBUG)
{
self::getClass('$devLogger')->log($level, $msg);
DI::devLogger()->log($level, $msg);
}
}

View File

@ -8,8 +8,7 @@
*/
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Config\PConfiguration;
use Friendica\DI;
/**
* @brief Management of user configuration storage
@ -18,7 +17,7 @@ use Friendica\Core\Config\PConfiguration;
* The PConfig::get() functions return boolean false for keys that are unset,
* and this could lead to subtle bugs.
*/
class PConfig extends BaseObject
class PConfig
{
/**
* @brief Loads all configuration values of a user's config family into a cached storage.
@ -30,7 +29,7 @@ class PConfig extends BaseObject
*/
public static function load(int $uid, string $cat)
{
self::getClass(PConfiguration::class)->load($uid, $cat);
DI::pConfig()->load($uid, $cat);
}
/**
@ -47,7 +46,7 @@ class PConfig extends BaseObject
*/
public static function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
{
return self::getClass(PConfiguration::class)->get($uid, $cat, $key, $default_value, $refresh);
return DI::pConfig()->get($uid, $cat, $key, $default_value, $refresh);
}
/**
@ -62,7 +61,7 @@ class PConfig extends BaseObject
*/
public static function set(int $uid, string $cat, string $key, $value)
{
return self::getClass(PConfiguration::class)->set($uid, $cat, $key, $value);
return DI::pConfig()->set($uid, $cat, $key, $value);
}
/**
@ -76,6 +75,6 @@ class PConfig extends BaseObject
*/
public static function delete(int $uid, string $cat, string $key)
{
return self::getClass(PConfiguration::class)->delete($uid, $cat, $key);
return DI::pConfig()->delete($uid, $cat, $key);
}
}

View File

@ -3,7 +3,7 @@
namespace Friendica\Core;
use Friendica\App;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Psr\Log\LoggerInterface;
/**
@ -28,7 +28,7 @@ final class Process
private $mode;
/**
* @var Configuration
* @var IConfiguration
*/
private $config;
@ -37,7 +37,7 @@ final class Process
*/
private $basePath;
public function __construct(LoggerInterface $logger, App\Mode $mode, Configuration $config, string $basepath)
public function __construct(LoggerInterface $logger, App\Mode $mode, IConfiguration $config, string $basepath)
{
$this->logger = $logger;
$this->mode = $mode;

View File

@ -6,14 +6,14 @@
namespace Friendica\Core;
use Exception;
use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Render\FriendicaSmarty;
use Friendica\Render\ITemplateEngine;
/**
* @brief This class handles Renderer related functions.
*/
class Renderer extends BaseObject
class Renderer
{
/**
* @brief An array of registered template engines ('name'=>'class name')
@ -61,10 +61,9 @@ class Renderer extends BaseObject
public static function replaceMacros($s, array $vars = [])
{
$stamp1 = microtime(true);
$a = self::getApp();
// pass $baseurl to all templates if it isn't set
$vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars);
$vars = array_merge(['$baseurl' => DI::baseUrl()->get()], $vars);
$t = self::getTemplateEngine();
@ -75,7 +74,7 @@ class Renderer extends BaseObject
exit();
}
$a->getProfiler()->saveTimestamp($stamp1, "rendering", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "rendering", System::callstack());
return $output;
}
@ -92,7 +91,7 @@ class Renderer extends BaseObject
public static function getMarkupTemplate($s, $root = '')
{
$stamp1 = microtime(true);
$a = self::getApp();
$a = DI::app();
$t = self::getTemplateEngine();
try {
@ -102,7 +101,7 @@ class Renderer extends BaseObject
exit();
}
$a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "file", System::callstack());
return $template;
}

View File

@ -2,8 +2,8 @@
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Network\HTTPException;
@ -20,7 +20,7 @@ use Friendica\Util\Strings;
* - Search in the local directory
* - Search in the global directory
*/
class Search extends BaseObject
class Search
{
const DEFAULT_DIRECTORY = 'https://dir.friendica.social';
@ -92,8 +92,7 @@ class Search extends BaseObject
*/
public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1)
{
$config = self::getApp()->getConfig();
$server = $config->get('system', 'directory', self::DEFAULT_DIRECTORY);
$server = DI::config()->get('system', 'directory', self::DEFAULT_DIRECTORY);
$searchUrl = $server . '/search';
@ -158,7 +157,7 @@ class Search extends BaseObject
*/
public static function getContactsFromLocalDirectory($search, $type = self::TYPE_ALL, $start = 0, $itemPage = 80)
{
$config = self::getApp()->getConfig();
$config = DI::config();
$diaspora = $config->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::DFRN;
$ostatus = !$config->get('system', 'ostatus_disabled') ? Protocol::OSTATUS : Protocol::DFRN;

View File

@ -5,9 +5,8 @@
*/
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Session\ISession;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Util\Strings;
@ -16,39 +15,39 @@ use Friendica\Util\Strings;
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Session extends BaseObject
class Session
{
public static $exists = false;
public static $expire = 180000;
public static function exists($name)
{
return self::getClass(ISession::class)->exists($name);
return DI::session()->exists($name);
}
public static function get($name, $defaults = null)
{
return self::getClass(ISession::class)->get($name, $defaults);
return DI::session()->get($name, $defaults);
}
public static function set($name, $value)
{
self::getClass(ISession::class)->set($name, $value);
DI::session()->set($name, $value);
}
public static function setMultiple(array $values)
{
self::getClass(ISession::class)->setMultiple($values);
DI::session()->setMultiple($values);
}
public static function remove($name)
{
self::getClass(ISession::class)->remove($name);
DI::session()->remove($name);
}
public static function clear()
{
self::getClass(ISession::class)->clear();
DI::session()->clear();
}
/**
@ -59,8 +58,7 @@ class Session extends BaseObject
*/
public static function getRemoteContactID($uid)
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();
if (empty($session->get('remote')[$uid])) {
return false;
@ -77,8 +75,7 @@ class Session extends BaseObject
*/
public static function getUserIDForVisitorContactID($cid)
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();
if (empty($session->get('remote'))) {
return false;
@ -94,8 +91,7 @@ class Session extends BaseObject
*/
public static function setVisitorsContacts()
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();
$session->set('remote', []);
@ -117,8 +113,7 @@ class Session extends BaseObject
*/
public static function isAuthenticated()
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();
return $session->get('authenticated', false);
}

View File

@ -4,8 +4,7 @@
*/
namespace Friendica\Core;
use Friendica\App\BaseURL;
use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\XML;
@ -19,18 +18,17 @@ use Friendica\Util\XML;
/**
* @brief System methods
*/
class System extends BaseObject
class System
{
/**
* @brief Retrieves the Friendica instance base URL
*
* @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN
* @return string Friendica server base URL
* @throws InternalServerErrorException
*/
public static function baseUrl($ssl = false)
{
return self::getClass(BaseURL::class)->get($ssl);
return DI::baseUrl()->get($ssl);
}
/**
@ -43,7 +41,7 @@ class System extends BaseObject
*/
public static function removedBaseUrl(string $orig_url)
{
return self::getApp()->removeBaseURL($orig_url);
return DI::baseUrl()->remove($orig_url);
}
/**
@ -184,7 +182,7 @@ class System extends BaseObject
if (is_bool($prefix) && !$prefix) {
$prefix = '';
} elseif (empty($prefix)) {
$prefix = hash('crc32', self::getApp()->getHostName());
$prefix = hash('crc32', DI::baseUrl()->getHostname());
}
while (strlen($prefix) < ($size - 13)) {

View File

@ -6,7 +6,7 @@
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Util\Strings;
@ -73,10 +73,9 @@ class Theme
return $info;
}
$a = \get_app();
$stamp1 = microtime(true);
$theme_file = file_get_contents("view/theme/$theme/theme.php");
$a->getProfiler()->saveTimestamp($stamp1, "file", System::callstack());
DI::profiler()->saveTimestamp($stamp1, "file", System::callstack());
$result = preg_match("|/\*.*\*/|msU", $theme_file, $matches);
@ -194,7 +193,7 @@ class Theme
*/
public static function getPathForFile($file)
{
$a = BaseObject::getApp();
$a = DI::app();
$theme = $a->getCurrentTheme();
@ -232,7 +231,7 @@ class Theme
return 'view/theme/' . $theme . '/style.css';
}
$a = BaseObject::getApp();
$a = DI::app();
$query_params = [];

View File

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\App;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\Strings;
@ -85,12 +86,11 @@ class UserImport
/**
* @brief Import account file exported from mod/uexport
*
* @param App $a Friendica App Class
* @param array $file array from $_FILES
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function importAccount(App $a, $file)
public static function importAccount($file)
{
Logger::log("Start user import from " . $file['tmp_name']);
/*
@ -282,6 +282,6 @@ class UserImport
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid);
info(L10n::t("Done. You can now login with your username and password"));
$a->internalRedirect('login');
DI::baseUrl()->redirect('login');
}
}

View File

@ -4,9 +4,9 @@
*/
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Process;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
@ -56,7 +56,7 @@ class Worker
self::$up_start = microtime(true);
// At first check the maximum load. We shouldn't continue with a high load
if ($a->isMaxLoadReached()) {
if (DI::process()->isMaxLoadReached()) {
Logger::log('Pre check: maximum load reached, quitting.', Logger::DEBUG);
return;
}
@ -78,7 +78,7 @@ class Worker
}
// Do we have too few memory?
if ($a->isMinMemoryReached()) {
if (DI::process()->isMinMemoryReached()) {
Logger::log('Pre check: Memory limit reached, quitting.', Logger::DEBUG);
return;
}
@ -90,7 +90,7 @@ class Worker
}
// Possibly there are too much database processes that block the system
if ($a->isMaxProcessesReached()) {
if (DI::process()->isMaxProcessesReached()) {
Logger::log('Pre check: maximum processes reached, quitting.', Logger::DEBUG);
return;
}
@ -140,7 +140,7 @@ class Worker
}
// Check free memory
if ($a->isMinMemoryReached()) {
if (DI::process()->isMinMemoryReached()) {
Logger::log('Memory limit reached, quitting.', Logger::DEBUG);
Lock::release('worker');
return;
@ -251,8 +251,6 @@ class Worker
*/
public static function execute($queue)
{
$a = \get_app();
$mypid = getmypid();
// Quit when in maintenance
@ -262,7 +260,7 @@ class Worker
}
// Constantly check the number of parallel database processes
if ($a->isMaxProcessesReached()) {
if (DI::process()->isMaxProcessesReached()) {
Logger::log("Max processes reached for process ".$mypid, Logger::DEBUG);
return false;
}
@ -386,7 +384,7 @@ class Worker
// We use the callstack here to analyze the performance of executed worker entries.
// For this reason the variables have to be initialized.
$a->getProfiler()->reset();
DI::profiler()->reset();
$a->queue = $queue;
@ -443,7 +441,7 @@ class Worker
Logger::info('Process done.', ['priority' => $queue["priority"], 'id' => $queue["id"], 'duration' => round($duration, 3)]);
$a->getProfiler()->saveLog($a->getLogger(), "ID " . $queue["id"] . ": " . $funcname);
DI::profiler()->saveLog(DI::logger(), "ID " . $queue["id"] . ": " . $funcname);
$cooldown = Config::get("system", "worker_cooldown", 0);
@ -1086,7 +1084,7 @@ class Worker
$args = ['no_cron' => !$do_cron];
$a = get_app();
$process = new Core\Process($a->getLogger(), $a->getMode(), $a->getConfig(), $a->getBasePath());
$process = new Core\Process(DI::logger(), DI::mode(), DI::config(), $a->getBasePath());
$process->run($command, $args);
// after spawning we have to remove the flag.
@ -1129,7 +1127,7 @@ class Worker
$priority = PRIORITY_MEDIUM;
// Don't fork from frontend tasks by default
$dont_fork = Config::get("system", "worker_dont_fork", false) || !\get_app()->getMode()->isBackend();
$dont_fork = Config::get("system", "worker_dont_fork", false) || !DI::mode()->isBackend();
$created = DateTimeFormat::utcNow();
$force_priority = false;
@ -1232,11 +1230,11 @@ class Worker
*/
public static function defer()
{
if (empty(BaseObject::getApp()->queue)) {
if (empty(DI::app()->queue)) {
return false;
}
$queue = BaseObject::getApp()->queue;
$queue = DI::app()->queue;
$retrial = $queue['retrial'];
$id = $queue['id'];

88
src/DI.php Normal file
View File

@ -0,0 +1,88 @@
<?php
namespace Friendica;
use Dice\Dice;
use Psr\Log\LoggerInterface;
/**
* 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()
* @method static App\Authentication auth()
* @method static App\Arguments args()
* @method static App\BaseURL baseUrl()
* @method static App\Mode mode()
* @method static App\Module module()
* @method static App\Page page()
* @method static App\Router router()
* @method static Content\Item contentItem()
* @method static Content\Text\BBCode\Video bbCodeVideo()
* @method static Core\Cache\ICache cache()
* @method static Core\Config\IConfiguration config()
* @method static Core\Config\IPConfiguration pConfig()
* @method static Core\Lock\ILock lock()
* @method static Core\L10n\L10n l10n()
* @method static Core\Process process()
* @method static Core\Session\ISession session()
* @method static Database\Database dba()
* @method static Model\Notify notify()
* @method static Model\Introduction intro()
* @method static Protocol\Activity activity()
* @method static Util\ACLFormatter aclFormatter()
* @method static Util\DateTimeFormat dtFormat()
* @method static Util\FileSystem fs()
* @method static Util\Profiler profiler()
* @method static LoggerInterface logger()
* @method static LoggerInterface devLogger()
* @method static LoggerInterface workerLogger()
*
*/
abstract class DI
{
const CLASS_MAPPING = [
'app' => App::class,
'auth' => App\Authentication::class,
'args' => App\Arguments::class,
'baseUrl' => App\BaseURL::class,
'mode' => App\Mode::class,
'module' => App\Module::class,
'page' => App\Page::class,
'router' => App\Router::class,
'contentItem' => Content\Item::class,
'bbCodeVideo' => Content\Text\BBCode\Video::class,
'cache' => Core\Cache\ICache::class,
'config' => Core\Config\IConfiguration::class,
'pConfig' => Core\Config\IPConfiguration::class,
'l10n' => Core\L10n\L10n::class,
'lock' => Core\Lock\ILock::class,
'process' => Core\Process::class,
'session' => Core\Session\ISession::class,
'dba' => Database\Database::class,
'notify' => Model\Notify::class,
'intro' => Model\Introduction::class,
'activity' => Protocol\Activity::class,
'aclFormatter' => Util\ACLFormatter::class,
'dtFormat' => Util\DateTimeFormat::class,
'fs' => Util\FileSystem::class,
'workerLogger' => Util\Logger\WorkerLogger::class,
'profiler' => Util\Profiler::class,
'logger' => LoggerInterface::class,
'devLogger' => '$devLogger',
];
/** @var Dice */
private static $dice;
public static function init(Dice $dice)
{
self::$dice = $dice;
}
public static function __callStatic($name, $arguments)
{
return self::$dice->create(self::CLASS_MAPPING[$name], $arguments);
}
}

View File

@ -2,7 +2,7 @@
namespace Friendica\Database;
use Friendica\BaseObject;
use Friendica\DI;
use mysqli;
use mysqli_result;
use mysqli_stmt;
@ -14,7 +14,7 @@ use PDOStatement;
*
* This class is for the low level database stuff that does driver specific things.
*/
class DBA extends BaseObject
class DBA
{
/**
* Lowest possible date value
@ -27,7 +27,7 @@ class DBA extends BaseObject
public static function connect()
{
return self::getClass(Database::class)->connect();
return DI::dba()->connect();
}
/**
@ -35,7 +35,7 @@ class DBA extends BaseObject
*/
public static function disconnect()
{
self::getClass(Database::class)->disconnect();
DI::dba()->disconnect();
}
/**
@ -43,7 +43,7 @@ class DBA extends BaseObject
*/
public static function reconnect()
{
return self::getClass(Database::class)->reconnect();
return DI::dba()->reconnect();
}
/**
@ -52,7 +52,7 @@ class DBA extends BaseObject
*/
public static function getConnection()
{
return self::getClass(Database::class)->getConnection();
return DI::dba()->getConnection();
}
/**
@ -65,7 +65,7 @@ class DBA extends BaseObject
*/
public static function serverInfo()
{
return self::getClass(Database::class)->serverInfo();
return DI::dba()->serverInfo();
}
/**
@ -76,17 +76,17 @@ class DBA extends BaseObject
*/
public static function databaseName()
{
return self::getClass(Database::class)->databaseName();
return DI::dba()->databaseName();
}
public static function escape($str)
{
return self::getClass(Database::class)->escape($str);
return DI::dba()->escape($str);
}
public static function connected()
{
return self::getClass(Database::class)->connected();
return DI::dba()->connected();
}
/**
@ -102,7 +102,7 @@ class DBA extends BaseObject
*/
public static function anyValueFallback($sql)
{
return self::getClass(Database::class)->anyValueFallback($sql);
return DI::dba()->anyValueFallback($sql);
}
/**
@ -158,7 +158,7 @@ class DBA extends BaseObject
{
$params = self::getParam(func_get_args());
return self::getClass(Database::class)->p($sql, $params);
return DI::dba()->p($sql, $params);
}
/**
@ -174,7 +174,7 @@ class DBA extends BaseObject
$params = self::getParam(func_get_args());
return self::getClass(Database::class)->e($sql, $params);
return DI::dba()->e($sql, $params);
}
/**
@ -188,7 +188,7 @@ class DBA extends BaseObject
*/
public static function exists($table, $condition)
{
return self::getClass(Database::class)->exists($table, $condition);
return DI::dba()->exists($table, $condition);
}
/**
@ -205,7 +205,7 @@ class DBA extends BaseObject
{
$params = self::getParam(func_get_args());
return self::getClass(Database::class)->fetchFirst($sql, $params);
return DI::dba()->fetchFirst($sql, $params);
}
/**
@ -215,7 +215,7 @@ class DBA extends BaseObject
*/
public static function affectedRows()
{
return self::getClass(Database::class)->affectedRows();
return DI::dba()->affectedRows();
}
/**
@ -226,7 +226,7 @@ class DBA extends BaseObject
*/
public static function columnCount($stmt)
{
return self::getClass(Database::class)->columnCount($stmt);
return DI::dba()->columnCount($stmt);
}
/**
* @brief Returns the number of rows of a statement
@ -236,7 +236,7 @@ class DBA extends BaseObject
*/
public static function numRows($stmt)
{
return self::getClass(Database::class)->numRows($stmt);
return DI::dba()->numRows($stmt);
}
/**
@ -247,7 +247,7 @@ class DBA extends BaseObject
*/
public static function fetch($stmt)
{
return self::getClass(Database::class)->fetch($stmt);
return DI::dba()->fetch($stmt);
}
/**
@ -262,7 +262,7 @@ class DBA extends BaseObject
*/
public static function insert($table, $param, $on_duplicate_update = false)
{
return self::getClass(Database::class)->insert($table, $param, $on_duplicate_update);
return DI::dba()->insert($table, $param, $on_duplicate_update);
}
/**
@ -272,7 +272,7 @@ class DBA extends BaseObject
*/
public static function lastInsertId()
{
return self::getClass(Database::class)->lastInsertId();
return DI::dba()->lastInsertId();
}
/**
@ -287,7 +287,7 @@ class DBA extends BaseObject
*/
public static function lock($table)
{
return self::getClass(Database::class)->lock($table);
return DI::dba()->lock($table);
}
/**
@ -298,7 +298,7 @@ class DBA extends BaseObject
*/
public static function unlock()
{
return self::getClass(Database::class)->unlock();
return DI::dba()->unlock();
}
/**
@ -308,7 +308,7 @@ class DBA extends BaseObject
*/
public static function transaction()
{
return self::getClass(Database::class)->transaction();
return DI::dba()->transaction();
}
/**
@ -318,7 +318,7 @@ class DBA extends BaseObject
*/
public static function commit()
{
return self::getClass(Database::class)->commit();
return DI::dba()->commit();
}
/**
@ -328,7 +328,7 @@ class DBA extends BaseObject
*/
public static function rollback()
{
return self::getClass(Database::class)->rollback();
return DI::dba()->rollback();
}
/**
@ -345,7 +345,7 @@ class DBA extends BaseObject
*/
public static function delete($table, array $conditions, array $options = [])
{
return self::getClass(Database::class)->delete($table, $conditions, $options);
return DI::dba()->delete($table, $conditions, $options);
}
/**
@ -379,7 +379,7 @@ class DBA extends BaseObject
*/
public static function update($table, $fields, $condition, $old_fields = [])
{
return self::getClass(Database::class)->update($table, $fields, $condition, $old_fields);
return DI::dba()->update($table, $fields, $condition, $old_fields);
}
/**
@ -396,7 +396,7 @@ class DBA extends BaseObject
*/
public static function selectFirst($table, array $fields = [], array $condition = [], $params = [])
{
return self::getClass(Database::class)->selectFirst($table, $fields, $condition, $params);
return DI::dba()->selectFirst($table, $fields, $condition, $params);
}
/**
@ -413,7 +413,7 @@ class DBA extends BaseObject
*/
public static function selectToArray($table, array $fields = [], array $condition = [], array $params = [])
{
return self::getClass(Database::class)->selectToArray($table, $fields, $condition, $params);
return DI::dba()->selectToArray($table, $fields, $condition, $params);
}
/**
@ -441,7 +441,7 @@ class DBA extends BaseObject
*/
public static function select($table, array $fields = [], array $condition = [], array $params = [])
{
return self::getClass(Database::class)->select($table, $fields, $condition, $params);
return DI::dba()->select($table, $fields, $condition, $params);
}
/**
@ -465,7 +465,7 @@ class DBA extends BaseObject
*/
public static function count($table, array $condition = [], array $params = [])
{
return self::getClass(Database::class)->count($table, $condition, $params);
return DI::dba()->count($table, $condition, $params);
}
/**
@ -639,7 +639,7 @@ class DBA extends BaseObject
*/
public static function toArray($stmt, $do_close = true)
{
return self::getClass(Database::class)->toArray($stmt, $do_close);
return DI::dba()->toArray($stmt, $do_close);
}
/**
@ -649,7 +649,7 @@ class DBA extends BaseObject
*/
public static function errorNo()
{
return self::getClass(Database::class)->errorNo();
return DI::dba()->errorNo();
}
/**
@ -659,7 +659,7 @@ class DBA extends BaseObject
*/
public static function errorMessage()
{
return self::getClass(Database::class)->errorMessage();
return DI::dba()->errorMessage();
}
/**
@ -670,7 +670,7 @@ class DBA extends BaseObject
*/
public static function close($stmt)
{
return self::getClass(Database::class)->close($stmt);
return DI::dba()->close($stmt);
}
/**
@ -683,7 +683,7 @@ class DBA extends BaseObject
*/
public static function processlist()
{
return self::getClass(Database::class)->processlist();
return DI::dba()->processlist();
}
/**
@ -695,7 +695,7 @@ class DBA extends BaseObject
*/
public static function isResult($array)
{
return self::getClass(Database::class)->isResult($array);
return DI::dba()->isResult($array);
}
/**
@ -707,6 +707,6 @@ class DBA extends BaseObject
*/
public static function escapeArray(&$arr, $add_quotation = false)
{
return self::getClass(Database::class)->escapeArray($arr, $add_quotation);
DI::dba()->escapeArray($arr, $add_quotation);
}
}

View File

@ -5,7 +5,7 @@ namespace Friendica\Factory;
use Friendica\App\BaseURL;
use Friendica\Core\Cache;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Database\Database;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
@ -25,7 +25,7 @@ class CacheFactory
const DEFAULT_TYPE = Cache\Cache::TYPE_DATABASE;
/**
* @var Configuration The configuration to read parameters out of the config
* @var IConfiguration The IConfiguration to read parameters out of the config
*/
private $config;
@ -49,7 +49,7 @@ class CacheFactory
*/
private $logger;
public function __construct(BaseURL $baseURL, Configuration $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
public function __construct(BaseURL $baseURL, IConfiguration $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
{
$this->hostname = $baseURL->getHostname();
$this->config = $config;

View File

@ -27,7 +27,7 @@ class ConfigFactory
* @param Cache\ConfigCache $configCache The config cache of this adapter
* @param ConfigModel $configModel The configuration model
*
* @return Config\Configuration
* @return Config\IConfiguration
*/
public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
{
@ -46,7 +46,7 @@ class ConfigFactory
* @param Cache\PConfigCache $pConfigCache The personal config cache
* @param PConfigModel $configModel The configuration model
*
* @return Config\PConfiguration
* @return Config\IPConfiguration
*/
public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel)
{

View File

@ -4,7 +4,7 @@ namespace Friendica\Factory;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Cache\IMemoryCache;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Lock;
use Friendica\Database\Database;
use Psr\Log\LoggerInterface;
@ -24,7 +24,7 @@ class LockFactory
const DEFAULT_DRIVER = 'default';
/**
* @var Configuration The configuration to read parameters out of the config
* @var IConfiguration The configuration to read parameters out of the config
*/
private $config;
@ -43,7 +43,7 @@ class LockFactory
*/
private $logger;
public function __construct(CacheFactory $cacheFactory, Configuration $config, Database $dba, LoggerInterface $logger)
public function __construct(CacheFactory $cacheFactory, IConfiguration $config, Database $dba, LoggerInterface $logger)
{
$this->cacheFactory = $cacheFactory;
$this->config = $config;

View File

@ -2,7 +2,7 @@
namespace Friendica\Factory;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Logger;
use Friendica\Database\Database;
use Friendica\Network\HTTPException\InternalServerErrorException;
@ -50,13 +50,13 @@ class LoggerFactory
* Creates a new PSR-3 compliant logger instances
*
* @param Database $database The Friendica Database instance
* @param Configuration $config The config
* @param IConfiguration $config The config
* @param Profiler $profiler The profiler of the app
* @param FileSystem $fileSystem FileSystem utils
*
* @return LoggerInterface The PSR-3 compliant logger instance
*/
public function create(Database $database, Configuration $config, Profiler $profiler, FileSystem $fileSystem)
public function create(Database $database, IConfiguration $config, Profiler $profiler, FileSystem $fileSystem)
{
if (empty($config->get('system', 'debugging', false))) {
$logger = new VoidLogger();
@ -137,7 +137,7 @@ class LoggerFactory
*
* It should never get filled during normal usage of Friendica
*
* @param Configuration $config The config
* @param IConfiguration $config The config
* @param Profiler $profiler The profiler of the app
* @param FileSystem $fileSystem FileSystem utils
*
@ -146,7 +146,7 @@ class LoggerFactory
* @throws InternalServerErrorException
* @throws \Exception
*/
public static function createDev(Configuration $config, Profiler $profiler, FileSystem $fileSystem)
public static function createDev(IConfiguration $config, Profiler $profiler, FileSystem $fileSystem)
{
$debugging = $config->get('system', 'debugging');
$stream = $config->get('system', 'dlogfile');

View File

@ -5,7 +5,7 @@ namespace Friendica\Factory;
use Friendica\App;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
@ -29,7 +29,8 @@ class SessionFactory
/**
* @param App\Mode $mode
* @param App\BaseURL $baseURL
* @param Configuration $config
* @param IConfiguration $config
* @param Cookie $cookie
* @param Database $dba
* @param ICache $cache
* @param LoggerInterface $logger
@ -37,7 +38,7 @@ class SessionFactory
*
* @return Session\ISession
*/
public function createSession(App\Mode $mode, App\BaseURL $baseURL, Configuration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
public function createSession(App\Mode $mode, App\BaseURL $baseURL, IConfiguration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
{
$stamp1 = microtime(true);
$session = null;

View File

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

View File

@ -6,7 +6,6 @@
namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Content\Text\HTML;
use Friendica\Core\Logger;
use Friendica\Core\Config;
@ -17,7 +16,7 @@ use Friendica\Util\JsonLD;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
class APContact extends BaseObject
class APContact
{
/**
* Resolves the profile url from the address by using webfinger

View File

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

View File

@ -5,7 +5,6 @@
namespace Friendica\Model;
use Friendica\App\BaseURL;
use Friendica\BaseObject;
use Friendica\Content\Pager;
use Friendica\Core\Config;
use Friendica\Core\Hook;
@ -16,8 +15,8 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\DFRN;
@ -32,7 +31,7 @@ use Friendica\Util\Strings;
/**
* @brief functions for interacting with a contact
*/
class Contact extends BaseObject
class Contact
{
/**
* @deprecated since version 2019.03
@ -1733,7 +1732,7 @@ class Contact extends BaseObject
*/
public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0)
{
$a = self::getApp();
$a = DI::app();
$cid = self::getIdForURL($contact_url);
@ -1758,7 +1757,7 @@ class Contact extends BaseObject
$cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
}
$pager = new Pager($a->query_string);
$pager = new Pager(DI::args()->getQueryString());
$params = ['order' => ['received' => true],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
@ -2267,13 +2266,13 @@ class Contact extends BaseObject
if (($protocol === Protocol::DFRN) && !DBA::isResult($contact)) {
if ($interactive) {
if (strlen($a->getURLPath())) {
if (strlen(DI::baseUrl()->getUrlPath())) {
$myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
} else {
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->getHostName());
$myaddr = bin2hex($a->user['nickname'] . '@' . DI::baseUrl()->getHostname());
}
$a->internalRedirect($ret['request'] . "&addr=$myaddr");
DI::baseUrl()->redirect($ret['request'] . "&addr=$myaddr");
// NOTREACHED
}

View File

@ -5,7 +5,6 @@
namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
@ -23,7 +22,7 @@ use Friendica\Util\XML;
/**
* @brief functions for interacting with the event database table
*/
class Event extends BaseObject
class Event
{
public static function getHTML(array $event, $simple = false)

View File

@ -6,7 +6,6 @@
namespace Friendica\Model;
use Friendica\BaseModule;
use Friendica\BaseObject;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
@ -16,7 +15,7 @@ use Friendica\Database\DBA;
/**
* @brief functions for interacting with the group database table
*/
class Group extends BaseObject
class Group
{
const FOLLOWERS = '~';
const MUTUALS = '&';

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