New bootstrap-based layout #30

Merged
Roflin merged 79 commits from bootstrap into master 2023-03-14 19:11:25 +01:00
Showing only changes of commit 29bf6af1f8 - Show all commits

View File

@ -490,9 +490,7 @@ class Asset
{ {
$db = Registry::get('db'); $db = Registry::get('db');
if (!unlink(ASSETSDIR . '/' . $this->subdir . '/' . $this->filename)) // First: delete associated metadata
return false;
$db->query(' $db->query('
DELETE FROM assets_meta DELETE FROM assets_meta
WHERE id_asset = {int:id_asset}', WHERE id_asset = {int:id_asset}',
@ -500,6 +498,7 @@ class Asset
'id_asset' => $this->id_asset, 'id_asset' => $this->id_asset,
]); ]);
// Second: figure out what tags to recount cardinality for
$recount_tags = $db->queryValues(' $recount_tags = $db->queryValues('
SELECT id_tag SELECT id_tag
FROM assets_tags FROM assets_tags
@ -517,13 +516,30 @@ class Asset
Tag::recount($recount_tags); Tag::recount($recount_tags);
$return = $db->query(' // Third: figure out what associated thumbs to delete
DELETE FROM assets $thumbs_to_delete = $db->queryValues('
SELECT filename
FROM assets_thumbs
WHERE id_asset = {int:id_asset}', WHERE id_asset = {int:id_asset}',
[ [
'id_asset' => $this->id_asset, 'id_asset' => $this->id_asset,
]); ]);
foreach ($thumbs_to_delete as $filename)
{
$thumb_path = THUMBSDIR . '/' . $this->subdir . '/' . $filename;
if (is_file($thumb_path))
unlink($thumb_path);
}
$db->query('
DELETE FROM assets_thumbs
WHERE id_asset = {int:id_asset}',
[
'id_asset' => $this->id_asset,
]);
// Reset asset ID for tags that use this asset for their thumbnail
$rows = $db->query(' $rows = $db->query('
SELECT id_tag SELECT id_tag
FROM tags FROM tags
@ -541,6 +557,17 @@ class Asset
} }
} }
// Finally, delete the actual asset
if (!unlink(ASSETSDIR . '/' . $this->subdir . '/' . $this->filename))
return false;
$return = $db->query('
DELETE FROM assets
WHERE id_asset = {int:id_asset}',
[
'id_asset' => $this->id_asset,
]);
return $return; return $return;
} }