Merge pull request #1148 from annando/args

Replaced argv/argc with replacement functions
pull/1149/head
Hypolite Petovan 2021-07-26 06:02:02 -04:00 committed by GitHub
commit 2cc453ca52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 127 additions and 106 deletions

View File

@ -181,7 +181,7 @@ function advancedcontentfilter_module() {}
function advancedcontentfilter_init(App $a)
{
if ($a->argc > 1 && $a->argv[1] == 'api') {
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
$slim = new \Slim\App();
require __DIR__ . '/src/middlewares.php';
@ -196,10 +196,10 @@ function advancedcontentfilter_init(App $a)
function advancedcontentfilter_content(App $a)
{
if (!local_user()) {
return Login::form('/' . implode('/', $a->argv));
return Login::form('/' . implode('/', DI::args()->getArgv()));
}
if ($a->argc > 1 && $a->argv[1] == 'help') {
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'help') {
$lang = $a->user['language'];
$default_dir = 'addon/advancedcontentfilter/doc/';

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:15+0100\n"
"POT-Creation-Date: 2021-07-25 13:15+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,32 +17,28 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/middlewares.php:49
msgid "Method not found"
msgstr ""
#: advancedcontentfilter.php:136
#: advancedcontentfilter.php:153
#, php-format
msgid "Filtered by rule: %s"
msgstr ""
#: advancedcontentfilter.php:150 advancedcontentfilter.php:207
#: advancedcontentfilter.php:167 advancedcontentfilter.php:224
msgid "Advanced Content Filter"
msgstr ""
#: advancedcontentfilter.php:206
#: advancedcontentfilter.php:223
msgid "Back to Addon Settings"
msgstr ""
#: advancedcontentfilter.php:208
#: advancedcontentfilter.php:225
msgid "Add a Rule"
msgstr ""
#: advancedcontentfilter.php:209
#: advancedcontentfilter.php:226
msgid "Help"
msgstr ""
#: advancedcontentfilter.php:210
#: advancedcontentfilter.php:227
msgid ""
"Add and manage your personal content filter rules in this screen. Rules have "
"a name and an arbitrary expression that will be matched against post data. "
@ -50,108 +46,112 @@ msgid ""
"the help page."
msgstr ""
#: advancedcontentfilter.php:211
#: advancedcontentfilter.php:228
msgid "Your rules"
msgstr ""
#: advancedcontentfilter.php:212
#: advancedcontentfilter.php:229
msgid ""
"You have no rules yet! Start adding one by clicking on the button above next "
"to the title."
msgstr ""
#: advancedcontentfilter.php:213
#: advancedcontentfilter.php:230
msgid "Disabled"
msgstr ""
#: advancedcontentfilter.php:214
#: advancedcontentfilter.php:231
msgid "Enabled"
msgstr ""
#: advancedcontentfilter.php:215
#: advancedcontentfilter.php:232
msgid "Disable this rule"
msgstr ""
#: advancedcontentfilter.php:216
#: advancedcontentfilter.php:233
msgid "Enable this rule"
msgstr ""
#: advancedcontentfilter.php:217
#: advancedcontentfilter.php:234
msgid "Edit this rule"
msgstr ""
#: advancedcontentfilter.php:218
#: advancedcontentfilter.php:235
msgid "Edit the rule"
msgstr ""
#: advancedcontentfilter.php:219
#: advancedcontentfilter.php:236
msgid "Save this rule"
msgstr ""
#: advancedcontentfilter.php:220
#: advancedcontentfilter.php:237
msgid "Delete this rule"
msgstr ""
#: advancedcontentfilter.php:221
#: advancedcontentfilter.php:238
msgid "Rule"
msgstr ""
#: advancedcontentfilter.php:222
#: advancedcontentfilter.php:239
msgid "Close"
msgstr ""
#: advancedcontentfilter.php:223
#: advancedcontentfilter.php:240
msgid "Add new rule"
msgstr ""
#: advancedcontentfilter.php:224
#: advancedcontentfilter.php:241
msgid "Rule Name"
msgstr ""
#: advancedcontentfilter.php:225
#: advancedcontentfilter.php:242
msgid "Rule Expression"
msgstr ""
#: advancedcontentfilter.php:226
#: advancedcontentfilter.php:243
msgid "Cancel"
msgstr ""
#: advancedcontentfilter.php:293 advancedcontentfilter.php:304
#: advancedcontentfilter.php:315 advancedcontentfilter.php:349
#: advancedcontentfilter.php:378 advancedcontentfilter.php:399
#: advancedcontentfilter.php:310 advancedcontentfilter.php:321
#: advancedcontentfilter.php:332 advancedcontentfilter.php:366
#: advancedcontentfilter.php:395 advancedcontentfilter.php:416
msgid "You must be logged in to use this method"
msgstr ""
#: advancedcontentfilter.php:319 advancedcontentfilter.php:353
#: advancedcontentfilter.php:382
#: advancedcontentfilter.php:336 advancedcontentfilter.php:370
#: advancedcontentfilter.php:399
msgid "Invalid form security token, please refresh the page."
msgstr ""
#: advancedcontentfilter.php:331
#: advancedcontentfilter.php:348
msgid "The rule name and expression are required."
msgstr ""
#: advancedcontentfilter.php:343
#: advancedcontentfilter.php:360
msgid "Rule successfully added"
msgstr ""
#: advancedcontentfilter.php:357 advancedcontentfilter.php:386
#: advancedcontentfilter.php:374 advancedcontentfilter.php:403
msgid "Rule doesn't exist or doesn't belong to you."
msgstr ""
#: advancedcontentfilter.php:372
#: advancedcontentfilter.php:389
msgid "Rule successfully updated"
msgstr ""
#: advancedcontentfilter.php:393
#: advancedcontentfilter.php:410
msgid "Rule successfully deleted"
msgstr ""
#: advancedcontentfilter.php:403
#: advancedcontentfilter.php:420
msgid "Missing argument: guid."
msgstr ""
#: advancedcontentfilter.php:411
#: advancedcontentfilter.php:428
#, php-format
msgid "Unknown post with guid: %s"
msgstr ""
#: src/middlewares.php:49
msgid "Method not found"
msgstr ""

View File

@ -12,6 +12,8 @@ use Friendica\Core\Hook;
use Friendica\DI;
use Friendica\Util\Strings;
global $blockem_words;
function blockem_install()
{
Hook::register('prepare_body_content_filter', 'addon/blockem/blockem.php', 'blockem_prepare_body_content_filter');
@ -141,6 +143,8 @@ function blockem_display_item(App $a, array &$b = null)
function blockem_conversation_start(App $a, array &$b)
{
global $blockem_words;
if (!local_user()) {
return;
}
@ -148,7 +152,7 @@ function blockem_conversation_start(App $a, array &$b)
$words = DI::pConfig()->get(local_user(), 'blockem', 'words');
if ($words) {
$a->data['blockem'] = explode(',', $words);
$blockem_words = explode(',', $words);
}
DI::page()['htmlhead'] .= <<< EOT
@ -171,6 +175,8 @@ EOT;
function blockem_item_photo_menu(App $a, array &$b)
{
global $blockem_words;
if (!local_user() || $b['item']['self']) {
return;
}
@ -178,8 +184,8 @@ function blockem_item_photo_menu(App $a, array &$b)
$blocked = false;
$author = $b['item']['author-link'];
if (!empty($a->data['blockem'])) {
foreach($a->data['blockem'] as $bloke) {
if (!empty($blockem_words)) {
foreach($blockem_words as $bloke) {
if (Strings::compareLink($bloke,$author)) {
$blocked = true;
break;

View File

@ -43,14 +43,14 @@ function buffer_content(App $a)
require_once "mod/settings.php";
settings_init($a);
if (isset($a->argv[1])) {
switch ($a->argv[1]) {
if (isset(DI::args()->getArgv()[1])) {
switch (DI::args()->getArgv()[1]) {
case "connect":
$o = buffer_connect($a);
break;
default:
$o = print_r($a->argv, true);
$o = print_r(DI::args()->getArgv(), true);
break;
}
} else {

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:15+0100\n"
"POT-Creation-Date: 2021-07-25 13:17+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -142,12 +142,12 @@ function catavatar_module() {}
*/
function catavatar_content(App $a)
{
if ($a->argc < 2 || $a->argc > 3) {
if (DI::args()->getArgc() < 2 || DI::args()->getArgc() > 3) {
throw new NotFoundException(); // this should be catched on index and show default "not found" page.
}
if (is_numeric($a->argv[1])) {
$uid = intval($a->argv[1]);
if (is_numeric(DI::args()->getArgv()[1])) {
$uid = intval(DI::args()->getArgv()[1]);
$condition = ['uid' => $uid,
'account_expired' => false, 'account_removed' => false];
$user = DBA::selectFirst('user', ['email'], $condition);
@ -157,15 +157,15 @@ function catavatar_content(App $a)
}
$seed = DI::pConfig()->get($uid, "catavatar", "seed", md5(trim(strtolower($user['email']))));
} elseif (!empty($a->argv[1])) {
$seed = $a->argv[1];
} elseif (!empty(DI::args()->getArgv()[1])) {
$seed = DI::args()->getArgv()[1];
} else {
throw new NotFoundException();
}
$size = 0;
if ($a->argc == 3) {
$size = intval($a->argv[2]);
if (DI::args()->getArgc() == 3) {
$size = intval(DI::args()->getArgv()[2]);
}
// ...Or start generation

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:15+0100\n"
"POT-Creation-Date: 2021-07-25 13:16+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,38 +17,38 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: catavatar.php:48
#: catavatar.php:49
msgid "Use Cat as Avatar"
msgstr ""
#: catavatar.php:49
#: catavatar.php:50
msgid "More Random Cat!"
msgstr ""
#: catavatar.php:50
#: catavatar.php:51
msgid "Reset to email Cat"
msgstr ""
#: catavatar.php:52
#: catavatar.php:53
msgid "Cat Avatar Settings"
msgstr ""
#: catavatar.php:53
#: catavatar.php:54
msgid "Set default profile avatar or randomize the cat."
msgstr ""
#: catavatar.php:78
#: catavatar.php:72
msgid "The cat hadn't found itself."
msgstr ""
#: catavatar.php:87
#: catavatar.php:81
msgid "There was an error, the cat ran away."
msgstr ""
#: catavatar.php:93
#: catavatar.php:87
msgid "Profile Photos"
msgstr ""
#: catavatar.php:108
#: catavatar.php:97
msgid "Meow!"
msgstr ""

View File

@ -18,6 +18,8 @@ use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Util\Strings;
global $forumdirectory_search;
function forumdirectory_install()
{
Hook::register('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
@ -42,13 +44,17 @@ function forumdirectory_init(App $a)
function forumdirectory_post(App $a)
{
global $forumdirectory_search;
if (!empty($_POST['search'])) {
$a->data['search'] = $_POST['search'];
$forumdirectory_search = $_POST['search'];
}
}
function forumdirectory_content(App $a)
{
global $forumdirectory_search;
if ((DI::config()->get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
notice(DI::l10n()->t('Public access denied.') . EOL);
return;
@ -59,8 +65,8 @@ function forumdirectory_content(App $a)
Nav::setSelected('directory');
if (!empty($a->data['search'])) {
$search = Strings::escapeTags(trim($a->data['search']));
if (!empty($forumdirectory_search)) {
$search = Strings::escapeTags(trim($forumdirectory_search));
} else {
$search = (!empty($_GET['search']) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
}
@ -111,7 +117,7 @@ function forumdirectory_content(App $a)
);
if (DBA::isResult($r)) {
if (in_array('small', $a->argv)) {
if (in_array('small', DI::args()->getArgv())) {
$photo = 'thumb';
} else {
$photo = 'photo';

View File

@ -88,11 +88,11 @@ function ifttt_settings_post()
function ifttt_post(App $a)
{
if ($a->argc != 2) {
if (DI::args()->getArgc() != 2) {
return;
}
$nickname = $a->argv[1];
$nickname = DI::args()->getArgv()[1];
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!DBA::isResult($user)) {

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:15+0100\n"
"POT-Creation-Date: 2021-07-25 13:17+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -14,6 +14,9 @@ use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Util\Strings;
global $js_upload_jsonresponse;
global $js_upload_result;
function js_upload_install()
{
Hook::register('photo_upload_form', __FILE__, 'js_upload_form');
@ -42,6 +45,8 @@ function js_upload_form(App $a, array &$b)
function js_upload_post_init(App $a, &$b)
{
global $js_upload_result, $js_upload_jsonresponse;
// list of valid extensions
$allowedExtensions = ['jpeg', 'gif', 'png', 'jpg'];
@ -53,7 +58,7 @@ function js_upload_post_init(App $a, &$b)
$result = $uploader->handleUpload();
// to pass data through iframe you will need to encode all html tags
$a->data['upload_jsonresponse'] = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
$js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
if (isset($result['error'])) {
Logger::log('mod/photos.php: photos_post(): error uploading photo: ' . $result['error'], Logger::DEBUG);
@ -61,12 +66,14 @@ function js_upload_post_init(App $a, &$b)
exit();
}
$a->data['upload_result'] = $result;
$js_upload_result = $result;
}
function js_upload_post_file(App $a, &$b)
{
$result = $a->data['upload_result'];
global $js_upload_result;
$result = $js_upload_result;
$b['src'] = $result['path'];
$b['filename'] = $result['filename'];
@ -76,9 +83,11 @@ function js_upload_post_file(App $a, &$b)
function js_upload_post_end(App $a, &$b)
{
global $js_upload_jsonresponse;
Logger::log('upload_post_end');
if (!empty($a->data['upload_jsonresponse'])) {
echo $a->data['upload_jsonresponse'];
if (!empty($js_upload_jsonresponse)) {
echo $js_upload_jsonresponse;
exit();
}
}

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:15+0100\n"
"POT-Creation-Date: 2021-07-25 13:16+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -82,11 +82,11 @@ msgstr ""
msgid "Save Settings"
msgstr ""
#: pumpio.php:981
#: pumpio.php:983
msgid "status"
msgstr ""
#: pumpio.php:985
#: pumpio.php:987
#, php-format
msgid "%1$s likes %2$s's %3$s"
msgstr ""

View File

@ -58,13 +58,13 @@ function pumpio_content(App $a)
require_once("mod/settings.php");
settings_init($a);
if (isset($a->argv[1])) {
switch ($a->argv[1]) {
if (isset(DI::args()->getArgv()[1])) {
switch (DI::args()->getArgv()[1]) {
case "connect":
$o = pumpio_connect($a);
break;
default:
$o = print_r($a->argv, true);
$o = print_r(DI::args()->getArgv(), true);
break;
}
} else {

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:16+0100\n"
"POT-Creation-Date: 2021-07-25 13:15+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,54 +17,54 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: tumblr.php:39
#: tumblr.php:40
msgid "Permission denied."
msgstr ""
#: tumblr.php:69 tumblr.php:283
#: tumblr.php:70 tumblr.php:284
msgid "Save Settings"
msgstr ""
#: tumblr.php:71
#: tumblr.php:72
msgid "Consumer Key"
msgstr ""
#: tumblr.php:72
#: tumblr.php:73
msgid "Consumer Secret"
msgstr ""
#: tumblr.php:177
#: tumblr.php:178
msgid "You are now authenticated to tumblr."
msgstr ""
#: tumblr.php:178
#: tumblr.php:179
msgid "return to the connector page"
msgstr ""
#: tumblr.php:194
#: tumblr.php:195
msgid "Post to Tumblr"
msgstr ""
#: tumblr.php:224 tumblr.php:228
#: tumblr.php:225 tumblr.php:229
msgid "Tumblr Export"
msgstr ""
#: tumblr.php:232
#: tumblr.php:233
msgid "(Re-)Authenticate your tumblr page"
msgstr ""
#: tumblr.php:236
#: tumblr.php:237
msgid "Enable Tumblr Post Addon"
msgstr ""
#: tumblr.php:242
#: tumblr.php:243
msgid "Post to Tumblr by default"
msgstr ""
#: tumblr.php:263
#: tumblr.php:264
msgid "Post to page:"
msgstr ""
#: tumblr.php:277
#: tumblr.php:278
msgid "You are not authenticated to tumblr"
msgstr ""

View File

@ -41,8 +41,8 @@ function tumblr_content(App $a)
return '';
}
if (isset($a->argv[1])) {
switch ($a->argv[1]) {
if (isset(DI::args()->getArgv()[1])) {
switch (DI::args()->getArgv()[1]) {
case "connect":
$o = tumblr_connect($a);
break;
@ -52,7 +52,7 @@ function tumblr_content(App $a)
break;
default:
$o = print_r($a->argv, true);
$o = print_r(DI::args()->getArgv(), true);
break;
}
} else {

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:16+0100\n"
"POT-Creation-Date: 2021-07-25 13:16+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -317,8 +317,8 @@ function windowsphonepush_content(App $a)
// Login with the specified Network credentials (like in api.php)
windowsphonepush_login($a);
$path = $a->argv[0];
$path2 = $a->argv[1];
$path = DI::args()->getArgv()[0];
$path2 = DI::args()->getArgv()[1];
if ($path == "windowsphonepush") {
switch ($path2) {
case "show_settings":

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-02-01 18:16+0100\n"
"POT-Creation-Date: 2021-07-25 13:16+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -170,7 +170,7 @@ function xmpp_converse(App $a)
return;
}
if (in_array($a->argv[0], ["delegation", "logout"])) {
if (in_array(DI::args()->getArgv()[0], ["delegation", "logout"])) {
$additional_commands = "converse.user.logout();\n";
} else {
$additional_commands = "";