Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
exporttreerussia.php
1<?php
10
11use Bitrix\Main;
14
16{
17 protected $regionCodeIndex = array();
18
19 public static function getFilePath()
20 {
21 return __FILE__;
22 }
23
24 public static function getTableName()
25 {
26 return 'b_tmp_export_tree_russia';
27 }
28
29 public function dropCodeIndex()
30 {
31 unset($this->codeIndex);
32
33 if(!empty($this->regionCodeIndex))
34 $this->codeIndex = $this->regionCodeIndex;
35 }
36
37 public function insert($data)
38 {
39 if(isset($this->codeIndex[$data['SYS_CODE']])) // already in there
40 return;
41
42 if($data['TYPE_CODE'] == 'REGION')
43 $this->regionCodeIndex[$data['SYS_CODE']] = $this->formatCode($this->exportOffset);
44
45 $this->codeIndex[$data['SYS_CODE']] = $this->formatCode($this->exportOffset);
46
47 $data['CODE'] = $this->codeIndex[$data['SYS_CODE']];
48 $data['PARENT_CODE'] = strlen($data['PARENT_SYS_CODE']) ? $this->codeIndex[$data['PARENT_SYS_CODE']] : '';
49
50 unset($data['PARENT_SYS_CODE']);
51
52 if(is_array($data['LANGNAMES']))
53 $data['LANGNAMES'] = serialize($data['LANGNAMES']);
54
55 if(is_array($data['EXTERNALS']))
56 $data['EXTERNALS'] = serialize($data['EXTERNALS']);
57
58 $this->exportOffset++;
59
60 $this->inserter->insert($data);
61 }
62
63 public static function getMap()
64 {
65 $map = parent::getMap();
66 $map['ZIP'] = array(
67 'data_type' => 'string',
68 );
69
70 return $map;
71 }
72}
static formatCode($value, $length=self::CODE_LENGTH)