[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()) { if (!local_user()) {
return; return;
} }
$advancedcontentfilter = DI::l10n()->t('Advanced Content Filter'); $data = [
'addon' => 'advancedcontentfilter',
$s .= <<<HTML 'title' => DI::l10n()->t('Advanced Content Filter'),
<span class="settings-block fakelink" style="display: block;"><h3><a href="advancedcontentfilter">$advancedcontentfilter <i class="glyphicon glyphicon-share"></i></a></h3></span> 'href' => 'advancedcontentfilter',
HTML; ];
return;
} }
/* /*

View File

@ -24,9 +24,9 @@ define("BIRDAVATAR_SIZE", 256);
*/ */
function birdavatar_install() function birdavatar_install()
{ {
Hook::register('avatar_lookup', 'addon/birdavatar/birdavatar.php', 'birdavatar_lookup'); Hook::register('avatar_lookup', __FILE__, 'birdavatar_lookup');
Hook::register('addon_settings', 'addon/birdavatar/birdavatar.php', 'birdavatar_addon_settings'); Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings');
Hook::register('addon_settings_post', 'addon/birdavatar/birdavatar.php', 'birdavatar_addon_settings_post'); Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post');
Logger::log('registered birdavatar'); Logger::log('registered birdavatar');
} }
@ -34,24 +34,29 @@ function birdavatar_install()
/** /**
* Bird avatar user settings page * Bird avatar user settings page
*/ */
function birdavatar_addon_settings(App $a, &$s) function birdavatar_addon_settings(App $a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
} }
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/birdavatar/'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/birdavatar/');
$s .= Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$postpost' => !empty($_POST['birdavatar-morebird']) || !empty($_POST['birdavatar-emailbird']),
'$uncache' => time(), '$uncache' => time(),
'$uid' => local_user(), '$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.'), '$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" <p>{{$setrandomize}}</p>
style="{{if $postpost}}display: none;{{else}}display: block;{{/if}}" <p><img src="{{$basepath}}/birdavatar/{{$uid}}?{{$uncache}}"></p>
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>

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\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -25,39 +26,25 @@ function blockem_install()
Hook::register('enotify_store' , 'addon/blockem/blockem.php', 'blockem_enotify_store'); 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()) { if (!local_user()) {
return; return;
} }
/* Add our stylesheet to the page so we can make our settings look nice */ $words = DI::pConfig()->get(local_user(), 'blockem', 'words', '');
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'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/blockem/');
$html = Renderer::replaceMacros($t, [
if (!$words) { '$info' => DI::l10n()->t("Hides user's content by collapsing posts. Also replaces their avatar with generic image."),
$words = ''; '$words' => ['blockem-words', DI::l10n()->t('Comma separated profile URLS:'), $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;
$data = [
'addon' => 'blockem',
'title' => DI::l10n()->t('Blockem'),
'html' => $html,
];
} }
function blockem_addon_settings_post(App $a, array &$b) 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() function catavatar_install()
{ {
Hook::register('avatar_lookup', 'addon/catavatar/catavatar.php', 'catavatar_lookup'); Hook::register('avatar_lookup', __FILE__, 'catavatar_lookup');
Hook::register('addon_settings', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings'); Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings');
Hook::register('addon_settings_post', 'addon/catavatar/catavatar.php', 'catavatar_addon_settings_post'); Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post');
Logger::notice('registered catavatar'); Logger::notice('registered catavatar');
} }
@ -35,24 +35,29 @@ function catavatar_install()
/** /**
* Cat avatar user settings page * Cat avatar user settings page
*/ */
function catavatar_addon_settings(App $a, &$s) function catavatar_addon_settings(App $a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
} }
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/catavatar/'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/catavatar/');
$s .= Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$postpost' => !empty($_POST['catavatar-morecat']) || !empty($_POST['catavatar-emailcat']), '$uncache' => time(),
'$uncache' => time(), '$uid' => local_user(),
'$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'),
'$setrandomize' => DI::l10n()->t('Set default profile avatar or randomize the cat.'), '$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" <p>{{$setrandomize}}</p>
style="{{if $postpost}}display: none;{{else}}display: block;{{/if}}" <p><img src="{{$basepath}}/catavatar/{{$uid}}?{{$uncache}}"></p>
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>

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'])); 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()) { if (!local_user()) {
return; 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'); $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.'); $noappidtext = DI::l10n()->t('No APPID found, please contact your admin to obtain one.');
} else { } else {
$noappidtext = ''; $noappidtext = '';
} }
$enable = intval(DI::pConfig()->get(local_user(), 'curweather', 'curweather_enable')); $enabled = 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/');
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/curweather/" ); $html = Renderer::replaceMacros($t, [
'$noappidtext' => $noappidtext,
$s = Renderer::replaceMacros($t, [ '$info' => DI::l10n()->t('Enter either the name of your location or the zip code.'),
'$submit' => DI::l10n()->t('Save Settings'), '$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>.')],
'$header' => DI::l10n()->t('Current Weather').' '.DI::l10n()->t('Settings'), '$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']],
'$noappidtext' => $noappidtext, '$enabled' => ['curweather_enable', DI::l10n()->t('Show weather data'), $enabled, ''],
'$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, '']
]); ]);
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 // 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');"> {{if $noappidtext}}
<h3>{{$header}}</h3> <p style="color: red; font-weight: bold;">{{$noappidtext}}</p>
</span> {{/if}}
<div id="settings_curweather_expanded" class="settings-block" style="display: none;"> {{include file="field_input.tpl" field=$curweather_loc}}
<span class="fakelink" onclick="openClose('settings_curweather_expanded'); openClose('settings_curweather_inflated');"> {{include file="field_select.tpl" field=$curweather_units}}
<h3>{{$header}}</h3> {{include file="field_checkbox.tpl" field=$enabled}}
</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>

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 * Author: Commander Zot
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function fromapp_install() function fromapp_install()
@ -28,47 +31,26 @@ function fromapp_settings_post($a, $post)
DI::pConfig()->set(local_user(), 'fromapp', 'force', intval($_POST['fromapp-force'])); 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()) { if (!local_user()) {
return; 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', ''); $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" ' : ''); $data = [
'addon' => 'fromapp',
'title' => DI::l10n()->t('FromApp Settings'),
/* Add some HTML to the existing form */ 'html' => $html,
];
$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>';
} }
function fromapp_post_hook(&$a, &$item) 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. * Called from the Addon Setting form.
* Add our own settings info to the page. * Add our own settings info to the page.
* *
* @param App $a * @param App $a
* @param string $s * @param array $data
* @throws Exception * @throws Exception
*/ */
function geonames_addon_settings(App $a, &$s) function geonames_addon_settings(App $a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
} }
$geo_account = DI::config()->get('geonames', 'username'); $geo_account = DI::config()->get('geonames', 'username');
if (!$geo_account) { if (!$geo_account) {
return; return;
} }
DI::page()->registerStylesheet(__DIR__ . '/geonames.css');
/* Get the current state of our config variable */
$enabled = intval(DI::pConfig()->get(local_user(), 'geonames', 'enable')); $enabled = intval(DI::pConfig()->get(local_user(), 'geonames', 'enable'));
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/geonames/'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/geonames/');
$s .= Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t('Geonames Settings'), '$info' => DI::l10n()->t('Replace numerical coordinates by the nearest populated location name in your posts.'),
'$description' => 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], '$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');"> <p>{{$info}}</p>
<h3>{{$title}}</h3> {{include file="field_checkbox.tpl" field=$enable}}
</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>

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\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -49,31 +50,25 @@ function gnot_settings_post($a,$post) {
function gnot_settings(&$a,&$s) { function gnot_settings(App &$a, array &$data)
{
if(! local_user()) if (!local_user()) {
return; 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"; $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/');
$html = Renderer::replaceMacros($t, [
/* Get the current state of our config variable */ '$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],
$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.")
]); ]);
$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\');"> <p>{{$text}}</p>
<h3>{{$title}}</h3> {{include file="field_checkbox.tpl" field=$enabled}}
</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>

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 * Version: 1.0
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer> * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function group_text_install() { function group_text_install() {
@ -42,31 +45,22 @@ function group_text_settings_post($a,$post) {
function group_text_settings(&$a,&$s) { function group_text_settings(App &$a, array &$data)
{
if(! local_user()) if (!local_user()) {
return; 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'); $enabled = DI::pConfig()->get(local_user(),'system','groupedit_image_limit');
$checked = (($enabled) ? ' checked="checked" ' : '');
/* Add some HTML to the existing form */ $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/group_text/');
$html = Renderer::replaceMacros($t, [
$s .= '<div class="settings-block">'; '$enabled' => ['group_text', DI::l10n()->t('Use a text only (non-image) group selector in the "group edit" menu'), $enabled],
$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>';
$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> * Author: Tobias Diekershoff <https://f.diekershoff.de/u/tobias>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
@ -17,30 +18,27 @@ function irc_install() {
Hook::register('addon_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post'); Hook::register('addon_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post');
} }
function irc_addon_settings(&$a,&$s) { function irc_addon_settings(App &$a, array &$data)
if(! local_user()) {
if (!local_user()) {
return; 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"; $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/irc/');
$html = Renderer::replaceMacros($t, [
/* setting popular channels, auto connect channels */ '$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.'),
$sitechats = DI::pConfig()->get( local_user(), 'irc','sitechats'); /* popular channels */ '$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.')],
$autochans = DI::pConfig()->get( local_user(), 'irc','autochans'); /* auto connect chans */ '$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/" );
$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.') ]
]); ]);
$data = [
return; 'addon' => 'irc',
'title' => DI::l10n()->t('IRC Settings'),
'html' => $html,
];
} }
function irc_addon_settings_post(&$a, &$b) { 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');"> <p>{{$info}}</p>
<h3>{{$header}}</h3> {{include file="field_input.tpl" field=$autochans}}
</span> {{include file="field_input.tpl" field=$sitechats}}
<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>

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 *"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function krynn_install() { function krynn_install() {
@ -111,42 +114,24 @@ function krynn_settings_post($a,$post) {
function krynn_settings(&$a,&$s) { function krynn_settings(App &$a, array &$data)
{
if(! local_user()) if(! local_user()) {
return; 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'); $enabled = DI::pConfig()->get(local_user(),'krynn','enable');
$checked = (($enabled) ? ' checked="checked" ' : ''); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/krynn/');
$html = Renderer::replaceMacros($t, [
/* Add some HTML to the existing form */ '$enabled' => ['krynn', DI::l10n()->t('Enable Krynn Addon'), $enabled],
]);
$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>';
$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 * 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()) { if (!local_user()) {
return; return;
@ -40,23 +40,25 @@ function langfilter_addon_settings(App $a, &$s)
$enabled = DI::pConfig()->get(local_user(), 'langfilter', 'enable', $enabled = DI::pConfig()->get(local_user(), 'langfilter', 'enable',
!DI::pConfig()->get(local_user(), 'langfilter', 'disable')); !DI::pConfig()->get(local_user(), 'langfilter', 'disable'));
$enable_checked = $enabled ? ' checked="checked"' : ''; $languages = DI::pConfig()->get(local_user(), 'langfilter', 'languages');
$languages = DI::pConfig()->get(local_user(), 'langfilter', 'languages'); $minconfidence = DI::pConfig()->get(local_user(), 'langfilter', 'minconfidence', 0) * 100;
$minconfidence = DI::pConfig()->get(local_user(), 'langfilter', 'minconfidence', 0) * 100; $minlength = DI::pConfig()->get(local_user(), 'langfilter', 'minlength', 32);
$minlength = DI::pConfig()->get(local_user(), 'langfilter', 'minlength' , 32);
$t = Renderer::getMarkupTemplate("settings.tpl", "addon/langfilter/"); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/langfilter/');
$s .= Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t("Language Filter"),
'$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.'), '$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".')], '$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.')], '$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).')], '$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 /* 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');"> <p>{{$intro}}</p>
<h3>{{$title}}</h3> {{include file="field_checkbox.tpl" field=$enabled}}
</span> {{include file="field_input.tpl" field=$languages}}
<div id="settings_langfilter_expanded" class="settings-block" style="display: none;"> {{include file="field/range_percent.tpl" field=$minconfidence}}
<span class="fakelink" onclick="openClose('settings_langfilter_expanded'); openClose('settings_langfilter_inflated');"> {{include file="field_input.tpl" field=$minlength}}
<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>

View File

@ -6,6 +6,7 @@
* Author: Matthew Exon <http://mat.exon.name> * Author: Matthew Exon <http://mat.exon.name>
*/ */
use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -462,51 +463,58 @@ function mailstream_convert_table_entries()
/** /**
* Form for configuring mailstream features for a user * Form for configuring mailstream features for a user
* *
* @param Friendica\App $a App object * @param App $a App object
* @param string $o HTML form data * @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'); $enabled = DI::pConfig()->get(local_user(), 'mailstream', 'enabled');
$address = DI::pConfig()->get(local_user(), 'mailstream', 'address'); $address = DI::pConfig()->get(local_user(), 'mailstream', 'address');
$nolikes = DI::pConfig()->get(local_user(), 'mailstream', 'nolikes'); $nolikes = DI::pConfig()->get(local_user(), 'mailstream', 'nolikes');
$attachimg= DI::pConfig()->get(local_user(), 'mailstream', 'attachimg'); $attachimg = DI::pConfig()->get(local_user(), 'mailstream', 'attachimg');
$template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/');
$s .= Renderer::replaceMacros($template, [ $template = Renderer::getMarkupTemplate('settings.tpl', 'addon/mailstream/');
'$enabled' => [ $html = Renderer::replaceMacros($template, [
'$enabled' => [
'mailstream_enabled', 'mailstream_enabled',
DI::l10n()->t('Enabled'), DI::l10n()->t('Enabled'),
$enabled $enabled
], ],
'$address' => [ '$address' => [
'mailstream_address', 'mailstream_address',
DI::l10n()->t('Email Address'), DI::l10n()->t('Email Address'),
$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', 'mailstream_nolikes',
DI::l10n()->t('Exclude Likes'), DI::l10n()->t('Exclude Likes'),
$nolikes, $nolikes,
DI::l10n()->t("Check this to omit mailing \"Like\" notifications") DI::l10n()->t('Check this to omit mailing "Like" notifications')
], ],
'$attachimg' => [ '$attachimg' => [
'mailstream_attachimg', 'mailstream_attachimg',
DI::l10n()->t('Attach Images'), DI::l10n()->t('Attach Images'),
$attachimg, $attachimg,
DI::l10n()->t("Download images in posts and attach them to the email. " . DI::l10n()->t('Download images in posts and attach them to the email. ' .
"Useful for reading email while offline.") '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 * Process data submitted to user's mailstream features form
* @param \Friendica\App $a * @param App $a
* @param array $post POST data * @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'])) { if (!local_user() || empty($post['mailstream-submit'])) {
return; 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');"> {{include file="field_checkbox.tpl" field=$enabled}}
<h3>{{$title}}</h3> {{include file="field_input.tpl" field=$address}}
</span> {{include file="field_checkbox.tpl" field=$nolikes}}
<div id="settings_mailstream_expanded" class="settings-block" style="display: none;"> {{include file="field_checkbox.tpl" field=$attachimg}}
<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>

View File

@ -17,7 +17,7 @@ function markdown_install() {
Hook::register('addon_settings_post', __FILE__, 'markdown_addon_settings_post'); 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()) { if (!local_user()) {
return; return;
@ -25,12 +25,16 @@ function markdown_addon_settings(App $a, &$s)
$enabled = intval(DI::pConfig()->get(local_user(), 'markdown', 'enabled')); $enabled = intval(DI::pConfig()->get(local_user(), 'markdown', 'enabled'));
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
$s .= Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$title' => DI::l10n()->t('Markdown'), '$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
'$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'),
]); ]);
$data = [
'addon' => 'markdown',
'title' => DI::l10n()->t('Markdown Settings'),
'html' => $html,
];
} }
function markdown_addon_settings_post(App $a, &$b) 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');"> {{include file="field_checkbox.tpl" field=$enabled}}
<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>

View File

@ -29,7 +29,7 @@ function mathjax_settings_post($a)
DI::pConfig()->set(local_user(), 'mathjax', 'use', intval($_POST['mathjax_use'])); 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()) { if (!local_user()) {
return; return;
@ -38,12 +38,16 @@ function mathjax_settings(App $a, &$s)
$use = DI::pConfig()->get(local_user(), 'mathjax', 'use', false); $use = DI::pConfig()->get(local_user(), 'mathjax', 'use', false);
$tpl = Renderer::getMarkupTemplate('settings.tpl', 'addon/mathjax'); $tpl = Renderer::getMarkupTemplate('settings.tpl', 'addon/mathjax');
$s .= Renderer::replaceMacros($tpl, [ $html = Renderer::replaceMacros($tpl, [
'$title' => 'MathJax',
'$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.'), '$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, ''], '$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) function mathjax_footer(App $a, &$b)

View File

@ -1,16 +1,2 @@
<p>{{$description}}</p>
<span id="settings_mathjax_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_mathjax_expanded'); openClose('settings_mathjax_inflated');"> {{include file="field_checkbox.tpl" field=$mathjax_use}}
<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>

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> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function nsfw_install() function nsfw_install()
@ -48,41 +51,27 @@ function nsfw_extract_photos($body)
return $new_body; return $new_body;
} }
function nsfw_addon_settings(&$a, &$s) function nsfw_addon_settings(App &$a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; 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" '); $data = [
$words = DI::pConfig()->get(local_user(), 'nsfw', 'words'); 'addon' => 'nsfw',
if (!$words) { 'title' => DI::l10n()->t('Content Filter (NSFW and more)'),
$words = 'nsfw,'; 'html' => $html,
} ];
$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;
} }
function nsfw_addon_settings_post(&$a, &$b) 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; $words = null;
if (DI::pConfig()->get(local_user(), 'nsfw', 'disable')) { if (DI::pConfig()->get(local_user(), 'nsfw', 'disable')) {

View File

@ -0,0 +1,3 @@
<p>{{$info}}</p>
{{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_textarea.tpl" field=$words}}

View File

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

View File

@ -5,8 +5,11 @@
* Version: 1.0 * Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function numfriends_install() { function numfriends_install() {
@ -39,30 +42,22 @@ function numfriends_settings_post($a,$post) {
* Add our own settings info to the page. * Add our own settings info to the page.
* *
*/ */
function numfriends_settings(&$a, &$s) function numfriends_settings(App &$a, array &$data)
{ {
if (! local_user()) { if (! local_user()) {
return; 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/numfriends/numfriends.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$numfriends = DI::pConfig()->get(local_user(), 'system', 'display_friend_count', 24); $numfriends = DI::pConfig()->get(local_user(), 'system', 'display_friend_count', 24);
/* Add some HTML to the existing form */ $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/numfriends/');
$html = Renderer::replaceMacros($t, [
'$numfriends' => ['numfriends', DI::l10n()->t('How many contacts to display on profile sidebar'), $numfriends],
]);
$s .= '<div class="settings-block">'; $data = [
$s .= '<h3>' . DI::l10n()->t('Numfriends Settings') . '</h3>'; 'addon' => 'numfriends',
$s .= '<div id="numfriends-wrapper">'; 'title' => DI::l10n()->t('Numfriends Settings'),
$s .= '<label id="numfriends-label" for="numfriends">' . DI::l10n()->t('How many contacts to display on profile sidebar') . '</label>'; 'html' => $html,
$s .= '<input id="numfriends-input" type="text" name="numfriends" value="' . intval($numfriends) . '" ' . '/>'; ];
$s .= '</div><div class="clear"></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="numfriends-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
} }

View File

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

View File

@ -68,17 +68,17 @@ function opmlexport(App $a)
} }
function opmlexport_addon_settings(App $a, &$s) function opmlexport_addon_settings(App $a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
} }
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/opmlexport/'); $data = [
$s .= Renderer::replaceMacros($t, [ 'addon' => 'opmlexport',
'$title' => DI::l10n()->t('OPML Export'), 'title' => DI::l10n()->t('OPML Export'),
'$submit' => DI::l10n()->t('Export RSS/Atom contacts'), 'submit' => DI::l10n()->t('Export RSS/Atom contacts'),
]); ];
} }

