[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

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

View file

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

View file

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