1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
history.php
См. документацию.
1<?php
2
3namespace Bitrix\Landing\PublicAction;
4
5use Bitrix\Landing;
6use Bitrix\Landing\PublicActionResult;
7use Bitrix\Landing\Template;
8use Bitrix\Landing\TemplateRef;
9
14{
15 public static function getForLanding(int $lid): PublicActionResult
16 {
18 $histories = [];
19
20 $historyMain = new Landing\History($lid, Landing\History::ENTITY_TYPE_LANDING);
21 $histories[$lid] = [
22 'stack' => $historyMain->getJsStack(),
23 'step' => $historyMain->getStep(),
24 ];
25
26 $isMultiArea = false;
27
29 {
30 $landing = Landing\Landing::createInstance($lid);
32 'select' => [
33 'AREA_COUNT'
34 ],
35 'filter' => [
36 'ID' => $landing->getTplId()
37 ]
38 ])->fetch();
39 if ($template && $template['AREA_COUNT'] > 0)
40 {
41 foreach ($landing->getAreas() as $areaLid)
42 {
43 if (count($histories) > $template['AREA_COUNT'])
44 {
45 break;
46 }
47
48 $isMultiArea = true;
49 $historyArea = new Landing\History($areaLid, Landing\History::ENTITY_TYPE_LANDING);
50
51 $histories[$areaLid] = [
52 'stack' => $historyArea->getJsStack(),
53 'step' => $historyArea->getStep(),
54 ];
55 }
56 }
57 }
58
59 if ($isMultiArea)
60 {
61 // Find max step of all areas
62 $maxStepId = 0;
63 foreach ($histories as $history)
64 {
65 foreach ($history['stack'] as $item)
66 {
67 if ($item['current'])
68 {
69 if ($item['id'] > $maxStepId)
70 {
71 $maxStepId = $item['id'];
72 }
73 }
74 }
75 }
76
77 // Make and sort complex multi area stack.
78 $multiAreaStack = [];
79 $multiAreaStep = 0;
80 foreach ($histories as $history)
81 {
82 foreach ($history['stack'] as $item)
83 {
84 $multiAreaStack[$item['id']] = $item;
85
86 // math new step
87 if ($item['id'] <= $maxStepId)
88 {
89 $multiAreaStep++;
90 }
91 }
92 }
93 ksort($multiAreaStack);
94
95 $result->setResult([
96 'stack' => array_values($multiAreaStack),
97 'step' => $multiAreaStep,
98 ]);
99 }
100
101 // Just single landing history
102 else
103 {
104 $result->setResult($histories[$lid]);
105 }
106
107 return $result;
108 }
109
110 public static function getForDesignerBlock(int $blockId): PublicActionResult
111 {
113 $history = new Landing\History($blockId, Landing\History::ENTITY_TYPE_DESIGNER_BLOCK);
114
115 $result->setResult([
116 'stack' => $history->getJsStack(),
117 'step' => $history->getStep(),
118 ]);
119
120 return $result;
121 }
122
123 public static function undoLanding(int $lid): PublicActionResult
124 {
125 return self::undoForEntity(Landing\History::ENTITY_TYPE_LANDING, $lid);
126 }
127
128 public static function redoLanding(int $lid): PublicActionResult
129 {
130 return self::redoForEntity(Landing\History::ENTITY_TYPE_LANDING, $lid);
131 }
132
133 public static function undoDesignerBlock(int $blockId): PublicActionResult
134 {
135 return self::undoForEntity(Landing\History::ENTITY_TYPE_DESIGNER_BLOCK, $blockId);
136 }
137
138 public static function redoDesignerBlock(int $blockId): PublicActionResult
139 {
140 return self::redoForEntity(Landing\History::ENTITY_TYPE_DESIGNER_BLOCK, $blockId);
141 }
142
143 public static function pushDesignerBlock(int $blockId, string $action, array $data): PublicActionResult
144 {
145 return self::pushForEntity(Landing\History::ENTITY_TYPE_DESIGNER_BLOCK, $blockId, $action, $data);
146 }
147
148 public static function clearDesignerBlock(int $blockId): PublicActionResult
149 {
150 return self::clearForEntity(Landing\History::ENTITY_TYPE_DESIGNER_BLOCK, $blockId);
151 }
152
153 public static function clearFutureForLanding(int $landingId): PublicActionResult
154 {
155 return self::clearFutureForEntity(Landing\History::ENTITY_TYPE_LANDING, $landingId);
156 }
157
158 protected static function undoForEntity(string $entityType, int $entityId): PublicActionResult
159 {
161 $error = new \Bitrix\Landing\Error;
162
163 Landing\Landing::setEditMode(true);
164
165 if (in_array($entityType, Landing\History::AVAILABLE_TYPES))
166 {
167 $history = new Landing\History($entityId, $entityType);
168 $command = $history->getJsCommand();
169 if ($history->undo())
170 {
171 $result->setResult($command);
172 }
173 else
174 {
175 $error->addError(
176 'HISTORY_UNDO_ERROR',
177 "History operation Undo fail for entity {$entityType}_{$entityId}"
178 );
179 $result->setError($error);
180 }
181 }
182 else
183 {
184 $error->addError(
185 'HISTORY_WRONG_TYPE',
186 'Wrong history entity type'
187 );
188 $result->setError($error);
189 }
190
191 return $result;
192 }
193
194 protected static function redoForEntity(string $entityType, int $entityId): PublicActionResult
195 {
197 $error = new \Bitrix\Landing\Error;
198
199 Landing\Landing::setEditMode(true);
200
201 if (in_array($entityType, Landing\History::AVAILABLE_TYPES))
202 {
203 $history = new Landing\History($entityId, $entityType);
204 $command = $history->getJsCommand(false);
205 if ($history->redo())
206 {
207 $result->setResult($command);
208 }
209 else
210 {
211 $error->addError(
212 'HISTORY_REDO_ERROR',
213 "History operation Redo fail for entity {$entityType}_{$entityId}"
214 );
215 $result->setError($error);
216 }
217 }
218 else
219 {
220 $error->addError(
221 'HISTORY_WRONG_TYPE',
222 'Wrong history entity type'
223 );
224 $result->setError($error);
225 }
226
227 return $result;
228 }
229
230 protected static function pushForEntity(
231 string $entityType,
232 int $entityId,
233 string $action,
236 {
238 $error = new \Bitrix\Landing\Error;
239
240 Landing\Landing::setEditMode(true);
241
242 if (in_array($entityType, Landing\History::AVAILABLE_TYPES))
243 {
244 $history = new Landing\History($entityId, $entityType);
245 if ($history->push($action, $data))
246 {
247 $result->setResult(true);
248 }
249 else
250 {
251 $error->addError(
252 'HISTORY_PUSH_ERROR',
253 "History operation Push fail for entity {$entityType}_{$entityId}"
254 );
255 $result->setError($error);
256 }
257 }
258 else
259 {
260 $error->addError(
261 'HISTORY_WRONG_TYPE',
262 'Wrong history entity type'
263 );
264 $result->setError($error);
265 }
266
267 return $result;
268 }
269
270 protected static function clearForEntity(string $entityType, int $entityId): PublicActionResult
271 {
273 $error = new \Bitrix\Landing\Error;
274
275 Landing\Landing::setEditMode(true);
276
277 if (in_array($entityType, Landing\History::AVAILABLE_TYPES))
278 {
279 $history = new Landing\History($entityId, $entityType);
280 if ($history->clear())
281 {
282 $result->setResult(true);
283 }
284 else
285 {
286 $error->addError(
287 'HISTORY_CLEAR_ERROR',
288 "History operation Clear fail for entity {$entityType}_{$entityId}"
289 );
290 $result->setError($error);
291 }
292 }
293 else
294 {
295 $error->addError(
296 'HISTORY_WRONG_TYPE',
297 'Wrong history entity type'
298 );
299 $result->setError($error);
300 }
301
302 return $result;
303 }
304
305 protected static function clearFutureForEntity(string $entityType, int $entityId): PublicActionResult
306 {
308 $error = new \Bitrix\Landing\Error;
309
310 Landing\Landing::setEditMode(true);
311
312 if (in_array($entityType, Landing\History::AVAILABLE_TYPES))
313 {
314 $history = new Landing\History($entityId, $entityType);
315 if ($history->clearFuture())
316 {
317 $result->setResult(true);
318 }
319 else
320 {
321 $error->addError(
322 'HISTORY_CLEAR_FUTURE_ERROR',
323 "History operation Clear future fail for entity {$entityType}_{$entityId}"
324 );
325 $result->setError($error);
326 }
327 }
328 else
329 {
330 $error->addError(
331 'HISTORY_WRONG_TYPE',
332 'Wrong history entity type'
333 );
334 $result->setError($error);
335 }
336
337 return $result;
338 }
339}
static redoLanding(int $lid)
Определения history.php:128
static redoForEntity(string $entityType, int $entityId)
Определения history.php:194
static clearFutureForEntity(string $entityType, int $entityId)
Определения history.php:305
static pushForEntity(string $entityType, int $entityId, string $action, array $data)
Определения history.php:230
static undoDesignerBlock(int $blockId)
Определения history.php:133
static redoDesignerBlock(int $blockId)
Определения history.php:138
static getForDesignerBlock(int $blockId)
Определения history.php:110
static clearDesignerBlock(int $blockId)
Определения history.php:148
static undoLanding(int $lid)
Определения history.php:123
static getForLanding(int $lid)
Определения history.php:15
static clearForEntity(string $entityType, int $entityId)
Определения history.php:270
static pushDesignerBlock(int $blockId, string $action, array $data)
Определения history.php:143
static undoForEntity(string $entityType, int $entityId)
Определения history.php:158
static clearFutureForLanding(int $landingId)
Определения history.php:153
static getList(array $params=array())
Определения template.php:20
static landingIsArea(int|array $lid)
Определения templateref.php:165
$data['IS_AVAILABLE']
Определения .description.php:13
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
Определения agent.php:3
$entityId
Определения payment.php:4
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$error
Определения subscription_card_product.php:20
$action
Определения file_dialog.php:21