View File

@ -1,12 +0,0 @@
<span id="settings_opmlexport_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_opmlexport_expanded'); openClose('settings_opmlexport_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="settings_opmlexport_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_opmlexport_expanded'); openClose('settings_opmlexport_inflated');">
<h3>{{$title}}</h3>
</span>
<div class="settings-submit-wrapper" >
<input type="submit" id="opmlexport-submit" name="opmlexport-submit" class="settings-submit" value="{{$submit}}" />
</div>
</div>

View File

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

View File

@ -6,8 +6,11 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* Author: Tony Baldwin <https://free-haven.org/profile/tony> * Author: Tony Baldwin <https://free-haven.org/profile/tony>
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function planets_install() { function planets_install() {
@ -110,40 +113,22 @@ function planets_settings_post($a,$post) {
function planets_settings(&$a,&$s) { function planets_settings(App &$a, array &$data)
{
if(! local_user()) if(! local_user()) {
return; 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/planets/planets.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$enabled = DI::pConfig()->get(local_user(),'planets','enable'); $enabled = DI::pConfig()->get(local_user(),'planets','enable');
$checked = (($enabled) ? ' checked="checked" ' : ''); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/planets/');
$html = Renderer::replaceMacros($t, [
/* Add some HTML to the existing form */ '$enabled' => ['planets', DI::l10n()->t('Enable Planets Addon'), $enabled],
]);
$s .= '<span id="settings_planets_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_planets_expanded\'); openClose(\'settings_planets_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Planets') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_planets_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_planets_expanded\'); openClose(\'settings_planets_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Planets') . '</h3>';
$s .= '</span>';
$s .= '<div class="settings-block">';
$s .= '<h3>' . DI::l10n()->t('Planets Settings') . '</h3>';
$s .= '<div id="planets-enable-wrapper">';
$s .= '<label id="planets-enable-label" for="planets-checkbox">' . DI::l10n()->t('Enable Planets Addon') . '</label>';
$s .= '<input id="planets-checkbox" type="checkbox" name="planets" value="1" ' . $checked . '/>';
$s .= '</div><div class="clear"></div></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="planets-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
$data = [
'addon' => 'planets',
'title' => DI::l10n()->t('Planets Settings'),
'html' => $html,
];
} }

View File

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

View File

@ -17,7 +17,10 @@
* them to open the comment window fully and insert the qcomment. Then "Submit" will submit it. * them to open the comment window fully and insert the qcomment. Then "Submit" will submit it.
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -28,27 +31,30 @@ function qcomment_install()
Hook::register('footer' , __FILE__, 'qcomment_footer'); Hook::register('footer' , __FILE__, 'qcomment_footer');
} }
function qcomment_footer(\Friendica\App $a, &$b) function qcomment_footer(App $a, &$b)
{ {
DI::page()->registerFooterScript('addon/qcomment/qcomment.js'); DI::page()->registerFooterScript('addon/qcomment/qcomment.js');
} }
function qcomment_addon_settings(&$a, &$s) function qcomment_addon_settings(App &$a, array &$data)
{ {
if (! local_user()) { if (!local_user()) {
return; return;
} }
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words', DI::l10n()->t(':-)') . "\n" . DI::l10n()->t(':-(') . "\n" . DI::l10n()->t('lol')); $words = DI::pConfig()->get(local_user(), 'qcomment', 'words', DI::l10n()->t(':-)') . "\n" . DI::l10n()->t(':-(') . "\n" . DI::l10n()->t('lol'));
$t = \Friendica\Core\Renderer::getMarkupTemplate('settings.tpl', 'addon/qcomment/'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/qcomment/');
$s .= \Friendica\Core\Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$postpost' => isset($_POST['qcomment-words']), '$description' => DI::l10n()->t('Quick comments are found near comment boxes, sometimes hidden. Click them to provide simple replies.'),
'$header' => DI::l10n()->t('Quick Comment Settings'),
'$description' => DI::l10n()->t("Quick comments are found near comment boxes, sometimes hidden. Click them to provide simple replies."),
'$save' => DI::l10n()->t('Save Settings'),
'$words' => ['qcomment-words', DI::l10n()->t('Enter quick comments, one per line'), $words, null, ' rows="10"'], '$words' => ['qcomment-words', DI::l10n()->t('Enter quick comments, one per line'), $words, null, ' rows="10"'],
]); ]);
$data = [
'addon' => 'qcomment',
'title' => DI::l10n()->t('Quick Comment Settings'),
'html' => $html,
];
} }
function qcomment_addon_settings_post(&$a, &$b) function qcomment_addon_settings_post(&$a, &$b)

