case 'showFromSearch':
$tweets = $this->tweetRepository->getTweetsFromSearch($this->settings, $response);
break;
+ case 'showListsFrom':
+ $tweets = $this->tweetRepository->getListsFromUser($this->settings, $response);
+ break;
}
// Look up for any errors
if ($response !== '') {
$tweets = $this->callApi(Tx_WtTwitter_Twitter_Api::getStatusesUserTimelineUrl(), 'GET', $parameter, $response);
}
- return $this->addOldUserInformation($this->sliceTweets($tweets, $settings['limit']));
+ return $this->addOldUserInformation($this->sliceArray($tweets, $settings['limit']));
}
/**
$tweets = $result->statuses;
}
- return $this->addOldUserInformation($this->sliceTweets($tweets, $settings['limit']));
+ return $this->addOldUserInformation($this->sliceArray($tweets, $settings['limit']));
+ }
+
+ public function getListsFromUser($settings, &$response = NULL) {
+ $lists = array();
+
+ if ($this->isTwitterSigned()&& $this->isCurlActivated()) {
+ $parameter = array(
+ 'count' => ((int) $settings['limit'] > 0 ? $settings['limit'] : '1000'),
+ 'cursor' => '-1'
+ );
+
+ // Get screen name
+ if (Tx_WtTwitter_Utility_Compatibility::testInt($settings['account'])) {
+ $parameter['user_id'] = $settings['account'];
+ } else {
+ $parameter['screen_name'] = $settings['account'];
+ }
+
+ $result = $this->callApi(Tx_WtTwitter_Twitter_Api::getListsOwnershipsUrl(), 'GET', $parameter, $response);
+ $lists = $result->lists;
+
+ usort($lists, function($a, $b) use ($settings) {
+ switch ($settings['orderby']) {
+ case 'subscriberCount':
+ $valueA = (int) $a->subscriber_count;
+ $valueB = (int) $b->subscriber_count;
+ break;
+ case 'memberCount':
+ $valueA = (int) $a->member_count;
+ $valueB = (int) $b->member_count;
+ break;
+ default:
+ $dateA = new DateTime($a->created_at);
+ $valueA = $dateA->getTimestamp();
+ $dateB = new DateTime($b->created_at);
+ $valueB = $dateB->getTimestamp();
+ }
+
+ if ($valueA === $valueB) {
+ return 0;
+ }
+
+ return ($valueA > $valueB) ? -1 : 1;
+ });
+ }
+
+ return $lists;
}
/**
}
/**
- * @param array $tweets
+ * @param array $array
* @param integer $count
* @return array
*/
- protected function sliceTweets(array $tweets, $count) {
- if (count($tweets) <= $count) {
- return $tweets;
+ protected function sliceArray(array $array, $count) {
+ if (empty($count) || count($array) <= $count) {
+ return $array;
}
- return array_slice($tweets, 0, $count);
+ return array_slice($array, 0, $count);
}
/**
/**
* @return string
*/
+ public static function getListsOwnershipsUrl() {
+ return 'https://api.twitter.com/1.1/lists/ownerships.json';
+ }
+
+ /**
+ * @return string
+ */
public static function getSearchTweetsUrl() {
return 'https://api.twitter.com/1.1/search/tweets.json';
}
-<T3DataStructure>\r
- <meta>\r
- <langDisable>1</langDisable>\r
- </meta>\r
- <sheets>\r
- <main>\r
- <ROOT>\r
- <TCEforms>\r
- <sheetTitle>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.sheet_main</sheetTitle>\r
- </TCEforms>\r
- <type>array</type>\r
- <el>\r
- <settings.flexform.mode>\r
- <TCEforms>\r
- <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode</label>\r
- <onChange>reload</onChange>\r
- <config>\r
- <type>select</type>\r
- <items type="array">\r
- <numIndex index="0" type="array">\r
- <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.0</numIndex>\r
- <numIndex index="1">showOwn</numIndex>\r
- </numIndex>\r
- <!--\r
- <numIndex index="1" type="array">\r
- <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.1</numIndex>\r
- <numIndex index="1">showHome</numIndex>\r
- </numIndex>\r
- <numIndex index="2" type="array">\r
- <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.2</numIndex>\r
- <numIndex index="1">showFriends</numIndex>\r
- </numIndex>\r
- -->\r
- <numIndex index="3" type="array">\r
- <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.3</numIndex>\r
- <numIndex index="1">showFromSearch</numIndex>\r
- </numIndex>\r
- </items>\r
- <maxitems>1</maxitems>\r
- <size>1</size>\r
- </config>\r
- </TCEforms>\r
- </settings.flexform.mode>\r
- <settings.flexform.account>\r
- <TCEforms>\r
- <exclude>1</exclude>\r
- <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.account</label>\r
- <displayCond>FIELD:settings.flexform.mode:=:showOwn</displayCond>\r
- <config>\r
- <type>input</type>\r
- <size>20</size>\r
- </config>\r
- </TCEforms>\r
- </settings.flexform.account>\r
- <settings.flexform.hashtag>\r
- <TCEforms>\r
- <exclude>1</exclude>\r
- <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.hashtag</label>\r
- <displayCond>FIELD:settings.flexform.mode:=:showFromSearch</displayCond>\r
- <config>\r
- <type>input</type>\r
- <size>20</size>\r
- </config>\r
- </TCEforms>\r
- </settings.flexform.hashtag>\r
- <settings.flexform.limit>\r
- <TCEforms>\r
- <exclude>1</exclude>\r
- <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.limit</label>\r
- <config>\r
- <type>input</type>\r
- <size>4</size>\r
- </config>\r
- </TCEforms>\r
- </settings.flexform.limit>\r
- </el>\r
- </ROOT>\r
- </main>\r
- </sheets>\r
+<T3DataStructure>
+ <meta>
+ <langDisable>1</langDisable>
+ </meta>
+ <sheets>
+ <main>
+ <ROOT>
+ <TCEforms>
+ <sheetTitle>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.sheet_main</sheetTitle>
+ </TCEforms>
+ <type>array</type>
+ <el>
+ <settings.flexform.mode>
+ <TCEforms>
+ <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode</label>
+ <onChange>reload</onChange>
+ <config>
+ <type>select</type>
+ <items type="array">
+ <numIndex index="0" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.0</numIndex>
+ <numIndex index="1">showOwn</numIndex>
+ </numIndex>
+ <!--
+ <numIndex index="1" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.1</numIndex>
+ <numIndex index="1">showHome</numIndex>
+ </numIndex>
+ <numIndex index="2" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.2</numIndex>
+ <numIndex index="1">showFriends</numIndex>
+ </numIndex>
+ -->
+ <numIndex index="3" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.3</numIndex>
+ <numIndex index="1">showFromSearch</numIndex>
+ </numIndex>
+ <numIndex index="4" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.mode.4</numIndex>
+ <numIndex index="1">showListsFrom</numIndex>
+ </numIndex>
+ </items>
+ <maxitems>1</maxitems>
+ <size>1</size>
+ </config>
+ </TCEforms>
+ </settings.flexform.mode>
+ <settings.flexform.account>
+ <TCEforms>
+ <exclude>1</exclude>
+ <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.account</label>
+ <displayCond>FIELD:settings.flexform.mode:IN:showOwn,showListsFrom</displayCond>
+ <config>
+ <type>input</type>
+ <size>20</size>
+ </config>
+ </TCEforms>
+ </settings.flexform.account>
+ <settings.flexform.hashtag>
+ <TCEforms>
+ <exclude>1</exclude>
+ <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.hashtag</label>
+ <displayCond>FIELD:settings.flexform.mode:=:showFromSearch</displayCond>
+ <config>
+ <type>input</type>
+ <size>20</size>
+ </config>
+ </TCEforms>
+ </settings.flexform.hashtag>
+ <settings.flexform.orderby>
+ <TCEforms>
+ <exclude>1</exclude>
+ <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.orderby</label>
+ <displayCond>FIELD:settings.flexform.mode:IN:showListsFrom</displayCond>
+ <config>
+ <type>select</type>
+ <items type="array">
+ <numIndex index="0" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.orderby.0</numIndex>
+ <numIndex index="1">createdAt</numIndex>
+ </numIndex>
+ <numIndex index="1" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.orderby.1</numIndex>
+ <numIndex index="1">subscriberCount</numIndex>
+ </numIndex>
+ <numIndex index="2" type="array">
+ <numIndex index="0">LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.orderby.2</numIndex>
+ <numIndex index="1">memberCount</numIndex>
+ </numIndex>
+ </items>
+ <maxitems>1</maxitems>
+ <size>1</size>
+ </config>
+ </TCEforms>
+ </settings.flexform.orderby>
+ <settings.flexform.limit>
+ <TCEforms>
+ <exclude>1</exclude>
+ <label>LLL:EXT:wt_twitter/Resources/Private/Language/locallang_db.xml:pi_flexform.limit</label>
+ <config>
+ <type>input</type>
+ <size>4</size>
+ </config>
+ </TCEforms>
+ </settings.flexform.limit>
+ </el>
+ </ROOT>
+ </main>
+ </sheets>
</T3DataStructure>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>\r
+<T3locallang>\r
+ <meta type="array">\r
+ <type>database</type>\r
+ <description>Language labels for database tables/fields belonging to extension 'wt_twitter'</description>\r
+ </meta>\r
+ <data type="array">\r
+ <languageKey index="default" type="array">\r
+ <label index="members">members</label>\r
+ <label index="subscribers">subscribers</label>\r
+ </languageKey>\r
+ <languageKey index="de" type="array">\r
+ <label index="members">Mitglieder</label>\r
+ <label index="subscribers">Abonnenten</label>\r
+ </languageKey>\r
+ </data>\r
+</T3locallang>
\ No newline at end of file
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>\r
-<T3locallang>\r
- <meta type="array">\r
- <type>database</type>\r
- <description>Language labels for database tables/fields belonging to extension 'wt_twitter'</description>\r
- </meta>\r
- <data type="array">\r
- <languageKey index="default" type="array">\r
- <label index="tt_content.list_type_pi1">Show Twitter Feeds</label>\r
- <label index="pi_flexform.sheet_main">Main Settings</label>\r
- <label index="pi_flexform.account">Username</label>\r
- <label index="pi_flexform.password">Twitter Password</label>\r
- <label index="pi_flexform.mode">Mode</label>\r
- <label index="pi_flexform.mode.0">Show tweets by username</label>\r
- <label index="pi_flexform.mode.1">Show Own and Friend Tweets</label>\r
- <label index="pi_flexform.mode.2">Show Friends Tweets</label>\r
- <label index="pi_flexform.mode.3">Show Tweets from search term</label>\r
- <label index="pi_flexform.template">Path to HTML template (optional)</label>\r
- <label index="pi_flexform.limit">Limit (optional)</label>\r
- <label index="pi_flexform.hashtag">Enter a hashtag</label>\r
- </languageKey>\r
- <languageKey index="de" type="array">\r
- <label index="tt_content.list_type_pi1">Zeige Twitter Einträge</label>\r
- <label index="pi_flexform.sheet_main">Einstellungen</label>\r
- <label index="pi_flexform.account">Twitter Account</label>\r
- <label index="pi_flexform.password">Twitter Passwort</label>\r
- <label index="pi_flexform.mode">Modus</label>\r
- <label index="pi_flexform.mode.0">Zeige Tweets von einem Benutzer</label>\r
- <label index="pi_flexform.mode.1">Zeige eigene und befreundete Tweets</label>\r
- <label index="pi_flexform.mode.2">Zeige befreundete Tweets</label>\r
- <label index="pi_flexform.mode.3">Zeige Tweets anhand von Suchbegriff</label>\r
- <label index="pi_flexform.template">HTML Template Pfad (optional)</label>\r
- <label index="pi_flexform.limit">Limit (optional)</label>\r
- <label index="pi_flexform.hashtag">Suche nach Hashtag</label>\r
- </languageKey>\r
- </data>\r
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+ <meta type="array">
+ <type>database</type>
+ <description>Language labels for database tables/fields belonging to extension 'wt_twitter'</description>
+ </meta>
+ <data type="array">
+ <languageKey index="default" type="array">
+ <label index="tt_content.list_type_pi1">Show Twitter Feeds</label>
+ <label index="pi_flexform.sheet_main">Main Settings</label>
+ <label index="pi_flexform.template">Path to HTML template (optional)</label>
+ <label index="pi_flexform.account">Username</label>
+ <label index="pi_flexform.password">Twitter Password</label>
+ <label index="pi_flexform.mode">Mode</label>
+ <label index="pi_flexform.mode.0">Show tweets by username</label>
+ <label index="pi_flexform.mode.1">Show Own and Friend Tweets</label>
+ <label index="pi_flexform.mode.2">Show Friends Tweets</label>
+ <label index="pi_flexform.mode.3">Show Tweets from search term</label>
+ <label index="pi_flexform.mode.4">Show lists from username</label>
+ <label index="pi_flexform.hashtag">Enter a hashtag</label>
+ <label index="pi_flexform.orderby">Order by</label>
+ <label index="pi_flexform.orderby.0">Creation date</label>
+ <label index="pi_flexform.orderby.1">Subscriber count</label>
+ <label index="pi_flexform.orderby.2">Member count</label>
+ <label index="pi_flexform.limit">Limit (optional)</label>
+ </languageKey>
+ <languageKey index="de" type="array">
+ <label index="tt_content.list_type_pi1">Zeige Twitter Einträge</label>
+ <label index="pi_flexform.sheet_main">Einstellungen</label>
+ <label index="pi_flexform.template">HTML Template Pfad (optional)</label>
+ <label index="pi_flexform.account">Twitter Account</label>
+ <label index="pi_flexform.password">Twitter Passwort</label>
+ <label index="pi_flexform.mode">Modus</label>
+ <label index="pi_flexform.mode.0">Zeige Tweets von einem Benutzer</label>
+ <label index="pi_flexform.mode.1">Zeige eigene und befreundete Tweets</label>
+ <label index="pi_flexform.mode.2">Zeige befreundete Tweets</label>
+ <label index="pi_flexform.mode.3">Zeige Tweets anhand von Suchbegriff</label>
+ <label index="pi_flexform.mode.4">Zeige Listen von einem Benutzer</label>
+ <label index="pi_flexform.hashtag">Suche nach Hashtag</label>
+ <label index="pi_flexform.orderby">Sortieren nach</label>
+ <label index="pi_flexform.orderby.0">Erstellungsdatum</label>
+ <label index="pi_flexform.orderby.1">Anzahl der Abonnenten</label>
+ <label index="pi_flexform.orderby.2">Anzahle der Mitglieder</label>
+ <label index="pi_flexform.limit">Limit (optional)</label>
+ </languageKey>
+ </data>
</T3locallang>
\ No newline at end of file
--- /dev/null
+<f:for each="{lists}" as="list">
+ <li style="padding: 10px; min-height: 40px;">
+ <f:link.external uri="https://www.twitter.com{list.uri}" target="_blank" >{list.name}</f:link.external>
+ <f:if condition="{list.description}">
+ <f:then>
+ <br />
+ {list.description}
+ </f:then>
+ </f:if>
+ <br />
+ {list.member_count} <f:translate key="members" />
+ <br />
+ {list.subscriber_count} <f:translate key="subscribers" />
+ <div style="clear: both"></div>
+ </li>
+</f:for>
\ No newline at end of file
--- /dev/null
+<f:for each="{tweets}" as="tweet">
+ <li style="padding: 10px; min-height: 40px;">
+ <f:if condition="{tweet.from_user}">
+ <f:link.external uri="http://twitter.com/{tweet.from_user}" target="_blank">
+ <img src="{tweet.profile_image_url}" alt="{tweet.from_user}" class="wt_twitter_profile_image" style="float: left; margin-right: 10px; border: 0;" />
+ </f:link.external>
+ <f:link.external uri="http://twitter.com/{tweet.from_user}" target="_blank">{tweet.from_user}</f:link.external>
+ </f:if>
+
+ {tweet -> f:cObject(typoscriptObjectPath: 'plugin.tx_wttwitter.settings.setup.tweets.created_at', currentValueKey: 'created_at')}<br />
+
+ {tweet -> f:cObject(typoscriptObjectPath: 'plugin.tx_wttwitter.settings.setup.tweets.text', currentValueKey: 'text')}
+
+ <div style="clear: both"></div>
+ </li>
+</f:for>
\ No newline at end of file
<div id="wt_twitter_newsticker">\r
<f:flashMessages class="wt_twitter_errors" style="background-color: #FBB19B; padding: 5px 30px; font-weight: bold; border: 1px solid #DC4C42; margin-bottom: 20px; font-family: arial, verdana; color: #444; font-size: 12px;" />\r
<ul class="wttwitter_feed" style="list-style-type: none;">\r
- <f:for each="{tweets}" as="tweet">\r
- <li style="padding: 10px; min-height: 40px;">\r
- <f:if condition="{tweet.from_user}">\r
- <f:link.external uri="http://twitter.com/{tweet.from_user}" target="_blank">\r
- <img src="{tweet.profile_image_url}" alt="{tweet.from_user}" class="wt_twitter_profile_image" style="float: left; margin-right: 10px; border: 0;" />\r
- </f:link.external>\r
- <f:link.external uri="http://twitter.com/{tweet.from_user}" target="_blank">{tweet.from_user}</f:link.external>\r
- </f:if>\r
-\r
- {tweet -> f:cObject(typoscriptObjectPath: 'plugin.tx_wttwitter.settings.setup.tweets.created_at', currentValueKey: 'created_at')}<br />\r
-\r
- {tweet -> f:cObject(typoscriptObjectPath: 'plugin.tx_wttwitter.settings.setup.tweets.text', currentValueKey: 'text')}\r
-\r
- <div style="clear: both"></div>\r
- </li>\r
- </f:for>\r
+ <f:if condition="{0: settings.mode} == {0: 'showOwn'}">\r
+ <f:then>\r
+ <f:render partial="Tweets/Show" arguments="{tweets: tweets}" />\r
+ </f:then>\r
+ </f:if>\r
+ <f:if condition="{0: settings.mode} == {0: 'showFromSearch'}">\r
+ <f:then>\r
+ <f:render partial="Tweets/Show" arguments="{tweets: tweets}" />\r
+ </f:then>\r
+ </f:if>\r
+ <f:if condition="{0: settings.mode} == {0: 'showListsFrom'}">\r
+ <f:then>\r
+ <f:render partial="Lists/Show" arguments="{lists: tweets}" />\r
+ </f:then>\r
+ </f:if>\r
</ul>\r
</div>
\ No newline at end of file