diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index 41ddffdb..3fe6884e 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -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 .= <<

$advancedcontentfilter

-HTML; - - return; + $data = [ + 'addon' => 'advancedcontentfilter', + 'title' => DI::l10n()->t('Advanced Content Filter'), + 'href' => 'advancedcontentfilter', + ]; } /* diff --git a/birdavatar/birdavatar.php b/birdavatar/birdavatar.php index af573bbd..0981b35d 100644 --- a/birdavatar/birdavatar.php +++ b/birdavatar/birdavatar.php @@ -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, + ], + ]; } /** diff --git a/birdavatar/templates/settings.tpl b/birdavatar/templates/settings.tpl index a31acfdb..13230bd1 100644 --- a/birdavatar/templates/settings.tpl +++ b/birdavatar/templates/settings.tpl @@ -1,24 +1,2 @@ - -

{{$header}}

-
-
- -

{{$header}}

-
- -

{{$setrandomize}}

-
- - -
- - -
-
-
+

{{$setrandomize}}

+

diff --git a/blockem/blockem.css b/blockem/blockem.css deleted file mode 100644 index 265b6ba8..00000000 --- a/blockem/blockem.css +++ /dev/null @@ -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; -} - diff --git a/blockem/blockem.php b/blockem/blockem.php index 3183915c..79e04c8b 100644 --- a/blockem/blockem.php +++ b/blockem/blockem.php @@ -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'] .= '' . "\r\n"; + $words = DI::pConfig()->get(local_user(), 'blockem', 'words', ''); - $words = DI::pConfig()->get(local_user(), 'blockem', 'words'); - - if (!$words) { - $words = ''; - } - - $s .= ''; - $s .= '

' . DI::l10n()->t('Blockem') . '

'; - $s .= '
'; - $s .= ''; - - 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) diff --git a/blockem/templates/settings.tpl b/blockem/templates/settings.tpl new file mode 100644 index 00000000..67398400 --- /dev/null +++ b/blockem/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_textarea.tpl" field=$words}} diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 181ac016..1304b24d 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -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, + ], + ]; } /** diff --git a/catavatar/templates/settings.tpl b/catavatar/templates/settings.tpl index 33563ffe..7659a9c8 100644 --- a/catavatar/templates/settings.tpl +++ b/catavatar/templates/settings.tpl @@ -1,24 +1,2 @@ - -

{{$header}}

-
-
- -

{{$header}}

-
- -

{{$setrandomize}}

-
- - -
- - -
-
-
+

{{$setrandomize}}

+

diff --git a/curweather/curweather.php b/curweather/curweather.php index 118c4a9a..c4b172ca 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -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. Berlin,DE or 14476,DE.') ], - '$curweather_units' => [ 'curweather_units', DI::l10n()->t('Units'), $curweather_units, DI::l10n()->t('select if the temperature should be displayed in °C or °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. Berlin,DE or 14476,DE.')], + '$curweather_units' => ['curweather_units', DI::l10n()->t('Units'), $curweather_units, DI::l10n()->t('select if the temperature should be displayed in °C or °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 diff --git a/curweather/templates/settings.tpl b/curweather/templates/settings.tpl index 09f6f506..d250b9bb 100644 --- a/curweather/templates/settings.tpl +++ b/curweather/templates/settings.tpl @@ -1,15 +1,6 @@ - -

{{$header}}

-
- +{{if $noappidtext}} +

{{$noappidtext}}

+{{/if}} +{{include file="field_input.tpl" field=$curweather_loc}} +{{include file="field_select.tpl" field=$curweather_units}} +{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/fromapp/fromapp.css b/fromapp/fromapp.css deleted file mode 100644 index 422624a1..00000000 --- a/fromapp/fromapp.css +++ /dev/null @@ -1,14 +0,0 @@ - - - -#fromapp-label, #fromapp-force-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#fromapp-input, #fromapp-force { - float: left; -} - - diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index ab1e1518..c00ad3de 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -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'] .= '' . "\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 .= ''; - $s .= '

' . DI::l10n()->t('FromApp Settings') . '

'; - $s .= '
'; - $s .= ''; + $data = [ + 'addon' => 'fromapp', + 'title' => DI::l10n()->t('FromApp Settings'), + 'html' => $html, + ]; } function fromapp_post_hook(&$a, &$item) diff --git a/fromapp/templates/settings.tpl b/fromapp/templates/settings.tpl new file mode 100644 index 00000000..c74e5783 --- /dev/null +++ b/fromapp/templates/settings.tpl @@ -0,0 +1,2 @@ +{{include file="field_input.tpl" field=$fromapp}} +{{include file="field_checkbox.tpl" field=$force}} \ No newline at end of file diff --git a/geonames/geonames.css b/geonames/geonames.css deleted file mode 100644 index 0c67e7fc..00000000 --- a/geonames/geonames.css +++ /dev/null @@ -1,14 +0,0 @@ - - - -#geonames-enable-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#geonames-checkbox { - float: left; -} - - diff --git a/geonames/geonames.php b/geonames/geonames.php index 5fdf65ef..a595a0f0 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -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, + ]; } diff --git a/geonames/templates/settings.tpl b/geonames/templates/settings.tpl index 05897b6a..796a544c 100644 --- a/geonames/templates/settings.tpl +++ b/geonames/templates/settings.tpl @@ -1,14 +1,2 @@ - -

{{$title}}

-
- -
\ No newline at end of file +

{{$info}}

+{{include file="field_checkbox.tpl" field=$enable}} diff --git a/gnot/gnot.css b/gnot/gnot.css deleted file mode 100644 index ccafdafb..00000000 --- a/gnot/gnot.css +++ /dev/null @@ -1,16 +0,0 @@ - -#gnot-desc { - margin-bottom: 10px; -} - -#gnot-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#gnot { - float: left; -} - - diff --git a/gnot/gnot.php b/gnot/gnot.php index 8b37fb1c..7acf8465 100644 --- a/gnot/gnot.php +++ b/gnot/gnot.php @@ -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'] .= '' . "\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, + ]; } diff --git a/gnot/templates/settings.tpl b/gnot/templates/settings.tpl index 1323eb4d..b153c623 100644 --- a/gnot/templates/settings.tpl +++ b/gnot/templates/settings.tpl @@ -1,20 +1,2 @@ - -

{{$title}}

-
- +

{{$text}}

+{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/group_text/group_text.css b/group_text/group_text.css deleted file mode 100644 index 4122b67e..00000000 --- a/group_text/group_text.css +++ /dev/null @@ -1,14 +0,0 @@ - - - -#group_text-enable-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#group_text-checkbox { - float: left; -} - - diff --git a/group_text/group_text.php b/group_text/group_text.php index aa644588..cb2c5eee 100644 --- a/group_text/group_text.php +++ b/group_text/group_text.php @@ -5,8 +5,11 @@ * Version: 1.0 * Author: Thomas Willingham */ + +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'] .= '' . "\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 .= '
'; - $s .= '

