[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
This commit is contained in:
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

@ -7,7 +7,10 @@
* based upon NSFW from Mike Macgirvin <http://macgirvin.com/profile/mike>
*
*/
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 .= '<span id="settings_showmore_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_showmore_expanded\'); openClose(\'settings_showmore_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('"Show more" Settings').'</h3>';
$s .= '</span>';
$s .= '<div id="settings_showmore_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_showmore_expanded\'); openClose(\'settings_showmore_inflated\');">';
$s .= '<h3>' . DI::l10n()->t('"Show more" Settings').'</h3>';
$s .= '</span>';
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/showmore/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['showmore-enable', DI::l10n()->t('Enable Show More'), $enabled],
'$chars' => ['showmore-chars', DI::l10n()->t('Cutting posts after how many characters'), $chars],
]);
$s .= '<div id="showmore-wrapper">';
$s .= '<label id="showmore-enable-label" for="showmore-enable">'.DI::l10n()->t('Enable Show More').'</label>';
$s .= '<input id="showmore-enable" type="checkbox" name="showmore-enable" value="1"'.$enable_checked.' />';
$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;
$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'])) {

View file

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