public function actionDiff($document_history_id) { $model = History::findOne($document_history_id); if (is_null($model)) { throw new \yii\web\HttpException(404, Yii::t('burivuh', 'Record in the history does not exist')); } $document = Document::findOne($model->document_id); $previous = History::find()->where(['document_id' => $model->document_id])->andWhere('created_at<:created_at', [':created_at' => $model->created_at])->orderBy('created_at DESC')->limit(1)->one(); $diffs = []; if (!is_null($previous)) { $dmp = new DiffMatchPatch(); $diffs = $dmp->diff_main($previous->content, $model->content, false); } return $this->render('diff', ['document' => $document, 'model' => $model, 'previous' => $previous, 'diffs' => $diffs]); }
public function actionDelete($document_id) { $model = Document::findOne($document_id); if (is_null($model)) { throw new \yii\web\HttpException(404, Yii::t('burivuh', 'The document does not exist')); } if (isset($_POST['document_id'])) { $category = Category::findOne($model->category_id); $model->delete(); $redirect = ['/burivuh/category/index']; if (!is_null($category)) { $redirect = $category->url; } $this->redirect($redirect); } return $this->render('delete', ['model' => $model]); }