From 308ba3ce8cdb2c30e538dbf219ee3ed6f1528ef7 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 5 Jan 2018 02:53:24 -0500 Subject: [PATCH] Improve Twitter settings display - Use template instead of manual HTML --- twitter/twitter.php | 70 ++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index dbd0bab8..7c747135 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -259,16 +259,12 @@ function twitter_settings(App $a, &$s) $csecret = Config::get('twitter', 'consumersecret' ); $otoken = PConfig::get(local_user(), 'twitter', 'oauthtoken' ); $osecret = PConfig::get(local_user(), 'twitter', 'oauthsecret' ); - $enabled = PConfig::get(local_user(), 'twitter', 'post'); - $checked = (($enabled) ? ' checked="checked" ' : ''); - $defenabled = PConfig::get(local_user(), 'twitter', 'post_by_default'); - $defchecked = (($defenabled) ? ' checked="checked" ' : ''); - $mirrorenabled = PConfig::get(local_user(), 'twitter', 'mirror_posts'); - $mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : ''); - $importenabled = PConfig::get(local_user(), 'twitter', 'import'); - $importchecked = (($importenabled) ? ' checked="checked" ' : ''); - $create_userenabled = PConfig::get(local_user(), 'twitter', 'create_user'); - $create_userchecked = (($create_userenabled) ? ' checked="checked" ' : ''); + + $enabled = intval(PConfig::get(local_user(), 'twitter', 'post')); + $defenabled = intval(PConfig::get(local_user(), 'twitter', 'post_by_default')); + $mirrorenabled = intval(PConfig::get(local_user(), 'twitter', 'mirror_posts')); + $importenabled = intval(PConfig::get(local_user(), 'twitter', 'import')); + $create_userenabled = intval(PConfig::get(local_user(), 'twitter', 'create_user')); $css = (($enabled) ? '' : '-disabled'); @@ -321,36 +317,40 @@ function twitter_settings(App $a, &$s) require_once 'library/twitteroauth.php'; $connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $details = $connection->get('account/verify_credentials'); - $s .= '

' . t('Currently connected to: ') . '' . $details->screen_name . '
' . $details->description . '

'; - $s .= '

' . t('If enabled all your public 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 ($a->user['hidewall']) { - $s .= '

' . t('Note: Due your privacy settings (Hide your profile details from unknown viewers?) 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 .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; - $s .= ''; - $s .= ''; + $field_checkbox = get_markup_template('field_checkbox.tpl'); + + $s .= '
+

' . t('Currently connected to: ') . '' . $details->screen_name . ' + +

+

+ + ' . $details->description . ' +

+
'; $s .= '
'; - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; + $s .= replace_macros($field_checkbox, array( + '$field' => array('twitter-enable', t('Allow posting to Twitter'), $enabled, t('If enabled all your public 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 ($a->user['hidewall']) { + $s .= '

' . t('Note: Due your privacy settings (Hide your profile details from unknown viewers?) 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 .= replace_macros($field_checkbox, array( + '$field' => array('twitter-default', t('Send public postings to Twitter by default'), $defenabled, '') + )); + $s .= replace_macros($field_checkbox, array( + '$field' => array('twitter-mirror', t('Mirror all posts from twitter that are no replies'), $mirrorenabled, '') + )); + $s .= replace_macros($field_checkbox, array( + '$field' => array('twitter-import', t('Import the remote timeline'), $importenabled, '') + )); + $s .= replace_macros($field_checkbox, array( + '$field' => array('twitter-create_user', t('Automatically create contacts'), $create_userenabled, '') + )); - $s .= ''; - $s .= ''; $s .= '
'; - - $s .= '
'; - $s .= ''; - $s .= ''; - $s .= '
'; $s .= '
'; } } -- 2.39.5