Merge pull request #10548 from annando/args

Replaced argv/argc with replacement functions
This commit is contained in:
Hypolite Petovan 2021-07-26 18:43:47 -04:00 committed by GitHub
commit 3cef3ab107
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 331 additions and 347 deletions

View file

@ -170,9 +170,8 @@ The content of this file should be something like
use Friendica\App;
function duepuntozero_lr_init(App $a) {
$a-> theme_info = array(
'extends' => 'duepuntozero'.
);
$a->setThemeInfoValue('extends', 'duepuntozero');
$a->set_template_engine('smarty3');
/* and more stuff e.g. the JavaScript function for the header */
}
@ -272,9 +271,7 @@ If you like to use another templating engine, please implement it.
When you want to inherit stuff from another theme you have to *announce* this in the theme_info:
$a->theme_info = array(
'extends' => 'duepuntozero',
);
$a->setThemeInfoValue('extends', 'duepuntozero');
which declares *duepuntozero* as parent of the theme.

View file

@ -545,10 +545,10 @@ function api_get_user(App $a, $contact_id = null)
}
// $called_api is the API path exploded on / and is expected to have at least 2 elements
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
if (is_null($user) && (DI::args()->getArgc() > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api);
if (!empty($a->argv[$argid])) {
$data = explode(".", $a->argv[$argid]);
if (!empty(DI::args()->getArgv()[$argid])) {
$data = explode(".", DI::args()->getArgv()[$argid]);
if (count($data) > 1) {
list($user, $null) = $data;
}
@ -1021,7 +1021,7 @@ function api_statuses_mediap($type)
}
$txt = HTML::toBBCode($txt);
$a->argv[1] = $user_info['screen_name']; //should be set to username?
DI::args()->getArgv()[1] = $user_info['screen_name']; //should be set to username?
$picture = wall_upload_post($a, false);
@ -1883,7 +1883,7 @@ function api_statuses_show($type)
}
// params
$id = intval($a->argv[3] ?? 0);
$id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0);
@ -1891,7 +1891,7 @@ function api_statuses_show($type)
// Hotot workaround
if ($id == 0) {
$id = intval($a->argv[4] ?? 0);
$id = intval(DI::args()->getArgv()[4] ?? 0);
}
Logger::log('API: api_statuses_show: ' . $id);
@ -1962,7 +1962,7 @@ function api_conversation_show($type)
}
// params
$id = intval($a->argv[3] ?? 0);
$id = intval(DI::args()->getArgv()[3] ?? 0);
$since_id = intval($_REQUEST['since_id'] ?? 0);
$max_id = intval($_REQUEST['max_id'] ?? 0);
$count = intval($_REQUEST['count'] ?? 20);
@ -1976,7 +1976,7 @@ function api_conversation_show($type)
// Hotot workaround
if ($id == 0) {
$id = intval($a->argv[4] ?? 0);
$id = intval(DI::args()->getArgv()[4] ?? 0);
}
Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
@ -2045,7 +2045,7 @@ function api_statuses_repeat($type)
api_get_user($a);
// params
$id = intval($a->argv[3] ?? 0);
$id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0);
@ -2053,7 +2053,7 @@ function api_statuses_repeat($type)
// Hotot workaround
if ($id == 0) {
$id = intval($a->argv[4] ?? 0);
$id = intval(DI::args()->getArgv()[4] ?? 0);
}
Logger::log('API: api_statuses_repeat: '.$id);
@ -2128,7 +2128,7 @@ function api_statuses_destroy($type)
api_get_user($a);
// params
$id = intval($a->argv[3] ?? 0);
$id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0);
@ -2136,7 +2136,7 @@ function api_statuses_destroy($type)
// Hotot workaround
if ($id == 0) {
$id = intval($a->argv[4] ?? 0);
$id = intval(DI::args()->getArgv()[4] ?? 0);
}
Logger::log('API: api_statuses_destroy: '.$id);
@ -2329,16 +2329,16 @@ function api_favorites_create_destroy($type)
// for versioned api.
/// @TODO We need a better global soluton
$action_argv_id = 2;
if (count($a->argv) > 1 && $a->argv[1] == "1.1") {
if (count(DI::args()->getArgv()) > 1 && DI::args()->getArgv()[1] == "1.1") {
$action_argv_id = 3;
}
if ($a->argc <= $action_argv_id) {
if (DI::args()->getArgc() <= $action_argv_id) {
throw new BadRequestException("Invalid request.");
}
$action = str_replace("." . $type, "", $a->argv[$action_argv_id]);
if ($a->argc == $action_argv_id + 2) {
$itemid = intval($a->argv[$action_argv_id + 1] ?? 0);
$action = str_replace("." . $type, "", DI::args()->getArgv()[$action_argv_id]);
if (DI::args()->getArgc() == $action_argv_id + 2) {
$itemid = intval(DI::args()->getArgv()[$action_argv_id + 1] ?? 0);
} else {
$itemid = intval($_REQUEST['id'] ?? 0);
}
@ -5616,7 +5616,7 @@ function api_friendica_activity($type)
if (api_user() === false) {
throw new ForbiddenException();
}
$verb = strtolower($a->argv[3]);
$verb = strtolower(DI::args()->getArgv()[3]);
$verb = preg_replace("|\..*$|", "", $verb);
$id = $_REQUEST['id'] ?? 0;
@ -5664,7 +5664,7 @@ function api_friendica_notification($type)
if (api_user() === false) {
throw new ForbiddenException();
}
if ($a->argc!==3) {
if (DI::args()->getArgc()!==3) {
throw new BadRequestException("Invalid argument count");
}
@ -5709,7 +5709,7 @@ function api_friendica_notification_seen($type)
if (api_user() === false || $user_info === false) {
throw new ForbiddenException();
}
if ($a->argc !== 4) {
if (DI::args()->getArgc() !== 4) {
throw new BadRequestException("Invalid argument count");
}

View file

@ -44,7 +44,7 @@ function cal_init(App $a)
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
if ($a->argc < 2) {
if (DI::args()->getArgc() < 2) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
@ -52,11 +52,11 @@ function cal_init(App $a)
// if it's a json request abort here becaus we don't
// need the widget data
if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) {
if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
return;
}
$owner = User::getOwnerDataByNick($a->argv[1]);
$owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
@ -73,7 +73,7 @@ function cal_init(App $a)
function cal_content(App $a)
{
$owner = User::getOwnerDataByNick($a->argv[1]);
$owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
@ -101,9 +101,9 @@ function cal_content(App $a)
$ignored = (!empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0);
$format = 'ical';
if ($a->argc == 4 && $a->argv[2] == 'export') {
if (DI::args()->getArgc() == 4 && DI::args()->getArgv()[2] == 'export') {
$mode = 'export';
$format = $a->argv[3];
$format = DI::args()->getArgv()[3];
}
// Setup permissions structures
@ -172,7 +172,7 @@ function cal_content(App $a)
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) {
if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
if (!empty($_GET['start'])) {
$start = $_GET['start'];
}
@ -220,7 +220,7 @@ function cal_content(App $a)
// transform the event in a usable array
$events = Event::prepareListForTemplate($r);
if (!empty($a->argv[2]) && ($a->argv[2] === 'json')) {
if (!empty(DI::args()->getArgv()[2]) && (DI::args()->getArgv()[2] === 'json')) {
echo json_encode($events);
exit();
}

View file

@ -37,19 +37,18 @@ use Friendica\Module\ActivityPub\Objects;
use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\DFRN;
use Friendica\Util\Strings;
function display_init(App $a)
{
if (ActivityPub::isRequest()) {
Objects::rawContent(['guid' => $a->argv[1] ?? null]);
Objects::rawContent(['guid' => DI::args()->getArgv()[1] ?? null]);
}
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
$nick = (($a->argc > 1) ? $a->argv[1] : '');
$nick = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
$item = null;
$item_user = local_user();
@ -57,12 +56,12 @@ function display_init(App $a)
$fields = ['uri-id', 'parent-uri-id', 'author-id', 'author-link', 'body', 'uid', 'guid', 'gravity'];
// If there is only one parameter, then check if this parameter could be a guid
if ($a->argc == 2) {
if (DI::args()->getArgc() == 2) {
$nick = '';
// Does the local user have this item?
if (local_user()) {
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]);
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => DI::args()->getArgv()[1], 'uid' => local_user()]);
if (DBA::isResult($item)) {
$nick = $a->user['nickname'];
}
@ -70,7 +69,7 @@ function display_init(App $a)
// Is this item private but could be visible to the remove visitor?
if (!DBA::isResult($item) && remote_user()) {
$item = Post::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]);
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item)) {
if (!Contact::isFollower(remote_user(), $item['uid'])) {
$item = null;
@ -82,10 +81,10 @@ function display_init(App $a)
// Is it an item with uid=0?
if (!DBA::isResult($item)) {
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => DI::args()->getArgv()[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
}
} elseif ($a->argc >= 3 && $nick == 'feed-item') {
$uri_id = $a->argv[2];
} elseif (DI::args()->getArgc() >= 3 && $nick == 'feed-item') {
$uri_id = DI::args()->getArgv()[2];
if (substr($uri_id, -5) == '.atom') {
$uri_id = substr($uri_id, 0, -5);
}
@ -96,8 +95,8 @@ function display_init(App $a)
return;
}
if ($a->argc >= 3 && $nick == 'feed-item') {
displayShowFeed($item['uri-id'], $item['uid'], $a->argc > 3 && $a->argv[3] == 'conversation.atom');
if (DI::args()->getArgc() >= 3 && $nick == 'feed-item') {
displayShowFeed($item['uri-id'], $item['uid'], DI::args()->getArgc() > 3 && DI::args()->getArgv()[3] == 'conversation.atom');
}
if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
@ -185,14 +184,14 @@ function display_content(App $a, $update = false, $update_uid = 0)
$parent_uri_id = $item['parent-uri-id'];
}
} else {
$uri_id = (($a->argc > 2) ? $a->argv[2] : 0);
$uri_id = ((DI::args()->getArgc() > 2) ? DI::args()->getArgv()[2] : 0);
$parent_uri_id = $uri_id;
if ($a->argc == 2) {
if (DI::args()->getArgc() == 2) {
$fields = ['uri-id', 'parent-uri-id', 'uid'];
if (local_user()) {
$condition = ['guid' => $a->argv[1], 'uid' => local_user()];
$condition = ['guid' => DI::args()->getArgv()[1], 'uid' => local_user()];
$item = Post::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
$uri_id = $item['uri-id'];
@ -201,7 +200,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
}
if (($parent_uri_id == 0) && remote_user()) {
$item = Post::selectFirst($fields, ['guid' => $a->argv[1], 'private' => Item::PRIVATE, 'origin' => true]);
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) {
$uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id'];
@ -209,7 +208,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
}
if ($parent_uri_id == 0) {
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $a->argv[1], 'uid' => 0];
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => DI::args()->getArgv()[1], 'uid' => 0];
$item = Post::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) {
$uri_id = $item['uri-id'];

View file

@ -38,7 +38,7 @@ function editpost_content(App $a)
return;
}
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
$post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0);
if (!$post_id) {
notice(DI::l10n()->t('Item not found'));

View file

@ -51,7 +51,7 @@ function events_init(App $a)
// If it's a json request abort here because we don't
// need the widget data
if ($a->argc > 1 && $a->argv[1] === 'json') {
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] === 'json') {
return;
}
@ -237,25 +237,25 @@ function events_content(App $a)
return Login::form();
}
if ($a->argc == 1) {
if (DI::args()->getArgc() == 1) {
$_SESSION['return_path'] = DI::args()->getCommand();
}
if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'ignore') && intval(DI::args()->getArgv()[2])) {
q("UPDATE `event` SET `ignore` = 1 WHERE `id` = %d AND `uid` = %d",
intval($a->argv[2]),
intval(DI::args()->getArgv()[2]),
intval(local_user())
);
}
if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'unignore') && intval(DI::args()->getArgv()[2])) {
q("UPDATE `event` SET `ignore` = 0 WHERE `id` = %d AND `uid` = %d",
intval($a->argv[2]),
intval(DI::args()->getArgv()[2]),
intval(local_user())
);
}
if ($a->theme_events_in_profile) {
if ($a->getThemeInfoValue('events_in_profile')) {
Nav::setSelected('home');
} else {
Nav::setSelected('events');
@ -279,7 +279,7 @@ function events_content(App $a)
$o = '';
$tabs = '';
// tabs
if ($a->theme_events_in_profile) {
if ($a->getThemeInfoValue('events_in_profile')) {
$tabs = BaseProfile::getTabsHTML($a, 'events', true, $a->user);
}
@ -288,27 +288,27 @@ function events_content(App $a)
$m = 0;
$ignored = !empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0;
if ($a->argc > 1) {
if ($a->argc > 2 && $a->argv[1] == 'event') {
if (DI::args()->getArgc() > 1) {
if (DI::args()->getArgc() > 2 && DI::args()->getArgv()[1] == 'event') {
$mode = 'edit';
$event_id = intval($a->argv[2]);
$event_id = intval(DI::args()->getArgv()[2]);
}
if ($a->argc > 2 && $a->argv[1] == 'drop') {
if (DI::args()->getArgc() > 2 && DI::args()->getArgv()[1] == 'drop') {
$mode = 'drop';
$event_id = intval($a->argv[2]);
$event_id = intval(DI::args()->getArgv()[2]);
}
if ($a->argc > 2 && $a->argv[1] == 'copy') {
if (DI::args()->getArgc() > 2 && DI::args()->getArgv()[1] == 'copy') {
$mode = 'copy';
$event_id = intval($a->argv[2]);
$event_id = intval(DI::args()->getArgv()[2]);
}
if ($a->argv[1] === 'new') {
if (DI::args()->getArgv()[1] === 'new') {
$mode = 'new';
$event_id = 0;
}
if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
if (DI::args()->getArgc() > 2 && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
$mode = 'view';
$y = intval($a->argv[1]);
$m = intval($a->argv[2]);
$y = intval(DI::args()->getArgv()[1]);
$m = intval(DI::args()->getArgv()[2]);
}
}
@ -337,7 +337,7 @@ function events_content(App $a)
$start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
if ($a->argc > 1 && $a->argv[1] === 'json') {
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] === 'json') {
if (!empty($_GET['start'])) {
$start = $_GET['start'];
}
@ -389,7 +389,7 @@ function events_content(App $a)
$events = Event::prepareListForTemplate($r);
}
if ($a->argc > 1 && $a->argv[1] === 'json') {
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] === 'json') {
header('Content-Type: application/json');
echo json_encode($events);
exit();

View file

@ -24,7 +24,7 @@ function fbrowser_content(App $a)
exit();
}
if ($a->argc == 1) {
if (DI::args()->getArgc() == 1) {
exit();
}
@ -38,14 +38,14 @@ function fbrowser_content(App $a)
$o = '';
switch ($a->argv[1]) {
switch (DI::args()->getArgv()[1]) {
case "image":
$path = ['' => DI::l10n()->t('Photos')];
$albums = false;
$sql_extra = "";
$sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
if ($a->argc==2) {
if (DI::args()->getArgc()==2) {
$photos = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' ",
intval(local_user()),
DBA::escape(Photo::CONTACT_PHOTOS),
@ -55,8 +55,8 @@ function fbrowser_content(App $a)
$albums = array_column($photos, 'album');
}
if ($a->argc == 3) {
$album = $a->argv[2];
if (DI::args()->getArgc() == 3) {
$album = DI::args()->getArgv()[2];
$sql_extra = sprintf("AND `album` = '%s' ", DBA::escape($album));
$sql_extra2 = "";
$path[$album] = $album;
@ -109,7 +109,7 @@ function fbrowser_content(App $a)
break;
case "file":
if ($a->argc==2) {
if (DI::args()->getArgc()==2) {
$files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ",
intval(local_user())
);

View file

@ -92,8 +92,8 @@ function lostpass_post(App $a)
function lostpass_content(App $a)
{
if ($a->argc > 1) {
$pwdreset_token = $a->argv[1];
if (DI::args()->getArgc() > 1) {
$pwdreset_token = DI::args()->getArgv()[1];
$user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'email', 'pwdreset_time', 'language'], ['pwdreset' => hash('sha256', $pwdreset_token)]);
if (!DBA::isResult($user)) {

View file

@ -38,14 +38,14 @@ function message_init(App $a)
{
$tabs = '';
if ($a->argc > 1 && is_numeric($a->argv[1])) {
if (DI::args()->getArgc() > 1 && is_numeric(DI::args()->getArgv()[1])) {
$tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl');
}
$new = [
'label' => DI::l10n()->t('New Message'),
'url' => 'message/new',
'sel' => $a->argc > 1 && $a->argv[1] == 'new',
'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
'accesskey' => 'm',
];
@ -96,8 +96,7 @@ function message_post(App $a)
// fake it to go back to the input form if no recipient listed
if ($norecip) {
$a->argc = 2;
$a->argv[1] = 'new';
DI::args()->setArgv(['message', 'new']);
} else {
DI::baseUrl()->redirect(DI::args()->getCommand() . '/' . $ret);
}
@ -116,7 +115,7 @@ function message_content(App $a)
$myprofile = DI::baseUrl() . '/profile/' . $a->user['nickname'];
$tpl = Renderer::getMarkupTemplate('mail_head.tpl');
if ($a->argc > 1 && $a->argv[1] == 'new') {
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') {
$button = [
'label' => DI::l10n()->t('Discard'),
'url' => '/message',
@ -135,20 +134,20 @@ function message_content(App $a)
'$button' => $button,
]);
if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
if (!intval($a->argv[2])) {
if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop' || DI::args()->getArgv()[1] === 'dropconv')) {
if (!intval(DI::args()->getArgv()[2])) {
return;
}
$cmd = $a->argv[1];
$cmd = DI::args()->getArgv()[1];
if ($cmd === 'drop') {
$message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]);
$message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
if(!DBA::isResult($message)){
notice(DI::l10n()->t('Conversation not found.'));
DI::baseUrl()->redirect('message');
}
if (!DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => local_user()])) {
notice(DI::l10n()->t('Message was not deleted.'));
}
@ -160,7 +159,7 @@ function message_content(App $a)
DI::baseUrl()->redirect('message/' . $conversation['id'] );
} else {
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]),
intval(DI::args()->getArgv()[2]),
intval(local_user())
);
if (DBA::isResult($r)) {
@ -174,7 +173,7 @@ function message_content(App $a)
}
}
if (($a->argc > 1) && ($a->argv[1] === 'new')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'new')) {
$o .= $header;
$tpl = Renderer::getMarkupTemplate('msg-header.tpl');
@ -184,7 +183,7 @@ function message_content(App $a)
'$linkurl' => DI::l10n()->t('Please enter a link URL:')
]);
$recipientId = $a->argv[2] ?? null;
$recipientId = DI::args()->getArgv()[2] ?? null;
$select = ACL::getMessageContactSelectHTML($recipientId);
@ -210,7 +209,7 @@ function message_content(App $a)
$_SESSION['return_path'] = DI::args()->getQueryString();
if ($a->argc == 1) {
if (DI::args()->getArgc() == 1) {
// List messages
@ -241,7 +240,7 @@ function message_content(App $a)
return $o;
}
if (($a->argc > 1) && (intval($a->argv[1]))) {
if ((DI::args()->getArgc() > 1) && (intval(DI::args()->getArgv()[1]))) {
$o .= $header;
@ -252,7 +251,7 @@ function message_content(App $a)
WHERE `mail`.`uid` = ? AND `mail`.`id` = ?
LIMIT 1",
local_user(),
$a->argv[1]
DI::args()->getArgv()[1]
);
if (DBA::isResult($message)) {
$contact_id = $message['contact-id'];
@ -345,7 +344,7 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('mail_display.tpl');
$o = Renderer::replaceMacros($tpl, [
'$thread_id' => $a->argv[1],
'$thread_id' => DI::args()->getArgv()[1],
'$thread_subject' => $message['title'],
'$thread_seen' => $seen,
'$delete' => DI::l10n()->t('Delete conversation'),

View file

@ -23,11 +23,10 @@ use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Util\Strings;
function oexchange_init(App $a) {
if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'xrd')) {
$tpl = Renderer::getMarkupTemplate('oexchange_xrd.tpl');
$o = Renderer::replaceMacros($tpl, ['$base' => DI::baseUrl()]);
@ -43,7 +42,7 @@ function oexchange_content(App $a) {
return $o;
}
if (($a->argc > 1) && $a->argv[1] === 'done') {
if ((DI::args()->getArgc() > 1) && DI::args()->getArgv()[1] === 'done') {
return;
}

View file

@ -62,8 +62,8 @@ function photos_init(App $a) {
Nav::setSelected('home');
if ($a->argc > 1) {
$owner = User::getOwnerDataByNick($a->argv[1]);
if (DI::args()->getArgc() > 1) {
$owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
$is_owner = (local_user() && (local_user() == $owner['uid']));
@ -134,7 +134,7 @@ function photos_init(App $a) {
function photos_post(App $a)
{
$user = User::getByNickname($a->argv[1]);
$user = User::getByNickname(DI::args()->getArgv()[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
@ -185,11 +185,11 @@ function photos_post(App $a)
$str_contact_allow .= $aclFormatter->toString(Contact::getPublicIdByUserId($page_owner_uid));
}
if ($a->argc > 3 && $a->argv[2] === 'album') {
if (!Strings::isHex($a->argv[3])) {
if (DI::args()->getArgc() > 3 && DI::args()->getArgv()[2] === 'album') {
if (!Strings::isHex(DI::args()->getArgv()[3])) {
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
}
$album = hex2bin($a->argv[3]);
$album = hex2bin(DI::args()->getArgv()[3]);
if ($album === DI::l10n()->t('Profile Photos') || $album === Photo::CONTACT_PHOTOS || $album === DI::l10n()->t(Photo::CONTACT_PHOTOS)) {
DI::baseUrl()->redirect($_SESSION['photo_return']);
@ -209,7 +209,7 @@ function photos_post(App $a)
// Check if the user has responded to a delete confirmation query
if (!empty($_REQUEST['canceled'])) {
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album/' . $a->argv[3]);
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album/' . DI::args()->getArgv()[3]);
}
// RENAME photo album
@ -269,19 +269,19 @@ function photos_post(App $a)
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
}
if ($a->argc > 3 && $a->argv[2] === 'image') {
if (DI::args()->getArgc() > 3 && DI::args()->getArgv()[2] === 'image') {
// Check if the user has responded to a delete confirmation query for a single photo
if (!empty($_POST['canceled'])) {
DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]);
}
if (!empty($_POST['delete'])) {
// same as above but remove single photo
if ($visitor) {
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => $a->argv[3]];
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]];
} else {
$condition = ['uid' => local_user(), 'resource-id' => $a->argv[3]];
$condition = ['uid' => local_user(), 'resource-id' => DI::args()->getArgv()[3]];
}
$photo = DBA::selectFirst('photo', ['resource-id'], $condition);
@ -295,22 +295,22 @@ function photos_post(App $a)
Photo::clearAlbumCache($page_owner_uid);
} else {
notice(DI::l10n()->t('Failed to delete the photo.'));
DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]);
}
DI::baseUrl()->redirect('photos/' . $a->argv[1]);
DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1]);
return; // NOTREACHED
}
}
if ($a->argc > 2 && (!empty($_POST['desc']) || !empty($_POST['newtag']) || isset($_POST['albname']))) {
if (DI::args()->getArgc() > 2 && (!empty($_POST['desc']) || !empty($_POST['newtag']) || isset($_POST['albname']))) {
$desc = !empty($_POST['desc']) ? Strings::escapeTags(trim($_POST['desc'])) : '';
$rawtags = !empty($_POST['newtag']) ? Strings::escapeTags(trim($_POST['newtag'])) : '';
$item_id = !empty($_POST['item_id']) ? intval($_POST['item_id']) : 0;
$albname = !empty($_POST['albname']) ? trim($_POST['albname']) : '';
$origaname = !empty($_POST['origaname']) ? Strings::escapeTags(trim($_POST['origaname'])) : '';
$resource_id = $a->argv[3];
$resource_id = DI::args()->getArgv()[3];
if (!strlen($albname)) {
$albname = DateTimeFormat::localNow('Y');
@ -815,7 +815,7 @@ function photos_content(App $a)
// photos/name/image/xxxxx/edit
// photos/name/image/xxxxx/drop
$user = User::getByNickname($a->argv[1]);
$user = User::getByNickname(DI::args()->getArgv()[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
@ -836,17 +836,17 @@ function photos_content(App $a)
// Parse arguments
$datum = null;
if ($a->argc > 3) {
$datatype = $a->argv[2];
$datum = $a->argv[3];
} elseif (($a->argc > 2) && ($a->argv[2] === 'upload')) {
if (DI::args()->getArgc() > 3) {
$datatype = DI::args()->getArgv()[2];
$datum = DI::args()->getArgv()[3];
} elseif ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[2] === 'upload')) {
$datatype = 'upload';
} else {
$datatype = 'summary';
}
if ($a->argc > 4) {
$cmd = $a->argv[4];
if (DI::args()->getArgc() > 4) {
$cmd = DI::args()->getArgv()[4];
} else {
$cmd = 'view';
}

View file

@ -35,7 +35,7 @@ function poco_init(App $a) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
if ($a->argc > 1) {
if (DI::args()->getArgc() > 1) {
// Only the system mode is supported
throw new \Friendica\Network\HTTPException\NotFoundException();
}

View file

@ -50,8 +50,8 @@ function hub_post_return()
function pubsub_init(App $a)
{
$nick = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 );
$nick = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
$contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 );
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$hub_mode = Strings::escapeTags(trim($_GET['hub_mode'] ?? ''));
@ -110,8 +110,8 @@ function pubsub_post(App $a)
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])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 );
$nick = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
$contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 );
$importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($importer)) {

View file

@ -66,9 +66,9 @@ function pubsubhubbub_init(App $a) {
Logger::log("$hub_mode request from " . $_SERVER['REMOTE_ADDR']);
if ($a->argc > 1) {
if (DI::args()->getArgc() > 1) {
// Normally the url should now contain the nick name as last part of the url
$nick = $a->argv[1];
$nick = DI::args()->getArgv()[1];
} else {
// Get the nick name from the topic as a fallback
$nick = $hub_topic;

View file

@ -35,10 +35,9 @@ function redir_init(App $a) {
}
$url = $_GET['url'] ?? '';
$quiet = !empty($_GET['quiet']) ? '&quiet=1' : '';
if ($a->argc > 1 && intval($a->argv[1])) {
$cid = intval($a->argv[1]);
if (DI::args()->getArgc() > 1 && intval(DI::args()->getArgv()[1])) {
$cid = intval(DI::args()->getArgv()[1]);
} else {
$cid = 0;
}

View file

@ -42,7 +42,7 @@ function salmon_post(App $a, $xml = '') {
Logger::log('new salmon ' . $xml, Logger::DATA);
$nick = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : '');
$nick = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
$importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (! DBA::isResult($importer)) {

View file

@ -66,14 +66,14 @@ function settings_post(App $a)
return;
}
if (($a->argc > 1) && ($a->argv[1] == 'addon')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'addon')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/addon', 'settings_addon');
Hook::callAll('addon_settings_post', $_POST);
return;
}
if (($a->argc > 1) && ($a->argv[1] == 'connectors')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'connectors')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/connectors', 'settings_connectors');
if (!empty($_POST['general-submit'])) {
@ -150,7 +150,7 @@ function settings_post(App $a)
return;
}
if (($a->argc > 1) && ($a->argv[1] === 'features')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'features')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features');
foreach ($_POST as $k => $v) {
if (strpos($k, 'feature_') === 0) {
@ -418,11 +418,11 @@ function settings_content(App $a)
return;
}
if (($a->argc > 1) && ($a->argv[1] === 'oauth')) {
if (($a->argc > 3) && ($a->argv[2] === 'delete')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'oauth')) {
if ((DI::args()->getArgc() > 3) && (DI::args()->getArgv()[2] === 'delete')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't');
DBA::delete('application-token', ['application-id' => $a->argv[3], 'uid' => local_user()]);
DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => local_user()]);
DI::baseUrl()->redirect('settings/oauth/', true);
return;
}
@ -443,7 +443,7 @@ function settings_content(App $a)
return $o;
}
if (($a->argc > 1) && ($a->argv[1] === 'addon')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'addon')) {
$addon_settings_forms = [];
foreach (DI::dba()->selectToArray('hook', ['file', 'function'], ['hook' => 'addon_settings']) as $hook) {
@ -462,7 +462,7 @@ function settings_content(App $a)
return $o;
}
if (($a->argc > 1) && ($a->argv[1] === 'features')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'features')) {
$arr = [];
$features = Feature::get();
@ -484,7 +484,7 @@ function settings_content(App $a)
return $o;
}
if (($a->argc > 1) && ($a->argv[1] === 'connectors')) {
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors')) {
$accept_only_sharer = intval(DI::pConfig()->get(local_user(), 'system', 'accept_only_sharer'));
$disable_cw = intval(DI::pConfig()->get(local_user(), 'system', 'disable_cw'));
$no_intelligent_shortening = intval(DI::pConfig()->get(local_user(), 'system', 'no_intelligent_shortening'));

View file

@ -22,11 +22,12 @@
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
function share_init(App $a) {
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
$post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0);
if (!$post_id || !local_user()) {
exit();

View file

@ -49,7 +49,7 @@ function tagger_content(App $a) {
return;
}
$item_id = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : 0);
$item_id = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : 0);
Logger::log('tagger: tag ' . $term . ' item ' . $item_id);

View file

@ -88,12 +88,12 @@ function tagrm_content(App $a)
// NOTREACHED
}
if ($a->argc == 3) {
update_tags($a->argv[1], [Strings::escapeTags(trim(hex2bin($a->argv[2])))]);
if (DI::args()->getArgc()== 3) {
update_tags(DI::args()->getArgv()[1], [Strings::escapeTags(trim(hex2bin(DI::args()->getArgv()[2])))]);
DI::baseUrl()->redirect($photo_return);
}
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
$item_id = ((DI::args()->getArgc()> 1) ? intval(DI::args()->getArgv()[1]) : 0);
if (!$item_id) {
DI::baseUrl()->redirect($photo_return);
// NOTREACHED

View file

@ -29,14 +29,14 @@ use Friendica\Module\Contact;
function update_contact_content(App $a)
{
if (!empty($a->argv[1]) && (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update'))) {
if (!empty(DI::args()->getArgv()[1]) && (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update'))) {
if (!empty($_GET['item'])) {
$item = Post::selectFirst(['parent'], ['id' => $_GET['item']]);
$parentid = $item['parent'] ?? 0;
} else {
$parentid = 0;
}
$text = Contact::getConversationsHMTL($a, $a->argv[1], true, $parentid);
$text = Contact::getConversationsHMTL($a, DI::args()->getArgv()[1], true, $parentid);
} else {
$text = '';
}

View file

@ -42,8 +42,8 @@ function videos_init(App $a)
Nav::setSelected('home');
if ($a->argc > 1) {
$owner = User::getOwnerDataByNick($a->argv[1]);
if (DI::args()->getArgc() > 1) {
$owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
@ -64,7 +64,7 @@ function videos_init(App $a)
function videos_post(App $a)
{
$user = User::getByNickname($a->argv[1]);
$user = User::getByNickname(DI::args()->getArgv()[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
@ -73,7 +73,7 @@ function videos_post(App $a)
DI::baseUrl()->redirect('videos/' . $user['nickname']);
}
if (($a->argc == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
if ((DI::args()->getArgc() == 2) && !empty($_POST['delete']) && !empty($_POST['id'])) {
$video_id = $_POST['id'];
if (Attach::exists(['id' => $video_id, 'uid' => local_user()])) {
@ -105,7 +105,7 @@ function videos_content(App $a)
// videos/name/video/xxxxx
// videos/name/video/xxxxx/edit
$user = User::getByNickname($a->argv[1]);
$user = User::getByNickname(DI::args()->getArgv()[1]);
if (!DBA::isResult($user)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
@ -127,9 +127,9 @@ function videos_content(App $a)
//
// Parse arguments
//
if ($a->argc > 3) {
$datatype = $a->argv[2];
} elseif(($a->argc > 2) && ($a->argv[2] === 'upload')) {
if (DI::args()->getArgc() > 3) {
$datatype = DI::args()->getArgv()[2];
} elseif((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[2] === 'upload')) {
$datatype = 'upload';
} else {
$datatype = 'summary';

View file

@ -31,8 +31,8 @@ function wall_attach_post(App $a) {
$r_json = (!empty($_GET['response']) && $_GET['response']=='json');
if ($a->argc > 1) {
$nick = $a->argv[1];
if (DI::args()->getArgc() > 1) {
$nick = DI::args()->getArgv()[1];
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
DBA::escape($nick)
);

View file

@ -43,9 +43,9 @@ function wall_upload_post(App $a, $desktopmode = true)
$r_json = (!empty($_GET['response']) && $_GET['response'] == 'json');
$album = trim($_GET['album'] ?? '');
if ($a->argc > 1) {
if (DI::args()->getArgc() > 1) {
if (empty($_FILES['media'])) {
$nick = $a->argv[1];
$nick = DI::args()->getArgv()[1];
$user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) {
if ($r_json) {

View file

@ -39,7 +39,7 @@ function wallmessage_post(App $a) {
$subject = (!empty($_REQUEST['subject']) ? Strings::escapeTags(trim($_REQUEST['subject'])) : '');
$body = (!empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : '');
$recipient = (($a->argc > 1) ? Strings::escapeTags($a->argv[1]) : '');
$recipient = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(DI::args()->getArgv()[1]) : '');
if ((! $recipient) || (! $body)) {
return;
}
@ -97,7 +97,7 @@ function wallmessage_content(App $a) {
return;
}
$recipient = (($a->argc > 1) ? $a->argv[1] : '');
$recipient = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
if (!$recipient) {
notice(DI::l10n()->t('No recipient.'));

View file

@ -57,18 +57,14 @@ use Psr\Log\LoggerInterface;
class App
{
public $user;
public $data = [];
/** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */
public $argv;
/** @deprecated 2019.09 - use App\Arguments->getArgc() */
public $argc;
public $theme_info = [];
// Allow themes to control internal parameters
// by changing App values in theme.php
public $videowidth = 425;
public $videoheight = 350;
public $theme_events_in_profile = true;
private $theme_info = [
'videowidth' => 425,
'videoheight' => 350,
'events_in_profile' => true
];
private $timezone = '';
private $profile_owner = 0;
@ -193,21 +189,53 @@ class App
return $this->timezone;
}
/**
* Set workerqueue information
*
* @param array $queue
* @return void
*/
public function setQueue(array $queue)
{
$this->queue = $queue;
}
/**
* Fetch workerqueue information
*
* @return array
*/
public function getQueue()
{
return $this->queue ?? [];
}
/**
* Fetch a specific workerqueue field
*
* @param string $index
* @return mixed
*/
public function getQueueValue(string $index)
{
return $this->queue[$index] ?? null;
}
public function setThemeInfoValue(string $index, $value)
{
$this->theme_info[$index] = $value;
}
public function getThemeInfo()
{
return $this->theme_info;
}
public function getThemeInfoValue(string $index, $default = null)
{
return $this->theme_info[$index] ?? $default;
}
/**
* Returns the current config cache of this node
*
@ -254,9 +282,6 @@ class App
$this->process = $process;
$this->pConfig = $pConfig;
$this->argv = $args->getArgv();
$this->argc = $args->getArgc();
$this->load();
}

View file

@ -87,6 +87,17 @@ class Arguments
return $this->argc;
}
public function setArgv(array $argv)
{
$this->argv = $argv;
$this->argc = count($argv);
}
public function setArgc(int $argc)
{
$this->argc = $argc;
}
/**
* Returns the value of a argv key
* @todo there are a lot of $a->argv usages in combination with ?? which can be replaced with this method

View file

@ -73,9 +73,9 @@ class OEmbed
$a = DI::app();
$cache_key = 'oembed:' . $a->videowidth . ':' . $embedurl;
$cache_key = 'oembed:' . $a->getThemeInfoValue('videowidth') . ':' . $embedurl;
$condition = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $a->videowidth];
$condition = ['url' => Strings::normaliseLink($embedurl), 'maxwidth' => $a->getThemeInfoValue('videowidth')];
$oembed_record = DBA::selectFirst('oembed', ['content'], $condition);
if (DBA::isResult($oembed_record)) {
$json_string = $oembed_record['content'];
@ -111,7 +111,7 @@ class OEmbed
// but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
$href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'],
['https://www.youtube.com/', 'https://player.vimeo.com/'], $href);
$result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->videowidth);
$result = DI::httpRequest()->fetchFull($href . '&maxwidth=' . $a->getThemeInfoValue('videowidth'));
if ($result->getReturnCode() === 200) {
$json_string = $result->getBody();
break;
@ -132,7 +132,7 @@ class OEmbed
if (!empty($oembed->type) && $oembed->type != 'error') {
DBA::insert('oembed', [
'url' => Strings::normaliseLink($embedurl),
'maxwidth' => $a->videowidth,
'maxwidth' => $a->getThemeInfoValue('videowidth'),
'content' => $json_string,
'created' => DateTimeFormat::utcNow()
], Database::INSERT_UPDATE);

View file

@ -1729,7 +1729,7 @@ class BBCode
$text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $text);
if ($try_oembed) {
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $text);
} else {
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
'<a href="https://www.youtube.com/watch?v=$1" target="_blank" rel="noopener noreferrer">https://www.youtube.com/watch?v=$1</a>', $text);
@ -1744,7 +1744,7 @@ class BBCode
$text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $text);
if ($try_oembed) {
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->getThemeInfoValue('videowidth') . '" height="' . $a->getThemeInfoValue('videoheight') . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $text);
} else {
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
'<a href="https://vimeo.com/$1" target="_blank" rel="noopener noreferrer">https://vimeo.com/$1</a>', $text);

View file

@ -166,7 +166,7 @@ class Renderer
} else {
$a = DI::app();
$class = self::$template_engines[$template_engine];
$obj = new $class($a->getCurrentTheme(), $a->theme_info);
$obj = new $class($a->getCurrentTheme(), $a->getThemeInfo());
self::$template_engine_instance[$template_engine] = $obj;
return $obj;
}

View file

@ -214,7 +214,7 @@ class Theme
$theme = $a->getCurrentTheme();
$parent = Strings::sanitizeFilePathItem($a->theme_info['extends'] ?? $theme);
$parent = Strings::sanitizeFilePathItem($a->getThemeInfoValue('extends', $theme));
$paths = [
"view/theme/$theme/$file",
@ -271,7 +271,7 @@ class Theme
$theme = Strings::sanitizeFilePathItem($theme);
$a = DI::app();
$base_theme = $a->theme_info['extends'] ?? '';
$base_theme = $a->getThemeInfoValue('extends') ?? '';
if (file_exists("view/theme/$theme/config.php")) {
return "view/theme/$theme/config.php";

View file

@ -2802,8 +2802,8 @@ class Item
}
// Replace friendica image url size with theme preference.
if (!empty($a->theme_info['item_image_size'])) {
$ps = $a->theme_info['item_image_size'];
if (!empty($a->getThemeInfoValue('item_image_size'))) {
$ps = $a->getThemeInfoValue('item_image_size');
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
}

View file

@ -37,12 +37,11 @@ class Attach extends BaseModule
public static function rawContent(array $parameters = [])
{
$a = DI::app();
if ($a->argc != 2) {
if (empty($parameters['item'])) {
throw new \Friendica\Network\HTTPException\BadRequestException();
}
// @TODO: Replace with parameter from router
$item_id = intval($a->argv[1]);
$item_id = intval($parameters['item']);
// Check for existence
$item = MAttach::exists(['id' => $item_id]);

View file

@ -81,7 +81,7 @@ class BaseProfile extends BaseModule
];
// the calendar link for the full featured events calendar
if ($is_owner && $a->theme_events_in_profile) {
if ($is_owner && $a->getThemeInfoValue('events_in_profile')) {
$tabs[] = [
'label' => DI::l10n()->t('Events'),
'url' => DI::baseUrl() . '/events',

View file

@ -42,21 +42,21 @@ class BaseSettings extends BaseModule
$tabs[] = [
'label' => DI::l10n()->t('Account'),
'url' => 'settings',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'settings') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() == 1) && (DI::args()->getArgv() === 'settings') ? 'active' : ''),
'accesskey' => 'o',
];
$tabs[] = [
'label' => DI::l10n()->t('Two-factor authentication'),
'url' => 'settings/2fa',
'selected' => (($a->argc > 1) && ($a->argv[1] === '2fa') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === '2fa') ? 'active' : ''),
'accesskey' => 'o',
];
$tabs[] = [
'label' => DI::l10n()->t('Profile'),
'url' => 'settings/profile',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'profile') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'profile') ? 'active' : ''),
'accesskey' => 'p',
];
@ -64,7 +64,7 @@ class BaseSettings extends BaseModule
$tabs[] = [
'label' => DI::l10n()->t('Additional features'),
'url' => 'settings/features',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'features') ? 'active' : ''),
'accesskey' => 't',
];
}
@ -72,49 +72,49 @@ class BaseSettings extends BaseModule
$tabs[] = [
'label' => DI::l10n()->t('Display'),
'url' => 'settings/display',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'display') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'display') ? 'active' : ''),
'accesskey' => 'i',
];
$tabs[] = [
'label' => DI::l10n()->t('Social Networks'),
'url' => 'settings/connectors',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors') ? 'active' : ''),
'accesskey' => 'w',
];
$tabs[] = [
'label' => DI::l10n()->t('Addons'),
'url' => 'settings/addon',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'addon') ? 'active' : ''),
'accesskey' => 'l',
];
$tabs[] = [
'label' => DI::l10n()->t('Manage Accounts'),
'url' => 'settings/delegation',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'delegation') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'delegation') ? 'active' : ''),
'accesskey' => 'd',
];
$tabs[] = [
'label' => DI::l10n()->t('Connected apps'),
'url' => 'settings/oauth',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'oauth') ? 'active' : ''),
'accesskey' => 'b',
];
$tabs[] = [
'label' => DI::l10n()->t('Export personal data'),
'url' => 'settings/userexport',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'userexport') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'userexport') ? 'active' : ''),
'accesskey' => 'e',
];
$tabs[] = [
'label' => DI::l10n()->t('Remove account'),
'url' => 'removeme',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'removeme') ? 'active' : ''),
'selected' => ((DI::args()->getArgc() == 1) && (DI::args()->getArgv() === 'removeme') ? 'active' : ''),
'accesskey' => 'r',
];

View file

@ -106,13 +106,13 @@ class Contact extends BaseModule
}
// @TODO: Replace with parameter from router
if ($a->argv[1] === 'batch') {
if (DI::args()->getArgv()[1] === 'batch') {
self::batchActions();
return;
}
// @TODO: Replace with parameter from router
$contact_id = intval($a->argv[1]);
$contact_id = intval(DI::args()->getArgv()[1]);
if (!$contact_id) {
return;
}
@ -271,10 +271,10 @@ class Contact extends BaseModule
$contact = null;
// @TODO: Replace with parameter from router
if ($a->argc == 2 && intval($a->argv[1])
|| $a->argc == 3 && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])
if (DI::args()->getArgc() == 2 && intval(DI::args()->getArgv()[1])
|| DI::args()->getArgc() == 3 && intval(DI::args()->getArgv()[1]) && in_array(DI::args()->getArgv()[2], ['posts', 'conversations'])
) {
$contact_id = intval($a->argv[1]);
$contact_id = intval(DI::args()->getArgv()[1]);
// Ensure to use the user contact when the public contact was provided
$data = Model\Contact::getPublicAndUserContactID($contact_id, local_user());
@ -293,7 +293,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) {
if ($contact['self']) {
// @TODO: Replace with parameter from router
if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) {
if ((DI::args()->getArgc() == 3) && intval(DI::args()->getArgv()[1]) && in_array(DI::args()->getArgv()[2], ['posts', 'conversations'])) {
DI::baseUrl()->redirect('profile/' . $contact['nick']);
} else {
DI::baseUrl()->redirect('profile/' . $contact['nick'] . '/profile');
@ -343,14 +343,14 @@ class Contact extends BaseModule
return Login::form();
}
if ($a->argc == 3) {
$contact_id = intval($a->argv[1]);
if (DI::args()->getArgc() == 3) {
$contact_id = intval(DI::args()->getArgv()[1]);
if (!$contact_id) {
throw new BadRequestException();
}
// @TODO: Replace with parameter from router
$cmd = $a->argv[2];
$cmd = DI::args()->getArgv()[2];
$orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]);
if (!DBA::isResult($orig_record)) {
@ -637,7 +637,7 @@ class Contact extends BaseModule
$sql_values = [local_user()];
// @TODO: Replace with parameter from router
$type = $a->argv[1] ?? '';
$type = DI::args()->getArgv()[1] ?? '';
switch ($type) {
case 'blocked':

View file

@ -23,7 +23,6 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
@ -38,16 +37,13 @@ class ItemBody extends BaseModule
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
}
$app = DI::app();
// @TODO: Replace with parameter from router
$itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);
if (!$itemId) {
if (empty($parameters['item'])) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
}
$item = Post::selectFirst(['body'], ['uid' => local_user(), 'uri-id' => $itemId]);
$itemId = intval($parameters['item']);
$item = Post::selectFirst(['body'], ['uid' => [0, local_user()], 'uri-id' => $itemId]);
if (!empty($item)) {
if (DI::mode()->isAjax()) {

View file

@ -40,15 +40,11 @@ class Fetch extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
// @TODO: Replace with parameter from router
if (($app->argc != 3) || (!in_array($app->argv[1], ["post", "status_message", "reshare"]))) {
if (empty($parameters['guid'])) {
throw new HTTPException\NotFoundException();
}
// @TODO: Replace with parameter from router
$guid = $app->argv[2];
$guid = $parameters['guid'];
// Fetch the item
$fields = [
@ -68,7 +64,7 @@ class Fetch extends BaseModule
$host = $parts["scheme"] . "://" . $parts["host"];
if (Strings::normaliseLink($host) != Strings::normaliseLink(DI::baseUrl()->get())) {
$location = $host . "/fetch/" . $app->argv[1] . "/" . urlencode($guid);
$location = $host . "/fetch/" . DI::args()->getArgv()[1] . "/" . urlencode($guid);
System::externalRedirect($location, 301);
}
}

View file

@ -76,12 +76,6 @@ class Directory extends BaseModule
if ($profiles['total'] === 0) {
notice(DI::l10n()->t('No entries (some entries may be hidden).'));
} else {
if (in_array('small', $app->argv)) {
$photo = 'thumb';
} else {
$photo = 'photo';
}
foreach ($profiles['entries'] as $entry) {
$contact = Model\Contact::getByURLForUser($entry['url'], local_user());
if (!empty($contact)) {

View file

@ -48,15 +48,10 @@ class Feed extends BaseModule
$last_update = $_GET['last_update'] ?? '';
$nocache = !empty($_GET['nocache']) && local_user();
// @TODO: Replace with parameter from router
if ($a->argc < 2) {
throw new \Friendica\Network\HTTPException\BadRequestException();
}
$type = null;
// @TODO: Replace with parameter from router
if ($a->argc > 2) {
$type = $a->argv[2];
if (DI::args()->getArgc() > 2) {
$type = DI::args()->getArgv()[2];
}
switch ($type) {
@ -72,10 +67,8 @@ class Feed extends BaseModule
$type = 'posts';
}
// @TODO: Replace with parameter from router
$nickname = $a->argv[1];
header("Content-type: application/atom+xml; charset=utf-8");
echo ProtocolFeed::atom($nickname, $last_update, 10, $type, $nocache, true);
echo ProtocolFeed::atom($parameters['nickname'], $last_update, 10, $type, $nocache, true);
exit();
}
}

View file

@ -39,10 +39,9 @@ class RemoveTag extends BaseModule
throw new HTTPException\ForbiddenException();
}
$app = DI::app();
$logger = DI::logger();
$item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0);
$item_id = $parameters['id'] ?? 0;
$term = XML::unescape(trim($_GET['term'] ?? ''));
$cat = XML::unescape(trim($_GET['cat'] ?? ''));

View file

@ -44,12 +44,11 @@ class SaveTag extends BaseModule
public static function rawContent(array $parameters = [])
{
$a = DI::app();
$logger = DI::logger();
$term = XML::unescape(trim($_GET['term'] ?? ''));
// @TODO: Replace with parameter from router
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
$item_id = $parameters['id'] ?? 0;
$logger->info('filer', ['tag' => $term, 'item' => $item_id]);

View file

@ -120,10 +120,8 @@ class Friendica extends BaseModule
}
}
$app = DI::app();
// @TODO: Replace with parameter from router
if ($app->argc <= 1 || ($app->argv[1] !== 'json')) {
if (DI::args()->getArgc() <= 1 || (DI::args()->getArgv()[1] !== 'json')) {
return;
}

View file

@ -47,7 +47,7 @@ class Group extends BaseModule
}
// @TODO: Replace with parameter from router
if (($a->argc == 2) && ($a->argv[1] === 'new')) {
if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'new')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
$name = Strings::escapeTags(trim($_POST['groupname']));
@ -64,10 +64,10 @@ class Group extends BaseModule
}
// @TODO: Replace with parameter from router
if (($a->argc == 2) && intval($a->argv[1])) {
if ((DI::args()->getArgc() == 2) && intval(DI::args()->getArgv()[1])) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user()]);
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user()]);
if (!DBA::isResult($group)) {
notice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
@ -93,8 +93,8 @@ class Group extends BaseModule
// POST /group/123/add/123
// POST /group/123/remove/123
// @TODO: Replace with parameter from router
if ($a->argc == 4) {
list($group_id, $command, $contact_id) = array_slice($a->argv, 1);
if (DI::args()->getArgc() == 4) {
list($group_id, $command, $contact_id) = array_slice(DI::args()->getArgv(), 1);
if (!Model\Group::exists($group_id, local_user())) {
throw new \Exception(DI::l10n()->t('Unknown group.'), 404);
@ -149,11 +149,11 @@ class Group extends BaseModule
$a = DI::app();
DI::page()['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone'));
DI::page()['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : 'everyone'));
// With no group number provided we jump to the unassigned contacts as a starting point
// @TODO: Replace with parameter from router
if ($a->argc == 1) {
if (DI::args()->getArgc() == 1) {
DI::baseUrl()->redirect('group/none');
}
@ -172,7 +172,7 @@ class Group extends BaseModule
];
// @TODO: Replace with parameter from router
if (($a->argc == 2) && ($a->argv[1] === 'new')) {
if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'new')) {
return Renderer::replaceMacros($tpl, $context + [
'$title' => DI::l10n()->t('Create a group of contacts/friends.'),
'$gname' => ['groupname', DI::l10n()->t('Group Name: '), '', ''],
@ -184,8 +184,8 @@ class Group extends BaseModule
$nogroup = false;
// @TODO: Replace with parameter from router
if (($a->argc == 2) && ($a->argv[1] === 'none') ||
($a->argc == 1) && ($a->argv[0] === 'nogroup')) {
if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'none') ||
(DI::args()->getArgc() == 1) && (DI::args()->getArgv()[0] === 'nogroup')) {
$id = -1;
$nogroup = true;
$group = [
@ -205,17 +205,17 @@ class Group extends BaseModule
}
// @TODO: Replace with parameter from router
if (($a->argc == 3) && ($a->argv[1] === 'drop')) {
if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');
// @TODO: Replace with parameter from router
if (intval($a->argv[2])) {
if (!Model\Group::exists($a->argv[2], local_user())) {
if (intval(DI::args()->getArgv()[2])) {
if (!Model\Group::exists(DI::args()->getArgv()[2], local_user())) {
notice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
}
if (!Model\Group::remove($a->argv[2])) {
if (!Model\Group::remove(DI::args()->getArgv()[2])) {
notice(DI::l10n()->t('Unable to remove group.'));
}
}
@ -223,17 +223,17 @@ class Group extends BaseModule
}
// @TODO: Replace with parameter from router
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
if ((DI::args()->getArgc() > 2) && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
if (DBA::exists('contact', ['id' => $a->argv[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
$change = intval($a->argv[2]);
if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
$change = intval(DI::args()->getArgv()[2]);
}
}
// @TODO: Replace with parameter from router
if (($a->argc > 1) && intval($a->argv[1])) {
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user(), 'deleted' => false]);
if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) {
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user(), 'deleted' => false]);
if (!DBA::isResult($group)) {
notice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');

View file

@ -45,11 +45,11 @@ class Help extends BaseModule
$lang = $config->get('system', 'language');
// @TODO: Replace with parameter from router
if ($a->argc > 1) {
if (DI::args()->getArgc() > 1) {
$path = '';
// looping through the argv keys bigger than 0 to build
// a path relative to /help
for ($x = 1; $x < $a->argc; $x ++) {
for ($x = 1; $x < DI::args()->getArgc(); $x ++) {
if (strlen($path)) {
$path .= '/';
}

View file

@ -39,26 +39,24 @@ class Oembed extends BaseModule
{
public static function content(array $parameters = [])
{
$a = DI::app();
// Unused form: /oembed/b2h?url=...
if ($a->argv[1] == 'b2h') {
if (DI::args()->getArgv()[1] == 'b2h') {
$url = ["", trim(hex2bin($_REQUEST['url']))];
echo Content\OEmbed::replaceCallback($url);
exit();
}
// Unused form: /oembed/h2b?text=...
if ($a->argv[1] == 'h2b') {
if (DI::args()->getArgv()[1] == 'h2b') {
$text = trim(hex2bin($_REQUEST['text']));
echo Content\OEmbed::HTML2BBCode($text);
exit();
}
// @TODO: Replace with parameter from router
if ($a->argc == 2) {
if (DI::args()->getArgc() == 2) {
echo '<html><body>';
$url = Strings::base64UrlDecode($a->argv[1]);
$url = Strings::base64UrlDecode(DI::args()->getArgv()[1]);
$j = Content\OEmbed::fetchURL($url);
// workaround for media.ccc.de (and any other endpoint that return size 0)

View file

@ -27,7 +27,6 @@ use Friendica\Model\User;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Util\Crypto;
use Friendica\Util\Strings;
use phpseclib\File\ASN1;
/**
* prints the public RSA key of a user
@ -36,15 +35,11 @@ class PublicRSAKey extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
// @TODO: Replace with parameter from router
if ($app->argc !== 2) {
if (empty($parameters['nick'])) {
throw new BadRequestException();
}
// @TODO: Replace with parameter from router
$nick = $app->argv[1];
$nick = $parameters['nick'];
$user = User::getByNickname($nick, ['spubkey']);
if (empty($user) || empty($user['spubkey'])) {

View file

@ -23,6 +23,7 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Content;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
@ -34,9 +35,7 @@ class Smilies extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
if (!empty($app->argv[1]) && ($app->argv[1] === "json")) {
if (!empty(DI::args()->getArgv()[1]) && (DI::args()->getArgv()[1] === "json")) {
$smilies = Content\Smilies::getList();
$results = [];
for ($i = 0; $i < count($smilies['texts']); $i++) {

View file

@ -40,10 +40,8 @@ class Xrd extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
// @TODO: Replace with parameter from router
if ($app->argv[0] == 'xrd') {
if (DI::args()->getArgv()[0] == 'xrd') {
if (empty($_GET['uri'])) {
return;
}

View file

@ -343,7 +343,7 @@ class Authentication
}
}
$this->redirectForTwoFactorAuthentication($user_record['uid'], $a);
$this->redirectForTwoFactorAuthentication($user_record['uid']);
if ($interactive) {
if ($user_record['login_date'] <= DBA::NULL_DATETIME) {
@ -369,12 +369,11 @@ class Authentication
* All return calls in this method skip two-factor authentication
*
* @param int $uid The User Identified
* @param App $a The Friendica Application context
*
* @throws HTTPException\ForbiddenException In case the two factor authentication is forbidden (e.g. for AJAX calls)
* @throws HTTPException\InternalServerErrorException
*/
private function redirectForTwoFactorAuthentication(int $uid, App $a)
private function redirectForTwoFactorAuthentication(int $uid)
{
// Check user setting, if 2FA disabled return
if (!$this->pConfig->get($uid, '2fa', 'verified')) {
@ -382,7 +381,7 @@ class Authentication
}
// Check current path, if public or 2fa module return
if ($a->argc > 0 && in_array($a->argv[0], ['2fa', 'view', 'help', 'api', 'proxy', 'logout'])) {
if (DI::args()->getArgc() > 0 && in_array(DI::args()->getArgv()[0], ['2fa', 'view', 'help', 'api', 'proxy', 'logout'])) {
return;
}

View file

@ -115,6 +115,12 @@ trait AppMockTrait
$this->app
->shouldReceive('getCurrentTheme')
->andReturn('Smarty3');
$this->app->shouldReceive('getThemeInfoValue')
->with('videowidth')
->andReturn(425);
$this->app->shouldReceive('getThemeInfoValue')
->with('videoheight')
->andReturn(350);
DI::init($this->dice);

View file

@ -76,8 +76,7 @@ class ApiTest extends FixtureTest
/** @var App app */
$this->app = DI::app();
$this->app->argc = 1;
$this->app->argv = [''];
DI::args()->setArgc(1);
// User data that the test database is populated with
$this->selfUser = [
@ -925,7 +924,7 @@ class ApiTest extends FixtureTest
{
global $called_api;
$called_api = ['api_path'];
$this->app->argv[1] = $this->otherUser['id'] . '.json';
DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
self::assertOtherUser(api_get_user($this->app));
}
@ -1198,7 +1197,7 @@ class ApiTest extends FixtureTest
*/
public function testApiStatusesMediap()
{
$this->app->argc = 2;
DI::args()->setArgc(2);
$_FILES = [
'media' => [
@ -1370,7 +1369,7 @@ class ApiTest extends FixtureTest
]
];
$app = DI::app();
$app->argc = 2;
DI::args()->setArgc(2);
$result = api_media_upload();
self::assertEquals('image/png', $result['media']['image']['image_type']);
@ -1793,7 +1792,7 @@ class ApiTest extends FixtureTest
*/
public function testApiStatusesShowWithId()
{
$this->app->argv[3] = 1;
DI::args()->setArgv(['', '', '', 1]);
$result = api_statuses_show('json');
self::assertStatus($result['status']);
}
@ -1805,7 +1804,7 @@ class ApiTest extends FixtureTest
*/
public function testApiStatusesShowWithConversation()
{
$this->app->argv[3] = 1;
DI::args()->setArgv(['', '', '', 1]);
$_REQUEST['conversation'] = 1;
$result = api_statuses_show('json');
self::assertNotEmpty($result['status']);
@ -1845,7 +1844,7 @@ class ApiTest extends FixtureTest
*/
public function testApiConversationShowWithId()
{
$this->app->argv[3] = 1;
DI::args()->setArgv(['', '', '', 1]);
$_REQUEST['max_id'] = 10;
$_REQUEST['page'] = -2;
$result = api_conversation_show('json');
@ -1898,12 +1897,12 @@ class ApiTest extends FixtureTest
*/
public function testApiStatusesRepeatWithId()
{
$this->app->argv[3] = 1;
DI::args()->setArgv(['', '', '', 1]);
$result = api_statuses_repeat('json');
self::assertStatus($result['status']);
// Also test with a shared status
$this->app->argv[3] = 5;
DI::args()->setArgv(['', '', '', 5]);
$result = api_statuses_repeat('json');
self::assertStatus($result['status']);
}
@ -1938,7 +1937,7 @@ class ApiTest extends FixtureTest
*/
public function testApiStatusesDestroyWithId()
{
$this->app->argv[3] = 1;
DI::args()->setArgv(['', '', '', 1]);
$result = api_statuses_destroy('json');
self::assertStatus($result['status']);
}
@ -2057,8 +2056,7 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroy()
{
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'create'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
api_favorites_create_destroy('json');
}
@ -2070,8 +2068,7 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroyWithInvalidId()
{
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'create', '12.json'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
api_favorites_create_destroy('json');
}
@ -2083,8 +2080,7 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroyWithInvalidAction()
{
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'change.json'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
$_REQUEST['id'] = 1;
api_favorites_create_destroy('json');
}
@ -2096,8 +2092,7 @@ class ApiTest extends FixtureTest
*/
public function testApiFavoritesCreateDestroyWithCreateAction()
{
$this->app->argv = ['api', '1.1', 'favorites', 'create.json'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
$_REQUEST['id'] = 3;
$result = api_favorites_create_destroy('json');
self::assertStatus($result['status']);
@ -2110,8 +2105,7 @@ class ApiTest extends FixtureTest
*/
public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
{
$this->app->argv = ['api', '1.1', 'favorites', 'create.rss'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
$_REQUEST['id'] = 3;
$result = api_favorites_create_destroy('rss');
self::assertXml($result, 'status');
@ -2124,8 +2118,7 @@ class ApiTest extends FixtureTest
*/
public function testApiFavoritesCreateDestroyWithDestroyAction()
{
$this->app->argv = ['api', '1.1', 'favorites', 'destroy.json'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
$_REQUEST['id'] = 3;
$result = api_favorites_create_destroy('json');
self::assertStatus($result['status']);
@ -2139,8 +2132,7 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
{
$this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'create.json'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
$_SESSION['authenticated'] = false;
api_favorites_create_destroy('json');
}
@ -3719,8 +3711,7 @@ class ApiTest extends FixtureTest
*/
public function testApiFriendicaNotificationWithEmptyResult()
{
$this->app->argv = ['api', 'friendica', 'notification'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', 'friendica', 'notification']);
$_SESSION['uid'] = 41;
$result = api_friendica_notification('json');
self::assertEquals(['note' => false], $result);
@ -3733,8 +3724,7 @@ class ApiTest extends FixtureTest
*/
public function testApiFriendicaNotificationWithXmlResult()
{
$this->app->argv = ['api', 'friendica', 'notification'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', 'friendica', 'notification']);
$result = api_friendica_notification('xml');
$dateRel = Temporal::getRelativeDate('2020-01-01 12:12:02');
$assertXml=<<<XML
@ -3753,8 +3743,7 @@ XML;
*/
public function testApiFriendicaNotificationWithJsonResult()
{
$this->app->argv = ['api', 'friendica', 'notification'];
$this->app->argc = count($this->app->argv);
DI::args()->setArgv(['api', 'friendica', 'notification']);
$result = json_encode(api_friendica_notification('json'));
self::assertJson($result);
}

View file

@ -24,8 +24,6 @@ class SmiliesTest extends MockedTest
parent::setUp();
$this->setUpVfsDir();
$this->mockApp($this->root);
$this->app->videowidth = 425;
$this->app->videoheight = 350;
$this->configMock->shouldReceive('get')
->with('system', 'no_smilies')
->andReturn(false);

View file

@ -40,8 +40,6 @@ class BBCodeTest extends MockedTest
parent::setUp();
$this->setUpVfsDir();
$this->mockApp($this->root);
$this->app->videowidth = 425;
$this->app->videoheight = 350;
$this->configMock->shouldReceive('get')
->with('system', 'remove_multiplicated_lines')
->andReturn(false);

View file

@ -33,8 +33,8 @@ function frio_init(App $a)
$frio = 'view/theme/frio';
// disable the events module link in the profile tab
$a->theme_events_in_profile = false;
$a->videowidth = 622;
$a->setThemeInfoValue('events_in_profile', false);
$a->setThemeInfoValue('videowidth', 622);
Renderer::setActiveTemplateEngine('smarty3');

View file

@ -21,7 +21,7 @@ use Friendica\Util\Strings;
function vier_init(App $a)
{
$a->theme_events_in_profile = false;
$a->setThemeInfoValue('events_in_profile', false);
Renderer::setActiveTemplateEngine('smarty3');