]> git.mxchange.org Git - friendica-addons.git/blobdiff - libertree/libertree.php
[advancedcontentfilter] Move NULL_DATE to DBA::NULL_DATETIME
[friendica-addons.git] / libertree / libertree.php
index b1b7546154b6dd96c50bcfc07354039de4a52389..19512bc540206f18a2a2da06abaa638a6aca81a1 100644 (file)
@@ -5,9 +5,13 @@
  * Version: 1.0
  * Author: Tony Baldwin <https://free-haven.org/u/tony>
  */
+
+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'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/libertree/libertree.css' . '" media="all" />' . "\r\n";
+    $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->getBaseURL() . '/addon/libertree/libertree.css' . '" media="all" />' . "\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);
-
        }
 }
-