[various] Convert addon_settings hook functions to the new data array format

- Add separate template files to several addons
- Remove superfluous addon settings CSS files
pull/1210/head
Hypolite Petovan 2021-11-20 04:56:55 -05:00
parent f0522a998b
commit 779b38ec09
68 changed files with 444 additions and 953 deletions

View File

@ -159,19 +159,17 @@ function advancedcontentfilter_prepare_body_content_filter(App $a, &$hook_data)
}
function advancedcontentfilter_addon_settings(App $a, &$s)
function advancedcontentfilter_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
}
$advancedcontentfilter = DI::l10n()->t('Advanced Content Filter');
$s .= <<<HTML
<span class="settings-block fakelink" style="display: block;"><h3><a href="advancedcontentfilter">$advancedcontentfilter <i class="glyphicon glyphicon-share"></i></a></h3></span>
HTML;
return;
$data = [
'addon' => 'advancedcontentfilter',
'title' => DI::l10n()->t('Advanced Content Filter'),
'href' => 'advancedcontentfilter',
];
}
/*

View File

@ -24,9 +24,9 @@ define("BIRDAVATAR_SIZE", 256);
*/
function birdavatar_install()
{
Hook::register('avatar_lookup', 'addon/birdavatar/birdavatar.php', 'birdavatar_lookup');
Hook::register('addon_settings', 'addon/birdavatar/birdavatar.php', 'birdavatar_addon_settings');
Hook::register('addon_settings_post', 'addon/birdavatar/birdavatar.php', 'birdavatar_addon_settings_post');
Hook::register('avatar_lookup', __FILE__, 'birdavatar_lookup');
Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post');
Logger::log('registered birdavatar');
}
@ -34,24 +34,29 @@ function birdavatar_install()
/**
* Bird avatar user settings page
*/
function birdavatar_addon_settings(App $a, &$s)
function birdavatar_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
}
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/birdavatar/');
$s .= Renderer::replaceMacros($t, [
'$postpost' => !empty($_POST['birdavatar-morebird']) || !empty($_POST['birdavatar-emailbird']),
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/birdavatar/');
$html = Renderer::replaceMacros($t, [
'$uncache' => time(),
'$uid' => local_user(),
'$usebird' => DI::l10n()->t('Use Bird as Avatar'),
'$morebird' => DI::l10n()->t('More Random Bird!'),
'$emailbird' => DI::l10n()->t('Reset to email Bird'),
'$seed' => DI::pConfig()->get(local_user(), 'birdavatar', 'seed', false),
'$header' => DI::l10n()->t('Bird Avatar Settings'),
'$setrandomize' => DI::l10n()->t('Set default profile avatar or randomize the bird.'),
]);
$data = [
'addon' => 'birdavar',
'title' => DI::l10n()->t('Bird Avatar Settings'),
'html' => $html,
'submit' => [
'birdavatar-usebird' => DI::l10n()->t('Use Bird as Avatar'),
'birdavatar-morebird' => DI::l10n()->t('More Random Bird!'),
'birdavatar-emailbird' => DI::pConfig()->get(local_user(), 'birdavatar', 'seed', false) ? DI::l10n()->t('Reset to email Bird') : null,
],
];
}
/**

View File

@ -1,24 +1,2 @@
<span id="settings_birdavatar_inflated" class="settings-block fakelink"
style="{{if $postpost}}display: none;{{else}}display: block;{{/if}}"
onclick="openClose('settings_birdavatar_expanded'); openClose('settings_birdavatar_inflated');">
<h3>{{$header}}</h3>
</span>
<div id="settings_birdavatar_expanded" class="settings-block"
style="{{if $postpost}}display: block;{{else}}display: none;{{/if}}">
<span class="fakelink" onclick="openClose('settings_birdavatar_expanded'); openClose('settings_birdavatar_inflated');">
<h3>{{$header}}</h3>
</span>
<img src="{{$basepath}}/birdavatar/{{$uid}}?{{$uncache}}">
<p>{{$setrandomize}}</p>
<div class="settings-submit-wrapper" >
<button type="submit" name="birdavatar-usebird"
class="btn btn-primary settings-submit" value="{{$usebird}}">{{$usebird}}</button>
<div class="btn-group" role="group" aria-label="...">
<button type="submit" name="birdavatar-morebird"
class="btn btn-default settings-submit" value="{{$morebird}}">{{$morebird}}</button>
<button type="submit" name="birdavatar-emailbird" {{if !$seed}}disabled{{/if}}
class="btn btn-default settings-submit" value="{{$emailbird}}">{{$emailbird}}</button>
</div>
</div>
</div>
<p>{{$setrandomize}}</p>
<p><img src="{{$basepath}}/birdavatar/{{$uid}}?{{$uncache}}"></p>

View File

@ -1,18 +0,0 @@
#blockem-label {
float: left;
width: 300px;
margin-top: 10px;
}
#blockem-words {
float: left;
margin-top: 10px;
width: 400px;
height: 150px;
}
#blockem-submit {
margin-top: 15px;
}

View File

@ -9,6 +9,7 @@
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Util\Strings;
@ -25,39 +26,25 @@ function blockem_install()
Hook::register('enotify_store' , 'addon/blockem/blockem.php', 'blockem_enotify_store');
}
function blockem_addon_settings (App $a, &$s)
function blockem_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/blockem/blockem.css' . '" media="all" />' . "\r\n";
$words = DI::pConfig()->get(local_user(), 'blockem', 'words', '');
$words = DI::pConfig()->get(local_user(), 'blockem', 'words');
if (!$words) {
$words = '';
}
$s .= '<span id="settings_blockem_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_blockem_expanded\'); openClose(\'settings_blockem_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Blockem') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_blockem_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_blockem_expanded\'); openClose(\'settings_blockem_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Blockem') . '</h3>';
$s .= '</span>';
$s .= '<div id="blockem-wrapper">';
$s .= '<div id="blockem-desc">'. DI::l10n()->t("Hides user's content by collapsing posts. Also replaces their avatar with generic image.") . ' </div>';
$s .= '<label id="blockem-label" for="blockem-words">' . DI::l10n()->t('Comma separated profile URLS:') . ' </label>';
$s .= '<textarea id="blockem-words" type="text" name="blockem-words" >' . htmlspecialchars($words) . '</textarea>';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="blockem-submit" name="blockem-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
return;
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/blockem/');
$html = Renderer::replaceMacros($t, [
'$info' => DI::l10n()->t("Hides user's content by collapsing posts. Also replaces their avatar with generic image."),
'$words' => ['blockem-words', DI::l10n()->t('Comma separated profile URLS:'), $words],
]);
$data = [
'addon' => 'blockem',
'title' => DI::l10n()->t('Blockem'),
'html' => $html,
];
}
function blockem_addon_settings_post(App $a, array &$b)

View File

@ -0,0 +1 @@
{{include file="field_textarea.tpl" field=$words}}

View File

@ -25,9 +25,9 @@ define("CATAVATAR_SIZE", 256);
*/
function catavatar_install()
{
Hook::register('avatar_lookup', 'addon/catavatar/catavatar.php', 'catavatar_lookup');
Hook::register('addon_settings', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings');
Hook::register('addon_settings_post', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings_post');
Hook::register('avatar_lookup', __FILE__, 'catavatar_lookup');
Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post');
Logger::notice('registered catavatar');
}
@ -35,24 +35,29 @@ function catavatar_install()
/**
* Cat avatar user settings page
*/
function catavatar_addon_settings(App $a, &$s)
function catavatar_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
}
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/catavatar/');
$s .= Renderer::replaceMacros($t, [
'$postpost' => !empty($_POST['catavatar-morecat']) || !empty($_POST['catavatar-emailcat']),
'$uncache' => time(),
'$uid' => local_user(),
'$usecat' => DI::l10n()->t('Use Cat as Avatar'),
'$morecat' => DI::l10n()->t('More Random Cat!'),
'$emailcat' => DI::l10n()->t('Reset to email Cat'),
'$seed' => DI::pConfig()->get(local_user(), 'catavatar', 'seed', false),
'$header' => DI::l10n()->t('Cat Avatar Settings'),
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/catavatar/');
$html = Renderer::replaceMacros($t, [
'$uncache' => time(),
'$uid' => local_user(),
'$setrandomize' => DI::l10n()->t('Set default profile avatar or randomize the cat.'),
]);
$data = [
'addon' => 'catavar',
'title' => DI::l10n()->t('Cat Avatar Settings'),
'html' => $html,
'submit' => [
'catavatar-usecat' => DI::l10n()->t('Use Cat as Avatar'),
'catavatar-morecat' => DI::l10n()->t('Another random Cat!'),
'catavatar-emailcat' => DI::pConfig()->get(local_user(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null,
],
];
}
/**

View File

@ -1,24 +1,2 @@
<span id="settings_catavatar_inflated" class="settings-block fakelink"
style="{{if $postpost}}display: none;{{else}}display: block;{{/if}}"
onclick="openClose('settings_catavatar_expanded'); openClose('settings_catavatar_inflated');">
<h3>{{$header}}</h3>
</span>
<div id="settings_catavatar_expanded" class="settings-block"
style="{{if $postpost}}display: block;{{else}}display: none;{{/if}}">
<span class="fakelink" onclick="openClose('settings_catavatar_expanded'); openClose('settings_catavatar_inflated');">
<h3>{{$header}}</h3>
</span>
<img src="{{$basepath}}/catavatar/{{$uid}}?{{$uncache}}">
<p>{{$setrandomize}}</p>
<div class="settings-submit-wrapper" >
<button type="submit" name="catavatar-usecat"
class="btn btn-primary settings-submit" value="{{$usecat}}">{{$usecat}}</button>
<div class="btn-group" role="group" aria-label="...">
<button type="submit" name="catavatar-morecat"
class="btn btn-default settings-submit" value="{{$morecat}}">{{$morecat}}</button>
<button type="submit" name="catavatar-emailcat" {{if !$seed}}disabled{{/if}}
class="btn btn-default settings-submit" value="{{$emailcat}}">{{$emailcat}}</button>
</div>
</div>
</div>
<p>{{$setrandomize}}</p>
<p><img src="{{$basepath}}/catavatar/{{$uid}}?{{$uncache}}"></p>

View File

@ -164,40 +164,38 @@ function curweather_addon_settings_post(App $a, $post)
DI::pConfig()->set(local_user(), 'curweather', 'curweather_units' , trim($_POST['curweather_units']));
}
function curweather_addon_settings(App $a, &$s)
function curweather_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
}
/* Get the current state of our config variable */
$curweather_loc = DI::pConfig()->get(local_user(), 'curweather', 'curweather_loc');
$curweather_loc = DI::pConfig()->get(local_user(), 'curweather', 'curweather_loc');
$curweather_units = DI::pConfig()->get(local_user(), 'curweather', 'curweather_units');
$appid = DI::config()->get('curweather', 'appid');
$appid = DI::config()->get('curweather', 'appid');
if ($appid == "") {
if ($appid == '') {
$noappidtext = DI::l10n()->t('No APPID found, please contact your admin to obtain one.');
} else {
$noappidtext = '';
}
$enable = intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable'));
$enable_checked = (($enable) ? ' checked="checked" ' : '');
// load template and replace the macros
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/curweather/" );
$enabled = intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable'));
$s = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$header' => DI::l10n()->t('Current Weather').' '.DI::l10n()->t('Settings'),
'$noappidtext' => $noappidtext,
'$info' => DI::l10n()->t('Enter either the name of your location or the zip code.'),
'$curweather_loc' => [ 'curweather_loc', DI::l10n()->t('Your Location'), $curweather_loc, DI::l10n()->t('Identifier of your location (name or zip code), e.g. <em>Berlin,DE</em> or <em>14476,DE</em>.') ],
'$curweather_units' => [ 'curweather_units', DI::l10n()->t('Units'), $curweather_units, DI::l10n()->t('select if the temperature should be displayed in &deg;C or &deg;F'), ['metric'=>'°C', 'imperial'=>'°F']],
'$enabled' => [ 'curweather_enable', DI::l10n()->t('Show weather data'), $enable, '']
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/curweather/');
$html = Renderer::replaceMacros($t, [
'$noappidtext' => $noappidtext,
'$info' => DI::l10n()->t('Enter either the name of your location or the zip code.'),
'$curweather_loc' => ['curweather_loc', DI::l10n()->t('Your Location'), $curweather_loc, DI::l10n()->t('Identifier of your location (name or zip code), e.g. <em>Berlin,DE</em> or <em>14476,DE</em>.')],
'$curweather_units' => ['curweather_units', DI::l10n()->t('Units'), $curweather_units, DI::l10n()->t('select if the temperature should be displayed in &deg;C or &deg;F'), ['metric' => '°C', 'imperial' => '°F']],
'$enabled' => ['curweather_enable', DI::l10n()->t('Show weather data'), $enabled, ''],
]);
return;
$data = [
'addon' => 'curweather',
'title' => DI::l10n()->t('Current Weather Settings'),
'html' => $html,
];
}
// Config stuff for the admin panel to let the admin of the node set a APPID

View File

@ -1,15 +1,6 @@
<span id="settings_curweather_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_curweather_expanded'); openClose('settings_curweather_inflated');">
<h3>{{$header}}</h3>
</span>
<div id="settings_curweather_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_curweather_expanded'); openClose('settings_curweather_inflated');">
<h3>{{$header}}</h3>
</span>
<div style="color: red; font-weight: bold;">{{$noappidtext}}</div>
{{include file="field_input.tpl" field=$curweather_loc}}
{{include file="field_select.tpl" field=$curweather_units}}
{{include file="field_checkbox.tpl" field=$enabled}}
<div class="settings-submit-wrapper" >
<input type="submit" id="curweather-settings-submit" name="curweather-settings-submit" class="settings-submit" value="{{$submit}}" />
</div>
</div>
{{if $noappidtext}}
<p style="color: red; font-weight: bold;">{{$noappidtext}}</p>
{{/if}}
{{include file="field_input.tpl" field=$curweather_loc}}
{{include file="field_select.tpl" field=$curweather_units}}
{{include file="field_checkbox.tpl" field=$enabled}}

View File

@ -1,14 +0,0 @@
#fromapp-label, #fromapp-force-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#fromapp-input, #fromapp-force {
float: left;
}

View File

@ -6,8 +6,11 @@
* Author: Commander Zot
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
function fromapp_install()
@ -28,47 +31,26 @@ function fromapp_settings_post($a, $post)
DI::pConfig()->set(local_user(), 'fromapp', 'force', intval($_POST['fromapp-force']));
}
function fromapp_settings(&$a, &$s)
function fromapp_settings(App &$a, array &$data)
{
if (!local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/fromapp/fromapp.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$fromapp = DI::pConfig()->get(local_user(), 'fromapp', 'app', '');
$force = intval(DI::pConfig()->get(local_user(), 'fromapp', 'force'));
$force = intval(DI::pConfig()->get(local_user(), 'fromapp', 'force'));
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/fromapp/');
$html = Renderer::replaceMacros($t, [
'$fromapp' => ['fromapp-input', DI::l10n()->t('The application name you would like to show your posts originating from. Separate different app names with a comma. A random one will then be selected for every posting.'), $fromapp],
'$force' => ['fromapp-force', DI::l10n()->t('Use this application name even if another application was used.'), $force],
]);
$force_enabled = (($force) ? ' checked="checked" ' : '');
/* Add some HTML to the existing form */
$s .= '<span id="settings_fromapp_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_fromapp_expanded\'); openClose(\'settings_fromapp_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('FromApp Settings') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_fromapp_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_fromapp_expanded\'); openClose(\'settings_fromapp_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('FromApp Settings') . '</h3>';
$s .= '</span>';
$s .= '<div id="fromapp-wrapper">';
$s .= '<label id="fromapp-label" for="fromapp-input">' . DI::l10n()->t('The application name you would like to show your posts originating from. Separate different app names with a comma. A random one will then be selected for every posting.') . '</label>';
$s .= '<input id="fromapp-input" type="text" name="fromapp-input" value="' . $fromapp . '" ' . '/>';
$s .= '<div class="clear"></div>';
$s .= '<label id="fromapp-force-label" for="fromapp-force">' . DI::l10n()->t('Use this application name even if another application was used.') . '</label>';
$s .= '<input id="fromapp-force" type="checkbox" name="fromapp-force" value="1" ' . $force_enabled . '/>';
$s .= '</div><div class="clear"></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="fromapp-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
$data = [
'addon' => 'fromapp',
'title' => DI::l10n()->t('FromApp Settings'),
'html' => $html,
];
}
function fromapp_post_hook(&$a, &$item)

View File

@ -0,0 +1,2 @@
{{include file="field_input.tpl" field=$fromapp}}
{{include file="field_checkbox.tpl" field=$force}}

View File

@ -1,14 +0,0 @@
#geonames-enable-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#geonames-checkbox {
float: left;
}

View File

@ -113,32 +113,32 @@ function geonames_addon_settings_post(App $a, array $post)
* Called from the Addon Setting form.
* Add our own settings info to the page.
*
* @param App $a
* @param string $s
* @param App $a
* @param array $data
* @throws Exception
*/
function geonames_addon_settings(App $a, &$s)
function geonames_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
}
$geo_account = DI::config()->get('geonames', 'username');
if (!$geo_account) {
return;
}
DI::page()->registerStylesheet(__DIR__ . '/geonames.css');
/* Get the current state of our config variable */
$enabled = intval(DI::pConfig()->get(local_user(), 'geonames', 'enable'));
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/geonames/');
$s .= Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t('Geonames Settings'),
'$description' => DI::l10n()->t('Replace numerical coordinates by the nearest populated location name in your posts.'),
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/geonames/');
$html = Renderer::replaceMacros($t, [
'$info' => DI::l10n()->t('Replace numerical coordinates by the nearest populated location name in your posts.'),
'$enable' => ['geonames-enable', DI::l10n()->t('Enable Geonames Addon'), $enabled],
'$submit' => DI::l10n()->t('Save Settings')
]);
$data = [
'addon' => 'geonames',
'title' => DI::l10n()->t('Geonames Settings'),
'html' => $html,
];
}

View File

@ -1,14 +1,2 @@
<span id="settings_geonames_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_geonames_expanded'); openClose('settings_geonames_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="settings_geonames_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_geonames_expanded'); openClose('settings_geonames_inflated');">
<h3>{{$title}}</h3>
</span>
<p>{{$description nofilter}}</p>
{{include file="field_checkbox.tpl" field=$enable}}
<div class="settings-submit-wrapper" >
<input type="submit" id="geonames-submit" name="geonames-submit" class="settings-submit" value="{{$submit}}" />
</div>
</div>
<div class="clear"></div>
<p>{{$info}}</p>
{{include file="field_checkbox.tpl" field=$enable}}

View File

@ -1,16 +0,0 @@
#gnot-desc {
margin-bottom: 10px;
}
#gnot-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#gnot {
float: left;
}

