bludit/kernel/ajax/slug.php

26 lines
667 B
PHP
Raw Permalink Normal View History

2015-05-05 03:00:01 +02:00
<?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
// text: valid slug text
$text = isset($_POST['text']) ? $_POST['text'] : '';
$parent = isset($_POST['parent']) ? $_POST['parent'] : NO_PARENT_CHAR;
$key = isset($_POST['key']) ? $_POST['key'] : '';
if( $_POST['type']==='page' ) {
$slug = $dbPages->generateKey($text, $parent, true, $key);
}
elseif( $_POST['type']==='post' ) {
$slug = $dbPosts->generateKey($text, $key);
}
echo json_encode( array('slug'=>$slug) );
2015-08-03 02:49:12 +02:00
?>