Exemplo n.º 1
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     $this->historyTemp->document_id = $this->document_id;
     $this->historyTemp->save();
     return true;
 }
Exemplo n.º 2
0
 public static function open($path)
 {
     $folderPath = \Yii::$app->getModule('burivuh')->filesPath . $path;
     $list = scandir($folderPath);
     $return = [];
     $folderList = [];
     $isDirMultisort = [];
     $filenameMultisort = [];
     foreach ($list as $key => $file) {
         if ($file == '..' || $file == '.') {
             continue;
         }
         $isDir = is_dir($folderPath . '/' . $file);
         $folderList[$key] = ['isDir' => $isDir, 'name' => $file];
         $filenameMultisort[$key] = $file;
         $isDirMultisort[$key] = $isDir;
     }
     array_multisort($isDirMultisort, SORT_DESC, SORT_NUMERIC, $filenameMultisort, SORT_ASC, SORT_STRING, $folderList);
     foreach ($folderList as $file) {
         if ($file['isDir']) {
             $return[] = Folder::read($path . '/' . $file['name']);
         } else {
             $return[] = Document::read($path . '/' . $file['name']);
         }
     }
     return $return;
 }
Exemplo n.º 3
0
 public function actionDelete()
 {
     $model = Document::read($this->path);
     if (is_null($model)) {
         throw new \yii\web\HttpException(404);
     }
     $model->delete();
     $this->redirect(['index', 'path' => $model->folder]);
 }
Exemplo n.º 4
0
 public function actionIndex($category_id = null)
 {
     if (is_null($category_id)) {
         $category = new Home();
     } else {
         $category = Category::findOne($category_id);
     }
     if ($category->category_id != 0 && is_null($category)) {
         throw new \yii\web\HttpException(404, Yii::t('burivuh', 'The category does not exist'));
     }
     $categories = Category::find()->where(['parent_id' => $category->category_id])->orderBy('title')->all();
     $documents = Document::find()->where(['category_id' => $category->category_id])->orderBy('title')->all();
     $readme = Document::find()->where(['title' => $category->title, 'category_id' => $category->category_id])->one();
     return $this->render('index', ['category' => $category, 'categories' => $categories, 'documents' => $documents, 'readme' => $readme]);
 }
Exemplo n.º 5
0
 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]);
 }
Exemplo n.º 6
0
 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]);
 }
Exemplo n.º 7
0
 public function getDocuments()
 {
     return $this->hasMany(Document::className(), ['category_id' => 'category_id']);
 }