Inheritance: extends Windwalker\Core\Model\DatabaseModel
 /**
  * doExecute
  *
  * @return  string
  */
 protected function doExecute()
 {
     $type = $this->input->get('type', 'post');
     $type = $type == 'post' ? $type : 'static';
     $view = new PostHtmlView($this->data);
     $model = new PostModel();
     $model['post.type'] = $type;
     $id = $this->input->get('id');
     $view['item'] = $model->getItem($id);
     $view['type'] = $type;
     $view['form'] = $model->getForm($view['item']);
     return $view->setLayout('edit')->render();
 }
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $model = new PostModel();
     $data = $this->input->getVar('post');
     $data['text'] = $this->input->getByPath('post.text', null, InputFilter::RAW);
     $data = new Data($data);
     $isNew = !$data['id'];
     try {
         $model->validate($data);
         if (!$isNew) {
             $oldData = (new DataMapper('posts'))->findOne($data['id']);
             $oldData->bind($data);
             $data = $oldData;
             $data->modified = (new Date())->format('Y-m-d H:i:s');
         } else {
             $data->blog = Blog::get()->id;
             $data->type = $this->input->get('type', 'post');
             $data->type = $data->type == 'post' ? $data->type : 'static';
             $data->created = (new Date())->format('Y-m-d H:i:s');
         }
         $data->author = $data->author ?: Author::get(User::get()->id, Blog::get()->id)->id;
         $text = preg_split('/(\\<\\!--\\s*\\{READMORE\\}\\s*--\\>)/', $data['text'], 2);
         $data->introtext = isset($text[0]) ? $text[0] : null;
         $data->fulltext = isset($text[1]) ? $text[1] : null;
         $data = $model->save($data);
     } catch (ValidFailException $e) {
         $return['msg'] = $e->getMessage();
         $return['success'] = false;
         $this->respond($return, 500);
         return false;
     } catch (\Exception $e) {
         if (WINDWALKER_DEBUG) {
             throw $e;
         }
         $return['msg'] = 'Save fail';
         $return['success'] = false;
         $this->respond($return, 500);
         return false;
     }
     $return['msg'] = 'Save success';
     $return['success'] = true;
     $return['item'] = $data;
     $this->respond($return, 200);
     return true;
 }