X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=libertree%2Flibertree.php;h=19512bc540206f18a2a2da06abaa638a6aca81a1;hb=13f2734f42b88a477fa1aa3f8ac0cf6b2bd9c903;hp=b1b7546154b6dd96c50bcfc07354039de4a52389;hpb=7ab24791667ab0ab1a04d01802e0a3ff47110c24;p=friendica-addons.git diff --git a/libertree/libertree.php b/libertree/libertree.php index b1b75461..19512bc5 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -5,9 +5,13 @@ * Version: 1.0 * Author: Tony Baldwin */ + +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Database\DBA; +use Friendica\Util\Network; function libertree_install() { Addon::registerHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local'); @@ -47,7 +51,7 @@ function libertree_settings(&$a,&$s) { /* Add our stylesheet to the page so we can make our settings look nice */ - $a->page['htmlhead'] .= '' . "\r\n"; + $a->page['htmlhead'] .= '' . "\r\n"; /* Get the current state of our config variables */ @@ -169,7 +173,7 @@ function libertree_send(&$a,&$b) { // Dont't post if the post doesn't belong to us. // This is a check for forum postings - $self = dba::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); + $self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]); if ($b['contact-id'] != $self['id']) { return; } @@ -177,14 +181,12 @@ function libertree_send(&$a,&$b) { $ltree_api_token = PConfig::get($b['uid'],'libertree','libertree_api_token'); $ltree_url = PConfig::get($b['uid'],'libertree','libertree_url'); $ltree_blog = "$ltree_url/api/v1/posts/create/?token=$ltree_api_token"; - $ltree_source = $a->get_hostname(); + $ltree_source = $a->getHostName(); if ($b['app'] != "") $ltree_source .= " (".$b['app'].")"; if($ltree_url && $ltree_api_token && $ltree_blog && $ltree_source) { - - require_once('include/bb2diaspora.php'); $tag_arr = []; $tags = ''; $x = preg_match_all('/\#\[(.*?)\](.*?)\[/',$b['tag'],$matches,PREG_SET_ORDER); @@ -216,7 +218,7 @@ function libertree_send(&$a,&$b) { } while ($oldbody != $body); // convert to markdown - $body = bb2diaspora($body, false, false); + $body = BBCode::toMarkdown($body, false); // Adding the title if(strlen($title)) @@ -229,9 +231,7 @@ function libertree_send(&$a,&$b) { // 'token' => $ltree_api_token ]; - $result = post_url($ltree_blog,$params); + $result = Network::post($ltree_blog, $params)->getBody(); logger('libertree: ' . $result); - } } -