View File

@ -8,6 +8,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
@ -49,31 +50,25 @@ function gnot_settings_post($a,$post) {
function gnot_settings(&$a,&$s) {
if(! local_user())
function gnot_settings(App &$a, array &$data)
{
if (!local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
$gnot = intval(DI::pConfig()->get(local_user(), 'gnot', 'enable'));
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/gnot/gnot.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$gnot = intval(DI::pConfig()->get(local_user(),'gnot','enable'));
$gnot_checked = (($gnot) ? ' checked="checked" ' : '' );
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/');
/* Add some HTML to the existing form */
$s .= Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t('Gnot Settings') ,
'$submit' => DI::l10n()->t('Save Settings'),
'$enable' => DI::l10n()->t('Enable this addon?'),
'$enabled' => $gnot_checked,
'$text' => DI::l10n()->t("Allows threading of email comment notifications on Gmail and anonymising the subject line.")
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/');
$html = Renderer::replaceMacros($t, [
'$text' => DI::l10n()->t("Allows threading of email comment notifications on Gmail and anonymising the subject line."),
'$enabled' => ['gnot', DI::l10n()->t('Enable this addon?'), $gnot],
]);
$data = [
'addon' => 'gnot',
'title' => DI::l10n()->t('Gnot Settings'),
'html' => $html,
];
}

View File

@ -1,20 +1,2 @@
<span id="settings_gnot_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_gnot_expanded\'); openClose(\'settings_gnot_inflated\');">
<h3>{{$title}}</h3>
</span>
<div id="settings_gnot_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose(\'settings_gnot_expanded\'); openClose(\'settings_gnot_inflated\');">
<h3>{{$title}}</h3>
</span>
<div id="gnot-wrapper">
<div id="gnot-desc">{{$text}}</div>
<label id="gnot-label" for="gnot">{{$enable}}</label>
<input id="gnot-input" type="checkbox" name="gnot" value="1" {{$enabled}} />
</div>
<div class="clear"></div>
/* provide a submit button */
<div class="settings-submit-wrapper" >
<input type="submit" name="gnot-submit" class="settings-submit" value="{{$submit}}" />
</div>
</div>
<p>{{$text}}</p>
{{include file="field_checkbox.tpl" field=$enabled}}

View File

@ -1,14 +0,0 @@
#group_text-enable-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#group_text-checkbox {
float: left;
}

View File

@ -5,8 +5,11 @@
* Version: 1.0
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
function group_text_install() {
@ -42,31 +45,22 @@ function group_text_settings_post($a,$post) {
function group_text_settings(&$a,&$s) {
if(! local_user())
function group_text_settings(App &$a, array &$data)
{
if (!local_user()) {
return;
/* Add our stylesheet to the page so we can make our settings look nice */
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/group_text/group_text.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
}
$enabled = DI::pConfig()->get(local_user(),'system','groupedit_image_limit');
$checked = (($enabled) ? ' checked="checked" ' : '');
/* Add some HTML to the existing form */
$s .= '<div class="settings-block">';
$s .= '<h3>' . DI::l10n()->t('Group Text') . '</h3>';
$s .= '<div id="group_text-enable-wrapper">';
$s .= '<label id="group_text-enable-label" for="group_text-checkbox">' . DI::l10n()->t('Use a text only (non-image) group selector in the "group edit" menu') . '</label>';
$s .= '<input id="group_text-checkbox" type="checkbox" name="group_text" value="1" ' . $checked . '/>';
$s .= '</div><div class="clear"></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="group_text-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/group_text/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['group_text', DI::l10n()->t('Use a text only (non-image) group selector in the "group edit" menu'), $enabled],
]);
$data = [
'addon' => 'group_text',
'title' => DI::l10n()->t('Group Text'),
'html' => $html,
];
}

View File

@ -0,0 +1 @@
{{include file="field_checkbox.tpl" field=$enabled}}

View File

@ -7,6 +7,7 @@
* Author: Tobias Diekershoff <https://f.diekershoff.de/u/tobias>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -17,30 +18,27 @@ function irc_install() {
Hook::register('addon_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post');
}
function irc_addon_settings(&$a,&$s) {
if(! local_user())
function irc_addon_settings(App &$a, array &$data)
{
if (!local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
$sitechats = DI::pConfig()->get(local_user(), 'irc', 'sitechats'); /* popular channels */
$autochans = DI::pConfig()->get(local_user(), 'irc', 'autochans'); /* auto connect chans */
// DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->getBaseURL() . '/addon/irc/irc.css' . '" media="all" />' . "\r\n";
/* setting popular channels, auto connect channels */
$sitechats = DI::pConfig()->get( local_user(), 'irc','sitechats'); /* popular channels */
$autochans = DI::pConfig()->get( local_user(), 'irc','autochans'); /* auto connect chans */
$t = Renderer::getMarkupTemplate( "settings.tpl", "addon/irc/" );
$s .= Renderer::replaceMacros($t, [
'$header' => DI::l10n()->t('IRC Settings'),
'$info' => DI::l10n()->t('Here you can change the system wide settings for the channels to automatically join and access via the side bar. Note the changes you do here, only effect the channel selection if you are logged in.'),
'$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.')],
'$sitechats' => [ 'sitechats', DI::l10n()->t('Popular Channels (comma separated)'), $sitechats, DI::l10n()->t('List of popular channels, will be displayed at the side and hotlinked for easy joining.') ]
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/irc/');
$html = Renderer::replaceMacros($t, [
'$info' => DI::l10n()->t('Here you can change the system wide settings for the channels to automatically join and access via the side bar. Note the changes you do here, only effect the channel selection if you are logged in.'),
'$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.')],
'$sitechats' => ['sitechats', DI::l10n()->t('Popular Channels (comma separated)'), $sitechats, DI::l10n()->t('List of popular channels, will be displayed at the side and hotlinked for easy joining.')],
]);
return;
$data = [
'addon' => 'irc',
'title' => DI::l10n()->t('IRC Settings'),
'html' => $html,
];
}
function irc_addon_settings_post(&$a, &$b) {

View File

@ -1,15 +1,3 @@
<span id="settings_irc_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_irc_expanded'); openClose('settings_irc_inflated');">
<h3>{{$header}}</h3>
</span>
<div id="settings_irc_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_irc_expanded'); openClose('settings_irc_inflated');">
<h3>{{$header}}</h3>
</span>
<p>{{$info}}</p>
{{include file="field_input.tpl" field=$autochans}}
{{include file="field_input.tpl" field=$sitechats}}
<div class="settings-submit-wrapper" >
<input type="submit" id="irc-submit" name="irc-submit" class="settings-submit" value="{{$submit}}" />
</div>
</div>
<p>{{$info}}</p>
{{include file="field_input.tpl" field=$autochans}}
{{include file="field_input.tpl" field=$sitechats}}

View File

@ -1,14 +0,0 @@
#krynn-enable-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#krynn-checkbox {
float: left;
}

View File

@ -9,8 +9,11 @@
*
*"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
function krynn_install() {
@ -111,42 +114,24 @@ function krynn_settings_post($a,$post) {
function krynn_settings(&$a,&$s) {
if(! local_user())
function krynn_settings(App &$a, array &$data)
{
if(! local_user()) {
return;
/* Add our stylesheet to the page so we can make our settings look nice */
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/krynn/krynn.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
}
$enabled = DI::pConfig()->get(local_user(),'krynn','enable');
$checked = (($enabled) ? ' checked="checked" ' : '');
/* Add some HTML to the existing form */
$s .= '<span id="settings_krynn_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_krynn_expanded\'); openClose(\'settings_krynn_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Krynn') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_krynn_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_krynn_expanded\'); openClose(\'settings_krynn_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Krynn') . '</h3>';
$s .= '</span>';
$s .= '<div class="settings-block">';
$s .= '<h3>' . DI::l10n()->t('Krynn Settings') . '</h3>';
$s .= '<div id="krynn-enable-wrapper">';
$s .= '<label id="krynn-enable-label" for="krynn-checkbox">' . DI::l10n()->t('Enable Krynn Addon') . '</label>';
$s .= '<input id="krynn-checkbox" type="checkbox" name="krynn" value="1" ' . $checked . '/>';
$s .= '</div><div class="clear"></div></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="krynn-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/krynn/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['krynn', DI::l10n()->t('Enable Krynn Addon'), $enabled],
]);
$data = [
'addon' => 'krynn',
'title' => DI::l10n()->t('Krynn Settings'),
'html' => $html,
];
}

View File

@ -0,0 +1 @@
{{include file="field_checkbox.tpl" field=$enabled}}

View File

@ -31,7 +31,7 @@ function langfilter_install()
* 3rd parse a SMARTY3 template, replacing some translateable strings for the form
*/
function langfilter_addon_settings(App $a, &$s)
function langfilter_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
@ -40,23 +40,25 @@ function langfilter_addon_settings(App $a, &$s)
$enabled = DI::pConfig()->get(local_user(), 'langfilter', 'enable',
!DI::pConfig()->get(local_user(), 'langfilter', 'disable'));
$enable_checked = $enabled ? ' checked="checked"' : '';
$languages = DI::pConfig()->get(local_user(), 'langfilter', 'languages');
$minconfidence = DI::pConfig()->get(local_user(), 'langfilter', 'minconfidence', 0) * 100;
$minlength = DI::pConfig()->get(local_user(), 'langfilter', 'minlength' , 32);
$languages = DI::pConfig()->get(local_user(), 'langfilter', 'languages');
$minconfidence = DI::pConfig()->get(local_user(), 'langfilter', 'minconfidence', 0) * 100;
$minlength = DI::pConfig()->get(local_user(), 'langfilter', 'minlength', 32);
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/langfilter/");
$s .= Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t("Language Filter"),
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/langfilter/');
$html = Renderer::replaceMacros($t, [
'$intro' => DI::l10n()->t('This addon tries to identify the language posts are written in. If it does not match any language specified below, posts will be hidden by collapsing them.'),
'$enabled' => ['langfilter_enable', DI::l10n()->t('Use the language filter'), $enable_checked, ''],
'$enabled' => ['langfilter_enable', DI::l10n()->t('Use the language filter'), $enabled],
'$languages' => ['langfilter_languages', DI::l10n()->t('Able to read'), $languages, DI::l10n()->t('List of abbreviations (ISO 639-1 codes) for languages you speak, comma separated. For example "de,it".')],
'$minconfidence' => ['langfilter_minconfidence', DI::l10n()->t('Minimum confidence in language detection'), $minconfidence, DI::l10n()->t('Minimum confidence in language detection being correct, from 0 to 100. Posts will not be filtered when the confidence of language detection is below this percent value.')],
'$minlength' => ['langfilter_minlength', DI::l10n()->t('Minimum length of message body'), $minlength, DI::l10n()->t('Minimum number of characters in message body for filter to be used. Posts shorter than this will not be filtered. Note: Language detection is unreliable for short content (<200 characters).')],
'$submit' => DI::l10n()->t('Save Settings'),
]);
return;
$data = [
'addon' => 'langfilter',
'title' => DI::l10n()->t('Language Filter'),
'html' => $html,
'submit' => ['langfilter-settings-submit' => DI::l10n()->t('Save Settings')],
];
}
/* Save the settings

View File

@ -1,19 +1,5 @@
<span id="settings_langfilter_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_langfilter_expanded'); openClose('settings_langfilter_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="settings_langfilter_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_langfilter_expanded'); openClose('settings_langfilter_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="langfilter-wrapper">
<p>{{$intro}}</p>
{{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_input.tpl" field=$languages}}
{{include file="field/range_percent.tpl" field=$minconfidence}}
{{include file="field_input.tpl" field=$minlength}}
</div>
<div class="settings-submit-wrapper" >
<input type="submit" id="langfilter-settings-submit" name="langfilter-settings-submit" class="settings-submit" value="{{$submit}}" />
</div>
</div>
<p>{{$intro}}</p>
{{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_input.tpl" field=$languages}}
{{include file="field/range_percent.tpl" field=$minconfidence}}
{{include file="field_input.tpl" field=$minlength}}

View File

@ -6,6 +6,7 @@
* Author: Matthew Exon <http://mat.exon.name>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
@ -462,51 +463,58 @@ function mailstream_convert_table_entries()
/**
* Form for configuring mailstream features for a user
*
* @param Friendica\App $a App object
* @param string $o HTML form data
* @param App $a App object
* @param array $data Hook data array
* @throws \Friendica\Network\HTTPException\ServiceUnavailableException
*/
function mailstream_addon_settings(&$a, &$s)
function mailstream_addon_settings(App &$a, array &$data)
{
$enabled = DI::pConfig()->get(local_user(), 'mailstream', 'enabled');
$address = DI::pConfig()->get(local_user(), 'mailstream', 'address');
$nolikes = DI::pConfig()->get(local_user(), 'mailstream', 'nolikes');
$attachimg= DI::pConfig()->get(local_user(), 'mailstream', 'attachimg');
$template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/');
$s .= Renderer::replaceMacros($template, [
'$enabled' => [
$enabled = DI::pConfig()->get(local_user(), 'mailstream', 'enabled');
$address = DI::pConfig()->get(local_user(), 'mailstream', 'address');
$nolikes = DI::pConfig()->get(local_user(), 'mailstream', 'nolikes');
$attachimg = DI::pConfig()->get(local_user(), 'mailstream', 'attachimg');
$template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/');
$html = Renderer::replaceMacros($template, [
'$enabled' => [
'mailstream_enabled',
DI::l10n()->t('Enabled'),
$enabled
],
'$address' => [
'$address' => [
'mailstream_address',
DI::l10n()->t('Email Address'),
$address,
DI::l10n()->t("Leave blank to use your account email address")
DI::l10n()->t('Leave blank to use your account email address')
],
'$nolikes' => [
'$nolikes' => [
'mailstream_nolikes',
DI::l10n()->t('Exclude Likes'),
$nolikes,
DI::l10n()->t("Check this to omit mailing \"Like\" notifications")
DI::l10n()->t('Check this to omit mailing "Like" notifications')
],
'$attachimg' => [
'mailstream_attachimg',
DI::l10n()->t('Attach Images'),
$attachimg,
DI::l10n()->t("Download images in posts and attach them to the email. " .
"Useful for reading email while offline.")
DI::l10n()->t('Download images in posts and attach them to the email. ' .
'Useful for reading email while offline.')
],
'$title' => DI::l10n()->t('Mail Stream Settings'),
'$submit' => DI::l10n()->t('Save Settings')]);
]);
$data = [
'addon' => 'mailstream',
'title' => DI::l10n()->t('Mail Stream Settings'),
'html' => $html,
];
}
/**
* Process data submitted to user's mailstream features form
* @param \Friendica\App $a
* @param App $a
* @param array $post POST data
*/
function mailstream_addon_settings_post(\Friendica\App $a, array $post)
function mailstream_addon_settings_post(App $a, array $post)
{
if (!local_user() || empty($post['mailstream-submit'])) {
return;

View File

@ -1,13 +1,4 @@
<span id="settings_mailstream_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_mailstream_expanded'); openClose('settings_mailstream_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="settings_mailstream_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_mailstream_expanded'); openClose('settings_mailstream_inflated');">
<h3>{{$title}}</h3>
</span>
{{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_input.tpl" field=$address}}
{{include file="field_checkbox.tpl" field=$nolikes}}
{{include file="field_checkbox.tpl" field=$attachimg}}
<input type="submit" name="mailstream-submit" value="{{$submit}}">
</div>
{{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_input.tpl" field=$address}}
{{include file="field_checkbox.tpl" field=$nolikes}}
{{include file="field_checkbox.tpl" field=$attachimg}}

View File

@ -17,7 +17,7 @@ function markdown_install() {
Hook::register('addon_settings_post', __FILE__, 'markdown_addon_settings_post');
}
function markdown_addon_settings(App $a, &$s)
function markdown_addon_settings(App $a, array &$data)
{
if (!local_user()) {
return;
@ -25,12 +25,16 @@ function markdown_addon_settings(App $a, &$s)
$enabled = intval(DI::pConfig()->get(local_user(), 'markdown', 'enabled'));
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
$s .= Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t('Markdown'),
'$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, self created items will additionally be parsed via Markdown.')],
'$submit' => DI::l10n()->t('Save Settings'),
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
]);
$data = [
'addon' => 'markdown',
'title' => DI::l10n()->t('Markdown Settings'),
'html' => $html,
];
}
function markdown_addon_settings_post(App $a, &$b)

View File

@ -1,15 +1 @@
<span id="settings_markdown_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_markdown_expanded'); openClose('settings_markdown_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="settings_markdown_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_markdown_expanded'); openClose('settings_markdown_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="markdown-wrapper">
{{include file="field_checkbox.tpl" field=$enabled}}
</div>
<div class="settings-submit-wrapper" >
<input type="submit" id="markdown-submit" name="markdown-submit" class="settings-submit" value="{{$submit}}" />
</div>
</div>
{{include file="field_checkbox.tpl" field=$enabled}}

View File

@ -29,7 +29,7 @@ function mathjax_settings_post($a)
DI::pConfig()->set(local_user(), 'mathjax', 'use', intval($_POST['mathjax_use']));
}
function mathjax_settings(App $a, &$s)
function mathjax_settings(App $a, array &$data)
{
if (!local_user()) {
return;
@ -38,12 +38,16 @@ function mathjax_settings(App $a, &$s)
$use = DI::pConfig()->get(local_user(), 'mathjax', 'use', false);
$tpl = Renderer::getMarkupTemplate('settings.tpl', 'addon/mathjax');
$s .= Renderer::replaceMacros($tpl, [
'$title' => 'MathJax',
$html = Renderer::replaceMacros($tpl, [
'$description' => DI::l10n()->t('The MathJax addon renders mathematical formulae written using the LaTeX syntax surrounded by the usual $$ or an eqnarray block in the postings of your wall,network tab and private mail.'),
'$mathjax_use' => ['mathjax_use', DI::l10n()->t('Use the MathJax renderer'), $use, ''],
'$savesettings' => DI::l10n()->t('Save Settings'),
]);
$data = [
'addon' => 'mathjax',
'title' => 'MathJax',
'html' => $html,
];
}
function mathjax_footer(App $a, &$b)

View File

@ -1,16 +1,2 @@
<span id="settings_mathjax_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_mathjax_expanded'); openClose('settings_mathjax_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="settings_mathjax_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_mathjax_expanded'); openClose('settings_mathjax_inflated');">
<h3>{{$title}}</h3>
</span>
<p>{{$description nofilter}}</p>
{{include file="field_checkbox.tpl" field=$mathjax_use}}
<div class="clear"></div>
<div class="settings-submit-wrapper">
<button type="submit" id="mathjax-submit" name="mathjax-submit" class="settings-submit" value="1">{{$savesettings}}</button>
</div>
</div>
<p>{{$description}}</p>
{{include file="field_checkbox.tpl" field=$mathjax_use}}

View File

@ -0,0 +1 @@
{{include file="field_checkbox.tpl" field=$enabled}}

View File

@ -1,19 +0,0 @@
#nsfw-label, #nsfw-enable-label {
float: left;
width: 300px;
margin-top: 10px;
}
#nsfw-words, #nsfw-enable {
float: left;
margin-top: 10px;
}
#nsfw-submit {
margin-top: 15px;
}
.nsfw-desc {
margin-top: 10px;
}

View File

@ -7,7 +7,10 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
function nsfw_install()
@ -48,41 +51,27 @@ function nsfw_extract_photos($body)
return $new_body;
}
function nsfw_addon_settings(&$a, &$s)
function nsfw_addon_settings(App &$a, array &$data)
{
if (!local_user()) {
return;
}
DI::page()->registerStylesheet(__DIR__ . '/nsfw.css', 'all');
$enabled = !DI::pConfig()->get(local_user(), 'nsfw', 'disable');
$words = DI::pConfig()->get(local_user(), 'nsfw', 'words', 'nsfw,');
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/nsfw/');
$html = Renderer::replaceMacros($t, [
'$info' => DI::l10n()->t('This addon searches for specified words/text in posts and collapses them. It can be used to filter content tagged with for instance #NSFW that may be deemed inappropriate at certain times or places, such as being at work. It is also useful for hiding irrelevant or annoying content from direct view.'),
'$enabled' => ['nsfw-enable', DI::l10n()->t('Enable Content filter'), $enabled],
'$words' => ['nsfw-words', DI::l10n()->t('Comma separated list of keywords to hide'), $words, DI::l10n()->t('Use /expression/ to provide regular expressions')],
]);
$enable_checked = (intval(DI::pConfig()->get(local_user(), 'nsfw', 'disable')) ? '' : ' checked="checked" ');
$words = DI::pConfig()->get(local_user(), 'nsfw', 'words');
if (!$words) {
$words = 'nsfw,';
}
$s .= '<span id="settings_nsfw_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_nsfw_expanded\'); openClose(\'settings_nsfw_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Content Filter (NSFW and more)') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_nsfw_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_nsfw_expanded\'); openClose(\'settings_nsfw_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Content Filter (NSFW and more)') . '</h3>';
$s .= '</span>';
$s .= '<div id="nsfw-wrapper">';
$s .= '<p>' . DI::l10n()->t('This addon searches for specified words/text in posts and collapses them. It can be used to filter content tagged with for instance #NSFW that may be deemed inappropriate at certain times or places, such as being at work. It is also useful for hiding irrelevant or annoying content from direct view.') . '</p>';
$s .= '<label id="nsfw-enable-label" for="nsfw-enable">' . DI::l10n()->t('Enable Content filter') . ' </label>';
$s .= '<input id="nsfw-enable" type="checkbox" name="nsfw-enable" value="1"' . $enable_checked . ' />';
$s .= '<div class="clear"></div>';
$s .= '<label id="nsfw-label" for="nsfw-words">' . DI::l10n()->t('Comma separated list of keywords to hide') . ' </label>';
$s .= '<textarea id="nsfw-words" type="text" name="nsfw-words">' . $words . '</textarea>';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="nsfw-submit" name="nsfw-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
$s .= '<div class="nsfw-desc">' . DI::l10n()->t('Use /expression/ to provide regular expressions') . '</div></div>';
return;
$data = [
'addon' => 'nsfw',
'title' => DI::l10n()->t('Content Filter (NSFW and more)'),
'html' => $html,
];
}
function nsfw_addon_settings_post(&$a, &$b)
@ -99,7 +88,7 @@ function nsfw_addon_settings_post(&$a, &$b)
}
}
function nsfw_prepare_body_content_filter(\Friendica\App $a, &$hook_data)
function nsfw_prepare_body_content_filter(App $a, &$hook_data)
{
$words = null;
if (DI::pConfig()->get(local_user(), 'nsfw', 'disable')) {