- added missing type-hints
- avoided local variables
- added some documentation
- changed double-quotes to single
pull/1269/head
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'); $mystart = DI::config()->get('blackout','begindate');
if (! is_string($mystart)) { $mystart = 'YYYY-MM-DD hh:mm'; } if (! is_string($mystart)) { $mystart = 'YYYY-MM-DD hh:mm'; }
$myend = DI::config()->get('blackout','enddate'); $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."), '$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']); function blackout_addon_admin_post (App $a)
$enddate = trim($_POST['enddate']); {
$url = trim($_POST['rurl']); DI::config()->set('blackout', 'begindate', trim($_POST['startdate']));
DI::config()->set('blackout','begindate',$begindate); DI::config()->set('blackout', 'enddate', trim($_POST['enddate']));
DI::config()->set('blackout','enddate',$enddate); DI::config()->set('blackout', 'url', trim($_POST['rurl']));
DI::config()->set('blackout','url',$url);
} }

View File

@ -24,7 +24,7 @@ function blockbot_install()
Hook::register('init_1', __FILE__, 'blockbot_init_1'); 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/'); $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 * handles the post request from the admin panel
* *
* @param App $a * @param App $a
*
* @return void * @return void
*/ */
function cookienotice_addon_admin_post(App $a) 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()) { if (!$a->isSiteAdmin()) {
return; return;

View File

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

View File

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

View File

@ -45,7 +45,7 @@ function obfuscate_email (string $s): string
function impressum_footer(App $a, string &$body) 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 != '') { if ($text != '') {
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/impressum/impressum.css" media="all" />'; 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) function impressum_addon_admin_post (App $a)
{ {
$owner = trim($_POST['owner'] ?? ''); DI::config()->set('impressum', 'owner', strip_tags(trim($_POST['owner'] ?? '')));
$ownerprofile = trim($_POST['ownerprofile'] ?? ''); DI::config()->set('impressum', 'ownerprofile', strip_tags(trim($_POST['ownerprofile'] ?? '')));
$postal = trim($_POST['postal'] ?? ''); DI::config()->set('impressum', 'postal', strip_tags(trim($_POST['postal'] ?? '')));
$notes = trim($_POST['notes'] ?? ''); DI::config()->set('impressum', 'email', strip_tags(trim($_POST['notes'] ?? '')));
$email = trim($_POST['email'] ?? ''); DI::config()->set('impressum', 'notes', strip_tags(trim($_POST['email'] ?? '')));
$footer_text = trim($_POST['footer_text'] ?? ''); DI::config()->set('impressum', 'footer_text', strip_tags(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));
} }
function impressum_addon_admin (App $a, &$o) function impressum_addon_admin (App $a, string &$o)
{ {
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/impressum/' ); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/impressum/' );
$o = Renderer::replaceMacros($t, [ $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'])); 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 */ $sitechats = DI::config()->get('irc', 'sitechats'); /* popular channels */
$autochans = DI::config()->get('irc', 'autochans'); /* auto connect chans */ $autochans = DI::config()->get('irc', 'autochans'); /* auto connect chans */
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/irc/' ); $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 = $form =
keycloakpassword_admin_input( keycloakpassword_admin_input(

View File

@ -57,9 +57,9 @@ function libravatar_lookup(array $a, array &$b)
/** /**
* Display admin settings for this addon * 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'); $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) function libravatar_addon_admin_post(App $a)
{ {
$default_avatar = trim($_POST['avatar'] ?? 'identicon'); DI::config()->set('libravatar', 'default_avatar', trim($_POST['avatar'] ?? 'identicon'));
DI::config()->set('libravatar', 'default_avatar', $default_avatar);
} }

View File

@ -75,12 +75,13 @@ function mailstream_addon_admin(App $a, string &$o)
$frommail = DI::config()->get('mailstream', 'frommail'); $frommail = DI::config()->get('mailstream', 'frommail');
$template = Renderer::getMarkupTemplate('admin.tpl', 'addon/mailstream/'); $template = Renderer::getMarkupTemplate('admin.tpl', 'addon/mailstream/');
$config = ['frommail', $config = ['frommail',
DI::l10n()->t('From Address'), DI::l10n()->t('From Address'),
$frommail, $frommail,
DI::l10n()->t('Email address that stream items will appear to be from.')]; DI::l10n()->t('Email address that stream items will appear to be from.')];
$o .= Renderer::replaceMacros($template, [ $o .= Renderer::replaceMacros($template, [
'$frommail' => $config, '$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 * @return string the created message ID
*/ */
function mailstream_generate_id($uri) function mailstream_generate_id(string $uri): string
{ {
$host = DI::baseUrl()->getHostname(); $host = DI::baseUrl()->getHostname();
$resource = hash('md5', $uri); $resource = hash('md5', $uri);
@ -110,7 +111,7 @@ function mailstream_generate_id($uri)
return $message_id; 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']); $criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']);
$item = Post::selectFirst([], $criteria); $item = Post::selectFirst([], $criteria);
@ -140,8 +141,9 @@ function mailstream_send_hook(App $a, $data)
* *
* @param App $a App object (unused) * @param App $a App object (unused)
* @param array $item content of the item (may or may not already be stored in the item table) * @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(); mailstream_check_version();
@ -174,11 +176,13 @@ function mailstream_post_hook(App $a, &$item)
$message_id = mailstream_generate_id($item['uri']); $message_id = mailstream_generate_id($item['uri']);
$send_hook_data = array('uid' => $item['uid'], $send_hook_data = [
'contact-id' => $item['contact-id'], 'uid' => $item['uid'],
'uri' => $item['uri'], 'contact-id' => $item['contact-id'],
'message_id' => $message_id, 'uri' => $item['uri'],
'tries' => 0); 'message_id' => $message_id,
'tries' => 0,
];
Hook::fork(PRIORITY_LOW, 'mailstream_send_hook', $send_hook_data); 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) * @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')) { if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) {
return; return;
} }
$attachments = []; $attachments = [];
preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1); 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"], $matches2);
preg_match_all("/\[img\=([^\]]*)\]([^[]*)\[\/img\]/ism", $item["body"], $matches3); preg_match_all("/\[img\=([^\]]*)\]([^[]*)\[\/img\]/ism", $item["body"], $matches3);
foreach (array_merge($matches1[3], $matches2[1], $matches3[1]) as $url) { foreach (array_merge($matches1[3], $matches2[1], $matches3[1]) as $url) {
$components = parse_url($url); $components = parse_url($url);
if (!$components) { if (!$components) {
continue; continue;
} }
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-'); $cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-');
$curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar); $curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar);
$attachments[$url] = [ $attachments[$url] = [
'data' => $curlResult->getBody(), 'data' => $curlResult->getBody(),
'guid' => hash("crc32", $url), 'guid' => hash('crc32', $url),
'filename' => basename($components['path']), 'filename' => basename($components['path']),
'type' => $curlResult->getContentType() 'type' => $curlResult->getContentType()
]; ];
@ -221,6 +230,7 @@ function mailstream_do_images(&$item, &$attachments)
continue; continue;
} }
} }
return $attachments; return $attachments;
} }
@ -231,7 +241,7 @@ function mailstream_do_images(&$item, &$attachments)
* *
* @return string sender suitable for use in the email * @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']); $contact = Contact::getById($item['contact-id']);
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
@ -249,7 +259,7 @@ function mailstream_sender($item)
* *
* @return string plaintext subject line * @return string plaintext subject line
*/ */
function mailstream_decode_subject($subject) function mailstream_decode_subject(string $subject): string
{ {
$html = BBCode::convert($subject); $html = BBCode::convert($subject);
if (!$html) { if (!$html) {
@ -264,7 +274,7 @@ function mailstream_decode_subject($subject)
return $notags; return $notags;
} }
$nocodes = preg_replace_callback("/(&#[0-9]+;)/", function ($m) { $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); }, $noentity);
if (!$nocodes) { if (!$nocodes) {
return $noentity; return $noentity;
@ -283,7 +293,7 @@ function mailstream_decode_subject($subject)
* *
* @return string subject line suitable for use in the email * @return string subject line suitable for use in the email
*/ */
function mailstream_subject($item) function mailstream_subject(array $item): string
{ {
if ($item['title']) { if ($item['title']) {
return mailstream_decode_subject($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. * @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)) { if (!is_array($item)) {
Logger::error('mailstream_send item is empty', ['message_id' => $message_id]); Logger::error('mailstream_send item is empty', ['message_id' => $message_id]);
return; return false;
} }
if (!$item['visible']) { if (!$item['visible']) {
@ -361,19 +371,20 @@ function mailstream_send($message_id, $item, $user)
'user email' => $user['email']]); 'user email' => $user['email']]);
return true; return true;
} }
require_once(dirname(__file__).'/phpmailer/class.phpmailer.php');
require_once (dirname(__file__) . '/phpmailer/class.phpmailer.php');
$attachments = []; $attachments = [];
mailstream_do_images($item, $attachments); mailstream_do_images($item, $attachments);
$frommail = DI::config()->get('mailstream', 'frommail'); $frommail = DI::config()->get('mailstream', 'frommail');
if ($frommail == "") { if ($frommail == '') {
$frommail = 'friendica@localhost.local'; $frommail = 'friendica@localhost.local';
} }
$address = DI::pConfig()->get($item['uid'], 'mailstream', 'address'); $address = DI::pConfig()->get($item['uid'], 'mailstream', 'address');
if (!$address) { if (!$address) {
$address = $user['email']; $address = $user['email'];
} }
$mail = new PHPmailer; $mail = new PHPmailer();
try { try {
$mail->XMailer = 'Friendica Mailstream Addon'; $mail->XMailer = 'Friendica Mailstream Addon';
$mail->SetFrom($frommail, mailstream_sender($item)); $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 * @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); $lines = str_split($text, 200);
for ($i = 0; $i < count($lines); $i++) { 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 * Process data submitted to user's mailstream features form
* @param App $a * @param App $a
* @param array $post POST data * @param array $post POST data
* @return void
*/ */
function mailstream_addon_settings_post(App $a, array $post) 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 // if the visitor of the page is not a local_user, use MathJax
// otherwise check the users settings. // 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) function newmemberwidget_addon_admin_post(App $a)
{ {
$ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""); DI::config()->set('newmemberwidget', 'freetext', (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""));
$lsn = trim($_POST['localsupportname'] ?? ''); DI::config()->set('newmemberwidget', 'linkglobalsupport', intval($_POST['linkglobalsupport']));
$gs = intval($_POST['linkglobalsupport']); DI::config()->set('newmemberwidget', 'linklocalsupport', intval($_POST['linklocalsupport']));
$ls = intval($_POST['linklocalsupport']); DI::config()->set('newmemberwidget', 'localsupport', trim($_POST['localsupportname'] ?? ''));
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));
} }
function newmemberwidget_addon_admin(App $a, &$o) function newmemberwidget_addon_admin(App $a, string &$o)
{ {
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/newmemberwidget'); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/newmemberwidget');
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'), '$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.")], '$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>)"], '$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.')], '$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)')], '$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) function nitter_addon_admin_post(App $a)
{ {
$nitterserver = rtrim(trim($_POST['nitterserver']),'/'); DI::config()->set('nitter', 'server', rtrim(trim($_POST['nitterserver']), '/'));
DI::config()->set('nitter', 'server', $nitterserver);
} }
/* Hook into the admin settings to let the admin choose a /* Hook into the admin settings to let the admin choose a
* nitter server to use for the replacement. * 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'); $nitterserver = DI::config()->get('nitter', 'server');
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nitter/'); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/nitter/');
@ -58,20 +57,20 @@ function nitter_addon_admin(App $a, &$o)
/* /*
* replace "twitter.com" with "nitter.net" * 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 // this needs to be a system setting
$replaced = false; $replaced = false;
$nitter = DI::config()->get('nitter', 'server', 'https://nitter.net'); $nitter = DI::config()->get('nitter', 'server', 'https://nitter.net');
if (strstr($o['html'], 'https://mobile.twitter.com')) { if (strstr($b['html'], 'https://mobile.twitter.com')) {
$o['html'] = str_replace('https://mobile.twitter.com', $nitter, $o['html']); $b['html'] = str_replace('https://mobile.twitter.com', $nitter, $b['html']);
$replaced = true; $replaced = true;
} }
if (strstr($o['html'], 'https://twitter.com')) { if (strstr($b['html'], 'https://twitter.com')) {
$o['html'] = str_replace('https://twitter.com', $nitter, $o['html']); $b['html'] = str_replace('https://twitter.com', $nitter, $b['html']);
$replaced = true; $replaced = true;
} }
if ($replaced) { 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'); 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'])) { if(empty($item['coord']) || !empty($item['location'])) {
return; 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); 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/'); $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) function nominatim_addon_admin_post(App $a)
{ {
$language = !empty($_POST['language']) ? trim($_POST['language']) : ''; DI::config()->set('nominatim', 'language', (!empty($_POST['language']) ? trim($_POST['language']) : ''));
DI::config()->set('nominatim', 'language', $language);
} }

View File

@ -22,7 +22,7 @@ use Friendica\DI;
*/ */
function notifyall_module() {} 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/>'; $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; $nomserver = OSM_NOM;
} }
if ($item['coord'] != "") { if ($item['coord'] != '') {
$coords = explode(' ', $item['coord']); $coords = explode(' ', $item['coord']);
if (count($coords) > 1) { if (count($coords) > 1) {
$lat = urlencode(round($coords[0], 5)); $lat = urlencode(round($coords[0], 5));
@ -96,13 +96,13 @@ function openstreetmap_location(App $a, &$item)
$target = $nomserver.'?q='.urlencode($item['location']); $target = $nomserver.'?q='.urlencode($item['location']);
} }
if ($item['location'] != "") { if ($item['location'] != '') {
$title = $item['location']; $title = $item['location'];
} else { } else {
$title = $item['coord']; $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) 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'; $args = '?q=' . urlencode($b['location']) . '&format=json';
$cachekey = "openstreetmap:" . $b['location']; $cachekey = 'openstreetmap:' . $b['location'];
$j = DI::cache()->get($cachekey); $j = DI::cache()->get($cachekey);
if (is_null($j)) { if (is_null($j)) {
@ -178,9 +178,9 @@ function openstreetmap_generate_map(App $a, array &$b)
Logger::debug('generate_map: ' . $b['html']); 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); $tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
$nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM); $nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
$zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM); $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) function openstreetmap_addon_admin_post(App $a)
{ {
$urltms = ($_POST['tmsserver'] ?? '') ?: OSM_TMS; DI::config()->set('openstreetmap', 'tmsserver', ($_POST['tmsserver'] ?? '') ?: OSM_TMS);
$urlnom = ($_POST['nomserver'] ?? '') ?: OSM_NOM; DI::config()->set('openstreetmap', 'nomserver', ($_POST['nomserver'] ?? '') ?: OSM_NOM);
$zoom = ($_POST['zoom'] ?? '') ?: OSM_ZOOM; DI::config()->set('openstreetmap', 'zoom', ($_POST['zoom'] ?? '') ?: OSM_ZOOM);
$marker = ($_POST['marker'] ?? '') ?: OSM_MARKER; DI::config()->set('openstreetmap', '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);
} }

View File

@ -54,15 +54,15 @@ function pageheader_addon_admin_post(App $a)
function pageheader_fetch(App $a, string &$b) function pageheader_fetch(App $a, string &$b)
{ {
if(file_exists('pageheader.html')){ if (file_exists('pageheader.html')) {
$s = file_get_contents('pageheader.html'); $s = file_get_contents('pageheader.html');
} else { } else {
$s = DI::config()->get('pageheader', 'text'); $s = DI::config()->get('pageheader', 'text');
} }
DI::page()->registerStylesheet(__DIR__ .'/pageheader.css'); DI::page()->registerStylesheet(__DIR__ .'/pageheader.css');
if ($s) { if ($s) {
$b .= '<div class="pageheader">' . $s . '</div>'; $b .= '<div class="pageheader">' . $s . '</div>';
} }
} }

View File

@ -91,8 +91,10 @@ function piwik_analytics(App $a, array &$b)
$b .= "</div>"; $b .= "</div>";
} }
} }
function piwik_addon_admin (App $a, &$o) { function piwik_addon_admin (App $a, string &$o)
{
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/piwik/" ); $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/piwik/" );
$o = Renderer::replaceMacros( $t, [ $o = Renderer::replaceMacros( $t, [
'$submit' => DI::l10n()->t('Save Settings'), '$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)')], '$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' ), ''], '$async' => ['async', DI::l10n()->t('Asynchronous tracking'), DI::config()->get('piwik','async' ), ''],
]); ]);
} }
function piwik_addon_admin_post (App $a) {
$url = trim($_POST['baseurl'] ?? ''); function piwik_addon_admin_post(App $a)
$id = trim($_POST['siteid'] ?? ''); {
$optout = trim($_POST['optout'] ?? ''); DI::config()->set('piwik', 'baseurl', trim($_POST['baseurl'] ?? ''));
$async = trim($_POST['async'] ?? ''); DI::config()->set('piwik', 'siteid', trim($_POST['siteid'] ?? ''));
DI::config()->set('piwik', 'baseurl', $url); DI::config()->set('piwik', 'optout', trim($_POST['optout'] ?? ''));
DI::config()->set('piwik', 'siteid', $id); DI::config()->set('piwik', 'async', trim($_POST['async'] ?? ''));
DI::config()->set('piwik', 'optout', $optout);
DI::config()->set('piwik', 'async', $async);
} }

