- if a <addon>_module() function is empty, it is more a statement and not a
  real function
This commit is contained in:
Roland Häder 2022-06-24 23:27:58 +02:00
parent e895b55f6d
commit 3ab46781b1
No known key found for this signature in database
GPG key ID: C82EDE5DDFA0BA77
21 changed files with 259 additions and 198 deletions

View file

@ -180,6 +180,11 @@ function advancedcontentfilter_addon_settings(App $a, array &$data)
* Module * Module
*/ */
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function advancedcontentfilter_module() {} function advancedcontentfilter_module() {}
function advancedcontentfilter_init(App $a) function advancedcontentfilter_init(App $a)

View file

@ -136,9 +136,12 @@ function birdavatar_lookup(App $a, array &$b)
$b['success'] = true; $b['success'] = true;
} }
function birdavatar_module() /**
{ * This is a statement rather than an actual function definition. The simple
} * existence of this method is checked to figure out if the addon offers a
* module.
*/
function birdavatar_module() {}
/** /**
* Returns image for user id * Returns image for user id

View file

@ -186,9 +186,12 @@ function blockem_item_photo_menu(App $a, array &$b)
} }
} }
function blockem_module() /**
{ * This is a statement rather than an actual function definition. The simple
} * existence of this method is checked to figure out if the addon offers a
* module.
*/
function blockem_module() {}
function blockem_init(App $a) function blockem_init(App $a)
{ {

View file

@ -19,10 +19,12 @@ function calc_app_menu(App $a, array &$b)
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
} }
/**
function calc_module() * This is a statement rather than an actual function definition. The simple
{ * existence of this method is checked to figure out if the addon offers a
} * module.
*/
function calc_module() {}
function calc_init(App $a) function calc_init(App $a)
{ {

View file

@ -137,6 +137,11 @@ function catavatar_lookup(App $a, array &$b)
$b['success'] = true; $b['success'] = true;
} }
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function catavatar_module() {} function catavatar_module() {}
/** /**

View file

@ -21,43 +21,49 @@ function convert_app_menu(App $a, array &$b)
function convert_module() {} function convert_module() {}
function convert_content($app) { function convert_content(App $a) {
// @TODO UnitConverter uses a deprecated constructor with the class' name
// @TODO Let's one day rewrite this to a modern composer package
include 'UnitConvertor.php';
include 'UnitConvertor.php'; class TP_Converter extends UnitConvertor
class TP_Converter extends UnitConvertor {
function TP_Converter($lang = 'en')
{ {
if ($lang != 'en' ) { public function __construct(string $lang = 'en')
$dec_point = '.'; $thousand_sep = "'"; {
if ($lang == 'en' ) {
$dec_point = '.';
$thousand_sep = ',';
} else { } else {
$dec_point = '.'; $thousand_sep = ','; $dec_point = '.';
$thousand_sep = "'";
} }
$this->UnitConvertor($dec_point , $thousand_sep ); parent::UnitConvertor($dec_point, $thousand_sep );
}
} // end func UnitConvertor private function findBaseUnit($from, $to)
{
function find_base_unit($from,$to) { while (list($skey, $sval) = each($this->bases)) {
while (list($skey,$sval) = each($this->bases)) { if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) {
if ($skey == $from || $to == $skey || in_array($to,$sval) || in_array($from,$sval)) {
return $skey; return $skey;
} }
} }
return false; return false;
} }
function getTable($value, $from_unit, $to_unit, $precision) { public function getTable($value, $from_unit, $to_unit, $precision): string
{
if ($base_unit = $this->find_base_unit($from_unit,$to_unit)) { $string = '';
if ($base_unit = $this->findBaseUnit($from_unit, $to_unit)) {
// A baseunit was found now lets convert from -> $base_unit // A baseunit was found now lets convert from -> $base_unit
$cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision) . ' ' . $base_unit; $cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision) . ' ' . $base_unit;
$cell ['class'] = ($base_unit == $from_unit || $base_unit == $to_unit) ? 'framedred' : ''; $cell ['class'] = ($base_unit == $from_unit || $base_unit == $to_unit) ? 'framedred' : '';
$cells[] = $cell; $cells[] = $cell;
// We now have the base unit and value now lets produce the table; // We now have the base unit and value now lets produce the table;
while (list($key,$val) = each($this->bases[$base_unit])) { while (list($key, $val) = each($this->bases[$base_unit])) {
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val; $cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : ''; $cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
$cells[] = $cell; $cells[] = $cell;
@ -66,25 +72,25 @@ include 'UnitConvertor.php';
$cc = count($cells); $cc = count($cells);
$string = "<table class=\"framed grayish\" border=\"1\" cellpadding=\"5\" width=\"80%\" align=\"center\"><tr>"; $string = "<table class=\"framed grayish\" border=\"1\" cellpadding=\"5\" width=\"80%\" align=\"center\"><tr>";
$string .= "<td rowspan=\"$cc\" align=\"center\">$value $from_unit</td>"; $string .= "<td rowspan=\"$cc\" align=\"center\">$value $from_unit</td>";
$i=0; $i = 0;
foreach ($cells as $cell) { foreach ($cells as $cell) {
if ($i==0) { if ($i == 0) {
$string .= "<td class=\"".$cell['class']."\">".$cell['value']."</td>"; $string .= "<td class=\"" . $cell['class'] . "\">" . $cell['value'] . "</td>";
$i++; $i++;
} else { } else {
$string .= "</tr><tr><td class=\"".$cell['class']."\">".$cell['value']."</td>"; $string .= "</tr><tr><td class=\"" . $cell['class'] . "\">" . $cell['value'] . "</td>";
} }
} }
$string .= "</tr></table>"; $string .= "</tr></table>";
}
return $string; return $string;
} }
} }
}
$conv = new TP_Converter('en'); $conv = new TP_Converter('en');
$conversions = [ $conversions = [
'Temperature' => ['base' => 'Celsius', 'Temperature' => ['base' => 'Celsius',
'conv' => [ 'conv' => [
'Fahrenheit' => ['ratio' => 1.8, 'offset' => 32], 'Fahrenheit' => ['ratio' => 1.8, 'offset' => 32],
@ -168,20 +174,18 @@ $conversions = [
'c (warp)' => 9.265669e-10 'c (warp)' => 9.265669e-10
] ]
] ]
]; ];
while (list($key,$val) = each($conversions)) {
while (list($key,$val) = each($conversions)) {
$conv->addConversion($val['base'], $val['conv']); $conv->addConversion($val['base'], $val['conv']);
$list[$key][] = $val['base']; $list[$key][] = $val['base'];
while (list($ukey,$uval) = each($val['conv'])) { while (list($ukey,$uval) = each($val['conv'])) {
$list[$key][] = $ukey; $list[$key][] = $ukey;
} }
} }
$o .= '<h3>Unit Conversions</h3>'; $o .= '<h3>Unit Conversions</h3>';
if (isset($_POST['from_unit']) && isset($_POST['value'])) { if (isset($_POST['from_unit']) && isset($_POST['value'])) {
$_POST['value'] = $_POST['value'] + 0; $_POST['value'] = $_POST['value'] + 0;
$o .= ($conv->getTable($_POST['value'], $_POST['from_unit'], $_POST['to_unit'], 5)) . '</p>'; $o .= ($conv->getTable($_POST['value'], $_POST['from_unit'], $_POST['to_unit'], 5)) . '</p>';

View file

@ -25,10 +25,17 @@ function forumdirectory_install()
Hook::register('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu'); Hook::register('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
} }
function forumdirectory_module() /**
{ * This is a statement rather than an actual function definition. The simple
return; * existence of this method is checked to figure out if the addon offers a
} * module.
*/
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function forumdirectory_module() {}
function forumdirectory_app_menu(App $a, array &$b) function forumdirectory_app_menu(App $a, array &$b)
{ {

View file

@ -24,15 +24,14 @@ function ifttt_install()
Hook::register('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post'); Hook::register('connector_settings_post', 'addon/ifttt/ifttt.php', 'ifttt_settings_post');
} }
function ifttt_module() /**
{ * This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function ifttt_module() {}
} function ifttt_content() {}
function ifttt_content()
{
}
function ifttt_settings(App $a, array &$data) function ifttt_settings(App $a, array &$data)
{ {

View file

@ -24,9 +24,12 @@ function impressum_install()
Logger::notice("installed impressum Addon"); Logger::notice("installed impressum Addon");
} }
function impressum_module() /**
{ * This is a statement rather than an actual function definition. The simple
} * existence of this method is checked to figure out if the addon offers a
* module.
*/
function impressum_module() {}
function impressum_content() function impressum_content()
{ {

View file

@ -20,11 +20,12 @@ function infiniteimprobabilitydrive_app_menu(App $a, array &$b)
$b['app_menu'][] = '<div class="app-title"><a href="infiniteimprobabilitydrive">' . DI::l10n()->t('Infinite Improbability Drive') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="infiniteimprobabilitydrive">' . DI::l10n()->t('Infinite Improbability Drive') . '</a></div>';
} }
/**
function infiniteimprobabilitydrive_module() * This is a statement rather than an actual function definition. The simple
{ * existence of this method is checked to figure out if the addon offers a
return; * module.
} */
function infiniteimprobabilitydrive_module() {}
function infiniteimprobabilitydrive_content(App $a) function infiniteimprobabilitydrive_content(App $a)

