- added missing type-hints
- avoided local variables
- added some documentation
- changed double-quotes to single
This commit is contained in:
Roland Häder 2022-06-30 13:32:13 +02:00
parent c0c15644a3
commit 06b15a6ed0
No known key found for this signature in database
GPG key ID: C82EDE5DDFA0BA77
29 changed files with 191 additions and 204 deletions

View file

@ -83,7 +83,8 @@ function blackout_redirect (App $a, $b)
}
}
function blackout_addon_admin(App $a, &$o) {
function blackout_addon_admin(App $a, string &$o)
{
$mystart = DI::config()->get('blackout','begindate');
if (! is_string($mystart)) { $mystart = 'YYYY-MM-DD hh:mm'; }
$myend = DI::config()->get('blackout','enddate');
@ -110,11 +111,10 @@ function blackout_addon_admin(App $a, &$o) {
'$aboutredirect' => DI::l10n()->t("<strong>Note</strong>: The redirect will be active from the moment you press the submit button. Users currently logged in will <strong>not</strong> be thrown out but can't login again after logging out while the blackout is still in place."),
]);
}
function blackout_addon_admin_post (App $a) {
$begindate = trim($_POST['startdate']);
$enddate = trim($_POST['enddate']);
$url = trim($_POST['rurl']);
DI::config()->set('blackout','begindate',$begindate);
DI::config()->set('blackout','enddate',$enddate);
DI::config()->set('blackout','url',$url);
function blackout_addon_admin_post (App $a)
{
DI::config()->set('blackout', 'begindate', trim($_POST['startdate']));
DI::config()->set('blackout', 'enddate', trim($_POST['enddate']));
DI::config()->set('blackout', 'url', trim($_POST['rurl']));
}

View file

@ -24,7 +24,7 @@ function blockbot_install()
Hook::register('init_1', __FILE__, 'blockbot_init_1');
}
function blockbot_addon_admin(App $a, &$o)
function blockbot_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/blockbot/');

View file

@ -58,7 +58,6 @@ function cookienotice_addon_admin(App $a, &$s)
* handles the post request from the admin panel
*
* @param App $a
*
* @return void
*/
function cookienotice_addon_admin_post(App $a)

View file