' . DI::l10n()->t('Group Text') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; + $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, + ]; } diff --git a/group_text/templates/settings.tpl b/group_text/templates/settings.tpl new file mode 100644 index 00000000..2f3f4ce7 --- /dev/null +++ b/group_text/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/irc/irc.php b/irc/irc.php index b441cebf..75dc89c0 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -7,6 +7,7 @@ * Author: Tobias Diekershoff */ +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'] .= '' . "\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) { diff --git a/irc/templates/settings.tpl b/irc/templates/settings.tpl index e463a59c..215b8f3f 100644 --- a/irc/templates/settings.tpl +++ b/irc/templates/settings.tpl @@ -1,15 +1,3 @@ - -

{{$header}}

-
- +

{{$info}}

+{{include file="field_input.tpl" field=$autochans}} +{{include file="field_input.tpl" field=$sitechats}} diff --git a/krynn/krynn.css b/krynn/krynn.css deleted file mode 100644 index 466a3ecd..00000000 --- a/krynn/krynn.css +++ /dev/null @@ -1,14 +0,0 @@ - - - -#krynn-enable-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#krynn-checkbox { - float: left; -} - - diff --git a/krynn/krynn.php b/krynn/krynn.php index 66cdf573..3cb7206d 100644 --- a/krynn/krynn.php +++ b/krynn/krynn.php @@ -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'] .= '' . "\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 .= ''; - $s .= '

