diff options
author | Sem <sembrestels@riseup.net> | 2013-02-13 01:25:07 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2013-02-13 01:25:07 +0100 |
commit | 5aff5b3913fbb6226d8fb3162453c58888fba38d (patch) | |
tree | 2bf8fe649d8c9d09a3be03154c4c669bccfbc54c /mod/twitter | |
parent | 3ed289b03fa3d851fd7fffbc0441ebc9b5e98310 (diff) | |
parent | 8d3a7ab1755829c6e070a038d6b33e326de8fc8f (diff) | |
download | elgg-5aff5b3913fbb6226d8fb3162453c58888fba38d.tar.gz elgg-5aff5b3913fbb6226d8fb3162453c58888fba38d.tar.bz2 |
Merge tag '1.8.13' of git://github.com/Elgg/Elgg
Elgg 1.8.13 release
Diffstat (limited to 'mod/twitter')
-rw-r--r-- | mod/twitter/languages/en.php | 9 | ||||
-rw-r--r-- | mod/twitter/views/default/widgets/twitter/content.php | 39 | ||||
-rw-r--r-- | mod/twitter/views/default/widgets/twitter/edit.php | 32 |
3 files changed, 50 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..caefd369a 100644 --- a/mod/twitter/views/default/widgets/twitter/content.php +++ b/mod/twitter/views/default/widgets/twitter/content.php @@ -6,26 +6,37 @@ * @package ElggTwitter */ -//some required params - $username = $vars['entity']->twitter_username; + +if (empty($username)) { + echo "<p>" . elgg_echo("twitter:notset") . "</p>"; + return; +} + +$username_is_valid = preg_match('~^[a-zA-Z0-9_]{1,20}$~', $username); +if (!$username_is_valid) { + echo "<p>" . elgg_echo("twitter:invalid") . "</p>"; + 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; ?> - <div id="twitter_widget"> <ul id="twitter_update_list"></ul> - <p class="visit_twitter"><a href="http://twitter.com/<?php echo $username; ?>"><?php echo elgg_echo("twitter:visit"); ?></a></p> + <p class="visit_twitter"><?php echo elgg_view('output/url', array( + 'text' => elgg_echo("twitter:visit"), + 'href' => 'http://twitter.com/' . urlencode($username), + 'is_trusted' => true, + )) ?></p> <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script> - <script type="text/javascript" src="https://api.twitter.com/1/statuses/user_timeline/<?php echo $username; ?>.json?callback=twitterCallback2&count=<?php echo $num; ?>"></script> + <script type="text/javascript" src="<?php echo htmlspecialchars($script_url, ENT_QUOTES, 'UTF-8') ?>"></script> </div> - -<?php -} else { - - echo "<p>" . elgg_echo("twitter:notset") . ".</p>"; - -} diff --git a/mod/twitter/views/default/widgets/twitter/edit.php b/mod/twitter/views/default/widgets/twitter/edit.php index 5da3a7e55..c3fc6f0d5 100644 --- a/mod/twitter/views/default/widgets/twitter/edit.php +++ b/mod/twitter/views/default/widgets/twitter/edit.php @@ -1,16 +1,24 @@ <?php - /** - * Elgg twitter edit page - * - * @package ElggTwitter - */ +/** + * Elgg twitter edit page + * + * @package ElggTwitter + */ ?> - <p> - <?php echo elgg_echo("twitter:username"); ?> - <input type="text" name="params[twitter_username]" value="<?php echo htmlentities($vars['entity']->twitter_username); ?>" /> - <br /><?php echo elgg_echo("twitter:num"); ?> - <input type="text" name="params[twitter_num]" value="<?php echo htmlentities($vars['entity']->twitter_num); ?>" /> - - </p>
\ No newline at end of file +<div> + <?php echo elgg_echo("twitter:username"); ?> + <?php echo elgg_view('input/text', array( + 'name' => 'params[twitter_username]', + 'value' => $vars['entity']->twitter_username, + )) ?> +</div> +<div> + <?php echo elgg_echo("twitter:num"); ?> + <?php echo elgg_view('input/text', array( + 'name' => 'params[twitter_num]', + 'value' => $vars['entity']->twitter_num, + )) ?> + <span class="elgg-text-help"><?php echo elgg_echo("twitter:apibug"); ?></span> +</div>
\ No newline at end of file |