function delete_page($id) { return CAT_Helper_Page::deletePage($id); }
if (!$page) { $ajax = array('message' => $backend->lang()->translate('Page not found'), 'success' => false); print json_encode($ajax); exit; } $visibility = $page['visibility']; $use_trash = false; // Check if we should delete it or just set the visibility to 'deleted' if (PAGE_TRASH !== false && $visibility != 'deleted') { $ajax_status = 1; // Page trash is enabled and page has not yet been deleted $result = CAT_Helper_Page::deletePage($page_id, true); $use_trash = true; } else { $ajax_status = 0; $result = CAT_Helper_Page::deletePage($page_id); } if (!$result) { $ajax = array('message' => $backend->lang()->translate('An error occured (using trash: {{trash}})', array('trash' => $use_trash ? $backend->lang()->translate('Yes') : $backend->lang()->translate('No'))) . ($backend->db()->isError() ? ' (DB error: ' . $backend->db()->getError() . ')' : ''), 'success' => false); print json_encode($ajax); exit; } else { // delete empty parent dir $directory = CAT_PATH . PAGES_DIRECTORY . CAT_Helper_Page::properties($page_id, 'link'); $directory = pathinfo($directory, PATHINFO_DIRNAME); if (is_dir($directory) && rtrim($directory, '/') != CAT_PATH . PAGES_DIRECTORY && CAT_Helper_Directory::is_empty($directory, true)) { CAT_Helper_Directory::removeDirectory($directory); } $ajax = array('message' => $backend->lang()->translate('Page(s) deleted successfully'), 'status' => $ajax_status, 'success' => true); print json_encode($ajax); exit;