' . DI::l10n()->t('Krynn') . '

'; - $s .= '
'; - $s .= ''; + $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, + ]; } diff --git a/krynn/templates/settings.tpl b/krynn/templates/settings.tpl new file mode 100644 index 00000000..2f3f4ce7 --- /dev/null +++ b/krynn/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index aeb53eeb..c75a07b5 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -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 diff --git a/langfilter/templates/settings.tpl b/langfilter/templates/settings.tpl index d2de7fce..1197e9f2 100644 --- a/langfilter/templates/settings.tpl +++ b/langfilter/templates/settings.tpl @@ -1,19 +1,5 @@ - -

{{$title}}

-
- +

{{$intro}}

+{{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}} diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 7e3f87f8..33959e1e 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -6,6 +6,7 @@ * Author: Matthew Exon */ +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; diff --git a/mailstream/templates/settings.tpl b/mailstream/templates/settings.tpl index aa02b274..6e5d1729 100644 --- a/mailstream/templates/settings.tpl +++ b/mailstream/templates/settings.tpl @@ -1,13 +1,4 @@ - -

{{$title}}

-
- +{{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}} diff --git a/markdown/markdown.php b/markdown/markdown.php index fe533147..283d8ee2 100644 --- a/markdown/markdown.php +++ b/markdown/markdown.php @@ -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) diff --git a/markdown/templates/settings.tpl b/markdown/templates/settings.tpl index 3d013515..2f3f4ce7 100644 --- a/markdown/templates/settings.tpl +++ b/markdown/templates/settings.tpl @@ -1,15 +1 @@ - -

{{$title}}

-
- +{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/mathjax/mathjax.php b/mathjax/mathjax.php index 9734457d..43b9d861 100644 --- a/mathjax/mathjax.php +++ b/mathjax/mathjax.php @@ -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) diff --git a/mathjax/templates/settings.tpl b/mathjax/templates/settings.tpl index e26e5a2b..0966595f 100644 --- a/mathjax/templates/settings.tpl +++ b/mathjax/templates/settings.tpl @@ -1,16 +1,2 @@ - - -

{{$title}}

-
- \ No newline at end of file +

{{$description}}

+{{include file="field_checkbox.tpl" field=$mathjax_use}} diff --git a/notimeline/templates/settings.tpl b/notimeline/templates/settings.tpl new file mode 100644 index 00000000..2f3f4ce7 --- /dev/null +++ b/notimeline/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/nsfw/nsfw.css b/nsfw/nsfw.css deleted file mode 100644 index a8c1bfe8..00000000 --- a/nsfw/nsfw.css +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php index 1cbcf7c8..67b4c188 100644 --- a/nsfw/nsfw.php +++ b/nsfw/nsfw.php @@ -7,7 +7,10 @@ * Author: Mike Macgirvin * */ + +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 .= ''; - $s .= '

' . DI::l10n()->t('Content Filter (NSFW and more)') . '

