diff --git a/src/controllers/Document/Create.php b/src/controllers/Document/Create.php
index fbe68ed7..1126b471 100644
--- a/src/controllers/Document/Create.php
+++ b/src/controllers/Document/Create.php
@@ -44,16 +44,21 @@ protected function handlePost(Router &$router, DocumentCreateModel &$model) {
if (!isset(Common::$database)) {
Common::$database = DatabaseDriver::getDatabaseObject();
}
- $data = $router->getRequestBodyArray();
- $title = (isset($data['title' ]) ? $data['title' ] : null);
- $markdown = (isset($data['markdown' ]) ? $data['markdown' ] : null);
- $content = (isset($data['content' ]) ? $data['content' ] : null);
- $publish = (isset($data['publish' ]) ? $data['publish' ] : null);
- $save = (isset($data['save' ]) ? $data['save' ] : null);
-
- $model->title = $title;
+ $data = $router->getRequestBodyArray();
+ $title = $data['title'] ?? null;
+ $markdown = $data['markdown'] ?? null;
+ $brief = $data['brief'] ?? null;
+ $content = $data['content'] ?? null;
+ $publish = $data['publish'] ?? null;
+ $save = $data['save'] ?? null;
+
+ $markdown = ($markdown ? true : false);
+ $publish = ($publish ? true : false);
+
+ $model->title = $title;
+ $model->brief = $brief;
$model->markdown = $markdown;
- $model->content = $content;
+ $model->content = $content;
if (empty($title)) {
$model->error = 'EMPTY_TITLE';
@@ -61,17 +66,15 @@ protected function handlePost(Router &$router, DocumentCreateModel &$model) {
$model->error = 'EMPTY_CONTENT';
}
- $options_bitmask = 0;
- if ($markdown) $options_bitmask |= Document::OPTION_MARKDOWN;
- if ($publish ) $options_bitmask |= Document::OPTION_PUBLISHED;
-
$user_id = $model->user->getId();
try {
$document = new Document(null);
+ $document->setBrief($brief);
$document->setContent($content);
- $document->setOptions($options_bitmask);
+ $document->setMarkdown($markdown);
+ $document->setPublished($publish);
$document->setTitle($title);
$document->setUserId($user_id);
$document->commit();
@@ -91,10 +94,12 @@ protected function handlePost(Router &$router, DocumentCreateModel &$model) {
$user_id,
getenv('REMOTE_ADDR'),
json_encode([
- 'error' => $model->error,
- 'options_bitmask' => $options_bitmask,
- 'title' => $title,
- 'content' => $content,
+ 'brief' => $brief,
+ 'content' => $content,
+ 'error' => $model->error,
+ 'markdown' => $markdown,
+ 'published' => $publish,
+ 'title' => $title,
])
);
}
diff --git a/src/controllers/Document/Edit.php b/src/controllers/Document/Edit.php
index 3e85b543..a968cf9d 100644
--- a/src/controllers/Document/Edit.php
+++ b/src/controllers/Document/Edit.php
@@ -23,16 +23,10 @@
class Edit extends Controller {
public function &run(Router &$router, View &$view, array &$args) {
- $data = $router->getRequestQueryArray();
- $model = new DocumentEditModel();
- $model->content = null;
- $model->document = null;
- $model->document_id = (isset($data['id']) ? $data['id'] : null);
- $model->error = null;
- $model->markdown = null;
- $model->published = null;
- $model->title = null;
- $model->user = Authentication::$user;
+ $data = $router->getRequestQueryArray();
+ $model = new DocumentEditModel();
+ $model->document_id = (isset($data['id']) ? $data['id'] : null);
+ $model->user = Authentication::$user;
$model->acl_allowed = ($model->user && $model->user->getOption(
User::OPTION_ACL_DOCUMENT_MODIFY
@@ -50,6 +44,7 @@ public function &run(Router &$router, View &$view, array &$args) {
$model->document_id
);
+ $model->brief = $model->document->getBrief(false);
$model->content = $model->document->getContent(false);
$model->markdown = $model->document->isMarkdown();
$model->published = $model->document->isPublished();
@@ -74,16 +69,21 @@ protected function handlePost(Router &$router, DocumentEditModel &$model) {
Common::$database = DatabaseDriver::getDatabaseObject();
}
- $data = $router->getRequestBodyArray();
- $category = (isset($data['category' ]) ? $data['category' ] : null);
- $title = (isset($data['title' ]) ? $data['title' ] : null);
- $markdown = (isset($data['markdown' ]) ? $data['markdown' ] : null);
- $content = (isset($data['content' ]) ? $data['content' ] : null);
- $publish = (isset($data['publish' ]) ? $data['publish' ] : null);
- $save = (isset($data['save' ]) ? $data['save' ] : null);
+ $data = $router->getRequestBodyArray();
+ $brief = $data['brief'] ?? null;
+ $category = $data['category'] ?? null;
+ $content = $data['content'] ?? null;
+ $markdown = $data['markdown'] ?? null;
+ $publish = $data['publish'] ?? null;
+ $save = $data['save'] ?? null;
+ $title = $data['title'] ?? null;
+
+ $markdown = ($markdown ? true : false);
+ $publish = ($publish ? true : false);
$model->category = $category;
$model->title = $title;
+ $model->brief = $brief;
$model->markdown = $markdown;
$model->content = $content;
@@ -98,9 +98,10 @@ protected function handlePost(Router &$router, DocumentEditModel &$model) {
try {
$model->document->setTitle($model->title);
- $model->document->setMarkdown($model->markdown);
+ $model->document->setBrief($model->brief);
+ $model->document->setMarkdown($markdown);
$model->document->setContent($model->content);
- $model->document->setPublished($publish ? true : false);
+ $model->document->setPublished($publish);
$model->document->incrementEdited();
$model->document->commit();
@@ -120,11 +121,12 @@ protected function handlePost(Router &$router, DocumentEditModel &$model) {
$user_id,
getenv('REMOTE_ADDR'),
json_encode([
- 'error' => $model->error,
+ 'brief' => $model->document->getBrief(false),
+ 'content' => $model->document->getContent(false),
'document_id' => $model->document_id,
+ 'error' => $model->error,
'options_bitmask' => $model->document->getOptions(),
'title' => $model->document->getTitle(),
- 'content' => $model->document->getContent(false),
])
);
}
diff --git a/src/controllers/Document/Index.php b/src/controllers/Document/Index.php
index 290fb3e1..02c78fdf 100644
--- a/src/controllers/Document/Index.php
+++ b/src/controllers/Document/Index.php
@@ -19,7 +19,6 @@
class Index extends Controller {
public function &run(Router &$router, View &$view, array &$args) {
$model = new DocumentIndexModel();
-
$query = $router->getRequestQueryArray();
$model->order = (
diff --git a/src/models/Document/Create.php b/src/models/Document/Create.php
index 93c81468..e5e24384 100644
--- a/src/models/Document/Create.php
+++ b/src/models/Document/Create.php
@@ -7,6 +7,7 @@
class Create extends Model {
public $acl_allowed;
+ public $brief;
public $content;
public $error;
public $markdown;
diff --git a/src/models/Document/Edit.php b/src/models/Document/Edit.php
index ab891133..51b72345 100644
--- a/src/models/Document/Edit.php
+++ b/src/models/Document/Edit.php
@@ -7,6 +7,7 @@
class Edit extends Model {
public $acl_allowed;
+ public $brief;
public $category;
public $content;
public $document;
diff --git a/src/templates/Document/Create.phtml b/src/templates/Document/Create.phtml
index 9d1203e7..a4ae1d71 100644
--- a/src/templates/Document/Create.phtml
+++ b/src/templates/Document/Create.phtml
@@ -17,6 +17,7 @@ switch ($error)
case 'INTERNAL_ERROR': $message = 'An internal error occurred while processing your request. Our staff have been notified of the issue. Try again later.'; break;
default: $message = $error;
}
+$form_brief = filter_var($this->getContext()->brief, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$form_content = filter_var($this->getContext()->content, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$form_markdown = $this->getContext()->markdown;
$form_title = filter_var($this->getContext()->title, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
diff --git a/src/templates/Document/Edit.phtml b/src/templates/Document/Edit.phtml
index 2d37ba81..1a276c55 100644
--- a/src/templates/Document/Edit.phtml
+++ b/src/templates/Document/Edit.phtml
@@ -20,6 +20,7 @@ switch ($error)
case 'INTERNAL_ERROR': $message = 'An internal error occurred while processing your request. Our staff have been notified of the issue. Try again later.'; break;
default: $message = $error;
}
+$form_brief = filter_var($this->getContext()->brief, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$form_content = filter_var($this->getContext()->content, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$form_markdown = $this->getContext()->markdown;
$form_title = filter_var($this->getContext()->title, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
diff --git a/src/templates/Document/Form.inc.phtml b/src/templates/Document/Form.inc.phtml
index 82b04d9e..c9e25281 100644
--- a/src/templates/Document/Form.inc.phtml
+++ b/src/templates/Document/Form.inc.phtml
@@ -5,18 +5,22 @@ namespace BNETDocs\Templates\Document; ?>
+