Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
responseparser.php
1<?php
2
4
6{
7 public function getOldToNewUidsMap($copyUid)
8 {
9 $uIds = [];
10 $dirUidValidity = '';
11 if ($responseLine = mb_stristr($copyUid, 'COPYUID'))
12 {
13 $data = explode(' ', mb_stristr($copyUid, 'COPYUID'));
14 if (isset($data[1]) && isset($data[2]) && isset($data[3]))
15 {
16 $dirUidValidity = $data[1];
17 $idsFrom = $this->getIdsSet($data[2]);
18 $idsTo = $this->getIdsSet(str_replace(']', '', $data[3]));
19 $uIds = array_combine($idsFrom, $idsTo);
20 }
21 }
22
23 return [
24 'uids' => $uIds,
25 'dirUid' => $dirUidValidity,
26 ];
27 }
28
29 private function getIdsSet($line)
30 {
31 $idsFrom = [];
32 $idsFromParsed = explode(',', $line);
33 foreach ($idsFromParsed as $_index => $_idFrom)
34 {
35 $sequence = explode(':', $_idFrom);
36 if (count($sequence) == 2)
37 {
38 $idsFrom = array_merge($idsFrom, range(min($sequence[0], $sequence[1]), max($sequence[0], $sequence[1]), 1));
39 }
40 elseif (count($sequence) == 1)
41 {
42 $idsFrom[] = intval($sequence[0]);
43 }
44 }
45 return $idsFrom;
46 }
47}