1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
nodeimg.php
См. документацию.
1<?php
2namespace Bitrix\Landing\Update\Block;
3
4use \Bitrix\Landing\File;
5use \Bitrix\Landing\Internals\BlockTable;
6use \Bitrix\Main\Entity;
7use \Bitrix\Main\Update\Stepper;
8use \Bitrix\Main\Config\Option;
9use \Bitrix\Main\Localization\Loc;
10
11Loc::loadMessages(__FILE__);
12
13class NodeImg extends Stepper
14{
15 protected static $moduleId = 'landing';
16
22 public function getFileHash($id)
23 {
24 return md5($id . '|' . LICENSE_KEY);
25 }
26
32 public function execute(array &$result)
33 {
34 $lastId = Option::get('landing', 'update_block_nodeimg', 0);
35
36 $toSave = array();
37 $finished = true;
38
39 // gets common quantity
40 $res = BlockTable::getList(array(
41 'select' => array(
43 'CNT', 'COUNT(*)'
44 )
45 )
46 ));
47 if ($row = $res->fetch())
48 {
49 $result['count'] = $row['CNT'];
50 }
51
52 // gets group for update
53 $res = BlockTable::getList(array(
54 'select' => array(
55 'ID', 'CONTENT'
56 ),
57 'filter' => array(
58 '>ID' => $lastId
59 ),
60 'order' => array(
61 'ID' => 'ASC'
62 ),
63 'limit' => 100
64 ));
65 while ($row = $res->fetch())
66 {
67 $files = array();
68 $fileExist = preg_match_all(
69 '/data\-([?fileid|filehash]+)\="([^"]+)"[^>]+data\-[?fileid|filehash]+\="([^"]+)"/is',
70 $row['CONTENT'],
72 );
73 if ($fileExist)
74 {
75 foreach ($matches[1] as $i => $attr)
76 {
77 if ($attr == 'fileid')
78 {
79 $files[$matches[2][$i]] = $matches[3][$i];
80 }
81 else
82 {
83 $files[$matches[3][$i]] = $matches[2][$i];
84 }
85 }
86 foreach ($files as $fileId => $fileHash)
87 {
88 if ($fileId > 0 && $this->getFileHash($fileId) == $fileHash)
89 {
90 if (!isset($toSave[$row['ID']]))
91 {
92 $toSave[$row['ID']] = array();
93 }
94 $toSave[$row['ID']][] = $fileId;
95 }
96 }
97 }
98 $lastId = $row['ID'];
99 $result['steps']++;
100 $finished = false;
101 }
102
103 // add files from blocks
104 foreach ($toSave as $block => $files)
105 {
106 File::addToBlock($block, $files);
107 }
108
109 // clear handlers all continue work
110 if (!$finished)
111 {
112 Option::set('landing', 'update_block_nodeimg', $lastId);
113 return true;
114 }
115 else
116 {
117 Option::delete('landing', array('name' => 'update_block_nodeimg'));
119 $eventManager->unregisterEventHandler(
120 'landing',
121 '\Bitrix\Landing\Internals\Block::OnBeforeDelete',
122 'landing',
123 '\Bitrix\Landing\Update\Block\NodeImg',
124 'disableBlockDelete');
125 $eventManager->unregisterEventHandler(
126 'landing',
127 'onLandingPublication',
128 'landing',
129 '\Bitrix\Landing\Update\Block\NodeImg',
130 'disablePublication'
131 );
132 return false;
133 }
134 }
135
141 public static function disableBlockDelete(Entity\Event $event)
142 {
143 $result = new Entity\EventResult();
144 $result->setErrors(array(
146 Loc::getMessage('LANDING_BLOCK_DISABLE_DELETE'),
147 'BLOCK_DISABLE_DELETE'
148 )
149 ));
150 return $result;
151 }
152
158 public static function disablePublication(\Bitrix\Main\Event $event)
159 {
160 $result = new Entity\EventResult;
161 $result->setErrors(array(
163 Loc::getMessage('LANDING_DISABLE_PUBLICATION'),
164 'LANDING_DISABLE_PUBLICATION'
165 )
166 ));
167 return $result;
168 }
169}
static addToBlock(int $blockId, $fileId, bool $temp=false)
Определения file.php:305
execute(array &$result)
Определения nodeimg.php:32
static disablePublication(\Bitrix\Main\Event $event)
Определения nodeimg.php:158
static disableBlockDelete(Entity\Event $event)
Определения nodeimg.php:141
Определения event.php:5
static getInstance()
Определения eventmanager.php:31
if(!\Bitrix\Main\Loader::includeModule('clouds')) $lastId
Определения sync.php:68
</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
const LICENSE_KEY($show_sql_stat=='Y')
Определения start.php:84
Определения ufield.php:9
$files
Определения mysql_to_pgsql.php:30
$event
Определения prolog_after.php:141
$i
Определения factura.php:643
$matches
Определения index.php:22
$eventManager
Определения include.php:412