|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * User: darkfriend <hi@darkfriend.ru> |
| 4 | + * Date: 19.02.2025 |
| 5 | + * Time: 02:41 |
| 6 | + */ |
| 7 | + |
| 8 | +require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"); |
| 9 | + |
| 10 | +$curModuleName = 'dev2fun.imagecompress'; |
| 11 | +\Bitrix\Main\Loader::includeModule('main'); |
| 12 | +\Bitrix\Main\Loader::includeModule($curModuleName); |
| 13 | + |
| 14 | +\Bitrix\Main\Loader::registerAutoLoadClasses( |
| 15 | + $curModuleName, |
| 16 | + [ |
| 17 | + 'Dev2funImageCompress' => 'include.php', |
| 18 | + ] |
| 19 | +); |
| 20 | + |
| 21 | +try { |
| 22 | + |
| 23 | + $cntWrongRelations = \Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable::getCountWrongRelations(); |
| 24 | + if ($cntWrongRelations) { |
| 25 | + $cntPerStep = 500; |
| 26 | + $steps = ceil($cntWrongRelations / $cntPerStep); |
| 27 | + for ($i = 1; $i <= $steps; $i++) { |
| 28 | + \Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable::removeWrongRelations($cntPerStep); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + \Dev2fun\ImageCompress\ImageCompressImagesToConvertedTable::addForeignKey(); |
| 33 | + |
| 34 | + |
| 35 | + CopyDirFiles("{$_SERVER["DOCUMENT_ROOT"]}/bitrix/modules/{$curModuleName}/install/admin", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/admin", true, true); |
| 36 | + CopyDirFiles("{$_SERVER["DOCUMENT_ROOT"]}/bitrix/modules/{$curModuleName}/install/js/vue", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/js/{$curModuleName}/vue", true, true); |
| 37 | + |
| 38 | + $eventManager = \Bitrix\Main\EventManager::getInstance(); |
| 39 | + $eventManager->registerEventHandler("main", "OnPageStart", $curModuleName, "Dev2fun\\ImageCompress\\Convert", "CleanCacheEvent", 999); |
| 40 | + |
| 41 | + $cntRows = \Dev2fun\ImageCompress\ImageCompressImagesConvertedTable::query() |
| 42 | + ->whereLike('IMAGE_PATH', '/upload/resize_cache%') |
| 43 | + ->queryCountTotal(); |
| 44 | + |
| 45 | + if ($cntRows) { |
| 46 | + \CAdminNotify::Add([ |
| 47 | + 'MESSAGE' => "Вам необходимо сделать перенос сконвертированных файлов в новое место расположение, <a href='/bitrix/admin/dev2fun_imagecompress_convert_move.php?lang=ru'>ссылка</a>", |
| 48 | + 'TAG' => $curModuleName . '_convert_move', |
| 49 | + 'MODULE_ID' => $curModuleName, |
| 50 | + 'NOTIFY_TYPE' => \CAdminNotify::TYPE_ERROR, |
| 51 | + ]); |
| 52 | + } |
| 53 | + |
| 54 | + \Dev2funImageCompress::ShowThanksNotice(); |
| 55 | + |
| 56 | + die("0.11.0 - Success"); |
| 57 | + |
| 58 | +} catch (Throwable $e) { |
| 59 | + ShowError($e->getMessage()); |
| 60 | +} |
0 commit comments