diff --git a/system/admin/admin.php b/system/admin/admin.php
index a78f909..1fc36c1 100644
--- a/system/admin/admin.php
+++ b/system/admin/admin.php
@@ -1,6 +1,8 @@
' . $post_description . "\n\n" . $content;
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
-
- $newfile = $dir . '/' . $post_url . '.md';
- if ($oldfile === $newfile) {
- file_put_contents($oldfile, print_r($post_content, true));
- } else {
- rename($oldfile, $newfile);
+
+ if(!empty($revertPage)) {
+ $newfile = $dir . '/draft/' . $post_url . '.md';
+ file_put_contents($newfile, print_r($post_content, true));
+ if (empty($static)) {
+ $old = pathinfo($oldfile, PATHINFO_FILENAME);
+ if(is_dir($dir . '/' . $old)) {
+ rename($dir . '/' . $old, $dir . '/' . $post_url);
+ }
+ }
+ unlink($oldfile);
+ } elseif(!empty($publishDraft)) {
+ $newfile = dirname($dir) . '/' . $post_url . '.md';
file_put_contents($newfile, print_r($post_content, true));
if (empty($static)) {
- $path = pathinfo($oldfile);
- $old = substr($path['filename'], strrpos($path['filename'], '/'));
+ $old = pathinfo($oldfile, PATHINFO_FILENAME);
if(is_dir($dir . '/' . $old)) {
rename($dir . '/' . $old, $dir . '/' . $post_url);
}
}
+ unlink($oldfile);
+ }else {
+ $newfile = $dir . '/' . $post_url . '.md';
+ if ($oldfile === $newfile) {
+ file_put_contents($oldfile, print_r($post_content, true));
+ } else {
+ rename($oldfile, $newfile);
+ file_put_contents($newfile, print_r($post_content, true));
+ if (empty($static)) {
+ $old = pathinfo($oldfile, PATHINFO_FILENAME);
+ if(is_dir($dir . '/' . $old)) {
+ rename($dir . '/' . $old, $dir . '/' . $post_url);
+ }
+ }
+ }
}
if (!empty($static)) {
@@ -628,7 +672,12 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr
}
if ($destination == 'post') {
- header("Location: $posturl");
+ if(!empty($revertPage)) {
+ $drafturl = site_url() . 'admin/draft';
+ header("Location: $drafturl");
+ } else {
+ header("Location: $posturl");
+ }
} else {
$redirect = site_url() . $destination;
header("Location: $redirect");
@@ -639,7 +688,6 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr
// Add category
function add_category($title, $url, $content, $description = null)
{
-
$post_title = safe_html($title);
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
$description = safe_html($description);
@@ -675,7 +723,7 @@ function add_category($title, $url, $content, $description = null)
// Edit category
function edit_category($title, $url, $content, $oldfile, $destination = null, $description = null)
{
- $dir = substr($oldfile, 0, strrpos($oldfile, '/'));
+ $dir = pathinfo($oldfile, PATHINFO_DIRNAME);
$post_title = safe_html($title);
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
@@ -1154,3 +1202,106 @@ function rename_category_folder($new_name, $old_file)
}
}
+
+// Return static page.
+function find_draft_pages($static = null)
+{
+ $posts = get_draft_pages();
+
+ $tmp = array();
+
+ if (!empty($posts)) {
+
+ foreach ($posts as $index => $v) {
+ if (stripos($v['basename'], $static . '.md') !== false) {
+
+ $post = new stdClass;
+
+ // The static page URL
+ $url= $v['filename'];
+
+ $post->url = site_url() . $url;
+
+ $post->file = $v['dirname'] . '/' . $v['basename'];
+ $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
+
+ $post->md = $url;
+
+ // Get the contents and convert it to HTML
+ $content = file_get_contents($post->file);
+
+ // Extract the title and body
+ $post->title = get_content_tag('t', $content, 'Untitled static page: ' . format_date($post->lastMod, 'l, j F Y, H:i'));
+
+ // Get the contents and convert it to HTML
+ $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
+
+ if (config('views.counter') == 'true') {
+ $post->views = get_views($post->file);
+ }
+
+ $post->description = get_content_tag("d", $content, get_description($post->body));
+
+ $word_count = str_word_count(strip_tags($post->body));
+ $post->readTime = ceil($word_count / 200);
+
+ $tmp[] = $post;
+ }
+ }
+ }
+
+ return $tmp;
+}
+
+// Return static page.
+function find_draft_subpages($static = null, $sub_static = null)
+{
+ $posts = get_draft_subpages();
+
+ $tmp = array();
+
+ if (!empty($posts)) {
+
+ foreach ($posts as $index => $v) {
+ if (stripos($v['basename'], $sub_static . '.md') !== false) {
+
+ $post = new stdClass;
+
+ if (is_null($static)) {
+ $static = str_replace('content/static/', '', dirname($v['dirname']));
+ }
+
+ // The static page URL
+ $url= $v['filename'];
+ $post->url = site_url() . $static . "/" . $url;
+
+ $post->file = $v['dirname'] . '/' . $v['basename'];
+ $post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
+
+ $post->md = $url;
+
+ $post->parent = $static;
+
+ // Get the contents and convert it to HTML
+ $content = file_get_contents($post->file);
+
+ // Extract the title and body
+ $post->title = get_content_tag('t', $content, 'Untitled static subpage: ' . format_date($post->lastMod, 'l, j F Y, H:i'));
+
+ // Get the contents and convert it to HTML
+ $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
+
+ $post->views = get_views($post->file);
+
+ $post->description = get_content_tag("d", $content, get_description($post->body));
+
+ $word_count = str_word_count(strip_tags($post->body));
+ $post->readTime = ceil($word_count / 200);
+
+ $tmp[] = $post;
+ }
+ }
+ }
+
+ return $tmp;
+}
\ No newline at end of file
diff --git a/system/admin/views/add-page.html.php b/system/admin/views/add-page.html.php
index 656282a..0d74a4f 100644
--- a/system/admin/views/add-page.html.php
+++ b/system/admin/views/add-page.html.php
@@ -42,7 +42,7 @@
-
+
diff --git a/system/admin/views/delete-category.html.php b/system/admin/views/delete-category.html.php
index 01c153d..1783d32 100644
--- a/system/admin/views/delete-category.html.php
+++ b/system/admin/views/delete-category.html.php
@@ -21,8 +21,9 @@ if (isset($destination)) {
} else {
$back = site_url();
}
+$info = $p->title . ' (' . $p->file . ')';
?>
-
title);?>
+