Browse Source

Version 2.1

master
M@dD3n 7 years ago
parent
commit
b2b1e1be17
  1. 4
      README.md
  2. 47
      import/class.import.parsers.php
  3. 21
      import/class.import.php
  4. 4
      import/module.php

4
README.md

@ -1,6 +1,6 @@
## import ## import
## Модуль импорта v2.0.1 (Light версия) ## Модуль импорта v2.1 (Light версия)
## Автор: @MadDen ## Автор: @MadDen
@ -13,6 +13,8 @@
## Changelog: ## Changelog:
13.04.2017 - версия 2.1
10.08.2016 - версия 2.0.1 10.08.2016 - версия 2.0.1
08.08.2016 - версия 2.0 08.08.2016 - версия 2.0

47
import/class.import.parsers.php

@ -35,7 +35,7 @@ class ModuleImportParsers
$ii = 0; $ii = 0;
$items = []; $items = array();
while ($item = fgetcsv($handle, 0, $sep, $protect)) while ($item = fgetcsv($handle, 0, $sep, $protect))
{ {
@ -80,7 +80,7 @@ class ModuleImportParsers
$tags = $Excel->sheets[0]['cells'][1]; // Определяем теги $tags = $Excel->sheets[0]['cells'][1]; // Определяем теги
$items = []; $items = array();
$ii = 0; $ii = 0;
@ -121,14 +121,14 @@ class ModuleImportParsers
$a = array_values($xml); $a = array_values($xml);
$tags = []; // Определяем теги $tags = array(); // Определяем теги
foreach ($a[0][0] AS $key => $value) foreach ($a[0][0] AS $key => $value)
{ {
$tags[] = $key; $tags[] = $key;
} }
$items = []; $items = array();
foreach ($a[0] AS $key => $row) foreach ($a[0] AS $key => $row)
{ {
@ -150,4 +150,43 @@ class ModuleImportParsers
return $result; return $result;
} }
/* !DBF */
public static function DBF2Array($fname)
{
$db = dbase_open($fname, 0);
$cols = dbase_get_header_info($db);
$count = dbase_numrecords($db);
$rows = array();
$tags = array();
foreach($cols AS $k => $v)
{
$tags[] = $v['name'];
}
$ii = 1;
for ($ii; $ii <= $count; $ii++)
{
$rows[] = dbase_get_record_with_names($db, $ii);
}
$result =
[
'num' => $count - $parser_row,
'tags' => $tags,
'rows' => $rows
];
dbase_close($db);
unset($cols, $count, $tags, $rows);
return $result;
}
} }

21
import/class.import.php

@ -338,7 +338,7 @@ class ModuleImport
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
// если новый // если новый
if (!$import_id) if (! $import_id)
{ {
$AVE_DB->Query(" $AVE_DB->Query("
INSERT INTO INSERT INTO
@ -416,13 +416,14 @@ class ModuleImport
$message = $AVE_Template->get_config_vars('saved'); $message = $AVE_Template->get_config_vars('saved');
$header = $AVE_Template->get_config_vars('success'); $header = $AVE_Template->get_config_vars('success');
$theme = 'accept'; $theme = 'accept';
echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme)); echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
exit; exit;
} }
else else
{ {
return $import_id; return $import_id;
} }
} }
/** /**
@ -584,12 +585,11 @@ class ModuleImport
$i = 0; $i = 0;
$log = $log = array(
[
'updated' => array(), 'updated' => array(),
'created' => array(), 'created' => array(),
'notfound' => array() 'notfound' => array()
]; );
// Обрабатываем по очереди каждый объект // Обрабатываем по очереди каждый объект
foreach($import_data['rows'] as $item) foreach($import_data['rows'] as $item)
@ -601,6 +601,7 @@ class ModuleImport
// парсим шаблоны // парсим шаблоны
$item_fields = $fields; $item_fields = $fields;
array_walk_recursive($item_fields, array($this, '_parse_tpl'), $replace); array_walk_recursive($item_fields, array($this, '_parse_tpl'), $replace);
// чистим память // чистим память
@ -618,7 +619,8 @@ class ModuleImport
} }
} }
if (! $pass) continue; if (! $pass)
continue;
// проверяем обязательные поля в теле документа // проверяем обязательные поля в теле документа
foreach ($fields_oblig['body'] as $field_id) foreach ($fields_oblig['body'] as $field_id)
@ -630,7 +632,8 @@ class ModuleImport
} }
} }
if (! $pass) continue; if (! $pass)
continue;
// находим документ по ключевым полям // находим документ по ключевым полям
$docids = $this->_docs_find($fields_key, $fields_comp, $item_fields, $import->rub_id); $docids = $this->_docs_find($fields_key, $fields_comp, $item_fields, $import->rub_id);

4
import/module.php

@ -16,10 +16,10 @@ if (defined('ACP'))
[ [
'ModuleName' => "Импорт (Облегченная версия)", 'ModuleName' => "Импорт (Облегченная версия)",
'ModuleSysName' => "import", 'ModuleSysName' => "import",
'ModuleVersion' => "2.0.1", 'ModuleVersion' => "2.1",
'ModuleDescription' => "Осуществляет импорт документов из файлов различных типов", 'ModuleDescription' => "Осуществляет импорт документов из файлов различных типов",
'ModuleAutor' => "AVE.cms Team", 'ModuleAutor' => "AVE.cms Team",
'ModuleCopyright' => "&copy; AVE.cms Team 2016", 'ModuleCopyright' => "&copy; AVE.cms Team 2017",
'ModuleStatus' => 1, 'ModuleStatus' => 1,
'ModuleIsFunction' => 0, 'ModuleIsFunction' => 0,
'ModuleTemplate' => 0, 'ModuleTemplate' => 0,

Loading…
Cancel
Save