From a3e24a55ec5ac3b25e3a442026e78ef4dacca452 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 16 Aug 2023 03:28:54 +0000 Subject: [PATCH] Last status is split for better readability --- twitter/lang/C/messages.po | 34 ++++++++++++++++-------- twitter/templates/connector_settings.tpl | 1 + twitter/twitter.php | 10 ++++--- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/twitter/lang/C/messages.po b/twitter/lang/C/messages.po index 4bcc4efa..366d6c8f 100644 --- a/twitter/lang/C/messages.po +++ b/twitter/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-08-09 19:59+0000\n" +"POT-Creation-Date: 2023-08-16 03:27+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,42 +17,46 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: twitter.php:80 +#: twitter.php:84 msgid "Post to Twitter" msgstr "" -#: twitter.php:117 +#: twitter.php:123 +msgid "No status." +msgstr "" + +#: twitter.php:129 msgid "Allow posting to Twitter" msgstr "" -#: twitter.php:117 +#: twitter.php:129 msgid "" "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." msgstr "" -#: twitter.php:118 +#: twitter.php:130 msgid "Send public postings to Twitter by default" msgstr "" -#: twitter.php:119 +#: twitter.php:131 msgid "API Key" msgstr "" -#: twitter.php:120 +#: twitter.php:132 msgid "API Secret" msgstr "" -#: twitter.php:121 +#: twitter.php:133 msgid "Access Token" msgstr "" -#: twitter.php:122 +#: twitter.php:134 msgid "Access Secret" msgstr "" -#: twitter.php:123 +#: twitter.php:135 msgid "" "Each user needs to register their own app to be able to post to Twitter. " "Please visit https://developer.twitter.com/en/portal/projects-and-apps to " @@ -61,6 +65,14 @@ msgid "" "in the app settings." msgstr "" -#: twitter.php:128 +#: twitter.php:136 +msgid "Last Status Summary" +msgstr "" + +#: twitter.php:137 +msgid "Last Status Content" +msgstr "" + +#: twitter.php:142 msgid "Twitter Export" msgstr "" diff --git a/twitter/templates/connector_settings.tpl b/twitter/templates/connector_settings.tpl index 534f39dc..251093de 100644 --- a/twitter/templates/connector_settings.tpl +++ b/twitter/templates/connector_settings.tpl @@ -5,4 +5,5 @@ {{include file="field_input.tpl" field=$api_secret}} {{include file="field_input.tpl" field=$access_token}} {{include file="field_input.tpl" field=$access_secret}} +{{include file="field_input.tpl" field=$status_title}} {{include file="field_textarea.tpl" field=$status}} \ No newline at end of file diff --git a/twitter/twitter.php b/twitter/twitter.php index c033fa93..d52da4f7 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -117,11 +117,12 @@ function twitter_settings(array &$data) $access_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'twitter', 'access_secret'); $last_status = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'twitter', 'last_status'); - if (!empty($last_status['code'])) { - $status = print_r($last_status, true); + if (!empty($last_status['code']) && !empty($last_status['reason'])) { + $status_title = sprintf('%d - %s', $last_status['code'], $last_status['reason']); } else { - $status = DI::l10n()->t('No status.'); + $status_title = DI::l10n()->t('No status.'); } + $status_content = $last_status['content'] ?? ''; $t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/twitter/'); $html = Renderer::replaceMacros($t, [ @@ -132,7 +133,8 @@ function twitter_settings(array &$data) '$access_token' => ['twitter-access-token', DI::l10n()->t('Access Token'), $access_token], '$access_secret' => ['twitter-access-secret', DI::l10n()->t('Access Secret'), $access_secret], '$help' => DI::l10n()->t('Each user needs to register their own app to be able to post to Twitter. Please visit https://developer.twitter.com/en/portal/projects-and-apps to register a project. Inside the project you then have to register an app. You will find the needed data for the connector on the page "Keys and token" in the app settings.'), - '$status' => ['twitter-status', DI::l10n()->t('Last Status'), $status, '', '', 'readonly'], + '$status_title' => ['twitter-status-title', DI::l10n()->t('Last Status Summary'), $status_title, '', '', 'readonly'], + '$status' => ['twitter-status', DI::l10n()->t('Last Status Content'), $status_content, '', '', 'readonly'], ]); $data = [ -- 2.39.5