X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=libertree%2Flibertree.php;h=19512bc540206f18a2a2da06abaa638a6aca81a1;hb=13f2734f42b88a477fa1aa3f8ac0cf6b2bd9c903;hp=0dd6e38ad54a282ec251f7c79ece80b51c3c5da1;hpb=c6e5bc3429c9c610895ba826d841cddd8c0f378b;p=friendica-addons.git diff --git a/libertree/libertree.php b/libertree/libertree.php index 0dd6e38a..19512bc5 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -1,13 +1,17 @@ */ + +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'); @@ -35,7 +39,7 @@ function libertree_jot_nets(&$a,&$b) { $ltree_defpost = PConfig::get(local_user(),'libertree','post_by_default'); $selected = ((intval($ltree_defpost) == 1) ? ' checked="checked" ' : ''); $b .= '
' - . t('Post to libertree') . '
'; + . L10n::t('Post to libertree') . ''; } } @@ -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 */ @@ -66,36 +70,36 @@ function libertree_settings(&$a,&$s) { /* Add some HTML to the existing form */ $s .= ''; - $s .= '

'. t('libertree Export').'

'; + $s .= '

'. L10n::t('libertree Export').'

'; $s .= '
'; $s .= ''; + $s .= '
'; } @@ -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); - } } -