1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
foldernew.php
См. документацию.
1<?php
2
4
11
12//\Bitrix\Main\Update\Stepper::bindClass('Bitrix\Landing\Update\Landing\FolderNew', 'landing', 0);
13
14class FolderNew extends Stepper
15{
16 protected static $moduleId = 'landing';
17
24 public function execute(array &$result, ?int $siteId = null): bool
25 {
27 $finished = true;
28
29 $globalFilter = [
30 '=FOLDER' => 'Y',
31 //'=DELETED' => ['Y', 'N'],
32 //'=SITE.DELETED' => ['Y', 'N']
33 ];
34
35 if ($siteId)
36 {
37 $globalFilter['SITE_ID'] = $siteId;
38 }
39
40 // gets common quantity
42 'select' => [
44 'CNT', 'COUNT(*)'
45 ),
46 ],
47 'filter' => $globalFilter,
48 ]);
49 if ($row = $res->fetch())
50 {
51 $result['count'] = (int)$row['CNT'];
52 }
53
54 if ($result['count'] > 0)
55 {
56 // gets group for update
58 'select' => [
59 'ID', 'TITLE', 'CODE', 'ACTIVE', 'DELETED', 'SITE_ID',
60 ],
61 'filter' => $globalFilter,
62 'order' => [
63 'ID' => 'ASC',
64 ],
65 ]);
66 while ($page = $res->fetch())
67 {
68 $folderId = null;
69 // create new folder and update folder to page
70 $resFolder = Folder::add([
71 'SITE_ID' => $page['SITE_ID'],
72 'TITLE' => $page['TITLE'],
73 'CODE' => $page['CODE'],
74 'ACTIVE' => $page['ACTIVE'],
75 'DELETED' => $page['DELETED'],
76 ]);
77 if ($resFolder->isSuccess())
78 {
79 $folderId = $resFolder->getId();
80 }
81 else
82 {
83 foreach ($resFolder->getErrors() as $error)
84 {
85 if ($error->getCode() === 'FOLDER_IS_NOT_UNIQUE')
86 {
87 $resFolder = Folder::getList([
88 'select' => [
89 'ID',
90 ],
91 'filter' => [
92 'SITE_ID' => $page['SITE_ID'],
93 'PARENT_ID' => null,
94 '=CODE' => $page['CODE'],
95 ],
96 ]);
97 if ($rowFolder = $resFolder->fetch())
98 {
99 $folderId = $rowFolder['ID'];
100 break;
101 }
102 }
103 }
104 }
105
106 if ($folderId)
107 {
108 Folder::update($folderId, [
109 'INDEX_ID' => $page['ID'],
110 ]);
111 LandingTable::update($page['ID'], [
112 'FOLDER' => 'N',
113 'FOLDER_ID' => $folderId,
114 ]);
115 Debug::log('FU:LandingTable::update', var_export([
116 'ID' => $page['ID'],
117 'FOLDER' => 'N',
118 'FOLDER_ID' => $folderId,
119 ], true));
120 // fetch old folder's pages and move it to the new folder
121 $resPage = LandingTable::getList([
122 'select' => [
123 'ID', 'FOLDER_ID',
124 ],
125 'filter' => [
126 'FOLDER_ID' => $page['ID'],
127 //'=DELETED' => ['Y', 'N'],
128 //'=SITE.DELETED' => ['Y', 'N']
129 ],
130 ]);
131 while ($rowPage = $resPage->fetch())
132 {
133 LandingTable::update($rowPage['ID'], [
134 'FOLDER_ID' => $folderId,
135 ]);
136 Debug::log('FU:LandingTable::update', var_export([
137 'ID' => $rowPage['ID'],
138 'FOLDER_ID_OLD' => $rowPage['FOLDER_ID'],
139 'FOLDER_ID' => $folderId,
140 ], true));
141 }
142 }
143
144 $finished = false;
145 }
146 }
147
148 if ($finished && !$siteId)
149 {
150 Manager::setOption('landing_new', 'Y');
151 }
152
154
155 return !$finished;
156 }
157}
static log($itemId, $itemDesc, $typeId='LANDING_LOG')
Определения debug.php:24
Определения folder.php:5
static getList(array $params=array())
Определения landing.php:602
static setOption($code, $value)
Определения manager.php:171
static setGlobalOn()
Определения rights.php:116
static setGlobalOff()
Определения rights.php:107
execute(array &$result, ?int $siteId=null)
Определения foldernew.php:24
Определения debug.php:6
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$siteId
Определения ajax.php:8
Определения ufield.php:9
$page
Определения order_form.php:33
$error
Определения subscription_card_product.php:20