bludit/bl-kernel/ajax/slug.php

29 lines
675 B
PHP
Raw 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
// slug: valid slug text
2015-05-05 03:00:01 +02:00
$text = isset($_POST['text']) ? $_POST['text'] : '';
2017-07-13 00:44:39 +02:00
$parent = isset($_POST['parent']) ? $_POST['parent'] : PARENT;
2015-05-05 03:00:01 +02:00
$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);
}
2016-09-26 04:30:06 +02:00
exit(json_encode(array(
'status'=>1,
'slug'=>$slug
)));
2015-05-05 03:00:01 +02:00
2016-01-21 02:46:13 +01:00
?>