View file

@ -64,11 +64,12 @@ function irc_app_menu(App $a, array &$b)
$b['app_menu'][] = '<div class="app-title"><a href="irc">' . DI::l10n()->t('IRC Chatroom') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="irc">' . DI::l10n()->t('IRC Chatroom') . '</a></div>';
} }
/**
function irc_module() { * This is a statement rather than an actual function definition. The simple
return; * existence of this method is checked to figure out if the addon offers a
} * module.
*/
function irc_module() {}
function irc_content(App $a) function irc_content(App $a)
{ {

View file

@ -58,11 +58,11 @@ function mailstream_check_version()
} }
/** /**
* This function indicates a module that can be wrapped in the LegacyModule class * This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/ */
function mailstream_module() function mailstream_module() {}
{
}
/** /**
* Adds an item in "addon features" in the admin menu of the site * Adds an item in "addon features" in the admin menu of the site
@ -70,7 +70,7 @@ function mailstream_module()
* @param App $a App object (unused) * @param App $a App object (unused)
* @param string $o HTML form data * @param string $o HTML form data
*/ */
function mailstream_addon_admin(App $a, &$o) 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/');

View file

@ -23,9 +23,12 @@ function namethingy_app_menu(App $a, array &$b)
} }
function namethingy_module() /**
{ * This is a statement rather than an actual function definition. The simple
} * existence of this method is checked to figure out if the addon offers a
* module.
*/
function namethingy_module() {}
function namethingy_content(App $a) function namethingy_content(App $a)
{ {

View file

@ -15,6 +15,11 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function notifyall_module() {} function notifyall_module() {}
function notifyall_addon_admin(App $a, &$o) function notifyall_addon_admin(App $a, &$o)

View file

@ -50,6 +50,11 @@ function pumpio_install()
Hook::register('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification'); Hook::register('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
} }
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function pumpio_module() {} function pumpio_module() {}
function pumpio_content(App $a) function pumpio_content(App $a)

View file

@ -130,9 +130,13 @@ function superblock_item_photo_menu(App $a, array &$b)
$b['menu'][DI::l10n()->t('Block Completely')] = 'javascript:superblockBlock(\'' . $author . '\'); return false;'; $b['menu'][DI::l10n()->t('Block Completely')] = 'javascript:superblockBlock(\'' . $author . '\'); return false;';
} }
/**
* This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
* module.
*/
function superblock_module() {} function superblock_module() {}
function superblock_init(App $a) function superblock_init(App $a)
{ {
if (!local_user()) { if (!local_user()) {

View file

@ -20,10 +20,12 @@ function tictac_app_menu(App $a, array &$b)
$b['app_menu'][] = '<div class="app-title"><a href="tictac">' . DI::l10n()->t('Three Dimensional Tic-Tac-Toe') . '</a></div>'; $b['app_menu'][] = '<div class="app-title"><a href="tictac">' . DI::l10n()->t('Three Dimensional Tic-Tac-Toe') . '</a></div>';
} }
function tictac_module() /**
{ * This is a statement rather than an actual function definition. The simple
return; * existence of this method is checked to figure out if the addon offers a
} * module.
*/
function tictac_module() {}
function tictac_content(App $a) { function tictac_content(App $a) {

View file

@ -29,9 +29,12 @@ function tumblr_install()
Hook::register('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post'); Hook::register('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
} }
function tumblr_module() /**
{ * This is a statement rather than an actual function definition. The simple
} * existence of this method is checked to figure out if the addon offers a
* module.
*/
function tumblr_module() {}
function tumblr_content(App $a) function tumblr_content(App $a)
{ {

View file

@ -1740,7 +1740,7 @@ function twitter_media_entities($post, array &$postarray, int $uriId = -1)
* @param integer $uriId URI Id used to store tags. 0 = create a new one; -1 = don't store tags for this post. * @param integer $uriId URI Id used to store tags. 0 = create a new one; -1 = don't store tags for this post.
* @return array item array * @return array item array
*/ */
function twitter_createpost(App $a, int $uid, $post, array $self, $create_user, bool $only_existing_contact, $noquote, int $uriId = 0): array function twitter_createpost(App $a, int $uid, $post, array $self, $create_user, bool $only_existing_contact, bool $noquote, int $uriId = 0): array
{ {
$postarray = []; $postarray = [];
$postarray['network'] = Protocol::TWITTER; $postarray['network'] = Protocol::TWITTER;

View file

@ -29,15 +29,19 @@ function webrtc_addon_admin (App $a, &$o)
'$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'] ?? ''); $url = trim($_POST['webrtcurl'] ?? '');
DI::config()->set('webrtc', 'webrtcurl', $url); DI::config()->set('webrtc', 'webrtcurl', $url);
} }
function webrtc_module() { /**
return; * This is a statement rather than an actual function definition. The simple
} * existence of this method is checked to figure out if the addon offers a
* module.
*/
function webrtc_module() {}
function webrtc_content(App $a) function webrtc_content(App $a)
{ {

View file

@ -60,10 +60,12 @@ function windowsphonepush_install()
} }
/* declare the windowsphonepush function so that /windowsphonepush url requests will land here */ /* declare the windowsphonepush function so that /windowsphonepush url requests will land here */
function windowsphonepush_module() /**
{ * This is a statement rather than an actual function definition. The simple
* existence of this method is checked to figure out if the addon offers a
} * module.
*/
function windowsphonepush_module() {}
/* Callback from the settings post function. /* Callback from the settings post function.
* $post contains the $_POST array. * $post contains the $_POST array.