$blog=DB::selectFirst("select * from blogs where poster = '".UOJContext::user()['username']."' and type = 'B' and is_draft = true");
}
$blog_editor=newUOJBlogEditor();
$blog_editor->name='blog';
if($blog){
$blog_editor->cur_data=array(
'title'=>$blog['title'],
'content_md'=>$blog['content_md'],
'content'=>$blog['content'],
'tags'=>queryBlogTags($blog['id']),
'is_hidden'=>$blog['is_hidden']
);
}else{
$blog_editor->cur_data=array(
'title'=>'新博客',
'content_md'=>'',
'content'=>'',
'tags'=>array(),
'is_hidden'=>true
);
}
if($blog&&!$blog['is_draft']){
$blog_editor->blog_url="/blog/{$blog['id']}";
}else{
$blog_editor->blog_url=null;
}
functionupdateBlog($id,$data){
DB::update("update blogs set title = '".DB::escape($data['title'])."', content = '".DB::escape($data['content'])."', content_md = '".DB::escape($data['content_md'])."', is_hidden = {$data['is_hidden']} where id = {$id}");