'; - $s .= '
'; - $s .= ''; - 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')) { diff --git a/nsfw/templates/settings.tpl b/nsfw/templates/settings.tpl new file mode 100644 index 00000000..1e3a2cbe --- /dev/null +++ b/nsfw/templates/settings.tpl @@ -0,0 +1,3 @@ +

{{$info}}

+{{include file="field_checkbox.tpl" field=$enabled}} +{{include file="field_textarea.tpl" field=$words}} diff --git a/numfriends/numfriends.css b/numfriends/numfriends.css deleted file mode 100644 index c92ef8dc..00000000 --- a/numfriends/numfriends.css +++ /dev/null @@ -1,14 +0,0 @@ - - - -#numfriends-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#numfriends { - float: left; -} - - diff --git a/numfriends/numfriends.php b/numfriends/numfriends.php index 7644c62d..5bea844c 100644 --- a/numfriends/numfriends.php +++ b/numfriends/numfriends.php @@ -5,8 +5,11 @@ * Version: 1.0 * Author: Mike Macgirvin */ + +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; +use Friendica\Core\Renderer; use Friendica\DI; function numfriends_install() { @@ -39,30 +42,22 @@ function numfriends_settings_post($a,$post) { * Add our own settings info to the page. * */ -function numfriends_settings(&$a, &$s) +function numfriends_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'] .= '' . "\r\n"; - - /* Get the current state of our config variable */ - $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 .= '
'; - $s .= '

' . DI::l10n()->t('Numfriends Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; + $data = [ + 'addon' => 'numfriends', + 'title' => DI::l10n()->t('Numfriends Settings'), + 'html' => $html, + ]; } diff --git a/numfriends/templates/settings.tpl b/numfriends/templates/settings.tpl new file mode 100644 index 00000000..c8221bb4 --- /dev/null +++ b/numfriends/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_input.tpl" field=$numfriends}} diff --git a/opmlexport/opmlexport.php b/opmlexport/opmlexport.php index 238185ed..c92b5960 100644 --- a/opmlexport/opmlexport.php +++ b/opmlexport/opmlexport.php @@ -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()) { return; } - $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/opmlexport/'); - $s .= Renderer::replaceMacros($t, [ - '$title' => DI::l10n()->t('OPML Export'), - '$submit' => DI::l10n()->t('Export RSS/Atom contacts'), - ]); + $data = [ + 'addon' => 'opmlexport', + 'title' => DI::l10n()->t('OPML Export'), + 'submit' => DI::l10n()->t('Export RSS/Atom contacts'), + ]; } diff --git a/opmlexport/templates/settings.tpl b/opmlexport/templates/settings.tpl deleted file mode 100644 index 9f26c512..00000000 --- a/opmlexport/templates/settings.tpl +++ /dev/null @@ -1,12 +0,0 @@ - -

{{$title}}

-
- diff --git a/planets/planets.css b/planets/planets.css deleted file mode 100644 index 668b65bc..00000000 --- a/planets/planets.css +++ /dev/null @@ -1,14 +0,0 @@ - - - -#planets-enable-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#planets-checkbox { - float: left; -} - - diff --git a/planets/planets.php b/planets/planets.php index 14ae0b3c..ef88db13 100644 --- a/planets/planets.php +++ b/planets/planets.php @@ -6,8 +6,11 @@ * Author: Mike Macgirvin * Author: Tony Baldwin */ + +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; +use Friendica\Core\Renderer; use Friendica\DI; function planets_install() { @@ -110,40 +113,22 @@ function planets_settings_post($a,$post) { -function planets_settings(&$a,&$s) { - - if(! local_user()) +function planets_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'] .= '' . "\r\n"; - - /* Get the current state of our config variable */ + } $enabled = DI::pConfig()->get(local_user(),'planets','enable'); - $checked = (($enabled) ? ' checked="checked" ' : ''); - - /* Add some HTML to the existing form */ - - $s .= ''; - $s .= '

' . DI::l10n()->t('Planets') . '

