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