diff --git a/system/admin/admin.php b/system/admin/admin.php index 1fc36c1..e939ebe 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -599,6 +599,7 @@ function add_sub_page($title, $url, $content, $static, $draft, $description = nu function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination = null, $description = null, $static = null) { $dir = pathinfo($oldfile, PATHINFO_DIRNAME); + $dirDraft = $dir . '/draft/'; $views = array(); $viewsFile = "content/data/views.json"; $post_title = safe_html($title); @@ -617,9 +618,17 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $post_content = '' . $post_description . "\n\n" . $content; if (!empty($post_title) && !empty($post_url) && !empty($post_content)) { + + if (!is_dir($dir)) { + mkdir($dir, 0775, true); + } + + if (!is_dir($dirDraft)) { + mkdir($dirDraft, 0775, true); + } if(!empty($revertPage)) { - $newfile = $dir . '/draft/' . $post_url . '.md'; + $newfile = $dirDraft . $post_url . '.md'; file_put_contents($newfile, print_r($post_content, true)); if (empty($static)) { $old = pathinfo($oldfile, PATHINFO_FILENAME); @@ -1304,4 +1313,4 @@ function find_draft_subpages($static = null, $sub_static = null) } return $tmp; -} \ No newline at end of file +}