View File

@ -1,21 +1,2 @@
<span id="settings_qcomment_inflated" class="settings-block fakelink" <p>{{$description}}</p>
style="{{if $postpost}}display: none;{{else}}display: block;{{/if}}" {{include file="field_textarea.tpl" field=$words}}
onclick="openClose('settings_qcomment_expanded'); openClose('settings_qcomment_inflated');">
<h3>{{$header}}</h3>
</span>
<div id="settings_qcomment_expanded" class="settings-block"
style="{{if $postpost}}display: block;{{else}}display: none;{{/if}}">
<span class="fakelink" onclick="openClose('settings_qcomment_expanded'); openClose('settings_qcomment_inflated');">
<h3>{{$header}}</h3>
</span>
<div id="qcomment-wrapper">
<p id="qcomment-desc">{{$description}}</p>
{{include file="field_textarea.tpl" field=$words}}
<div class="settings-submit-wrapper">
<button type="submit" id="qcomment-submit" name="qcomment-submit" class="btn btn-primary settings-submit">{{$save}}</button>
</div>
</div>
</div>

View File

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

View File

@ -18,8 +18,11 @@
* system will call the name_uninstall() function. * system will call the name_uninstall() function.
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function randplace_install() { function randplace_install() {
@ -145,32 +148,22 @@ function randplace_settings_post($a,$post) {
function randplace_settings(&$a,&$s) { function randplace_settings(App &$a, array &$data)
{
if(! local_user()) if(! local_user()) {
return; 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/randplace/randplace.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$enabled = DI::pConfig()->get(local_user(),'randplace','enable'); $enabled = DI::pConfig()->get(local_user(),'randplace','enable');
$checked = (($enabled) ? ' checked="checked" ' : ''); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/randplace/');
$html = Renderer::replaceMacros($t, [
/* Add some HTML to the existing form */ '$enabled' => ['randplace', DI::l10n()->t('Enable Randplace Addon'), $enabled],
]);
$s .= '<div class="settings-block">';
$s .= '<h3>' . DI::l10n()->t('Randplace Settings') . '</h3>';
$s .= '<div id="randplace-enable-wrapper">';
$s .= '<label id="randplace-enable-label" for="randplace-checkbox">' . DI::l10n()->t('Enable Randplace Addon') . '</label>';
$s .= '<input id="randplace-checkbox" type="checkbox" name="randplace" value="1" ' . $checked . '/>';
$s .= '</div><div class="clear"></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="randplace-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
$data = [
'addon' => 'randplace',
'title' => DI::l10n()->t('Randplace Settings'),
'html' => $html,
];
} }

View File

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

View File

@ -36,24 +36,30 @@ function securemail_install()
* *
* @see App * @see App
*/ */
function securemail_settings(App &$a, &$s) function securemail_settings(App &$a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
} }
$enable = intval(DI::pConfig()->get(local_user(), 'securemail', 'enable')); $enabled = intval(DI::pConfig()->get(local_user(), 'securemail', 'enable'));
$publickey = DI::pConfig()->get(local_user(), 'securemail', 'pkey'); $publickey = DI::pConfig()->get(local_user(), 'securemail', 'pkey');
$t = Renderer::getMarkupTemplate('admin.tpl', 'addon/securemail/'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/securemail/');
$html = Renderer::replaceMacros($t, [
$s .= Renderer::replaceMacros($t, [ '$enabled' => ['securemail-enable', DI::l10n()->t('Enable Secure Mail'), $enabled],
'$title' => DI::l10n()->t('"Secure Mail" Settings'),
'$submit' => DI::l10n()->t('Save Settings'),
'$test' => DI::l10n()->t('Save and send test'), //NOTE: update also in 'post'
'$enable' => ['securemail-enable', DI::l10n()->t('Enable Secure Mail'), $enable, ''],
'$publickey' => ['securemail-pkey', DI::l10n()->t('Public key'), $publickey, DI::l10n()->t('Your public PGP key, ascii armored format')] '$publickey' => ['securemail-pkey', DI::l10n()->t('Public key'), $publickey, DI::l10n()->t('Your public PGP key, ascii armored format')]
]); ]);
$data = [
'addon' => 'securemail',
'title' => DI::l10n()->t('"Secure Mail" Settings'),
'html' => $html,
'submit' => [
'securemail-submit' => DI::l10n()->t('Save Settings'),
'securemail-test' => DI::l10n()->t('Save and send test'),
],
];
} }
/** /**
@ -72,13 +78,12 @@ function securemail_settings_post(App &$a, array &$b)
return; return;
} }
if ($_POST['securemail-submit']) { if (!empty($_POST['securemail-submit']) || !empty($_POST['securemail-test'])) {
DI::pConfig()->set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey'])); DI::pConfig()->set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
$enable = (!empty($_POST['securemail-enable']) ? 1 : 0); $enable = (!empty($_POST['securemail-enable']) ? 1 : 0);
DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable); DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable);
if ($_POST['securemail-submit'] == 'test') { if (!empty($_POST['securemail-test'])) {
$res = DI::emailer()->send(new SecureTestEmail(DI::app(), DI::config(), DI::pConfig(), DI::baseUrl())); $res = DI::emailer()->send(new SecureTestEmail(DI::app(), DI::config(), DI::pConfig(), DI::baseUrl()));
// revert to saved value // revert to saved value

View File

@ -1,16 +0,0 @@
<span id="settings_securemail_inflated" class="settings-block fakelink" style="display: block" onclick="openClose('settings_securemail_expanded'); openClose('settings_securemail_inflated');">
<h3>{{$title}}</h3>
</span>
<div id="settings_securemail_expanded" class="settings-block" style="display: none">
<span class="fakelink" onclick="openClose('settings_securemail_expanded'); openClose('settings_securemail_inflated');"><h3>{{$title}}</h3></span>
<div id="securemail-wrapper">
{{include file="field_checkbox.tpl" field=$enable}}
{{include file="field_textarea.tpl" field=$publickey}}
<div class="form-group pull-right settings-submit-wrapper" >
<button type="submit" name="securemail-submit" class="btn btn-primary" value="submit">{{$submit}}</button>
<button type="submit" name="securemail-submit" class="btn btn-default" value="test">{{$test}}</button>
</div>
<div class="clear"></div>
</div>
</div>

View File

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

View File

@ -7,7 +7,10 @@
* based upon NSFW from Mike Macgirvin <http://macgirvin.com/profile/mike> * based upon NSFW from Mike Macgirvin <http://macgirvin.com/profile/mike>
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -18,7 +21,7 @@ function showmore_install()
Hook::register('addon_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post'); Hook::register('addon_settings_post', 'addon/showmore/showmore.php', 'showmore_addon_settings_post');
} }
function showmore_addon_settings(&$a, &$s) function showmore_addon_settings(App &$a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
@ -26,31 +29,20 @@ function showmore_addon_settings(&$a, &$s)
DI::page()->registerStylesheet(__DIR__ . '/showmore.css', 'all'); DI::page()->registerStylesheet(__DIR__ . '/showmore.css', 'all');
$enable_checked = (intval(DI::pConfig()->get(local_user(), 'showmore', 'disable')) ? '' : ' checked="checked"'); $enabled = !DI::pConfig()->get(local_user(), 'showmore', 'disable');
$chars = DI::pConfig()->get(local_user(), 'showmore', 'chars', 1100); $chars = DI::pConfig()->get(local_user(), 'showmore', 'chars', 1100);
$s .= '<span id="settings_showmore_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_showmore_expanded\'); openClose(\'settings_showmore_inflated\');">'; $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore/');
$s .= '<h3>' . DI::l10n()->t('"Show more" Settings').'</h3>'; $html = Renderer::replaceMacros($t, [
$s .= '</span>'; '$enabled' => ['showmore-enable', DI::l10n()->t('Enable Show More'), $enabled],
$s .= '<div id="settings_showmore_expanded" class="settings-block" style="display: none;">'; '$chars' => ['showmore-chars', DI::l10n()->t('Cutting posts after how many characters'), $chars],
$s .= '<span class="fakelink" onclick="openClose(\'settings_showmore_expanded\'); openClose(\'settings_showmore_inflated\');">'; ]);
$s .= '<h3>' . DI::l10n()->t('"Show more" Settings').'</h3>';
$s .= '</span>';
$s .= '<div id="showmore-wrapper">'; $data = [
'addon' => 'showmore',
$s .= '<label id="showmore-enable-label" for="showmore-enable">'.DI::l10n()->t('Enable Show More').'</label>'; 'title' => DI::l10n()->t('"Show more" Settings'),
$s .= '<input id="showmore-enable" type="checkbox" name="showmore-enable" value="1"'.$enable_checked.' />'; 'html' => $html,
$s .= '<div class="clear"></div>'; ];
$s .= '<label id="showmore-label" for="showmore-chars">'.DI::l10n()->t('Cutting posts after how much characters').' </label>';
$s .= '<input id="showmore-words" type="text" name="showmore-chars" value="'.$chars.'" />';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="showmore-submit" name="showmore-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
// $s .= '<div class="showmore-desc">' . DI::l10n()->t('Use /expression/ to provide regular expressions') . '</div>';
$s .= '</div>';
return;
} }
function showmore_addon_settings_post(&$a, &$b) function showmore_addon_settings_post(&$a, &$b)
@ -101,7 +93,7 @@ function get_body_length($body)
return strlen($string); return strlen($string);
} }
function showmore_prepare_body(\Friendica\App $a, &$hook_data) function showmore_prepare_body(App $a, &$hook_data)
{ {
// No combination with content filters // No combination with content filters
if (!empty($hook_data['filter_reasons'])) { if (!empty($hook_data['filter_reasons'])) {

View File

@ -0,0 +1,3 @@
<p>{{$info}}</p>
{{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_input.tpl" field=$chars}}

View File

@ -45,7 +45,7 @@ function showmore_dyn_settings_post()
} }
} }
function showmore_dyn_settings(App &$a, &$o) function showmore_dyn_settings(App &$a, array &$data)
{ {
if(!local_user()) { if(!local_user()) {
return; return;
@ -55,12 +55,15 @@ function showmore_dyn_settings(App &$a, &$o)
DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight);
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore_dyn/'); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore_dyn/');
$o .= Renderer::replaceMacros($t, [ $html = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'),
'$header' => DI::l10n()->t('Show More Dynamic'),
'$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, DI::l10n()->t('The maximal pixel height of posts before the Show More link is added, 0 to disable'), '', '', 'number'], '$limitHeight' => ['limitHeight', DI::l10n()->t('Limit Height'), $limitHeight, DI::l10n()->t('The maximal pixel height of posts before the Show More link is added, 0 to disable'), '', '', 'number'],
]); ]);
$data = [
'addon' => 'showmore_dyn',
'title' => DI::l10n()->t('Show More Dynamic'),
'html' => $html,
];
} }
function showmore_dyn_script() function showmore_dyn_script()

View File

@ -1,13 +1 @@
<span id="settings_showmore_dyn_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_showmore_dyn_expanded'); openClose('settings_showmore_dyn_inflated');"> {{include file="field_input.tpl" field=$limitHeight}}
<h3>{{$header}}</h3>
</span>
<div id="settings_showmore_dyn_expanded" class="settings-block" style="display: none;">
<span class="fakelink" onclick="openClose('settings_showmore_dyn_expanded'); openClose('settings_showmore_dyn_inflated');">
<h3>{{$header}}</h3>
</span>
{{include file="field_input.tpl" field=$limitHeight}}
<div class="settings-submit-wrapper">
<input type="submit" value="{{$submit}}" class="settings-submit" name="showmore_dyn-submit" />
</div>
</div>

View File

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

View File

@ -6,7 +6,10 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
function startpage_install() { function startpage_install() {
@ -54,36 +57,22 @@ function startpage_settings_post($a, $post)
* Add our own settings info to the page. * Add our own settings info to the page.
* *
*/ */
function startpage_settings(&$a, &$s) function startpage_settings(App &$a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
} }
/* Add our stylesheet to the page so we can make our settings look nice */ $startpage = DI::pConfig()->get(local_user(), 'startpage', 'startpage');
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/startpage/startpage.css' . '" media="all" />' . "\r\n"; $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/startpage/');
$html = Renderer::replaceMacros($t, [
'$startpage' => ['startpage', DI::l10n()->t('Home page to load after login - leave blank for profile wall'), $startpage, DI::l10n()->t('Examples: "network" or "notifications/system"')],
]);
/* Get the current state of our config variable */ $data = [
'addon' => 'startpage',
$page = DI::pConfig()->get(local_user(), 'startpage', 'startpage'); 'title' => DI::l10n()->t('Startpage'),
'html' => $html,
/* Add some HTML to the existing form */ ];
$s .= '<span id="settings_startpage_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Startpage') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_startpage_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Startpage') . '</h3>';
$s .= '</span>';
$s .= '<div id="startpage-page-wrapper">';
$s .= '<label id="startpage-page-label" for="startpage-page">' . DI::l10n()->t('Home page to load after login - leave blank for profile wall') . '</label>';
$s .= '<input id="startpage-page" type="text" name="startpage" value="' . $page . '" />';
$s .= '</div><div class="clear"></div>';
$s .= '<div id="startpage-desc">' . DI::l10n()->t('Examples: &quot;network&quot; or &quot;notifications/system&quot;') . '</div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="startpage-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
} }

