if(intval($tmbl_post) == 1) {
$tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default');
$selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
- $b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . 'value="1" /> '
+ $b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . ' value="1" /> '
. t('Post to Tumblr') . '</div>';
}
}
$tags = implode(',',$tag_arr);
$link = "";
- if ($b['title'] == '') {
- // Take the description from the bookmark
- if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches))
- $link = $matches[1];
- $b['title'] = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8');
+ $video = false;
+ $title = trim($b['title']);
+
+ // Checking for a bookmark
+ if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) {
+ $link = $matches[1];
+ if ($title == '')
+ $title = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8');
+
+ $body = $b['body'];
+ // splitting the text in two parts:
+ // before and after the bookmark
+ $pos = strpos($body, "[bookmark");
+ $body1 = substr($body, 0, $pos);
+ $body2 = substr($body, $pos);
+
+ // Removing the bookmark
+ $body2 = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'',$body2);
+ $body = $body1.$body2;
+
+ $video = ((stristr($link,'youtube')) || (stristr($link,'youtu.be')) || (stristr($mtch[1],'vimeo')));
}
$params = array(
'generator' => 'Friendica',
'tags' => $tags);
- if ($link != '') {
+ if (($link != '') and $video) {
+ $params['type'] = "video";
+ $params['embed'] = $link;
+ if ($title != '')
+ $params['caption'] = '<h1><a href="'.$link.'">'.$title.
+ "</a></h1><p>".bbcode($body)."</p>";
+ else
+ $params['caption'] = bbcode($body);
+ } else if (($link != '') and !$video) {
$params['type'] = "link";
- $params['name'] = $b['title'],
+ $params['name'] = $title;
$params['url'] = $link;
- $params['description'] = bbcode($b['body']);
+ //$params['description'] = bbcode($body);
+ $params['description'] = bbcode($b["body"]);
} else {
$params['type'] = "regular";
- $params['title'] = $b['title'],
+ $params['title'] = $title;
$params['body'] = bbcode($b['body']);
}