Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
fixsrcimg.php
1<?php
3
4use \Bitrix\Landing\Internals\BlockTable;
5use \Bitrix\Main\Update\Stepper;
6use \Bitrix\Main\Config\Option;
7use \Bitrix\Main\Localization\Loc;
8
9Loc::loadMessages(__FILE__);
10
11class FixSrcImg extends Stepper
12{
13 protected static $moduleId = 'landing';
14
20 public function execute(array &$result)
21 {
22 $lastId = Option::get('landing', 'update_block_fixsrcimg', 0);
23
24 $finished = true;
25
26 // gets common quantity
27 $res = BlockTable::getList(array(
28 'select' => array(
30 'CNT', 'COUNT(*)'
31 )
32 ),
33 'filter' => [
34 'LOGIC' => 'OR',
35 'CONTENT' => [
36 '%http:///%',
37 '%https:///%',
38 ]
39 ]
40 ));
41 if ($row = $res->fetch())
42 {
43 $result['count'] = $row['CNT'];
44 }
45
46 // gets group for update
47 $res = BlockTable::getList(array(
48 'select' => array(
49 'ID', 'CONTENT'
50 ),
51 'filter' => array(
52 '>ID' => $lastId,
53 [
54 'LOGIC' => 'OR',
55 'CONTENT' => [
56 '%http:///%',
57 '%https:///%',
58 ]
59 ]
60 ),
61 'order' => array(
62 'ID' => 'ASC'
63 ),
64 'limit' => 10
65 ));
66 while ($row = $res->fetch())
67 {
68 $lastId = $row['ID'];
69 $result['steps']++;
70
71 BlockTable::update($row['ID'], [
72 'CONTENT' => str_replace(
73 ['http:///', 'https:///'],
74 '/',
75 $row['CONTENT']
76 )
77 ]);
78
79 $finished = false;
80 }
81
82 // add files from blocks
83 if (!$finished)
84 {
85 Option::set('landing', 'update_block_fixsrcimg', $lastId);
86 return true;
87 }
88 else
89 {
90 Option::delete('landing', array('name' => 'update_block_fixsrcimg'));
91 return false;
92 }
93 }
94}
static loadMessages($file)
Definition loc.php:64