'; - $s .= '
'; - $s .= ''; + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/planets/'); + $html = Renderer::replaceMacros($t, [ + '$enabled' => ['planets', DI::l10n()->t('Enable Planets Addon'), $enabled], + ]); + $data = [ + 'addon' => 'planets', + 'title' => DI::l10n()->t('Planets Settings'), + 'html' => $html, + ]; } diff --git a/planets/templates/settings.tpl b/planets/templates/settings.tpl new file mode 100644 index 00000000..2f3f4ce7 --- /dev/null +++ b/planets/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/qcomment/qcomment.php b/qcomment/qcomment.php index f662aecc..aec4e9bf 100644 --- a/qcomment/qcomment.php +++ b/qcomment/qcomment.php @@ -17,7 +17,10 @@ * 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\Renderer; use Friendica\DI; use Friendica\Util\XML; @@ -28,27 +31,30 @@ function qcomment_install() 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'); } -function qcomment_addon_settings(&$a, &$s) +function qcomment_addon_settings(App &$a, array &$data) { - if (! local_user()) { + if (!local_user()) { 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/'); - $s .= \Friendica\Core\Renderer::replaceMacros($t, [ - '$postpost' => isset($_POST['qcomment-words']), - '$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'), + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/qcomment/'); + $html = Renderer::replaceMacros($t, [ + '$description' => DI::l10n()->t('Quick comments are found near comment boxes, sometimes hidden. Click them to provide simple replies.'), '$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) diff --git a/qcomment/templates/settings.tpl b/qcomment/templates/settings.tpl index 31ccea86..a9bf0d2e 100644 --- a/qcomment/templates/settings.tpl +++ b/qcomment/templates/settings.tpl @@ -1,21 +1,2 @@ - -

{{$header}}

-
-
- -

{{$header}}

-
- -
-

{{$description}}

- - {{include file="field_textarea.tpl" field=$words}} - -
- -
-
-
+

{{$description}}

+{{include file="field_textarea.tpl" field=$words}} diff --git a/randplace/randplace.css b/randplace/randplace.css deleted file mode 100644 index bd7af6d7..00000000 --- a/randplace/randplace.css +++ /dev/null @@ -1,14 +0,0 @@ - - - -#randplace-enable-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#randplace-checkbox { - float: left; -} - - diff --git a/randplace/randplace.php b/randplace/randplace.php index d831bfe3..69ad4d52 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -18,8 +18,11 @@ * system will call the name_uninstall() function. * */ + +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Logger; +use Friendica\Core\Renderer; use Friendica\DI; function randplace_install() { @@ -145,32 +148,22 @@ function randplace_settings_post($a,$post) { -function randplace_settings(&$a,&$s) { - - if(! local_user()) +function randplace_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'] .= '' . "\r\n"; - - /* Get the current state of our config variable */ + } $enabled = DI::pConfig()->get(local_user(),'randplace','enable'); - $checked = (($enabled) ? ' checked="checked" ' : ''); - - /* Add some HTML to the existing form */ - - $s .= '
'; - $s .= '

' . DI::l10n()->t('Randplace Settings') . '

'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - /* provide a submit button */ - - $s .= '
'; + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/randplace/'); + $html = Renderer::replaceMacros($t, [ + '$enabled' => ['randplace', DI::l10n()->t('Enable Randplace Addon'), $enabled], + ]); + $data = [ + 'addon' => 'randplace', + 'title' => DI::l10n()->t('Randplace Settings'), + 'html' => $html, + ]; } diff --git a/randplace/templates/settings.tpl b/randplace/templates/settings.tpl new file mode 100644 index 00000000..2f3f4ce7 --- /dev/null +++ b/randplace/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_checkbox.tpl" field=$enabled}} diff --git a/securemail/securemail.php b/securemail/securemail.php index 9ab596ab..62673eb1 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -36,24 +36,30 @@ function securemail_install() * * @see App */ -function securemail_settings(App &$a, &$s) +function securemail_settings(App &$a, array &$data) { if (!local_user()) { 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'); - $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/securemail/'); - - $s .= Renderer::replaceMacros($t, [ - '$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, ''], + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/securemail/'); + $html = Renderer::replaceMacros($t, [ + '$enabled' => ['securemail-enable', DI::l10n()->t('Enable Secure Mail'), $enabled], '$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; } - if ($_POST['securemail-submit']) { + if (!empty($_POST['securemail-submit']) || !empty($_POST['securemail-test'])) { DI::pConfig()->set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey'])); $enable = (!empty($_POST['securemail-enable']) ? 1 : 0); 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())); // revert to saved value diff --git a/securemail/templates/admin.tpl b/securemail/templates/admin.tpl deleted file mode 100644 index ec35e332..00000000 --- a/securemail/templates/admin.tpl +++ /dev/null @@ -1,16 +0,0 @@ - -

