From af0d5a61d59ba0142fc5e38b8ebad6e6a6174bbf Mon Sep 17 00:00:00 2001 From: Sanae Date: Mon, 1 Jul 2024 20:28:50 +0000 Subject: [PATCH] revert tag loading changes and update file reverting commits from c117673 to 4985f67, and ed76601 --- js/media/addedit.js | 3 +-- models/media_model.php | 8 +------- models/mediametadata_model.php | 2 +- updates/20240321.php | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/js/media/addedit.js b/js/media/addedit.js index e12f4037..b81e6577 100644 --- a/js/media/addedit.js +++ b/js/media/addedit.js @@ -582,8 +582,7 @@ OB.Media.editPage = function(ids) $.each(OB.Settings.media_metadata, function(index, metadata) { if(metadata.type=='tags') { - // TODO: Tags not currently working. - // $form.find('.metadata_'+metadata.name+'_field').val( media['metadata_'+metadata.name].split(',') ); + $form.find('.metadata_'+metadata.name+'_field').val( media['metadata_'+metadata.name].split(',') ); } else $form.find('.metadata_'+metadata.name+'_field').val( media['metadata_'+metadata.name] ); }); diff --git a/models/media_model.php b/models/media_model.php index 30a1b1c2..a0546ffa 100644 --- a/models/media_model.php +++ b/models/media_model.php @@ -260,12 +260,6 @@ public function get_init_what($args = []) $default = implode(',', $default); } - if ($metadata_field['type'] === 'tags') { - // $this->db->what('GROUP_CONCAT(media_tags.tag)', 'metadata_' . $metadata_field['name'], false); - // var_dump($metadata_field['id']); die(); - continue; - } - $this->db->what('COALESCE(media.metadata_' . $metadata_field['name'] . ',"' . $this->db->escape($default) . '")', 'metadata_' . $metadata_field['name'], false); } } @@ -281,7 +275,6 @@ public function get_init_join($args = []) $this->db->leftjoin('languages', 'media.language', 'languages.language_id'); $this->db->leftjoin('countries', 'media.country', 'countries.country_id'); $this->db->leftjoin('media_genres', 'media.genre_id', 'media_genres.id'); - //$this->db->leftjoin('media_tags', 'media_tags.media_id', 'media.id'); $this->db->leftjoin('users', 'media.owner_id', 'users.id'); } @@ -1407,6 +1400,7 @@ public function save($args = []) } } } + $metadata['metadata_' . $metadata_field['name']] = implode(',', $tags); } else { $metadata['metadata_' . $metadata_field['name']] = $item['metadata_' . $metadata_field['name']] ?? null; } diff --git a/models/mediametadata_model.php b/models/mediametadata_model.php index f6b71480..017aab73 100644 --- a/models/mediametadata_model.php +++ b/models/mediametadata_model.php @@ -236,7 +236,7 @@ public function save($data, $id) $this->db->query('ALTER TABLE ' . $this->db->format_backticks('media') . ' ADD ' . $this->db->format_backticks('metadata_' . $data['name']) . ' BOOLEAN NULL DEFAULT NULL'); } elseif ($save['type'] == 'select' || $save['type'] == 'text') { $this->db->query('ALTER TABLE ' . $this->db->format_backticks('media') . ' ADD ' . $this->db->format_backticks('metadata_' . $data['name']) . ' VARCHAR(255) NULL DEFAULT NULL'); - } elseif ($save['type'] == 'textarea') { + } elseif ($save['type'] == 'textarea' || $save['type'] == 'tags') { $this->db->query('ALTER TABLE ' . $this->db->format_backticks('media') . ' ADD ' . $this->db->format_backticks('metadata_' . $data['name']) . ' TEXT NULL DEFAULT NULL'); } elseif ($save['type'] == 'integer') { $this->db->query('ALTER TABLE ' . $this->db->format_backticks('media') . ' ADD ' . $this->db->format_backticks('metadata_' . $data['name']) . ' BIGINT NULL DEFAULT NULL'); diff --git a/updates/20240321.php b/updates/20240321.php index 3127f317..90e67b7b 100644 --- a/updates/20240321.php +++ b/updates/20240321.php @@ -35,7 +35,7 @@ public function run() $colType = 'VARCHAR(255)'; break; case 'tags': - // Tags are stored in media_tags table. + $colType = 'TEXT'; break; case 'hidden': $colType = 'LONGTEXT';