bitbucket -> github
parent
9cfdde525f
commit
e78c32b69e
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 445 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
class RestQueryGetPost extends RestQuery
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($args){
|
||||||
|
global $core;
|
||||||
|
|
||||||
|
$explodedArgs = explode("/",$args);
|
||||||
|
$this->blog_id = $explodedArgs[0];
|
||||||
|
$post_id = $explodedArgs[2];
|
||||||
|
$post = $core->blog->getPosts(array('post_id' => $post_id));
|
||||||
|
|
||||||
|
if ($post->isEmpty()) {
|
||||||
|
$this->response_code = 404;
|
||||||
|
$this->response_message = array(
|
||||||
|
'code' => 404,
|
||||||
|
'error' => 'POST '.$post_id.' does not exists'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fieldsKeys= $post->columns();
|
||||||
|
|
||||||
|
$postArr = array();
|
||||||
|
foreach($fieldsKeys as $key){
|
||||||
|
$postArr[$key] = $post -> $key;
|
||||||
|
}
|
||||||
|
//les metas
|
||||||
|
|
||||||
|
//getMetadata($params);
|
||||||
|
$metas = array();
|
||||||
|
$rs = $core->meta->getMetadata(array('post_id' => $post_id));
|
||||||
|
//('meta_id' => $meta_id, 'meta_type' => $meta_type, 'post_id' => $post_id);
|
||||||
|
while($rs->fetch()){
|
||||||
|
$metas[] = array(
|
||||||
|
'meta_id' => $rs->meta_id,
|
||||||
|
'meta_type' => $rs->meta_type
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$postArr['metas'] = $metas;
|
||||||
|
|
||||||
|
$this -> response_message = $postArr;
|
||||||
|
$this -> response_code = 200;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
class RestQueryGetPosts extends RestQuery
|
||||||
|
{
|
||||||
|
//curl -X GET "http://dotclear.localhost/dotclear/index.php?rest/default/posts" -H "accept: application/json" -H "x_dc_key: 1zhoGXv9PA0lvPNG81GUlCNfqT45gVuV"
|
||||||
|
public function __construct($args)
|
||||||
|
{
|
||||||
|
|
||||||
|
global $core;
|
||||||
|
|
||||||
|
$explodedArgs = explode("/",$args);
|
||||||
|
$this->blog_id = $explodedArgs[0];
|
||||||
|
$this->required_perms = 'unauth'; //les niveaux d'acces aux contenus sont
|
||||||
|
//gérés dans la function $core->blog->getPosts($params)
|
||||||
|
|
||||||
|
if($core->auth === false){
|
||||||
|
$core->auth = new restAuth($core); //class dcBlog need it
|
||||||
|
$unauth = true;
|
||||||
|
}
|
||||||
|
$core->blog = new dcBlog($core, $this->blog_id);
|
||||||
|
$blog_settings = new dcSettings($core,$this->blog_id);
|
||||||
|
|
||||||
|
if($this->is_allowed() === false){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$params['where'] = '';
|
||||||
|
if((isset($_GET['limit-start'])) && (isset($_GET['limit-count']))){
|
||||||
|
$params['limit'] = array($_GET['limit-start'],$_GET['limit-count']);
|
||||||
|
}elseif((isset($_GET['limit-start'])) xor (isset($_GET['limit-count']))){
|
||||||
|
$this->response_code = 400;
|
||||||
|
$this->response_message = array(
|
||||||
|
'code' => 400,
|
||||||
|
'message' => 'If you set limits both of limit-start and limit-cout must be setted'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['cat_id'])){
|
||||||
|
$params['cat_id'] = $_GET['cat_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['post_status'])){
|
||||||
|
$params['post_status'] = $_GET['post_status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['password'])){
|
||||||
|
$params['where'] .= ' AND post_password IS '.($_GET['password'] ? 'NOT ' : '').'NULL ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['post_selected'])){
|
||||||
|
$params['post_selected'] = $_GET['post_selected']; //to do, vérifier, si c'est pris correctement comment un boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['post_open_comment'])){
|
||||||
|
$params['where'] .= " AND post_open_comment = '".$_GET['post_open_comment']."' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['post_open_tb'])){
|
||||||
|
$params['where'] .= " AND post_open_tb = '".$_GET['post_open_tb']."' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
//date
|
||||||
|
if((isset($_GET['post_month'])) && (isset ($_GET['post_year']))){
|
||||||
|
$params['post_month'] = $_GET['post_month'];
|
||||||
|
$params['post_year'] = $_GET['post_year'];
|
||||||
|
}elseif((isset($_GET['post_month'])) xor (isset ($_GET['post_year']))){
|
||||||
|
$this -> response_code = 400;
|
||||||
|
$this -> response_message = array(
|
||||||
|
'code' => 400,
|
||||||
|
'message' => 'If you set date parameters both of post_month and post_year must be setted'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['format'])){
|
||||||
|
$params['where'] .= " AND post_format = '".$_GET['format']."' ";
|
||||||
|
}
|
||||||
|
if(isset($_GET['sortby'])){
|
||||||
|
$params['order'] = $_GET['sortby'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$rs = $core->blog->getPosts($params);
|
||||||
|
|
||||||
|
$fieldsKeys= $rs->columns();
|
||||||
|
$response = array();
|
||||||
|
while ($rs->fetch()) {
|
||||||
|
$post = array();
|
||||||
|
foreach($fieldsKeys as $key){
|
||||||
|
$post[$key] = $rs->$key;
|
||||||
|
}
|
||||||
|
$response[] = $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this -> response_code = 200;
|
||||||
|
$this -> response_message = $response;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
class RestQueryGetPostsById extends RestQuery
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
class RestQueryPostCategories extends RestQuery
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IN $params array with keys
|
||||||
|
* OUT integer, the new category id
|
||||||
|
*/
|
||||||
|
public function createCategory($params){
|
||||||
|
global $core;
|
||||||
|
if(!isset($params['cat_title'])){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$cur = $core->con->openCursor($core->prefix.'category');
|
||||||
|
$cur->cat_title = $params['cat_title'];
|
||||||
|
if (isset($params['cat_desc'])) {
|
||||||
|
$cur->cat_desc = $params['cat_desc'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($params['cat_url'])) {
|
||||||
|
$cur->cat_url = $params['cat_url'];
|
||||||
|
}else{
|
||||||
|
$cur->cat_url = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($params['cat_parent_id'])){
|
||||||
|
$cat_parent_id = $params['cat_parent_id'];
|
||||||
|
}else{
|
||||||
|
$cat_parent_id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
# --BEHAVIOR-- adminBeforeCategoryCreate
|
||||||
|
$core->callBehavior('adminBeforeCategoryCreate',$cur);
|
||||||
|
|
||||||
|
$id = $core->blog->addCategory($cur,(integer)$cat_parent_id);
|
||||||
|
|
||||||
|
# --BEHAVIOR-- adminAfterCategoryCreate
|
||||||
|
$core->callBehavior('adminAfterCategoryCreate',$cur,$id);
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
}catch (Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public function __construct($args,$body){
|
||||||
|
|
||||||
|
global $core;
|
||||||
|
$explodedArgs = explode("/",$args);
|
||||||
|
$this->blog_id = $explodedArgs[0];
|
||||||
|
$this->required_perms = 'none'; //To do
|
||||||
|
|
||||||
|
if($core->auth === false){
|
||||||
|
$core->auth = new restAuth($core); //class dcBlog need it
|
||||||
|
$unauth = true;
|
||||||
|
}
|
||||||
|
$core->blog = new dcBlog($core, $this->blog_id);
|
||||||
|
$blog_settings = new dcSettings($core,$this->blog_id);
|
||||||
|
|
||||||
|
if($this->is_allowed() === false){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$clientQueryArr = json_decode($body, true);
|
||||||
|
if(empty($clientQueryArr)){
|
||||||
|
$this->response_code = 400;
|
||||||
|
$this->response_message = array(
|
||||||
|
'error' => 'Can\'t parse input JSON'.$body,
|
||||||
|
'code' => 400
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$this->check_for_required_fields(
|
||||||
|
$clientQueryArr,
|
||||||
|
array('cat_title'), //required fields
|
||||||
|
array('cat_url','cat_desc','cat_parent_id','cat_position','temporary') //facultatives fields
|
||||||
|
)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->createCategory($clientQueryArr);
|
||||||
|
|
||||||
|
if($id === false){
|
||||||
|
$this->response_code = 500;
|
||||||
|
$this->response_message = array(
|
||||||
|
"error" => "Something is wrong",
|
||||||
|
"code" => 500
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$this->response_code = 200;
|
||||||
|
$this->response_message = array(
|
||||||
|
"message" => "Successfully create category",
|
||||||
|
"id" => $id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
*Methode permettant de créer des métas (dont les tags)
|
||||||
|
*/
|
||||||
|
class RestQueryPostMetas extends RestQuery
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a meta
|
||||||
|
* if already exists, do nothing, does not generate warnings
|
||||||
|
*/
|
||||||
|
public function add_meta($meta_id,$meta_type,$post_id){
|
||||||
|
global $core;
|
||||||
|
//check if meta already exists
|
||||||
|
$params = array('meta_id' => $meta_id, 'meta_type' => $meta_type, 'post_id' => $post_id);
|
||||||
|
|
||||||
|
$rs = $core->meta->getMetadata($params, false);
|
||||||
|
if($rs->fetch()){
|
||||||
|
return $rs->meta_id; //the meta already exists
|
||||||
|
}elseif($core->meta->setPostMeta($post_id,$meta_type,$meta_id) === false){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return $meta_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __construct($args,$body)
|
||||||
|
{
|
||||||
|
global $core;
|
||||||
|
$explodedArgs = explode("/",$args);
|
||||||
|
$this->blog_id = $explodedArgs[0];
|
||||||
|
$this->required_perms = 'none'; //To do
|
||||||
|
|
||||||
|
if($core->auth === false){
|
||||||
|
$core->auth = new restAuth($core);
|
||||||
|
$unauth = true;
|
||||||
|
}
|
||||||
|
$core->blog = new dcBlog($core, $this->blog_id);
|
||||||
|
$blog_settings = new dcSettings($core,$this->blog_id);
|
||||||
|
|
||||||
|
if($this->is_allowed() === false){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$clientQueryArr = json_decode($body, true);
|
||||||
|
|
||||||
|
$createdIds = array();
|
||||||
|
$clientQueryArr = $this->arrayOfObjetsOrNot($clientQueryArr,'meta_id');
|
||||||
|
foreach($clientQueryArr as $query){
|
||||||
|
|
||||||
|
//check for needed fields
|
||||||
|
if(!$this->check_for_required_fields($query,
|
||||||
|
array('meta_id','meta_type','post_id'), //required fields
|
||||||
|
array() //facultatives fields
|
||||||
|
)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this -> add_meta($query['meta_id'],$query['meta_type'],$query['post_id']);
|
||||||
|
|
||||||
|
if($id === false){
|
||||||
|
$this->response_code = 500;
|
||||||
|
$this->response_message = array("code" => 500,
|
||||||
|
"message" => "An error occured while setting meta ".$query['meta_id']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$createdIds[] = $id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response_code = 201;
|
||||||
|
if(count($createdIds) == 1){
|
||||||
|
$this->response_message = array(
|
||||||
|
"code" => 200,
|
||||||
|
"message" => "Successfully insert meta",
|
||||||
|
"id" => $createdIds[0]
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$this->response_message = array(
|
||||||
|
"code" => 200,
|
||||||
|
"message" => "Successfully insert metas",
|
||||||
|
"id" => $createdIds
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,205 @@
|
|||||||
|
<?php
|
||||||
|
class RestQueryPostPost extends RestQuery{
|
||||||
|
public function __construct($args,$body){
|
||||||
|
global $core;
|
||||||
|
$explodedArgs = explode("/",$args);
|
||||||
|
$this->blog_id = $explodedArgs[0];
|
||||||
|
$this->required_perms = 'none'; //To do
|
||||||
|
|
||||||
|
if($core->auth === false){
|
||||||
|
$core->auth = new restAuth($core); //class dcBlog need it
|
||||||
|
$unauth = true;
|
||||||
|
}
|
||||||
|
$core->blog = new dcBlog($core, $this->blog_id);
|
||||||
|
$blog_settings = new dcSettings($core,$this->blog_id);
|
||||||
|
|
||||||
|
if($this->is_allowed() === false){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$clientQueryArr = json_decode($body, true);
|
||||||
|
if(empty($clientQueryArr)){
|
||||||
|
$this->response_code = 400;
|
||||||
|
$this->response_message = array(
|
||||||
|
'error' => 'Can\'t parse input JSON'.$body,
|
||||||
|
'code' => 400
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//tester si plusieurs posts
|
||||||
|
$allPosts = $this->arrayOfObjetsOrNot($clientQueryArr,'post_title');
|
||||||
|
|
||||||
|
//is it valid fields?
|
||||||
|
foreach($allPosts as $p){
|
||||||
|
if(!$this->check_for_required_fields(
|
||||||
|
$p,
|
||||||
|
array('post_title','post_format','post_content','post_status'), //required fields
|
||||||
|
array('cat_id','new_cat_id','new_cat_parent','post_dt','post_password',
|
||||||
|
'post_lang','post_excerpt','post_excerpt_xhtml','post_content_xhtml',
|
||||||
|
'post_notes','post_selected','post_open_comment','post_open_tb','post_url','post_tags') //facultatives fields
|
||||||
|
)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$createdIds = array();
|
||||||
|
//end of checks; lets submit new posts
|
||||||
|
foreach($allPosts as $p){
|
||||||
|
|
||||||
|
//gestion de la categorie
|
||||||
|
if(isset($p['new_cat_id'])){
|
||||||
|
$params = array();
|
||||||
|
$params['cat_title'] = $p['new_cat_id'];
|
||||||
|
if(isset($p['new_cat_parent_id']))
|
||||||
|
$params['cat_parent_id'] = $p['new_cat_parent_id'];
|
||||||
|
if(isset($p['new_cat_url']))
|
||||||
|
$params['cat_url'] = $p['new_cat_url'];
|
||||||
|
if(isset($p['new_cat_desc']))
|
||||||
|
$params['cat_desc'] = $p['new_cat_desc'];
|
||||||
|
|
||||||
|
$cat_id = RestQueryPostCategories::createCategory($params);
|
||||||
|
|
||||||
|
if($cat_id === false){
|
||||||
|
$this->response_message = 400;
|
||||||
|
$this->response_message = array(
|
||||||
|
"error" => "ERROR when creating the new category.",
|
||||||
|
"code" => 400
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}elseif(isset($p['cat_id'])){
|
||||||
|
$cat_id = $core->con->escape($p['cat_id']);
|
||||||
|
}else{
|
||||||
|
$cat_id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$cur = $core->con->openCursor($core->prefix.'post');
|
||||||
|
$cur->post_title = $core->con->escape($p['post_title']);
|
||||||
|
$cur->cat_id = $cat_id;
|
||||||
|
if(isset($p['post_dt']))
|
||||||
|
$cur->post_dt = $core->con->escape($p['post_dt']);
|
||||||
|
else
|
||||||
|
$cur->post_dt = '';
|
||||||
|
$cur->post_format = $core->con->escape($p['post_format']); //mandatory field
|
||||||
|
if(isset($p['post_password']))
|
||||||
|
$cur->post_password = $core->con->escape($p['post_password']);
|
||||||
|
else
|
||||||
|
$cur->post_password = null;
|
||||||
|
|
||||||
|
if(isset($p['post_lang']))
|
||||||
|
$cur->post_lang = $core->con->escape($p['post_lang']);
|
||||||
|
else
|
||||||
|
$cur->post_lang = '';
|
||||||
|
|
||||||
|
$cur->post_title = $core->con->escape($p['post_title']); //mandatory field
|
||||||
|
|
||||||
|
if(isset($p['post_excerpt']))
|
||||||
|
$cur->post_excerpt = $core->con->escape($p['post_excerpt']);
|
||||||
|
else
|
||||||
|
$cur->post_excerpt = '';
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($p['post_excerpt_xhtml'])){
|
||||||
|
|
||||||
|
$cur->post_excerpt_xhtml = $core->con->escape($p['post_excerpt_xhtml']);
|
||||||
|
|
||||||
|
}elseif(($p['post_format'] == 'wiki') && (isset($p['post_excerpt']))) {
|
||||||
|
$cur->post_excerpt_xhtml = $core->wikiTransform($p['post_excerpt']);
|
||||||
|
}elseif(($p['post_format'] <> 'wiki') && (!isset($p['post_excerpt']))){
|
||||||
|
$this->response_message = 400;
|
||||||
|
$this->response_message = array(
|
||||||
|
"error" => "ERROR. If not wiki format, give me post_exerpt_xhtml please.",
|
||||||
|
"code" => 400
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cur->post_content = $p['post_content']; //mandatory field
|
||||||
|
|
||||||
|
if($p['post_format'] == 'xhtml'){
|
||||||
|
$cur->post_content_xhtml = $core->con->escape($p['post_content']);
|
||||||
|
}elseif(isset($p['post_content_xhtml'])){
|
||||||
|
$cur->post_content_xhtml = $core->con->escape($p['post_content_xhtml']);
|
||||||
|
}elseif($p['post_format'] == 'wiki'){
|
||||||
|
//convertir le format wiki en html
|
||||||
|
$cur->post_content_xhtml = $core->wikiTransform($p['post_content']);
|
||||||
|
}else{
|
||||||
|
//sortir en erreur
|
||||||
|
$this->response_code = 400;
|
||||||
|
$this->response_message = array(
|
||||||
|
"error" => "ERROR. If not wiki format, give me post_content_xhtml please.",
|
||||||
|
"code" => 400
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
//$cur->post_notes = $post_notes; TO DO
|
||||||
|
|
||||||
|
$cur->post_status = $core->con->escape($p['post_status']); //mandatory field
|
||||||
|
|
||||||
|
if(isset($p['post_selected']))
|
||||||
|
$cur->post_selected = (integer) $core->con->escape($p['post_selected']);
|
||||||
|
else
|
||||||
|
$cur->post_selected = 0;
|
||||||
|
|
||||||
|
if(isset($p['post_open_comment']))
|
||||||
|
$cur->post_open_comment = (integer)$core->con->escape($p['post_open_comment']);
|
||||||
|
else
|
||||||
|
$cur->post_open_comment = 0;
|
||||||
|
|
||||||
|
if(isset($p['post_open_tb']))
|
||||||
|
$cur->post_open_tb = (integer) $core->con->escape($p['post_open_tb']);
|
||||||
|
else
|
||||||
|
$cur->post_open_tb = 0;
|
||||||
|
|
||||||
|
if(isset($p['post_notes']))
|
||||||
|
$cur->post_notes = $core->con->escape($p['post_notes']);
|
||||||
|
|
||||||
|
$cur->user_id = $core->auth->userID();
|
||||||
|
|
||||||
|
try {
|
||||||
|
# --BEHAVIOR-- adminBeforePostCreate
|
||||||
|
$core->callBehavior('adminBeforePostCreate',$cur);
|
||||||
|
|
||||||
|
$return_id = $core->blog->addPost($cur);
|
||||||
|
$createdIds[] = $return_id;
|
||||||
|
# --BEHAVIOR-- adminAfterPostCreate
|
||||||
|
$core->callBehavior('adminAfterPostCreate',$cur,$return_id);
|
||||||
|
|
||||||
|
//les eventuels tags
|
||||||
|
if(isset($p['post_tags'])){
|
||||||
|
foreach($p['post_tags'] as $tag){
|
||||||
|
RestQueryPostMetas::add_meta($tag,'tag',$return_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->response_code = 500;
|
||||||
|
$this->response_message = array(
|
||||||
|
"code" => 500,
|
||||||
|
"message" => $e->getMessage(),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
$this->response_code = 200;
|
||||||
|
if(count($createdIds) == 1){
|
||||||
|
$id = (integer)$createdIds[0];
|
||||||
|
}else{
|
||||||
|
$id = $createdIds;
|
||||||
|
}
|
||||||
|
$this->response_message = array(
|
||||||
|
"message" => "Successfully create post(s)",
|
||||||
|
"id" => $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Before Width: | Height: | Size: 675 B After Width: | Height: | Size: 675 B |
Loading…
Reference in New Issue