1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
nodeimg.php
См. документацию.
1
<?php
2
namespace
Bitrix\Landing\Update\Block;
3
4
use \Bitrix\Landing\File;
5
use \Bitrix\Landing\Internals\BlockTable;
6
use \Bitrix\Main\Entity;
7
use \Bitrix\Main\Update\Stepper;
8
use \Bitrix\Main\Config\Option;
9
use \Bitrix\Main\Localization\Loc;
10
11
Loc::loadMessages(__FILE__);
12
13
class
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
(
42
new
\
Bitrix
\
Main
\
Entity
\
ExpressionField
(
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'
],
71
$matches
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'
));
118
$eventManager
=
\Bitrix\Main\EventManager::getInstance
();
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
(
145
new
Entity
\
EntityError
(
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
(
162
new
\
Bitrix
\
Main
\
Entity
\
EntityError
(
163
Loc::getMessage(
'LANDING_DISABLE_PUBLICATION'
),
164
'LANDING_DISABLE_PUBLICATION'
165
)
166
));
167
return
$result
;
168
}
169
}
Bitrix\Landing\File\addToBlock
static addToBlock(int $blockId, $fileId, bool $temp=false)
Определения
file.php:305
Bitrix\Landing\Update\Block\NodeImg
Определения
nodeimg.php:14
Bitrix\Landing\Update\Block\NodeImg\execute
execute(array &$result)
Определения
nodeimg.php:32
Bitrix\Landing\Update\Block\NodeImg\getFileHash
getFileHash($id)
Определения
nodeimg.php:22
Bitrix\Landing\Update\Block\NodeImg\disablePublication
static disablePublication(\Bitrix\Main\Event $event)
Определения
nodeimg.php:158
Bitrix\Landing\Update\Block\NodeImg\disableBlockDelete
static disableBlockDelete(Entity\Event $event)
Определения
nodeimg.php:141
Bitrix\Landing\Update\Block\NodeImg\$moduleId
static $moduleId
Определения
nodeimg.php:15
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\EventManager\getInstance
static getInstance()
Определения
eventmanager.php:31
Bitrix\Main\ORM\EntityError
Определения
entityerror.php:12
Bitrix\Main\ORM\Fields\ExpressionField
Определения
expressionfield.php:25
Bitrix\Main\Update\Stepper
Определения
stepper.php:29
$lastId
if(!\Bitrix\Main\Loader::includeModule('clouds')) $lastId
Определения
sync.php:68
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$result
$result
Определения
get_property_values.php:14
LICENSE_KEY
const LICENSE_KEY($show_sql_stat=='Y')
Определения
start.php:84
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main
Bitrix\Main\$files
$files
Определения
mysql_to_pgsql.php:30
Bitrix
$event
$event
Определения
prolog_after.php:141
$i
$i
Определения
factura.php:643
$matches
$matches
Определения
index.php:22
$eventManager
$eventManager
Определения
include.php:412
bitrix
modules
landing
lib
update
block
nodeimg.php
Создано системой
1.14.0