Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/landing/lib/update/block/ |
Upload File : |
<?php namespace Bitrix\Landing\Update\Block; use \Bitrix\Landing\Internals\BlockTable; use \Bitrix\Main\Update\Stepper; use \Bitrix\Main\Config\Option; use \Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__); class FixSrcImg extends Stepper { protected static $moduleId = 'landing'; /** * One step of converter. * @param array &$result Result array. * @return bool */ public function execute(array &$result) { $lastId = Option::get('landing', 'update_block_fixsrcimg', 0); $finished = true; // gets common quantity $res = BlockTable::getList(array( 'select' => array( new \Bitrix\Main\Entity\ExpressionField( 'CNT', 'COUNT(*)' ) ), 'filter' => [ 'LOGIC' => 'OR', 'CONTENT' => [ '%http:///%', '%https:///%', ] ] )); if ($row = $res->fetch()) { $result['count'] = $row['CNT']; } // gets group for update $res = BlockTable::getList(array( 'select' => array( 'ID', 'CONTENT' ), 'filter' => array( '>ID' => $lastId, [ 'LOGIC' => 'OR', 'CONTENT' => [ '%http:///%', '%https:///%', ] ] ), 'order' => array( 'ID' => 'ASC' ), 'limit' => 10 )); while ($row = $res->fetch()) { $lastId = $row['ID']; $result['steps']++; BlockTable::update($row['ID'], [ 'CONTENT' => str_replace( ['http:///', 'https:///'], '/', $row['CONTENT'] ) ]); $finished = false; } // add files from blocks if (!$finished) { Option::set('landing', 'update_block_fixsrcimg', $lastId); return true; } else { Option::delete('landing', array('name' => 'update_block_fixsrcimg')); return false; } } }