]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Term.php
Update use statement lists with new Friendica\Database\dba class
[friendica.git] / src / Model / Term.php
index 85b14174ae83fca4b0f197a033bf181d2c710c32..9f0b595014bdaf245ab6c8f4f86cdbad4b3338e9 100644 (file)
@@ -5,9 +5,8 @@
 namespace Friendica\Model;
 
 use Friendica\Core\System;
+use Friendica\Database\dba;
 use Friendica\Database\DBM;
-use Friendica\Model\Item;
-use dba;
 
 require_once 'boot.php';
 require_once 'include/conversation.php';
@@ -35,6 +34,21 @@ class Term
                return $tag_text;
        }
 
+       public static function fileTextFromItemId($itemid)
+       {
+               $file_text = '';
+               $condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]];
+               $tags = dba::select('term', [], $condition);
+               while ($tag = dba::fetch($tags)) {
+                       if ($tag['type'] == TERM_CATEGORY) {
+                               $file_text .= '<' . $tag['term'] . '>';
+                       } else {
+                               $file_text .= '[' . $tag['term'] . ']';
+                       }
+               }
+               return $file_text;
+       }
+
        public static function insertFromTagFieldByItemId($itemid, $tags)
        {
                $profile_base = System::baseUrl();
@@ -150,9 +164,9 @@ class Term
         * @param integer $itemid item id
         * @return void
         */
-       public static function insertFromFileFieldByItemId($itemid)
+       public static function insertFromFileFieldByItemId($itemid, $files)
        {
-               $message = Item::selectFirst(['uid', 'deleted', 'file'], ['id' => $itemid]);
+               $message = Item::selectFirst(['uid', 'deleted'], ['id' => $itemid]);
                if (!DBM::is_result($message)) {
                        return;
                }
@@ -164,6 +178,8 @@ class Term
                        return;
                }
 
+               $message['file'] = $files;
+
                if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
                        foreach ($files[1] as $file) {
                                dba::insert('term', [
@@ -220,7 +236,9 @@ class Term
 
                        $orig_tag = $tag["url"];
 
-                       $tag["url"] = Contact::magicLinkById($item['author-id'], $tag['url']);
+                       $author = ['uid' => 0, 'id' => $item['author-id'],
+                               'network' => $item['author-network'], 'url' => $item['author-link']];
+                       $tag["url"] = Contact::magicLinkByContact($author, $tag['url']);
 
                        if ($tag["type"] == TERM_HASHTAG) {
                                if ($orig_tag != $tag["url"]) {