Commit da63a57808ce7f1862a064de3a8c91bc76ddb038
1 parent
9bfcfcaf
parser csv v2
Showing
4 changed files
with
62 additions
and
15 deletions
Show diff stats
backend/components/parsers/ParserHandler.php
@@ -25,8 +25,7 @@ class ParserHandler { | @@ -25,8 +25,7 @@ class ParserHandler { | ||
25 | private function run(){ | 25 | private function run(){ |
26 | if ($this->extension = '.csv'){ | 26 | if ($this->extension = '.csv'){ |
27 | $csvParser = new Reader( $this->filePath ); | 27 | $csvParser = new Reader( $this->filePath ); |
28 | - return ['parserFile' => $this->filePath]; | ||
29 | - //$csvParser->read(); | 28 | + return $csvParser->read(); |
30 | }; | 29 | }; |
31 | } | 30 | } |
32 | } | 31 | } |
33 | \ No newline at end of file | 32 | \ No newline at end of file |
backend/controllers/ParserController.php
@@ -64,24 +64,26 @@ class ParserController extends Controller | @@ -64,24 +64,26 @@ class ParserController extends Controller | ||
64 | $model->file->saveAs( $filePath ); | 64 | $model->file->saveAs( $filePath ); |
65 | 65 | ||
66 | $data = new ParserHandler( $filePath ); | 66 | $data = new ParserHandler( $filePath ); |
67 | - var_dump($data); | ||
68 | -// $provider = new ArrayDataProvider([ | ||
69 | -// 'allModels' => $data, | ||
70 | -// 'pagination' => [ | ||
71 | -// 'pageSize' => 10, | 67 | +// echo "<pre>"; |
68 | +// var_dump($data); | ||
69 | +// echo "</pre>"; | ||
70 | + $provider = new ArrayDataProvider([ | ||
71 | + 'allModels' => $data, | ||
72 | + 'pagination' => [ | ||
73 | + 'pageSize' => 10, | ||
74 | + ], | ||
75 | +// 'sort' => [ | ||
76 | +// 'attributes' => ['id', 'name'], | ||
72 | // ], | 77 | // ], |
73 | -//// 'sort' => [ | ||
74 | -//// 'attributes' => ['id', 'name'], | ||
75 | -//// ], | ||
76 | -// ]); | 78 | + ]); |
77 | 79 | ||
78 | -// return $this->render('parsingResult', | ||
79 | -// ['model' => $model, | ||
80 | -// 'dataProvider' => $provider]); | 80 | + return $this->render('results', |
81 | + ['model' => $model, | ||
82 | + 'dataProvider' => $provider]); | ||
81 | } | 83 | } |
82 | } | 84 | } |
83 | 85 | ||
84 | - return $this->render('parser', ['model' => $model]); | 86 | + return $this->render('index', ['model' => $model]); |
85 | } | 87 | } |
86 | 88 | ||
87 | 89 |
backend/views/parser/parser.php renamed to backend/views/parser/index.php
1 | +<?php | ||
2 | + | ||
3 | +use yii\helpers\Html; | ||
4 | +use yii\grid\GridView; | ||
5 | + | ||
6 | +/* @var $this yii\web\View */ | ||
7 | +/* @var $searchModel backend\models\ArticlesSearch */ | ||
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | ||
9 | + | ||
10 | +$this->title = 'Results'; | ||
11 | +$this->params['breadcrumbs'][] = $this->title; | ||
12 | +?> | ||
13 | +<div class="articles-index"> | ||
14 | + | ||
15 | + <h1><?= Html::encode($this->title) ?></h1> | ||
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | ||
17 | + | ||
18 | + <p> | ||
19 | + <?= Html::a('Создать', ['create', 'type' =>$type], ['class' => 'btn btn-success']) ?> | ||
20 | + </p> | ||
21 | + | ||
22 | + <?= GridView::widget([ | ||
23 | + '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 | + ]); ?> | ||
45 | + | ||
46 | +</div> | ||
0 | \ No newline at end of file | 47 | \ No newline at end of file |