From a526e71cd2292936db92bb7d46dce85fb0d80705 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Tue, 23 Apr 2019 23:26:02 +0200 Subject: [PATCH] Create symlink with the page name for images directory --- bl-kernel/pages.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php index c80f657d..33a050cd 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -138,6 +138,11 @@ class Pages extends dbJSON { // Save database $this->save(); + // Create symlink for images directory + if (Filesystem::directoryExists(PATH_UPLOADS_PAGES.$row['uuid'])) { + symlink(PATH_UPLOADS_PAGES.$row['uuid'], PATH_UPLOADS_PAGES.$key); + } + return $key; } @@ -214,6 +219,10 @@ class Pages extends dbJSON { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey); return false; } + + // Regenerate the symlink to a proper directory + unlink(PATH_UPLOADS_PAGES.$key); + symlink(PATH_UPLOADS_PAGES.$row['uuid'], PATH_UPLOADS_PAGES.$newKey); } // If the content was passed via arguments replace the content @@ -280,7 +289,7 @@ class Pages extends dbJSON { } // Delete page images directory; The function already check if exists the directory - Filesystem::deleteRecursive(PATH_UPLOADS_PAGES.$this->db[$key]['uuid']); + Filesystem::deleteRecursive(PATH_UPLOADS_PAGES.$key); // Remove from database unset($this->db[$key]);