コード例 #1
0
ファイル: MapController.php プロジェクト: krvd/cms-Inji
 public function indexAction()
 {
     $this->view->setTitle('Карты миграции данных');
     if (!empty($_POST['type'])) {
         foreach ($_POST['type'] as $pathId => $objectType) {
             $mapPath = Migrations\Migration\Map\Path::get($pathId);
             if (is_numeric($objectType)) {
                 $mapPath->object_id = $objectType;
                 $mapPath->type = 'object';
             } else {
                 if ($objectType == 'object') {
                     $object = new Migrations\Migration\Object();
                     $object->model = !empty($_POST['typeOptions'][$pathId]) ? $_POST['typeOptions'][$pathId] : '';
                     $object->migration_id = $mapPath->map->migration_id;
                     $object->code = $object->name = $mapPath->item;
                     $object->save();
                     $mapPath->type = 'object';
                     $mapPath->object_id = $object->id;
                 } else {
                     $mapPath->type = $objectType;
                 }
             }
             $mapPath->save();
         }
     }
     if (!empty($_POST['param'])) {
         foreach ($_POST['param'] as $paramId => $type) {
             $param = \Migrations\Migration\Object\Param::get($paramId);
             if ($type == 'newObject') {
                 $object = new Migrations\Migration\Object();
                 $object->model = !empty($_POST['paramOptions'][$paramId]) ? $_POST['paramOptions'][$paramId] : '';
                 $object->migration_id = $param->object->migration_id;
                 $object->code = $object->name = $param->code;
                 $object->save();
                 $param->type = 'object';
                 $param->value = $object->id;
             } else {
                 $param->type = $type;
                 $param->value = !empty($_POST['paramOptions'][$paramId]) ? $_POST['paramOptions'][$paramId] : '';
             }
             $param->save();
         }
     }
     $models = $this->modules->getSelectListModels();
     $map = \Migrations\Migration\Map::get($_GET['item_pk']);
     $objects = $map->migration->objects(['forSelect' => true]);
     $this->view->page(['data' => compact('map', 'models', 'objects')]);
 }
コード例 #2
0
 public function manualAction()
 {
     if (!empty($_POST)) {
         $this->module->startMigration(\Migrations\Migration\Map::get($_POST['map'])->migration_id, $_POST['map'], $_FILES['file']['tmp_name']);
     }
     $selectArray = ['' => 'Выберите'];
     $migrations = Migrations\Migration::getList();
     foreach ($migrations as $migration) {
         $item = ['text' => $migration->name, 'input' => ['name' => 'map', 'type' => 'select', 'source' => 'array', 'sourceArray' => ['' => 'Выберите']]];
         foreach ($migration->maps as $map) {
             $item['input']['sourceArray'][$map->id] = ['text' => $map->name, 'input' => ['type' => 'file', 'name' => 'file', 'noprefix' => true]];
         }
         $selectArray[$migration->id] = $item;
     }
     $this->view->setTitle('Ручная миграции данных');
     $this->view->page(['data' => compact('selectArray')]);
 }
コード例 #3
0
ファイル: manual.php プロジェクト: krvd/cms-Inji
<h1>Ручная миграция данных</h1>
<?php 
$form = new Ui\Form();
$form->begin();
$form->input('select', 'map', 'Выберите карту миграции', ['values' => \Migrations\Migration\Map::getList(['forSelect' => true])]);
$form->input('file', 'file', 'Выберите файл');
$form->end('Начать');