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; } exit;
// update trail $database->query(sprintf("UPDATE `%spages` SET page_trail='%s' WHERE page_id='%s' LIMIT 1", CAT_TABLE_PREFIX, CAT_Helper_Page::getPageTrail($sub['page_id']), $sub['page_id'])); // Re-write the access file for this page $old_subpage_file = CAT_PATH . PAGES_DIRECTORY . $new_sub_link . PAGE_EXTENSION; // remove old file if (file_exists($old_subpage_file)) { unlink($old_subpage_file); } // create new CAT_Helper_Page::createAccessFile($new_sub_link, $sub['page_id']); } } } // check if source directory is empty now $source_dir = pathinfo(CAT_PATH . PAGES_DIRECTORY . $old_link, PATHINFO_DIRNAME); if (CAT_Helper_Directory::is_empty($source_dir, true)) { CAT_Helper_Directory::removeDirectory($source_dir); } } // ============================== // ! Check if there is a db error // ============================== if (CAT_Helper_Page::getInstance()->db()->isError()) { $ajax = array('message' => CAT_Helper_Page::getInstance()->db()->getError(), 'success' => false); print json_encode($ajax); exit; } else { $ajax = array('message' => $backend->lang()->translate('Page settings saved successfully'), 'menu_title' => htmlspecialchars_decode($options['menu_title'], ENT_QUOTES), 'page_title' => htmlspecialchars_decode($options['page_title'], ENT_QUOTES), 'visibility' => $options['visibility'], 'parent' => $options['parent'], 'position' => $options['position'], 'success' => true); print json_encode($ajax); exit; }