Merge pull request #110 from annando/master

twitter, statusnet, gpluspost
This commit is contained in:
tobiasd 2013-03-30 01:47:52 -07:00
commit 3ba1f2f9ce
3 changed files with 26 additions and 2 deletions

View file

@ -327,6 +327,16 @@ function gpluspost_feeditem($pid, $uid) {
$link = current($links); $link = current($links);
} }
$multiplelinks = (sizeof($links) > 1); $multiplelinks = (sizeof($links) > 1);
if ($multiplelinks) {
$html2 = bbcode($msg, false, false);
$links2 = collecturls($html2);
if (sizeof($links2) > 0) {
reset($links2);
$link = current($links2);
$multiplelinks = (sizeof($links2) > 1);
}
}
} }
$msglink = ""; $msglink = "";
@ -350,8 +360,8 @@ function gpluspost_feeditem($pid, $uid) {
$title = $lines[0]; $title = $lines[0];
} }
if ($image != $msglink) //if ($image != $msglink)
$html = trim(str_replace($msglink, "", $html)); // $html = trim(str_replace($msglink, "", $html));
$title = trim(str_replace($msglink, "", $title)); $title = trim(str_replace($msglink, "", $title));
@ -360,6 +370,8 @@ function gpluspost_feeditem($pid, $uid) {
if ($uid == 0) if ($uid == 0)
$title = $item["author-name"].": ".$title; $title = $item["author-name"].": ".$title;
$msglink = htmlspecialchars(html_entity_decode($msglink));
$title = str_replace("&", "&", $title); $title = str_replace("&", "&", $title);
//$html = str_replace("&", "&", $html); //$html = str_replace("&", "&", $html);

View file

@ -498,6 +498,8 @@ function statusnet_shortenmsg($b, $max_char) {
while (strpos($msg, " ") !== false) while (strpos($msg, " ") !== false)
$msg = str_replace(" ", " ", $msg); $msg = str_replace(" ", " ", $msg);
$origmsg = $msg;
// Removing URLs // Removing URLs
$msg = preg_replace('/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', "", $msg); $msg = preg_replace('/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', "", $msg);
@ -533,6 +535,10 @@ function statusnet_shortenmsg($b, $max_char) {
if (($msglink == "") and strlen($msg) > $max_char) if (($msglink == "") and strlen($msg) > $max_char)
$msglink = $b["plink"]; $msglink = $b["plink"];
// If the message is short enough then don't modify it. (if the link exists in the original message)
if ((strlen(trim($origmsg)) <= $max_char) AND (strpos($origmsg, $msglink) OR ($msglink == "")))
return(array("msg"=>trim($origmsg), "image"=>""));
if (strlen($msglink) > 20) if (strlen($msglink) > 20)
$msglink = short_link($msglink); $msglink = short_link($msglink);

View file

@ -351,6 +351,8 @@ function twitter_shortenmsg($b) {
while (strpos($msg, " ") !== false) while (strpos($msg, " ") !== false)
$msg = str_replace(" ", " ", $msg); $msg = str_replace(" ", " ", $msg);
$origmsg = $msg;
// Removing URLs // Removing URLs
$msg = preg_replace('/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', "", $msg); $msg = preg_replace('/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', "", $msg);
@ -386,6 +388,10 @@ function twitter_shortenmsg($b) {
if (($msglink == "") and strlen($msg) > $max_char) if (($msglink == "") and strlen($msg) > $max_char)
$msglink = $b["plink"]; $msglink = $b["plink"];
// If the message is short enough then don't modify it. (if the link exists in the original message)
if ((strlen(trim($origmsg)) <= $max_char) AND (strpos($origmsg, $msglink) OR ($msglink == "")))
return(trim($origmsg));
if (strlen($msglink) > 20) if (strlen($msglink) > 20)
$msglink = short_link($msglink); $msglink = short_link($msglink);