]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Term.php
Preparation for not storing the file field into the item table.
[friendica.git] / src / Model / Term.php
index 85b14174ae83fca4b0f197a033bf181d2c710c32..bed44d6857a0f66580ddb4e8d3ee20aa0a0c9d28 100644 (file)
@@ -35,6 +35,17 @@ 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)) {
+                       $file_text .= '[' . $tag['term'] . ']';
+               }
+               return $file_text;
+       }
+
        public static function insertFromTagFieldByItemId($itemid, $tags)
        {
                $profile_base = System::baseUrl();
@@ -150,9 +161,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 +175,8 @@ class Term
                        return;
                }
 
+               $message['file'] = $files;
+
                if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
                        foreach ($files[1] as $file) {
                                dba::insert('term', [