View File

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

View File

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

View File

@ -6,7 +6,10 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* *
*/ */
use Friendica\App;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -19,35 +22,24 @@ function superblock_install()
Hook::register('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store'); Hook::register('enotify_store', 'addon/superblock/superblock.php', 'superblock_enotify_store');
} }
function superblock_addon_settings(&$a, &$s) function superblock_addon_settings(App &$a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; return;
} }
DI::page()->registerStylesheet(__DIR__ . '/superblock.css', 'all'); $blocked = DI::pConfig()->get(local_user(), 'system', 'blocked', '');
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/superblock/');
$html = Renderer::replaceMacros($t, [
'$urls' => ['superblock-words', DI::l10n()->t('Comma separated profile URLs to block'), $blocked],
]);
$words = DI::pConfig()->get(local_user(), 'system', 'blocked'); $data = [
if (!$words) { 'addon' => 'superblock',
$words = ''; 'title' => DI::l10n()->t('Superblock'),
} 'html' => $html,
];
$s .= '<span id="settings_superblock_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_superblock_expanded\'); openClose(\'settings_superblock_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Superblock') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_superblock_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_superblock_expanded\'); openClose(\'settings_superblock_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('Superblock') . '</h3>';
$s .= '</span>';
$s .= '<div id="superblock-wrapper">';
$s .= '<label id="superblock-label" for="superblock-words">' . DI::l10n()->t('Comma separated profile URLS to block') . ' </label>';
$s .= '<textarea id="superblock-words" type="text" name="superblock-words" >' . htmlspecialchars($words) . '</textarea>';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="superblock-submit" name="superblock-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
return;
} }
function superblock_addon_settings_post(&$a, &$b) function superblock_addon_settings_post(&$a, &$b)

