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; use Friendica\App;
function duepuntozero_lr_init(App $a) { function duepuntozero_lr_init(App $a) {
$a-> theme_info = array( $a->setThemeInfoValue('extends', 'duepuntozero');
'extends' => 'duepuntozero'.
);
$a->set_template_engine('smarty3'); $a->set_template_engine('smarty3');
/* and more stuff e.g. the JavaScript function for the header */ /* 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: When you want to inherit stuff from another theme you have to *announce* this in the theme_info:
$a->theme_info = array( $a->setThemeInfoValue('extends', 'duepuntozero');
'extends' => 'duepuntozero',
);
which declares *duepuntozero* as parent of the theme. 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 // $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); $argid = count($called_api);
if (!empty($a->argv[$argid])) { if (!empty(DI::args()->getArgv()[$argid])) {
$data = explode(".", $a->argv[$argid]); $data = explode(".", DI::args()->getArgv()[$argid]);
if (count($data) > 1) { if (count($data) > 1) {
list($user, $null) = $data; list($user, $null) = $data;
} }
@ -1021,7 +1021,7 @@ function api_statuses_mediap($type)
} }
$txt = HTML::toBBCode($txt); $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); $picture = wall_upload_post($a, false);
@ -1883,7 +1883,7 @@ function api_statuses_show($type)
} }
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) { if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0); $id = intval($_REQUEST['id'] ?? 0);
@ -1891,7 +1891,7 @@ function api_statuses_show($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { if ($id == 0) {
$id = intval($a->argv[4] ?? 0); $id = intval(DI::args()->getArgv()[4] ?? 0);
} }
Logger::log('API: api_statuses_show: ' . $id); Logger::log('API: api_statuses_show: ' . $id);
@ -1962,7 +1962,7 @@ function api_conversation_show($type)
} }
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
$since_id = intval($_REQUEST['since_id'] ?? 0); $since_id = intval($_REQUEST['since_id'] ?? 0);
$max_id = intval($_REQUEST['max_id'] ?? 0); $max_id = intval($_REQUEST['max_id'] ?? 0);
$count = intval($_REQUEST['count'] ?? 20); $count = intval($_REQUEST['count'] ?? 20);
@ -1976,7 +1976,7 @@ function api_conversation_show($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { 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]); 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); api_get_user($a);
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) { if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0); $id = intval($_REQUEST['id'] ?? 0);
@ -2053,7 +2053,7 @@ function api_statuses_repeat($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { if ($id == 0) {
$id = intval($a->argv[4] ?? 0); $id = intval(DI::args()->getArgv()[4] ?? 0);
} }
Logger::log('API: api_statuses_repeat: '.$id); Logger::log('API: api_statuses_repeat: '.$id);
@ -2128,7 +2128,7 @@ function api_statuses_destroy($type)
api_get_user($a); api_get_user($a);
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) { if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0); $id = intval($_REQUEST['id'] ?? 0);
@ -2136,7 +2136,7 @@ function api_statuses_destroy($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { if ($id == 0) {
$id = intval($a->argv[4] ?? 0); $id = intval(DI::args()->getArgv()[4] ?? 0);
} }
Logger::log('API: api_statuses_destroy: '.$id); Logger::log('API: api_statuses_destroy: '.$id);
@ -2329,16 +2329,16 @@ function api_favorites_create_destroy($type)
// for versioned api. // for versioned api.
/// @TODO We need a better global soluton /// @TODO We need a better global soluton
$action_argv_id = 2; $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; $action_argv_id = 3;
} }
if ($a->argc <= $action_argv_id) { if (DI::args()->getArgc() <= $action_argv_id) {
throw new BadRequestException("Invalid request."); throw new BadRequestException("Invalid request.");
} }
$action = str_replace("." . $type, "", $a->argv[$action_argv_id]); $action = str_replace("." . $type, "", DI::args()->getArgv()[$action_argv_id]);
if ($a->argc == $action_argv_id + 2) { if (DI::args()->getArgc() == $action_argv_id + 2) {
$itemid = intval($a->argv[$action_argv_id + 1] ?? 0); $itemid = intval(DI::args()->getArgv()[$action_argv_id + 1] ?? 0);
} else { } else {
$itemid = intval($_REQUEST['id'] ?? 0); $itemid = intval($_REQUEST['id'] ?? 0);
} }
@ -5616,7 +5616,7 @@ function api_friendica_activity($type)
if (api_user() === false) { if (api_user() === false) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
$verb = strtolower($a->argv[3]); $verb = strtolower(DI::args()->getArgv()[3]);
$verb = preg_replace("|\..*$|", "", $verb); $verb = preg_replace("|\..*$|", "", $verb);
$id = $_REQUEST['id'] ?? 0; $id = $_REQUEST['id'] ?? 0;
@ -5664,7 +5664,7 @@ function api_friendica_notification($type)
if (api_user() === false) { if (api_user() === false) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
if ($a->argc!==3) { if (DI::args()->getArgc()!==3) {
throw new BadRequestException("Invalid argument count"); throw new BadRequestException("Invalid argument count");
} }
@ -5709,7 +5709,7 @@ function api_friendica_notification_seen($type)
if (api_user() === false || $user_info === false) { if (api_user() === false || $user_info === false) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
if ($a->argc !== 4) { if (DI::args()->getArgc() !== 4) {
throw new BadRequestException("Invalid argument count"); 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.')); 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.')); 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 // if it's a json request abort here becaus we don't
// need the widget data // 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; return;
} }
$owner = User::getOwnerDataByNick($a->argv[1]); $owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
if (empty($owner)) { if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
@ -73,7 +73,7 @@ function cal_init(App $a)
function cal_content(App $a) function cal_content(App $a)
{ {
$owner = User::getOwnerDataByNick($a->argv[1]); $owner = User::getOwnerDataByNick(DI::args()->getArgv()[1]);
if (empty($owner)) { if (empty($owner)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); 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); $ignored = (!empty($_REQUEST['ignored']) ? intval($_REQUEST['ignored']) : 0);
$format = 'ical'; $format = 'ical';
if ($a->argc == 4 && $a->argv[2] == 'export') { if (DI::args()->getArgc() == 4 && DI::args()->getArgv()[2] == 'export') {
$mode = 'export'; $mode = 'export';
$format = $a->argv[3]; $format = DI::args()->getArgv()[3];
} }
// Setup permissions structures // 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); $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'])) { if (!empty($_GET['start'])) {
$start = $_GET['start']; $start = $_GET['start'];
} }
@ -220,7 +220,7 @@ function cal_content(App $a)
// transform the event in a usable array // transform the event in a usable array
$events = Event::prepareListForTemplate($r); $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); echo json_encode($events);
exit(); exit();
} }

View file

@ -37,19 +37,18 @@ use Friendica\Module\ActivityPub\Objects;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Util\Strings;
function display_init(App $a) function display_init(App $a)
{ {
if (ActivityPub::isRequest()) { 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()) { if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
return; return;
} }
$nick = (($a->argc > 1) ? $a->argv[1] : ''); $nick = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
$item = null; $item = null;
$item_user = local_user(); $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']; $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 there is only one parameter, then check if this parameter could be a guid
if ($a->argc == 2) { if (DI::args()->getArgc() == 2) {
$nick = ''; $nick = '';
// Does the local user have this item? // Does the local user have this item?
if (local_user()) { 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)) { if (DBA::isResult($item)) {
$nick = $a->user['nickname']; $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? // Is this item private but could be visible to the remove visitor?
if (!DBA::isResult($item) && remote_user()) { 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 (DBA::isResult($item)) {
if (!Contact::isFollower(remote_user(), $item['uid'])) { if (!Contact::isFollower(remote_user(), $item['uid'])) {
$item = null; $item = null;
@ -82,10 +81,10 @@ function display_init(App $a)
// Is it an item with uid=0? // Is it an item with uid=0?
if (!DBA::isResult($item)) { 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') { } elseif (DI::args()->getArgc() >= 3 && $nick == 'feed-item') {
$uri_id = $a->argv[2]; $uri_id = DI::args()->getArgv()[2];
if (substr($uri_id, -5) == '.atom') { if (substr($uri_id, -5) == '.atom') {
$uri_id = substr($uri_id, 0, -5); $uri_id = substr($uri_id, 0, -5);
} }
@ -96,8 +95,8 @@ function display_init(App $a)
return; return;
} }
if ($a->argc >= 3 && $nick == 'feed-item') { if (DI::args()->getArgc() >= 3 && $nick == 'feed-item') {
displayShowFeed($item['uri-id'], $item['uid'], $a->argc > 3 && $a->argv[3] == 'conversation.atom'); 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')) { 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']; $parent_uri_id = $item['parent-uri-id'];
} }
} else { } 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; $parent_uri_id = $uri_id;
if ($a->argc == 2) { if (DI::args()->getArgc() == 2) {
$fields = ['uri-id', 'parent-uri-id', 'uid']; $fields = ['uri-id', 'parent-uri-id', 'uid'];
if (local_user()) { 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); $item = Post::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
$uri_id = $item['uri-id']; $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()) { 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'])) { if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) {
$uri_id = $item['uri-id']; $uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-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) { 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); $item = Post::selectFirstForUser(local_user(), $fields, $condition);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
$uri_id = $item['uri-id']; $uri_id = $item['uri-id'];

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -50,8 +50,8 @@ function hub_post_return()
function pubsub_init(App $a) function pubsub_init(App $a)
{ {
$nick = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : ''); $nick = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); $contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 );
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$hub_mode = Strings::escapeTags(trim($_GET['hub_mode'] ?? '')); $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('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . DI::args()->getCommand() . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']);
Logger::log('Data: ' . $xml, Logger::DATA); Logger::log('Data: ' . $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])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 ); $contact_id = ((DI::args()->getArgc() > 2) ? intval(DI::args()->getArgv()[2]) : 0 );
$importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]); $importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBA::isResult($importer)) { if (!DBA::isResult($importer)) {

View file

@ -66,9 +66,9 @@ function pubsubhubbub_init(App $a) {
Logger::log("$hub_mode request from " . $_SERVER['REMOTE_ADDR']); 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 // 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 { } else {
// Get the nick name from the topic as a fallback // Get the nick name from the topic as a fallback
$nick = $hub_topic; $nick = $hub_topic;

View file

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

View file

@ -42,7 +42,7 @@ function salmon_post(App $a, $xml = '') {
Logger::log('new salmon ' . $xml, Logger::DATA); 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]); $importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (! DBA::isResult($importer)) { if (! DBA::isResult($importer)) {

View file

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

View file

@ -22,11 +22,12 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
function share_init(App $a) { 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()) { if (!$post_id || !local_user()) {
exit(); exit();

View file

@ -49,7 +49,7 @@ function tagger_content(App $a) {
return; 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); Logger::log('tagger: tag ' . $term . ' item ' . $item_id);

View file

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

View file

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

View file

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

View file

@ -31,8 +31,8 @@ function wall_attach_post(App $a) {
$r_json = (!empty($_GET['response']) && $_GET['response']=='json'); $r_json = (!empty($_GET['response']) && $_GET['response']=='json');
if ($a->argc > 1) { if (DI::args()->getArgc() > 1) {
$nick = $a->argv[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", $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) 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'); $r_json = (!empty($_GET['response']) && $_GET['response'] == 'json');
$album = trim($_GET['album'] ?? ''); $album = trim($_GET['album'] ?? '');
if ($a->argc > 1) { if (DI::args()->getArgc() > 1) {
if (empty($_FILES['media'])) { 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]); $user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
if ($r_json) { if ($r_json) {

View file

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

View file

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

View file

@ -87,6 +87,17 @@ class Arguments
return $this->argc; 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 * 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 * @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(); $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); $oembed_record = DBA::selectFirst('oembed', ['content'], $condition);
if (DBA::isResult($oembed_record)) { if (DBA::isResult($oembed_record)) {
$json_string = $oembed_record['content']; $json_string = $oembed_record['content'];
@ -111,7 +111,7 @@ class OEmbed
// but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯ // but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯
$href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'], $href = str_replace(['http://www.youtube.com/', 'http://player.vimeo.com/'],
['https://www.youtube.com/', 'https://player.vimeo.com/'], $href); ['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) { if ($result->getReturnCode() === 200) {
$json_string = $result->getBody(); $json_string = $result->getBody();
break; break;
@ -132,7 +132,7 @@ class OEmbed
if (!empty($oembed->type) && $oembed->type != 'error') { if (!empty($oembed->type) && $oembed->type != 'error') {
DBA::insert('oembed', [ DBA::insert('oembed', [
'url' => Strings::normaliseLink($embedurl), 'url' => Strings::normaliseLink($embedurl),
'maxwidth' => $a->videowidth, 'maxwidth' => $a->getThemeInfoValue('videowidth'),
'content' => $json_string, 'content' => $json_string,
'created' => DateTimeFormat::utcNow() 'created' => DateTimeFormat::utcNow()
], Database::INSERT_UPDATE); ], Database::INSERT_UPDATE);

View file

@ -1729,7 +1729,7 @@ class BBCode
$text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $text); $text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $text);
if ($try_oembed) { 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 { } else {
$text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", $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); '<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); $text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $text);
if ($try_oembed) { 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 { } else {
$text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", $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); '<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 { } else {
$a = DI::app(); $a = DI::app();
$class = self::$template_engines[$template_engine]; $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; self::$template_engine_instance[$template_engine] = $obj;
return $obj; return $obj;
} }

View file

@ -214,7 +214,7 @@ class Theme
$theme = $a->getCurrentTheme(); $theme = $a->getCurrentTheme();
$parent = Strings::sanitizeFilePathItem($a->theme_info['extends'] ?? $theme); $parent = Strings::sanitizeFilePathItem($a->getThemeInfoValue('extends', $theme));
$paths = [ $paths = [
"view/theme/$theme/$file", "view/theme/$theme/$file",
@ -271,7 +271,7 @@ class Theme
$theme = Strings::sanitizeFilePathItem($theme); $theme = Strings::sanitizeFilePathItem($theme);
$a = DI::app(); $a = DI::app();
$base_theme = $a->theme_info['extends'] ?? ''; $base_theme = $a->getThemeInfoValue('extends') ?? '';
if (file_exists("view/theme/$theme/config.php")) { if (file_exists("view/theme/$theme/config.php")) {
return "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. // Replace friendica image url size with theme preference.
if (!empty($a->theme_info['item_image_size'])) { if (!empty($a->getThemeInfoValue('item_image_size'))) {
$ps = $a->theme_info['item_image_size']; $ps = $a->getThemeInfoValue('item_image_size');
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s); $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 = []) public static function rawContent(array $parameters = [])
{ {
$a = DI::app(); $a = DI::app();
if ($a->argc != 2) { if (empty($parameters['item'])) {
throw new \Friendica\Network\HTTPException\BadRequestException(); throw new \Friendica\Network\HTTPException\BadRequestException();
} }
// @TODO: Replace with parameter from router $item_id = intval($parameters['item']);
$item_id = intval($a->argv[1]);
// Check for existence // Check for existence
$item = MAttach::exists(['id' => $item_id]); $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 // 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[] = [ $tabs[] = [
'label' => DI::l10n()->t('Events'), 'label' => DI::l10n()->t('Events'),
'url' => DI::baseUrl() . '/events', 'url' => DI::baseUrl() . '/events',

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -44,12 +44,11 @@ class SaveTag extends BaseModule
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = DI::app();
$logger = DI::logger(); $logger = DI::logger();
$term = XML::unescape(trim($_GET['term'] ?? '')); $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]); $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 // @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; return;
} }

View file

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

View file

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

View file

@ -39,26 +39,24 @@ class Oembed extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = DI::app();
// Unused form: /oembed/b2h?url=... // Unused form: /oembed/b2h?url=...
if ($a->argv[1] == 'b2h') { if (DI::args()->getArgv()[1] == 'b2h') {
$url = ["", trim(hex2bin($_REQUEST['url']))]; $url = ["", trim(hex2bin($_REQUEST['url']))];
echo Content\OEmbed::replaceCallback($url); echo Content\OEmbed::replaceCallback($url);
exit(); exit();
} }
// Unused form: /oembed/h2b?text=... // Unused form: /oembed/h2b?text=...
if ($a->argv[1] == 'h2b') { if (DI::args()->getArgv()[1] == 'h2b') {
$text = trim(hex2bin($_REQUEST['text'])); $text = trim(hex2bin($_REQUEST['text']));
echo Content\OEmbed::HTML2BBCode($text); echo Content\OEmbed::HTML2BBCode($text);
exit(); exit();
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc == 2) { if (DI::args()->getArgc() == 2) {
echo '<html><body>'; echo '<html><body>';
$url = Strings::base64UrlDecode($a->argv[1]); $url = Strings::base64UrlDecode(DI::args()->getArgv()[1]);
$j = Content\OEmbed::fetchURL($url); $j = Content\OEmbed::fetchURL($url);
// workaround for media.ccc.de (and any other endpoint that return size 0) // 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\Network\HTTPException\BadRequestException;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use phpseclib\File\ASN1;
/** /**
* prints the public RSA key of a user * prints the public RSA key of a user
@ -36,15 +35,11 @@ class PublicRSAKey extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = DI::app(); if (empty($parameters['nick'])) {
// @TODO: Replace with parameter from router
if ($app->argc !== 2) {
throw new BadRequestException(); throw new BadRequestException();
} }
// @TODO: Replace with parameter from router $nick = $parameters['nick'];
$nick = $app->argv[1];
$user = User::getByNickname($nick, ['spubkey']); $user = User::getByNickname($nick, ['spubkey']);
if (empty($user) || empty($user['spubkey'])) { if (empty($user) || empty($user['spubkey'])) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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