{{$title}}

-
- diff --git a/securemail/templates/settings.tpl b/securemail/templates/settings.tpl new file mode 100644 index 00000000..110a3a7d --- /dev/null +++ b/securemail/templates/settings.tpl @@ -0,0 +1,2 @@ +{{include file="field_checkbox.tpl" field=$enabled}} +{{include file="field_textarea.tpl" field=$publickey}} diff --git a/showmore/showmore.php b/showmore/showmore.php index 574be70f..945277ae 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -7,7 +7,10 @@ * based upon NSFW from Mike Macgirvin * */ + +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Util\Strings; @@ -18,7 +21,7 @@ function showmore_install() 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()) { return; @@ -26,31 +29,20 @@ function showmore_addon_settings(&$a, &$s) DI::page()->registerStylesheet(__DIR__ . '/showmore.css', 'all'); - $enable_checked = (intval(DI::pConfig()->get(local_user(), 'showmore', 'disable')) ? '' : ' checked="checked"'); - $chars = DI::pConfig()->get(local_user(), 'showmore', 'chars', 1100); + $enabled = !DI::pConfig()->get(local_user(), 'showmore', 'disable'); + $chars = DI::pConfig()->get(local_user(), 'showmore', 'chars', 1100); - $s .= ''; - $s .= '

' . DI::l10n()->t('"Show more" Settings').'

'; - $s .= '
'; - $s .= ''; - - return; + $data = [ + 'addon' => 'showmore', + 'title' => DI::l10n()->t('"Show more" Settings'), + 'html' => $html, + ]; } function showmore_addon_settings_post(&$a, &$b) @@ -101,7 +93,7 @@ function get_body_length($body) 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 if (!empty($hook_data['filter_reasons'])) { diff --git a/showmore/templates/settings.tpl b/showmore/templates/settings.tpl new file mode 100644 index 00000000..b1887d62 --- /dev/null +++ b/showmore/templates/settings.tpl @@ -0,0 +1,3 @@ +

{{$info}}

+{{include file="field_checkbox.tpl" field=$enabled}} +{{include file="field_input.tpl" field=$chars}} diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index bf8f5608..39dfa489 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -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()) { return; @@ -55,12 +55,15 @@ function showmore_dyn_settings(App &$a, &$o) DI::pConfig()->set(local_user(), 'showmore_dyn', 'limitHeight', $limitHeight); $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore_dyn/'); - $o .= Renderer::replaceMacros($t, [ - '$submit' => DI::l10n()->t('Save Settings'), - '$header' => DI::l10n()->t('Show More Dynamic'), + $html = Renderer::replaceMacros($t, [ '$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() diff --git a/showmore_dyn/templates/settings.tpl b/showmore_dyn/templates/settings.tpl index ac37e937..a6a283ad 100644 --- a/showmore_dyn/templates/settings.tpl +++ b/showmore_dyn/templates/settings.tpl @@ -1,13 +1 @@ - -

{{$header}}

-
- +{{include file="field_input.tpl" field=$limitHeight}} diff --git a/startpage/startpage.css b/startpage/startpage.css deleted file mode 100644 index e78be7ec..00000000 --- a/startpage/startpage.css +++ /dev/null @@ -1,16 +0,0 @@ - - - -#startpage-page-label { - float: left; - width: 200px; - margin-bottom: 25px; -} - -#startpage-page { - float: left; -} - -#startpage-desc { - margin-bottom: 10px; -} diff --git a/startpage/startpage.php b/startpage/startpage.php index 8cdf444f..d72effde 100644 --- a/startpage/startpage.php +++ b/startpage/startpage.php @@ -6,7 +6,10 @@ * Author: Mike Macgirvin * */ + +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\Renderer; use Friendica\DI; function startpage_install() { @@ -54,36 +57,22 @@ function startpage_settings_post($a, $post) * Add our own settings info to the page. * */ -function startpage_settings(&$a, &$s) +function startpage_settings(App &$a, array &$data) { if (!local_user()) { 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'] .= '' . "\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 */ - - $page = DI::pConfig()->get(local_user(), 'startpage', 'startpage'); - - /* Add some HTML to the existing form */ - - $s .= ''; - $s .= '

' . DI::l10n()->t('Startpage') . '

'; - $s .= '
'; - $s .= ''; + $data = [ + 'addon' => 'startpage', + 'title' => DI::l10n()->t('Startpage'), + 'html' => $html, + ]; } diff --git a/startpage/templates/settings.tpl b/startpage/templates/settings.tpl new file mode 100644 index 00000000..7078a83a --- /dev/null +++ b/startpage/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_input.tpl" field=$startpage}} diff --git a/superblock/superblock.css b/superblock/superblock.css deleted file mode 100644 index 368355bd..00000000 --- a/superblock/superblock.css +++ /dev/null @@ -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; -} - diff --git a/superblock/superblock.php b/superblock/superblock.php index d3186087..5c5cfcc3 100644 --- a/superblock/superblock.php +++ b/superblock/superblock.php @@ -6,7 +6,10 @@ * Author: Mike Macgirvin * */ + +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Util\Strings; @@ -19,35 +22,24 @@ function superblock_install() 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()) { 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'); - if (!$words) { - $words = ''; - } - - $s .= ''; - $s .= '

