This commit is contained in:
Baoshuo Ren 2022-03-20 18:23:40 +08:00
parent e3fc955b75
commit 71214c0631
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -7,6 +7,8 @@ class UOJBlogEditor {
public $save; public $save;
public $cur_data = array(); public $cur_data = array();
public $post_data = array(); public $post_data = array();
public $show_editor = true;
public $show_tags = true;
public $label_text = array( public $label_text = array(
'title' => '标题', 'title' => '标题',
@ -78,7 +80,15 @@ class UOJBlogEditor {
} }
private function receivePostData() { private function receivePostData() {
$errors = array(); $errors = array();
foreach (array('title', 'content_md', 'tags') as $name) {
$keys = array('title');
if ($this->show_tags) {
$keys[] = 'tags';
}
if ($this->show_editor) {
$keys[] = 'content_md';
}
foreach ($keys as $name) {
$cur_err = $this->validate($name); $cur_err = $this->validate($name);
if ($cur_err) { if ($cur_err) {
$errors[$name] = $cur_err; $errors[$name] = $cur_err;
@ -95,6 +105,7 @@ class UOJBlogEditor {
$this->post_data['title'] = HTML::escape($this->post_data['title']); $this->post_data['title'] = HTML::escape($this->post_data['title']);
if ($this->show_editor) {
if ($this->type == 'blog') { if ($this->type == 'blog') {
$content_md = $_POST[$this->name . '_content_md']; $content_md = $_POST[$this->name . '_content_md'];
try { try {
@ -189,6 +200,7 @@ EOD
$this->post_data['content'] = json_encode($config) . "\n" . $this->post_data['content']; $this->post_data['content'] = json_encode($config) . "\n" . $this->post_data['content'];
} }
} }
}
public function handleSave() { public function handleSave() {
$save = $this->save; $save = $this->save;