@ -212,7 +212,7 @@ function curweather_addon_admin_post(App $a)
}
}
function curweather_addon_admin(App $a, &$o)
function curweather_addon_admin(App $a, string &$o)
{
if (!$a->isSiteAdmin()) {
return;

View file

@ -18,58 +18,63 @@ function geocoordinates_install()
Hook::register('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
}
function geocoordinates_resolve_item(&$item)
function geocoordinates_resolve_item(array &$item)
{
if((!$item["coord"]) || ($item["location"]))
if ((!$item['coord']) || ($item['location'])) {
return;
}
$key = DI::config()->get("geocoordinates", "api_key");
if ($key == "")
$key = DI::config()->get('geocoordinates', 'api_key');
if ($key == '') {
return;
}
$language = DI::config()->get("geocoordinates", "language");
if ($language == "")
$language = "de";
$language = DI::config()->get('geocoordinates', 'language');
if ($language == '') {
$language = 'de';
}
$coords = explode(' ',$item["coord"]);
$coords = explode(' ', $item['coord']);
if (count($coords) < 2)
if (count($coords) < 2) {
return;
}
$coords[0] = round($coords[0], 5);
$coords[1] = round($coords[1], 5);
$result = DI::cache()->get("geocoordinates:".$language.":".$coords[0]."-".$coords[1]);
$result = DI::cache()->get('geocoordinates:' . $language . ':' . $coords[0] . '-' . $coords[1]);
if (!is_null($result)) {
$item["location"] = $result;
$item['location'] = $result;
return;
}
$s = DI::httpClient()->fetch("https://api.opencagedata.com/geocode/v1/json?q=" . $coords[0] . "," . $coords[1] . "&key=" . $key . "&language=" . $language);
$s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
if (!$s) {
Logger::info("API could not be queried");
Logger::info('API could not be queried');
return;
}
$data = json_decode($s);
if ($data->status->code != "200") {
Logger::info("API returned error ".$data->status->code." ".$data->status->message);
if ($data->status->code != '200') {
Logger::info('API returned error ' . $data->status->code . ' ' . $data->status->message);
return;
}
if (($data->total_results == 0) || (count($data->results) == 0)) {
Logger::info("No results found for coordinates ".$item["coord"]);
Logger::info('No results found for coordinates ' . $item['coord']);
return;
}
$item["location"] = $data->results[0]->formatted;
$item['location'] = $data->results[0]->formatted;
Logger::info("Got location for coordinates ".$coords[0]."-".$coords[1].": ".$item["location"]);
Logger::info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
if ($item["location"] != "")
DI::cache()->set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
if ($item['location'] != '') {
DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']);
}
}
function geocoordinates_post_hook(App $a, &$item)
@ -77,10 +82,9 @@ function geocoordinates_post_hook(App $a, &$item)
geocoordinates_resolve_item($item);
}
function geocoordinates_addon_admin(App $a, &$o)
function geocoordinates_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/geocoordinates/");
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/geocoordinates/');
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
@ -91,9 +95,6 @@ function geocoordinates_addon_admin(App $a, &$o)
function geocoordinates_addon_admin_post(App $a)
{
$api_key = trim($_POST['api_key'] ?? '');
DI::config()->set('geocoordinates', 'api_key', $api_key);
$language = trim($_POST['language'] ?? '');
DI::config()->set('geocoordinates', 'language', $language);
DI::config()->set('geocoordinates', 'api_key', trim($_POST['api_key'] ?? ''));
DI::config()->set('geocoordinates', 'language', trim($_POST['language'] ?? ''));
}

View file

@ -62,7 +62,7 @@ function gravatar_lookup(App $a, array &$b)
/**
* Display admin settings for this addon
*/
function gravatar_addon_admin (App $a, &$o)
function gravatar_addon_admin (App $a, string &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/gravatar/" );
@ -113,8 +113,6 @@ function gravatar_addon_admin_post (App $a)
{
BaseModule::checkFormSecurityToken('gravatarsave');
$default_avatar = trim($_POST['avatar'] ?? 'identicon');
$rating = trim($_POST['rating'] ?? 'g');
DI::config()->set('gravatar', 'default_avatar', $default_avatar);
DI::config()->set('gravatar', 'rating', $rating);
DI::config()->set('gravatar', 'default_avatar', trim($_POST['avatar'] ?? 'identicon'));
DI::config()->set('gravatar', 'rating', $rating = trim($_POST['rating'] ?? 'g'));
}

View file

@ -45,7 +45,7 @@ function obfuscate_email (string $s): string
function impressum_footer(App $a, string &$body)
{
$text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum','footer_text')));
$text = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'footer_text')));
if ($text != '') {
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/impressum/impressum.css" media="all" />';
@ -95,22 +95,15 @@ function impressum_show(App $a, string &$body)
function impressum_addon_admin_post (App $a)
{
$owner = trim($_POST['owner'] ?? '');
$ownerprofile = trim($_POST['ownerprofile'] ?? '');
$postal = trim($_POST['postal'] ?? '');
$notes = trim($_POST['notes'] ?? '');
$email = trim($_POST['email'] ?? '');
$footer_text = trim($_POST['footer_text'] ?? '');
DI::config()->set('impressum', 'owner', strip_tags($owner));
DI::config()->set('impressum', 'ownerprofile', strip_tags($ownerprofile));
DI::config()->set('impressum', 'postal', strip_tags($postal));
DI::config()->set('impressum', 'email', strip_tags($email));
DI::config()->set('impressum', 'notes', strip_tags($notes));
DI::config()->set('impressum', 'footer_text', strip_tags($footer_text));
DI::config()->set('impressum', 'owner', strip_tags(trim($_POST['owner'] ?? '')));
DI::config()->set('impressum', 'ownerprofile', strip_tags(trim($_POST['ownerprofile'] ?? '')));
DI::config()->set('impressum', 'postal', strip_tags(trim($_POST['postal'] ?? '')));
DI::config()->set('impressum', 'email', strip_tags(trim($_POST['notes'] ?? '')));
DI::config()->set('impressum', 'notes', strip_tags(trim($_POST['email'] ?? '')));
DI::config()->set('impressum', 'footer_text', strip_tags(trim($_POST['footer_text'] ?? '')));
}
function impressum_addon_admin (App $a, &$o)
function impressum_addon_admin (App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/impressum/' );
$o = Renderer::replaceMacros($t, [

View file

@ -135,7 +135,7 @@ function irc_addon_admin_post (App $a)
DI::config()->set('irc', 'sitechats', trim($_POST['sitechats']));
}
}
function irc_addon_admin (App $a, &$o) {
function irc_addon_admin (App $a, string &$o) {
$sitechats = DI::config()->get('irc', 'sitechats'); /* popular channels */
$autochans = DI::config()->get('irc', 'autochans'); /* auto connect chans */
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/irc/' );

View file

@ -110,7 +110,7 @@ function keycloakpassword_admin_input($key, $label, $description)
];
}
function keycloakpassword_addon_admin(App $a, &$o)
function keycloakpassword_addon_admin(App $a, string &$o)
{
$form =
keycloakpassword_admin_input(

View file

@ -57,9 +57,9 @@ function libravatar_lookup(array $a, array &$b)
/**
* Display admin settings for this addon
*/
function libravatar_addon_admin(App $a, &$o)
function libravatar_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/libravatar");
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/libravatar');
$default_avatar = DI::config()->get('libravatar', 'default_avatar', 'identicon');
@ -90,6 +90,5 @@ function libravatar_addon_admin(App $a, &$o)
*/
function libravatar_addon_admin_post(App $a)
{
$default_avatar = trim($_POST['avatar'] ?? 'identicon');
DI::config()->set('libravatar', 'default_avatar', $default_avatar);
DI::config()->set('libravatar', 'default_avatar', trim($_POST['avatar'] ?? 'identicon'));
}

View file

@ -80,7 +80,8 @@ function mailstream_addon_admin(App $a, string &$o)
DI::l10n()->t('Email address that stream items will appear to be from.')];
$o .= Renderer::replaceMacros($template, [
'$frommail' => $config,
'$submit' => DI::l10n()->t('Save Settings')]);
'$submit' => DI::l10n()->t('Save Settings')
]);
}
/**
@ -101,7 +102,7 @@ function mailstream_addon_admin_post()
*
* @return string the created message ID
*/
function mailstream_generate_id($uri)
function mailstream_generate_id(string $uri): string
{
$host = DI::baseUrl()->getHostname();
$resource = hash('md5', $uri);
@ -110,7 +111,7 @@ function mailstream_generate_id($uri)
return $message_id;
}
function mailstream_send_hook(App $a, $data)
function mailstream_send_hook(App $a, array $data)
{
$criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']);
$item = Post::selectFirst([], $criteria);
@ -140,8 +141,9 @@ function mailstream_send_hook(App $a, $data)
*
* @param App $a App object (unused)
* @param array $item content of the item (may or may not already be stored in the item table)
* @return void
*/
function mailstream_post_hook(App $a, &$item)
function mailstream_post_hook(App $a, array &$item)
{
mailstream_check_version();
@ -174,11 +176,13 @@ function mailstream_post_hook(App $a, &$item)
$message_id = mailstream_generate_id($item['uri']);
$send_hook_data = array('uid' => $item['uid'],
$send_hook_data = [
'uid' => $item['uid'],
'contact-id' => $item['contact-id'],
'uri' => $item['uri'],
'message_id' => $message_id,
'tries' => 0);
'tries' => 0,
];
Hook::fork(PRIORITY_LOW, 'mailstream_send_hook', $send_hook_data);
}
@ -193,25 +197,30 @@ function mailstream_post_hook(App $a, &$item)
*
* @return array new value of the attachments table (results are also stored in the reference parameter)
*/
function mailstream_do_images(&$item, &$attachments)
function mailstream_do_images(arrat &$item, array &$attachments)
{
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) {
return;
}
$attachments = [];
preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1);
preg_match_all("/\[img\](.*?)\[\/img\]/ism", $item["body"], $matches2);
preg_match_all("/\[img\=([^\]]*)\]([^[]*)\[\/img\]/ism", $item["body"], $matches3);
foreach (array_merge($matches1[3], $matches2[1], $matches3[1]) as $url) {
$components = parse_url($url);
if (!$components) {
continue;
}
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-');
$curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar);
$attachments[$url] = [
'data' => $curlResult->getBody(),
'guid' => hash("crc32", $url),
'guid' => hash('crc32', $url),
'filename' => basename($components['path']),
'type' => $curlResult->getContentType()
];
@ -221,6 +230,7 @@ function mailstream_do_images(&$item, &$attachments)
continue;
}
}
return $attachments;
}
@ -231,7 +241,7 @@ function mailstream_do_images(&$item, &$attachments)
*
* @return string sender suitable for use in the email
*/
function mailstream_sender($item)
function mailstream_sender(array $item): string
{
$contact = Contact::getById($item['contact-id']);
if (DBA::isResult($contact)) {
@ -249,7 +259,7 @@ function mailstream_sender($item)
*
* @return string plaintext subject line
*/
function mailstream_decode_subject($subject)
function mailstream_decode_subject(string $subject): string
{
$html = BBCode::convert($subject);
if (!$html) {
@ -264,7 +274,7 @@ function mailstream_decode_subject($subject)
return $notags;
}
$nocodes = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
return mb_convert_encoding($m[1], 'UTF-8', 'HTML-ENTITIES');
}, $noentity);
if (!$nocodes) {
return $noentity;
@ -283,7 +293,7 @@ function mailstream_decode_subject($subject)
*
* @return string subject line suitable for use in the email
*/
function mailstream_subject($item)
function mailstream_subject(array $item): string
{
if ($item['title']) {
return mailstream_decode_subject($item['title']);
@ -345,11 +355,11 @@ function mailstream_subject($item)
*
* @return bool True if this message has been completed. False if it should be retried.
*/
function mailstream_send($message_id, $item, $user)
function mailstream_send(string $message_id, array $item, array $user): bool
{
if (!is_array($item)) {
Logger::error('mailstream_send item is empty', ['message_id' => $message_id]);
return;
return false;
}
if (!$item['visible']) {
@ -361,19 +371,20 @@ function mailstream_send($message_id, $item, $user)
'user email' => $user['email']]);
return true;
}
require_once(dirname(__file__).'/phpmailer/class.phpmailer.php');
require_once (dirname(__file__) . '/phpmailer/class.phpmailer.php');
$attachments = [];
mailstream_do_images($item, $attachments);
$frommail = DI::config()->get('mailstream', 'frommail');
if ($frommail == "") {
if ($frommail == '') {
$frommail = 'friendica@localhost.local';
}
$address = DI::pConfig()->get($item['uid'], 'mailstream', 'address');
if (!$address) {
$address = $user['email'];
}
$mail = new PHPmailer;
$mail = new PHPmailer();
try {
$mail->XMailer = 'Friendica Mailstream Addon';
$mail->SetFrom($frommail, mailstream_sender($item));
@ -428,7 +439,7 @@ function mailstream_send($message_id, $item, $user)
*
* @param string $text text to word wrap - modified in-place
*/
function mailstream_html_wrap(&$text)
function mailstream_html_wrap(string &$text): string
{
$lines = str_split($text, 200);
for ($i = 0; $i < count($lines); $i++) {
@ -514,6 +525,7 @@ function mailstream_addon_settings(App &$a, array &$data)
* Process data submitted to user's mailstream features form
* @param App $a
* @param array $post POST data
* @return void
*/
function mailstream_addon_settings_post(App $a, array $post)
{

View file

@ -50,7 +50,7 @@ function mathjax_settings(App $a, array &$data)
];
}
function mathjax_footer(App $a, string &$b)
function mathjax_footer(App $a, string &$body)
{
// if the visitor of the page is not a local_user, use MathJax
// otherwise check the users settings.

View file

@ -48,24 +48,21 @@ function newmemberwidget_network_mod_init (App $a, $b)
function newmemberwidget_addon_admin_post(App $a)
{
$ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : "");
$lsn = trim($_POST['localsupportname'] ?? '');
$gs = intval($_POST['linkglobalsupport']);
$ls = intval($_POST['linklocalsupport']);
DI::config()->set('newmemberwidget', 'freetext', trim($ft));
DI::config()->set('newmemberwidget', 'linkglobalsupport', $gs);
DI::config()->set('newmemberwidget', 'linklocalsupport', $ls);
DI::config()->set('newmemberwidget', 'localsupport', trim($lsn));
DI::config()->set('newmemberwidget', 'freetext', (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""));
DI::config()->set('newmemberwidget', 'linkglobalsupport', intval($_POST['linkglobalsupport']));
DI::config()->set('newmemberwidget', 'linklocalsupport', intval($_POST['linklocalsupport']));
DI::config()->set('newmemberwidget', 'localsupport', trim($_POST['localsupportname'] ?? ''));
}
function newmemberwidget_addon_admin(App $a, &$o)
function newmemberwidget_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/newmemberwidget');
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$freetext' => [ "freetext", DI::l10n()->t("Message"), DI::config()->get("newmemberwidget", "freetext"), DI::l10n()->t("Your message for new members. You can use bbcode here.")],
'$linkglobalsupport' => [ "linkglobalsupport", DI::l10n()->t('Add a link to global support forum'), DI::config()->get('newmemberwidget', 'linkglobalsupport'), DI::l10n()->t('Should a link to the global support forum be displayed?')." (<a href='https://forum.friendi.ca/profile/helpers'>@helpers</a>)"],
'$linklocalsupport' => [ "linklocalsupport", DI::l10n()->t('Add a link to the local support forum'), DI::config()->get('newmemberwidget', 'linklocalsupport'), DI::l10n()->t('If you have a local support forum and want to have a link displayed in the widget, check this box.')],
'$localsupportname' => [ "localsupportname", DI::l10n()->t('Name of the local support group'), DI::config()->get('newmemberwidget', 'localsupport'), DI::l10n()->t('If you checked the above, specify the <em>nickname</em> of the local support group here (i.e. helpers)')],
'$freetext' => ["freetext", DI::l10n()->t("Message"), DI::config()->get("newmemberwidget", "freetext"), DI::l10n()->t("Your message for new members. You can use bbcode here.")],
'$linkglobalsupport' => ["linkglobalsupport", DI::l10n()->t('Add a link to global support forum'), DI::config()->get('newmemberwidget', 'linkglobalsupport'), DI::l10n()->t('Should a link to the global support forum be displayed?')." (<a href='https://forum.friendi.ca/profile/helpers'>@helpers</a>)"],
'$linklocalsupport' => ["linklocalsupport", DI::l10n()->t('Add a link to the local support forum'), DI::config()->get('newmemberwidget', 'linklocalsupport'), DI::l10n()->t('If you have a local support forum and want to have a link displayed in the widget, check this box.')],
'$localsupportname' => ["localsupportname", DI::l10n()->t('Name of the local support group'), DI::config()->get('newmemberwidget', 'localsupport'), DI::l10n()->t('If you checked the above, specify the <em>nickname</em> of the local support group here (i.e. helpers)')],
]);
}

View file

@ -37,14 +37,13 @@ function nitter_install()
*/
function nitter_addon_admin_post(App $a)
{
$nitterserver = rtrim(trim($_POST['nitterserver']),'/');
DI::config()->set('nitter', 'server', $nitterserver);
DI::config()->set('nitter', 'server', rtrim(trim($_POST['nitterserver']), '/'));
}
/* Hook into the admin settings to let the admin choose a
* nitter server to use for the replacement.
*/
function nitter_addon_admin(App $a, &$o)
function nitter_addon_admin(App $a, string &$o)
{
$nitterserver = DI::config()->get('nitter', 'server');
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nitter/');
@ -58,20 +57,20 @@ function nitter_addon_admin(App $a, &$o)
/*
* replace "twitter.com" with "nitter.net"
*/
function nitter_render(App $a, &$o)
function nitter_render(App $a, array &$b)
{
// this needs to be a system setting
$replaced = false;
$nitter = DI::config()->get('nitter', 'server', 'https://nitter.net');
if (strstr($o['html'], 'https://mobile.twitter.com')) {
$o['html'] = str_replace('https://mobile.twitter.com', $nitter, $o['html']);
if (strstr($b['html'], 'https://mobile.twitter.com')) {
$b['html'] = str_replace('https://mobile.twitter.com', $nitter, $b['html']);
$replaced = true;
}
if (strstr($o['html'], 'https://twitter.com')) {
$o['html'] = str_replace('https://twitter.com', $nitter, $o['html']);
if (strstr($b['html'], 'https://twitter.com')) {
$b['html'] = str_replace('https://twitter.com', $nitter, $b['html']);
$replaced = true;
}
if ($replaced) {
$o['html'] .= '<hr><p>' . DI::l10n()->t('In an attempt to protect your privacy, links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '</p>';
$b['html'] .= '<hr><p>' . DI::l10n()->t('In an attempt to protect your privacy, links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '</p>';
}
}

View file

@ -18,7 +18,7 @@ function nominatim_install()
Hook::register('post_remote', 'addon/nominatim/nominatim.php', 'nominatim_post_hook');
}
function nominatim_resolve_item(&$item)
function nominatim_resolve_item(array &$item)
{
if(empty($item['coord']) || !empty($item['location'])) {
return;
@ -65,12 +65,12 @@ function nominatim_resolve_item(&$item)
}
}
function nominatim_post_hook(App $a, &$item)
function nominatim_post_hook(App $a, array &$item)
{
nominatim_resolve_item($item);
}
function nominatim_addon_admin(App $a, &$o)
function nominatim_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nominatim/');
@ -83,6 +83,5 @@ function nominatim_addon_admin(App $a, &$o)
function nominatim_addon_admin_post(App $a)
{
$language = !empty($_POST['language']) ? trim($_POST['language']) : '';
DI::config()->set('nominatim', 'language', $language);
DI::config()->set('nominatim', 'language', (!empty($_POST['language']) ? trim($_POST['language']) : ''));
}

View file

@ -22,7 +22,7 @@ use Friendica\DI;
*/
function notifyall_module() {}
function notifyall_addon_admin(App $a, &$o)
function notifyall_addon_admin(App $a, string &$o)
{
$o = '<div></div>&nbsp;&nbsp;&nbsp;&nbsp;<a href="' . DI::baseUrl()->get() . '/notifyall">' . DI::l10n()->t('Send email to all members') . '</a></br/>';
}

View file

@ -79,7 +79,7 @@ function openstreetmap_location(App $a, &$item)
$nomserver = OSM_NOM;
}
if ($item['coord'] != "") {
if ($item['coord'] != '') {
$coords = explode(' ', $item['coord']);
if (count($coords) > 1) {
$lat = urlencode(round($coords[0], 5));
@ -96,13 +96,13 @@ function openstreetmap_location(App $a, &$item)
$target = $nomserver.'?q='.urlencode($item['location']);
}
if ($item['location'] != "") {
if ($item['location'] != '') {
$title = $item['location'];
} else {
$title = $item['coord'];
}
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
$item['html'] = '<a target="map" title="' . $title . '" href= "' . $target . '">' . $title . '</a>';
}
function openstreetmap_get_coordinates(App $a, array &$b)
@ -116,7 +116,7 @@ function openstreetmap_get_coordinates(App $a, array &$b)
$args = '?q=' . urlencode($b['location']) . '&format=json';
$cachekey = "openstreetmap:" . $b['location'];
$cachekey = 'openstreetmap:' . $b['location'];
$j = DI::cache()->get($cachekey);
if (is_null($j)) {
@ -178,9 +178,9 @@ function openstreetmap_generate_map(App $a, array &$b)
Logger::debug('generate_map: ' . $b['html']);
}
function openstreetmap_addon_admin(App $a, &$o)
function openstreetmap_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/openstreetmap/");
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/openstreetmap/');
$tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
$nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
$zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM);
@ -202,13 +202,8 @@ function openstreetmap_addon_admin(App $a, &$o)
function openstreetmap_addon_admin_post(App $a)
{
$urltms = ($_POST['tmsserver'] ?? '') ?: OSM_TMS;
$urlnom = ($_POST['nomserver'] ?? '') ?: OSM_NOM;
$zoom = ($_POST['zoom'] ?? '') ?: OSM_ZOOM;
$marker = ($_POST['marker'] ?? '') ?: OSM_MARKER;
DI::config()->set('openstreetmap', 'tmsserver', $urltms);
DI::config()->set('openstreetmap', 'nomserver', $urlnom);
DI::config()->set('openstreetmap', 'zoom', $zoom);
DI::config()->set('openstreetmap', 'marker', $marker);
DI::config()->set('openstreetmap', 'tmsserver', ($_POST['tmsserver'] ?? '') ?: OSM_TMS);
DI::config()->set('openstreetmap', 'nomserver', ($_POST['nomserver'] ?? '') ?: OSM_NOM);
DI::config()->set('openstreetmap', 'zoom', ($_POST['zoom'] ?? '') ?: OSM_ZOOM);
DI::config()->set('openstreetmap', 'marker', ($_POST['marker'] ?? '') ?: OSM_MARKER);
}

View file

@ -54,7 +54,7 @@ function pageheader_addon_admin_post(App $a)
function pageheader_fetch(App $a, string &$b)
{
if(file_exists('pageheader.html')){
if (file_exists('pageheader.html')) {
$s = file_get_contents('pageheader.html');
} else {
$s = DI::config()->get('pageheader', 'text');

View file

@ -91,8 +91,10 @@ function piwik_analytics(App $a, array &$b)
$b .= "</div>";
}
}
function piwik_addon_admin (App $a, &$o) {
function piwik_addon_admin (App $a, string &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/piwik/" );
$o = Renderer::replaceMacros( $t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$piwikbaseurl' => ['baseurl', DI::l10n()->t('Matomo (Piwik) Base URL'), DI::config()->get('piwik','baseurl' ), DI::l10n()->t('Absolute path to your Matomo (Piwik) installation. (without protocol (http/s), with trailing slash)')],
@ -101,13 +103,11 @@ function piwik_addon_admin (App $a, &$o) {
'$async' => ['async', DI::l10n()->t('Asynchronous tracking'), DI::config()->get('piwik','async' ), ''],
]);
}
function piwik_addon_admin_post (App $a) {
$url = trim($_POST['baseurl'] ?? '');
$id = trim($_POST['siteid'] ?? '');
$optout = trim($_POST['optout'] ?? '');
$async = trim($_POST['async'] ?? '');
DI::config()->set('piwik', 'baseurl', $url);
DI::config()->set('piwik', 'siteid', $id);
DI::config()->set('piwik', 'optout', $optout);
DI::config()->set('piwik', 'async', $async);
function piwik_addon_admin_post(App $a)
{
DI::config()->set('piwik', 'baseurl', trim($_POST['baseurl'] ?? ''));
DI::config()->set('piwik', 'siteid', trim($_POST['siteid'] ?? ''));
DI::config()->set('piwik', 'optout', trim($_POST['optout'] ?? ''));
DI::config()->set('piwik', 'async', trim($_POST['async'] ?? ''));
}

View file

@ -125,29 +125,24 @@ function public_server_login(App $a, $b)
function public_server_addon_admin_post(App $a)
{
BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver');
$expiredays = trim($_POST['expiredays'] ?? '');
$expireposts = trim($_POST['expireposts'] ?? '');
$nologin = trim($_POST['nologin'] ?? '');
$flagusers = trim($_POST['flagusers'] ?? '');
$flagposts = trim($_POST['flagposts'] ?? '');
$flagpostsexpire = trim($_POST['flagpostsexpire'] ?? '');
DI::config()->set('public_server', 'expiredays', $expiredays);
DI::config()->set('public_server', 'expireposts', $expireposts);
DI::config()->set('public_server', 'nologin', $nologin);
DI::config()->set('public_server', 'flagusers', $flagusers);
DI::config()->set('public_server', 'flagposts', $flagposts);
DI::config()->set('public_server', 'flagpostsexpire', $flagpostsexpire);
DI::config()->set('public_server', 'expiredays', trim($_POST['expiredays'] ?? ''));
DI::config()->set('public_server', 'expireposts', trim($_POST['expireposts'] ?? ''));
DI::config()->set('public_server', 'nologin', trim($_POST['nologin'] ?? ''));
DI::config()->set('public_server', 'flagusers', trim($_POST['flagusers'] ?? ''));
DI::config()->set('public_server', 'flagposts', trim($_POST['flagposts'] ?? ''));
DI::config()->set('public_server', 'flagpostsexpire', trim($_POST['flagpostsexpire'] ?? ''));
}
function public_server_addon_admin(App $a, &$o)
function public_server_addon_admin(App $a, string &$o)
{
$token = BaseModule::getFormSecurityToken("publicserver");
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/public_server");
$token = BaseModule::getFormSecurityToken('publicserver');
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/public_server');
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$form_security_token' => $token,
'$infotext' => DI::l10n()->t('Set any of these options to 0 to deactivate it.'),
'$expiredays' => ["expiredays","Expire Days", intval(DI::config()->get('public_server', 'expiredays')), "When an account is created on the site, it is given a hard "],
'$expiredays' => ["expiredays", "Expire Days", intval(DI::config()->get('public_server', 'expiredays')), "When an account is created on the site, it is given a hard "],
'$expireposts' => ["expireposts", "Expire Posts", intval(DI::config()->get('public_server', 'expireposts')), "Set the default days for posts to expire here"],
'$nologin' => ["nologin", "No Login", intval(DI::config()->get('public_server', 'nologin')), "Remove users who have never logged in after nologin days "],
'$flagusers' => ["flagusers", "Flag users", intval(DI::config()->get('public_server', 'flagusers')), "Remove users who last logged in over flagusers days ago"],

View file

@ -31,7 +31,7 @@ function qcomment_install()
Hook::register('footer' , __FILE__, 'qcomment_footer');
}
function qcomment_footer(App $a, string &$b)
function qcomment_footer(App $a, string &$body)
{
DI::page()->registerFooterScript('addon/qcomment/qcomment.js');
}
@ -57,7 +57,7 @@ function qcomment_addon_settings(App &$a, array &$data)
];
}
function qcomment_addon_settings_post(App $a, array &$b)
function qcomment_addon_settings_post(App $a, array &$body)
{
if (!local_user()) {
return;

View file

@ -26,7 +26,7 @@ function rendertime_init_1(App $a)
{
}
function rendertime_addon_admin(App $a, &$o)
function rendertime_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/rendertime/");
@ -47,9 +47,8 @@ function rendertime_addon_admin_post(App $a)
* @param App $a
* @param string $o
*/
function rendertime_page_end(App $a, &$o)
function rendertime_page_end(App $a, string &$o)
{
$profiler = DI::profiler();
$duration = microtime(true) - $profiler->get('start');

View file

@ -26,7 +26,7 @@ function saml_module($a)
{
}
function saml_init($a)
function saml_init(App $a)
{
if (DI::args()->getArgc() < 2) {
return;
@ -80,15 +80,15 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer');
}
function saml_head(App $a, string &$b)
function saml_head(App $a, string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/saml.css');
}
function saml_footer(App $a, string &$b)
function saml_footer(App $a, string &$body)
{
$fragment = addslashes(BBCode::convert(DI::config()->get('saml', 'settings_statement')));
$b .= <<<EOL
$body .= <<<EOL
<script>
var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); }
@ -125,7 +125,7 @@ function saml_sso_initiate(App $a, array &$b)
exit();
}
function saml_sso_reply($a)
function saml_sso_reply(App $a)
{
$auth = new \OneLogin\Saml2\Auth(saml_settings());
$requestID = null;
@ -225,7 +225,7 @@ function saml_input($key, $label, $description)
];
}
function saml_addon_admin(App $a, &$o)
function saml_addon_admin(App $a, string &$o)
{
$form =
saml_input(

View file

@ -24,12 +24,12 @@ function showmore_dyn_install()
Hook::register('addon_settings_post', __FILE__, 'showmore_dyn_settings_post');
}
function showmore_dyn_head(App $a, string &$b)
function showmore_dyn_head(App $a, string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/showmore_dyn.css');
}
function showmore_dyn_footer(App $a, string &$b)
function showmore_dyn_footer(App $a, string &$body)
{
DI::page()->registerFooterScript(__DIR__ . '/showmore_dyn.js');
}

View file

@ -628,7 +628,7 @@ function statusnet_addon_admin_post(App $a)
$sites = DI::config()->set('statusnet', 'sites', $sites);
}
function statusnet_addon_admin(App $a, &$o)
function statusnet_addon_admin(App $a, string &$o)
{
$sites = DI::config()->get('statusnet', 'sites');
$sitesform = [];

View file

@ -64,7 +64,7 @@ function tumblr_content(App $a)
return $o;
}
function tumblr_addon_admin(App $a, &$o)
function tumblr_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/tumblr/" );
@ -78,11 +78,8 @@ function tumblr_addon_admin(App $a, &$o)
function tumblr_addon_admin_post(App $a)
{
$consumer_key = trim($_POST['consumer_key'] ?? '');
$consumer_secret = trim($_POST['consumer_secret'] ?? '');
DI::config()->set('tumblr', 'consumer_key',$consumer_key);
DI::config()->set('tumblr', 'consumer_secret',$consumer_secret);
DI::config()->set('tumblr', 'consumer_key', trim($_POST['consumer_key'] ?? ''));
DI::config()->set('tumblr', 'consumer_secret', trim($_POST['consumer_secret'] ?? ''));
}
function tumblr_connect(App $a)
@ -99,7 +96,7 @@ function tumblr_connect(App $a)
// The callback URL is the script that gets called after the user authenticates with tumblr
// In this example, it would be the included callback.php
$callback_url = DI::baseUrl()->get()."/tumblr/callback";
$callback_url = DI::baseUrl()->get() . '/tumblr/callback';
// Let's begin. First we need a Request Token. The request token is required to send the user
// to Tumblr's login page.
@ -174,8 +171,8 @@ function tumblr_callback(App $a)
}
// What's next? Now that we have an Access Token and Secret, we can make an API call.
DI::pConfig()->set(local_user(), "tumblr", "oauth_token", $access_token['oauth_token']);
DI::pConfig()->set(local_user(), "tumblr", "oauth_token_secret", $access_token['oauth_token_secret']);
DI::pConfig()->set(local_user(), 'tumblr', 'oauth_token', $access_token['oauth_token']);
DI::pConfig()->set(local_user(), 'tumblr', 'oauth_token_secret', $access_token['oauth_token_secret']);
$o = DI::l10n()->t("You are now authenticated to tumblr.");
$o .= '<br /><a href="' . DI::baseUrl()->get() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>';

View file

@ -903,13 +903,11 @@ function twitter_delete_item(array $item)
function twitter_addon_admin_post(App $a)
{
$consumerkey = trim($_POST['consumerkey'] ?? '');
$consumersecret = trim($_POST['consumersecret'] ?? '');
DI::config()->set('twitter', 'consumerkey', $consumerkey);
DI::config()->set('twitter', 'consumersecret', $consumersecret);
DI::config()->set('twitter', 'consumerkey', trim($_POST['consumerkey'] ?? ''));
DI::config()->set('twitter', 'consumersecret', trim($_POST['consumersecret'] ?? ''));
}
function twitter_addon_admin(App $a, &$o)
function twitter_addon_admin(App $a, string &$o)
{
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/twitter/');

View file

@ -11,12 +11,14 @@ use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
function viewsrc_install() {
function viewsrc_install()
{
Hook::register('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
Hook::register('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
}
function viewsrc_page_end(App $a, &$o){
function viewsrc_page_end(App $a, string &$o)
{
DI::page()['htmlhead'] .= <<< EOS
<script>
$(function(){

View file

@ -21,19 +21,23 @@ function webrtc_app_menu(App $a, array &$b)
$b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
}
function webrtc_addon_admin (App $a, &$o)
function webrtc_addon_admin (App $a, string &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
$o = Renderer::replaceMacros( $t, [
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/webrtc/' );
$o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$webrtcurl' => ['webrtcurl', DI::l10n()->t('WebRTC Base URL'), DI::config()->get('webrtc','webrtcurl' ), DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')],
'$webrtcurl' => [
'webrtcurl',
DI::l10n()->t('WebRTC Base URL'),
DI::config()->get('webrtc','webrtcurl' ),
DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .'),
],
]);
}
function webrtc_addon_admin_post (App $a)
{
$url = trim($_POST['webrtcurl'] ?? '');
DI::config()->set('webrtc', 'webrtcurl', $url);
DI::config()->set('webrtc', 'webrtcurl', trim($_POST['webrtcurl'] ?? ''));
}
/**
@ -43,7 +47,7 @@ function webrtc_addon_admin_post (App $a)
*/
function webrtc_module() {}
function webrtc_content(App $a)
function webrtc_content(App $a): string
{
$o = '';