X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tumblr%2Ftumblr.php;h=03a67949b3ec299f439c95166a13b0d235317f7a;hb=bf2d3a835690697eafc5f6ec8fda9a0dcb34a42f;hp=deba857e5ffe34241c6ea4fee887d493242f14f3;hpb=65a26cddddec5690d0add1aa55fe23af433af041;p=friendica-addons.git diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index deba857e..03a67949 100755 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -32,7 +32,7 @@ function tumblr_jot_nets(&$a,&$b) { if(intval($tmbl_post) == 1) { $tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default'); $selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : ''); - $b .= '
' + $b .= '
' . t('Post to Tumblr') . '
'; } } @@ -166,19 +166,58 @@ function tumblr_send(&$a,&$b) { } } if(count($tag_arr)) - $tags = implode(',',$tag_arr); - + $tags = implode(',',$tag_arr); + + $link = ""; + $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( 'email' => $tmbl_username, 'password' => $tmbl_password, - 'title' => (($b['title']) ? $b['title'] : t('Post from Friendica')), - 'type' => 'regular', 'format' => 'html', 'generator' => 'Friendica', - 'tags' => $tags, - 'body' => bbcode($b['body']) - ); + 'tags' => $tags); + + if (($link != '') and $video) { + $params['type'] = "video"; + $params['embed'] = $link; + if ($title != '') + $params['caption'] = '

'.$title. + "

".bbcode($body)."

"; + else + $params['caption'] = bbcode($body); + } else if (($link != '') and !$video) { + $params['type'] = "link"; + $params['name'] = $title; + $params['url'] = $link; + //$params['description'] = bbcode($body); + $params['description'] = bbcode($b["body"]); + } else { + $params['type'] = "regular"; + $params['title'] = $title; + $params['body'] = bbcode($b['body']); + } $x = post_url($tmbl_blog,$params); $ret_code = $a->get_curl_code(); @@ -187,7 +226,7 @@ function tumblr_send(&$a,&$b) { elseif($ret_code == 403) logger('tumblr_send: authentication failure'); else - logger('tumblr_send: general error: ' . print_r($x,true)); + logger('tumblr_send: general error: ' . print_r($x,true)); } }