function twitter_pull_render in Twitter Pull 7.2
Same name and namespace in other branches
- 6.2 twitter_pull.module \twitter_pull_render()
- 6 twitter_pull.module \twitter_pull_render()
- 7 twitter_pull.module \twitter_pull_render()
Retrieves appropriate tweets (by username, hashkey or search term) and passes over to the theming function with $themekey key passing tweets array along.
The rest of this module needs to make sure that corresponding theming functions exist, exist tweets array and perform desired theming.
Parameters
$twitkey: Twitter key, which can be a username (prepended with @), hashtag (prepended with #), or a search term.
$title: Title passed to the theme template.
$num_items: Number of tweets to retrieve from Twitter. Can't be more than 200.
$themekey: Theme key name to use for theming the output of Twitter API.
$lazy_load: Use javascript to retrieve the twitter results once the page is loaded.
3 calls to twitter_pull_render()
- twitter_pull_block_view in ./
twitter_pull.module - Implementation of hook_block_view()
- twitter_pull_box::render in plugins/
twitter_pull_box.inc - Implementation of boxes_box::render().
- twitter_pull_lazy in ./
twitter_pull.module - Menu callback to provide lazy loading of tweets.
File
- ./
twitter_pull.module, line 102 - Twitter Pull module.
Code
function twitter_pull_render($twitkey, $title = NULL, $num_items = NULL, $themekey = NULL, $lazy_load = FALSE, $rts = NULL, $exclude_replies = NULL) {
drupal_add_css(drupal_get_path('module', 'twitter_pull') . '/twitter-pull-listing.css');
//-- Set the lazy load id. Encode the twitkey and title to make sure the they don't contain dashes.
$lazy_id = rtrim(base64_encode($twitkey) . '-' . base64_encode($title) . '-' . (int) $num_items . '-' . $themekey, '-');
//-- Set defaults if empty arguments were passed
$title = empty($title) && $title != FALSE ? t('Related Tweets') : filter_xss($title);
$themekey = empty($themekey) ? 'twitter_pull_listing' : $themekey;
$num_items = empty($num_items) ? twitter_pull_num_items() : $num_items;
if (!$lazy_load) {
$tweets = twitter_pull_retrieve($twitkey, $num_items, $rts, $exclude_replies);
}
else {
$tweets = NULL;
$uri = url('twitter_pull_lazy/' . $lazy_id);
$id = uniqid('twitter-pull-lazy-');
$lazy_load = '<div class="throbber twitter-pull-lazy" id="' . $id . '">' . t('Loading...') . '</div>';
drupal_add_js('jQuery(document).ready(function () { jQuery.get("' . $uri . '", function(data) { jQuery("#' . $id . '").html(data).removeClass("throbber"); }); });', 'inline');
}
module_invoke_all('twitter_pull_modify', $tweets);
$ret = theme($themekey, array(
'tweets' => $tweets,
'twitkey' => $twitkey,
'title' => $title,
'lazy_load' => $lazy_load,
));
if (empty($ret) && !empty($tweets)) {
$errmsg = t("Non-empty list of tweets returned blank space after applying theme function. Most probably you are passing invalid/unregistered theme key or tpl file corresponding to the theme key does not yet exist. Please fix the problem.");
watchdog('Twitter Pull', $errmsg, array(), WATCHDOG_WARNING);
$ret = t('Errors occured while trying to retrieve tweets. Please check Watchdog log messages.');
}
return $ret;
}