' . DI::l10n()->t('Superblock') . '

'; - $s .= '
'; - $s .= ''; - - return; + $data = [ + 'addon' => 'superblock', + 'title' => DI::l10n()->t('Superblock'), + 'html' => $html, + ]; } function superblock_addon_settings_post(&$a, &$b) diff --git a/superblock/templates/settings.tpl b/superblock/templates/settings.tpl new file mode 100644 index 00000000..113588e3 --- /dev/null +++ b/superblock/templates/settings.tpl @@ -0,0 +1 @@ +{{include file="field_textarea.tpl" field=$urls}} diff --git a/windowsphonepush/templates/settings.tpl b/windowsphonepush/templates/settings.tpl new file mode 100644 index 00000000..9198225c --- /dev/null +++ b/windowsphonepush/templates/settings.tpl @@ -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}} diff --git a/windowsphonepush/windowsphonepush.css b/windowsphonepush/windowsphonepush.css deleted file mode 100644 index 95ba6d2c..00000000 --- a/windowsphonepush/windowsphonepush.css +++ /dev/null @@ -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; -} diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index d2529eea..8f289d12 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -31,6 +31,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Hook; use Friendica\Core\Logger; +use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; @@ -86,48 +87,28 @@ function windowsphonepush_settings_post($a, $post) /* Called from the Addon Setting form. * Add our own settings info to the page. */ -function windowsphonepush_settings(&$a, &$s) +function windowsphonepush_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'] .= '' . "\r\n"; - - /* Get the current state of our config variables */ $enabled = DI::pConfig()->get(local_user(), 'windowsphonepush', 'enable'); - $checked_enabled = (($enabled) ? ' checked="checked" ' : ''); - $senditemtext = DI::pConfig()->get(local_user(), 'windowsphonepush', 'senditemtext'); - $checked_senditemtext = (($senditemtext) ? ' checked="checked" ' : ''); - $device_url = DI::pConfig()->get(local_user(), 'windowsphonepush', 'device_url'); - /* Add some HTML to the existing form */ - $s .= '
'; - $s .= '

' . DI::l10n()->t('WindowsPhonePush Settings') . '

'; + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/windowsphonepush/'); + $html = Renderer::replaceMacros($t, [ + '$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 .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - /* provide a submit button - enable und senditemtext can be changed by the user */ - $s .= '
'; - - /* provide further read-only information concerning the addon (useful for */ - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - - return; + $data = [ + 'addon' => 'windowsphonepush', + 'title' => DI::l10n()->t('WindowsPhonePush Settings'), + 'html' => $html, + ]; } /* Cron function used to regularly check all users on the server with active windowsphonepushaddon and send