mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 11:36:20 +05:30
Improve Autosave
This commit is contained in:
parent
017291d83d
commit
a813ed3b38
10 changed files with 308 additions and 393 deletions
214
autosave.php
214
autosave.php
|
|
@ -1,214 +0,0 @@
|
||||||
<?php
|
|
||||||
define('HTMLY', true);
|
|
||||||
require 'system/vendor/autoload.php';
|
|
||||||
|
|
||||||
if (login()) {
|
|
||||||
|
|
||||||
// Automatically Save Draft
|
|
||||||
function auto_save_page($title, $url, $content, $draft, $description = null)
|
|
||||||
{
|
|
||||||
$post_title = safe_html($title);
|
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
|
||||||
$description = safe_html($description);
|
|
||||||
if ($description !== null) {
|
|
||||||
if (!empty($description)) {
|
|
||||||
$post_description = "\n<!--d " . $description . " d-->";
|
|
||||||
} else {
|
|
||||||
$post_description = "\n<!--d " . $content . " d-->";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$post_description = "";
|
|
||||||
}
|
|
||||||
$posts = get_static_pages();
|
|
||||||
$timestamp = date('YmdHis');
|
|
||||||
foreach ($posts as $index => $v) {
|
|
||||||
if (strtolower($v['basename']) === strtolower($post_url . '.md')) {
|
|
||||||
$post_url = $post_url .'-'. $timestamp;
|
|
||||||
} else {
|
|
||||||
$post_url = $post_url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
|
||||||
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
|
||||||
|
|
||||||
$filename = $post_url . '.md';
|
|
||||||
$dir = 'content/static/';
|
|
||||||
$dirDraft = 'content/static/draft/';
|
|
||||||
|
|
||||||
if (!is_dir($dirDraft)) {
|
|
||||||
mkdir($dirDraft, 0775, true);
|
|
||||||
}
|
|
||||||
file_put_contents($dirDraft . $filename, print_r($post_content, true), LOCK_EX);
|
|
||||||
return "Auto Saved";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatically Save Draft
|
|
||||||
function auto_save_post($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null)
|
|
||||||
{
|
|
||||||
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
|
|
||||||
$tag = array_filter(array_unique($tag));
|
|
||||||
$tagslang = "content/data/tags.lang";
|
|
||||||
if (file_exists($tagslang)) {
|
|
||||||
$taglang = array_flip(unserialize(file_get_contents($tagslang)));
|
|
||||||
$tflip = array_intersect_key($taglang, array_flip($tag));
|
|
||||||
$post_tag = array();
|
|
||||||
$post_tagmd = array();
|
|
||||||
foreach ($tag as $t) {
|
|
||||||
if (array_key_exists($t, $tflip)) {
|
|
||||||
foreach ($tflip as $tfp => $tf){
|
|
||||||
if($t == $tfp) {
|
|
||||||
$post_tag[] = $tf;
|
|
||||||
$post_tagmd[] = $tfp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$post_tag[] = $t;
|
|
||||||
$post_tagmd[] = $t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_tag = safe_tag(implode(',', $post_tag));
|
|
||||||
$post_tagmd = safe_html(implode(',', $post_tagmd));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$post_tag = safe_tag(implode(',', $tag));
|
|
||||||
$post_tagmd = safe_html(implode(',', $tag));
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_date = date('Y-m-d-H-i-s', strtotime($dateTime));
|
|
||||||
$post_title = safe_html($title);
|
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
$post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($post_tag)));
|
|
||||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
|
||||||
$category = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($category)));
|
|
||||||
$description = safe_html($description);
|
|
||||||
|
|
||||||
$post_t = explode(',', $post_tag);
|
|
||||||
$pret_t = explode(',', $post_tagmd);
|
|
||||||
$tags = tag_cloud(true);
|
|
||||||
$timestamp = date('YmdHis');
|
|
||||||
|
|
||||||
$combine = array_combine($pret_t, $post_t);
|
|
||||||
$inter = array_intersect_key($tags, array_flip($post_t));
|
|
||||||
$newtag = array();
|
|
||||||
|
|
||||||
foreach ($combine as $tag => $v) {
|
|
||||||
if (array_key_exists($v, $tags)) {
|
|
||||||
foreach ($inter as $in => $i){
|
|
||||||
if($v == $in) {
|
|
||||||
if (strtolower($tag) == strtolower(tag_i18n($in))) {
|
|
||||||
$newtag[$v]= $tag;
|
|
||||||
} else {
|
|
||||||
$newtag[$v.'-'. $timestamp]= $tag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$newtag[$v] = $tag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_tag = implode(',', array_keys($newtag));
|
|
||||||
|
|
||||||
$posts = get_blog_posts();
|
|
||||||
foreach ($posts as $index => $v) {
|
|
||||||
$arr = explode('_', $v['basename']);
|
|
||||||
if (strtolower($arr[2]) === strtolower($post_url . '.md')) {
|
|
||||||
$post_url = $post_url .'-'. $timestamp;
|
|
||||||
} else {
|
|
||||||
$post_url = $post_url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($description !== null) {
|
|
||||||
if (!empty($description)) {
|
|
||||||
$post_description = "\n<!--d " . $description . " d-->";
|
|
||||||
} else {
|
|
||||||
$post_description = "\n<!--d " . get_description($content) . " d-->";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$post_description = "";
|
|
||||||
}
|
|
||||||
if ($tag !== null) {
|
|
||||||
$tagmd = "\n<!--tag " . $post_tagmd . " tag-->";
|
|
||||||
} else {
|
|
||||||
$tagmd = "";
|
|
||||||
}
|
|
||||||
if ($media!== null) {
|
|
||||||
$post_media = "\n<!--" .$type. " " . preg_replace('/\s\s+/', ' ', strip_tags($media)) . " " .$type. "-->";
|
|
||||||
} else {
|
|
||||||
$post_media = "";
|
|
||||||
}
|
|
||||||
$post_content = "<!--t " . $post_title . " t-->" . $post_description . $tagmd . $post_media . "\n\n" . $content;
|
|
||||||
|
|
||||||
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
|
||||||
|
|
||||||
$filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md';
|
|
||||||
|
|
||||||
$dir = 'content/' . $user . '/blog/' . $category. '/draft/';
|
|
||||||
|
|
||||||
if (is_dir($dir)) {
|
|
||||||
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
|
||||||
} else {
|
|
||||||
mkdir($dir, 0775, true);
|
|
||||||
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
|
||||||
}
|
|
||||||
|
|
||||||
save_tag_i18n($post_tag, $post_tagmd);
|
|
||||||
|
|
||||||
rebuilt_cache('all');
|
|
||||||
return "Auto Saved";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = $_POST['title'];
|
|
||||||
$url = $_POST['url'];
|
|
||||||
$content = $_POST['content'];
|
|
||||||
$description = $_POST['description'];
|
|
||||||
$draft = 'true';
|
|
||||||
$posttype = $_POST['posttype'];
|
|
||||||
|
|
||||||
if (!empty($content)) {
|
|
||||||
if ($posttype == 'is_page') {
|
|
||||||
$response = auto_save_page($title, $url, $content, $draft, $description);
|
|
||||||
} else {
|
|
||||||
$user = $_SESSION[site_url()]['user'];
|
|
||||||
$tag = $_POST['tag'];
|
|
||||||
$category = $_POST['category'];
|
|
||||||
$dateTime = $_POST['dateTime'];
|
|
||||||
if ($posttype == 'is_image') {
|
|
||||||
$type = 'image';
|
|
||||||
$media = $_POST['pimage'];
|
|
||||||
} elseif ($posttype == 'is_video') {
|
|
||||||
$type = 'video';
|
|
||||||
$media = $_POST['pvideo'];
|
|
||||||
} elseif ($posttype == 'is_link') {
|
|
||||||
$type = 'link';
|
|
||||||
$media = $_POST['plink'];
|
|
||||||
} elseif ($posttype == 'is_quote') {
|
|
||||||
$type = 'quote';
|
|
||||||
$media = $_POST['pquote'];
|
|
||||||
} elseif ($posttype == 'is_audio') {
|
|
||||||
$type = 'audio';
|
|
||||||
$media = $_POST['paudio'];
|
|
||||||
} elseif ($posttype == 'is_post') {
|
|
||||||
$type = 'post';
|
|
||||||
$media = null;
|
|
||||||
}
|
|
||||||
$response = auto_save_post($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$response = "No content to save.";
|
|
||||||
}
|
|
||||||
echo $response;
|
|
||||||
} else {
|
|
||||||
$login = site_url() . 'login';
|
|
||||||
header("location: $login");
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
@ -120,8 +120,11 @@ function remove_accent($str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add content
|
// Add content
|
||||||
function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null)
|
function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null, $dateTime = null, $autoSave = null)
|
||||||
{
|
{
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
$draft = 'draft';
|
||||||
|
}
|
||||||
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
|
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
|
||||||
$tag = array_filter(array_unique($tag));
|
$tag = array_filter(array_unique($tag));
|
||||||
$tagslang = "content/data/tags.lang";
|
$tagslang = "content/data/tags.lang";
|
||||||
|
|
@ -237,11 +240,23 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty
|
||||||
mkdir($dir, 0775, true);
|
mkdir($dir, 0775, true);
|
||||||
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($draft)) {
|
||||||
|
$draftFile = 'content/' . $user . '/blog/' . $category. '/draft/' . $filename;
|
||||||
|
if (file_exists($draftFile)) {
|
||||||
|
unlink($draftFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
save_tag_i18n($post_tag, $post_tagmd);
|
save_tag_i18n($post_tag, $post_tagmd);
|
||||||
|
|
||||||
rebuilt_cache('all');
|
rebuilt_cache('all');
|
||||||
|
|
||||||
clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename, $category, $type);
|
clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename, $category, $type);
|
||||||
|
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
return "Auto Saved";
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($draft)) {
|
if (empty($draft)) {
|
||||||
if (date('Y-m-d-H-i-s') >= $post_date) {
|
if (date('Y-m-d-H-i-s') >= $post_date) {
|
||||||
|
|
@ -258,7 +273,7 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit content
|
// Edit content
|
||||||
function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null)
|
function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null, $autoSave = null)
|
||||||
{
|
{
|
||||||
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
|
$tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ',')));
|
||||||
$tag = array_filter(array_unique($tag));
|
$tag = array_filter(array_unique($tag));
|
||||||
|
|
@ -449,7 +464,7 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
|
||||||
|
|
||||||
rebuilt_cache('all');
|
rebuilt_cache('all');
|
||||||
clear_post_cache($dt, $post_tag, $post_url, $oldfile, $category, $type);
|
clear_post_cache($dt, $post_tag, $post_url, $oldfile, $category, $type);
|
||||||
|
|
||||||
$old_filename = pathinfo($oldfile, PATHINFO_FILENAME);
|
$old_filename = pathinfo($oldfile, PATHINFO_FILENAME);
|
||||||
$old_ex = explode('_', $old_filename);
|
$old_ex = explode('_', $old_filename);
|
||||||
$old_url = $old_ex[2];
|
$old_url = $old_ex[2];
|
||||||
|
|
@ -465,6 +480,10 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
return "Auto Saved";
|
||||||
|
}
|
||||||
|
|
||||||
if ($destination == 'post') {
|
if ($destination == 'post') {
|
||||||
if(!empty($revertPost)) {
|
if(!empty($revertPost)) {
|
||||||
|
|
@ -498,8 +517,11 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add static page
|
// Add static page
|
||||||
function add_page($title, $url, $content, $draft, $description = null)
|
function add_page($title, $url, $content, $draft, $description = null, $autoSave = null)
|
||||||
{
|
{
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
$draft = 'draft';
|
||||||
|
}
|
||||||
$post_title = safe_html($title);
|
$post_title = safe_html($title);
|
||||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||||
$description = safe_html($description);
|
$description = safe_html($description);
|
||||||
|
|
@ -536,6 +558,10 @@ function add_page($title, $url, $content, $draft, $description = null)
|
||||||
mkdir($dir, 0775, true);
|
mkdir($dir, 0775, true);
|
||||||
}
|
}
|
||||||
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
||||||
|
$draftFile = $dirDraft . $filename;
|
||||||
|
if (file_exists($draftFile)) {
|
||||||
|
unlink($draftFile);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!is_dir($dirDraft)) {
|
if (!is_dir($dirDraft)) {
|
||||||
mkdir($dirDraft, 0775, true);
|
mkdir($dirDraft, 0775, true);
|
||||||
|
|
@ -546,6 +572,10 @@ function add_page($title, $url, $content, $draft, $description = null)
|
||||||
rebuilt_cache('all');
|
rebuilt_cache('all');
|
||||||
clear_page_cache($post_url);
|
clear_page_cache($post_url);
|
||||||
|
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
return "Auto Saved";
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($draft)) {
|
if (empty($draft)) {
|
||||||
$redirect = site_url() . 'admin/pages';
|
$redirect = site_url() . 'admin/pages';
|
||||||
header("Location: $redirect");
|
header("Location: $redirect");
|
||||||
|
|
@ -557,8 +587,11 @@ function add_page($title, $url, $content, $draft, $description = null)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add static sub page
|
// Add static sub page
|
||||||
function add_sub_page($title, $url, $content, $static, $draft, $description = null)
|
function add_sub_page($title, $url, $content, $static, $draft, $description = null, $autoSave = null)
|
||||||
{
|
{
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
$draft = 'draft';
|
||||||
|
}
|
||||||
$post = find_page($static);
|
$post = find_page($static);
|
||||||
$static = pathinfo($post['current']->md, PATHINFO_FILENAME);
|
$static = pathinfo($post['current']->md, PATHINFO_FILENAME);
|
||||||
$post_title = safe_html($title);
|
$post_title = safe_html($title);
|
||||||
|
|
@ -597,12 +630,20 @@ function add_sub_page($title, $url, $content, $static, $draft, $description = nu
|
||||||
mkdir($dir, 0775, true);
|
mkdir($dir, 0775, true);
|
||||||
}
|
}
|
||||||
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
file_put_contents($dir . $filename, print_r($post_content, true), LOCK_EX);
|
||||||
|
$draftFile = $dirDraft . $filename;
|
||||||
|
if (file_exists($draftFile)) {
|
||||||
|
unlink($draftFile);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!is_dir($dirDraft)) {
|
if (!is_dir($dirDraft)) {
|
||||||
mkdir($dirDraft, 0775, true);
|
mkdir($dirDraft, 0775, true);
|
||||||
}
|
}
|
||||||
file_put_contents($dirDraft . $filename, print_r($post_content, true), LOCK_EX);
|
file_put_contents($dirDraft . $filename, print_r($post_content, true), LOCK_EX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
return "Auto Saved";
|
||||||
|
}
|
||||||
|
|
||||||
rebuilt_cache('all');
|
rebuilt_cache('all');
|
||||||
clear_page_cache($post_url);
|
clear_page_cache($post_url);
|
||||||
|
|
@ -612,7 +653,7 @@ function add_sub_page($title, $url, $content, $static, $draft, $description = nu
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edit static page and sub page
|
// Edit static page and sub page
|
||||||
function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination = null, $description = null, $static = null)
|
function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination = null, $description = null, $static = null, $autoSave = null)
|
||||||
{
|
{
|
||||||
$dir = pathinfo($oldfile, PATHINFO_DIRNAME);
|
$dir = pathinfo($oldfile, PATHINFO_DIRNAME);
|
||||||
$fn = explode('.', pathinfo($oldfile, PATHINFO_FILENAME));
|
$fn = explode('.', pathinfo($oldfile, PATHINFO_FILENAME));
|
||||||
|
|
@ -638,7 +679,7 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
||||||
|
|
||||||
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
||||||
|
|
||||||
if(!empty($revertPage)) {
|
if(!empty($revertPage)) {
|
||||||
|
|
@ -655,7 +696,7 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlink($oldfile);
|
unlink($oldfile);
|
||||||
} elseif(!empty($publishDraft)) {
|
} elseif (!empty($publishDraft)) {
|
||||||
$newfile = dirname($dir) . '/' . $post_url . '.md';
|
$newfile = dirname($dir) . '/' . $post_url . '.md';
|
||||||
file_put_contents($newfile, print_r($post_content, true), LOCK_EX);
|
file_put_contents($newfile, print_r($post_content, true), LOCK_EX);
|
||||||
if (empty($static)) {
|
if (empty($static)) {
|
||||||
|
|
@ -665,7 +706,7 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlink($oldfile);
|
unlink($oldfile);
|
||||||
}else {
|
} else {
|
||||||
$newfile = $dir . '/' . $post_url . '.md';
|
$newfile = $dir . '/' . $post_url . '.md';
|
||||||
if ($oldfile === $newfile) {
|
if ($oldfile === $newfile) {
|
||||||
file_put_contents($oldfile, print_r($post_content, true), LOCK_EX);
|
file_put_contents($oldfile, print_r($post_content, true), LOCK_EX);
|
||||||
|
|
@ -697,7 +738,7 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
|
||||||
}
|
}
|
||||||
|
|
||||||
rebuilt_cache('all');
|
rebuilt_cache('all');
|
||||||
clear_page_cache($post_url);
|
clear_page_cache($post_url);
|
||||||
|
|
||||||
if (!empty($static)) {
|
if (!empty($static)) {
|
||||||
$posturl = site_url() . $static .'/'. $pu;
|
$posturl = site_url() . $static .'/'. $pu;
|
||||||
|
|
@ -746,6 +787,10 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($autoSave)) {
|
||||||
|
return "Auto Saved";
|
||||||
|
}
|
||||||
|
|
||||||
if ($destination == 'post') {
|
if ($destination == 'post') {
|
||||||
if(!empty($revertPage)) {
|
if(!empty($revertPage)) {
|
||||||
$drafturl = site_url() . 'admin/draft';
|
$drafturl = site_url() . 'admin/draft';
|
||||||
|
|
|
||||||
|
|
@ -151,4 +151,21 @@ pre code {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #f0f9ff;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
z-index: 999;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,6 @@ $images = image_gallery(null, 1, 40);
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Extra.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Extra.js"></script>
|
||||||
<link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/jquery-ui.css">
|
<link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/jquery-ui.css">
|
||||||
<link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/autosave.css">
|
|
||||||
<script>
|
<script>
|
||||||
$( function() {
|
$( function() {
|
||||||
var availableTags = [
|
var availableTags = [
|
||||||
|
|
@ -291,7 +290,14 @@ $( function() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Declare the base path. Important -->
|
<!-- Declare the base path. Important -->
|
||||||
<script type="text/javascript">var base_path = '<?php echo site_url() ?>'; var initial_image = '<?php echo $images;?>';</script>
|
<script type="text/javascript">
|
||||||
|
var base_path = '<?php echo site_url() ?>';
|
||||||
|
var initial_image = '<?php echo $images;?>';
|
||||||
|
var parent_page = '';
|
||||||
|
var oldfile = '';
|
||||||
|
var addEdit = 'add';
|
||||||
|
var saveInterval = 60000;
|
||||||
|
</script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -313,6 +319,6 @@ $('.img-container').on("click", ".the-img", function(e) {
|
||||||
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?php if (config('autosave.enable') == 'true' ) {
|
<?php if (config('autosave.enable') == 'true' ):?>
|
||||||
echo '<script src="'.site_url().'system/resources/js/save_draft.js"></script>';
|
<script src="<?php echo site_url();?>system/resources/js/save_draft.js"></script>
|
||||||
} ?>
|
<?php endif;?>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Extra.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Extra.js"></script>
|
||||||
<link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/jquery-ui.css">
|
<link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/jquery-ui.css">
|
||||||
<link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/autosave.css">
|
|
||||||
|
|
||||||
<?php if (isset($error)) { ?>
|
<?php if (isset($error)) { ?>
|
||||||
<div class="error-message"><?php echo $error ?></div>
|
<div class="error-message"><?php echo $error ?></div>
|
||||||
|
|
@ -27,7 +26,7 @@
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<?php if ($type == 'is_page') :?>
|
<?php if ($type == 'is_page' || $type == 'is_subpage') :?>
|
||||||
<label for="pURL"><?php echo i18n('Slug');?> (<?php echo i18n('optional');?>)</label>
|
<label for="pURL"><?php echo i18n('Slug');?> (<?php echo i18n('optional');?>)</label>
|
||||||
<input type="text" class="form-control text" id="pURL" name="url" value="<?php if (isset($postUrl)) {echo $postUrl;} ?>" placeholder="<?php echo i18n('If_the_url_is_left_empty_we_will_use_the_page_title');?>"/>
|
<input type="text" class="form-control text" id="pURL" name="url" value="<?php if (isset($postUrl)) {echo $postUrl;} ?>" placeholder="<?php echo i18n('If_the_url_is_left_empty_we_will_use_the_page_title');?>"/>
|
||||||
<br>
|
<br>
|
||||||
|
|
@ -43,7 +42,7 @@
|
||||||
<br>
|
<br>
|
||||||
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
||||||
<?php if ($type == 'is_page') :?>
|
<?php if ($type == 'is_page' || $type == 'is_subpage') :?>
|
||||||
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Publish');?>"/> <input type="submit" name="draft" class="btn btn-primary draft" value="<?php echo i18n('Save_as_draft');?>"/>
|
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Publish');?>"/> <input type="submit" name="draft" class="btn btn-primary draft" value="<?php echo i18n('Save_as_draft');?>"/>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
<?php if ($type == 'is_category') :?>
|
<?php if ($type == 'is_category') :?>
|
||||||
|
|
@ -118,7 +117,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Declare the base path. Important -->
|
<!-- Declare the base path. Important -->
|
||||||
<script type="text/javascript">var base_path = '<?php echo site_url() ?>'; var initial_image = '<?php echo $images;?>';</script>
|
<script type="text/javascript">
|
||||||
|
var base_path = '<?php echo site_url() ?>';
|
||||||
|
var initial_image = '<?php echo $images;?>';
|
||||||
|
var parent_page = '<?php echo $parent;?>';
|
||||||
|
var oldfile = '';
|
||||||
|
var addEdit = 'add';
|
||||||
|
var saveInterval = 60000;
|
||||||
|
</script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function loadImages(page) {
|
function loadImages(page) {
|
||||||
|
|
@ -139,6 +145,6 @@ $('.img-container').on("click", ".the-img", function(e) {
|
||||||
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?php if (config('autosave.enable') == 'true' ) {
|
<?php if (config('autosave.enable') == 'true' ):?>
|
||||||
echo '<script src="'.site_url().'system/resources/js/save_draft.js"></script>';
|
<script src="<?php echo site_url();?>system/resources/js/save_draft.js"></script>
|
||||||
} ?>
|
<?php endif;?>
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ $( function() {
|
||||||
<?php if (isset($error)) { ?>
|
<?php if (isset($error)) { ?>
|
||||||
<div class="error-message"><?php echo $error ?></div>
|
<div class="error-message"><?php echo $error ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<div class="notice" id="response"></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="wmd-panel" style="width:100%;">
|
<div class="wmd-panel" style="width:100%;">
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
|
@ -224,6 +224,7 @@ $( function() {
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div>
|
<div>
|
||||||
|
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||||
<label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
|
<label for="wmd-input"><?php echo i18n('Content');?> <span class="required">*</span></label>
|
||||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
||||||
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error'; } } ?>" name="content" cols="20" rows="15"><?php echo $oldcontent ?></textarea><br>
|
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error'; } } ?>" name="content" cols="20" rows="15"><?php echo $oldcontent ?></textarea><br>
|
||||||
|
|
@ -339,7 +340,14 @@ $( function() {
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Declare the base path. Important -->
|
<!-- Declare the base path. Important -->
|
||||||
<script type="text/javascript">var base_path = '<?php echo site_url() ?>'; var initial_image = '<?php echo $images;?>';</script>
|
<script type="text/javascript">
|
||||||
|
var base_path = '<?php echo site_url() ?>';
|
||||||
|
var initial_image = '<?php echo $images;?>';
|
||||||
|
var parent_page = '';
|
||||||
|
var oldfile = '<?php echo $filename;?>';
|
||||||
|
var addEdit = 'edit';
|
||||||
|
var saveInterval = 60000;
|
||||||
|
</script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -361,3 +369,8 @@ $('.img-container').on("click", ".the-img", function(e) {
|
||||||
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<?php if (config('autosave.enable') == 'true' ):?>
|
||||||
|
<?php if ($isdraft[4] == 'draft') : ?>
|
||||||
|
<script src="<?php echo site_url();?>system/resources/js/save_draft.js"></script>
|
||||||
|
<?php endif;?>
|
||||||
|
<?php endif;?>
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ $images = image_gallery(null, 1, 40);
|
||||||
<?php if (isset($error)) { ?>
|
<?php if (isset($error)) { ?>
|
||||||
<div class="error-message"><?php echo $error ?></div>
|
<div class="error-message"><?php echo $error ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<div class="notice" id="response"></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="wmd-panel" style="width:100%;">
|
<div class="wmd-panel" style="width:100%;">
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
|
|
@ -141,6 +141,7 @@ $images = image_gallery(null, 1, 40);
|
||||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
||||||
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) {if (empty($postContent)) {echo 'error';}} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea>
|
<textarea id="wmd-input" class="form-control wmd-input <?php if (isset($postContent)) {if (empty($postContent)) {echo 'error';}} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea>
|
||||||
<br>
|
<br>
|
||||||
|
<input type="hidden" id="pType" name="posttype" value="<?php echo $type; ?>">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
|
||||||
<?php if($type == 'is_frontpage' || $type == 'is_profile') { ?>
|
<?php if($type == 'is_frontpage' || $type == 'is_profile') { ?>
|
||||||
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Save');?>"/>
|
<input type="submit" name="submit" class="btn btn-primary submit" value="<?php echo i18n('Save');?>"/>
|
||||||
|
|
@ -264,7 +265,14 @@ $images = image_gallery(null, 1, 40);
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Declare the base path. Important -->
|
<!-- Declare the base path. Important -->
|
||||||
<script type="text/javascript">var base_path = '<?php echo site_url() ?>'; var initial_image = '<?php echo $images;?>';</script>
|
<script type="text/javascript">
|
||||||
|
var base_path = '<?php echo site_url() ?>';
|
||||||
|
var initial_image = '<?php echo $images;?>';
|
||||||
|
var parent_page = '<?php echo $parent;?>';
|
||||||
|
var oldfile = '<?php echo $url;?>';
|
||||||
|
var addEdit = 'edit';
|
||||||
|
var saveInterval = 60000;
|
||||||
|
</script>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||||
<?php if ($type == 'is_profile'):?>
|
<?php if ($type == 'is_profile'):?>
|
||||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
||||||
|
|
@ -288,3 +296,8 @@ $('.img-container').on("click", ".the-img", function(e) {
|
||||||
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<?php if (config('autosave.enable') == 'true' ):?>
|
||||||
|
<?php if (stripos($dir . '/', '/draft/') !== false): ?>
|
||||||
|
<script src="<?php echo site_url();?>system/resources/js/save_draft.js"></script>
|
||||||
|
<?php endif;?>
|
||||||
|
<?php endif;?>
|
||||||
|
|
|
||||||
286
system/htmly.php
286
system/htmly.php
|
|
@ -120,7 +120,7 @@ get('/index', function () {
|
||||||
// Get submitted login data
|
// Get submitted login data
|
||||||
post('/login', function () {
|
post('/login', function () {
|
||||||
|
|
||||||
$proper = (is_csrf_proper(from($_REQUEST, 'csrf_token')));
|
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||||
$captcha = config('login.protect.system');
|
$captcha = config('login.protect.system');
|
||||||
if (is_null($captcha) || $captcha === 'disabled') {
|
if (is_null($captcha) || $captcha === 'disabled') {
|
||||||
$captcha = true;
|
$captcha = true;
|
||||||
|
|
@ -714,6 +714,9 @@ post('/add/content', function () {
|
||||||
if ($date !== null && $time !== null) {
|
if ($date !== null && $time !== null) {
|
||||||
$dateTime = $date . ' ' . $time;
|
$dateTime = $date . ' ' . $time;
|
||||||
}
|
}
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($is_post) && empty($is_image) && empty($is_video) && empty($is_audio) && empty($is_link) && empty($is_quote)) {
|
if (empty($is_post) && empty($is_image) && empty($is_video) && empty($is_audio) && empty($is_link) && empty($is_quote)) {
|
||||||
$add = site_url() . 'admin/content';
|
$add = site_url() . 'admin/content';
|
||||||
|
|
@ -721,47 +724,17 @@ post('/add/content', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
||||||
if (!empty($url)) {
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null, $dateTime);
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null, $dateTime);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null, $dateTime);
|
|
||||||
}
|
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
||||||
if (!empty($url)) {
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image, $dateTime);
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image, $dateTime);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image, $dateTime);
|
|
||||||
}
|
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
||||||
if (!empty($url)) {
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video, $dateTime);
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video, $dateTime);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video, $dateTime);
|
|
||||||
}
|
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
||||||
if (!empty($url)) {
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio, $dateTime);
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio, $dateTime);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio, $dateTime);
|
|
||||||
}
|
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
||||||
if (!empty($url)) {
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote, $dateTime);
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote, $dateTime);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote, $dateTime);
|
|
||||||
}
|
|
||||||
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
} elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
||||||
if (!empty($url)) {
|
add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link, $dateTime);
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link, $dateTime);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link, $dateTime);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -876,14 +849,12 @@ post('/add/page', function () {
|
||||||
$draft = from($_REQUEST, 'draft');
|
$draft = from($_REQUEST, 'draft');
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content) && login()) {
|
if ($proper && !empty($title) && !empty($content) && login()) {
|
||||||
if (!empty($url)) {
|
add_page($title, $url, $content, $draft, $description);
|
||||||
add_page($title, $url, $content, $draft, $description);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_page($title, $url, $content, $draft, $description);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -917,6 +888,93 @@ post('/add/page', function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Autosave
|
||||||
|
post('/admin/autosave', function () {
|
||||||
|
|
||||||
|
if (login()) {
|
||||||
|
$title = $_REQUEST['title'];
|
||||||
|
$url = $_REQUEST['url'];
|
||||||
|
$content = $_REQUEST['content'];
|
||||||
|
$description = $_REQUEST['description'];
|
||||||
|
$draft = 'draft';
|
||||||
|
$posttype = $_REQUEST['posttype'];
|
||||||
|
$autoSave = $_REQUEST['autoSave'];
|
||||||
|
$addEdit = $_REQUEST['addEdit'];
|
||||||
|
$user = $_SESSION[site_url()]['user'];
|
||||||
|
$role = user('role', $user);
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($addEdit == 'edit') {
|
||||||
|
$revertPage = '';
|
||||||
|
$revertPost = '';
|
||||||
|
$publishDraft = '';
|
||||||
|
$oldfile = $_REQUEST['oldfile'];
|
||||||
|
$destination = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($title) && !empty($content)) {
|
||||||
|
if ($posttype == 'is_page') {
|
||||||
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
|
if ($addEdit == 'add') {
|
||||||
|
$response = add_page($title, $url, $content, $draft, $description, $autoSave);
|
||||||
|
} else {
|
||||||
|
$response = edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, null, $autoSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($posttype == 'is_subpage') {
|
||||||
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
|
$static = $_REQUEST['parent_page'];
|
||||||
|
if ($addEdit == 'add') {
|
||||||
|
$response = add_sub_page($title, $url, $content, $static, $draft, $description, $autoSave);
|
||||||
|
} else {
|
||||||
|
$response = edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static, $autoSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$tag = $_REQUEST['tag'];
|
||||||
|
$category = $_REQUEST['category'];
|
||||||
|
$dateTime = $_REQUEST['dateTime'];
|
||||||
|
if ($posttype == 'is_image') {
|
||||||
|
$type = 'image';
|
||||||
|
$media = $_REQUEST['pimage'];
|
||||||
|
} elseif ($posttype == 'is_video') {
|
||||||
|
$type = 'video';
|
||||||
|
$media = $_REQUEST['pvideo'];
|
||||||
|
} elseif ($posttype == 'is_link') {
|
||||||
|
$type = 'link';
|
||||||
|
$media = $_REQUEST['plink'];
|
||||||
|
} elseif ($posttype == 'is_quote') {
|
||||||
|
$type = 'quote';
|
||||||
|
$media = $_REQUEST['pquote'];
|
||||||
|
} elseif ($posttype == 'is_audio') {
|
||||||
|
$type = 'audio';
|
||||||
|
$media = $_REQUEST['paudio'];
|
||||||
|
} elseif ($posttype == 'is_post') {
|
||||||
|
$type = 'post';
|
||||||
|
$media = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($title) && !empty($tag) && !empty($content) && !empty($media)) {
|
||||||
|
if ($addEdit == 'add') {
|
||||||
|
$response = add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime, $autoSave);
|
||||||
|
} else {
|
||||||
|
$arr = explode('/', $oldfile);
|
||||||
|
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
||||||
|
$response = edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination, $description, $dateTime, $media, $autoSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$response = "No content to save.";
|
||||||
|
}
|
||||||
|
echo $response;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Show the add category
|
// Show the add category
|
||||||
get('/add/category', function () {
|
get('/add/category', function () {
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
|
|
@ -966,14 +1024,12 @@ post('/add/category', function () {
|
||||||
$description = from($_REQUEST, 'description');
|
$description = from($_REQUEST, 'description');
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
if (!empty($url)) {
|
add_category($title, $url, $content, $description);
|
||||||
add_category($title, $url, $content, $description);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_category($title, $url, $content, $description);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -1452,7 +1508,7 @@ get('/admin/pages/:static', function ($static)
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . '<a href="'. site_url() .'admin/pages">' .i18n('pages').'</a> » ' . $post->title,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . '<a href="'. site_url() .'admin/pages">' .i18n('pages').'</a> » ' . $post->title,
|
||||||
'p' => $post,
|
'p' => $post,
|
||||||
'static' => $post,
|
'static' => $post,
|
||||||
'type' => 'staticSubpage',
|
'type' => 'is_subpage',
|
||||||
'prev' => static_prev($prev),
|
'prev' => static_prev($prev),
|
||||||
'next' => static_next($next),
|
'next' => static_next($next),
|
||||||
'is_page' => true
|
'is_page' => true
|
||||||
|
|
@ -1463,7 +1519,7 @@ get('/admin/pages/:static', function ($static)
|
||||||
'description' => safe_html(strip_tags(blog_description())),
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'metatags' => generate_meta(null, null),
|
'metatags' => generate_meta(null, null),
|
||||||
'type' => 'staticSubpage',
|
'type' => 'is_subpage',
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
'bodyclass' => 'denied',
|
'bodyclass' => 'denied',
|
||||||
'breadcrumb' => '',
|
'breadcrumb' => '',
|
||||||
|
|
@ -2811,14 +2867,12 @@ post('/category/:category/edit', function () {
|
||||||
$description = from($_REQUEST, 'description');
|
$description = from($_REQUEST, 'description');
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
if (!empty($url)) {
|
edit_category($title, $url, $content, $oldfile, $destination, $description);
|
||||||
edit_category($title, $url, $content, $oldfile, $destination, $description);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
edit_category($title, $url, $content, $oldfile, $destination, $description);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -3557,44 +3611,37 @@ post('/post/:name/edit', function () {
|
||||||
} elseif (!empty($is_post)) {
|
} elseif (!empty($is_post)) {
|
||||||
$type = 'is_post';
|
$type = 'is_post';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
|
|
||||||
$arr = explode('/', $oldfile);
|
$arr = explode('/', $oldfile);
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -3931,7 +3978,7 @@ get('/:static', function ($static) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . $post->title,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . $post->title,
|
||||||
'p' => $post,
|
'p' => $post,
|
||||||
'static' => $post,
|
'static' => $post,
|
||||||
'type' => 'staticPage',
|
'type' => 'is_page',
|
||||||
'prev' => static_prev($prev),
|
'prev' => static_prev($prev),
|
||||||
'next' => static_next($next),
|
'next' => static_next($next),
|
||||||
'is_page' => true
|
'is_page' => true
|
||||||
|
|
@ -3959,7 +4006,8 @@ get('/:static/add', function ($static) {
|
||||||
'description' => safe_html(strip_tags(blog_description())),
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'metatags' => generate_meta(null, null),
|
'metatags' => generate_meta(null, null),
|
||||||
'type' => 'is_page',
|
'type' => 'is_subpage',
|
||||||
|
'parent' => $static,
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
'bodyclass' => 'add-page',
|
'bodyclass' => 'add-page',
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . i18n('Add_new_page')
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . i18n('Add_new_page')
|
||||||
|
|
@ -3996,14 +4044,12 @@ post('/:static/add', function ($static) {
|
||||||
$draft = from($_REQUEST, 'draft');
|
$draft = from($_REQUEST, 'draft');
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
if (!empty($url)) {
|
add_sub_page($title, $url, $content, $static, $draft, $description);
|
||||||
add_sub_page($title, $url, $content, $static, $draft, $description);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
add_sub_page($title, $url, $content, $static, $draft, $description);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -4025,7 +4071,7 @@ post('/:static/add', function ($static) {
|
||||||
'postTitle' => $title,
|
'postTitle' => $title,
|
||||||
'postUrl' => $url,
|
'postUrl' => $url,
|
||||||
'postContent' => $content,
|
'postContent' => $content,
|
||||||
'type' => 'is_page',
|
'type' => 'is_subpage',
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
'bodyclass' => 'add-page',
|
'bodyclass' => 'add-page',
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . $title . '">' . $title . '</a> » ' . i18n('Add_new_page')
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . $title . '">' . $title . '</a> » ' . i18n('Add_new_page')
|
||||||
|
|
@ -4067,7 +4113,8 @@ get('/:static/edit', function ($static) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="'. site_url() .'admin/pages">' .i18n('pages').'</a> » ' . $post->title,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="'. site_url() .'admin/pages">' .i18n('pages').'</a> » ' . $post->title,
|
||||||
'p' => $post,
|
'p' => $post,
|
||||||
'static' => $post,
|
'static' => $post,
|
||||||
'type' => 'staticPage',
|
'type' => 'is_page',
|
||||||
|
'parent' => ''
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
render('denied', array(
|
render('denied', array(
|
||||||
|
|
@ -4075,7 +4122,7 @@ get('/:static/edit', function ($static) {
|
||||||
'description' => safe_html(strip_tags(blog_description())),
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'metatags' => generate_meta(null, null),
|
'metatags' => generate_meta(null, null),
|
||||||
'type' => 'staticPage',
|
'type' => 'is_page',
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
'bodyclass' => 'denied',
|
'bodyclass' => 'denied',
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Denied')
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Denied')
|
||||||
|
|
@ -4104,14 +4151,12 @@ post('/:static/edit', function () {
|
||||||
$publishDraft = from($_REQUEST, 'publishdraft');
|
$publishDraft = from($_REQUEST, 'publishdraft');
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
if (!empty($url)) {
|
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description);
|
||||||
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -4137,6 +4182,8 @@ post('/:static/edit', function () {
|
||||||
'postContent' => $content,
|
'postContent' => $content,
|
||||||
'bodyclass' => 'edit-page',
|
'bodyclass' => 'edit-page',
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
|
'type' => 'is_page',
|
||||||
|
'parent' => '',
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Edit')
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Edit')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -4176,7 +4223,7 @@ get('/:static/delete', function ($static) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Delete') . ': ' . $post->title,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Delete') . ': ' . $post->title,
|
||||||
'p' => $post,
|
'p' => $post,
|
||||||
'static' => $post,
|
'static' => $post,
|
||||||
'type' => 'staticPage',
|
'type' => 'is_page',
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
render('denied', array(
|
render('denied', array(
|
||||||
|
|
@ -4300,7 +4347,7 @@ get('/:static/:sub', function ($static, $sub) {
|
||||||
'parent' => $parent_post,
|
'parent' => $parent_post,
|
||||||
'prev' => static_prev($prev),
|
'prev' => static_prev($prev),
|
||||||
'next' => static_next($next),
|
'next' => static_next($next),
|
||||||
'type' => 'subPage',
|
'type' => 'is_subpage',
|
||||||
'is_subpage' => true
|
'is_subpage' => true
|
||||||
), $layout);
|
), $layout);
|
||||||
});
|
});
|
||||||
|
|
@ -4343,7 +4390,8 @@ get('/:static/:sub/edit', function ($static, $sub) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . $page->title,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . $page->title,
|
||||||
'p' => $page,
|
'p' => $page,
|
||||||
'static' => $page,
|
'static' => $page,
|
||||||
'type' => 'subPage',
|
'type' => 'is_subpage',
|
||||||
|
'parent' => $static
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
render('denied', array(
|
render('denied', array(
|
||||||
|
|
@ -4351,7 +4399,7 @@ get('/:static/:sub/edit', function ($static, $sub) {
|
||||||
'description' => safe_html(strip_tags(blog_description())),
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'metatags' => generate_meta(null, null),
|
'metatags' => generate_meta(null, null),
|
||||||
'type' => 'subPage',
|
'type' => 'is_subpage',
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
'bodyclass' => 'denied',
|
'bodyclass' => 'denied',
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Denied')
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Denied')
|
||||||
|
|
@ -4383,14 +4431,12 @@ post('/:static/:sub/edit', function ($static, $sub) {
|
||||||
}
|
}
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
if ($role === 'editor' || $role === 'admin') {
|
if ($role === 'editor' || $role === 'admin') {
|
||||||
if ($proper && !empty($title) && !empty($content)) {
|
if ($proper && !empty($title) && !empty($content)) {
|
||||||
if (!empty($url)) {
|
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static);
|
||||||
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static);
|
|
||||||
} else {
|
|
||||||
$url = $title;
|
|
||||||
edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft, $destination, $description, $static);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$message['error'] = '';
|
$message['error'] = '';
|
||||||
if (empty($title)) {
|
if (empty($title)) {
|
||||||
|
|
@ -4416,8 +4462,10 @@ post('/:static/:sub/edit', function ($static, $sub) {
|
||||||
'postContent' => $content,
|
'postContent' => $content,
|
||||||
'static' => $static,
|
'static' => $static,
|
||||||
'sub' => $sub,
|
'sub' => $sub,
|
||||||
|
'type' => 'is_subpage',
|
||||||
'bodyclass' => 'edit-page',
|
'bodyclass' => 'edit-page',
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
|
'parent' => $static,
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Edit')
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Edit')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -4465,7 +4513,7 @@ get('/:static/:sub/delete', function ($static, $sub) {
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . $page->title,
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » <a href="' . site_url() . 'admin/pages/' . $post->slug . '">' . $post->title . '</a> » ' . $page->title,
|
||||||
'p' => $page,
|
'p' => $page,
|
||||||
'static' => $page,
|
'static' => $page,
|
||||||
'type' => 'subPage',
|
'type' => 'is_subpage',
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
render('denied', array(
|
render('denied', array(
|
||||||
|
|
@ -4473,7 +4521,7 @@ get('/:static/:sub/delete', function ($static, $sub) {
|
||||||
'description' => safe_html(strip_tags(blog_description())),
|
'description' => safe_html(strip_tags(blog_description())),
|
||||||
'canonical' => site_url(),
|
'canonical' => site_url(),
|
||||||
'metatags' => generate_meta(null, null),
|
'metatags' => generate_meta(null, null),
|
||||||
'type' => 'subPage',
|
'type' => 'is_subpage',
|
||||||
'is_admin' => true,
|
'is_admin' => true,
|
||||||
'bodyclass' => 'denied',
|
'bodyclass' => 'denied',
|
||||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Denied')
|
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Denied')
|
||||||
|
|
@ -4737,46 +4785,38 @@ post('/:year/:month/:name/edit', function () {
|
||||||
} elseif (!empty($is_post)) {
|
} elseif (!empty($is_post)) {
|
||||||
$type = 'is_post';
|
$type = 'is_post';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($url)) {
|
||||||
|
$url = $title;
|
||||||
|
}
|
||||||
|
|
||||||
$arr = explode('/', $oldfile);
|
$arr = explode('/', $oldfile);
|
||||||
$user = $_SESSION[site_url()]['user'];
|
$user = $_SESSION[site_url()]['user'];
|
||||||
$role = user('role', $user);
|
$role = user('role', $user);
|
||||||
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
if ($user === $arr[1] || $role === 'editor' || $role === 'admin') {
|
||||||
|
|
||||||
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio);
|
||||||
|
|
||||||
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
} else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) {
|
||||||
if (empty($url)) {
|
|
||||||
$url = $title;
|
|
||||||
}
|
|
||||||
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
|
edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
.notice {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 20px;
|
|
||||||
right: 20px;
|
|
||||||
padding: 10px 20px;
|
|
||||||
background-color: #f0f9ff;
|
|
||||||
border: 1px solid #e0e0e0;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
|
|
||||||
font-size: 14px;
|
|
||||||
color: #333;
|
|
||||||
z-index: 999;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
@ -16,6 +16,7 @@ function updateData() {
|
||||||
var pDate = $("#pDate").val();
|
var pDate = $("#pDate").val();
|
||||||
var pTime = $("#pTime").val();
|
var pTime = $("#pTime").val();
|
||||||
var dateTime = pDate + " " + pTime;
|
var dateTime = pDate + " " + pTime;
|
||||||
|
var autoSave = 'autoSave';
|
||||||
|
|
||||||
// Prepare data to send to PHP
|
// Prepare data to send to PHP
|
||||||
var data = {
|
var data = {
|
||||||
|
|
@ -27,31 +28,35 @@ function updateData() {
|
||||||
category: category,
|
category: category,
|
||||||
posttype: posttype,
|
posttype: posttype,
|
||||||
pimage: pimage,
|
pimage: pimage,
|
||||||
paudio: paudio,
|
paudio: paudio,
|
||||||
pvideo: pvideo,
|
pvideo: pvideo,
|
||||||
pquote: pquote,
|
pquote: pquote,
|
||||||
plink: plink,
|
plink: plink,
|
||||||
dateTime: dateTime
|
dateTime: dateTime,
|
||||||
|
autoSave: autoSave,
|
||||||
|
addEdit: addEdit,
|
||||||
|
oldfile: oldfile,
|
||||||
|
parent_page: parent_page
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_path + 'autosave.php',
|
url: base_path + 'admin/autosave',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: data,
|
data: data,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
$("#response").html(response);
|
$("#response").html(response);
|
||||||
$("#response").fadeIn(600, function() {
|
$("#response").fadeIn(600, function() {
|
||||||
$("#response").css("display", "block");
|
$("#response").css("display", "block");
|
||||||
});
|
});
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$("#response").fadeOut(600, function() {
|
$("#response").fadeOut(600, function() {
|
||||||
$("#response").css("display", "none");
|
$("#response").css("display", "none");
|
||||||
});
|
});
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
setInterval(updateData, 60000);
|
setInterval(updateData, saveInterval);
|
||||||
});
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue