function _tweet_process in Tweet 6.2
Same name and namespace in other branches
- 5.2 tweet.module \_tweet_process()
- 6.4 tweet.module \_tweet_process()
- 6.3 tweet.module \_tweet_process()
- 7.4 tweet.module \_tweet_process()
Determines what will be in the tweet itself.
Parameters
$format: A string containing the text of the tweet before it gets processed.
$tokens: An associative array where keys represent text that will be replaced by their value in $format.
Return value
The URL-ready tweet text.
1 call to _tweet_process()
- _tweet_to_twitter in ./
tweet.module - Creates a link to post a URL and optionally title to twitter. Uses the current page by default.
File
- ./
tweet.module, line 148 - Builds links to post pages to twitter.
Code
function _tweet_process($format = '', $tokens = array()) {
if (!$format) {
$format = variable_get('tweet_format', '[url] [title]');
}
foreach ($tokens as $search => $replace) {
$format = str_ireplace($search, $replace, $format);
}
$format = drupal_urlencode($format);
//The #, &, and / characters get double-encoded by drupal_urlencode, but they must appear single-encoded for Twitter to recognize them.
//Spaces are manually encoded to plus signs for clarity of whitespace at the end of the tweet.
$format = str_replace(array(
'%2523',
'%2526',
'%252F',
'%20',
), array(
'%23',
'%26',
'%2F',
'+',
), $format);
return $format;
}