Commit 1cc27986a6333a36df95b8027b73f208b3e7b08d

Authored by Mihail
1 parent 021773a2

merge with server

1 .idea 1 .idea
2 -/uploads  
3 \ No newline at end of file 2 \ No newline at end of file
  3 +/uploads
  4 +/vendor
4 \ No newline at end of file 5 \ No newline at end of file
backend/controllers/ParserController.php
1 <?php 1 <?php
2 namespace backend\controllers; 2 namespace backend\controllers;
3 3
  4 +use common\components\parsers\MailParser;
4 use Yii; 5 use Yii;
5 use yii\data\ActiveDataProvider; 6 use yii\data\ActiveDataProvider;
6 use yii\filters\AccessControl; 7 use yii\filters\AccessControl;
@@ -53,6 +54,7 @@ class ParserController extends BaseController @@ -53,6 +54,7 @@ class ParserController extends BaseController
53 public function actionIndex($mode = 0) 54 public function actionIndex($mode = 0)
54 { 55 {
55 $model = new UploadFileParsingForm(); 56 $model = new UploadFileParsingForm();
  57 + // $mail = new MailParser();
56 // установим режим, 0 - ручная загрузка, 1 - автозагрузка 58 // установим режим, 0 - ручная загрузка, 1 - автозагрузка
57 $model->mode = $mode; 59 $model->mode = $mode;
58 return $this->render('index', ['model' => $model]); 60 return $this->render('index', ['model' => $model]);
common/components/parsers/config.php
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
52 ['console' => 52 ['console' =>
53 ['class' => 'yii\multiparser\XmlParser', 53 ['class' => 'yii\multiparser\XmlParser',
54 'node' => 'Товар', 54 'node' => 'Товар',
55 - 'hasHeaderRow' => true, 55 + 'has_header_row' => true,
56 'keys' => [ 56 'keys' => [
57 "BRAND" => 'Производитель', 57 "BRAND" => 'Производитель',
58 "ARTICLE"=> 'Код', 58 "ARTICLE"=> 'Код',
@@ -72,9 +72,9 @@ @@ -72,9 +72,9 @@
72 ['web' => 72 ['web' =>
73 ['class' => 'yii\multiparser\XlsxParser', 73 ['class' => 'yii\multiparser\XlsxParser',
74 'path_for_extract_files' => \Yii::getAlias('@temp_upload') . '/', 74 'path_for_extract_files' => \Yii::getAlias('@temp_upload') . '/',
  75 + 'has_header_row' => true,
75 'converter_conf' => [ 76 'converter_conf' => [
76 'class' => 'common\components\parsers\CustomConverter', 77 'class' => 'common\components\parsers\CustomConverter',
77 - 'hasHeaderRow' => true,  
78 'configuration' => ["string" => []], 78 'configuration' => ["string" => []],
79 ] 79 ]
80 ], 80 ],
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 "yiisoft/yii2": ">=2.0.6", 18 "yiisoft/yii2": ">=2.0.6",
19 "yiisoft/yii2-bootstrap": "*", 19 "yiisoft/yii2-bootstrap": "*",
20 "yiisoft/yii2-swiftmailer": "*", 20 "yiisoft/yii2-swiftmailer": "*",
  21 + "artweb/yii2-multiparser": "master-dev",
21 "yiisoft/yii2-imagine": "*" 22 "yiisoft/yii2-imagine": "*"
22 }, 23 },
23 "require-dev": { 24 "require-dev": {
@@ -4,9 +4,55 @@ @@ -4,9 +4,55 @@
4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 "This file is @generated automatically" 5 "This file is @generated automatically"
6 ], 6 ],
7 - "hash": "8580bd82955b1fbb80d47024e184056e", 7 + "hash": "0a5f8749ae4c46cb2b7dd9d3f777c97c",
  8 + "content-hash": "4c396673df5a5e19daaa0f887579444c",
8 "packages": [ 9 "packages": [
9 { 10 {
  11 + "name": "artweb/yii2-multiparser",
  12 + "version": "dev-master",
  13 + "source": {
  14 + "type": "git",
  15 + "url": "https://github.com/tsurkanovm/yii-multiparser.git",
  16 + "reference": "7a3cd2728c4b0c9db1b6bcea411f8df87b69ecd3"
  17 + },
  18 + "dist": {
  19 + "type": "zip",
  20 + "url": "https://api.github.com/repos/tsurkanovm/yii-multiparser/zipball/7a3cd2728c4b0c9db1b6bcea411f8df87b69ecd3",
  21 + "reference": "7a3cd2728c4b0c9db1b6bcea411f8df87b69ecd3",
  22 + "shasum": ""
  23 + },
  24 + "require": {
  25 + "yiisoft/yii2": "*"
  26 + },
  27 + "type": "library",
  28 + "autoload": {
  29 + "psr-4": {
  30 + "yii\\multiparser\\": "lib\\"
  31 + }
  32 + },
  33 + "notification-url": "https://packagist.org/downloads/",
  34 + "license": [
  35 + "MIT"
  36 + ],
  37 + "authors": [
  38 + {
  39 + "name": "Mihail Tsurkanov",
  40 + "email": "tsurkanovm@gmail.com",
  41 + "role": "Developer"
  42 + }
  43 + ],
  44 + "description": "This extension provides a Multiparser solution for Yii framework 2.0.",
  45 + "homepage": "https://github.com/tsurkanovm/yii-multiparser.git",
  46 + "keywords": [
  47 + "csv",
  48 + "parser",
  49 + "xlsx",
  50 + "xml",
  51 + "yii2"
  52 + ],
  53 + "time": "2015-10-26 10:04:39"
  54 + },
  55 + {
10 "name": "bower-asset/bootstrap", 56 "name": "bower-asset/bootstrap",
11 "version": "v3.3.5", 57 "version": "v3.3.5",
12 "source": { 58 "source": {
@@ -317,6 +363,58 @@ @@ -317,6 +363,58 @@
317 "time": "2013-11-30 08:25:19" 363 "time": "2013-11-30 08:25:19"
318 }, 364 },
319 { 365 {
  366 + "name": "imagine/imagine",
  367 + "version": "v0.5.0",
  368 + "source": {
  369 + "type": "git",
  370 + "url": "https://github.com/avalanche123/Imagine.git",
  371 + "reference": "f64ec666baaa800edcbf237db41121a569230709"
  372 + },
  373 + "dist": {
  374 + "type": "zip",
  375 + "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/f64ec666baaa800edcbf237db41121a569230709",
  376 + "reference": "f64ec666baaa800edcbf237db41121a569230709",
  377 + "shasum": ""
  378 + },
  379 + "require": {
  380 + "php": ">=5.3.2"
  381 + },
  382 + "require-dev": {
  383 + "sami/sami": "dev-master"
  384 + },
  385 + "suggest": {
  386 + "ext-gd": "to use the GD implementation",
  387 + "ext-gmagick": "to use the Gmagick implementation",
  388 + "ext-imagick": "to use the Imagick implementation"
  389 + },
  390 + "type": "library",
  391 + "autoload": {
  392 + "psr-0": {
  393 + "Imagine": "lib/"
  394 + }
  395 + },
  396 + "notification-url": "https://packagist.org/downloads/",
  397 + "license": [
  398 + "MIT"
  399 + ],
  400 + "authors": [
  401 + {
  402 + "name": "Bulat Shakirzyanov",
  403 + "email": "mallluhuct@gmail.com",
  404 + "homepage": "http://avalanche123.com"
  405 + }
  406 + ],
  407 + "description": "Image processing for PHP 5.3",
  408 + "homepage": "http://imagine.readthedocs.org/",
  409 + "keywords": [
  410 + "drawing",
  411 + "graphics",
  412 + "image manipulation",
  413 + "image processing"
  414 + ],
  415 + "time": "2013-07-10 17:25:36"
  416 + },
  417 + {
320 "name": "swiftmailer/swiftmailer", 418 "name": "swiftmailer/swiftmailer",
321 "version": "v5.4.1", 419 "version": "v5.4.1",
322 "source": { 420 "source": {
@@ -459,21 +557,21 @@ @@ -459,21 +557,21 @@
459 }, 557 },
460 { 558 {
461 "name": "yiisoft/yii2-bootstrap", 559 "name": "yiisoft/yii2-bootstrap",
462 - "version": "2.0.4", 560 + "version": "2.0.5",
463 "source": { 561 "source": {
464 "type": "git", 562 "type": "git",
465 "url": "https://github.com/yiisoft/yii2-bootstrap.git", 563 "url": "https://github.com/yiisoft/yii2-bootstrap.git",
466 - "reference": "1b6b1e61cf91c3cdd517d6a7e71d30bb212e4af0" 564 + "reference": "1464f93834b1d5edb1f5625f7ffd6c3723fa4923"
467 }, 565 },
468 "dist": { 566 "dist": {
469 "type": "zip", 567 "type": "zip",
470 - "url": "https://api.github.com/repos/yiisoft/yii2-bootstrap/zipball/1b6b1e61cf91c3cdd517d6a7e71d30bb212e4af0",  
471 - "reference": "1b6b1e61cf91c3cdd517d6a7e71d30bb212e4af0", 568 + "url": "https://api.github.com/repos/yiisoft/yii2-bootstrap/zipball/1464f93834b1d5edb1f5625f7ffd6c3723fa4923",
  569 + "reference": "1464f93834b1d5edb1f5625f7ffd6c3723fa4923",
472 "shasum": "" 570 "shasum": ""
473 }, 571 },
474 "require": { 572 "require": {
475 "bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*", 573 "bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*",
476 - "yiisoft/yii2": ">=2.0.4" 574 + "yiisoft/yii2": ">=2.0.6"
477 }, 575 },
478 "type": "yii2-extension", 576 "type": "yii2-extension",
479 "extra": { 577 "extra": {
@@ -505,7 +603,7 @@ @@ -505,7 +603,7 @@
505 "bootstrap", 603 "bootstrap",
506 "yii2" 604 "yii2"
507 ], 605 ],
508 - "time": "2015-05-10 22:08:17" 606 + "time": "2015-09-23 17:48:24"
509 }, 607 },
510 { 608 {
511 "name": "yiisoft/yii2-composer", 609 "name": "yiisoft/yii2-composer",
@@ -555,6 +653,54 @@ @@ -555,6 +653,54 @@
555 "time": "2015-03-01 06:22:44" 653 "time": "2015-03-01 06:22:44"
556 }, 654 },
557 { 655 {
  656 + "name": "yiisoft/yii2-imagine",
  657 + "version": "2.0.3",
  658 + "source": {
  659 + "type": "git",
  660 + "url": "https://github.com/yiisoft/yii2-imagine.git",
  661 + "reference": "0961343138b65bba447de84b2b300899617e6acc"
  662 + },
  663 + "dist": {
  664 + "type": "zip",
  665 + "url": "https://api.github.com/repos/yiisoft/yii2-imagine/zipball/0961343138b65bba447de84b2b300899617e6acc",
  666 + "reference": "0961343138b65bba447de84b2b300899617e6acc",
  667 + "shasum": ""
  668 + },
  669 + "require": {
  670 + "imagine/imagine": "0.5.*",
  671 + "yiisoft/yii2": "*"
  672 + },
  673 + "type": "yii2-extension",
  674 + "extra": {
  675 + "branch-alias": {
  676 + "dev-master": "2.0.x-dev"
  677 + }
  678 + },
  679 + "autoload": {
  680 + "psr-4": {
  681 + "yii\\imagine\\": ""
  682 + }
  683 + },
  684 + "notification-url": "https://packagist.org/downloads/",
  685 + "license": [
  686 + "BSD-3-Clause"
  687 + ],
  688 + "authors": [
  689 + {
  690 + "name": "Antonio Ramirez",
  691 + "email": "amigo.cobos@gmail.com"
  692 + }
  693 + ],
  694 + "description": "The Imagine integration for the Yii framework",
  695 + "keywords": [
  696 + "helper",
  697 + "image",
  698 + "imagine",
  699 + "yii2"
  700 + ],
  701 + "time": "2015-03-01 06:22:44"
  702 + },
  703 + {
558 "name": "yiisoft/yii2-swiftmailer", 704 "name": "yiisoft/yii2-swiftmailer",
559 "version": "2.0.4", 705 "version": "2.0.4",
560 "source": { 706 "source": {
@@ -634,101 +780,6 @@ @@ -634,101 +780,6 @@
634 } 780 }
635 }, 781 },
636 { 782 {
637 - "name": "composer/installers",  
638 - "version": "v1.0.21",  
639 - "source": {  
640 - "type": "git",  
641 - "url": "https://github.com/composer/installers.git",  
642 - "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"  
643 - },  
644 - "dist": {  
645 - "type": "zip",  
646 - "url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",  
647 - "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",  
648 - "shasum": ""  
649 - },  
650 - "replace": {  
651 - "roundcube/plugin-installer": "*",  
652 - "shama/baton": "*"  
653 - },  
654 - "require-dev": {  
655 - "composer/composer": "1.0.*@dev",  
656 - "phpunit/phpunit": "4.1.*"  
657 - },  
658 - "type": "composer-installer",  
659 - "extra": {  
660 - "class": "Composer\\Installers\\Installer",  
661 - "branch-alias": {  
662 - "dev-master": "1.0-dev"  
663 - }  
664 - },  
665 - "autoload": {  
666 - "psr-0": {  
667 - "Composer\\Installers\\": "src/"  
668 - }  
669 - },  
670 - "notification-url": "https://packagist.org/downloads/",  
671 - "license": [  
672 - "MIT"  
673 - ],  
674 - "authors": [  
675 - {  
676 - "name": "Kyle Robinson Young",  
677 - "email": "kyle@dontkry.com",  
678 - "homepage": "https://github.com/shama"  
679 - }  
680 - ],  
681 - "description": "A multi-framework Composer library installer",  
682 - "homepage": "http://composer.github.com/installers/",  
683 - "keywords": [  
684 - "Craft",  
685 - "Dolibarr",  
686 - "Hurad",  
687 - "MODX Evo",  
688 - "OXID",  
689 - "SMF",  
690 - "Thelia",  
691 - "WolfCMS",  
692 - "agl",  
693 - "aimeos",  
694 - "annotatecms",  
695 - "bitrix",  
696 - "cakephp",  
697 - "chef",  
698 - "codeigniter",  
699 - "concrete5",  
700 - "croogo",  
701 - "dokuwiki",  
702 - "drupal",  
703 - "elgg",  
704 - "fuelphp",  
705 - "grav",  
706 - "installer",  
707 - "joomla",  
708 - "kohana",  
709 - "laravel",  
710 - "lithium",  
711 - "magento",  
712 - "mako",  
713 - "mediawiki",  
714 - "modulework",  
715 - "moodle",  
716 - "phpbb",  
717 - "piwik",  
718 - "ppi",  
719 - "puppet",  
720 - "roundcube",  
721 - "shopware",  
722 - "silverstripe",  
723 - "symfony",  
724 - "typo3",  
725 - "wordpress",  
726 - "zend",  
727 - "zikula"  
728 - ],  
729 - "time": "2015-02-18 17:17:01"  
730 - },  
731 - {  
732 "name": "fzaninotto/faker", 783 "name": "fzaninotto/faker",
733 "version": "v1.5.0", 784 "version": "v1.5.0",
734 "source": { 785 "source": {
@@ -815,55 +866,6 @@ @@ -815,55 +866,6 @@
815 "time": "2013-11-01 13:02:21" 866 "time": "2013-11-01 13:02:21"
816 }, 867 },
817 { 868 {
818 - "name": "silverstripe/framework",  
819 - "version": "3.1.13",  
820 - "source": {  
821 - "type": "git",  
822 - "url": "https://github.com/silverstripe/silverstripe-framework.git",  
823 - "reference": "04b803dfc6dc60f2e6a38fa74f957156230b54be"  
824 - },  
825 - "dist": {  
826 - "type": "zip",  
827 - "url": "https://api.github.com/repos/silverstripe/silverstripe-framework/zipball/04b803dfc6dc60f2e6a38fa74f957156230b54be",  
828 - "reference": "04b803dfc6dc60f2e6a38fa74f957156230b54be",  
829 - "shasum": ""  
830 - },  
831 - "require": {  
832 - "composer/installers": "*",  
833 - "php": ">=5.3.2"  
834 - },  
835 - "require-dev": {  
836 - "phpunit/phpunit": "~3.7@stable"  
837 - },  
838 - "type": "silverstripe-module",  
839 - "autoload": {  
840 - "classmap": [  
841 - "tests/behat/features/bootstrap"  
842 - ]  
843 - },  
844 - "notification-url": "https://packagist.org/downloads/",  
845 - "license": [  
846 - "BSD-3-Clause"  
847 - ],  
848 - "authors": [  
849 - {  
850 - "name": "SilverStripe",  
851 - "homepage": "http://silverstripe.com"  
852 - },  
853 - {  
854 - "name": "The SilverStripe Community",  
855 - "homepage": "http://silverstripe.org"  
856 - }  
857 - ],  
858 - "description": "The SilverStripe framework",  
859 - "homepage": "http://silverstripe.org",  
860 - "keywords": [  
861 - "framework",  
862 - "silverstripe"  
863 - ],  
864 - "time": "2015-05-28 06:59:11"  
865 - },  
866 - {  
867 "name": "yiisoft/yii2-codeception", 869 "name": "yiisoft/yii2-codeception",
868 "version": "2.0.4", 870 "version": "2.0.4",
869 "source": { 871 "source": {
@@ -1058,7 +1060,9 @@ @@ -1058,7 +1060,9 @@
1058 ], 1060 ],
1059 "aliases": [], 1061 "aliases": [],
1060 "minimum-stability": "stable", 1062 "minimum-stability": "stable",
1061 - "stability-flags": [], 1063 + "stability-flags": {
  1064 + "artweb/yii2-multiparser": 20
  1065 + },
1062 "prefer-stable": false, 1066 "prefer-stable": false,
1063 "prefer-lowest": false, 1067 "prefer-lowest": false,
1064 "platform": { 1068 "platform": {
vendor/composer/autoload_psr4.php
@@ -7,6 +7,7 @@ $baseDir = dirname($vendorDir); @@ -7,6 +7,7 @@ $baseDir = dirname($vendorDir);
7 7
8 return array( 8 return array(
9 'yii\\swiftmailer\\' => array($vendorDir . '/yiisoft/yii2-swiftmailer'), 9 'yii\\swiftmailer\\' => array($vendorDir . '/yiisoft/yii2-swiftmailer'),
  10 + 'yii\\multiparser\\' => array($vendorDir . '/artweb/yii2-multiparser/lib'),
10 'yii\\imagine\\' => array($vendorDir . '/yiisoft/yii2-imagine'), 11 'yii\\imagine\\' => array($vendorDir . '/yiisoft/yii2-imagine'),
11 'yii\\gii\\' => array($vendorDir . '/yiisoft/yii2-gii'), 12 'yii\\gii\\' => array($vendorDir . '/yiisoft/yii2-gii'),
12 'yii\\faker\\' => array($vendorDir . '/yiisoft/yii2-faker'), 13 'yii\\faker\\' => array($vendorDir . '/yiisoft/yii2-faker'),
vendor/composer/installed.json
@@ -1043,5 +1043,52 @@ @@ -1043,5 +1043,52 @@
1043 "imagine", 1043 "imagine",
1044 "yii2" 1044 "yii2"
1045 ] 1045 ]
  1046 + },
  1047 + {
  1048 + "name": "artweb/yii2-multiparser",
  1049 + "version": "dev-master",
  1050 + "version_normalized": "9999999-dev",
  1051 + "source": {
  1052 + "type": "git",
  1053 + "url": "https://github.com/tsurkanovm/yii-multiparser.git",
  1054 + "reference": "7a3cd2728c4b0c9db1b6bcea411f8df87b69ecd3"
  1055 + },
  1056 + "dist": {
  1057 + "type": "zip",
  1058 + "url": "https://api.github.com/repos/tsurkanovm/yii-multiparser/zipball/7a3cd2728c4b0c9db1b6bcea411f8df87b69ecd3",
  1059 + "reference": "7a3cd2728c4b0c9db1b6bcea411f8df87b69ecd3",
  1060 + "shasum": ""
  1061 + },
  1062 + "require": {
  1063 + "yiisoft/yii2": "*"
  1064 + },
  1065 + "time": "2015-10-26 10:04:39",
  1066 + "type": "library",
  1067 + "installation-source": "dist",
  1068 + "autoload": {
  1069 + "psr-4": {
  1070 + "yii\\multiparser\\": "lib\\"
  1071 + }
  1072 + },
  1073 + "notification-url": "https://packagist.org/downloads/",
  1074 + "license": [
  1075 + "MIT"
  1076 + ],
  1077 + "authors": [
  1078 + {
  1079 + "name": "Mihail Tsurkanov",
  1080 + "email": "tsurkanovm@gmail.com",
  1081 + "role": "Developer"
  1082 + }
  1083 + ],
  1084 + "description": "This extension provides a Multiparser solution for Yii framework 2.0.",
  1085 + "homepage": "https://github.com/tsurkanovm/yii-multiparser.git",
  1086 + "keywords": [
  1087 + "csv",
  1088 + "parser",
  1089 + "xlsx",
  1090 + "xml",
  1091 + "yii2"
  1092 + ]
1046 } 1093 }
1047 ] 1094 ]
vendor/yiisoft/multiparser/Converter.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 31.08.2015  
6 - * Time: 12:50  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -// класс который содержит преобразователи значений (фильтры) используемые при парсинге  
12 -class Converter implements ConverterInterface  
13 -{  
14 -  
15 - const METHOD_PREFIX = 'convertTo';  
16 -  
17 - //public $configuration = [];  
18 -  
19 - public static function convertToFloat($value)  
20 - {  
21 - if ($value == '') {  
22 - $value = 0;  
23 - }  
24 - $value = trim(str_replace(",", ".", $value));  
25 - $value = preg_replace("/[^0-9.]+/", "", strtoupper($value));  
26 -  
27 - if ($value == '') {  
28 - return '';  
29 - }  
30 - $value = round((float)$value, 2);  
31 -  
32 - return $value;  
33 - }  
34 -  
35 - public static function convertToInteger($value)  
36 - {  
37 - if ($value == '') {  
38 - $value = 0;  
39 - }  
40 - $value = trim(str_replace(",", ".", $value));  
41 - $value = preg_replace("/[^0-9.]+/", "", strtoupper($value));  
42 - if ($value == '') {  
43 - return '';  
44 - }  
45 - $value = round((int)$value, 2);  
46 -  
47 - return $value;  
48 - }  
49 -  
50 - public static function convertToEncode($value)  
51 - {  
52 - $res = $value;  
53 - if (is_array($value)) {  
54 -  
55 - $res = Encoder::encodeArray($value);  
56 -  
57 - } elseif (is_string($value)) {  
58 -  
59 - $res = Encoder::encodeString($value);  
60 -  
61 - }  
62 - return $res;  
63 - }  
64 -  
65 - public static function convertToString($value)  
66 - {  
67 - $convert_func = function ($value_to_convert) {  
68 - return str_replace(array('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '~', '`', '"', "'", ' ', '№', '%', ';', ':', '[', ']', '{', '}', '*', '?', '/', '\'', '|', '.', ',', '<', '>', '\\'), '', $value_to_convert);  
69 - };  
70 -  
71 - if( is_string( $value ) ){  
72 - $value = $convert_func( $value );  
73 - }  
74 -  
75 - if( is_array( $value ) ){  
76 - array_walk( $value, $convert_func );  
77 - }  
78 -  
79 - return $value;  
80 - }  
81 -  
82 - /**  
83 - * @param $name - имя метода конвертации  
84 - * @param $value - значение на конвертацию  
85 - * @return mixed  
86 - */  
87 - public static function __callStatic($name, $value)  
88 - {  
89 - $method_name = self::METHOD_PREFIX . $name;  
90 -  
91 - if (method_exists(static::class, $method_name)) {  
92 - return static::$method_name($value[0]);  
93 -  
94 - } else {  
95 - // если такого метода конвертации не предусмотрено, то возвращаем не конвертируя  
96 - return $value[0];  
97 -  
98 - }  
99 - }  
100 -  
101 - public function __call($name, $params)  
102 - {  
103 - return self::__callStatic($name, $params);  
104 - }  
105 -  
106 -  
107 - /**  
108 - * @param $arr - массив для конвертирования  
109 - * @param $configuration - массив конфигурация конвертирования  
110 - * @return mixed  
111 - * конвертирует массив по полученным настройкам, вызывая последовательно функции конвертации (указанные в конфигурации)  
112 - */  
113 - public static function convertByConfiguration($arr, $configuration)  
114 - {  
115 - if ($hasKey = isset($configuration['hasKey']))  
116 - unset($configuration['hasKey']);  
117 -  
118 - if (isset($configuration['configuration'])) {  
119 - $arr_config = $configuration['configuration'];  
120 - unset($configuration['configuration']);  
121 - } else {  
122 - throw new \Exception('Не указан обязательный параметр конфигурационного файла - converter_conf[configuration]');  
123 - }  
124 -  
125 - // проставим аттрибуты из конфига{}{}  
126 - self::setAttributes($configuration);  
127 -  
128 - foreach ($arr_config as $key => $value) {  
129 - if ($hasKey) {  
130 - // у нас ассоциативный массив, и мы можем конвертировать каждое значение в отдельности  
131 - if (is_array($value)) {  
132 - //если пустой массив то конвертируем всю строку  
133 - if (count($value) === 0) {  
134 -  
135 - $arr = self::$key($arr);  
136 - continue;  
137 - }  
138 - // иначе конвертируем каждую ячейку в отдельности  
139 - foreach ($value as $sub_value) {  
140 - if (isset($arr[$sub_value])) {  
141 - // конвертируем только те ячейки которые сопоставлены в прочитанном массиве с колонками в конфигурационном файле  
142 - $arr[$sub_value] = self::$key($arr[$sub_value]);  
143 - }  
144 -  
145 - }  
146 - } else {  
147 -  
148 - if (isset($arr[$value])) {  
149 - // конвертируем только те ячейки которые сопоставлены в прочитанном массиве с колонками в конфигурационном файле  
150 - $arr[$value] = self::$key($arr[$value]);  
151 - // CustomVarDamp::dump($result);  
152 - }  
153 -  
154 - }  
155 -  
156 - } else {  
157 - // нет заголовка - мы можем конвертировать только строку в целом  
158 - $arr = self::$key($arr);  
159 - }  
160 -  
161 - }  
162 -  
163 - return $arr;  
164 - }  
165 -  
166 - public static function setAttributes($configuration)  
167 - {  
168 - foreach ($configuration as $key_setting => $setting) {  
169 - if (property_exists(static::class, $key_setting))  
170 - static::$$key_setting = $setting;  
171 - }  
172 -  
173 - }  
174 -  
175 -  
176 -}  
177 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/ConverterInterface.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Tsurkanov  
5 - * Date: 20.10.2015  
6 - * Time: 13:38  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -  
12 -interface ConverterInterface {  
13 -  
14 - public static function convertByConfiguration( $arr_values_to_convert, $configuration );  
15 -  
16 -}  
17 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/CsvParser.php deleted
1 -<?php  
2 -/**  
3 -  
4 - */  
5 -namespace yii\multiparser;  
6 -use common\components\CustomVarDamp;  
7 -  
8 -  
9 -/**  
10 - * Class CsvParser  
11 - * @package yii\multiparser  
12 - * @todo - перевести на анг. яз.  
13 - */  
14 -class CsvParser extends TableParser  
15 -{  
16 - /** @var string - разделитель csv */  
17 - public $delimiter = ';';  
18 -  
19 -  
20 -  
21 - /**  
22 - * метод устанвливает нужные настройки объекта SplFileObject, для работы с csv  
23 - */  
24 - public function setup()  
25 - {  
26 -  
27 - $this->file->setCsvControl($this->delimiter);  
28 - $this->file->setFlags(\SplFileObject::READ_CSV);  
29 - $this->file->setFlags(\SplFileObject::SKIP_EMPTY);  
30 -  
31 - parent::setup();  
32 -  
33 - }  
34 -  
35 - public function read()  
36 - {  
37 - parent::read();  
38 -  
39 - return $this->result;  
40 - }  
41 -  
42 -  
43 - protected function readRow( )  
44 - {  
45 - $this->row = $this->file->fgetcsv();  
46 - }  
47 -  
48 - protected function isEmptyRow(){  
49 -  
50 - $is_empty = false;  
51 -  
52 - if ($this->row === false || $this->row === NULL ) {  
53 - return true;  
54 - }  
55 -  
56 - $j = 0;  
57 - for ($i = 1; $i <= count( $this->row ); $i++) {  
58 -  
59 - if ( $this->isEmptyColumn( $this->row[$i - 1] ) ) {  
60 - $j++;  
61 - }  
62 -  
63 - if ( $j >= $this->min_column_quantity ) {  
64 - $is_empty = true;  
65 - break;  
66 - }  
67 - }  
68 -  
69 - return $is_empty;  
70 - }  
71 -  
72 - protected function isEmptyColumn( $val ){  
73 - return $val == '';  
74 - }  
75 -}  
76 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/DynamicFormHelper.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 08.09.2015  
6 - * Time: 14:50  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -use yii\base\DynamicModel;  
12 -use yii\grid\GridView;  
13 -use yii\grid\SerialColumn;  
14 -use yii\helpers\ArrayHelper;  
15 -  
16 -/**  
17 - * Class DynamicFormHelper  
18 - * @package backend\components\parsers  
19 - * Содержит процедуры генерации компонентов с динамическим количеством аттрибутов  
20 - */  
21 -class DynamicFormHelper  
22 -{  
23 -  
24 - const KEY_PREFIX = 'attr_';  
25 -  
26 - /**  
27 - * @param $source - int or array  
28 - * если передан массив, то создается модель с атрибутами переданными в массиве,  
29 - * ключ - имя, значение - значение аттрибута  
30 - * если передано число, то создается переданное количество аттрибутов с именами - attr_0, attr_1...  
31 - */  
32 - public static function CreateDynamicModel( $source )  
33 - {  
34 - $arr_keys = [];  
35 - if (is_array($source)) {  
36 - $arr_keys = $source;  
37 - } elseif (is_int($source)) {  
38 -  
39 - $i = 0;  
40 - while ($source > $i) {  
41 - $arr_keys[] = self::KEY_PREFIX . $i;  
42 - $i++;  
43 - }  
44 - array_flip($arr_keys);  
45 -  
46 - }  
47 -  
48 - $model = new DynamicModel($arr_keys);  
49 -  
50 - return $model;  
51 - }  
52 -  
53 - // @todo add comments  
54 - public static function CreateGridWithDropDownListHeader( $dataProvider, $form, $header_model, $arr_header_values )  
55 - {  
56 - $columns_config = [['class' => SerialColumn::className()]];  
57 - $i = 0;  
58 - foreach( $header_model as $key => $value ) {  
59 -  
60 - $columns_config[] = ['header' => $form->field($header_model, $key, ['inputOptions' => ['label' => '']])->dropDownList($arr_header_values), 'attribute' => $i];  
61 - $i++;  
62 - }  
63 - $dynamic_grid_view = GridView::widget( ['dataProvider' => $dataProvider,  
64 - 'columns' => $columns_config ] );  
65 -  
66 - return $dynamic_grid_view;  
67 -  
68 - }  
69 -  
70 -}  
71 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/Encoder.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 27.08.2015  
6 - * Time: 13:36  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -// @todo add comments  
12 -class Encoder  
13 -{  
14 - /** @var out encoding charset */  
15 - public static $out_charset = 'UTF-8';  
16 - /** @var out encoding charset */  
17 - public static $in_charset = 'windows-1251';  
18 -  
19 - public static function encodeFile($in_charset, $out_charset, $filePath)  
20 - {  
21 -  
22 - $old_content = file_get_contents($filePath);  
23 - $encode_content = self::encodeString( $old_content, $in_charset, $out_charset );  
24 - $file = @fopen($filePath, "w");  
25 - fwrite($file, $encode_content);  
26 - @fclose($file);  
27 - }  
28 -  
29 - public static function encodeArray( $array, $in_charset = '', $out_charset = '')  
30 - {  
31 - if ($in_charset)  
32 - self::$in_charset = $in_charset;  
33 -  
34 - if ($out_charset)  
35 - self::$out_charset = $out_charset;  
36 -  
37 - $result = array_map(  
38 - function ($value) {  
39 -  
40 - return self::encodeString( $value, self::$in_charset, self::$out_charset );  
41 -  
42 - },  
43 - $array);  
44 -  
45 - return $result;  
46 - }  
47 -  
48 - public static function encodeString( $source, $in_charset = '', $out_charset = '' ){  
49 -  
50 - if ($in_charset)  
51 - self::$in_charset = $in_charset;  
52 -  
53 - if ($out_charset)  
54 - self::$out_charset = $out_charset;  
55 -  
56 - return iconv( self::$in_charset, self::$out_charset, $source );  
57 -  
58 - }  
59 -}  
60 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/ObjectCreator.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Tsurkanov  
5 - * Date: 20.10.2015  
6 - * Time: 16:24  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -  
12 -use common\components\CustomVarDamp;  
13 -  
14 -class ObjectCreator {  
15 - public static function build( array $configuration ){  
16 - if ( isset( $configuration['class'] ) ) {  
17 - $class = trim( $configuration['class'] );  
18 - unset( $configuration['class'] );  
19 - } else{  
20 - throw new \ErrorException('Error configuration - undefined class');  
21 - }  
22 -  
23 - $object = new $class();  
24 - foreach ($configuration as $name => $value) {  
25 - $object->$name = $value;  
26 - }  
27 -  
28 - return $object;  
29 - }  
30 -}  
31 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/Parser.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 04.09.2015  
6 - * Time: 18:25  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -//@todo - заменить read на parse  
12 -//@todo - xml - убрать из названий функций xml и array - это и так понятно  
13 -  
14 -  
15 -use common\components\CustomVarDamp;  
16 -  
17 -abstract class Parser  
18 -{  
19 - public $converter_conf = [];  
20 - protected $converter = NULL;  
21 -  
22 - /**  
23 - * @var array - результирующий массив с отпарсенными значениями  
24 - */  
25 - protected $result = [];  
26 -  
27 - /** @var array - массив с заголовком,  
28 - * */  
29 - public $keys = NULL;  
30 - /** @var bool  
31 - имеет ли файл заголовок который будет установлен ключами возвращемого массива*/  
32 - public $has_header_row = false;  
33 -  
34 - /** @var экземляр SplFileObject читаемого файла */  
35 - public $file;  
36 -  
37 -  
38 -  
39 - public function setup()  
40 - {  
41 - $this->setupConverter();  
42 - }  
43 -  
44 - protected function setupConverter()  
45 - {  
46 - if ( $this->has_header_row || $this->keys !== NULL ) {  
47 - // если у файла есть заголовок, то в результате имеем ассоциативный массив  
48 - $this->converter_conf['hasKey'] = 1;  
49 - }  
50 -  
51 - if ( $this->converter_conf ) {  
52 - $converter = ObjectCreator::build( $this->converter_conf );  
53 - if ( $converter instanceof ConverterInterface ) {  
54 -  
55 - $this->converter = $converter;  
56 -  
57 - }  
58 - }  
59 -  
60 -  
61 - }  
62 -  
63 - public abstract function read();  
64 -  
65 - /**  
66 - * @param $arr  
67 - * @return mixed  
68 - * преобразовует значения прочитанного массива в нужные типы, согласно конфигурации конвертера  
69 - */  
70 - protected function convert( $arr )  
71 - {  
72 -  
73 - if ($this->converter !== NULL) {  
74 -  
75 - $arr = $this->converter->convertByConfiguration( $arr, $this->converter_conf );  
76 -  
77 - }  
78 -  
79 -  
80 - return $arr;  
81 -  
82 - }  
83 -}  
84 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/ParserHandler.php deleted
1 -<?php  
2 -  
3 -namespace yii\multiparser;  
4 -  
5 -use common\components\CustomVarDamp;  
6 -  
7 -class ParserHandler  
8 -{  
9 - //@todo - добавить комменты на анг язе (ошибки выкидывать тоже на англ яз.)  
10 - //@todo - сделать универсальную обработку ошибок  
11 - //@todo - возможно отказаться от YiiParserHandler  
12 - const DEFAULT_MODE = 'web';  
13 - /** @var string */  
14 - protected $filePath;  
15 -  
16 - /** @var string */  
17 - protected $configuration = [];  
18 - /** @var string */  
19 - protected $custom_configuration = [];  
20 -  
21 - /** @var instance of SplFileObject */  
22 - protected $fileObject;  
23 -  
24 - /** @var string - extension of file $filePath */  
25 - protected $extension;  
26 -  
27 - /** @var string - */  
28 - protected $mode;  
29 -  
30 - /** @var string - */  
31 - protected $options;  
32 -  
33 - /**  
34 - * @param string first line in file for parsing  
35 - */  
36 - public function setup($filePath, $options = [])  
37 - {  
38 - $this->filePath = $filePath;  
39 - if (isset($options['mode'])) {  
40 -  
41 - $this->mode = $options['mode'];  
42 - unset($options['mode']);  
43 -  
44 - } else {  
45 -  
46 - $this->mode = self::DEFAULT_MODE;  
47 -  
48 - }  
49 -  
50 - $this->options = $options;  
51 -  
52 - $this->fileObject = new \SplFileObject($this->filePath, 'r');  
53 -  
54 - $options['file'] = $this->fileObject;  
55 - $this->extension = $this->fileObject->getExtension();  
56 -  
57 - $this->custom_configuration = $this->getCustomConfiguration($this->extension, $this->mode);  
58 - $this->custom_configuration = array_merge_recursive($this->custom_configuration, $options);  
59 -  
60 - }  
61 -  
62 - public function run()  
63 - {  
64 - $result = [];  
65 - if (count($this->custom_configuration)) {  
66 -  
67 - $parser = $this->createObjectByConfiguration($this->custom_configuration);  
68 -  
69 - try {  
70 -  
71 - $parser->setup();  
72 - $result = $parser->read();  
73 -  
74 - } catch (\ErrorException $e) {  
75 -  
76 - echo $e->getMessage();  
77 -  
78 - }  
79 -  
80 - }  
81 -  
82 - return $result;  
83 - }  
84 -  
85 - public function getCustomConfiguration($extension, $parameter)  
86 - {  
87 - if (!count($this->configuration)) {  
88 - $this->setConfiguration(require(__DIR__ . '/config.php'));  
89 - }  
90 -  
91 - if (!isset($this->configuration[$extension])) {  
92 - throw new \ErrorException("Parser do not maintain file with extension {$extension}");  
93 - }  
94 - if (!isset($this->configuration[$extension][$parameter])) {  
95 - throw new \ErrorException("Parser configurator do not have settings for {$parameter} parameter");  
96 - }  
97 -  
98 - return $this->configuration[$extension][$parameter];  
99 - }  
100 -  
101 - public function setConfiguration($configuration)  
102 - {  
103 - $this->configuration = $configuration;  
104 - }  
105 -  
106 - protected function createObjectByConfiguration($configuration)  
107 - {  
108 - return ObjectCreator::build($configuration);  
109 - }  
110 -}  
111 -  
112 -  
vendor/yiisoft/multiparser/TableParser.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Tsurkanov  
5 - * Date: 22.10.2015  
6 - * Time: 15:53  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -  
12 -use common\components\CustomVarDamp;  
13 -  
14 -abstract class TableParser extends Parser {  
15 -  
16 -  
17 - /**  
18 - * @var array - текущий отпарсенный ряд  
19 - */  
20 - protected $row = [];  
21 -  
22 - /** @var int - первая строка с которой начинать парсить */  
23 - public $first_line = 0;  
24 -  
25 - /** @var int - последняя строка до которой парсить  
26 - * если не указана, то парсинг происходит до конца файла*/  
27 - public $last_line = 0;  
28 -  
29 - /** @var int - первая колонка файла с которой начнется парсинг */  
30 - public $first_column = 0;  
31 -  
32 -  
33 - /** @var bool  
34 - нужно ли искать автоматически первоую значисмую строку (не пустая строка)  
35 - * иначе первая строка будет взята из аттрибута $first_line */  
36 - public $auto_detect_first_line = false;  
37 -  
38 - /** @var int - количество значимых колонок, что бы определить первую значимую строку  
39 - * используется при автоопределении первой строки*/  
40 - public $min_column_quantity = 5;  
41 - /** @var int - количество пустых строк, что бы определить конец файла,  
42 - такое количеество подряд пустых строк считается концом файла*/  
43 - public $empty_lines_quantity = 3;  
44 -  
45 -  
46 - /** @var int - номер текущей строки парсера */  
47 - protected $current_row_number = 0;  
48 -  
49 -  
50 - protected abstract function isEmptyRow();  
51 -  
52 - protected abstract function isEmptyColumn($column_value);  
53 -  
54 - protected abstract function readRow();  
55 -  
56 -  
57 - public function read()  
58 - {  
59 - if ($this->auto_detect_first_line) {  
60 - $this->shiftToFirstValuableLine();  
61 - }  
62 -  
63 - // будем считать количество пустых строк подряд - при достижении $empty_lines_quantity - считаем что это конец файла и выходим  
64 - $empty_lines = 0;  
65 - while ( $empty_lines < $this->empty_lines_quantity ) {  
66 - // прочтем строку из файла  
67 - $this->readRow();  
68 -  
69 - if ( $this->isEmptyRow() ) {  
70 - //счетчик пустых строк  
71 - $empty_lines++;  
72 - continue;  
73 - }  
74 -  
75 - // уберем пустые колонки из ряда  
76 - $this->filterRow();  
77 -  
78 -  
79 - $this->adjustRowToSettings( );  
80 -  
81 - // строка не пустая, имеем прочитанный массив значений  
82 - $this->current_row_number++;  
83 -  
84 - // для первой строки утановим ключи из заголовка  
85 - $this->setKeysFromHeader();  
86 -  
87 - // если у нас установлен лимит, при его достижении прекращаем парсинг  
88 - if ( $this->isLastLine() )  
89 - break;  
90 -  
91 - // обнуляем счетчик, так как считаюся пустые строки ПОДРЯД  
92 - $empty_lines = 0;  
93 -  
94 - $this->result[] = $this->row;  
95 - $this->row = [];  
96 -  
97 - }  
98 -  
99 -  
100 - }  
101 - /**  
102 - * определяет первую значимую строку,  
103 - * считывается файл пока в нем не встретится строка с непустыми колонками  
104 - * в количестве указанном в атрибуте min_column_quantity  
105 - * в результате выполнения $current_row_number будет находится на последней незначимой строке  
106 - */  
107 - protected function shiftToFirstValuableLine()  
108 - {  
109 - do {  
110 -  
111 - $this->current_row_number ++;  
112 - $this->readRow();  
113 -  
114 - } while( $this->isEmptyRow() );  
115 -  
116 - // @todo - сделать опционально  
117 - // код для того что бы парсить первую строку, закомментировано как предполагается что первая значимая строка это заголовок  
118 - // $this->current_row_number --;  
119 -// $this->file->seek( $this->current_row_number );  
120 - }  
121 -  
122 - /**  
123 - * @return array - одномерный массив результата парсинга строки  
124 - */  
125 - protected function adjustRowToSettings( )  
126 - {  
127 -  
128 - // если есть заголовок, то перед конвертацией его нужно назначить  
129 - if ( $this->keys !== NULL ) {  
130 -  
131 - if (count($this->keys) !== count($this->row)) {  
132 - throw new \Exception("Ошибка парсинга файла в строке # {$this->current_row_number}. Не соответсвие числа ключевых колонок (заголовка) - числу колонок с данными", 0, 1, $this->file->getBasename(), $this->current_row_number);  
133 - }  
134 -  
135 - $this->row = array_combine($this->keys, $this->row);  
136 - }  
137 -  
138 - // попытаемся конвертировать прочитанные значения согласно конфигурации котнвертера значений  
139 - $this->row = $this->convert($this->row);  
140 -  
141 - // обрежем массив к первой значимой колонке  
142 - if ( $this->first_column ) {  
143 -  
144 - $this->row = array_slice($this->row, $this->first_column);  
145 -  
146 - }  
147 -  
148 - }  
149 -  
150 - protected function setKeysFromHeader(){  
151 - if ( $this->has_header_row ) {  
152 - // в файле есть заголовок, но он еще не назначен - назначим  
153 - if ($this->keys === NULL) {  
154 - $this->keys = array_values( $this->row );  
155 - }  
156 - }  
157 - }  
158 -  
159 - protected function filterRow(){  
160 - $this->row = array_filter( $this->row, function($val){  
161 - return !$this->isEmptyColumn($val);  
162 - });  
163 - }  
164 -  
165 - protected function isLastLine(){  
166 -  
167 - if ( ( $this->last_line ) && ( $this->current_row_number > $this->last_line ) ) {  
168 - return true;  
169 - }  
170 - return false;  
171 - }  
172 -  
173 -}  
174 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/XlsxParser.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Tsurkanov  
5 - * Date: 21.10.2015  
6 - * Time: 15:44  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -  
12 -use common\components\CustomVarDamp;  
13 -  
14 -  
15 -/**  
16 - * Class XlsxParser  
17 - * @package yii\multiparser  
18 - */  
19 -class XlsxParser extends TableParser {  
20 -  
21 - /**  
22 - * @var string - путь куда будут распаковываться файлы, если не указанно - во временный каталог сервера  
23 - */  
24 - public $path_for_extract_files = '';  
25 -  
26 -  
27 - /**  
28 - * @var int - если указано то считывание будет производиться с этого листа, иначе со всех листов  
29 - * при чтении со всех листов - выходной массив будет иметь номера листов первыми элементами  
30 - */  
31 - public $active_sheet = 0;  
32 -  
33 - protected $strings_arr = [];  
34 - protected $sheets_arr = [];  
35 -  
36 - protected $current_node;  
37 - protected $current_sheet;  
38 -  
39 - public function setup()  
40 - {  
41 -  
42 - parent::setup();  
43 -  
44 - if ( $this->path_for_extract_files == '' ) {  
45 - $this->path_for_extract_files = sys_get_temp_dir();  
46 - }  
47 - }  
48 -  
49 -  
50 - public function read()  
51 - {  
52 -  
53 - // $this->extractFiles();  
54 -  
55 - $this->readSheets();  
56 - $this->readStrings();  
57 -  
58 - foreach ( $this->sheets_arr as $sheet ) {  
59 - //проходим по всем файлам из директории /xl/worksheets/  
60 -  
61 - $sheet_path = $this->path_for_extract_files . '/xl/worksheets/' . $sheet . '.xml';  
62 - if ( file_exists( $sheet_path ) && is_readable( $sheet_path ) ) {  
63 -  
64 - $xml = simplexml_load_file( $sheet_path, "SimpleXMLIterator" );  
65 - $this->current_node = $xml->sheetData->row;  
66 - $this->current_node->rewind();  
67 -  
68 - parent::read();  
69 -  
70 - }  
71 -  
72 - }  
73 -CustomVarDamp::dumpAndDie($this->$result);  
74 - // return $this->$result_arr;  
75 - }  
76 -  
77 - protected function extractFiles ()  
78 - {  
79 - $zip = new \ZipArchive;  
80 - if ( $zip->open( $this->file->getPathname() ) === TRUE ) {  
81 - $zip->extractTo( $this->path_for_extract_files );  
82 - $zip->close();  
83 - } else {  
84 - throw new \Exception( 'Ошибка чтения xlsx файла' );  
85 - }  
86 - }  
87 -  
88 - protected function readSheets ()  
89 - {  
90 - if ( $this->active_sheet ) {  
91 - $this->sheets_arr[ $this->active_sheet ] = 'Sheet' . $this->active_sheet;  
92 - return;  
93 - }  
94 -  
95 - $xml = simplexml_load_file( $this->path_for_extract_files . '/xl/workbook.xml' );  
96 - foreach ( $xml->sheets->children() as $sheet ) {  
97 - $sheet_name = '';  
98 - $sheet_id = 0;  
99 - $attr = $sheet->attributes();  
100 - foreach ( $attr as $name => $value ) {  
101 - if ($name == 'name')  
102 - $sheet_name = (string)$value;  
103 -  
104 - if ($name == 'sheetId')  
105 - $sheet_id = $value;  
106 -  
107 - }  
108 - if ( $sheet_name && $sheet_id ) {  
109 - $this->sheets_arr[$sheet_name] = 'Sheet' . $sheet_id;  
110 - }  
111 -//  
112 - }  
113 - }  
114 -  
115 - protected function readStrings ()  
116 - {  
117 - $xml = simplexml_load_file( $this->path_for_extract_files . '/xl/sharedStrings.xml' );  
118 - foreach ( $xml->children() as $item ) {  
119 - $this->strings_arr[] = (string)$item->t;  
120 - }  
121 - }  
122 -  
123 -  
124 -  
125 - // protected function readRow ( $item, $sheet , $current_row )  
126 - protected function readRow ( )  
127 - {  
128 - $node = $this->current_node->getChildren();  
129 -  
130 - foreach ( $node as $child ) {  
131 - $attr = $child->attributes();  
132 -  
133 - if( isset($child->v) ) {  
134 - $value = (string)$child->v;  
135 - }else{  
136 - $value = '';  
137 - }  
138 - if ( isset( $attr['t'] ) ) {  
139 - // $this->result_arr[$sheet][$current_row][$cell] = $this->strings_arr[ $value ];  
140 - $this->row[] = $this->strings_arr[ $value ];  
141 - }else{  
142 - // $this->result_arr[$sheet][$current_row][$cell] = $value;  
143 - $this->row[] = $value;  
144 - }  
145 -  
146 - }  
147 - $this->current_node->next();  
148 - CustomVarDamp::dump($this->row);  
149 - }  
150 -  
151 - protected function isEmptyRow(){  
152 -  
153 - $is_empty = false;  
154 -  
155 - if ( !count( $this->row ) || !$this->current_node->valid() ) {  
156 - return true;  
157 - }  
158 -  
159 - $j = 0;  
160 - for ($i = 1; $i <= count( $this->row ); $i++) {  
161 -  
162 - if ( $this->isEmptyColumn( $this->row[$i - 1] ) ) {  
163 - $j++;  
164 - }  
165 -  
166 - if ( $j >= $this->min_column_quantity ) {  
167 - $is_empty = true;  
168 - break;  
169 - }  
170 - }  
171 -  
172 - return $is_empty;  
173 - }  
174 -  
175 - protected function isEmptyColumn( $val ){  
176 - return $val == '';  
177 - }  
178 -}  
179 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/XmlParser.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 10.09.2015  
6 - * Time: 17:47  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -  
12 -use common\components\CustomVarDamp;  
13 -use common\components\CustomArrayHelper;  
14 -  
15 -class XmlParser extends Parser{  
16 -  
17 - public $node;  
18 -  
19 - public function read()  
20 - {  
21 - $file = $this->file;  
22 - $result = $this->xmlToArray( $file->getPathname() );  
23 -  
24 - if ( isset($this->node) ) {  
25 -  
26 - $result = $result[ $this->node ];  
27 -  
28 - }  
29 -  
30 - return $result;  
31 - }  
32 -  
33 -  
34 - /**  
35 - * Converts an XML string to a PHP array  
36 - *  
37 - * @uses recursiveXMLToArray()  
38 - * @param string $file_path  
39 - * @return array  
40 - */  
41 - protected function xmlToArray( $file_path ) {  
42 -  
43 - try {  
44 - $xml = new \SimpleXMLElement( $file_path, 0, true );  
45 - //\common\components\CustomVarDamp::dumpAndDie($xml->children()->children());  
46 - $result = $this->recursiveXMLToArray( $xml );  
47 - } catch(Exception $ex) {  
48 -  
49 - throw $ex;  
50 - }  
51 -  
52 - return $result;  
53 - }  
54 -  
55 - /**  
56 - * Convert a XML string to a PHP array recursively. Do not  
57 - * call this function directly  
58 - *  
59 - * @param SimpleXMLElement  
60 - *  
61 - * @return mixed  
62 - */  
63 - protected function recursiveXMLToArray($xml) {  
64 - if( $xml instanceof \SimpleXMLElement ) {  
65 - $attributes = $xml->attributes();  
66 -  
67 - foreach( $attributes as $key => $value ) {  
68 - if( $value ) {  
69 - $attribute_array[$key] = (string) $value;  
70 - }  
71 - }  
72 - $previous_xml = $xml;  
73 - $xml = get_object_vars($xml);  
74 - }  
75 -  
76 - if(is_array($xml)) {  
77 -  
78 - if( count($xml) == 0 )  
79 - return (string) $previous_xml; // for CDATA  
80 -  
81 - foreach($xml as $key => $value) {  
82 - $row[$key] = $this->recursiveXMLToArray($value);  
83 - }  
84 - if ( is_string($value) ) {  
85 - // дошли до конца рекурсии  
86 - // преобразуем ряд согласно конфигурации  
87 - if ( $this->keys !== NULL ) {  
88 - // назначим ключи из конфигурации, согласно массиву $keys  
89 - $row = $this->compareArrayWithKeys( $row );  
90 - }  
91 - $row = $this->convert( $row );  
92 -  
93 - }  
94 -  
95 -  
96 - if( isset( $attribute_array ) )  
97 - $row['@'] = $attribute_array; // Attributes  
98 -  
99 - return $row;  
100 - }  
101 - return (string) $xml;  
102 - }  
103 -  
104 - /**  
105 - * @param array $value_arr - текущий ряд, массив, которому нужно назначить конфигурационные ключи ($keys)  
106 - * @return array  
107 - */  
108 - protected function compareArrayWithKeys( array $value_arr ){  
109 - $res = $this->keys;  
110 - foreach ( $this->keys as $key => $value ) {  
111 - if ( array_key_exists( $value, $value_arr ) ) {  
112 - $res[$key] = $value_arr[$value];  
113 - }  
114 - }  
115 - return $res;  
116 - }  
117 -  
118 -}  
119 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/YiiConverter.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 07.09.2015  
6 - * Time: 15:56  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -use common\components\CustomVarDamp;  
12 -use yii\base\Component;  
13 -use yii\base\ErrorException;  
14 -  
15 -  
16 -class YiiConverter extends Component{  
17 -  
18 -public $configuration;  
19 -public $converter;  
20 -  
21 - public function init()  
22 - {  
23 - parent::init();  
24 - $converter = \Yii::createObject( $this->configuration );  
25 - if ( $converter instanceof ConverterInterface ) {  
26 -  
27 - $this->converter = $converter;  
28 - }else{  
29 - throw new ErrorException('Wrong type of converter');  
30 - }  
31 -  
32 -  
33 - }  
34 -  
35 - public function convertTo( $method, $value, $attributes = [] ){  
36 -  
37 - if ( $attributes ) {  
38 - $this->converter->setAttributes($attributes);  
39 - }  
40 - return $this->converter->$method( $value );  
41 -  
42 - }  
43 -  
44 - public function convertByConfiguration( $value, $configuration ){  
45 -  
46 - return $this->converter->convertByConfiguration( $value, $configuration );  
47 -  
48 - }  
49 -  
50 -  
51 -}  
52 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/YiiMultiparser.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 07.09.2015  
6 - * Time: 15:56  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -use common\components\CustomVarDamp;  
12 -use yii\base\Component;  
13 -  
14 -  
15 -  
16 -  
17 -class YiiMultiparser extends Component{  
18 -  
19 -public $configuration;  
20 -public $parserHandler;  
21 -  
22 - public function init()  
23 - {  
24 - parent::init();  
25 - $this->parserHandler = new YiiParserHandler( );  
26 - $this->parserHandler->setConfiguration( $this->configuration );  
27 -  
28 - }  
29 -  
30 -  
31 - public function parse( $filePath, $options = [] ){  
32 -  
33 - $this->parserHandler->setup( $filePath, $options );  
34 -  
35 - return $this->parserHandler->run();  
36 -  
37 - }  
38 -  
39 - public function getConfiguration( $extension, $parameter ){  
40 -  
41 - return $this->parserHandler->getCustomConfiguration( $extension, $parameter );  
42 -  
43 - }  
44 -  
45 -}  
46 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/YiiParserHandler.php deleted
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Cibermag  
5 - * Date: 07.09.2015  
6 - * Time: 15:53  
7 - */  
8 -  
9 -namespace yii\multiparser;  
10 -  
11 -  
12 -use common\components\CustomVarDamp;  
13 -  
14 -class YiiParserHandler extends ParserHandler{  
15 -  
16 -  
17 - /**  
18 - * @param $filePath  
19 - * @param array $options  
20 - * проверяет читабельность переданного файла, а также наличие настроек парсера в конфигурационном файле для данного типа файла  
21 - */  
22 -// public function setup($filePath, $options = [])  
23 -// {  
24 -// $this->filePath = $filePath;  
25 -// if (isset($options['mode'])) {  
26 -//  
27 -// $this->mode = $options['mode'];  
28 -// unset($options['mode']);  
29 -//  
30 -// } else {  
31 -//  
32 -// $this->mode = self::DEFAULT_MODE;  
33 -//  
34 -// }  
35 -//  
36 -// $this->options = $options;  
37 -//  
38 -// try {  
39 -// $this->fileObject = new \SplFileObject($this->filePath, 'r');  
40 -// } catch (\ErrorException $e) {  
41 -// // Yii::warning("Ошибка открытия файла {$this->filePath}");  
42 -// echo "Ошибка открытия файла {$this->filePath}";  
43 -// return [];  
44 -// }  
45 -//  
46 -// $options['file'] = $this->fileObject;  
47 -// $this->extension = $this->fileObject->getExtension();  
48 -//  
49 -// try {  
50 -//  
51 -// $this->configuration = array_merge_recursive ($this->configuration, $options);  
52 -//  
53 -// } catch (\ErrorException $e) {  
54 -// echo $e->getMessage();  
55 -// return [];  
56 -// }  
57 -//  
58 -// }  
59 -//  
60 -// public function run()  
61 -// {  
62 -//  
63 -// $result = [];  
64 -//  
65 -// // \common\components\CustomVarDamp::dumpAndDie($this);  
66 -// if (count($this->configuration)) {  
67 -// $parser = \Yii::createObject($this->configuration);  
68 -//  
69 -// try {  
70 -//  
71 -// $parser->setup();  
72 -// $result = $parser->read();  
73 -//  
74 -// } catch (\ErrorException $e) {  
75 -//  
76 -// echo $e->getMessage();  
77 -//  
78 -// }  
79 -//  
80 -// }  
81 -//  
82 -// return $result;  
83 -// }  
84 - protected function createObjectByConfiguration($configuration)  
85 - {  
86 - return \Yii::createObject($configuration);  
87 - }  
88 -  
89 -  
90 -}  
91 \ No newline at end of file 0 \ No newline at end of file
vendor/yiisoft/multiparser/config.php deleted
1 -<?php  
2 -return  
3 - [  
4 - 'csv' =>  
5 - ['web' =>  
6 - ['class' => 'yii\multiparser\CsvParser',  
7 - 'auto_detect_first_line' => true,  
8 - 'converter_conf' => [  
9 - "float" => 'PRICE',  
10 - "integer" => 'QUANTITY',  
11 - "string" => 'DESCR'  
12 - ]],  
13 - 'basic_column' => [  
14 - "ARTICLE" => 'Артикул',  
15 - "PRICE" => 'Цена',  
16 - "DESCR" => 'Наименование',  
17 - "QUANTITY" => 'Колво'  
18 -  
19 - ],  
20 - ]];