View File

@ -125,29 +125,24 @@ function public_server_login(App $a, $b)
function public_server_addon_admin_post(App $a) function public_server_addon_admin_post(App $a)
{ {
BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver'); BaseModule::checkFormSecurityTokenRedirectOnError('/admin/addons/publicserver', 'publicserver');
$expiredays = trim($_POST['expiredays'] ?? '');
$expireposts = trim($_POST['expireposts'] ?? ''); DI::config()->set('public_server', 'expiredays', trim($_POST['expiredays'] ?? ''));
$nologin = trim($_POST['nologin'] ?? ''); DI::config()->set('public_server', 'expireposts', trim($_POST['expireposts'] ?? ''));
$flagusers = trim($_POST['flagusers'] ?? ''); DI::config()->set('public_server', 'nologin', trim($_POST['nologin'] ?? ''));
$flagposts = trim($_POST['flagposts'] ?? ''); DI::config()->set('public_server', 'flagusers', trim($_POST['flagusers'] ?? ''));
$flagpostsexpire = trim($_POST['flagpostsexpire'] ?? ''); DI::config()->set('public_server', 'flagposts', trim($_POST['flagposts'] ?? ''));
DI::config()->set('public_server', 'expiredays', $expiredays); DI::config()->set('public_server', 'flagpostsexpire', trim($_POST['flagpostsexpire'] ?? ''));
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);
} }
function public_server_addon_admin(App $a, &$o) function public_server_addon_admin(App $a, string &$o)
{ {
$token = BaseModule::getFormSecurityToken("publicserver"); $token = BaseModule::getFormSecurityToken('publicserver');
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/public_server"); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/public_server');
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$form_security_token' => $token, '$form_security_token' => $token,
'$infotext' => DI::l10n()->t('Set any of these options to 0 to deactivate it.'), '$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"], '$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 "], '$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"], '$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'); 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'); 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()) { if (!local_user()) {
return; 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/"); $t = Renderer::getMarkupTemplate("admin.tpl", "addon/rendertime/");
@ -47,9 +47,8 @@ function rendertime_addon_admin_post(App $a)
* @param App $a * @param App $a
* @param string $o * @param string $o
*/ */
function rendertime_page_end(App $a, &$o) function rendertime_page_end(App $a, string &$o)
{ {
$profiler = DI::profiler(); $profiler = DI::profiler();
$duration = microtime(true) - $profiler->get('start'); $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) { if (DI::args()->getArgc() < 2) {
return; return;
@ -80,15 +80,15 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer'); 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'); 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'))); $fragment = addslashes(BBCode::convert(DI::config()->get('saml', 'settings_statement')));
$b .= <<<EOL $body .= <<<EOL
<script> <script>
var target=$("#settings-nickname-desc"); var target=$("#settings-nickname-desc");
if (target.length) { target.append("<p>$fragment</p>"); } if (target.length) { target.append("<p>$fragment</p>"); }
@ -125,7 +125,7 @@ function saml_sso_initiate(App $a, array &$b)
exit(); exit();
} }
function saml_sso_reply($a) function saml_sso_reply(App $a)
{ {
$auth = new \OneLogin\Saml2\Auth(saml_settings()); $auth = new \OneLogin\Saml2\Auth(saml_settings());
$requestID = null; $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 = $form =
saml_input( saml_input(

View File

@ -24,12 +24,12 @@ function showmore_dyn_install()
Hook::register('addon_settings_post', __FILE__, 'showmore_dyn_settings_post'); 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'); 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'); 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); $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'); $sites = DI::config()->get('statusnet', 'sites');
$sitesform = []; $sitesform = [];

View File

@ -64,7 +64,7 @@ function tumblr_content(App $a)
return $o; return $o;
} }
function tumblr_addon_admin(App $a, &$o) function tumblr_addon_admin(App $a, string &$o)
{ {
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/tumblr/" ); $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) function tumblr_addon_admin_post(App $a)
{ {
$consumer_key = trim($_POST['consumer_key'] ?? ''); DI::config()->set('tumblr', 'consumer_key', trim($_POST['consumer_key'] ?? ''));
$consumer_secret = trim($_POST['consumer_secret'] ?? ''); DI::config()->set('tumblr', 'consumer_secret', trim($_POST['consumer_secret'] ?? ''));
DI::config()->set('tumblr', 'consumer_key',$consumer_key);
DI::config()->set('tumblr', 'consumer_secret',$consumer_secret);
} }
function tumblr_connect(App $a) 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 // 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 // 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 // Let's begin. First we need a Request Token. The request token is required to send the user
// to Tumblr's login page. // 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. // 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', $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_secret', $access_token['oauth_token_secret']);
$o = DI::l10n()->t("You are now authenticated to tumblr."); $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>'; $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) function twitter_addon_admin_post(App $a)
{ {
$consumerkey = trim($_POST['consumerkey'] ?? ''); DI::config()->set('twitter', 'consumerkey', trim($_POST['consumerkey'] ?? ''));
$consumersecret = trim($_POST['consumersecret'] ?? ''); DI::config()->set('twitter', 'consumersecret', trim($_POST['consumersecret'] ?? ''));
DI::config()->set('twitter', 'consumerkey', $consumerkey);
DI::config()->set('twitter', 'consumersecret', $consumersecret);
} }
function twitter_addon_admin(App $a, &$o) function twitter_addon_admin(App $a, string &$o)
{ {
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/twitter/'); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/twitter/');

View File

@ -11,12 +11,14 @@ use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\DI; use Friendica\DI;
function viewsrc_install() { function viewsrc_install()
{
Hook::register('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu'); Hook::register('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
Hook::register('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end'); 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 DI::page()['htmlhead'] .= <<< EOS
<script> <script>
$(function(){ $(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>'; $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/" ); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/webrtc/' );
$o = Renderer::replaceMacros( $t, [ $o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'), '$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) function webrtc_addon_admin_post (App $a)
{ {
$url = trim($_POST['webrtcurl'] ?? ''); DI::config()->set('webrtc', 'webrtcurl', trim($_POST['webrtcurl'] ?? ''));
DI::config()->set('webrtc', 'webrtcurl', $url);
} }
/** /**
@ -43,7 +47,7 @@ function webrtc_addon_admin_post (App $a)
*/ */
function webrtc_module() {} function webrtc_module() {}
function webrtc_content(App $a) function webrtc_content(App $a): string
{ {
$o = ''; $o = '';