From b339fd125870bb0b084cf54b03cdacd257cc560b Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Thu, 17 Jan 2013 10:24:54 -0500 Subject: Corrects encoding and other small tweaks in Twitter widget --- mod/twitter/languages/en.php | 9 ++--- .../views/default/widgets/twitter/content.php | 41 ++++++++++++++-------- mod/twitter/views/default/widgets/twitter/edit.php | 34 +++++++++++------- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/mod/twitter/languages/en.php b/mod/twitter/languages/en.php index 29700744a..11e745ba1 100644 --- a/mod/twitter/languages/en.php +++ b/mod/twitter/languages/en.php @@ -4,13 +4,14 @@ */ $english = array( - 'twitter:title' => 'Twitter', 'twitter:info' => 'Display your latest tweets', - 'twitter:username' => 'Enter your twitter username.', - 'twitter:num' => 'The number of tweets to show.', + 'twitter:username' => 'Your twitter username', + 'twitter:num' => 'Number of tweets to show*', 'twitter:visit' => 'visit my twitter', - 'twitter:notset' => 'This Twitter widget is not yet set to go. To display your latest tweets, click on - edit - and fill in your details', + 'twitter:notset' => 'This widget needs to be configured. To display your latest tweets, click the customize icon and fill in your Twitter username.', + 'twitter:invalid' => 'This widget is configured with an invalid Twitter username. Click the customize icon to correct it.', + 'twitter:apibug' => "*Due to a bug in the Twitter 1.0 API, you may see fewer tweets than you ask for.", ); add_translation("en", $english); diff --git a/mod/twitter/views/default/widgets/twitter/content.php b/mod/twitter/views/default/widgets/twitter/content.php index c616d944c..dd741745e 100644 --- a/mod/twitter/views/default/widgets/twitter/content.php +++ b/mod/twitter/views/default/widgets/twitter/content.php @@ -6,26 +6,39 @@ * @package ElggTwitter */ -//some required params - $username = $vars['entity']->twitter_username; + +if (empty($username)) { + echo "

" . elgg_echo("twitter:notset") . "

"; + return; +} + +$username_is_valid = preg_match('~^[a-zA-Z0-9_]{1,20}$~', $username); + +if (!$username_is_valid) { + echo "

" . elgg_echo("twitter:invalid") . "

"; + return; +} + + + $num = $vars['entity']->twitter_num; +if (empty($num)) { + $num = 5; +} -// if the twitter username is empty, then do not show -if ($username) { +// @todo upgrade to 1.1 API https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline +$script_url = "https://api.twitter.com/1/statuses/user_timeline/" . urlencode($username) . ".json" + . "?callback=twitterCallback2&count=" . (int) $num; ?> -
-

+

elgg_echo("twitter:visit"), + 'href' => 'http://twitter.com/' . urlencode($username), + 'is_trusted' => true, + )) ?>

- +
- -" . elgg_echo("twitter:notset") . ".

"; - -} diff --git a/mod/twitter/views/default/widgets/twitter/edit.php b/mod/twitter/views/default/widgets/twitter/edit.php index 5da3a7e55..5dd291257 100644 --- a/mod/twitter/views/default/widgets/twitter/edit.php +++ b/mod/twitter/views/default/widgets/twitter/edit.php @@ -1,16 +1,26 @@ -

- - -
- - -

\ No newline at end of file +

+ +

+

+ + +

\ No newline at end of file -- cgit v1.2.3