Create symlink with the page name for images directory

This commit is contained in:
Diego Najar 2019-04-23 23:26:02 +02:00
parent aa17de9665
commit a526e71cd2
1 changed files with 10 additions and 1 deletions

View File

@ -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]);