Merge pull request #2106 from annando/1511-ostatus-bookmark-design
Small OStatus changes
This commit is contained in:
+20
-9
@@ -99,10 +99,19 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
|
||||
$image = "";
|
||||
}
|
||||
|
||||
if ($simplehtml == 7)
|
||||
$text = sprintf('<a href="%s" title="%s" class="attachment thumbnail" rel="nofollow external">%s</a>',
|
||||
$url, $title, $title);
|
||||
elseif (($simplehtml != 4) AND ($simplehtml != 0))
|
||||
if ($simplehtml == 7) {
|
||||
$title2 = $title;
|
||||
|
||||
$test1 = trim(html_entity_decode($match[1],ENT_QUOTES,'UTF-8'));
|
||||
$test2 = trim(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
|
||||
|
||||
// If the link description is similar to the text above then don't add the link description
|
||||
if (($title != "") AND ((strpos($test1,$test2) !== false) OR
|
||||
(similar_text($test1,$test2) / strlen($title)) > 0.9))
|
||||
$title2 = $url;
|
||||
$text = sprintf('<a href="%s" title="%s" class="attachment thumbnail" rel="nofollow external">%s</a><br />',
|
||||
$url, $title, $title2);
|
||||
} elseif (($simplehtml != 4) AND ($simplehtml != 0))
|
||||
$text = sprintf('<a href="%s" target="_blank">%s</a><br>', $url, $title);
|
||||
else {
|
||||
$text = sprintf('<span class="type-%s">', $type);
|
||||
@@ -950,11 +959,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
||||
$Text = preg_replace_callback("&\[url=/posts/([^\[\]]*)\](.*)\[\/url\]&Usi", 'bb_DiasporaLinks', $Text);
|
||||
|
||||
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
|
||||
if (!$forplaintext)
|
||||
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
|
||||
else {
|
||||
$Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text);
|
||||
$Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
|
||||
if ($simplehtml != 7) {
|
||||
if (!$forplaintext)
|
||||
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
|
||||
else {
|
||||
$Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text);
|
||||
$Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
|
||||
}
|
||||
}
|
||||
|
||||
if ($tryoembed)
|
||||
|
||||
+35
-19
@@ -4171,14 +4171,13 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
||||
);
|
||||
}
|
||||
// send email notification to owner?
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// create contact record
|
||||
|
||||
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
|
||||
`blocked`, `readonly`, `pending`, `writable` )
|
||||
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1 ) ",
|
||||
$r = q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
|
||||
`blocked`, `readonly`, `pending`, `writable`)
|
||||
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1)",
|
||||
intval($importer['uid']),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($url),
|
||||
@@ -4193,27 +4192,38 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
||||
intval($importer['uid']),
|
||||
dbesc($url)
|
||||
);
|
||||
if(count($r))
|
||||
if(count($r)) {
|
||||
$contact_record = $r[0];
|
||||
|
||||
// create notification
|
||||
$hash = random_string();
|
||||
$photos = import_profile_photo($photo,$importer["uid"],$contact_record["id"]);
|
||||
|
||||
if(is_array($contact_record)) {
|
||||
$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `hash`, `datetime`)
|
||||
VALUES ( %d, %d, 0, 0, '%s', '%s' )",
|
||||
intval($importer['uid']),
|
||||
intval($contact_record['id']),
|
||||
dbesc($hash),
|
||||
dbesc(datetime_convert())
|
||||
);
|
||||
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
intval($contact_record["id"])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($importer['uid'])
|
||||
);
|
||||
$a = get_app();
|
||||
if(count($r)) {
|
||||
if(count($r) AND !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
|
||||
// create notification
|
||||
$hash = random_string();
|
||||
|
||||
if(is_array($contact_record)) {
|
||||
$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `hash`, `datetime`)
|
||||
VALUES ( %d, %d, 0, 0, '%s', '%s' )",
|
||||
intval($importer['uid']),
|
||||
intval($contact_record['id']),
|
||||
dbesc($hash),
|
||||
dbesc(datetime_convert())
|
||||
);
|
||||
}
|
||||
|
||||
if(intval($r[0]['def_gid'])) {
|
||||
require_once('include/group.php');
|
||||
@@ -4221,7 +4231,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
||||
}
|
||||
|
||||
if(($r[0]['notify-flags'] & NOTIFY_INTRO) &&
|
||||
in_array($r[0]['page-flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
|
||||
|
||||
notification(array(
|
||||
'type' => NOTIFY_INTRO,
|
||||
@@ -4239,7 +4249,13 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
||||
));
|
||||
|
||||
}
|
||||
} elseif (count($r) AND in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
$r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
|
||||
intval($importer['uid']),
|
||||
dbesc($url)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4645,7 +4661,7 @@ function item_getfeedtags($item) {
|
||||
if($cnt) {
|
||||
for($x = 0; $x < $cnt; $x ++) {
|
||||
if($matches[1][$x])
|
||||
$ret[] = array('#',$matches[1][$x], $matches[2][$x]);
|
||||
$ret[$matches[2][$x]] = array('#',$matches[1][$x], $matches[2][$x]);
|
||||
}
|
||||
}
|
||||
$matches = false;
|
||||
|
||||
+12
-3
@@ -1201,6 +1201,14 @@ function ostatus_get_attachment($doc, $root, $item) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (($siteinfo["type"] != "photo") AND isset($siteinfo["image"])) {
|
||||
$photodata = get_photo_info($siteinfo["image"]);
|
||||
|
||||
$attributes = array("rel" => "preview", "href" => $siteinfo["image"], "media:width" => $photodata[0], "media:height" => $photodata[1]);
|
||||
xml_add_element($doc, $root, "link", "", $attributes);
|
||||
}
|
||||
|
||||
|
||||
$arr = explode('[/attach],',$item['attach']);
|
||||
if(count($arr)) {
|
||||
foreach($arr as $r) {
|
||||
@@ -1229,7 +1237,7 @@ function ostatus_add_author($doc, $owner, $profile) {
|
||||
$author = $doc->createElement("author");
|
||||
xml_add_element($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||
xml_add_element($doc, $author, "uri", $owner["url"]);
|
||||
xml_add_element($doc, $author, "name", $owner["nick"]);
|
||||
xml_add_element($doc, $author, "name", $profile["name"]);
|
||||
|
||||
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $owner["url"]);
|
||||
xml_add_element($doc, $author, "link", "", $attributes);
|
||||
@@ -1327,6 +1335,7 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
|
||||
if ($item['title'] != "")
|
||||
$body = "[b]".$item['title']."[/b]\n\n".$body;
|
||||
|
||||
//$body = bb_remove_share_information($body);
|
||||
$body = bbcode($body, false, false, 7);
|
||||
|
||||
xml_add_element($doc, $entry, "content", $body, array("type" => "html"));
|
||||
@@ -1440,7 +1449,7 @@ function ostatus_feed(&$a, $owner_nick, $last_update) {
|
||||
$root->appendChild($entry);
|
||||
}
|
||||
|
||||
return($doc->saveXML());
|
||||
return(trim($doc->saveXML()));
|
||||
}
|
||||
|
||||
function ostatus_salmon($item,$owner) {
|
||||
@@ -1452,6 +1461,6 @@ function ostatus_salmon($item,$owner) {
|
||||
|
||||
$doc->appendChild($entry);
|
||||
|
||||
return($doc->saveXML());
|
||||
return(trim($doc->saveXML()));
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user