View File

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

View File

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

View File

@ -1,36 +0,0 @@
#windowsphonepush-device_url-wrapper {
margin-top: 25px;
}
#windowsphonepush-enable-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#windowsphonepush-enable-chk {
float: left;
}
#windowsphonepush-device_url-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#windowsphonepush-device_url-text {
float: left;
background-color: #C0C0C0;
width: 500px;
}
#windowsphonepush-senditemtext-label {
float: left;
width: 200px;
margin-bottom: 25px;
}
#windowsphonepush-senditemtext-chk {
float: left;
}

View File

@ -31,6 +31,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
@ -86,48 +87,28 @@ function windowsphonepush_settings_post($a, $post)
/* Called from the Addon Setting form. /* Called from the Addon Setting form.
* Add our own settings info to the page. * Add our own settings info to the page.
*/ */
function windowsphonepush_settings(&$a, &$s) function windowsphonepush_settings(App &$a, array &$data)
{ {
if (!local_user()) { if (!local_user()) {
return; 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/windowsphonepush/windowsphonepush.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variables */
$enabled = DI::pConfig()->get(local_user(), 'windowsphonepush', 'enable'); $enabled = DI::pConfig()->get(local_user(), 'windowsphonepush', 'enable');
$checked_enabled = (($enabled) ? ' checked="checked" ' : '');
$senditemtext = DI::pConfig()->get(local_user(), 'windowsphonepush', 'senditemtext'); $senditemtext = DI::pConfig()->get(local_user(), 'windowsphonepush', 'senditemtext');
$checked_senditemtext = (($senditemtext) ? ' checked="checked" ' : '');
$device_url = DI::pConfig()->get(local_user(), 'windowsphonepush', 'device_url'); $device_url = DI::pConfig()->get(local_user(), 'windowsphonepush', 'device_url');
/* Add some HTML to the existing form */ $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/windowsphonepush/');
$s .= '<div class="settings-block">'; $html = Renderer::replaceMacros($t, [
$s .= '<h3>' . DI::l10n()->t('WindowsPhonePush Settings') . '</h3>'; '$enabled' => ['windowsphonepush', DI::l10n()->t('Enable WindowsPhonePush Addon'), $enabled],
'$senditemtext' => ['windowsphonepush-senditemtext', DI::l10n()->t('Push text of new item'), $senditemtext],
'$device_url' => ['', DI::l10n()->t('Device URL'), $device_url, '', false, ' readonly'],
]);
$s .= '<div id="windowsphonepush-enable-wrapper">'; $data = [
$s .= '<label id="windowsphonepush-enable-label" for="windowsphonepush-enable-chk">' . DI::l10n()->t('Enable WindowsPhonePush Addon') . '</label>'; 'addon' => 'windowsphonepush',
$s .= '<input id="windowsphonepush-enable-chk" type="checkbox" name="windowsphonepush" value="1" ' . $checked_enabled . '/>'; 'title' => DI::l10n()->t('WindowsPhonePush Settings'),
$s .= '</div><div class="clear"></div>'; 'html' => $html,
];
$s .= '<div id="windowsphonepush-senditemtext-wrapper">';
$s .= '<label id="windowsphonepush-senditemtext-label" for="windowsphonepush-senditemtext-chk">' . DI::l10n()->t('Push text of new item') . '</label>';
$s .= '<input id="windowsphonepush-senditemtext-chk" type="checkbox" name="windowsphonepush-senditemtext" value="1" ' . $checked_senditemtext . '/>';
$s .= '</div><div class="clear"></div>';
/* provide a submit button - enable und senditemtext can be changed by the user */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="windowsphonepush-submit" name="windowsphonepush-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div><div class="clear"></div>';
/* provide further read-only information concerning the addon (useful for */
$s .= '<div id="windowsphonepush-device_url-wrapper">';
$s .= '<label id="windowsphonepush-device_url-label" for="windowsphonepush-device_url-text">Device-URL</label>';
$s .= '<input id="windowsphonepush-device_url-text" type="text" readonly value=' . $device_url . '/>';
$s .= '</div><div class="clear"></div></div>';
return;
} }
/* Cron function used to regularly check all users on the server with active windowsphonepushaddon and send /* Cron function used to regularly check all users on the server with active windowsphonepushaddon and send