[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
|
@ -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,15 +48,13 @@ 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
$enabled = DI::pConfig()->get(local_user(), 'diaspora', 'post', false);
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(local_user(),'diaspora','post');
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(), 'diaspora', 'post_by_default');
|
$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');
|
||||||
|
@ -93,23 +91,30 @@ function diaspora_settings(App $a, &$s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
'$info' => $info,
|
||||||
'$error' => $error,
|
'$error' => $error,
|
||||||
'$enabled' => $enabled,
|
|
||||||
'$enabled_checkbox' => ['enabled', DI::l10n()->t('Enable Diaspora Post Addon'), $enabled],
|
'$enabled' => ['enabled', DI::l10n()->t('Enable Diaspora Post Addon'), $enabled],
|
||||||
'$handle' => ['handle', DI::l10n()->t('Diaspora handle'), $handle, null, null, 'placeholder="user@domain.tld"'],
|
'$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.')],
|
'$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,
|
'$aspect_select' => $aspect_select,
|
||||||
'$post_by_default' => ['post_by_default', DI::l10n()->t('Post to Diaspora by default'), $def_enabled],
|
'$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>
|
|
|
@ -36,7 +36,7 @@ function discourse_install()
|
||||||
Hook::register('connector_settings_post', __FILE__, 'discourse_settings_post');
|
Hook::register('connector_settings_post', __FILE__, 'discourse_settings_post');
|
||||||
}
|
}
|
||||||
|
|
||||||
function discourse_settings(App $a, &$s)
|
function discourse_settings(App $a, array &$data)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
|
@ -44,12 +44,18 @@ function discourse_settings(App $a, &$s)
|
||||||
|
|
||||||
$enabled = intval(DI::pConfig()->get(local_user(), 'discourse', 'enabled'));
|
$enabled = intval(DI::pConfig()->get(local_user(), 'discourse', 'enabled'));
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/discourse/');
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/discourse/');
|
||||||
$s .= Renderer::replaceMacros($t, [
|
$html = Renderer::replaceMacros($t, [
|
||||||
'$title' => DI::l10n()->t('Discourse'),
|
|
||||||
'$enabled' => ['enabled', DI::l10n()->t('Enable processing of Discourse mailing list mails'), $enabled, DI::l10n()->t('If enabled, incoming mails from Discourse will be improved so they look much better. To make it work, you have to configure the e-mail settings in Friendica. You also have to enable the mailing list mode in Discourse. Then you have to add the Discourse mail account as contact.')],
|
'$enabled' => ['enabled', DI::l10n()->t('Enable processing of Discourse mailing list mails'), $enabled, DI::l10n()->t('If enabled, incoming mails from Discourse will be improved so they look much better. To make it work, you have to configure the e-mail settings in Friendica. You also have to enable the mailing list mode in Discourse. Then you have to add the Discourse mail account as contact.')],
|
||||||
'$submit' => DI::l10n()->t('Save Settings'),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'connector' => 'discourse',
|
||||||
|
'title' => DI::l10n()->t('Discourse'),
|
||||||
|
'image' => 'images/discourse.png',
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'html' => $html,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function discourse_settings_post(App $a)
|
function discourse_settings_post(App $a)
|
||||||
|
|
1
discourse/templates/connector_settings.tpl
Normal file
1
discourse/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
|
@ -1,15 +0,0 @@
|
||||||
<span id="settings_discourse_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_discourse_expanded'); openClose('settings_discourse_inflated');">
|
|
||||||
<img class="connector{{if ! $enabled.2}}-disabled{{/if}}" src="images/discourse.png" /><h3 class="connector">{{$title}}</h3>
|
|
||||||
</span>
|
|
||||||
<div id="settings_discourse_expanded" class="settings-block" style="display: none;">
|
|
||||||
<span class="fakelink" onclick="openClose('settings_discourse_expanded'); openClose('settings_discourse_inflated');">
|
|
||||||
<img class="connector{{if ! $enabled.2}}-disabled{{/if}}" src="images/discourse.png" /><h3 class="connector">{{$title}}</h3>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div id="discourse-wrapper">
|
|
||||||
{{include file="field_checkbox.tpl" field=$enabled}}
|
|
||||||
</div>
|
|
||||||
<div class="settings-submit-wrapper" >
|
|
||||||
<input type="submit" id="discourse-submit" name="discourse-submit" class="settings-submit" value="{{$submit}}" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
#dwpost-enable-label, #dwpost-username-label, #dwpost-password-label, #dwpost-bydefault-label {
|
|
||||||
float: left;
|
|
||||||
width: 200px;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#dwpost-checkbox, #dwpost-username, #dwpost-password, #dwpost-bydefault {
|
|
||||||
float: left;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#dwpost-submit {
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
|
@ -12,7 +12,7 @@ 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;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
|
@ -48,58 +48,31 @@ function dwpost_jot_nets(App $a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function dwpost_settings(App $a, &$s)
|
function dwpost_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 */
|
$enabled = DI::pConfig()->get(local_user(), 'dwpost', 'post', false);
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/dwpost/dwpost.css' . '" media="all" />' . "\r\n";
|
$dw_username = DI::pConfig()->get(local_user(), 'dwpost', 'dw_username');
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
|
||||||
$enabled = DI::pConfig()->get(local_user(), 'dwpost', 'post');
|
|
||||||
|
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(), 'dwpost', 'post_by_default');
|
$def_enabled = DI::pConfig()->get(local_user(), 'dwpost', 'post_by_default');
|
||||||
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/dwpost/');
|
||||||
|
$html = Renderer::replaceMacros($t, [
|
||||||
|
'$enabled' => ['dwpost', DI::l10n()->t('Enable Dreamwidth Post Addon'), $enabled],
|
||||||
|
'$username' => ['dw_username', DI::l10n()->t('Dreamwidth username'), $dw_username],
|
||||||
|
'$password' => ['dw_password', DI::l10n()->t('Dreamwidth password')],
|
||||||
|
'$bydefault' => ['dw_bydefault', DI::l10n()->t('Post to Dreamwidth by default'), $def_enabled],
|
||||||
|
]);
|
||||||
|
|
||||||
$dw_username = DI::pConfig()->get(local_user(), 'dwpost', 'dw_username');
|
$data = [
|
||||||
$dw_password = DI::pConfig()->get(local_user(), 'dwpost', 'dw_password');
|
'connector' => 'dwpost',
|
||||||
|
'title' => DI::l10n()->t('Dreamwidth Export'),
|
||||||
/* Add some HTML to the existing form */
|
'image' => 'images/dreamwidth.png',
|
||||||
$s .= '<span id="settings_dwpost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_dwpost_expanded\'); openClose(\'settings_dwpost_inflated\');">';
|
'enabled' => $enabled,
|
||||||
$s .= '<img class="connector" src="images/dreamwidth.png" /><h3 class="connector">'. DI::l10n()->t("Dreamwidth Export").'</h3>';
|
'html' => $html,
|
||||||
$s .= '</span>';
|
];
|
||||||
$s .= '<div id="settings_dwpost_expanded" class="settings-block" style="display: none;">';
|
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_dwpost_expanded\'); openClose(\'settings_dwpost_inflated\');">';
|
|
||||||
$s .= '<img class="connector" src="images/dreamwidth.png" /><h3 class="connector">'. DI::l10n()->t("Dreamwidth Export").'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
|
|
||||||
$s .= '<div id="dwpost-enable-wrapper">';
|
|
||||||
$s .= '<label id="dwpost-enable-label" for="dwpost-checkbox">' . DI::l10n()->t('Enable dreamwidth Post Addon') . '</label>';
|
|
||||||
$s .= '<input id="dwpost-checkbox" type="checkbox" name="dwpost" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="dwpost-username-wrapper">';
|
|
||||||
$s .= '<label id="dwpost-username-label" for="dwpost-username">' . DI::l10n()->t('dreamwidth username') . '</label>';
|
|
||||||
$s .= '<input id="dwpost-username" type="text" name="dw_username" value="' . $dw_username . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="dwpost-password-wrapper">';
|
|
||||||
$s .= '<label id="dwpost-password-label" for="dwpost-password">' . DI::l10n()->t('dreamwidth password') . '</label>';
|
|
||||||
$s .= '<input id="dwpost-password" type="password" name="dw_password" value="' . $dw_password . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="dwpost-bydefault-wrapper">';
|
|
||||||
$s .= '<label id="dwpost-bydefault-label" for="dwpost-bydefault">' . DI::l10n()->t('Post to dreamwidth by default') . '</label>';
|
|
||||||
$s .= '<input id="dwpost-bydefault" type="checkbox" name="dw_bydefault" value="1" ' . $def_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
/* provide a submit button */
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="dwpost-submit" name="dwpost-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
4
dwpost/templates/connector_settings.tpl
Normal file
4
dwpost/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||||
|
{{include file="field_input.tpl" field=$username}}
|
||||||
|
{{include file="field_password.tpl" field=$password}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$bydefault}}
|
|
@ -11,6 +11,7 @@ use Friendica\Content\PageInfo;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
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;
|
||||||
|
@ -33,55 +34,47 @@ function ifttt_content()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ifttt_settings(App $a, &$s)
|
function ifttt_settings(App $a, array &$data)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = DI::pConfig()->get(local_user(), 'ifttt', 'key');
|
$key = DI::pConfig()->get(local_user(), 'ifttt', 'key');
|
||||||
|
|
||||||
if (!$key) {
|
if (!$key) {
|
||||||
$key = Strings::getRandomHex(20);
|
$key = Strings::getRandomHex(20);
|
||||||
DI::pConfig()->set(local_user(), 'ifttt', 'key', $key);
|
DI::pConfig()->set(local_user(), 'ifttt', 'key', $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= '<span id="settings_ifttt_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_ifttt_expanded\'); openClose(\'settings_ifttt_inflated\');">';
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ifttt/');
|
||||||
$s .= '<img class="connector" src="addon/ifttt/ifttt.png" /><h3 class="connector">' . DI::l10n()->t('IFTTT Mirror') . '</h3>';
|
$html = Renderer::replaceMacros($t, [
|
||||||
$s .= '</span>';
|
'$l10n' => [
|
||||||
$s .= '<div id="settings_ifttt_expanded" class="settings-block" style="display: none;">';
|
'intro' => DI::l10n()->t('Create an account at <a href="http://www.ifttt.com">IFTTT</a>. Create three Facebook recipes that are connected with <a href="https://ifttt.com/maker">Maker</a> (In the form "if Facebook then Maker") with the following parameters:'),
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_ifttt_expanded\'); openClose(\'settings_ifttt_inflated\');">';
|
'url' => DI::l10n()->t('URL'),
|
||||||
$s .= '<img class="connector" src="addon/ifttt/ifttt.png" /><h3 class="connector">' . DI::l10n()->t('IFTTT Mirror') . '</h3>';
|
'method' => DI::l10n()->t('Method'),
|
||||||
$s .= '</span>';
|
'content_type' => DI::l10n()->t('Content Type'),
|
||||||
|
'new_status_message_body' => DI::l10n()->t('Body for "new status message"'),
|
||||||
|
'new_photo_upload_body' => DI::l10n()->t('Body for "new photo upload"'),
|
||||||
|
'new_link_post_body' => DI::l10n()->t('Body for "new link post"'),
|
||||||
|
],
|
||||||
|
'$url' => DI::baseUrl()->get() . '/ifttt/' . $a->getLoggedInUserNickname(),
|
||||||
|
'$new_status_message_body' => 'key=' . $key . '&type=status&msg=<<<{{Message}}>>>&date=<<<{{UpdatedAt}}>>>&url=<<<{{PageUrl}}>>>',
|
||||||
|
'$new_photo_upload_body' => 'key=' . $key . '&type=photo&link=<<<{{Link}}>>>&image=<<<{{ImageSource}}>>>&msg=<<<{{Caption}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>',
|
||||||
|
'$new_link_post_body' => 'key=' . $key . '&type=link&link=<<<{{Link}}>>>&title=<<<{{Title}}>>>&msg=<<<{{Message}}>>>&description=<<<{{Description}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>',
|
||||||
|
]);
|
||||||
|
|
||||||
$s .= '<div id="ifttt-configuration-wrapper">';
|
$data = [
|
||||||
$s .= '<p>' . DI::l10n()->t('Create an account at <a href="http://www.ifttt.com">IFTTT</a>. Create three Facebook recipes that are connected with <a href="https://ifttt.com/maker">Maker</a> (In the form "if Facebook then Maker") with the following parameters:') . '</p>';
|
'connector' => 'ifttt',
|
||||||
$s .= '<h4>URL</h4>';
|
'title' => DI::l10n()->t('IFTTT Mirror'),
|
||||||
$s .= '<p>' . DI::baseUrl()->get() . '/ifttt/' . $a->getLoggedInUserNickname() . '</p>';
|
'image' => 'addon/ifttt/ifttt.png',
|
||||||
$s .= '<h4>Method</h4>';
|
'html' => $html,
|
||||||
$s .= '<p>POST</p>';
|
'submit' => DI::l10n()->t('Generate new key'),
|
||||||
$s .= '<h4>Content Type</h4>';
|
];
|
||||||
$s .= '<p>application/x-www-form-urlencoded</p>';
|
|
||||||
$s .= '<h4>' . DI::l10n()->t('Body for "new status message"') . '</h4>';
|
|
||||||
$s .= '<p><code>' . htmlentities('key=' . $key . '&type=status&msg=<<<{{Message}}>>>&date=<<<{{UpdatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '</code></p>';
|
|
||||||
$s .= '<h4>' . DI::l10n()->t('Body for "new photo upload"') . '</h4>';
|
|
||||||
$s .= '<p><code>' . htmlentities('key=' . $key . '&type=photo&link=<<<{{Link}}>>>&image=<<<{{ImageSource}}>>>&msg=<<<{{Caption}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '</code></p>';
|
|
||||||
$s .= '<h4>' . DI::l10n()->t('Body for "new link post"') . '</h4>';
|
|
||||||
$s .= '<p><code>' . htmlentities('key=' . $key . '&type=link&link=<<<{{Link}}>>>&title=<<<{{Title}}>>>&msg=<<<{{Message}}>>>&description=<<<{{Description}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>') . '</code></p>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="ifttt-rekey-wrapper">';
|
|
||||||
$s .= '<label id="ifttt-rekey-label" for="ifttt-checkbox">' . DI::l10n()->t('Generate new key') . '</label>';
|
|
||||||
$s .= '<input id="ifttt-checkbox" type="checkbox" name="ifttt-rekey" value="1" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="ifttt-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
|
||||||
$s .= '</div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ifttt_settings_post()
|
function ifttt_settings_post()
|
||||||
{
|
{
|
||||||
if (!empty($_POST['ifttt-submit']) && isset($_POST['ifttt-rekey'])) {
|
if (!empty($_POST['ifttt-submit'])) {
|
||||||
DI::pConfig()->delete(local_user(), 'ifttt', 'key');
|
DI::pConfig()->delete(local_user(), 'ifttt', 'key');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
ifttt/templates/connector_settings.tpl
Normal file
15
ifttt/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<p>{{$l10n.intro nofilter}}</p>
|
||||||
|
<dl>
|
||||||
|
<dt>{{$l10n.url}}</dt>
|
||||||
|
<dd>{{$url}}</dd>
|
||||||
|
<dt>{{$l10n.method}}</dt>
|
||||||
|
<dd>POST</dd>
|
||||||
|
<dt>{{$l10n.content_type}}</dt>
|
||||||
|
<dd>application/x-www-form-urlencoded</dd>
|
||||||
|
<dt>{{$l10n.new_status_message_body}}</dt>
|
||||||
|
<dd><code>{{$new_status_message_body}}</code></dd>
|
||||||
|
<dt>{{$l10n.new_photo_upload_body}}</dt>
|
||||||
|
<dd><code>{{$new_photo_upload_body}}</code></dd>
|
||||||
|
<dt>{{$l10n.new_link_post_body}}</dt>
|
||||||
|
<dd><code>{{$new_link_post_body}}</code></dd>
|
||||||
|
</dl>
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
#ijpost-enable-label, #ijpost-username-label, #ijpost-password-label, #ijpost-bydefault-label {
|
|
||||||
float: left;
|
|
||||||
width: 200px;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ijpost-checkbox, #ijpost-username, #ijpost-password, #ijpost-bydefault {
|
|
||||||
float: left;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ijpost-submit {
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
|
@ -8,9 +8,11 @@
|
||||||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -26,7 +28,7 @@ function ijpost_install()
|
||||||
Hook::register('connector_settings_post', 'addon/ijpost/ijpost.php', 'ijpost_settings_post');
|
Hook::register('connector_settings_post', 'addon/ijpost/ijpost.php', 'ijpost_settings_post');
|
||||||
}
|
}
|
||||||
|
|
||||||
function ijpost_jot_nets(\Friendica\App &$a, array &$jotnets_fields)
|
function ijpost_jot_nets(App &$a, array &$jotnets_fields)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
|
@ -44,60 +46,31 @@ function ijpost_jot_nets(\Friendica\App &$a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ijpost_settings(&$a, &$s)
|
function ijpost_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 */
|
$enabled = DI::pConfig()->get(local_user(), 'ijpost', 'post', false);
|
||||||
|
$ij_username = DI::pConfig()->get(local_user(), 'ijpost', 'ij_username');
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/ijpost/ijpost.css' . '" media="all" />' . "\r\n";
|
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(local_user(), 'ijpost', 'post');
|
|
||||||
|
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(), 'ijpost', 'post_by_default');
|
$def_enabled = DI::pConfig()->get(local_user(), 'ijpost', 'post_by_default');
|
||||||
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ijpost/');
|
||||||
|
$html = Renderer::replaceMacros($t, [
|
||||||
|
'$enabled' => ['ijpost', DI::l10n()->t('Enable InsaneJournal Post Addon'), $enabled],
|
||||||
|
'$username' => ['ij_username', DI::l10n()->t('InsaneJournal username'), $ij_username],
|
||||||
|
'$password' => ['ij_password', DI::l10n()->t('InsaneJournal password')],
|
||||||
|
'$bydefault' => ['ij_bydefault', DI::l10n()->t('Post to InsaneJournal by default'), $def_enabled],
|
||||||
|
]);
|
||||||
|
|
||||||
$ij_username = DI::pConfig()->get(local_user(), 'ijpost', 'ij_username');
|
$data = [
|
||||||
$ij_password = DI::pConfig()->get(local_user(), 'ijpost', 'ij_password');
|
'connector' => 'ijpost',
|
||||||
|
'title' => DI::l10n()->t('InsaneJournal Export'),
|
||||||
/* Add some HTML to the existing form */
|
'image' => 'images/insanejournal.gif',
|
||||||
$s .= '<span id="settings_ijpost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_ijpost_expanded\'); openClose(\'settings_ijpost_inflated\');">';
|
'enabled' => $enabled,
|
||||||
$s .= '<img class="connector" src="images/insanejournal.gif" /><h3 class="connector">'. DI::l10n()->t("InsaneJournal Export").'</h3>';
|
'html' => $html,
|
||||||
$s .= '</span>';
|
];
|
||||||
$s .= '<div id="settings_ijpost_expanded" class="settings-block" style="display: none;">';
|
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_ijpost_expanded\'); openClose(\'settings_ijpost_inflated\');">';
|
|
||||||
$s .= '<img class="connector" src="images/insanejournal.gif" /><h3 class="connector">'. DI::l10n()->t("InsaneJournal Export").'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
|
|
||||||
$s .= '<div id="ijpost-enable-wrapper">';
|
|
||||||
$s .= '<label id="ijpost-enable-label" for="ijpost-checkbox">' . DI::l10n()->t('Enable InsaneJournal Post Addon') . '</label>';
|
|
||||||
$s .= '<input id="ijpost-checkbox" type="checkbox" name="ijpost" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="ijpost-username-wrapper">';
|
|
||||||
$s .= '<label id="ijpost-username-label" for="ijpost-username">' . DI::l10n()->t('InsaneJournal username') . '</label>';
|
|
||||||
$s .= '<input id="ijpost-username" type="text" name="ij_username" value="' . $ij_username . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="ijpost-password-wrapper">';
|
|
||||||
$s .= '<label id="ijpost-password-label" for="ijpost-password">' . DI::l10n()->t('InsaneJournal password') . '</label>';
|
|
||||||
$s .= '<input id="ijpost-password" type="password" name="ij_password" value="' . $ij_password . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="ijpost-bydefault-wrapper">';
|
|
||||||
$s .= '<label id="ijpost-bydefault-label" for="ijpost-bydefault">' . DI::l10n()->t('Post to InsaneJournal by default') . '</label>';
|
|
||||||
$s .= '<input id="ijpost-bydefault" type="checkbox" name="ij_bydefault" value="1" ' . $def_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
/* provide a submit button */
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="ijpost-submit" name="ijpost-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ijpost_settings_post(&$a, &$b)
|
function ijpost_settings_post(&$a, &$b)
|
||||||
|
|
4
ijpost/templates/connector_settings.tpl
Normal file
4
ijpost/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||||
|
{{include file="field_input.tpl" field=$username}}
|
||||||
|
{{include file="field_password.tpl" field=$password}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$bydefault}}
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
#libertree-enable-label, #libertree-api_token-label, #libertree-url-label, #libertree-bydefault-label {
|
|
||||||
float: left;
|
|
||||||
width: 200px;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#libertree-checkbox, #libertree-api_token, #libertree-url, #libertree-bydefault {
|
|
||||||
float: left;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#libertree-submit {
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ 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;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
@ -43,63 +44,32 @@ function libertree_jot_nets(App &$a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function libertree_settings(&$a,&$s) {
|
function libertree_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 */
|
$enabled = DI::pConfig()->get(local_user(), 'libertree', 'post', false);
|
||||||
|
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/libertree/libertree.css' . '" media="all" />' . "\r\n";
|
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(local_user(),'libertree','post');
|
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
|
||||||
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(),'libertree','post_by_default');
|
|
||||||
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$ltree_api_token = DI::pConfig()->get(local_user(), 'libertree', 'libertree_api_token');
|
$ltree_api_token = DI::pConfig()->get(local_user(), 'libertree', 'libertree_api_token');
|
||||||
$ltree_url = DI::pConfig()->get(local_user(), 'libertree', 'libertree_url');
|
$ltree_url = DI::pConfig()->get(local_user(), 'libertree', 'libertree_url');
|
||||||
|
$def_enabled = DI::pConfig()->get(local_user(), 'libertree', 'post_by_default');
|
||||||
|
|
||||||
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/libertree/');
|
||||||
|
$html = Renderer::replaceMacros($t, [
|
||||||
|
'$enabled' => ['libertree', DI::l10n()->t('Enable Libertree Post Addon'), $enabled],
|
||||||
|
'$ltree_url' => ['libertree_url', DI::l10n()->t('Libertree site URL'), $ltree_url],
|
||||||
|
'$ltree_api_token' => ['libertree_api_token', DI::l10n()->t('Libertree API token'), $ltree_api_token],
|
||||||
|
'$bydefault' => ['ij_bydefault', DI::l10n()->t('Post to Libertree by default'), $def_enabled],
|
||||||
|
]);
|
||||||
|
|
||||||
/* Add some HTML to the existing form */
|
$data = [
|
||||||
|
'connector' => 'libertree',
|
||||||
$s .= '<span id="settings_libertree_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_libertree_expanded\'); openClose(\'settings_libertree_inflated\');">';
|
'title' => DI::l10n()->t('Libertree Export'),
|
||||||
$s .= '<img class="connector'.$css.'" src="images/libertree.png" /><h3 class="connector">'. DI::l10n()->t('libertree Export').'</h3>';
|
'image' => 'images/libertree.png',
|
||||||
$s .= '</span>';
|
'enabled' => $enabled,
|
||||||
$s .= '<div id="settings_libertree_expanded" class="settings-block" style="display: none;">';
|
'html' => $html,
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_libertree_expanded\'); openClose(\'settings_libertree_inflated\');">';
|
];
|
||||||
$s .= '<img class="connector'.$css.'" src="images/libertree.png" /><h3 class="connector">'. DI::l10n()->t('libertree Export').'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
|
|
||||||
$s .= '<div id="libertree-enable-wrapper">';
|
|
||||||
$s .= '<label id="libertree-enable-label" for="libertree-checkbox">' . DI::l10n()->t('Enable Libertree Post Addon') . '</label>';
|
|
||||||
$s .= '<input id="libertree-checkbox" type="checkbox" name="libertree" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="libertree-api_token-wrapper">';
|
|
||||||
$s .= '<label id="libertree-api_token-label" for="libertree-api_token">' . DI::l10n()->t('Libertree API token') . '</label>';
|
|
||||||
$s .= '<input id="libertree-api_token" type="text" name="libertree_api_token" value="' . $ltree_api_token . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="libertree-url-wrapper">';
|
|
||||||
$s .= '<label id="libertree-url-label" for="libertree-url">' . DI::l10n()->t('Libertree site URL') . '</label>';
|
|
||||||
$s .= '<input id="libertree-url" type="text" name="libertree_url" value="' . $ltree_url . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="libertree-bydefault-wrapper">';
|
|
||||||
$s .= '<label id="libertree-bydefault-label" for="libertree-bydefault">' . DI::l10n()->t('Post to Libertree by default') . '</label>';
|
|
||||||
$s .= '<input id="libertree-bydefault" type="checkbox" name="libertree_bydefault" value="1" ' . $def_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
/* provide a submit button */
|
|
||||||
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="libertree-submit" name="libertree-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
4
libertree/templates/connector_settings.tpl
Normal file
4
libertree/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||||
|
{{include file="field_input.tpl" field=$ltree_url}}
|
||||||
|
{{include file="field_input.tpl" field=$ltree_api_token}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$bydefault}}
|
BIN
ljpost/livejournal.png
Normal file
BIN
ljpost/livejournal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -8,9 +8,11 @@
|
||||||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
|
@ -27,7 +29,7 @@ function ljpost_install() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ljpost_jot_nets(\Friendica\App &$a, array &$jotnets_fields)
|
function ljpost_jot_nets(App &$a, array &$jotnets_fields)
|
||||||
{
|
{
|
||||||
if(! local_user()) {
|
if(! local_user()) {
|
||||||
return;
|
return;
|
||||||
|
@ -46,57 +48,31 @@ function ljpost_jot_nets(\Friendica\App &$a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function ljpost_settings(&$a,&$s) {
|
function ljpost_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 */
|
$enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post', false);
|
||||||
|
$ij_username = DI::pConfig()->get(local_user(), 'ljpost', 'ij_username');
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/ljpost/ljpost.css' . '" media="all" />' . "\r\n";
|
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(local_user(),'ljpost','post');
|
|
||||||
|
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post_by_default');
|
$def_enabled = DI::pConfig()->get(local_user(), 'ljpost', 'post_by_default');
|
||||||
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
||||||
|
$html = Renderer::replaceMacros($t, [
|
||||||
$lj_username = DI::pConfig()->get(local_user(), 'ljpost', 'lj_username');
|
'$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled],
|
||||||
$lj_password = DI::pConfig()->get(local_user(), 'ljpost', 'lj_password');
|
'$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username],
|
||||||
|
'$password' => ['ij_password', DI::l10n()->t('LiveJournal password')],
|
||||||
|
'$bydefault' => ['ij_bydefault', DI::l10n()->t('Post to LiveJournal by default'), $def_enabled],
|
||||||
/* Add some HTML to the existing form */
|
]);
|
||||||
|
|
||||||
$s .= '<div class="settings-block">';
|
|
||||||
$s .= '<h3>' . DI::l10n()->t('LiveJournal Post Settings') . '</h3>';
|
|
||||||
$s .= '<div id="ljpost-enable-wrapper">';
|
|
||||||
$s .= '<label id="ljpost-enable-label" for="ljpost-checkbox">' . DI::l10n()->t('Enable LiveJournal Post Addon') . '</label>';
|
|
||||||
$s .= '<input id="ljpost-checkbox" type="checkbox" name="ljpost" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="ljpost-username-wrapper">';
|
|
||||||
$s .= '<label id="ljpost-username-label" for="ljpost-username">' . DI::l10n()->t('LiveJournal username') . '</label>';
|
|
||||||
$s .= '<input id="ljpost-username" type="text" name="lj_username" value="' . $lj_username . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="ljpost-password-wrapper">';
|
|
||||||
$s .= '<label id="ljpost-password-label" for="ljpost-password">' . DI::l10n()->t('LiveJournal password') . '</label>';
|
|
||||||
$s .= '<input id="ljpost-password" type="password" name="lj_password" value="' . $lj_password . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="ljpost-bydefault-wrapper">';
|
|
||||||
$s .= '<label id="ljpost-bydefault-label" for="ljpost-bydefault">' . DI::l10n()->t('Post to LiveJournal by default') . '</label>';
|
|
||||||
$s .= '<input id="ljpost-bydefault" type="checkbox" name="lj_bydefault" value="1" ' . $def_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
/* provide a submit button */
|
|
||||||
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="ljpost-submit" name="ljpost-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
|
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'connector' => 'ljpost',
|
||||||
|
'title' => DI::l10n()->t('LiveJournal Export'),
|
||||||
|
'image' => 'addon/ljpost/livejournal.png',
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'html' => $html,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
4
ljpost/templates/connector_settings.tpl
Normal file
4
ljpost/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||||
|
{{include file="field_input.tpl" field=$username}}
|
||||||
|
{{include file="field_password.tpl" field=$password}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$bydefault}}
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
#pumpio-import-label,#pumpio-mirror-label,#pumpio-public-label, #pumpio-enable-label, #pumpio-username-label, #pumpio-servername-label, #pumpio-bydefault-label, #pumpio-delete-label {
|
|
||||||
float: left;
|
|
||||||
width: 200px;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pumpio-import,#pumpio-mirror,#pumpio-public, #pumpio-checkbox, #pumpio-username, #pumpio-servername, #pumpio-bydefault, #pumpio-delete {
|
|
||||||
float: left;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pumpio-submit {
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -216,109 +217,59 @@ function pumpio_jot_nets(App $a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_settings(App $a, &$s)
|
function pumpio_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 */
|
$pumpio_host = DI::pConfig()->get(local_user(), 'pumpio', 'host');
|
||||||
|
$pumpio_user = DI::pConfig()->get(local_user(), 'pumpio', 'user');
|
||||||
|
$oauth_token = DI::pConfig()->get(local_user(), 'pumpio', 'oauth_token');
|
||||||
|
$oauth_token_secret = DI::pConfig()->get(local_user(), 'pumpio', 'oauth_token_secret');
|
||||||
|
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/pumpio/pumpio.css' . '" media="all" />' . "\r\n";
|
$import_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'import', false);
|
||||||
|
$enabled = DI::pConfig()->get(local_user(), 'pumpio', 'post', false);
|
||||||
|
$def_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'post_by_default', false);
|
||||||
|
$public_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'public', false);
|
||||||
|
$mirror_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'mirror', false);
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
$submit = ['pumpio-submit' => DI::l10n()->t('Save Settings')];
|
||||||
|
if ($oauth_token && $oauth_token_secret) {
|
||||||
$import_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'import');
|
$submit['pumpio-delete'] = DI::l10n()->t('Delete this preset');
|
||||||
$import_checked = (($import_enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(local_user(), 'pumpio', 'post');
|
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
|
||||||
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'post_by_default');
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$public_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'public');
|
|
||||||
$public_checked = (($public_enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$mirror_enabled = DI::pConfig()->get(local_user(), 'pumpio', 'mirror');
|
|
||||||
$mirror_checked = (($mirror_enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$servername = DI::pConfig()->get(local_user(), "pumpio", "host");
|
|
||||||
$username = DI::pConfig()->get(local_user(), "pumpio", "user");
|
|
||||||
|
|
||||||
/* Add some HTML to the existing form */
|
|
||||||
|
|
||||||
$s .= '<span id="settings_pumpio_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
|
||||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. DI::l10n()->t('Pump.io Import/Export/Mirror').'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
$s .= '<div id="settings_pumpio_expanded" class="settings-block" style="display: none;">';
|
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
|
||||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. DI::l10n()->t('Pump.io Import/Export/Mirror').'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-username-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-username-label" for="pumpio-username">'.DI::l10n()->t('pump.io username (without the servername)').'</label>';
|
|
||||||
$s .= '<input id="pumpio-username" type="text" name="pumpio_user" value="'.$username.'" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-servername-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-servername-label" for="pumpio-servername">'.DI::l10n()->t('pump.io servername (without "http://" or "https://" )').'</label>';
|
|
||||||
$s .= '<input id="pumpio-servername" type="text" name="pumpio_host" value="'.$servername.'" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
if (($username != '') && ($servername != '')) {
|
|
||||||
$oauth_token = DI::pConfig()->get(local_user(), "pumpio", "oauth_token");
|
|
||||||
$oauth_token_secret = DI::pConfig()->get(local_user(), "pumpio", "oauth_token_secret");
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-password-wrapper">';
|
|
||||||
if (($oauth_token == "") || ($oauth_token_secret == "")) {
|
|
||||||
$s .= '<div id="pumpio-authenticate-wrapper">';
|
|
||||||
$s .= '<a href="'.DI::baseUrl()->get().'/pumpio/connect">'.DI::l10n()->t("Authenticate your pump.io connection").'</a>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
} else {
|
|
||||||
$s .= '<div id="pumpio-import-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-import-label" for="pumpio-import">' . DI::l10n()->t('Import the remote timeline') . '</label>';
|
|
||||||
$s .= '<input id="pumpio-import" type="checkbox" name="pumpio_import" value="1" ' . $import_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-enable-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-enable-label" for="pumpio-checkbox">' . DI::l10n()->t('Enable pump.io Post Addon') . '</label>';
|
|
||||||
$s .= '<input id="pumpio-checkbox" type="checkbox" name="pumpio" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-bydefault-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-bydefault-label" for="pumpio-bydefault">' . DI::l10n()->t('Post to pump.io by default') . '</label>';
|
|
||||||
$s .= '<input id="pumpio-bydefault" type="checkbox" name="pumpio_bydefault" value="1" ' . $def_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-public-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-public-label" for="pumpio-public">' . DI::l10n()->t('Should posts be public?') . '</label>';
|
|
||||||
$s .= '<input id="pumpio-public" type="checkbox" name="pumpio_public" value="1" ' . $public_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-mirror-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-mirror-label" for="pumpio-mirror">' . DI::l10n()->t('Mirror all public posts') . '</label>';
|
|
||||||
$s .= '<input id="pumpio-mirror" type="checkbox" name="pumpio_mirror" value="1" ' . $mirror_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="pumpio-delete-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-delete-label" for="pumpio-delete">' . DI::l10n()->t('Check to delete this preset') . '</label>';
|
|
||||||
$s .= '<input id="pumpio-delete" type="checkbox" name="pumpio_delete" value="1" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/pumpio/');
|
||||||
}
|
$html = Renderer::replaceMacros($t, [
|
||||||
|
'$l10n' => [
|
||||||
|
'authenticate' => DI::l10n()->t('Authenticate your pump.io connection'),
|
||||||
|
],
|
||||||
|
'$pumpio_host' => $pumpio_host,
|
||||||
|
'$pumpio_user' => $pumpio_user,
|
||||||
|
'$oauth_token' => $oauth_token,
|
||||||
|
'$oauth_token_secret' => $oauth_token_secret,
|
||||||
|
'$authenticate_url' => DI::baseUrl()->get() . '/pumpio/connect',
|
||||||
|
'$servername' => ['pumpio_host', DI::l10n()->t('Pump.io servername (without "http://" or "https://" )'), $pumpio_host],
|
||||||
|
'$username' => ['pumpio_user', DI::l10n()->t('Pump.io username (without the servername)'), $pumpio_user],
|
||||||
|
'$import' => ['pumpio_import', DI::l10n()->t('Import the remote timeline'), $import_enabled],
|
||||||
|
'$enabled' => ['pumpio', DI::l10n()->t('Enable Pump.io Post Addon'), $enabled],
|
||||||
|
'$bydefault' => ['pumpio_bydefault', DI::l10n()->t('Post to Pump.io by default'), $def_enabled],
|
||||||
|
'$public' => ['pumpio_public', DI::l10n()->t('Should posts be public?'), $public_enabled],
|
||||||
|
'$mirror' => ['pumpio_mirror', DI::l10n()->t('Mirror all public posts'), $mirror_enabled],
|
||||||
|
]);
|
||||||
|
|
||||||
/* provide a submit button */
|
$data = [
|
||||||
|
'connector' => 'pumpio',
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
|
'title' => DI::l10n()->t('Pump.io Import/Export/Mirror'),
|
||||||
|
'image' => 'images/pumpio.png',
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'html' => $html,
|
||||||
|
'submit' => $submit,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_settings_post(App $a, array &$b)
|
function pumpio_settings_post(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if (!empty($_POST['pumpio-submit'])) {
|
|
||||||
if (!empty($_POST['pumpio_delete'])) {
|
if (!empty($_POST['pumpio_delete'])) {
|
||||||
DI::pConfig()->set(local_user(), 'pumpio', 'consumer_key' , '');
|
DI::pConfig()->set(local_user(), 'pumpio', 'consumer_key' , '');
|
||||||
DI::pConfig()->set(local_user(), 'pumpio', 'consumer_secret' , '');
|
DI::pConfig()->set(local_user(), 'pumpio', 'consumer_secret' , '');
|
||||||
|
@ -333,7 +284,7 @@ function pumpio_settings_post(App $a, array &$b)
|
||||||
DI::pConfig()->set(local_user(), 'pumpio', 'post_by_default' , false);
|
DI::pConfig()->set(local_user(), 'pumpio', 'post_by_default' , false);
|
||||||
DI::pConfig()->set(local_user(), 'pumpio', 'lastdate' , 0);
|
DI::pConfig()->set(local_user(), 'pumpio', 'lastdate' , 0);
|
||||||
DI::pConfig()->set(local_user(), 'pumpio', 'last_id' , '');
|
DI::pConfig()->set(local_user(), 'pumpio', 'last_id' , '');
|
||||||
} else {
|
} elseif (!empty($_POST['pumpio-submit'])) {
|
||||||
// filtering the username if it is filled wrong
|
// filtering the username if it is filled wrong
|
||||||
$user = $_POST['pumpio_user'];
|
$user = $_POST['pumpio_user'];
|
||||||
if (strstr($user, "@")) {
|
if (strstr($user, "@")) {
|
||||||
|
@ -362,7 +313,6 @@ function pumpio_settings_post(App $a, array &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function pumpio_load_config(App $a, ConfigFileLoader $loader)
|
function pumpio_load_config(App $a, ConfigFileLoader $loader)
|
||||||
{
|
{
|
||||||
|
|
13
pumpio/templates/connector_settings.tpl
Normal file
13
pumpio/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{{include file="field_input.tpl" field=$servername}}
|
||||||
|
{{include file="field_input.tpl" field=$username}}
|
||||||
|
|
||||||
|
{{if $oauth_token && $oauth_token_secret}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$bydefault}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$public}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$mirror}}
|
||||||
|
{{elseif $pumpio_host && $pumpio_user}}
|
||||||
|
<div id="pumpio-authenticate-wrapper">
|
||||||
|
<a href="{{$authenticate_url}}">{{$l10n.authenticate}}</a>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
|
@ -10,62 +10,3 @@
|
||||||
height: 52px;
|
height: 52px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
#statusnet-disconnect-label {
|
|
||||||
float: left;
|
|
||||||
width: 250px;
|
|
||||||
margin-bottom: 25px;
|
|
||||||
}
|
|
||||||
#statusnet-disconnect {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#statusnet-default-label,
|
|
||||||
#statusnet-applicationname-label,
|
|
||||||
#statusnet-sendtaglinks-label,
|
|
||||||
#statusnet-shortening-label,
|
|
||||||
#statusnet-mirror-label,
|
|
||||||
#statusnet-import-label,
|
|
||||||
#statusnet-create_user-label,
|
|
||||||
#statusnet-pin-label,
|
|
||||||
#statusnet-enable-label {
|
|
||||||
float: left;
|
|
||||||
width: 250px;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#statusnet-checkbox {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#statusnet-pin {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#statusnet-consumerkey-label {
|
|
||||||
float: left;
|
|
||||||
width: 250px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
#statusnet-consumerkey {
|
|
||||||
float: left;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
#statusnet-consumersecret-label {
|
|
||||||
float: left;
|
|
||||||
width: 250px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
#statusnet-consumersecret {
|
|
||||||
float: left;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
#statusnet-baseapi-label {
|
|
||||||
float: left;
|
|
||||||
width: 250px;
|
|
||||||
margin-bottom: 25px;
|
|
||||||
}
|
|
||||||
#statusnet-baseapi {
|
|
||||||
float: left;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
|
@ -107,13 +107,13 @@ function statusnet_settings_post(App $a, $post)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// don't check GNU Social settings if GNU Social submit button is not clicked
|
// don't check GNU Social settings if GNU Social submit button is not clicked
|
||||||
if (empty($_POST['statusnet-submit'])) {
|
if (empty($_POST['statusnet-submit']) && empty($_POST['statusnet-disconnect'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['statusnet-disconnect'])) {
|
if (!empty($_POST['statusnet-disconnect'])) {
|
||||||
/* * *
|
/* * *
|
||||||
* if the GNU Social-disconnect checkbox is set, clear the GNU Social configuration
|
* if the GNU Social-disconnect button is clicked, clear the GNU Social configuration
|
||||||
*/
|
*/
|
||||||
DI::pConfig()->delete(local_user(), 'statusnet', 'consumerkey');
|
DI::pConfig()->delete(local_user(), 'statusnet', 'consumerkey');
|
||||||
DI::pConfig()->delete(local_user(), 'statusnet', 'consumersecret');
|
DI::pConfig()->delete(local_user(), 'statusnet', 'consumersecret');
|
||||||
|
@ -149,7 +149,6 @@ function statusnet_settings_post(App $a, $post)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DI::baseUrl()->redirect('settings/connectors');
|
|
||||||
} else {
|
} else {
|
||||||
if (isset($_POST['statusnet-consumersecret'])) {
|
if (isset($_POST['statusnet-consumersecret'])) {
|
||||||
// check if we can reach the API of the GNU Social server
|
// check if we can reach the API of the GNU Social server
|
||||||
|
@ -177,7 +176,6 @@ function statusnet_settings_post(App $a, $post)
|
||||||
notice(DI::l10n()->t('We could not contact the GNU Social API with the Path you entered.') . EOL);
|
notice(DI::l10n()->t('We could not contact the GNU Social API with the Path you entered.') . EOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DI::baseUrl()->redirect('settings/connectors');
|
|
||||||
} else {
|
} else {
|
||||||
if (isset($_POST['statusnet-pin'])) {
|
if (isset($_POST['statusnet-pin'])) {
|
||||||
// if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
|
// if the user supplied us with a PIN from GNU Social, let the magic of OAuth happen
|
||||||
|
@ -195,7 +193,6 @@ function statusnet_settings_post(App $a, $post)
|
||||||
DI::pConfig()->set(local_user(), 'statusnet', 'post', 1);
|
DI::pConfig()->set(local_user(), 'statusnet', 'post', 1);
|
||||||
DI::pConfig()->set(local_user(), 'statusnet', 'post_taglinks', 1);
|
DI::pConfig()->set(local_user(), 'statusnet', 'post_taglinks', 1);
|
||||||
// reload the Addon Settings page, if we don't do it see Bug #42
|
// reload the Addon Settings page, if we don't do it see Bug #42
|
||||||
DI::baseUrl()->redirect('settings/connectors');
|
|
||||||
} else {
|
} else {
|
||||||
// if no PIN is supplied in the POST variables, the user has changed the setting
|
// if no PIN is supplied in the POST variables, the user has changed the setting
|
||||||
// to post a dent for every new __public__ posting to the wall
|
// to post a dent for every new __public__ posting to the wall
|
||||||
|
@ -213,171 +210,125 @@ function statusnet_settings_post(App $a, $post)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusnet_settings(App $a, &$s)
|
function statusnet_settings(App $a, array &$data)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::getById(local_user());
|
DI::page()->registerStylesheet(__DIR__ . '/statusnet.css', 'all');
|
||||||
|
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/statusnet/statusnet.css' . '" media="all" />' . "\r\n";
|
|
||||||
/* * *
|
/* * *
|
||||||
* 1) Check that we have a base api url and a consumer key & secret
|
* 1) Check that we have a base api url and a consumer key & secret
|
||||||
* 2) If no OAuthtoken & stuff is present, generate button to get some
|
* 2) If no OAuthtoken & stuff is present, generate button to get some
|
||||||
* allow the user to cancel the connection process at this step
|
* allow the user to cancel the connection process at this step
|
||||||
* 3) Checkbox for "Send public notices (respect size limitation)
|
* 3) Checkbox for "Send public notices (respect size limitation)
|
||||||
*/
|
*/
|
||||||
$api = DI::pConfig()->get(local_user(), 'statusnet', 'baseapi');
|
$baseapi = DI::pConfig()->get(local_user(), 'statusnet', 'baseapi');
|
||||||
$ckey = DI::pConfig()->get(local_user(), 'statusnet', 'consumerkey');
|
$ckey = DI::pConfig()->get(local_user(), 'statusnet', 'consumerkey');
|
||||||
$csecret = DI::pConfig()->get(local_user(), 'statusnet', 'consumersecret');
|
$csecret = DI::pConfig()->get(local_user(), 'statusnet', 'consumersecret');
|
||||||
$otoken = DI::pConfig()->get(local_user(), 'statusnet', 'oauthtoken');
|
$otoken = DI::pConfig()->get(local_user(), 'statusnet', 'oauthtoken');
|
||||||
$osecret = DI::pConfig()->get(local_user(), 'statusnet', 'oauthsecret');
|
$osecret = DI::pConfig()->get(local_user(), 'statusnet', 'oauthsecret');
|
||||||
$enabled = DI::pConfig()->get(local_user(), 'statusnet', 'post');
|
$enabled = DI::pConfig()->get(local_user(), 'statusnet', 'post', false);
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
$def_enabled = DI::pConfig()->get(local_user(), 'statusnet', 'post_by_default', false);
|
||||||
$defenabled = DI::pConfig()->get(local_user(), 'statusnet', 'post_by_default');
|
$mirror_enabled = DI::pConfig()->get(local_user(), 'statusnet', 'mirror_posts', false);
|
||||||
$defchecked = (($defenabled) ? ' checked="checked" ' : '');
|
$createuser_enabled = DI::pConfig()->get(local_user(), 'statusnet', 'create_user', false);
|
||||||
$mirrorenabled = DI::pConfig()->get(local_user(), 'statusnet', 'mirror_posts');
|
|
||||||
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
|
||||||
$import = DI::pConfig()->get(local_user(), 'statusnet', 'import');
|
$import = DI::pConfig()->get(local_user(), 'statusnet', 'import');
|
||||||
$importselected = ["", "", ""];
|
|
||||||
$importselected[$import] = ' selected="selected"';
|
|
||||||
//$importenabled = DI::pConfig()->get(local_user(),'statusnet','import');
|
|
||||||
//$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
|
||||||
$create_userenabled = DI::pConfig()->get(local_user(), 'statusnet', 'create_user');
|
|
||||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
// Radio button list to select existing application credentials
|
||||||
|
$sites = array_map(function ($site) {
|
||||||
|
return ['statusnet-preconf-apiurl', $site['sitename'], $site['apiurl']];
|
||||||
|
}, DI::config()->get('statusnet', 'sites', []));
|
||||||
|
|
||||||
$s .= '<span id="settings_statusnet_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_statusnet_expanded\'); openClose(\'settings_statusnet_inflated\');">';
|
$submit = ['statusnet-submit' => DI::l10n()->t('Save Settings')];
|
||||||
$s .= '<img class="connector' . $css . '" src="images/gnusocial.png" /><h3 class="connector">' . DI::l10n()->t('GNU Social Import/Export/Mirror') . '</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
$s .= '<div id="settings_statusnet_expanded" class="settings-block" style="display: none;">';
|
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_statusnet_expanded\'); openClose(\'settings_statusnet_inflated\');">';
|
|
||||||
$s .= '<img class="connector' . $css . '" src="images/gnusocial.png" /><h3 class="connector">' . DI::l10n()->t('GNU Social Import/Export/Mirror') . '</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
|
|
||||||
if ((!$ckey) && (!$csecret)) {
|
if ($ckey && $csecret) {
|
||||||
|
if ($otoken && $osecret) {
|
||||||
/* * *
|
/* * *
|
||||||
* no consumer keys
|
* we have an OAuth key / secret pair for the user
|
||||||
|
* so let's give a chance to disable the postings to GNU Social
|
||||||
*/
|
*/
|
||||||
$globalsn = DI::config()->get('statusnet', 'sites');
|
$connection = new StatusNetOAuth($baseapi, $ckey, $csecret, $otoken, $osecret);
|
||||||
/* * *
|
$account = $connection->get('account/verify_credentials');
|
||||||
* lets check if we have one or more globally configured GNU Social
|
|
||||||
* server OAuth credentials in the configuration. If so offer them
|
if (!empty($account)) {
|
||||||
* with a little explanation to the user as choice - otherwise
|
$connected_account = DI::l10n()->t('Currently connected to: <a href="%s" target="_statusnet">%s</a>', $account->statusnet_profile_url, $account->screen_name);
|
||||||
* ignore this option entirely.
|
|
||||||
*/
|
|
||||||
if (!$globalsn == null) {
|
|
||||||
$s .= '<h4>' . DI::l10n()->t('Globally Available GNU Social OAuthKeys') . '</h4>';
|
|
||||||
$s .= '<p>' . DI::l10n()->t("There are preconfigured OAuth key pairs for some GNU Social servers available. If you are using one of them, please use these credentials. If not feel free to connect to any other GNU Social instance \x28see below\x29.") . '</p>';
|
|
||||||
$s .= '<div id="statusnet-preconf-wrapper">';
|
|
||||||
foreach ($globalsn as $asn) {
|
|
||||||
$s .= '<input type="radio" name="statusnet-preconf-apiurl" value="' . $asn['apiurl'] . '">' . $asn['sitename'] . '<br />';
|
|
||||||
}
|
}
|
||||||
$s .= '<p></p><div class="clear"></div></div>';
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
$user = User::getById(local_user());
|
||||||
|
if ($user['hidewall']) {
|
||||||
|
$privacy_warning = DI::l10n()->t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to GNU Social will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.');
|
||||||
}
|
}
|
||||||
$s .= '<h4>' . DI::l10n()->t('Provide your own OAuth Credentials') . '</h4>';
|
|
||||||
$s .= '<p>' . DI::l10n()->t('No consumer key pair for GNU Social found. Register your Friendica Account as an desktop client on your GNU Social account, copy the consumer key pair here and enter the API base root.<br />Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendica installation at your favorited GNU Social installation.') . '</p>';
|
$submit['statusnet-disconnect'] = DI::l10n()->t('Clear OAuth configuration');
|
||||||
$s .= '<div id="statusnet-consumer-wrapper">';
|
|
||||||
$s .= '<label id="statusnet-consumerkey-label" for="statusnet-consumerkey">' . DI::l10n()->t('OAuth Consumer Key') . '</label>';
|
|
||||||
$s .= '<input id="statusnet-consumerkey" type="text" name="statusnet-consumerkey" size="35" /><br />';
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
$s .= '<label id="statusnet-consumersecret-label" for="statusnet-consumersecret">' . DI::l10n()->t('OAuth Consumer Secret') . '</label>';
|
|
||||||
$s .= '<input id="statusnet-consumersecret" type="text" name="statusnet-consumersecret" size="35" /><br />';
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
$s .= '<label id="statusnet-baseapi-label" for="statusnet-baseapi">' . DI::l10n()->t("Base API Path \x28remember the trailing /\x29") . '</label>';
|
|
||||||
$s .= '<input id="statusnet-baseapi" type="text" name="statusnet-baseapi" size="35" /><br />';
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
//$s .= '<label id="statusnet-applicationname-label" for="statusnet-applicationname">'.DI::l10n()->t('GNU Socialapplication name').'</label>';
|
|
||||||
//$s .= '<input id="statusnet-applicationname" type="text" name="statusnet-applicationname" size="35" /><br />';
|
|
||||||
$s .= '<p></p><div class="clear"></div>';
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
|
||||||
$s .= '</div>';
|
|
||||||
} else {
|
} else {
|
||||||
/* * *
|
|
||||||
* ok we have a consumer key pair now look into the OAuth stuff
|
|
||||||
*/
|
|
||||||
if ((!$otoken) && (!$osecret)) {
|
|
||||||
/* * *
|
/* * *
|
||||||
* the user has not yet connected the account to GNU Social
|
* the user has not yet connected the account to GNU Social
|
||||||
* get a temporary OAuth key/secret pair and display a button with
|
* get a temporary OAuth key/secret pair and display a button with
|
||||||
* which the user can request a PIN to connect the account to a
|
* which the user can request a PIN to connect the account to a
|
||||||
* account at GNU Social
|
* account at GNU Social
|
||||||
*/
|
*/
|
||||||
$connection = new StatusNetOAuth($api, $ckey, $csecret);
|
$connection = new StatusNetOAuth($baseapi, $ckey, $csecret);
|
||||||
$request_token = $connection->getRequestToken('oob');
|
$request_token = $connection->getRequestToken('oob');
|
||||||
$token = $request_token['oauth_token'];
|
$authorize_url = $connection->getAuthorizeURL($request_token['oauth_token'], false);
|
||||||
/* * *
|
|
||||||
* make some nice form
|
|
||||||
*/
|
|
||||||
$s .= '<p>' . DI::l10n()->t('To connect to your GNU Social account click the button below to get a security code from GNU Social which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to GNU Social.') . '</p>';
|
|
||||||
$s .= '<a href="' . $connection->getAuthorizeURL($token, False) . '" target="_statusnet"><img src="addon/statusnet/signinwithstatusnet.png" alt="' . DI::l10n()->t('Log in with GNU Social') . '"></a>';
|
|
||||||
$s .= '<div id="statusnet-pin-wrapper">';
|
|
||||||
$s .= '<label id="statusnet-pin-label" for="statusnet-pin">' . DI::l10n()->t('Copy the security code from GNU Social here') . '</label>';
|
|
||||||
$s .= '<input id="statusnet-pin" type="text" name="statusnet-pin" />';
|
|
||||||
$s .= '<input id="statusnet-token" type="hidden" name="statusnet-token" value="' . $token . '" />';
|
|
||||||
$s .= '<input id="statusnet-token2" type="hidden" name="statusnet-token2" value="' . $request_token['oauth_token_secret'] . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
|
||||||
$s .= '<h4>' . DI::l10n()->t('Cancel Connection Process') . '</h4>';
|
|
||||||
$s .= '<div id="statusnet-cancel-wrapper">';
|
|
||||||
$s .= '<p>' . DI::l10n()->t('Current GNU Social API is') . ': ' . $api . '</p>';
|
|
||||||
$s .= '<label id="statusnet-cancel-label" for="statusnet-cancel">' . DI::l10n()->t('Cancel GNU Social Connection') . '</label>';
|
|
||||||
$s .= '<input id="statusnet-cancel" type="checkbox" name="statusnet-disconnect" value="1" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
|
||||||
} else {
|
|
||||||
/* * *
|
|
||||||
* we have an OAuth key / secret pair for the user
|
|
||||||
* so let's give a chance to disable the postings to GNU Social
|
|
||||||
*/
|
|
||||||
$connection = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret);
|
|
||||||
$details = $connection->get('account/verify_credentials');
|
|
||||||
if (!empty($details)) {
|
|
||||||
$s .= '<div id="statusnet-info" ><img id="statusnet-avatar" src="' . $details->profile_image_url . '" /><p id="statusnet-info-block">' . DI::l10n()->t('Currently connected to: ') . '<a href="' . $details->statusnet_profile_url . '" target="_statusnet">' . $details->screen_name . '</a><br /><em>' . $details->description . '</em></p></div>';
|
|
||||||
}
|
|
||||||
$s .= '<p>' . DI::l10n()->t('If enabled all your <strong>public</strong> postings can be posted to the associated GNU Social account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') . '</p>';
|
|
||||||
if ($user['hidewall']) {
|
|
||||||
$s .= '<p>' . DI::l10n()->t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to GNU Social will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '</p>';
|
|
||||||
}
|
|
||||||
$s .= '<div id="statusnet-enable-wrapper">';
|
|
||||||
$s .= '<label id="statusnet-enable-label" for="statusnet-checkbox">' . DI::l10n()->t('Allow posting to GNU Social') . '</label>';
|
|
||||||
$s .= '<input id="statusnet-checkbox" type="checkbox" name="statusnet-enable" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
$s .= '<label id="statusnet-default-label" for="statusnet-default">' . DI::l10n()->t('Send public postings to GNU Social by default') . '</label>';
|
|
||||||
$s .= '<input id="statusnet-default" type="checkbox" name="statusnet-default" value="1" ' . $defchecked . '/>';
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<label id="statusnet-mirror-label" for="statusnet-mirror">' . DI::l10n()->t('Mirror all posts from GNU Social that are no replies or repeated messages') . '</label>';
|
$submit['statusnet-disconnect'] = DI::l10n()->t('Cancel GNU Social Connection');
|
||||||
$s .= '<input id="statusnet-mirror" type="checkbox" name="statusnet-mirror" value="1" ' . $mirrorchecked . '/>';
|
|
||||||
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
$s .= '</div>';
|
|
||||||
|
|
||||||
$s .= '<label id="statusnet-import-label" for="statusnet-import">' . DI::l10n()->t('Import the remote timeline') . '</label>';
|
|
||||||
//$s .= '<input id="statusnet-import" type="checkbox" name="statusnet-import" value="1" '. $importchecked . '/>';
|
|
||||||
|
|
||||||
$s .= '<select name="statusnet-import" id="statusnet-import" />';
|
|
||||||
$s .= '<option value="0" ' . $importselected[0] . '>' . DI::l10n()->t("Disabled") . '</option>';
|
|
||||||
$s .= '<option value="1" ' . $importselected[1] . '>' . DI::l10n()->t("Full Timeline") . '</option>';
|
|
||||||
$s .= '<option value="2" ' . $importselected[2] . '>' . DI::l10n()->t("Only Mentions") . '</option>';
|
|
||||||
$s .= '</select>';
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
/*
|
|
||||||
$s .= '<label id="statusnet-create_user-label" for="statusnet-create_user">'.DI::l10n()->t('Automatically create contacts').'</label>';
|
|
||||||
$s .= '<input id="statusnet-create_user" type="checkbox" name="statusnet-create_user" value="1" '. $create_userchecked . '/>';
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
*/
|
|
||||||
$s .= '<div id="statusnet-disconnect-wrapper">';
|
|
||||||
$s .= '<label id="statusnet-disconnect-label" for="statusnet-disconnect">' . DI::l10n()->t('Clear OAuth configuration') . '</label>';
|
|
||||||
$s .= '<input id="statusnet-disconnect" type="checkbox" name="statusnet-disconnect" value="1" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="statusnet-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/statusnet/');
|
||||||
|
$html = Renderer::replaceMacros($t, [
|
||||||
|
'$l10n' => [
|
||||||
|
'global_title' => DI::l10n()->t('Globally Available GNU Social OAuthKeys'),
|
||||||
|
'global_info' => DI::l10n()->t(DI::l10n()->t('There are preconfigured OAuth key pairs for some GNU Social servers available. If you are using one of them, please use these credentials. If not feel free to connect to any other GNU Social instance (see below).')),
|
||||||
|
'credentials_title' => DI::l10n()->t('Provide your own OAuth Credentials'),
|
||||||
|
'credentials_info' => DI::l10n()->t('No consumer key pair for GNU Social found. Register your Friendica Account as a desktop application on your GNU Social account, copy the consumer key pair here and enter the API base root.<br />Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendica installation at your favorite GNU Social installation.'),
|
||||||
|
'oauth_info' => DI::l10n()->t('To connect to your GNU Social account click the button below to get a security code from GNU Social which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to GNU Social.'),
|
||||||
|
'oauth_alt' => DI::l10n()->t('Log in with GNU Social'),
|
||||||
|
'oauth_cancel' => DI::l10n()->t('Cancel Connection Process'),
|
||||||
|
'oauth_api' => DI::l10n()->t('Current GNU Social API is: %s', $baseapi),
|
||||||
|
'connected_account' => $connected_account ?? '',
|
||||||
|
'privacy_warning' => $privacy_warning ?? '',
|
||||||
|
],
|
||||||
|
|
||||||
|
'$ckey' => $ckey,
|
||||||
|
'$csecret' => $csecret,
|
||||||
|
'$otoken' => $otoken,
|
||||||
|
'$osecret' => $osecret,
|
||||||
|
'$sites' => $sites,
|
||||||
|
|
||||||
|
'$authorize_url' => $authorize_url ?? '',
|
||||||
|
'$request_token' => $request_token ?? null,
|
||||||
|
'$account' => $account ?? null,
|
||||||
|
|
||||||
|
'$authenticate_url' => DI::baseUrl()->get() . '/statusnet/connect',
|
||||||
|
|
||||||
|
'$consumerkey' => ['statusnet-consumerkey', DI::l10n()->t('OAuth Consumer Key'), '', '', false, ' size="35'],
|
||||||
|
'$consumersecret' => ['statusnet-consumersecret', DI::l10n()->t('OAuth Consumer Secret'), '', '', false, ' size="35'],
|
||||||
|
|
||||||
|
'$baseapi' => ['statusnet-baseapi', DI::l10n()->t('Base API Path (remember the trailing /)'), '', '', false, ' size="35'],
|
||||||
|
'$pin' => ['statusnet-pin', DI::l10n()->t('Copy the security code from GNU Social here')],
|
||||||
|
|
||||||
|
'$enable' => ['statusnet-enabled', DI::l10n()->t('Allow posting to GNU Social'), $enabled, DI::l10n()->t('If enabled all your <strong>public</strong> postings can be posted to the associated GNU Social account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')],
|
||||||
|
'$default' => ['statusnet-default', DI::l10n()->t('Post to GNU Social by default'), $def_enabled],
|
||||||
|
'$mirror' => ['statusnet-mirror', DI::l10n()->t('Mirror all public posts'), $mirror_enabled],
|
||||||
|
'$create_user' => ['statusnet-create_user', DI::l10n()->t('Automatically create contacts'), $createuser_enabled],
|
||||||
|
'$import' => ['statusnet-import', DI::l10n()->t('Import the remote timeline'), $import, '', [
|
||||||
|
0 => DI::l10n()->t('Disabled'),
|
||||||
|
1 => DI::l10n()->t('Full Timeline'),
|
||||||
|
2 => DI::l10n()->t('Only Mentions'),
|
||||||
|
]],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'connector' => 'statusnet',
|
||||||
|
'title' => DI::l10n()->t('GNU Social Import/Export/Mirror'),
|
||||||
|
'image' => 'images/gnusocial.png',
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'html' => $html,
|
||||||
|
'submit' => $submit,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusnet_hook_fork(App $a, array &$b)
|
function statusnet_hook_fork(App $a, array &$b)
|
||||||
|
|
50
statusnet/templates/connector_settings.tpl
Normal file
50
statusnet/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
{{if $ckey && $csecret}}
|
||||||
|
{{if $otoken && $osecret}}
|
||||||
|
{{if $account}}
|
||||||
|
<div id="statusnet-info">
|
||||||
|
<img id="statusnet-avatar" src="{{$account->profile_image_url}}" />
|
||||||
|
<p id="statusnet-info-block">
|
||||||
|
{{$l10n.connected_account nofilter}}<br />
|
||||||
|
<em>{{$account->description}}</em>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$enable}}
|
||||||
|
<p>{{$l10n.connected_public nofilter}}</p>
|
||||||
|
{{if $l10n.privacy_warning}}
|
||||||
|
<p>{{$l10n.privacy_warning nofilter}}</p>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{include file="field_checkbox.tpl" field=$default}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$mirror}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$import}}
|
||||||
|
{{*include file="field_checkbox.tpl" field=$create_user*}}
|
||||||
|
{{else}}
|
||||||
|
<p>{{$l10n.oauth_info}}</p>
|
||||||
|
<a href="{{$authorize_url}}" target="_statusnet"><img src="addon/statusnet/signinwithstatusnet.png" alt="{{$l10n.oauth_alt}}"></a>
|
||||||
|
<div id="statusnet-pin-wrapper">
|
||||||
|
<input id="statusnet-token" type="hidden" name="statusnet-token" value="{{$request_token.oauth_token}}" />
|
||||||
|
<input id="statusnet-token2" type="hidden" name="statusnet-token2" value="{{$request_token.oauth_token_secret}}" />
|
||||||
|
{{include file="field_input.tpl" field=$pin}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>{{$l10n.oauth_api}}</p>
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
{{if $sites}}
|
||||||
|
<h4>{{$l10n.global_title}}</h4>
|
||||||
|
<p>{{$l10n.global_info}}</p>
|
||||||
|
<div id="statusnet-preconf-wrapper">
|
||||||
|
{{foreach $sites as $site}}
|
||||||
|
{{include file="field_radio.tpl" field=$site}}
|
||||||
|
{{/foreach}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
<h4>{{$l10n.credentials_title}}</h4>
|
||||||
|
<p>{{$l10n.credentials_info nofilter}}</p>
|
||||||
|
<div id="statusnet-consumer-wrapper">
|
||||||
|
{{include file="field_input.tpl" field=$consumerkey}}
|
||||||
|
{{include file="field_input.tpl" field=$consumersecret}}
|
||||||
|
{{include file="field_input.tpl" field=$baseapi}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
10
tumblr/templates/connector_settings.tpl
Normal file
10
tumblr/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<p><a href="{{$authenticate_url}}">{{$l10n.connect}}</a></p>
|
||||||
|
|
||||||
|
{{include file="field_checkbox.tpl" field=$enable}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$bydefault}}
|
||||||
|
|
||||||
|
{{if $page_select}}
|
||||||
|
{{include file="field_select.tpl" field=$page_select}}
|
||||||
|
{{else}}
|
||||||
|
{{$l10n.noconnect}}
|
||||||
|
{{/if}}
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
#tumblr-enable-label, #tumblr-username-label, #tumblr-page-label, #tumblr-bydefault-label {
|
|
||||||
float: left;
|
|
||||||
width: 200px;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tumblr-checkbox, #tumblr-username, #tumblr-page, #tumblr-bydefault {
|
|
||||||
float: left;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tumblr-submit {
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
|
@ -198,89 +198,54 @@ function tumblr_jot_nets(App $a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tumblr_settings(App $a, &$s)
|
function tumblr_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 */
|
$enabled = DI::pConfig()->get(local_user(), 'tumblr', 'post', false);
|
||||||
|
$def_enabled = DI::pConfig()->get(local_user(), 'tumblr', 'post_by_default', false);
|
||||||
|
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/tumblr/tumblr.css' . '" media="all" />' . "\r\n";
|
$oauth_token = DI::pConfig()->get(local_user(), 'tumblr', 'oauth_token');
|
||||||
|
$oauth_token_secret = DI::pConfig()->get(local_user(), 'tumblr', 'oauth_token_secret');
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
if ($oauth_token && $oauth_token_secret) {
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(local_user(), 'tumblr', 'post');
|
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
|
||||||
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(), 'tumblr', 'post_by_default');
|
|
||||||
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
/* Add some HTML to the existing form */
|
|
||||||
|
|
||||||
$s .= '<span id="settings_tumblr_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
|
||||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. DI::l10n()->t('Tumblr Export').'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
$s .= '<div id="settings_tumblr_expanded" class="settings-block" style="display: none;">';
|
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
|
||||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. DI::l10n()->t('Tumblr Export').'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
|
|
||||||
$s .= '<div id="tumblr-username-wrapper">';
|
|
||||||
$s .= '<a href="'.DI::baseUrl()->get().'/tumblr/connect">'.DI::l10n()->t("(Re-)Authenticate your tumblr page").'</a>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="tumblr-enable-wrapper">';
|
|
||||||
$s .= '<label id="tumblr-enable-label" for="tumblr-checkbox">' . DI::l10n()->t('Enable Tumblr Post Addon') . '</label>';
|
|
||||||
$s .= '<input type="hidden" name="tumblr" value="0"/>';
|
|
||||||
$s .= '<input id="tumblr-checkbox" type="checkbox" name="tumblr" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="tumblr-bydefault-wrapper">';
|
|
||||||
$s .= '<label id="tumblr-bydefault-label" for="tumblr-bydefault">' . DI::l10n()->t('Post to Tumblr by default') . '</label>';
|
|
||||||
$s .= '<input type="hidden" name="tumblr_bydefault" value="0"/>';
|
|
||||||
$s .= '<input id="tumblr-bydefault" type="checkbox" name="tumblr_bydefault" value="1" ' . $def_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$oauth_token = DI::pConfig()->get(local_user(), "tumblr", "oauth_token");
|
|
||||||
$oauth_token_secret = DI::pConfig()->get(local_user(), "tumblr", "oauth_token_secret");
|
|
||||||
|
|
||||||
$s .= '<div id="tumblr-page-wrapper">';
|
|
||||||
|
|
||||||
if (($oauth_token != "") && ($oauth_token_secret != "")) {
|
|
||||||
$page = DI::pConfig()->get(local_user(), 'tumblr', 'page');
|
$page = DI::pConfig()->get(local_user(), 'tumblr', 'page');
|
||||||
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
$consumer_key = DI::config()->get('tumblr', 'consumer_key');
|
||||||
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
|
||||||
|
|
||||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||||
|
|
||||||
$userinfo = $tum_oauth->get('user/info');
|
$userinfo = $tum_oauth->get('user/info');
|
||||||
|
|
||||||
$blogs = [];
|
$blogs = array_map(function ($blog) {
|
||||||
|
return substr(str_replace(["http://", "https://"], ["", ""], $blog->url), 0, -1);
|
||||||
|
}, $userinfo->response->user->blogs);
|
||||||
|
|
||||||
$s .= '<label id="tumblr-page-label" for="tumblr-page">' . DI::l10n()->t('Post to page:') . '</label>';
|
$page_select = ['tumblr-page', DI::l10n()->t('Post to page:'), $page, '', $blogs];
|
||||||
$s .= '<select name="tumblr_page" id="tumblr-page">';
|
|
||||||
foreach($userinfo->response->user->blogs as $blog) {
|
|
||||||
$blogurl = substr(str_replace(["http://", "https://"], ["", ""], $blog->url), 0, -1);
|
|
||||||
|
|
||||||
if ($page == $blogurl) {
|
|
||||||
$s .= "<option value='".$blogurl."' selected>".$blogurl."</option>";
|
|
||||||
} else {
|
|
||||||
$s .= "<option value='".$blogurl."'>".$blogurl."</option>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= "</select>";
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/tumblr/');
|
||||||
} else {
|
$html = Renderer::replaceMacros($t, [
|
||||||
$s .= DI::l10n()->t("You are not authenticated to tumblr");
|
'$l10n' => [
|
||||||
}
|
'connect' => DI::l10n()->t('(Re-)Authenticate your tumblr page'),
|
||||||
|
'noconnect' => DI::l10n()->t('You are not authenticated to tumblr'),
|
||||||
|
],
|
||||||
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
'$authenticate_url' => DI::baseUrl()->get() . '/tumblr/connect',
|
||||||
|
|
||||||
/* provide a submit button */
|
'$enable' => ['tumblr', DI::l10n()->t('Enable Tumblr Post Addon'), $enabled],
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="tumblr-submit" name="tumblr-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
|
'$bydefault' => ['tumblr_bydefault', DI::l10n()->t('Post to Tumblr by default'), $def_enabled],
|
||||||
|
'$page_select' => $page_select ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'connector' => 'tumblr',
|
||||||
|
'title' => DI::l10n()->t('Tumblr Export'),
|
||||||
|
'image' => 'images/tumblr.png',
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'html' => $html,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function tumblr_settings_post(App $a, array &$b)
|
function tumblr_settings_post(App $a, array &$b)
|
||||||
|
|
23
twitter/templates/connector_settings.tpl
Normal file
23
twitter/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<div id="twitter-info" >
|
||||||
|
{{if $l10n.connected}}
|
||||||
|
<p>{{$l10n.connected nofilter}} <button type="submit" name="twitter-disconnect" value="1">{{$l10n.disconnect}}</button></p>
|
||||||
|
<p id="twitter-info-block">
|
||||||
|
<a href="https://twitter.com/{{$account->screen_name}}" target="_twitter"><img id="twitter-avatar" src="{{$account->profile_image_url}}" /></a>
|
||||||
|
<em>{{$account->description}}</em>
|
||||||
|
</p>
|
||||||
|
{{else}}
|
||||||
|
<p>{{$l10n.invalid}}</p>
|
||||||
|
<button type="submit" name="twitter-disconnect" value="1">{{$l10n.disconnect}}</button>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clear"></div>
|
||||||
|
|
||||||
|
{{include file="field_checkbox.tpl" field=$enable}}
|
||||||
|
{{if $l10n.privacy_warning}}
|
||||||
|
<p>{{$l10n.privacy_warning nofilter}}</p>
|
||||||
|
{{/if}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$default}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$mirror}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$import}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$create_user}}
|
|
@ -10,34 +10,3 @@
|
||||||
height: 52px;
|
height: 52px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
#twitter-disconnect-label {
|
|
||||||
float: left;
|
|
||||||
width: 250px;
|
|
||||||
margin-bottom: 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#twitter-disconnect {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
#twitter-default-label,
|
|
||||||
#twitter-sendtaglinks-label,
|
|
||||||
#twitter-enable-label,
|
|
||||||
#twitter-shortening-label,
|
|
||||||
#twitter-mirror-label,
|
|
||||||
#twitter-import-label,
|
|
||||||
#twitter-create_user-label,
|
|
||||||
#twitter-pin-label {
|
|
||||||
float: left;
|
|
||||||
width: 250px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#twitter-checkbox {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#twitter-pin {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -269,8 +269,6 @@ function twitter_settings_post(App $a)
|
||||||
} catch(TwitterOAuthException $e) {
|
} catch(TwitterOAuthException $e) {
|
||||||
notice($e->getMessage());
|
notice($e->getMessage());
|
||||||
}
|
}
|
||||||
// reload the Addon Settings page, if we don't do it see Bug #42
|
|
||||||
DI::baseUrl()->redirect('settings/connectors');
|
|
||||||
} else {
|
} else {
|
||||||
// if no PIN is supplied in the POST variables, the user has changed the setting
|
// if no PIN is supplied in the POST variables, the user has changed the setting
|
||||||
// to post a tweet for every new __public__ posting to the wall
|
// to post a tweet for every new __public__ posting to the wall
|
||||||
|
@ -287,7 +285,7 @@ function twitter_settings_post(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_settings(App $a, &$s)
|
function twitter_settings(App $a, array &$data)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
|
@ -295,7 +293,8 @@ function twitter_settings(App $a, &$s)
|
||||||
|
|
||||||
$user = User::getById(local_user());
|
$user = User::getById(local_user());
|
||||||
|
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n";
|
DI::page()->registerStylesheet(__DIR__ . '/twitter.css', 'all');
|
||||||
|
|
||||||
/* * *
|
/* * *
|
||||||
* 1) Check that we have global consumer key & secret
|
* 1) Check that we have global consumer key & secret
|
||||||
* 2) If no OAuthtoken & stuff is present, generate button to get some
|
* 2) If no OAuthtoken & stuff is present, generate button to get some
|
||||||
|
@ -312,21 +311,14 @@ function twitter_settings(App $a, &$s)
|
||||||
$importenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'import'));
|
$importenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'import'));
|
||||||
$create_userenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'create_user'));
|
$create_userenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'create_user'));
|
||||||
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
// Hide the submit button by default
|
||||||
|
$submit = '';
|
||||||
$s .= '<span id="settings_twitter_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_twitter_expanded\'); openClose(\'settings_twitter_inflated\');">';
|
|
||||||
$s .= '<img class="connector' . $css . '" src="images/twitter.png" /><h3 class="connector">' . DI::l10n()->t('Twitter Import/Export/Mirror') . '</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
$s .= '<div id="settings_twitter_expanded" class="settings-block" style="display: none;">';
|
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_twitter_expanded\'); openClose(\'settings_twitter_inflated\');">';
|
|
||||||
$s .= '<img class="connector' . $css . '" src="images/twitter.png" /><h3 class="connector">' . DI::l10n()->t('Twitter Import/Export/Mirror') . '</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
|
|
||||||
if ((!$ckey) && (!$csecret)) {
|
if ((!$ckey) && (!$csecret)) {
|
||||||
/* no global consumer keys
|
/* no global consumer keys
|
||||||
* display warning and skip personal config
|
* display warning and skip personal config
|
||||||
*/
|
*/
|
||||||
$s .= '<p>' . DI::l10n()->t('No consumer key pair for Twitter found. Please contact your site administrator.') . '</p>';
|
$html = '<p>' . DI::l10n()->t('No consumer key pair for Twitter found. Please contact your site administrator.') . '</p>';
|
||||||
} else {
|
} else {
|
||||||
// ok we have a consumer key pair now look into the OAuth stuff
|
// ok we have a consumer key pair now look into the OAuth stuff
|
||||||
if ((!$otoken) && (!$osecret)) {
|
if ((!$otoken) && (!$osecret)) {
|
||||||
|
@ -338,17 +330,19 @@ function twitter_settings(App $a, &$s)
|
||||||
$connection = new TwitterOAuth($ckey, $csecret);
|
$connection = new TwitterOAuth($ckey, $csecret);
|
||||||
try {
|
try {
|
||||||
$result = $connection->oauth('oauth/request_token', ['oauth_callback' => 'oob']);
|
$result = $connection->oauth('oauth/request_token', ['oauth_callback' => 'oob']);
|
||||||
$s .= '<p>' . DI::l10n()->t('At this Friendica instance the Twitter addon was enabled but you have not yet connected your account to your Twitter account. To do so click the button below to get a PIN from Twitter which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to Twitter.') . '</p>';
|
|
||||||
$s .= '<a href="' . $connection->url('oauth/authorize', ['oauth_token' => $result['oauth_token']]) . '" target="_twitter"><img src="addon/twitter/lighter.png" alt="' . DI::l10n()->t('Log in with Twitter') . '"></a>';
|
$html = '<p>' . DI::l10n()->t('At this Friendica instance the Twitter addon was enabled but you have not yet connected your account to your Twitter account. To do so click the button below to get a PIN from Twitter which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to Twitter.') . '</p>';
|
||||||
$s .= '<div id="twitter-pin-wrapper">';
|
$html .= '<a href="' . $connection->url('oauth/authorize', ['oauth_token' => $result['oauth_token']]) . '" target="_twitter"><img src="addon/twitter/lighter.png" alt="' . DI::l10n()->t('Log in with Twitter') . '"></a>';
|
||||||
$s .= '<label id="twitter-pin-label" for="twitter-pin">' . DI::l10n()->t('Copy the PIN from Twitter here') . '</label>';
|
$html .= '<div id="twitter-pin-wrapper">';
|
||||||
$s .= '<input id="twitter-pin" type="text" name="twitter-pin" />';
|
$html .= '<label id="twitter-pin-label" for="twitter-pin">' . DI::l10n()->t('Copy the PIN from Twitter here') . '</label>';
|
||||||
$s .= '<input id="twitter-token" type="hidden" name="twitter-token" value="' . $result['oauth_token'] . '" />';
|
$html .= '<input id="twitter-pin" type="text" name="twitter-pin" />';
|
||||||
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="' . $result['oauth_token_secret'] . '" />';
|
$html .= '<input id="twitter-token" type="hidden" name="twitter-token" value="' . $result['oauth_token'] . '" />';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$html .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="' . $result['oauth_token_secret'] . '" />';
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
|
$submit = null;
|
||||||
} catch (TwitterOAuthException $e) {
|
} catch (TwitterOAuthException $e) {
|
||||||
$s .= '<p>' . DI::l10n()->t('An error occured: ') . $e->getMessage() . '</p>';
|
$html = '<p>' . DI::l10n()->t('An error occured: ') . $e->getMessage() . '</p>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* * *
|
/* * *
|
||||||
|
@ -357,57 +351,53 @@ function twitter_settings(App $a, &$s)
|
||||||
*/
|
*/
|
||||||
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
|
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
|
||||||
try {
|
try {
|
||||||
$details = $connection->get('account/verify_credentials');
|
$account = $connection->get('account/verify_credentials');
|
||||||
|
if (property_exists($account, 'screen_name') &&
|
||||||
$field_checkbox = Renderer::getMarkupTemplate('field_checkbox.tpl');
|
property_exists($account, 'description') &&
|
||||||
|
property_exists($account, 'profile_image_url')
|
||||||
if (property_exists($details, 'screen_name') &&
|
) {
|
||||||
property_exists($details, 'description') &&
|
$connected = DI::l10n()->t('Currently connected to: <a href="https://twitter.com/%1$s" target="_twitter">%1$s</a>', $account->screen_name);
|
||||||
property_exists($details, 'profile_image_url')) {
|
|
||||||
$s .= '<div id="twitter-info" >
|
|
||||||
<p>' . DI::l10n()->t('Currently connected to: ') . '<a href="https://twitter.com/' . $details->screen_name . '" target="_twitter">' . $details->screen_name . '</a>
|
|
||||||
<button type="submit" name="twitter-disconnect" value="1">' . DI::l10n()->t('Disconnect') . '</button>
|
|
||||||
</p>
|
|
||||||
<p id="twitter-info-block">
|
|
||||||
<a href="https://twitter.com/' . $details->screen_name . '" target="_twitter"><img id="twitter-avatar" src="' . $details->profile_image_url . '" /></a>
|
|
||||||
<em>' . $details->description . '</em>
|
|
||||||
</p>
|
|
||||||
</div>';
|
|
||||||
} else {
|
} else {
|
||||||
$s .= '<div id="twitter-info" >
|
|
||||||
<p>Invalid Twitter info</p>
|
|
||||||
<button type="submit" name="twitter-disconnect" value="1">' . DI::l10n()->t('Disconnect') . '</button>
|
|
||||||
</div>';
|
|
||||||
Logger::notice('Invalid twitter info (verify credentials).', ['auth' => TwitterOAuth::class]);
|
Logger::notice('Invalid twitter info (verify credentials).', ['auth' => TwitterOAuth::class]);
|
||||||
}
|
}
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= Renderer::replaceMacros($field_checkbox, [
|
|
||||||
'$field' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')]
|
|
||||||
]);
|
|
||||||
if ($user['hidewall']) {
|
if ($user['hidewall']) {
|
||||||
$s .= '<p>' . DI::l10n()->t('<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '</p>';
|
$privacy_warning = DI::l10n()->t('<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.');
|
||||||
}
|
}
|
||||||
$s .= Renderer::replaceMacros($field_checkbox, [
|
|
||||||
'$field' => ['twitter-default', DI::l10n()->t('Send public postings to Twitter by default'), $defenabled, '']
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/twitter/');
|
||||||
|
$html = Renderer::replaceMacros($t, [
|
||||||
|
'$l10n' => [
|
||||||
|
'connected' => $connected ?? '',
|
||||||
|
'invalid' => DI::l10n()->t('Invalid Twitter info'),
|
||||||
|
'disconnect' => DI::l10n()->t('Disconnect'),
|
||||||
|
'privacy_warning' => $privacy_warning ?? '',
|
||||||
|
],
|
||||||
|
|
||||||
|
'$account' => $account,
|
||||||
|
'$enable' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')],
|
||||||
|
'$default' => ['twitter-default', DI::l10n()->t('Send public postings to Twitter by default'), $defenabled],
|
||||||
|
'$mirror' => ['twitter-mirror', DI::l10n()->t('Mirror all posts from twitter that are no replies'), $mirrorenabled],
|
||||||
|
'$import' => ['twitter-import', DI::l10n()->t('Import the remote timeline'), $importenabled],
|
||||||
|
'$create_user' => ['twitter-create_user', DI::l10n()->t('Automatically create contacts'), $create_userenabled, DI::l10n()->t('This will automatically create a contact in Friendica as soon as you receive a message from an existing contact via the Twitter network. If you do not enable this, you need to manually add those Twitter contacts in Friendica from whom you would like to see posts here.')],
|
||||||
]);
|
]);
|
||||||
$s .= Renderer::replaceMacros($field_checkbox, [
|
|
||||||
'$field' => ['twitter-mirror', DI::l10n()->t('Mirror all posts from twitter that are no replies'), $mirrorenabled, '']
|
// Enable the default submit button
|
||||||
]);
|
$submit = null;
|
||||||
$s .= Renderer::replaceMacros($field_checkbox, [
|
|
||||||
'$field' => ['twitter-import', DI::l10n()->t('Import the remote timeline'), $importenabled, '']
|
|
||||||
]);
|
|
||||||
$s .= Renderer::replaceMacros($field_checkbox, [
|
|
||||||
'$field' => ['twitter-create_user', DI::l10n()->t('Automatically create contacts'), $create_userenabled, DI::l10n()->t('This will automatically create a contact in Friendica as soon as you receive a message from an existing contact via the Twitter network. If you do not enable this, you need to manually add those Twitter contacts in Friendica from whom you would like to see posts here.')]
|
|
||||||
]);
|
|
||||||
$s .= '<div class="clear"></div>';
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div>';
|
|
||||||
} catch (TwitterOAuthException $e) {
|
} catch (TwitterOAuthException $e) {
|
||||||
$s .= '<p>' . DI::l10n()->t('An error occured: ') . $e->getMessage() . '</p>';
|
$html = '<p>' . DI::l10n()->t('An error occured: ') . $e->getMessage() . '</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
$data = [
|
||||||
|
'connector' => 'twitter',
|
||||||
|
'title' => DI::l10n()->t('Twitter Import/Export/Mirror'),
|
||||||
|
'enabled' => $enabled,
|
||||||
|
'image' => 'images/twitter.png',
|
||||||
|
'html' => $html,
|
||||||
|
'submit' => $submit ?? null,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_hook_fork(App $a, array &$b)
|
function twitter_hook_fork(App $a, array &$b)
|
||||||
|
|
5
wppost/templates/connector_settings.tpl
Normal file
5
wppost/templates/connector_settings.tpl
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$enabled}}
|
||||||
|
{{include file="field_input.tpl" field=$username}}
|
||||||
|
{{include file="field_password.tpl" field=$password}}
|
||||||
|
{{include file="field_input.tpl" field=$blog}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$bydefault}}
|
|
@ -1,20 +0,0 @@
|
||||||
|
|
||||||
#wppost-enable-label, #wppost-username-label, #wppost-password-label,
|
|
||||||
#wppost-blog-label, #wppost-bydefault-label,
|
|
||||||
#wppost-backlink-label, #wppost-shortcheck-label {
|
|
||||||
float: left;
|
|
||||||
width: 200px;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#wppost-checkbox, #wppost-username, #wppost-password,
|
|
||||||
#wppost-blog, #wppost-bydefault,
|
|
||||||
#wppost-shortcheck, #wppost-backlink {
|
|
||||||
float: left;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#wppost-submit {
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Content\Text\BBCode;
|
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\Post;
|
use Friendica\Model\Post;
|
||||||
|
@ -25,7 +27,7 @@ function wppost_install()
|
||||||
Hook::register('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
|
Hook::register('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
|
||||||
}
|
}
|
||||||
|
|
||||||
function wppost_jot_nets(\Friendica\App &$a, array &$jotnets_fields)
|
function wppost_jot_nets(App &$a, array &$jotnets_fields)
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
return;
|
return;
|
||||||
|
@ -44,92 +46,39 @@ function wppost_jot_nets(\Friendica\App &$a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function wppost_settings(&$a, &$s) {
|
function wppost_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 */
|
$enabled = DI::pConfig()->get(local_user(), 'wppost', 'post', false);
|
||||||
|
|
||||||
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/wppost/wppost.css' . '" media="all" />' . "\r\n";
|
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(local_user(),'wppost','post');
|
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
|
||||||
|
|
||||||
$def_enabled = DI::pConfig()->get(local_user(),'wppost','post_by_default');
|
|
||||||
$back_enabled = DI::pConfig()->get(local_user(),'wppost','backlink');
|
|
||||||
$shortcheck_enabled = DI::pConfig()->get(local_user(),'wppost','shortcheck');
|
|
||||||
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
|
||||||
$back_checked = (($back_enabled) ? ' checked="checked" ' : '');
|
|
||||||
$shortcheck_checked = (($shortcheck_enabled) ? ' checked="checked" ' : '');
|
|
||||||
|
|
||||||
$wp_username = DI::pConfig()->get(local_user(), 'wppost', 'wp_username');
|
$wp_username = DI::pConfig()->get(local_user(), 'wppost', 'wp_username');
|
||||||
$wp_password = DI::pConfig()->get(local_user(), 'wppost', 'wp_password');
|
|
||||||
$wp_blog = DI::pConfig()->get(local_user(), 'wppost', 'wp_blog');
|
$wp_blog = DI::pConfig()->get(local_user(), 'wppost', 'wp_blog');
|
||||||
|
$def_enabled = DI::pConfig()->get(local_user(), 'wppost', 'post_by_default', false);
|
||||||
|
$back_enabled = DI::pConfig()->get(local_user(), 'wppost', 'backlink', false);
|
||||||
$wp_backlink_text = DI::pConfig()->get(local_user(), 'wppost', 'wp_backlink_text');
|
$wp_backlink_text = DI::pConfig()->get(local_user(), 'wppost', 'wp_backlink_text');
|
||||||
|
$shortcheck_enabled = DI::pConfig()->get(local_user(), 'wppost', 'shortcheck', false);
|
||||||
|
|
||||||
|
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/wppost/');
|
||||||
|
$html = Renderer::replaceMacros($t, [
|
||||||
|
'$enabled' => ['wppost', DI::l10n()->t('Enable Wordpress Post Addon'), $enabled],
|
||||||
|
'$username' => ['wp_username', DI::l10n()->t('Wordpress username'), $wp_username],
|
||||||
|
'$password' => ['wp_password', DI::l10n()->t('Wordpress password')],
|
||||||
|
'$blog' => ['wp_blog', DI::l10n()->t('WordPress API URL'), $wp_blog],
|
||||||
|
'$bydefault' => ['wp_bydefault', DI::l10n()->t('Post to Wordpress by default'), $def_enabled],
|
||||||
|
'$backlink' => ['wp_backlink', DI::l10n()->t('Provide a backlink to the Friendica post'), $back_enabled],
|
||||||
|
'$backlink_text' => ['wp_backlink_text', DI::l10n()->t('Text for the backlink, e.g. Read the original post and comment stream on Friendica.'), $wp_backlink_text],
|
||||||
|
'$shortcheck' => ['wp_shortcheck', DI::l10n()->t('Don\'t post messages that are too short'), $shortcheck_enabled],
|
||||||
|
]);
|
||||||
|
|
||||||
/* Add some HTML to the existing form */
|
$data = [
|
||||||
|
'connector' => 'wppost',
|
||||||
$s .= '<span id="settings_wppost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_wppost_expanded\'); openClose(\'settings_wppost_inflated\');">';
|
'title' => DI::l10n()->t('Wordpress Export'),
|
||||||
$s .= '<img class="connector'.$css.'" src="images/wordpress.png" /><h3 class="connector">'. DI::l10n()->t('Wordpress Export').'</h3>';
|
'image' => 'images/wordpress.png',
|
||||||
$s .= '</span>';
|
'enabled' => $enabled,
|
||||||
$s .= '<div id="settings_wppost_expanded" class="settings-block" style="display: none;">';
|
'html' => $html,
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_wppost_expanded\'); openClose(\'settings_wppost_inflated\');">';
|
];
|
||||||
$s .= '<img class="connector'.$css.'" src="images/wordpress.png" /><h3 class="connector">'. DI::l10n()->t('Wordpress Export').'</h3>';
|
|
||||||
$s .= '</span>';
|
|
||||||
$s .= '<div id="wppost-enable-wrapper">';
|
|
||||||
$s .= '<label id="wppost-enable-label" for="wppost-enable">' . DI::l10n()->t('Enable WordPress Post Addon') . '</label>';
|
|
||||||
$s .= '<input type="hidden" name="wppost" value="0"/>';
|
|
||||||
$s .= '<input id="wppost-enable" type="checkbox" name="wppost" value="1" ' . $checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="wppost-username-wrapper">';
|
|
||||||
$s .= '<label id="wppost-username-label" for="wppost-username">' . DI::l10n()->t('WordPress username') . '</label>';
|
|
||||||
$s .= '<input id="wppost-username" type="text" name="wp_username" value="' . $wp_username . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="wppost-password-wrapper">';
|
|
||||||
$s .= '<label id="wppost-password-label" for="wppost-password">' . DI::l10n()->t('WordPress password') . '</label>';
|
|
||||||
$s .= '<input id="wppost-password" type="password" name="wp_password" value="' . $wp_password . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="wppost-blog-wrapper">';
|
|
||||||
$s .= '<label id="wppost-blog-label" for="wppost-blog">' . DI::l10n()->t('WordPress API URL') . '</label>';
|
|
||||||
$s .= '<input id="wppost-blog" type="text" name="wp_blog" value="' . $wp_blog . '" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="wppost-bydefault-wrapper">';
|
|
||||||
$s .= '<label id="wppost-bydefault-label" for="wppost-bydefault">' . DI::l10n()->t('Post to WordPress by default') . '</label>';
|
|
||||||
$s .= '<input type="hidden" name="wp_bydefault" value="0"/>';
|
|
||||||
$s .= '<input id="wppost-bydefault" type="checkbox" name="wp_bydefault" value="1" ' . $def_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="wppost-backlink-wrapper">';
|
|
||||||
$s .= '<label id="wppost-backlink-label" for="wppost-backlink">' . DI::l10n()->t('Provide a backlink to the Friendica post') . '</label>';
|
|
||||||
$s .= '<input type="hidden" name="wp_backlink" value="0"/>';
|
|
||||||
$s .= '<input id="wppost-backlink" type="checkbox" name="wp_backlink" value="1" ' . $back_checked . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
$s .= '<div id="wppost-backlinktext-wrapper">';
|
|
||||||
$s .= '<label id="wppost-backlinktext-label" for="wp_backlink_text">' . DI::l10n()->t('Text for the backlink, e.g. Read the original post and comment stream on Friendica.') . '</label>';
|
|
||||||
$s .= '<input id="wppost-backlinktext" type="text" name="wp_backlink_text" value="'. $wp_backlink_text.'" ' . $wp_backlink_text . '/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
$s .= '<div id="wppost-shortcheck-wrapper">';
|
|
||||||
$s .= '<label id="wppost-shortcheck-label" for="wppost-shortcheck">' . DI::l10n()->t("Don't post messages that are too short") . '</label>';
|
|
||||||
$s .= '<input type="hidden" name="wp_shortcheck" value="0"/>';
|
|
||||||
$s .= '<input id="wppost-shortcheck" type="checkbox" name="wp_shortcheck" value="1" '.$shortcheck_checked.'/>';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
|
||||||
|
|
||||||
/* provide a submit button */
|
|
||||||
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="wppost-submit" name="wppost-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue