fixed ajax calls
This commit is contained in:
parent
7d196f8e16
commit
0676b0b768
|
@ -368,7 +368,7 @@ table.statistics tr:last-child td {
|
|||
#alert {
|
||||
top: 0;
|
||||
color: #ffffff;
|
||||
padding: 20px 60px;
|
||||
padding: 8px 80px;
|
||||
display: none;
|
||||
position: fixed;
|
||||
text-align: center;
|
||||
|
|
|
@ -150,6 +150,12 @@ $(document).ready(function() {
|
|||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$( "#bludit-logo" ).dblclick(function() {
|
||||
alert( "Hey! what are you doing ?" );
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Javascript -->
|
||||
<?php include(PATH_JS.'functions.php') ?>
|
||||
|
||||
|
|
|
@ -214,28 +214,28 @@ $(document).ready(function()
|
|||
var text = $(this).val();
|
||||
var parent = $("#jsparent").val();
|
||||
|
||||
checkSlugPage(text, parent, key, $("#jsslug"));
|
||||
generateSlug(text, parent, key, $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jstitle").keyup(function() {
|
||||
var text = $(this).val();
|
||||
var parent = $("#jsparent").val();
|
||||
|
||||
checkSlugPage(text, parent, key, $("#jsslug"));
|
||||
generateSlug(text, parent, key, $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jsparent").change(function() {
|
||||
var parent = $(this).val();
|
||||
var text = $("#jsslug").val();
|
||||
|
||||
if(parent==NO_PARENT_CHAR) {
|
||||
if (parent=="") {
|
||||
$("#jsparentExample").text("");
|
||||
}
|
||||
else {
|
||||
$("#jsparentExample").text(parent+"/");
|
||||
}
|
||||
|
||||
checkSlugPage(text, parent, key, $("#jsslug"));
|
||||
generateSlug(text, parent, key, $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jsdelete").click(function() {
|
||||
|
|
|
@ -193,28 +193,28 @@ $(document).ready(function()
|
|||
var text = $(this).val();
|
||||
var parent = $("#jsparent").val();
|
||||
|
||||
checkSlugPage(text, parent, "", $("#jsslug"));
|
||||
generateSlug(text, parent, "", $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jstitle").keyup(function() {
|
||||
var text = $(this).val();
|
||||
var parent = $("#jsparent").val();
|
||||
|
||||
checkSlugPage(text, parent, "", $("#jsslug"));
|
||||
generateSlug(text, parent, "", $("#jsslug"));
|
||||
});
|
||||
|
||||
$("#jsparent").change(function() {
|
||||
var parent = $(this).val();
|
||||
var text = $("#jsslug").val();
|
||||
|
||||
if(parent==NO_PARENT_CHAR) {
|
||||
if(parent=="") {
|
||||
$("#jsparentExample").text("");
|
||||
}
|
||||
else {
|
||||
$("#jsparentExample").text(parent+"/");
|
||||
}
|
||||
|
||||
checkSlugPage(text, parent, "", $("#jsslug"));
|
||||
generateSlug(text, parent, "", $("#jsslug"));
|
||||
});
|
||||
|
||||
// Button Save as draft
|
||||
|
|
|
@ -51,7 +51,7 @@ echo '
|
|||
}
|
||||
|
||||
for($i=1; $i<=Paginator::amountOfPages(); $i++) {
|
||||
echo '<li><a href='.Paginator::absoluteUrl($i).' class="page">'.$i.'</a></li>';
|
||||
echo '<li><a href="'.Paginator::absoluteUrl($i).'" class="page">'.$i.'</a></li>';
|
||||
}
|
||||
|
||||
// Show next page link
|
||||
|
|
|
@ -8,7 +8,7 @@ header('Content-Type: application/json');
|
|||
$filename = isset($_POST['filename']) ? $_POST['filename'] : '';
|
||||
|
||||
if( empty($filename) ) {
|
||||
echo json_encode( array('status'=>0, 'msg'=>'The filename is empty.') );
|
||||
echo json_encode( array('status'=>1, 'msg'=>'The filename is empty.') );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,13 @@ if( Sanitize::pathFile(PATH_UPLOADS.$filename) ) {
|
|||
// Delete the thumnails.
|
||||
Filesystem::rmfile(PATH_UPLOADS_THUMBNAILS.$filename);
|
||||
|
||||
echo json_encode( array('status'=>1, 'msg'=>'The file was deleted.') );
|
||||
echo json_encode( array('status'=>0, 'msg'=>'The file was deleted.') );
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
exit(json_encode(array(
|
||||
'status'=>0,
|
||||
'status'=>1,
|
||||
'msg'=>'The file does not exist.'
|
||||
)));
|
||||
|
||||
|
|
|
@ -1,29 +1,17 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Request $_POST
|
||||
// type: page or post.
|
||||
// text: Slug to valid.
|
||||
// parent: Page parent, if you are checking a slug for a page.
|
||||
|
||||
// Response JSON
|
||||
// slug: valid slug text
|
||||
|
||||
$text = isset($_POST['text']) ? $_POST['text'] : '';
|
||||
$parent = isset($_POST['parent']) ? $_POST['parent'] : PARENT;
|
||||
$key = isset($_POST['key']) ? $_POST['key'] : '';
|
||||
$parent = isset($_POST['parentKey']) ? $_POST['parentKey'] : PARENT;
|
||||
$oldKey = isset($_POST['currentKey']) ? $_POST['currentKey'] : '';
|
||||
|
||||
if( $_POST['type']==='page' ) {
|
||||
$slug = $dbPages->generateKey($text, $parent, true, $key);
|
||||
}
|
||||
elseif( $_POST['type']==='post' ) {
|
||||
$slug = $dbPosts->generateKey($text, $key);
|
||||
}
|
||||
$slug = $dbPages->generateKey($text, $parent, $returnSlug=true, $oldKey);
|
||||
|
||||
exit(json_encode(array(
|
||||
'status'=>1,
|
||||
exit(json_encode(
|
||||
array(
|
||||
'status'=>0,
|
||||
'slug'=>$slug
|
||||
)));
|
||||
)
|
||||
));
|
||||
|
||||
?>
|
|
@ -17,23 +17,19 @@ $layout['parameters'] = implode('/', $explodeSlug);
|
|||
|
||||
// Disable Magic Quotes.
|
||||
// Thanks, http://stackoverflow.com/questions/517008/how-to-turn-off-magic-quotes-on-shared-hosting
|
||||
if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) )
|
||||
{
|
||||
if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) ) {
|
||||
$_POST = array_map('stripslashes', $_POST);
|
||||
$_GET = array_map('stripslashes', $_GET);
|
||||
$_COOKIE = array_map('stripslashes', $_COOKIE);
|
||||
}
|
||||
|
||||
// --- AJAX ---
|
||||
if( $layout['slug']==='ajax' )
|
||||
{
|
||||
// Check if the user is loggued.
|
||||
if($Login->isLogged())
|
||||
{
|
||||
if ($layout['slug']==='ajax') {
|
||||
if ($Login->isLogged()) {
|
||||
// Rules: Security check CSRF
|
||||
include(PATH_RULES.'99.security.php');
|
||||
|
||||
// Load the ajax file.
|
||||
// Load the ajax file
|
||||
if( Sanitize::pathFile(PATH_AJAX, $layout['parameters'].'.php') ) {
|
||||
include(PATH_AJAX.$layout['parameters'].'.php');
|
||||
}
|
||||
|
|
|
@ -19,41 +19,21 @@ echo '</script>';
|
|||
|
||||
var ajaxRequest;
|
||||
|
||||
function checkSlugPage(text, parent, oldKey, writeResponse)
|
||||
{
|
||||
parent = typeof parent !== 'undefined' ? parent : PARENT;
|
||||
oldKey = typeof oldKey !== 'undefined' ? oldKey : "";
|
||||
|
||||
checkSlug("page", text, parent, oldKey, writeResponse);
|
||||
}
|
||||
|
||||
function checkSlugPost(text, oldKey, writeResponse)
|
||||
{
|
||||
checkSlug("post", text, null, oldKey, writeResponse);
|
||||
}
|
||||
|
||||
function checkSlug(type, text, parentPage, key, writeResponse)
|
||||
{
|
||||
function generateSlug(text, parentKey, currentKey, writeResponse) {
|
||||
if(ajaxRequest) {
|
||||
ajaxRequest.abort();
|
||||
}
|
||||
|
||||
if(type=="page")
|
||||
{
|
||||
ajaxRequest = $.ajax({
|
||||
type: "POST",
|
||||
data:{ tokenCSRF: tokenCSRF, type: "page", text: text, parent: parentPage, key: key},
|
||||
data: {
|
||||
tokenCSRF: tokenCSRF,
|
||||
text: text,
|
||||
parentKey: parentKey,
|
||||
currentKey: currentKey
|
||||
},
|
||||
url: "<?php echo HTML_PATH_ADMIN_ROOT.'ajax/slug' ?>"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ajaxRequest = $.ajax({
|
||||
type: "POST",
|
||||
data:{ tokenCSRF: tokenCSRF, type: "post", text: text, key: key },
|
||||
url: "<?php echo HTML_PATH_ADMIN_ROOT.'ajax/slug' ?>"
|
||||
});
|
||||
}
|
||||
|
||||
// Callback handler that will be called on success
|
||||
ajaxRequest.done(function (response, textStatus, jqXHR){
|
||||
|
|
|
@ -68,7 +68,7 @@ class pluginsimpleMDE extends Plugin {
|
|||
$html .= '<link rel="stylesheet" href="'.$pluginPath.'css/simplemde.min.css">';
|
||||
|
||||
// Font-awesome is a dependency of SimpleMDE
|
||||
$html .= '<link rel="stylesheet" href="'.HTML_PATH_ADMIN_THEME_CSS.'font-awesome.min.css">';
|
||||
$html .= '<link rel="stylesheet" href="'.HTML_PATH_CORE_CSS.'font-awesome/font-awesome.min.css">';
|
||||
|
||||
// SimpleMDE js
|
||||
$html .= '<script src="'.$pluginPath.'js/simplemde.min.js"></script>';
|
||||
|
|
Loading…
Reference in New Issue