Skip to content

Commit

Permalink
#29 체크리스트 본문 내용 보정작업 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
redgoose-dev committed Mar 3, 2021
1 parent df6adaa commit a532d98
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions controller/checklist/UtilForChecklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@ public static function getPercentIntoCheckboxes(string $body): int
return (int)floor($checked / $total * 100);
}

/**
* adjust content
*
* @param string $content
* @return string
*/
public static function adjustContent(string $content): string
{
$content = str_replace("'", "\'", $content);
return $content;
}

}
5 changes: 4 additions & 1 deletion controller/checklist/add_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
// set percent into content
$percent = UtilForChecklist::getPercentIntoCheckboxes($this->post->content);

// adjust content
$content = UtilForChecklist::adjustContent($this->post->content);

// set output
$output = Controller\Main::add($this, (object)[
'table' => 'checklist',
'return' => isset($this->get->return),
'data' => (object)[
'srl' => null,
'user_srl' => (int)$token->data->user_srl,
'content' => $this->post->content,
'content' => $content,
'percent' => $percent,
'regdate' => isset($this->post->regdate) ? $this->post->regdate : date('Y-m-d H:i:s'),
],
Expand Down
5 changes: 4 additions & 1 deletion controller/checklist/edit_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@
'srl' => $srl,
]);

// adjust content
$content = UtilForChecklist::adjustContent($this->post->content);

// set output
$output = Controller\Main::edit($this, (object)[
'table' => 'checklist',
'srl' => $srl,
'data' => [
"content='{$this->post->content}'",
"content='{$content}'",
"percent={$percent}",
],
]);
Expand Down

0 comments on commit a532d98

Please sign in to comment.