$s .= '<label id="statusnet-default-label" for="statusnet-default">'. t('Send public postings to StatusNet by default') .'</label>';
$s .= '<input id="statusnet-default" type="checkbox" name="statusnet-default" value="1" ' . $defchecked . '/>';
$s .= '<div class="clear"></div>';
- $s .= '<label id="statusnet-sendtaglinks-label" for="statusnet-sendtaglinks">'.t('Send #tag links to StatusNet').'</label>';
+ $s .= '<label id="statusnet-sendtaglinks-label" for="statusnet-sendtaglinks">'.t('Send linked #-tags and @-names to StatusNet').'</label>';
$s .= '<input id="statusnet-sendtaglinks" type="checkbox" name="statusnet-sendtaglinks" value="1" '. $linkschecked . '/>';
$s .= '</div><div class="clear"></div>';
if($ckey && $csecret && $otoken && $osecret) {
- require_once('include/bbcode.php');
+ require_once('include/bbcode.php');
$dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
$max_char = $dent->get_maxlength(); // max. length for a dent
// we will only work with up to two times the length of the dent
- // we can later send to StatusNet. This way we can "gain" some
- // information during shortening of potential links but do not
+ // we can later send to StatusNet. This way we can "gain" some
+ // information during shortening of potential links but do not
// shorten all the links in a 200000 character long essay.
if (! $b['title']=='') {
- $tmp = $b['title'] . ' : '. $b['body'];
+ $tmp = $b['title'].": \n".$b['body'];
// $tmp = substr($tmp, 0, 4*$max_char);
} else {
$tmp = $b['body']; // substr($b['body'], 0, 3*$max_char);
// that is, don't send if the option is not set in the
// connector settings
if ($linksenabled=='0') {
- $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+ // #-tags
+ $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+ // @-mentions
+ $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ // recycle 2
+ //$recycle = html_entity_decode("♻ ", ENT_QUOTES, 'UTF-8');
+ //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
}
// preserve links to webpages
$tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
}
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
- $msg = strip_tags(bbcode($tmp));
+ //$msg = strip_tags(bbcode($tmp, false, false));
+ $msg = bbcode($tmp, false, false);
+ $msg = str_replace(array('<br>','<br />'),"\n",$msg);
+ $msg = strip_tags($msg);
+
// quotes not working - let's try this
$msg = html_entity_decode($msg);
+
if (( strlen($msg) > $max_char) && $max_char > 0) {
$shortlink = short_link( $b['plink'] );
// the new message will be shortened such that "... $shortlink"
$msg = implode(' ', $e);
$msg .= '... ' . $shortlink;
}
+
+ $msg = trim($msg);
+
// and now dent it :-)
if(strlen($msg)) {
$result = $dent->post('statuses/update', array('status' => $msg));
- logger('statusnet_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
+ logger('statusnet_post send, result: ' . print_r($result, true).
+ "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b));
if ($result->error) {
logger('Send to StatusNet failed: "' . $result->error . '"');
}