[various] Convert connector_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:
parent
779b38ec09
commit
9acfdb4090
36 changed files with 612 additions and 1012 deletions
|
@ -1,16 +0,0 @@
|
|||
|
||||
#diaspora-enable-label, #diaspora-username-label, #diaspora-password-label, #diaspora-bydefault-label, #diaspora-aspect-label {
|
||||
float: left;
|
||||
width: 200px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#diaspora-checkbox, #diaspora-username, #diaspora-password, #diaspora-bydefault, #diaspora-aspect {
|
||||
float: left;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#diaspora-submit {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
|
@ -48,22 +48,20 @@ function diaspora_jot_nets(App $a, array &$jotnets_fields)
|
|||
}
|
||||
}
|
||||
|
||||
function diaspora_settings(App $a, &$s)
|
||||
function diaspora_settings(App $a, array &$data)
|
||||
{
|
||||
if (! local_user()) {
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the current state of our config variables */
|
||||
$enabled = DI::pConfig()->get(local_user(), 'diaspora', 'post', false);
|
||||
$def_enabled = DI::pConfig()->get(local_user(), 'diaspora', 'post_by_default');
|
||||
|
||||
$enabled = DI::pConfig()->get(local_user(),'diaspora','post');
|
||||
$def_enabled = DI::pConfig()->get(local_user(),'diaspora','post_by_default');
|
||||
|
||||
$handle = DI::pConfig()->get(local_user(), 'diaspora', 'handle');
|
||||
$handle = DI::pConfig()->get(local_user(), 'diaspora', 'handle');
|
||||
$password = DI::pConfig()->get(local_user(), 'diaspora', 'password');
|
||||
$aspect = DI::pConfig()->get(local_user(),'diaspora','aspect');
|
||||
$aspect = DI::pConfig()->get(local_user(), 'diaspora', 'aspect');
|
||||
|
||||
$info = '';
|
||||
$info = '';
|
||||
$error = '';
|
||||
if (Session::get('my_address')) {
|
||||
$info = DI::l10n()->t('Please remember: You can always be reached from Diaspora with your Friendica handle <strong>%s</strong>. ', Session::get('my_address'));
|
||||
|
@ -79,37 +77,44 @@ function diaspora_settings(App $a, &$s)
|
|||
if ($rawAspects) {
|
||||
$availableAspects = [
|
||||
'all_aspects' => DI::l10n()->t('All aspects'),
|
||||
'public' => DI::l10n()->t('Public'),
|
||||
'public' => DI::l10n()->t('Public'),
|
||||
];
|
||||
foreach ($rawAspects as $rawAspect) {
|
||||
$availableAspects[$rawAspect->id] = $rawAspect->name;
|
||||
}
|
||||
|
||||
$aspect_select = ['aspect', DI::l10n()->t('Post to aspect:'), $aspect, '', $availableAspects];
|
||||
$info = DI::l10n()->t('Connected with your Diaspora account <strong>%s</strong>', $handle);
|
||||
$info = DI::l10n()->t('Connected with your Diaspora account <strong>%s</strong>', $handle);
|
||||
} else {
|
||||
$info = '';
|
||||
$info = '';
|
||||
$error = DI::l10n()->t("Can't login to your Diaspora account. Please check handle (in the format user@domain.tld) and password.");
|
||||
}
|
||||
}
|
||||
|
||||
DI::page()->registerStylesheet(__DIR__ . '/diaspora.css');
|
||||
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/diaspora/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
'$l10n' => [
|
||||
'info_header' => DI::l10n()->t('Information'),
|
||||
'error_header' => DI::l10n()->t('Error'),
|
||||
],
|
||||
|
||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/diaspora/');
|
||||
$s .= Renderer::replaceMacros($t, [
|
||||
'$header' => DI::l10n()->t('Diaspora Export'),
|
||||
'$info_header' => DI::l10n()->t('Information'),
|
||||
'$error_header' => DI::l10n()->t('Error'),
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$info' => $info,
|
||||
'$error' => $error,
|
||||
'$enabled' => $enabled,
|
||||
'$enabled_checkbox' => ['enabled', DI::l10n()->t('Enable Diaspora Post Addon'), $enabled],
|
||||
'$handle' => ['handle', DI::l10n()->t('Diaspora handle'), $handle, null, null, 'placeholder="user@domain.tld"'],
|
||||
'$password' => ['password', DI::l10n()->t('Diaspora password'), '', DI::l10n()->t('Privacy notice: Your Diaspora password will be stored unencrypted to authenticate you with your Diaspora pod. This means your Friendica node administrator can have access to it.')],
|
||||
'$aspect_select' => $aspect_select,
|
||||
'$post_by_default' => ['post_by_default', DI::l10n()->t('Post to Diaspora by default'), $def_enabled],
|
||||
'$info' => $info,
|
||||
'$error' => $error,
|
||||
|
||||
'$enabled' => ['enabled', DI::l10n()->t('Enable Diaspora Post Addon'), $enabled],
|
||||
'$handle' => ['handle', DI::l10n()->t('Diaspora handle'), $handle, null, null, 'placeholder="user@domain.tld"'],
|
||||
'$password' => ['password', DI::l10n()->t('Diaspora password'), '', DI::l10n()->t('Privacy notice: Your Diaspora password will be stored unencrypted to authenticate you with your Diaspora pod. This means your Friendica node administrator can have access to it.')],
|
||||
'$aspect_select' => $aspect_select,
|
||||
'$post_by_default' => ['post_by_default', DI::l10n()->t('Post to Diaspora by default'), $def_enabled],
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'connector' => 'diaspora',
|
||||
'title' => DI::l10n()->t('Diaspora Export'),
|
||||
'image' => 'images/diaspora-logo.png',
|
||||
'enabled' => $enabled,
|
||||
'html' => $html,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
|
32
diaspora/templates/connector_settings.tpl
Normal file
32
diaspora/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,32 @@
|
|||
{{if $info}}
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">{{$l10n.info_header}}</h4>
|
||||
</div>
|
||||
<p class="panel-body">
|
||||
{{$info nofilter}}
|
||||
</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if $error}}
|
||||
<div class="panel panel-danger">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">{{$l10n.error_header}}</h4>
|
||||
</div>
|
||||
<p class="panel-body">
|
||||
{{$error nofilter}}
|
||||
</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||
|
||||
{{if $aspect_select}}
|
||||
{{include file="field_select.tpl" field=$aspect_select}}
|
||||
|
||||
{{include file="field_checkbox.tpl" field=$post_by_default}}
|
||||
{{else}}
|
||||
{{include file="field_input.tpl" field=$handle}}
|
||||
|
||||
{{include file="field_password.tpl" field=$password}}
|
||||
{{/if}}
|
|
@ -1,47 +0,0 @@
|
|||
<span id="settings_diaspora_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_diaspora_expanded'); openClose('settings_diaspora_inflated');">
|
||||
<img class="connector{{if !$enabled}}-disabled{{/if}}" src="images/diaspora-logo.png">
|
||||
<h3 class="connector">{{$header}}</h3>
|
||||
</span>
|
||||
<div id="settings_diaspora_expanded" class="settings-block" style="display: none;">
|
||||
<span class="fakelink" onclick="openClose('settings_diaspora_expanded'); openClose('settings_diaspora_inflated');">
|
||||
<img class="connector{{if !$enabled}}-disabled{{/if}}" src="images/diaspora-logo.png">
|
||||
<h3 class="connector">{{$header}}</h3>
|
||||
</span>
|
||||
|
||||
{{if $info}}
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">{{$info_header}}</h4>
|
||||
</div>
|
||||
<p class="panel-body">
|
||||
{{$info nofilter}}
|
||||
</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{if $error}}
|
||||
<div class="panel panel-danger">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">{{$error_header}}</h4>
|
||||
</div>
|
||||
<p class="panel-body">
|
||||
{{$error nofilter}}
|
||||
</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{include file="field_checkbox.tpl" field=$enabled_checkbox}}
|
||||
|
||||
{{if $aspect_select}}
|
||||
{{include file="field_select.tpl" field=$aspect_select}}
|
||||
|
||||
{{include file="field_checkbox.tpl" field=$post_by_default}}
|
||||
{{else}}
|
||||
{{include file="field_input.tpl" field=$handle}}
|
||||
|
||||
{{include file="field_password.tpl" field=$password}}
|
||||
{{/if}}
|
||||
|
||||
<div class="settings-submit-wrapper">
|
||||
<button type="submit" class="btn btn-primary settings-submit" id="diaspora-submit" name="diaspora-submit" value="diaspora-submit">{{$submit}}</button>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue