Changes:
- added more type-hints - cleaned up some files (curly braces, spaces)pull/1265/head
parent
a1e17968d1
commit
04df7f6e05
|
@ -117,7 +117,7 @@ function birdavatar_addon_settings_post(App $a, &$s)
|
|||
* @param $a array
|
||||
* @param &$b array
|
||||
*/
|
||||
function birdavatar_lookup(App $a, &$b)
|
||||
function birdavatar_lookup(App $a, array &$b)
|
||||
{
|
||||
$user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]);
|
||||
if (DBA::isResult($user)) {
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
|
@ -54,7 +55,8 @@ function blackout_install() {
|
|||
Hook::register('page_header', 'addon/blackout/blackout.php', 'blackout_redirect');
|
||||
}
|
||||
|
||||
function blackout_redirect ($a, $b) {
|
||||
function blackout_redirect (App $a, $b)
|
||||
{
|
||||
// if we have a logged in user, don't throw her out
|
||||
if (local_user()) {
|
||||
return true;
|
||||
|
@ -67,20 +69,21 @@ function blackout_redirect ($a, $b) {
|
|||
$now = time();
|
||||
$date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart);
|
||||
$date2 = DateTime::createFromFormat('Y-m-d G:i', $myend);
|
||||
if ( $date1 && $date2 ) {
|
||||
if ($date1 && $date2) {
|
||||
$date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart)->format('U');
|
||||
$date2 = DateTime::createFromFormat('Y-m-d G:i', $myend)->format('U');
|
||||
} else {
|
||||
$date1 = 0;
|
||||
$date2 = 0;
|
||||
$date1 = 0;
|
||||
$date2 = 0;
|
||||
}
|
||||
|
||||
if (( $date1 <= $now ) && ( $now <= $date2 )) {
|
||||
Logger::notice('redirecting user to blackout page');
|
||||
System::externalRedirect($myurl);
|
||||
}
|
||||
}
|
||||
|
||||
function blackout_addon_admin(&$a, &$o) {
|
||||
function blackout_addon_admin(App $a, &$o) {
|
||||
$mystart = DI::config()->get('blackout','begindate');
|
||||
if (! is_string($mystart)) { $mystart = 'YYYY-MM-DD hh:mm'; }
|
||||
$myend = DI::config()->get('blackout','enddate');
|
||||
|
@ -107,7 +110,7 @@ function blackout_addon_admin(&$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 (&$a) {
|
||||
function blackout_addon_admin_post (App $a) {
|
||||
$begindate = trim($_POST['startdate']);
|
||||
$enddate = trim($_POST['enddate']);
|
||||
$url = trim($_POST['rurl']);
|
||||
|
|
|
@ -19,12 +19,14 @@ use Friendica\Network\HTTPException\ForbiddenException;
|
|||
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
function blockbot_install() {
|
||||
function blockbot_install()
|
||||
{
|
||||
Hook::register('init_1', __FILE__, 'blockbot_init_1');
|
||||
}
|
||||
|
||||
function blockbot_addon_admin(&$a, &$o) {
|
||||
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/blockbot/");
|
||||
function blockbot_addon_admin(App $a, &$o)
|
||||
{
|
||||
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/blockbot/');
|
||||
|
||||
$o = Renderer::replaceMacros($t, [
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
|
@ -34,13 +36,15 @@ function blockbot_addon_admin(&$a, &$o) {
|
|||
]);
|
||||
}
|
||||
|
||||
function blockbot_addon_admin_post(&$a) {
|
||||
function blockbot_addon_admin_post(App $a)
|
||||
{
|
||||
DI::config()->set('blockbot', 'good_crawlers', $_POST['good_crawlers'] ?? false);
|
||||
DI::config()->set('blockbot', 'block_gab', $_POST['block_gab'] ?? false);
|
||||
DI::config()->set('blockbot', 'training', $_POST['training'] ?? false);
|
||||
}
|
||||
|
||||
function blockbot_init_1(App $a) {
|
||||
function blockbot_init_1(App $a)
|
||||
{
|
||||
if (empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ function buglink_install()
|
|||
Hook::register('page_end', 'addon/buglink/buglink.php', 'buglink_active');
|
||||
}
|
||||
|
||||
function buglink_active(App $a, &$b)
|
||||
function buglink_active(App $a, array &$b)
|
||||
{
|
||||
$b .= '<div id="buglink_wrapper" style="position: fixed; bottom: 5px; left: 5px;"><a href="https://github.com/friendica/friendica/issues" target="_blank" rel="noopener noreferrer" title="' . DI::l10n()->t('Report Bug') . '"><img src="addon/buglink/bug-x.gif" alt="' . DI::l10n()->t('Report Bug') . '" /></a></div>';
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Version: 1.0
|
||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -12,19 +14,19 @@ function calc_install() {
|
|||
Hook::register('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
|
||||
}
|
||||
|
||||
function calc_app_menu($a,&$b) {
|
||||
function calc_app_menu(App $a, array &$b)
|
||||
{
|
||||
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
|
||||
}
|
||||
|
||||
|
||||
function calc_module() {}
|
||||
function calc_module()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function calc_init($a) {
|
||||
|
||||
$x = <<< EOT
|
||||
function calc_init(App $a)
|
||||
{
|
||||
$x = <<< EOT
|
||||
|
||||
<script language="JavaScript">
|
||||
/**************************************
|
||||
|
@ -354,6 +356,5 @@ $o .= <<< EOT
|
|||
</td></tr></tbody></table>
|
||||
|
||||
EOT;
|
||||
return $o;
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ function catavatar_addon_settings_post(App $a, &$s)
|
|||
* @param $a array
|
||||
* @param &$b array
|
||||
*/
|
||||
function catavatar_lookup(App $a, &$b)
|
||||
function catavatar_lookup(App $a, array &$b)
|
||||
{
|
||||
$user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]);
|
||||
if (DBA::isResult($user)) {
|
||||
|
|
|
@ -5,13 +5,16 @@
|
|||
* Version: 1.0
|
||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
|
||||
function convert_install() {
|
||||
Hook::register('app_menu', 'addon/convert/convert.php', 'convert_app_menu');
|
||||
}
|
||||
|
||||
function convert_app_menu($a,&$b) {
|
||||
function convert_app_menu(App $a, array &$b)
|
||||
{
|
||||
$b['app_menu'][] = '<div class="app-title"><a href="convert">Units Conversion</a></div>';
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ function cookienotice_addon_admin_post(App $a)
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function cookienotice_page_content_top(App $a, &$b)
|
||||
function cookienotice_page_content_top(App $a, array &$b)
|
||||
{
|
||||
DI::page()->registerStylesheet(__DIR__ . '/cookienotice.css');
|
||||
DI::page()->registerFooterScript(__DIR__ . '/cookienotice.js');
|
||||
|
@ -99,7 +99,7 @@ function cookienotice_page_content_top(App $a, &$b)
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function cookienotice_page_end(App $a, &$b)
|
||||
function cookienotice_page_end(App $a, array &$b)
|
||||
{
|
||||
$text = (string)DI::config()->get('cookienotice', 'text', DI::l10n()->t('This website uses cookies to recognize revisiting and logged in users. You accept the usage of these cookies by continue browsing this website.'));
|
||||
$oktext = (string)DI::config()->get('cookienotice', 'oktext', DI::l10n()->t('OK'));
|
||||
|
|
|
@ -87,7 +87,7 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
|
|||
return $r;
|
||||
}
|
||||
|
||||
function curweather_network_mod_init(App $a, &$b)
|
||||
function curweather_network_mod_init(App $a, array &$b)
|
||||
{
|
||||
if (!intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable'))) {
|
||||
return;
|
||||
|
|
|
@ -118,7 +118,7 @@ function diaspora_settings(App $a, array &$data)
|
|||
}
|
||||
|
||||
|
||||
function diaspora_settings_post(App $a, &$b)
|
||||
function diaspora_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!empty($_POST['diaspora-submit'])) {
|
||||
DI::pConfig()->set(local_user(),'diaspora', 'post' , intval($_POST['enabled']));
|
||||
|
@ -137,7 +137,7 @@ function diaspora_settings_post(App $a, &$b)
|
|||
}
|
||||
}
|
||||
|
||||
function diaspora_hook_fork(&$a, &$b)
|
||||
function diaspora_hook_fork(App $a, array &$b)
|
||||
{
|
||||
if ($b['name'] != 'notifier_normal') {
|
||||
return;
|
||||
|
|
|
@ -21,7 +21,7 @@ function fromapp_install()
|
|||
Logger::notice("installed fromapp");
|
||||
}
|
||||
|
||||
function fromapp_settings_post($a, $post)
|
||||
function fromapp_settings_post(App $a, $post)
|
||||
{
|
||||
if (!local_user() || empty($_POST['fromapp-submit'])) {
|
||||
return;
|
||||
|
@ -53,7 +53,7 @@ function fromapp_settings(App &$a, array &$data)
|
|||
];
|
||||
}
|
||||
|
||||
function fromapp_post_hook(&$a, &$item)
|
||||
function fromapp_post_hook(App $a, &$item)
|
||||
{
|
||||
if (! local_user()) {
|
||||
return;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
|
@ -71,12 +72,12 @@ function geocoordinates_resolve_item(&$item)
|
|||
DI::cache()->set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
|
||||
}
|
||||
|
||||
function geocoordinates_post_hook($a, &$item)
|
||||
function geocoordinates_post_hook(App $a, &$item)
|
||||
{
|
||||
geocoordinates_resolve_item($item);
|
||||
}
|
||||
|
||||
function geocoordinates_addon_admin(&$a, &$o)
|
||||
function geocoordinates_addon_admin(App $a, &$o)
|
||||
{
|
||||
|
||||
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/geocoordinates/");
|
||||
|
@ -88,7 +89,7 @@ function geocoordinates_addon_admin(&$a, &$o)
|
|||
]);
|
||||
}
|
||||
|
||||
function geocoordinates_addon_admin_post(&$a)
|
||||
function geocoordinates_addon_admin_post(App $a)
|
||||
{
|
||||
$api_key = trim($_POST['api_key'] ?? '');
|
||||
DI::config()->set('geocoordinates', 'api_key', $api_key);
|
||||
|
|
|
@ -15,8 +15,8 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Notification;
|
||||
|
||||
function gnot_install() {
|
||||
|
||||
function gnot_install()
|
||||
{
|
||||
Hook::register('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings');
|
||||
Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
|
||||
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
|
||||
|
@ -25,31 +25,22 @@ function gnot_install() {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Callback from the settings post function.
|
||||
* $post contains the $_POST array.
|
||||
* We will make sure we've got a valid user account
|
||||
* and if so set our configuration setting for this person.
|
||||
*
|
||||
*/
|
||||
|
||||
function gnot_settings_post($a,$post) {
|
||||
function gnot_settings_post(App $a, $post) {
|
||||
if(! local_user() || empty($_POST['gnot-submit']))
|
||||
return;
|
||||
|
||||
DI::pConfig()->set(local_user(),'gnot','enable',intval($_POST['gnot']));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Called from the Addon Setting form.
|
||||
* Add our own settings info to the page.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function gnot_settings(App &$a, array &$data)
|
||||
{
|
||||
if (!local_user()) {
|
||||
|
@ -71,10 +62,13 @@ function gnot_settings(App &$a, array &$data)
|
|||
];
|
||||
}
|
||||
|
||||
|
||||
function gnot_enotify_mail(&$a,&$b) {
|
||||
if((! $b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable'))))
|
||||
function gnot_enotify_mail(App $a, array &$b)
|
||||
{
|
||||
if ((!$b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable')))) {
|
||||
return;
|
||||
if($b['type'] == Notification\Type::COMMENT)
|
||||
}
|
||||
|
||||
if ($b['type'] == Notification\Type::COMMENT) {
|
||||
$b['subject'] = DI::l10n()->t('[Friendica:Notify] Comment to conversation #%d', $b['parent']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
|
||||
|
@ -13,27 +15,26 @@ function googlemaps_install()
|
|||
{
|
||||
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
||||
|
||||
Logger::notice("installed googlemaps");
|
||||
Logger::notice('installed googlemaps');
|
||||
}
|
||||
|
||||
function googlemaps_location($a, &$item)
|
||||
function googlemaps_location(App $a, &$item)
|
||||
{
|
||||
|
||||
if(! (strlen($item['location']) || strlen($item['coord']))) {
|
||||
if (!(strlen($item['location']) || strlen($item['coord']))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($item['coord'] != ""){
|
||||
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
|
||||
if ($item['coord'] != '') {
|
||||
$target = 'http://maps.google.com/?q=' . urlencode($item['coord']);
|
||||
} else {
|
||||
$target = "http://maps.google.com/?q=".urlencode($item['location']);
|
||||
$target = 'http://maps.google.com/?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>';
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ function gravatar_load_config(App $a, ConfigFileLoader $loader)
|
|||
* @param $a array
|
||||
* @param &$b array
|
||||
*/
|
||||
function gravatar_lookup($a, &$b) {
|
||||
function gravatar_lookup(App $a, array &$b)
|
||||
{
|
||||
$default_avatar = DI::config()->get('gravatar', 'default_avatar');
|
||||
$rating = DI::config()->get('gravatar', 'rating');
|
||||
|
||||
|
@ -61,17 +62,20 @@ function gravatar_lookup($a, &$b) {
|
|||
/**
|
||||
* Display admin settings for this addon
|
||||
*/
|
||||
function gravatar_addon_admin (&$a, &$o) {
|
||||
function gravatar_addon_admin (App $a, &$o)
|
||||
{
|
||||
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/gravatar/" );
|
||||
|
||||
$default_avatar = DI::config()->get('gravatar', 'default_avatar');
|
||||
$rating = DI::config()->get('gravatar', 'rating');
|
||||
|
||||
// set default values for first configuration
|
||||
if(! $default_avatar)
|
||||
if (!$default_avatar) {
|
||||
$default_avatar = 'identicon'; // pseudo-random geometric pattern based on email hash
|
||||
if(! $rating)
|
||||
}
|
||||
if (!$rating) {
|
||||
$rating = 'g'; // suitable for display on all websites with any audience type
|
||||
}
|
||||
|
||||
// Available options for the select boxes
|
||||
$default_avatars = [
|
||||
|
@ -105,7 +109,8 @@ function gravatar_addon_admin (&$a, &$o) {
|
|||
/**
|
||||
* Save admin settings
|
||||
*/
|
||||
function gravatar_addon_admin_post (&$a) {
|
||||
function gravatar_addon_admin_post (App $a)
|
||||
{
|
||||
BaseModule::checkFormSecurityToken('gravatarsave');
|
||||
|
||||
$default_avatar = trim($_POST['avatar'] ?? 'identicon');
|
||||
|
|
|
@ -29,7 +29,7 @@ function group_text_install() {
|
|||
*
|
||||
*/
|
||||
|
||||
function group_text_settings_post($a,$post) {
|
||||
function group_text_settings_post(App $a, $post) {
|
||||
if(! local_user() || empty($_POST['group_text-submit']))
|
||||
return;
|
||||
DI::pConfig()->set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
|
||||
|
|
|
@ -16,7 +16,7 @@ function highlightjs_install()
|
|||
Hook::register('footer', __FILE__, 'highlightjs_footer');
|
||||
}
|
||||
|
||||
function highlightjs_head(App $a, &$b)
|
||||
function highlightjs_head(App $a, array &$b)
|
||||
{
|
||||
if ($a->getCurrentTheme() == 'frio') {
|
||||
$style = 'bootstrap';
|
||||
|
@ -27,7 +27,7 @@ function highlightjs_head(App $a, &$b)
|
|||
DI::page()->registerStylesheet(__DIR__ . '/asset/styles/' . $style . '.css');
|
||||
}
|
||||
|
||||
function highlightjs_footer(App $a, &$b)
|
||||
function highlightjs_footer(App $a, array &$b)
|
||||
{
|
||||
DI::page()->registerFooterScript(__DIR__ . '/asset/highlight.pack.js');
|
||||
DI::page()->registerFooterScript(__DIR__ . '/highlightjs.js');
|
||||
|
|
|
@ -73,7 +73,7 @@ function ijpost_settings(App &$a, array &$data)
|
|||
];
|
||||
}
|
||||
|
||||
function ijpost_settings_post(&$a, &$b)
|
||||
function ijpost_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!empty($_POST['ijpost-submit'])) {
|
||||
DI::pConfig()->set(local_user(), 'ijpost', 'post', intval($_POST['ijpost']));
|
||||
|
@ -83,7 +83,7 @@ function ijpost_settings_post(&$a, &$b)
|
|||
}
|
||||
}
|
||||
|
||||
function ijpost_post_local(&$a, &$b)
|
||||
function ijpost_post_local(App $a, array &$b)
|
||||
{
|
||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||
|
||||
|
@ -118,7 +118,7 @@ function ijpost_post_local(&$a, &$b)
|
|||
$b['postopts'] .= 'ijpost';
|
||||
}
|
||||
|
||||
function ijpost_send(&$a, &$b)
|
||||
function ijpost_send(App $a, array &$b)
|
||||
{
|
||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||
return;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* License: 3-clause BSD license
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
|
@ -15,91 +16,107 @@ use Friendica\DI;
|
|||
use Friendica\Core\Config\Util\ConfigFileLoader;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
|
||||
function impressum_install() {
|
||||
function impressum_install()
|
||||
{
|
||||
Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
|
||||
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
|
||||
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
|
||||
Logger::notice("installed impressum Addon");
|
||||
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
|
||||
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
|
||||
Logger::notice("installed impressum Addon");
|
||||
}
|
||||
|
||||
function impressum_module() {
|
||||
}
|
||||
function impressum_content() {
|
||||
DI::baseUrl()->redirect('friendica/');
|
||||
function impressum_module()
|
||||
{
|
||||
}
|
||||
|
||||
function obfuscate_email ($s) {
|
||||
$s = str_replace('@','(at)',$s);
|
||||
$s = str_replace('.','(dot)',$s);
|
||||
return $s;
|
||||
}
|
||||
function impressum_footer($a, &$b) {
|
||||
$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" />';
|
||||
$b .= '<div class="clear"></div>';
|
||||
$b .= '<div id="impressum_footer">'.$text.'</div>';
|
||||
}
|
||||
function impressum_content()
|
||||
{
|
||||
DI::baseUrl()->redirect('friendica/');
|
||||
}
|
||||
|
||||
function impressum_load_config(\Friendica\App $a, ConfigFileLoader $loader)
|
||||
function obfuscate_email (string $s): string
|
||||
{
|
||||
$s = str_replace('@', '(at)', $s);
|
||||
$s = str_replace('.', '(dot)', $s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
function impressum_footer(App $a, array &$b)
|
||||
{
|
||||
$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" />';
|
||||
$b .= '<div class="clear"></div>';
|
||||
$b .= '<div id="impressum_footer">'.$text.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
function impressum_load_config(App $a, ConfigFileLoader $loader)
|
||||
{
|
||||
$a->getConfigCache()->load($loader->loadAddonConfig('impressum'));
|
||||
}
|
||||
|
||||
function impressum_show($a,&$b) {
|
||||
$b .= '<h3>'.DI::l10n()->t('Impressum').'</h3>';
|
||||
$owner = DI::config()->get('impressum', 'owner');
|
||||
$owner_profile = DI::config()->get('impressum','ownerprofile');
|
||||
$postal = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal')));
|
||||
$notes = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes')));
|
||||
$email = obfuscate_email( DI::config()->get('impressum','email') );
|
||||
if (strlen($owner)) {
|
||||
if (strlen($owner_profile)) {
|
||||
$tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
|
||||
} else {
|
||||
$tmp = $owner;
|
||||
}
|
||||
if (strlen($email)) {
|
||||
$b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.DI::l10n()->t('Email Address').'</strong>: '.$email.'</p>';
|
||||
} else {
|
||||
$b .= '<p><strong>'.DI::l10n()->t('Site Owner').'</strong>: '. $tmp .'</p>';
|
||||
}
|
||||
if (strlen($postal)) {
|
||||
$b .= '<p><strong>'.DI::l10n()->t('Postal Address').'</strong><br />'. $postal .'</p>';
|
||||
}
|
||||
if (strlen($notes)) {
|
||||
$b .= '<p>'.$notes.'</p>';
|
||||
}
|
||||
} else {
|
||||
$b .= '<p>'.DI::l10n()->t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.').'</p>';
|
||||
}
|
||||
function impressum_show(App $a, array &$b)
|
||||
{
|
||||
$b .= '<h3>' . DI::l10n()->t('Impressum') . '</h3>';
|
||||
$owner = DI::config()->get('impressum', 'owner');
|
||||
$owner_profile = DI::config()->get('impressum', 'ownerprofile');
|
||||
$postal = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'postal')));
|
||||
$notes = ProxyUtils::proxifyHtml(BBCode::convert(DI::config()->get('impressum', 'notes')));
|
||||
$email = obfuscate_email( DI::config()->get('impressum', 'email') );
|
||||
|
||||
if (strlen($owner)) {
|
||||
if (strlen($owner_profile)) {
|
||||
$tmp = '<a href="' . $owner_profile . '">' . $owner . '</a>';
|
||||
} else {
|
||||
$tmp = $owner;
|
||||
}
|
||||
|
||||
if (strlen($email)) {
|
||||
$b .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'<br /><strong>' . DI::l10n()->t('Email Address') . '</strong>: ' . $email . '</p>';
|
||||
} else {
|
||||
$b .= '<p><strong>' . DI::l10n()->t('Site Owner').'</strong>: ' . $tmp .'</p>';
|
||||
}
|
||||
|
||||
if (strlen($postal)) {
|
||||
$b .= '<p><strong>' . DI::l10n()->t('Postal Address') . '</strong><br />' . $postal . '</p>';
|
||||
}
|
||||
|
||||
if (strlen($notes)) {
|
||||
$b .= '<p>' . $notes . '</p>';
|
||||
}
|
||||
} else {
|
||||
$b .= '<p>' . DI::l10n()->t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.') . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function impressum_addon_admin_post (&$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));
|
||||
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));
|
||||
}
|
||||
function impressum_addon_admin (&$a, &$o) {
|
||||
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/impressum/" );
|
||||
$o = Renderer::replaceMacros($t, [
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$owner' => ['owner', DI::l10n()->t('Site Owner'), DI::config()->get('impressum','owner'), DI::l10n()->t('The page operators name.')],
|
||||
'$ownerprofile' => ['ownerprofile', DI::l10n()->t('Site Owners Profile'), DI::config()->get('impressum','ownerprofile'), DI::l10n()->t('Profile address of the operator.')],
|
||||
'$postal' => ['postal', DI::l10n()->t('Postal Address'), DI::config()->get('impressum','postal'), DI::l10n()->t('How to contact the operator via snail mail. You can use BBCode here.')],
|
||||
'$notes' => ['notes', DI::l10n()->t('Notes'), DI::config()->get('impressum','notes'), DI::l10n()->t('Additional notes that are displayed beneath the contact information. You can use BBCode here.')],
|
||||
'$email' => ['email', DI::l10n()->t('Email Address'), DI::config()->get('impressum','email'), DI::l10n()->t('How to contact the operator via email. (will be displayed obfuscated)')],
|
||||
'$footer_text' => ['footer_text', DI::l10n()->t('Footer note'), DI::config()->get('impressum','footer_text'), DI::l10n()->t('Text for the footer. You can use BBCode here.')],
|
||||
]);
|
||||
|
||||
function impressum_addon_admin (App $a, &$o)
|
||||
{
|
||||
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/impressum/' );
|
||||
$o = Renderer::replaceMacros($t, [
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$owner' => ['owner', DI::l10n()->t('Site Owner'), DI::config()->get('impressum','owner'), DI::l10n()->t('The page operators name.')],
|
||||
'$ownerprofile' => ['ownerprofile', DI::l10n()->t('Site Owners Profile'), DI::config()->get('impressum','ownerprofile'), DI::l10n()->t('Profile address of the operator.')],
|
||||
'$postal' => ['postal', DI::l10n()->t('Postal Address'), DI::config()->get('impressum','postal'), DI::l10n()->t('How to contact the operator via snail mail. You can use BBCode here.')],
|
||||
'$notes' => ['notes', DI::l10n()->t('Notes'), DI::config()->get('impressum','notes'), DI::l10n()->t('Additional notes that are displayed beneath the contact information. You can use BBCode here.')],
|
||||
'$email' => ['email', DI::l10n()->t('Email Address'), DI::config()->get('impressum','email'), DI::l10n()->t('How to contact the operator via email. (will be displayed obfuscated)')],
|
||||
'$footer_text' => ['footer_text', DI::l10n()->t('Footer note'), DI::config()->get('impressum','footer_text'), DI::l10n()->t('Text for the footer. You can use BBCode here.')],
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Version: 1.0
|
||||
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -13,7 +15,7 @@ function infiniteimprobabilitydrive_install()
|
|||
Hook::register('app_menu', 'addon/infiniteimprobabilitydrive/infiniteimprobabilitydrive.php', 'infiniteimprobabilitydrive_app_menu');
|
||||
}
|
||||
|
||||
function infiniteimprobabilitydrive_app_menu($a, &$b)
|
||||
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>';
|
||||
}
|
||||
|
@ -25,7 +27,7 @@ function infiniteimprobabilitydrive_module()
|
|||
}
|
||||
|
||||
|
||||
function infiniteimprobabilitydrive_content(&$a)
|
||||
function infiniteimprobabilitydrive_content(App $a)
|
||||
{
|
||||
$baseurl = DI::baseUrl()->get() . '/addon/infiniteimprobabilitydrive';
|
||||
$o = '';
|
||||
|
|
64
irc/irc.php
64
irc/irc.php
|
@ -12,7 +12,8 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
function irc_install() {
|
||||
function irc_install()
|
||||
{
|
||||
Hook::register('app_menu', 'addon/irc/irc.php', 'irc_app_menu');
|
||||
Hook::register('addon_settings', 'addon/irc/irc.php', 'irc_addon_settings');
|
||||
Hook::register('addon_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post');
|
||||
|
@ -41,11 +42,13 @@ function irc_addon_settings(App &$a, array &$data)
|
|||
];
|
||||
}
|
||||
|
||||
function irc_addon_settings_post(&$a, &$b) {
|
||||
if(!local_user())
|
||||
function irc_addon_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!empty($_POST['irc-submit'])) {
|
||||
if (!empty($_POST['irc-submit'])) {
|
||||
if (isset($_POST['autochans'])) {
|
||||
DI::pConfig()->set(local_user(), 'irc', 'autochans', trim(($_POST['autochans'])));
|
||||
}
|
||||
|
@ -56,7 +59,8 @@ function irc_addon_settings_post(&$a, &$b) {
|
|||
}
|
||||
}
|
||||
|
||||
function irc_app_menu($a,&$b) {
|
||||
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>';
|
||||
}
|
||||
|
||||
|
@ -66,27 +70,30 @@ function irc_module() {
|
|||
}
|
||||
|
||||
|
||||
function irc_content(&$a) {
|
||||
|
||||
function irc_content(App $a)
|
||||
{
|
||||
$baseurl = DI::baseUrl()->get() . '/addon/irc';
|
||||
$o = '';
|
||||
|
||||
/* set the list of popular channels */
|
||||
if (local_user()) {
|
||||
$sitechats = DI::pConfig()->get( local_user(), 'irc', 'sitechats');
|
||||
if (!$sitechats)
|
||||
$sitechats = DI::config()->get('irc', 'sitechats');
|
||||
$sitechats = DI::pConfig()->get( local_user(), 'irc', 'sitechats');
|
||||
if (!$sitechats) {
|
||||
$sitechats = DI::config()->get('irc', 'sitechats');
|
||||
}
|
||||
} else {
|
||||
$sitechats = DI::config()->get('irc','sitechats');
|
||||
$sitechats = DI::config()->get('irc','sitechats');
|
||||
}
|
||||
if($sitechats)
|
||||
|
||||
if ($sitechats) {
|
||||
$chats = explode(',',$sitechats);
|
||||
else
|
||||
} else {
|
||||
$chats = ['friendica','chat','chatback','hottub','ircbar','dateroom','debian'];
|
||||
}
|
||||
|
||||
|
||||
DI::page()['aside'] .= '<div class="widget"><h3>' . DI::l10n()->t('Popular Channels') . '</h3><ul>';
|
||||
foreach($chats as $chat) {
|
||||
foreach ($chats as $chat) {
|
||||
DI::page()['aside'] .= '<li><a href="' . DI::baseUrl()->get() . '/irc?channels=' . $chat . '" >' . '#' . $chat . '</a></li>';
|
||||
}
|
||||
DI::page()['aside'] .= '</ul></div>';
|
||||
|
@ -99,10 +106,12 @@ function irc_content(&$a) {
|
|||
} else {
|
||||
$autochans = DI::config()->get('irc','autochans');
|
||||
}
|
||||
if($autochans)
|
||||
|
||||
if ($autochans) {
|
||||
$channels = $autochans;
|
||||
else
|
||||
} else {
|
||||
$channels = ($_GET['channels'] ?? '') ?: 'friendica';
|
||||
}
|
||||
|
||||
/* add the chatroom frame and some html */
|
||||
$o .= <<< EOT
|
||||
|
@ -111,23 +120,24 @@ function irc_content(&$a) {
|
|||
<iframe src="//web.libera.chat?channels=$channels" style="width:100%; max-width:900px; height: 600px;"></iframe>
|
||||
EOT;
|
||||
|
||||
return $o;
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function irc_addon_admin_post (&$a) {
|
||||
if(!$a->isSiteAdmin())
|
||||
function irc_addon_admin_post (App $a)
|
||||
{
|
||||
if (!$a->isSiteAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($_POST['irc-submit']) {
|
||||
DI::config()->set('irc','autochans',trim($_POST['autochans']));
|
||||
DI::config()->set('irc','sitechats',trim($_POST['sitechats']));
|
||||
if ($_POST['irc-submit']) {
|
||||
DI::config()->set('irc', 'autochans', trim($_POST['autochans']));
|
||||
DI::config()->set('irc', 'sitechats', trim($_POST['sitechats']));
|
||||
}
|
||||
}
|
||||
function irc_addon_admin (&$a, &$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/" );
|
||||
function irc_addon_admin (App $a, &$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/' );
|
||||
$o = Renderer::replaceMacros($t, [
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$autochans' => [ 'autochans', DI::l10n()->t('Channel(s) to auto connect (comma separated)'), $autochans, DI::l10n()->t('List of channels that shall automatically connected to when the app is launched.')],
|
||||
|
|
|
@ -43,7 +43,7 @@ function js_upload_form(App $a, array &$b)
|
|||
]);
|
||||
}
|
||||
|
||||
function js_upload_post_init(App $a, &$b)
|
||||
function js_upload_post_init(App $a, array &$b)
|
||||
{
|
||||
global $js_upload_result, $js_upload_jsonresponse;
|
||||
|
||||
|
@ -69,7 +69,7 @@ function js_upload_post_init(App $a, &$b)
|
|||
$js_upload_result = $result;
|
||||
}
|
||||
|
||||
function js_upload_post_file(App $a, &$b)
|
||||
function js_upload_post_file(App $a, array &$b)
|
||||
{
|
||||
global $js_upload_result;
|
||||
|
||||
|
@ -81,7 +81,7 @@ function js_upload_post_file(App $a, &$b)
|
|||
|
||||
}
|
||||
|
||||
function js_upload_post_end(App $a, &$b)
|
||||
function js_upload_post_end(App $a, array &$b)
|
||||
{
|
||||
global $js_upload_jsonresponse;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ function keycloakpassword_request($client_id, $secret, $url, $params = [])
|
|||
return $res;
|
||||
}
|
||||
|
||||
function keycloakpassword_authenticate($a, &$b)
|
||||
function keycloakpassword_authenticate(App $a, array &$b)
|
||||
{
|
||||
if (empty($b['password'])) {
|
||||
return;
|
||||
|
@ -110,7 +110,7 @@ function keycloakpassword_admin_input($key, $label, $description)
|
|||
];
|
||||
}
|
||||
|
||||
function keycloakpassword_addon_admin(&$a, &$o)
|
||||
function keycloakpassword_addon_admin(App $a, &$o)
|
||||
{
|
||||
$form =
|
||||
keycloakpassword_admin_input(
|
||||
|
@ -140,7 +140,7 @@ function keycloakpassword_addon_admin(&$a, &$o)
|
|||
$o = Renderer::replaceMacros($t, $form);
|
||||
}
|
||||
|
||||
function keycloakpassword_addon_admin_post(&$a)
|
||||
function keycloakpassword_addon_admin_post(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
return;
|
||||
|
|
|
@ -41,7 +41,7 @@ function krynn_install() {
|
|||
Logger::notice("installed krynn");
|
||||
}
|
||||
|
||||
function krynn_post_hook($a, &$item) {
|
||||
function krynn_post_hook(App $a, &$item) {
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -97,7 +97,7 @@ function krynn_post_hook($a, &$item) {
|
|||
*
|
||||
*/
|
||||
|
||||
function krynn_settings_post($a,$post) {
|
||||
function krynn_settings_post(App $a, $post) {
|
||||
if(! local_user())
|
||||
return;
|
||||
if($_POST['krynn-submit'])
|
||||
|
|
|
@ -67,7 +67,7 @@ function langfilter_addon_settings(App $a, array &$data)
|
|||
* 3rd save the settings to the DB for later usage
|
||||
*/
|
||||
|
||||
function langfilter_addon_settings_post(App $a, &$b)
|
||||
function langfilter_addon_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!local_user()) {
|
||||
return;
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
* ...etc.
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -67,12 +68,12 @@ function ldapauth_install()
|
|||
Hook::register('authenticate', 'addon/ldapauth/ldapauth.php', 'ldapauth_hook_authenticate');
|
||||
}
|
||||
|
||||
function ldapauth_load_config(\Friendica\App $a, ConfigFileLoader $loader)
|
||||
function ldapauth_load_config(App $a, ConfigFileLoader $loader)
|
||||
{
|
||||
$a->getConfigCache()->load($loader->loadAddonConfig('ldapauth'));
|
||||
}
|
||||
|
||||
function ldapauth_hook_authenticate($a, &$b)
|
||||
function ldapauth_hook_authenticate(App $a, array &$b)
|
||||
{
|
||||
$user = ldapauth_authenticate($b['username'], $b['password']);
|
||||
if (!empty($user['uid'])) {
|
||||
|
|
|
@ -27,9 +27,9 @@ function libertree_install()
|
|||
|
||||
function libertree_jot_nets(App &$a, array &$jotnets_fields)
|
||||
{
|
||||
if(! local_user()) {
|
||||
return;
|
||||
}
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(local_user(), 'libertree', 'post')) {
|
||||
$jotnets_fields[] = [
|
||||
|
@ -37,13 +37,12 @@ function libertree_jot_nets(App &$a, array &$jotnets_fields)
|
|||
'field' => [
|
||||
'libertree_enable',
|
||||
DI::l10n()->t('Post to libertree'),
|
||||
DI::pConfig()->get(local_user(), 'libertree', 'post_by_default')
|
||||
]
|
||||
DI::pConfig()->get(local_user(), 'libertree', 'post_by_default'),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function libertree_settings(App $a, array &$data)
|
||||
{
|
||||
if (!local_user()) {
|
||||
|
@ -72,11 +71,9 @@ function libertree_settings(App $a, array &$data)
|
|||
];
|
||||
}
|
||||
|
||||
|
||||
function libertree_settings_post(&$a,&$b) {
|
||||
|
||||
if(!empty($_POST['libertree-submit'])) {
|
||||
|
||||
function libertree_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!empty($_POST['libertree-submit'])) {
|
||||
DI::pConfig()->set(local_user(),'libertree','post',intval($_POST['libertree']));
|
||||
DI::pConfig()->set(local_user(),'libertree','post_by_default',intval($_POST['libertree_bydefault']));
|
||||
DI::pConfig()->set(local_user(),'libertree','libertree_api_token',trim($_POST['libertree_api_token']));
|
||||
|
@ -101,7 +98,8 @@ function libertree_hook_fork(App &$a, array &$b)
|
|||
}
|
||||
}
|
||||
|
||||
function libertree_post_local(&$a,&$b) {
|
||||
function libertree_post_local(App $a, array &$b)
|
||||
{
|
||||
|
||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||
|
||||
|
@ -136,11 +134,8 @@ function libertree_post_local(&$a,&$b) {
|
|||
$b['postopts'] .= 'libertree';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function libertree_send(&$a,&$b) {
|
||||
|
||||
function libertree_send(App $a, array &$b)
|
||||
{
|
||||
Logger::notice('libertree_send: invoked');
|
||||
|
||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||
|
@ -188,15 +183,16 @@ function libertree_send(&$a,&$b) {
|
|||
// remove multiple newlines
|
||||
do {
|
||||
$oldbody = $body;
|
||||
$body = str_replace("\n\n\n", "\n\n", $body);
|
||||
} while ($oldbody != $body);
|
||||
$body = str_replace("\n\n\n", "\n\n", $body);
|
||||
} while ($oldbody != $body);
|
||||
|
||||
// convert to markdown
|
||||
$body = BBCode::toMarkdown($body, false);
|
||||
|
||||
// Adding the title
|
||||
if(strlen($title))
|
||||
$body = "## ".html_entity_decode($title)."\n\n".$body;
|
||||
if (strlen($title)) {
|
||||
$body = '## ' . html_entity_decode($title) . "\n\n" . $body;
|
||||
}
|
||||
|
||||
|
||||
$params = [
|
||||
|
|
|
@ -35,7 +35,7 @@ function libravatar_load_config(App $a, ConfigFileLoader $loader)
|
|||
* @param $a array
|
||||
* @param &$b array
|
||||
*/
|
||||
function libravatar_lookup($a, &$b)
|
||||
function libravatar_lookup(array $a, array &$b)
|
||||
{
|
||||
$default_avatar = DI::config()->get('libravatar', 'default_avatar');
|
||||
if (empty($default_avatar)) {
|
||||
|
@ -44,6 +44,7 @@ function libravatar_lookup($a, &$b)
|
|||
}
|
||||
|
||||
require_once 'Services/Libravatar.php';
|
||||
|
||||
$libravatar = new Services_Libravatar();
|
||||
$libravatar->setSize($b['size']);
|
||||
$libravatar->setDefault($default_avatar);
|
||||
|
@ -56,7 +57,7 @@ function libravatar_lookup($a, &$b)
|
|||
/**
|
||||
* Display admin settings for this addon
|
||||
*/
|
||||
function libravatar_addon_admin(&$a, &$o)
|
||||
function libravatar_addon_admin(App $a, &$o)
|
||||
{
|
||||
$t = Renderer::getMarkupTemplate("admin.tpl", "addon/libravatar");
|
||||
|
||||
|
@ -87,7 +88,7 @@ function libravatar_addon_admin(&$a, &$o)
|
|||
/**
|
||||
* Save admin settings
|
||||
*/
|
||||
function libravatar_addon_admin_post(&$a)
|
||||
function libravatar_addon_admin_post(App $a)
|
||||
{
|
||||
$default_avatar = trim($_POST['avatar'] ?? 'identicon');
|
||||
DI::config()->set('libravatar', 'default_avatar', $default_avatar);
|
||||
|
|
|
@ -21,32 +21,31 @@ use Friendica\Util\DateTimeFormat;
|
|||
use Friendica\Util\XML;
|
||||
|
||||
function ljpost_install() {
|
||||
Hook::register('post_local', 'addon/ljpost/ljpost.php', 'ljpost_post_local');
|
||||
Hook::register('notifier_normal', 'addon/ljpost/ljpost.php', 'ljpost_send');
|
||||
Hook::register('jot_networks', 'addon/ljpost/ljpost.php', 'ljpost_jot_nets');
|
||||
Hook::register('connector_settings', 'addon/ljpost/ljpost.php', 'ljpost_settings');
|
||||
Hook::register('connector_settings_post', 'addon/ljpost/ljpost.php', 'ljpost_settings_post');
|
||||
Hook::register('post_local', 'addon/ljpost/ljpost.php', 'ljpost_post_local');
|
||||
Hook::register('notifier_normal', 'addon/ljpost/ljpost.php', 'ljpost_send');
|
||||
Hook::register('jot_networks', 'addon/ljpost/ljpost.php', 'ljpost_jot_nets');
|
||||
Hook::register('connector_settings', 'addon/ljpost/ljpost.php', 'ljpost_settings');
|
||||
Hook::register('connector_settings_post', 'addon/ljpost/ljpost.php', 'ljpost_settings_post');
|
||||
|
||||
}
|
||||
|
||||
function ljpost_jot_nets(App &$a, array &$jotnets_fields)
|
||||
{
|
||||
if(! local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(local_user(),'ljpost','post')) {
|
||||
$jotnets_fields[] = [
|
||||
'type' => 'checkbox',
|
||||
'field' => [
|
||||
'ljpost_enable',
|
||||
DI::l10n()->t('Post to LiveJournal'),
|
||||
DI::pConfig()->get(local_user(),'ljpost','post_by_default')
|
||||
]
|
||||
];
|
||||
}
|
||||
if(! local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(local_user(),'ljpost','post')) {
|
||||
$jotnets_fields[] = [
|
||||
'type' => 'checkbox',
|
||||
'field' => [
|
||||
'ljpost_enable',
|
||||
DI::l10n()->t('Post to LiveJournal'),
|
||||
DI::pConfig()->get(local_user(),'ljpost','post_by_default')
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function ljpost_settings(App &$a, array &$data)
|
||||
{
|
||||
|
@ -54,11 +53,11 @@ function ljpost_settings(App &$a, array &$data)
|
|||
return;
|
||||
}
|
||||
|
||||
$enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post', false);
|
||||
$enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post', false);
|
||||
$ij_username = DI::pConfig()->get(local_user(), 'ljpost', 'ij_username');
|
||||
$def_enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post_by_default');
|
||||
|
||||
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
||||
$t= Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
'$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled],
|
||||
'$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username],
|
||||
|
@ -68,68 +67,68 @@ function ljpost_settings(App &$a, array &$data)
|
|||
|
||||
$data = [
|
||||
'connector' => 'ljpost',
|
||||
'title' => DI::l10n()->t('LiveJournal Export'),
|
||||
'image' => 'addon/ljpost/livejournal.png',
|
||||
'title' => DI::l10n()->t('LiveJournal Export'),
|
||||
'image' => 'addon/ljpost/livejournal.png',
|
||||
'enabled' => $enabled,
|
||||
'html' => $html,
|
||||
'html' => $html,
|
||||
];
|
||||
}
|
||||
|
||||
function ljpost_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!empty($_POST['ljpost-submit'])) {
|
||||
DI::pConfig()->set(local_user(), 'ljpost', 'post', intval($_POST['ljpost']));
|
||||
DI::pConfig()->set(local_user(), 'ljpost', 'post_by_default', intval($_POST['lj_bydefault']));
|
||||
DI::pConfig()->set(local_user(), 'ljpost', 'lj_username', trim($_POST['lj_username']));
|
||||
DI::pConfig()->set(local_user(), 'ljpost', 'lj_password', trim($_POST['lj_password']));
|
||||
}
|
||||
}
|
||||
|
||||
function ljpost_settings_post(&$a,&$b) {
|
||||
|
||||
if(!empty($_POST['ljpost-submit' |