Functions for autosave type

This commit is contained in:
Diego Najar 2019-05-26 23:08:50 +02:00
parent 787538e1ca
commit ff4f166962
2 changed files with 12 additions and 3 deletions

View File

@ -289,20 +289,23 @@ class Pages extends dbJSON {
// Page doesn't exist in database // Page doesn't exist in database
if (!$this->exists($key)) { if (!$this->exists($key)) {
Log::set(__METHOD__.LOG_SEP.'The page does not exist. Key: '.$key); Log::set(__METHOD__.LOG_SEP.'The page does not exist. Key: '.$key);
return false;
} }
// Delete directory and files // Delete directory and files
if (Filesystem::deleteRecursive(PATH_PAGES.$key) === false) { if (Filesystem::deleteRecursive(PATH_PAGES.$key) === false) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the directory '.PATH_PAGES.$key); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the directory '.PATH_PAGES.$key, LOG_TYPE_ERROR);
} }
// Delete page images directory; The function already check if exists the directory // Delete page images directory; The function already check if exists the directory
Filesystem::deleteRecursive(PATH_UPLOADS_PAGES.$key); if (Filesystem::deleteRecursive(PATH_UPLOADS_PAGES.$key) === false) {
Log::set(__METHOD__.LOG_SEP.'Directory with images not found '.PATH_UPLOADS_PAGES.$key);
}
// Remove from database // Remove from database
unset($this->db[$key]); unset($this->db[$key]);
// Save the database. // Save the database
if ($this->save()===false) { if ($this->save()===false) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.'); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
} }

View File

@ -363,6 +363,12 @@ class Page {
return ($this->getValue('type')=='draft'); return ($this->getValue('type')=='draft');
} }
// (boolean) Returns TRUE if the page is autosave, FALSE otherwise
public function autosave()
{
return ($this->getValue('type')=='autosave');
}
// (boolean) Returns TRUE if the page is sticky, FALSE otherwise // (boolean) Returns TRUE if the page is sticky, FALSE otherwise
public function sticky() public function sticky()
{ {