Commit 48829d222ed6f4827fc9db5d96051d944a0336dc
1 parent
da63a578
parser
Showing
4 changed files
with
14 additions
and
33 deletions
Show diff stats
backend/components/parsers/ParserHandler.php
backend/controllers/ParserController.php
| ... | ... | @@ -63,10 +63,12 @@ class ParserController extends Controller |
| 63 | 63 | $filePath = Yii::getAlias('@webroot') . '/uploads/' . $model->file->baseName . '.' . $model->file->extension; |
| 64 | 64 | $model->file->saveAs( $filePath ); |
| 65 | 65 | |
| 66 | - $data = new ParserHandler( $filePath ); | |
| 67 | -// echo "<pre>"; | |
| 68 | -// var_dump($data); | |
| 69 | -// echo "</pre>"; | |
| 66 | + $parser = new ParserHandler( $filePath ); | |
| 67 | + $data = $parser->run(); | |
| 68 | + | |
| 69 | + if( !is_array($data) ){ | |
| 70 | + $data = ['No results']; | |
| 71 | + } | |
| 70 | 72 | $provider = new ArrayDataProvider([ |
| 71 | 73 | 'allModels' => $data, |
| 72 | 74 | 'pagination' => [ |
| ... | ... | @@ -78,7 +80,7 @@ class ParserController extends Controller |
| 78 | 80 | ]); |
| 79 | 81 | |
| 80 | 82 | return $this->render('results', |
| 81 | - ['model' => $model, | |
| 83 | + ['model' => $data, | |
| 82 | 84 | 'dataProvider' => $provider]); |
| 83 | 85 | } |
| 84 | 86 | } | ... | ... |
backend/views/parser/index.php
| 1 | 1 | <?php |
| 2 | 2 | use yii\widgets\ActiveForm; |
| 3 | 3 | ?> |
| 4 | - | |
| 4 | + <div class="catalog-view"> | |
| 5 | 5 | <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?> |
| 6 | 6 | |
| 7 | 7 | <?= $form->field($model, 'file')->fileInput() ?> |
| 8 | 8 | |
| 9 | 9 | <button>Прочитать</button> |
| 10 | 10 | |
| 11 | -<?php ActiveForm::end() ?> | |
| 12 | 11 | \ No newline at end of file |
| 12 | +<?php ActiveForm::end() ?> | |
| 13 | + </div> | |
| 13 | 14 | \ No newline at end of file | ... | ... |
backend/views/parser/results.php
| ... | ... | @@ -4,43 +4,21 @@ use yii\helpers\Html; |
| 4 | 4 | use yii\grid\GridView; |
| 5 | 5 | |
| 6 | 6 | /* @var $this yii\web\View */ |
| 7 | -/* @var $searchModel backend\models\ArticlesSearch */ | |
| 7 | +/* @var $searchModel backend\models\CatalogSearch */ | |
| 8 | 8 | /* @var $dataProvider yii\data\ActiveDataProvider */ |
| 9 | 9 | |
| 10 | 10 | $this->title = 'Results'; |
| 11 | 11 | $this->params['breadcrumbs'][] = $this->title; |
| 12 | 12 | ?> |
| 13 | -<div class="articles-index"> | |
| 13 | +<div class="catalog-index"> | |
| 14 | 14 | |
| 15 | 15 | <h1><?= Html::encode($this->title) ?></h1> |
| 16 | 16 | <?php // echo $this->render('_search', ['model' => $searchModel]); ?> |
| 17 | 17 | |
| 18 | - <p> | |
| 19 | - <?= Html::a('Создать', ['create', 'type' =>$type], ['class' => 'btn btn-success']) ?> | |
| 20 | - </p> | |
| 18 | + | |
| 21 | 19 | |
| 22 | 20 | <?= GridView::widget([ |
| 23 | 21 | 'dataProvider' => $dataProvider, |
| 24 | - 'filterModel' => $searchModel, | |
| 25 | - 'columns' => [ | |
| 26 | - ['class' => 'yii\grid\SerialColumn'], | |
| 27 | - | |
| 28 | - 'id', | |
| 29 | - 'name', | |
| 30 | - 'translit', | |
| 31 | - 'title', | |
| 32 | - [ | |
| 33 | - 'format' => 'image', | |
| 34 | - 'attribute'=>'image', | |
| 35 | - ], | |
| 36 | - // 'body:ntext', | |
| 37 | - // 'meta_title', | |
| 38 | - // 'description', | |
| 39 | - // 'h1', | |
| 40 | - // 'seo_text:ntext', | |
| 41 | - | |
| 42 | - ['class' => 'yii\grid\ActionColumn'], | |
| 43 | - ], | |
| 44 | 22 | ]); ?> |
| 45 | 23 | |
| 46 | 24 | </div> |
| 47 | 25 | \ No newline at end of file | ... | ... |