/**
  * Creates a new TopicContent model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new TopicContent();
     if ($model->load(Yii::$app->request->post())) {
         $model->topic_text_source = 'source';
         $model->topic_extra = 'extra';
         if ($model->save()) {
             return $this->redirect('?r=topic/view&id=' . $model->topic_id);
         } else {
             var_dump($model->errors);
         }
     } else {
         $model->topic_id = $_GET['topic_id'];
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionEdit($id)
 {
     $request = Yii::$app->getRequest();
     $me = Yii::$app->getUser()->getIdentity();
     $model = $this->findTopicModel($id, ['content', 'node']);
     if (!$me->canEdit($model)) {
         throw new ForbiddenHttpException('您没有权限修改或已超过可修改时间。');
     }
     if ($me->isAdmin()) {
         $model->scenario = Topic::SCENARIO_ADMIN_EDIT;
     } else {
         $model->scenario = Topic::SCENARIO_AUTHOR_EDIT;
     }
     if (!($content = $model->content)) {
         $content = new TopicContent(['topic_id' => $model->id]);
     }
     $oldTags = $model->tags;
     if ($model->load($request->post()) && $model->validate() && $content->load($request->post()) && $content->validate()) {
         //			$model->tags = Tag::editTags($model->tags, $oldTags);
         $model->tags = Tag::getTags($model->tags);
         $model->save(false) && $content->save(false);
         Tag::afterTopicEdit($model->id, $model->tags, $oldTags);
         (new History(['user_id' => $me->id, 'action' => History::ACTION_EDIT_TOPIC, 'action_time' => $model->updated_at, 'target' => $model->id]))->save(false);
         return $this->redirect(Topic::getRedirectUrl($id, 0, $request->get('ip', 1), $request->get('np', 1)));
     }
     return $this->render('edit', ['model' => $model, 'content' => $content]);
 }