- 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
Signed by: roland
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,166 +21,170 @@ 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 = "'"; {
} else { if ($lang == 'en' ) {
$dec_point = '.'; $thousand_sep = ','; $dec_point = '.';
$thousand_sep = ',';
} else {
$dec_point = '.';
$thousand_sep = "'";
}
parent::UnitConvertor($dec_point, $thousand_sep );
} }
$this->UnitConvertor($dec_point , $thousand_sep ); private function findBaseUnit($from, $to)
{
while (list($skey, $sval) = each($this->bases)) {
if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) {
return $skey;
}
}
} // end func UnitConvertor return false;
function find_base_unit($from,$to) {
while (list($skey,$sval) = each($this->bases)) {
if ($skey == $from || $to == $skey || in_array($to,$sval) || in_array($from,$sval)) {
return $skey;
}
} }
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 = '';
// A baseunit was found now lets convert from -> $base_unit
if ($base_unit = $this->findBaseUnit($from_unit, $to_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;
// We now have the base unit and value now lets produce the table;
while (list($key,$val) = each($this->bases[$base_unit])) {
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
$cells[] = $cell; $cells[] = $cell;
// We now have the base unit and value now lets produce the table;
while (list($key, $val) = each($this->bases[$base_unit])) {
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
$cells[] = $cell;
}
$cc = count($cells);
$string = "<table class=\"framed grayish\" border=\"1\" cellpadding=\"5\" width=\"80%\" align=\"center\"><tr>";
$string .= "<td rowspan=\"$cc\" align=\"center\">$value $from_unit</td>";
$i = 0;
foreach ($cells as $cell) {
if ($i == 0) {
$string .= "<td class=\"" . $cell['class'] . "\">" . $cell['value'] . "</td>";
$i++;
} else {
$string .= "</tr><tr><td class=\"" . $cell['class'] . "\">" . $cell['value'] . "</td>";
}
}
$string .= "</tr></table>";
} }
$cc = count($cells);
$string = "<table class=\"framed grayish\" border=\"1\" cellpadding=\"5\" width=\"80%\" align=\"center\"><tr>";
$string .= "<td rowspan=\"$cc\" align=\"center\">$value $from_unit</td>";
$i=0;
foreach ($cells as $cell) {
if ($i==0) {
$string .= "<td class=\"".$cell['class']."\">".$cell['value']."</td>";
$i++;
} else {
$string .= "</tr><tr><td class=\"".$cell['class']."\">".$cell['value']."</td>";
}
}
$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],
'Kelvin' => ['ratio' => 1, 'offset' => 273], 'Kelvin' => ['ratio' => 1, 'offset' => 273],
'Reaumur' => 0.8 'Reaumur' => 0.8
]
],
'Weight' => ['base' => 'kg',
'conv' => [
'g' => 1000,
'mg' => 1000000,
't' => 0.001,
'grain' => 15432,
'oz' => 35.274,
'lb' => 2.2046,
'cwt(UK)' => 0.019684,
'cwt(US)' => 0.022046,
'ton (US)' => 0.0011023,
'ton (UK)' => 0.0009842
]
],
'Distance' => ['base' => 'km',
'conv' => [
'm' => 1000,
'dm' => 10000,
'cm' => 100000,
'mm' => 1000000,
'mile' => 0.62137,
'naut.mile' => 0.53996,
'inch(es)' => 39370,
'ft' => 3280.8,
'yd' => 1093.6,
'furlong' => 4.970969537898672,
'fathom' => 546.8066491688539
]
],
'Area' => ['base' => 'km 2',
'conv' => [
'ha' => 100,
'acre' => 247.105,
'm 2' => pow(1000,2),
'dm 2' => pow(10000,2),
'cm 2' => pow(100000,2),
'mm 2' => pow(1000000,2),
'mile 2' => pow(0.62137,2),
'naut.miles 2' => pow(0.53996,2),
'in 2' => pow(39370,2),
'ft 2' => pow(3280.8,2),
'yd 2' => pow(1093.6,2),
]
],
'Volume' => ['base' => 'm 3',
'conv' => [
'in 3' => 61023.6,
'ft 3' => 35.315,
'cm 3' => pow(10,6),
'dm 3' => 1000,
'litre' => 1000,
'hl' => 10,
'yd 3' => 1.30795,
'gal(US)' => 264.172,
'gal(UK)' => 219.969,
'pint' => 2113.376,
'quart' => 1056.688,
'cup' => 4266.753,
'fl oz' => 33814.02,
'tablespoon' => 67628.04,
'teaspoon' => 202884.1,
'pt (UK)' => 1000/0.56826,
'barrel petroleum' => 1000/158.99,
'Register Tons' => 2.832,
'Ocean Tons' => 1.1327
]
],
'Speed' => ['base' => 'kmph',
'conv' => [
'mps' => 0.0001726031,
'milesph' => 0.62137,
'knots' => 0.53996,
'mach STP' => 0.0008380431,
'c (warp)' => 9.265669e-10
]
] ]
], ];
'Weight' => ['base' => 'kg',
'conv' => [
'g' => 1000,
'mg' => 1000000,
't' => 0.001,
'grain' => 15432,
'oz' => 35.274,
'lb' => 2.2046,
'cwt(UK)' => 0.019684,
'cwt(US)' => 0.022046,
'ton (US)' => 0.0011023,
'ton (UK)' => 0.0009842
]
],
'Distance' => ['base' => 'km',
'conv' => [
'm' => 1000,
'dm' => 10000,
'cm' => 100000,
'mm' => 1000000,
'mile' => 0.62137,
'naut.mile' => 0.53996,
'inch(es)' => 39370,
'ft' => 3280.8,
'yd' => 1093.6,
'furlong' => 4.970969537898672,
'fathom' => 546.8066491688539
]
],
'Area' => ['base' => 'km 2',
'conv' => [
'ha' => 100,
'acre' => 247.105,
'm 2' => pow(1000,2),
'dm 2' => pow(10000,2),
'cm 2' => pow(100000,2),
'mm 2' => pow(1000000,2),
'mile 2' => pow(0.62137,2),
'naut.miles 2' => pow(0.53996,2),
'in 2' => pow(39370,2),
'ft 2' => pow(3280.8,2),
'yd 2' => pow(1093.6,2),
]
],
'Volume' => ['base' => 'm 3',
'conv' => [
'in 3' => 61023.6,
'ft 3' => 35.315,
'cm 3' => pow(10,6),
'dm 3' => 1000,
'litre' => 1000,
'hl' => 10,
'yd 3' => 1.30795,
'gal(US)' => 264.172,
'gal(UK)' => 219.969,
'pint' => 2113.376,
'quart' => 1056.688,
'cup' => 4266.753,
'fl oz' => 33814.02,
'tablespoon' => 67628.04,
'teaspoon' => 202884.1,
'pt (UK)' => 1000/0.56826,
'barrel petroleum' => 1000/158.99,
'Register Tons' => 2.832,
'Ocean Tons' => 1.1327
]
],
'Speed' => ['base' => 'kmph',
'conv' => [
'mps' => 0.0001726031,
'milesph' => 0.62137,
'knots' => 0.53996,
'mach STP' => 0.0008380431,
'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;

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.