├── .github
└── FUNDING.yml
├── README.md
├── migrations
├── 0.10.0.php
├── 0.11.0.php
├── 0.11.2.php
├── 0.11.4.php
├── 0.5.0.php
├── 0.5.3.php
├── 0.6.0.php
├── 0.6.1.php
├── 0.7.0.php
├── 0.8.0.php
└── 0.9.0.php
├── utf8
└── dev2fun.imagecompress
│ ├── admin
│ ├── dev2fun_imagecompress_convert.php
│ ├── dev2fun_imagecompress_convert_move.php
│ ├── dev2fun_imagecompress_files.php
│ └── menu.php
│ ├── classes
│ └── general
│ │ ├── ImageCompressImagesConvertedTable.php
│ │ ├── ImageCompressImagesTable.php
│ │ ├── ImageCompressImagesToConvertedTable.php
│ │ ├── ImageCompressTable.php
│ │ └── MySqlHelper.php
│ ├── console
│ ├── cache-delayed-delete.php
│ ├── convert.php
│ └── optimize.php
│ ├── default_option.php
│ ├── frontend
│ ├── .babelrc
│ ├── .editorconfig
│ ├── .eslintignore
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .prettierrc
│ ├── config
│ │ ├── env
│ │ │ ├── dev.env.js
│ │ │ ├── prod.env.js
│ │ │ └── staging.env.js
│ │ ├── webpack.config.common.js
│ │ ├── webpack.config.dev.js
│ │ └── webpack.config.prod.js
│ ├── env.d.ts
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── postcss.config.js
│ ├── src
│ │ ├── App.vue
│ │ ├── components
│ │ │ ├── AdminMessage.vue
│ │ │ ├── AdminNote.vue
│ │ │ ├── MoverFiles.vue
│ │ │ └── ProgressBar.vue
│ │ ├── main.ts
│ │ ├── methods
│ │ │ ├── configMain.js
│ │ │ └── http.js
│ │ └── scss
│ │ │ └── style.scss
│ ├── tailwind.config.js
│ ├── tsconfig.json
│ └── webpack.config.js
│ ├── include.php
│ ├── include
│ ├── convert
│ │ └── webp.php
│ └── options
│ │ ├── gif.php
│ │ └── svg.php
│ ├── install
│ ├── admin
│ │ ├── dev2fun_imagecompress_convert.php
│ │ ├── dev2fun_imagecompress_convert_move.php
│ │ └── dev2fun_imagecompress_files.php
│ ├── error.php
│ ├── final.php
│ ├── index.php
│ ├── js
│ │ ├── script.js
│ │ └── vue
│ │ │ ├── css
│ │ │ └── bundle.css
│ │ │ └── js
│ │ │ ├── 265.70db9293.chunk.js
│ │ │ ├── 534.e3a55a2c.chunk.js
│ │ │ ├── 683.9c04fc2e.chunk.js
│ │ │ ├── 82.68b0c6b6.chunk.js
│ │ │ └── main.bundle.js
│ ├── step1.php
│ ├── themes
│ │ └── .default
│ │ │ ├── dev2fun.imagecompress.css
│ │ │ └── icons
│ │ │ └── dev2fun.imagecompress
│ │ │ └── dev2fun_imagecompress.png
│ ├── unstep1.php
│ └── version.php
│ ├── lang
│ └── ru
│ │ ├── admin
│ │ ├── dev2fun_imagecompress_convert.php
│ │ ├── dev2fun_imagecompress_convert_move.php
│ │ ├── dev2fun_imagecompress_files.php
│ │ └── menu.php
│ │ ├── classes
│ │ └── general
│ │ │ ├── ImageCompressImagesToConvertedTable.php
│ │ │ └── ImageCompressTable.php
│ │ ├── include.php
│ │ ├── install
│ │ ├── error.php
│ │ ├── final.php
│ │ ├── index.php
│ │ ├── step1.php
│ │ └── unstep1.php
│ │ ├── lib
│ │ ├── AdminList.php
│ │ ├── Check.php
│ │ ├── Compress.php
│ │ ├── Convert.php
│ │ ├── Jpegoptim.php
│ │ └── Optipng.php
│ │ ├── options.php
│ │ └── updater.php
│ ├── lib
│ ├── AdminList.php
│ ├── AvifConvertImagick.php
│ ├── AvifConvertPhp.php
│ ├── Cache.php
│ ├── CacheCleaner.php
│ ├── Check.php
│ ├── Compress.php
│ ├── CompressAgent.php
│ ├── Convert.php
│ ├── ConvertAgent.php
│ ├── ConvertSearchPictures.php
│ ├── Gif.php
│ ├── IO.php
│ ├── Jpegoptim.php
│ ├── LazyConvert.php
│ ├── Optipng.php
│ ├── Process.php
│ ├── Ps2Pdf.php
│ ├── Resize.php
│ ├── Svg.php
│ ├── Webp.php
│ ├── WebpConvertPhp.php
│ └── script.js
│ ├── options.php
│ └── tabs
│ ├── convert.php
│ ├── donate.php
│ └── optimize.php
└── win1251
└── dev2fun.imagecompress
├── admin
├── dev2fun_imagecompress_convert.php
├── dev2fun_imagecompress_convert_move.php
├── dev2fun_imagecompress_files.php
└── menu.php
├── classes
└── general
│ ├── ImageCompressImagesConvertedTable.php
│ ├── ImageCompressImagesTable.php
│ ├── ImageCompressImagesToConvertedTable.php
│ ├── ImageCompressTable.php
│ └── MySqlHelper.php
├── console
├── cache-delayed-delete.php
├── convert.php
└── optimize.php
├── default_option.php
├── frontend
├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .prettierrc
├── config
│ ├── env
│ │ ├── dev.env.js
│ │ ├── prod.env.js
│ │ └── staging.env.js
│ ├── webpack.config.common.js
│ ├── webpack.config.dev.js
│ └── webpack.config.prod.js
├── env.d.ts
├── index.html
├── package-lock.json
├── package.json
├── postcss.config.js
├── src
│ ├── App.vue
│ ├── components
│ │ ├── AdminMessage.vue
│ │ ├── AdminNote.vue
│ │ ├── MoverFiles.vue
│ │ └── ProgressBar.vue
│ ├── main.ts
│ ├── methods
│ │ ├── configMain.js
│ │ └── http.js
│ └── scss
│ │ └── style.scss
├── tailwind.config.js
├── tsconfig.json
└── webpack.config.js
├── include.php
├── include
├── convert
│ └── webp.php
└── options
│ ├── gif.php
│ └── svg.php
├── install
├── admin
│ ├── dev2fun_imagecompress_convert.php
│ ├── dev2fun_imagecompress_convert_move.php
│ └── dev2fun_imagecompress_files.php
├── error.php
├── final.php
├── index.php
├── js
│ ├── script.js
│ └── vue
│ │ ├── css
│ │ └── bundle.css
│ │ └── js
│ │ ├── 265.70db9293.chunk.js
│ │ ├── 534.e3a55a2c.chunk.js
│ │ ├── 683.9c04fc2e.chunk.js
│ │ ├── 82.68b0c6b6.chunk.js
│ │ └── main.bundle.js
├── step1.php
├── themes
│ └── .default
│ │ ├── dev2fun.imagecompress.css
│ │ └── icons
│ │ └── dev2fun.imagecompress
│ │ └── dev2fun_imagecompress.png
├── unstep1.php
└── version.php
├── lang
└── ru
│ ├── admin
│ ├── dev2fun_imagecompress_convert.php
│ ├── dev2fun_imagecompress_convert_move.php
│ ├── dev2fun_imagecompress_files.php
│ └── menu.php
│ ├── classes
│ └── general
│ │ ├── ImageCompressImagesToConvertedTable.php
│ │ └── ImageCompressTable.php
│ ├── include.php
│ ├── install
│ ├── error.php
│ ├── final.php
│ ├── index.php
│ ├── step1.php
│ └── unstep1.php
│ ├── lib
│ ├── AdminList.php
│ ├── Check.php
│ ├── Compress.php
│ ├── Convert.php
│ ├── Jpegoptim.php
│ └── Optipng.php
│ ├── options.php
│ └── updater.php
├── lib
├── AdminList.php
├── AvifConvertImagick.php
├── AvifConvertPhp.php
├── Cache.php
├── CacheCleaner.php
├── Check.php
├── Compress.php
├── CompressAgent.php
├── Convert.php
├── ConvertAgent.php
├── ConvertSearchPictures.php
├── Gif.php
├── IO.php
├── Jpegoptim.php
├── LazyConvert.php
├── Optipng.php
├── Process.php
├── Ps2Pdf.php
├── Resize.php
├── Svg.php
├── Webp.php
├── WebpConvertPhp.php
└── script.js
├── options.php
└── tabs
├── convert.php
├── donate.php
└── optimize.php
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | # github: [darkfriend]
4 | custom: [
5 | 'https://paypal.me/darkfriend',
6 | 'https://www.tinkoff.ru/cf/36wVfnMf7mo',
7 | 'https://yoomoney.ru/to/410011413398643'
8 | ]
9 |
--------------------------------------------------------------------------------
/migrations/0.10.0.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 23.07.2024
6 | * Time: 21:03
7 | */
8 |
9 | require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
10 |
11 | $curModuleName = 'dev2fun.imagecompress';
12 | \Bitrix\Main\Loader::includeModule('main');
13 | \Bitrix\Main\Loader::includeModule($curModuleName);
14 |
15 | \Bitrix\Main\Loader::registerAutoLoadClasses(
16 | $curModuleName,
17 | [
18 | 'Dev2funImageCompress' => 'include.php',
19 | ]
20 | );
21 |
22 | try {
23 | $sites = [];
24 | $rsSites = CSite::GetList();
25 | while ($site = $rsSites->Fetch()) {
26 | $sites[] = $site;
27 | }
28 |
29 | foreach ($sites as $site) {
30 | $pages = \Bitrix\Main\Config\Option::get(\Dev2funImageCompress::MODULE_ID, 'exclude_pages', '', $site['ID']);
31 | if ($pages) {
32 | $pages = \json_decode($pages, true);
33 | } else {
34 | $pages = [];
35 | }
36 | if (!$pages) {
37 | continue;
38 | }
39 | $pages = array_filter($pages, function($page) {
40 | return $page !== '#(\/bitrix\/.*)#';
41 | });
42 | \Bitrix\Main\Config\Option::set(
43 | \Dev2funImageCompress::MODULE_ID,
44 | 'exclude_pages',
45 | \json_encode(\array_values($pages)),
46 | $site['ID']
47 | );
48 | }
49 |
50 | \Dev2funImageCompress::ShowThanksNotice();
51 |
52 | die("0.10.0 - Success");
53 |
54 | } catch (Throwable $e) {
55 | ShowError($e->getMessage());
56 | }
57 |
--------------------------------------------------------------------------------
/migrations/0.11.0.php:
--------------------------------------------------------------------------------
1 |
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' => "Вам необходимо сделать перенос сконвертированных файлов в новое место расположение, ссылка",
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 | }
61 |
--------------------------------------------------------------------------------
/migrations/0.11.2.php:
--------------------------------------------------------------------------------
1 |
4 | * Date: 17.03.2025
5 | * Time: 19:34
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 | 'Dev2fun\ImageCompress\ImageCompressImagesTable' => 'classes/general/ImageCompressImagesTable.php',
19 | 'Dev2fun\ImageCompress\ImageCompressImagesConvertedTable' => 'classes/general/ImageCompressImagesConvertedTable.php',
20 | ]
21 | );
22 |
23 | try {
24 |
25 | /** @var Main\DB\MysqlCommonConnection $connection */
26 | $connection = \Dev2fun\ImageCompress\ImageCompressImagesTable::getEntity()->getConnection();
27 |
28 | $isTableExists = $connection->isTableExists(\Dev2fun\ImageCompress\ImageCompressImagesTable::getTableName());
29 | if ($isTableExists && !$connection->isIndexExists(\Dev2fun\ImageCompress\ImageCompressImagesTable::getTableName(), ['IMAGE_HASH', 'IMAGE_IGNORE'])) {
30 | $connection->createIndex(
31 | \Dev2fun\ImageCompress\ImageCompressImagesTable::getTableName(),
32 | 'indx_image_hash',
33 | ['IMAGE_HASH', 'IMAGE_IGNORE']
34 | );
35 | }
36 |
37 | $isTableExists = $connection->isTableExists(\Dev2fun\ImageCompress\ImageCompressImagesConvertedTable::getTableName());
38 | if ($isTableExists && !$connection->isIndexExists(\Dev2fun\ImageCompress\ImageCompressImagesConvertedTable::getTableName(), ['ORIGINAL_IMAGE_HASH'])) {
39 | $connection->createIndex(
40 | \Dev2fun\ImageCompress\ImageCompressImagesConvertedTable::getTableName(),
41 | 'indx_original_image_hash',
42 | ['ORIGINAL_IMAGE_HASH']
43 | );
44 | }
45 |
46 | \Dev2funImageCompress::ShowThanksNotice();
47 |
48 | die("0.11.2 - Success");
49 |
50 | } catch (Throwable $e) {
51 | ShowError($e->getMessage());
52 | }
53 |
--------------------------------------------------------------------------------
/migrations/0.11.4.php:
--------------------------------------------------------------------------------
1 |
4 | * Date: 12.05.2025
5 | * Time: 00:32
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 | $eventManager = \Bitrix\Main\EventManager::getInstance();
24 | $eventManager->registerEventHandler(
25 | "main",
26 | "OnFileDelete",
27 | $curModuleName,
28 | "Dev2fun\\ImageCompress\\Convert",
29 | "ConvertImageOnFileDeleteEvent"
30 | );
31 |
32 | \Dev2funImageCompress::ShowThanksNotice();
33 |
34 | die("0.11.4 - Success");
35 |
36 | } catch (Throwable $e) {
37 | ShowError($e->getMessage());
38 | }
39 |
--------------------------------------------------------------------------------
/migrations/0.5.0.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 23.06.2020
6 | * Time: 4:54
7 | */
8 |
9 | require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
10 |
11 | $curModuleName = 'dev2fun.imagecompress';
12 | \Bitrix\Main\Loader::includeModule($curModuleName);
13 | \Bitrix\Main\Loader::registerAutoLoadClasses(
14 | $curModuleName,
15 | [
16 | 'Dev2funImageCompress' => 'include.php',
17 | ]
18 | );
19 |
20 | $eventManager = \Bitrix\Main\EventManager::getInstance();
21 | $eventManager->registerEventHandler("main", "OnGetFileSRC", $curModuleName, "Dev2fun\\ImageCompress\\Convert", "CompressImageOnConvertEvent");
22 |
23 | \Dev2funImageCompress::ShowThanksNotice();
24 |
25 | die("0.5.0 - Success");
--------------------------------------------------------------------------------
/migrations/0.5.3.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 13.10.2020
6 | * Time: 2:12
7 | */
8 |
9 | require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
10 |
11 | $curModuleName = 'dev2fun.imagecompress';
12 | \Bitrix\Main\Loader::includeModule($curModuleName);
13 | \Bitrix\Main\Loader::registerAutoLoadClasses(
14 | $curModuleName,
15 | [
16 | 'Dev2funImageCompress' => 'include.php',
17 | ]
18 | );
19 |
20 | $eventManager = \Bitrix\Main\EventManager::getInstance();
21 | $eventManager->registerEventHandler("main", "OnAfterResizeImage", $curModuleName, "Dev2fun\\ImageCompress\\Convert", "CompressImageCacheOnConvertEvent");
22 |
23 | \Dev2funImageCompress::ShowThanksNotice();
24 |
25 | die("0.5.3 - Success");
--------------------------------------------------------------------------------
/migrations/0.6.0.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 23.06.2020
6 | * Time: 4:54
7 | */
8 |
9 | require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
10 |
11 | $curModuleName = 'dev2fun.imagecompress';
12 | \Bitrix\Main\Loader::includeModule($curModuleName);
13 | \Bitrix\Main\Loader::registerAutoLoadClasses(
14 | $curModuleName,
15 | [
16 | 'Dev2funImageCompress' => 'include.php',
17 | ]
18 | );
19 |
20 | $eventManager = \Bitrix\Main\EventManager::getInstance();
21 | $eventManager->registerEventHandler("main", "OnEndBufferContent", $curModuleName, "Dev2fun\\ImageCompress\\Convert", "PostConverterEvent");
22 |
23 | \Dev2funImageCompress::ShowThanksNotice();
24 |
25 | die("0.6.0 - Success");
--------------------------------------------------------------------------------
/migrations/0.6.1.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 23.06.2020
6 | * Time: 4:54
7 | */
8 |
9 | require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
10 |
11 | $curModuleName = 'dev2fun.imagecompress';
12 | \Bitrix\Main\Loader::includeModule('main');
13 | \Bitrix\Main\Loader::includeModule($curModuleName);
14 | \Bitrix\Main\Loader::registerAutoLoadClasses(
15 | $curModuleName,
16 | [
17 | 'Dev2funImageCompress' => 'include.php',
18 | ]
19 | );
20 |
21 | $eventManager = \Bitrix\Main\EventManager::getInstance();
22 | $eventManager->registerEventHandler("main", "OnEndBufferContent", $curModuleName, "Dev2fun\\ImageCompress\\Convert", "PostConverterEvent");
23 |
24 | \Bitrix\Main\Config\Option::set(
25 | $curModuleName,
26 | 'convert_mode',
27 | \serialize(['hitConvert', 'postConvert'])
28 | );
29 |
30 | \Dev2funImageCompress::ShowThanksNotice();
31 |
32 | die("0.6.1 - Success");
--------------------------------------------------------------------------------
/migrations/0.7.0.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 23.06.2020
6 | * Time: 4:54
7 | */
8 |
9 | require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
10 |
11 | $curModuleName = 'dev2fun.imagecompress';
12 | \Bitrix\Main\Loader::includeModule('main');
13 | \Bitrix\Main\Loader::includeModule($curModuleName);
14 | \Bitrix\Main\Loader::registerAutoLoadClasses(
15 | $curModuleName,
16 | [
17 | 'Dev2funImageCompress' => 'include.php',
18 | ]
19 | );
20 |
21 | \Bitrix\Main\Config\Option::set(
22 | $curModuleName,
23 | 'convert_quality',
24 | \Bitrix\Main\Config\Option::get($curModuleName, 'webp_quality', 80)
25 | );
26 |
27 | \Dev2funImageCompress::ShowThanksNotice();
28 |
29 | die("0.7.0 - Success");
--------------------------------------------------------------------------------
/migrations/0.9.0.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 26.04.2024
6 | * Time: 22:11
7 | */
8 |
9 | require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
10 |
11 | $curModuleName = 'dev2fun.imagecompress';
12 | \Bitrix\Main\Loader::includeModule('main');
13 | \Bitrix\Main\Loader::includeModule($curModuleName);
14 |
15 | \Bitrix\Main\Loader::registerAutoLoadClasses(
16 | $curModuleName,
17 | [
18 | 'Dev2funImageCompress' => 'include.php',
19 | "Dev2fun\ImageCompress\Cache" => 'lib/Cache.php',
20 | ]
21 | );
22 |
23 | try {
24 | // add agent
25 | $startTime = ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 120, 'FULL');
26 | $agentId = CAgent::AddAgent(
27 | \Dev2fun\ImageCompress\Cache::class . '::agentRun();',
28 | $curModuleName,
29 | 'Y',
30 | 120,
31 | '',
32 | 'N',
33 | $startTime,
34 | 100,
35 | false,
36 | false
37 | );
38 | if (!$agentId) {
39 | throw new Exception('Error when add agent for cache-delete');
40 | }
41 | \Bitrix\Main\Config\Option::set($curModuleName, 'cache_delete_agent', $agentId);
42 |
43 | \Dev2funImageCompress::ShowThanksNotice();
44 |
45 | die("0.9.0 - Success");
46 |
47 | } catch (Throwable $e) {
48 | ShowError($e->getMessage());
49 | }
50 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/admin/menu.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.11.0
5 | */
6 |
7 | IncludeModuleLangFile(__FILE__);
8 |
9 | use Bitrix\Main\Localization\Loc;
10 |
11 | if(!is_object($GLOBALS["USER_FIELD_MANAGER"])) {
12 | return false;
13 | }
14 |
15 | if(!$USER->CanDoOperation("dev2fun.imagecompress")) {
16 | return false;
17 | }
18 |
19 | $moduleId = 'dev2fun.imagecompress';
20 | if (!\Bitrix\Main\Loader::includeModule($moduleId)) {
21 | return false;
22 | }
23 |
24 | $items[] = [
25 | 'text' => Loc::getMessage('DEV2FUN_IMAGECOMPRESS_MENU_ITEM_FILES'),
26 | 'url' => "dev2fun_imagecompress_files.php?lang=".LANGUAGE_ID,
27 | 'module_id' => $moduleId,
28 | 'items_id' => 'menu_dev2fun_imagecompress_files',
29 | 'more_url' => [
30 | 'dev2fun_imagecompress_files.php',
31 | ],
32 | ];
33 | $items[] = [
34 | 'text' => Loc::getMessage('DEV2FUN_IMAGECOMPRESS_MENU_ITEM_CONVERT'),
35 | 'url' => "dev2fun_imagecompress_convert.php?lang=".LANGUAGE_ID,
36 | 'module_id' => $moduleId,
37 | 'items_id' => 'menu_dev2fun_imagecompress_convert',
38 | 'more_url' => [
39 | 'dev2fun_imagecompress_convert.php',
40 | ],
41 | ];
42 | $items[] = [
43 | 'text' => Loc::getMessage('DEV2FUN_IMAGECOMPRESS_MENU_ITEM_CONVERT_MOVE'),
44 | 'url' => "dev2fun_imagecompress_convert_move.php?lang=".LANGUAGE_ID,
45 | 'module_id' => $moduleId,
46 | 'items_id' => 'menu_dev2fun_imagecompress_convert_move',
47 | 'more_url' => [
48 | 'dev2fun_imagecompress_convert_move.php',
49 | ],
50 | ];
51 |
52 | $arMenu = [
53 | "parent_menu" => "global_menu_settings",
54 | "section" => "dev2fun_imagecompress",
55 | "items_id" => "dev2fun_imagecompress",
56 | // "section" => "settings",
57 | "sort" => 900,
58 | "text" => Loc::getMessage("DEV2FUN_IMAGECOMPRESS_MENU_TEXT"),
59 | "title" => Loc::getMessage("DEV2FUN_IMAGECOMPRESS_MENU_TITLE"),
60 | "url" => "dev2fun_imagecompress_files.php?lang=".LANGUAGE_ID,
61 | "more_url" => [
62 | "dev2fun_imagecompress_files.php",
63 | "dev2fun_imagecompress_convert.php",
64 | "dev2fun_imagecompress_convert_move.php",
65 | ],
66 | "icon" => "dev2fun_compressimage_menu_icon",
67 | "page_icon" => "dev2fun_compressimage_page_icon",
68 | "items" => $items,
69 | ];
70 |
71 | return $arMenu;
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/classes/general/ImageCompressImagesConvertedTable.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.8.3
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | use Bitrix\Main;
10 | use Bitrix\Main\Entity;
11 | use Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class ImageCompressImagesConvertedTable extends Entity\DataManager
16 | {
17 | static $module_id = "dev2fun.imagecompress";
18 |
19 | public static function getFilePath()
20 | {
21 | return __FILE__;
22 | }
23 |
24 | public static function getTableName()
25 | {
26 | return 'b_d2f_imagecompress_images_converted';
27 | // return 'b_d2f_imagecompress_webp_images';
28 | }
29 |
30 | public static function getTableTitle()
31 | {
32 | return Loc::getMessage('DEV2FUN_IMAGECOMPRESS_PAGES_TITLE');
33 | }
34 |
35 | public static function getMap()
36 | {
37 | return [
38 | new Entity\IntegerField('ID', [
39 | 'primary' => true,
40 | 'autocomplete' => true,
41 | ]),
42 |
43 | new Entity\StringField('IMAGE_PATH', [
44 | 'required' => true,
45 | ]),
46 |
47 | new Entity\StringField('ORIGINAL_IMAGE_HASH', [
48 | 'required' => true,
49 | ]),
50 |
51 | new Entity\EnumField('IMAGE_TYPE', [
52 | 'values' => [
53 | Convert::TYPE_WEBP,
54 | Convert::TYPE_AVIF,
55 | ],
56 | 'required' => true,
57 | ]),
58 |
59 | ];
60 | }
61 |
62 | /**
63 | * Create table
64 | * @return void
65 | * @throws Main\ArgumentException
66 | * @throws Main\DB\SqlQueryException
67 | * @throws Main\SystemException
68 | */
69 | public static function createTable()
70 | {
71 | static::getEntity()->createDbTable();
72 | /** @var Main\DB\MysqlCommonConnection $connection */
73 | $connection = static::getEntity()->getConnection();
74 |
75 | $connection->createIndex(
76 | static::getTableName(),
77 | 'unique_image_path_type',
78 | ['IMAGE_PATH', 'IMAGE_TYPE'],
79 | $connection::INDEX_UNIQUE
80 | );
81 | }
82 |
83 | /**
84 | * Drop table
85 | * @return void
86 | * @throws Main\ArgumentException
87 | * @throws Main\DB\SqlQueryException
88 | * @throws Main\SystemException
89 | */
90 | public static function dropTable()
91 | {
92 | static::getEntity()->getConnection()->dropTable(static::getTableName());
93 | }
94 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/classes/general/ImageCompressImagesTable.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.11.2
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | use Bitrix\Main;
10 | use Bitrix\Main\Entity;
11 | use Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class ImageCompressImagesTable extends Entity\DataManager
16 | {
17 | static $module_id = "dev2fun.imagecompress";
18 |
19 | public static function getFilePath()
20 | {
21 | return __FILE__;
22 | }
23 |
24 | public static function getTableName()
25 | {
26 | return 'b_d2f_imagecompress_images';
27 | }
28 |
29 | public static function getTableTitle()
30 | {
31 | return Loc::getMessage('DEV2FUN_IMAGECOMPRESS_PAGES_TITLE');
32 | }
33 |
34 | public static function getMap()
35 | {
36 | return [
37 | new Entity\IntegerField('ID', [
38 | 'primary' => true,
39 | 'autocomplete' => true,
40 | ]),
41 |
42 | new Entity\StringField('IMAGE_PATH', [
43 | 'unique' => true,
44 | ]),
45 |
46 | new Entity\StringField('IMAGE_HASH', [
47 | 'nullable' => true,
48 | ]),
49 |
50 | new Entity\BooleanField('IMAGE_IGNORE', [
51 | 'values' => ['N', 'Y'],
52 | 'default_value' => 'N',
53 | ]),
54 | // ->configureValues('N', 'Y')
55 | // ->configureDefaultValue('N'),
56 |
57 | new Entity\DatetimeField('DATE_CHECK', [
58 | 'nullable' => true,
59 | ]),
60 | // ->configureNullable(),
61 |
62 | new Entity\DatetimeField('DATE_UPDATE', [
63 | 'nullable' => true,
64 | ]),
65 | // ->configureNullable(),
66 |
67 | (new Entity\ReferenceField(
68 | 'CONVERTED_IMAGE',
69 | ImageCompressImagesToConvertedTable::class,
70 | [
71 | '=this.ID' => 'ref.IMAGE_ID',
72 | // '=this.IMAGE_TYPE' => 'ref.IMAGE_TYPE',
73 | ]
74 | // ['join_type' => 'INNER']
75 | )),
76 |
77 | ];
78 | }
79 |
80 | /**
81 | * Create table
82 | * @return void
83 | * @throws Main\ArgumentException
84 | * @throws Main\DB\SqlQueryException
85 | * @throws Main\SystemException
86 | */
87 | public static function createTable()
88 | {
89 | static::getEntity()->createDbTable();
90 | /** @var Main\DB\MysqlCommonConnection $connection */
91 | $connection = static::getEntity()->getConnection();
92 |
93 | $connection->createIndex(
94 | static::getTableName(),
95 | 'indx_date_check',
96 | ['DATE_CHECK']
97 | );
98 |
99 | if (!$connection->isIndexExists(static::getTableName(), ['IMAGE_HASH', 'IMAGE_IGNORE'])) {
100 | $connection->createIndex(
101 | static::getTableName(),
102 | 'indx_image_hash',
103 | ['IMAGE_HASH', 'IMAGE_IGNORE']
104 | );
105 | }
106 | }
107 |
108 | /**
109 | * Drop table
110 | * @return void
111 | * @throws Main\ArgumentException
112 | * @throws Main\DB\SqlQueryException
113 | * @throws Main\SystemException
114 | */
115 | public static function dropTable()
116 | {
117 | static::getEntity()->getConnection()->dropTable(static::getTableName());
118 | }
119 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/classes/general/ImageCompressTable.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.8.3
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | use Bitrix\Main\Entity;
10 | use Bitrix\Main\Localization\Loc;
11 |
12 | //Loc::loadMessages(__FILE__);
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class ImageCompressTable extends Entity\DataManager
16 | {
17 | static $module_id = "dev2fun.imagecompress";
18 |
19 | public static function getFilePath()
20 | {
21 | return __FILE__;
22 | }
23 |
24 | public static function getTableName()
25 | {
26 | return 'b_d2f_imagecompress_files';
27 | }
28 |
29 | public static function getTableTitle()
30 | {
31 | return Loc::getMessage('DEV2FUN_IMAGECOMPRESS_REDIRECTS_TITLE');
32 | }
33 |
34 | public static function getMap()
35 | {
36 | return array(
37 | new Entity\IntegerField('SIZE_BEFORE'),
38 | new Entity\IntegerField('SIZE_AFTER'),
39 | new Entity\IntegerField('FILE_ID', [
40 | 'primary' => true,
41 | ]),
42 | new Entity\ReferenceField(
43 | 'FILE',
44 | 'Bitrix\Main\FileTable',
45 | [
46 | '=this.FILE_ID' => 'ref.ID'
47 | ]
48 | ),
49 | );
50 | }
51 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/classes/general/MySqlHelper.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.8.0
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | class MySqlHelper
10 | {
11 | /**
12 | * @param string $tableName
13 | * @param array $insertRowsFields
14 | * @return string
15 | * @throws \Bitrix\Main\ArgumentTypeException
16 | * @throws \Bitrix\Main\DB\SqlQueryException
17 | */
18 | public static function getInsertIgnore(string $tableName, array $insertFields): string
19 | {
20 | $connection = \Bitrix\Main\Application::getInstance()->getConnection();
21 | $sqlHelper = $connection->getSqlHelper();
22 |
23 | $insert = $sqlHelper->prepareInsert($tableName, $insertFields);
24 |
25 | if ($tableName && !empty($insert[0]) && !empty($insert[1])) {
26 | $sql = "
27 | INSERT IGNORE INTO {$sqlHelper->quote($tableName)} ({$insert[0]})
28 | VALUES ({$insert[1]})";
29 | } else {
30 | $sql = '';
31 | }
32 |
33 | return $sql;
34 | }
35 |
36 | /**
37 | * @param string $tableName
38 | * @param array $insertRowsFields
39 | * @return string
40 | * @throws \Bitrix\Main\ArgumentTypeException
41 | * @throws \Bitrix\Main\DB\SqlQueryException
42 | */
43 | public static function getInsertIgnoreMulti(string $tableName, array $insertRowsFields): string
44 | {
45 | $connection = \Bitrix\Main\Application::getInstance()->getConnection();
46 | $sqlHelper = $connection->getSqlHelper();
47 |
48 | $columns = null;
49 | $insertRows = [];
50 | foreach ($insertRowsFields as $insertFields) {
51 | $insert = $sqlHelper->prepareInsert($tableName, $insertFields);
52 | if (empty($columns) && !empty($insert[0])) {
53 | $columns = $insert[0];
54 | }
55 | if (!empty($insert[1])) {
56 | $insertRows[] = "({$insert[1]})";
57 | }
58 | }
59 |
60 | if ($columns && $insertRows && $tableName) {
61 | $sql = "
62 | INSERT IGNORE INTO {$sqlHelper->quote($tableName)} ({$columns})
63 | VALUES ".implode(', ', $insertRows);
64 | } else {
65 | $sql = '';
66 | }
67 |
68 | return $sql;
69 | }
70 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/console/cache-delayed-delete.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
5 | * @version 0.9.0
6 | * @since 0.9.0
7 | * @example /path_to_module/console/cache-delayed-delete.php -l=1000
8 | * @example /2 * * * * php -f /path_to_module/console/cache-delayed-delete.php -l=1000
9 | */
10 |
11 | set_time_limit(3600);
12 | $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../../';
13 |
14 | define("NOT_CHECK_PERMISSIONS", true);
15 | //define("BX_UTF", true);
16 | define("NO_KEEP_STATISTIC", true);
17 | define("NO_AGENT_STATISTIC", true);
18 | //define("NOT_CHECK_PERMISSIONS", true);
19 | define("NO_AGENT_CHECK", true);
20 | define("BX_BUFFER_USED", true);
21 | error_reporting(E_ALL | E_ERROR | E_PARSE);
22 | ini_set("display_errors", "On");
23 |
24 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
25 |
26 | //error_reporting(E_ALL|E_ERROR|E_PARSE);
27 | //ini_set("display_errors","On");
28 |
29 | \Bitrix\Main\Loader::includeModule('main');
30 | \Bitrix\Main\Loader::includeModule('dev2fun.imagecompress');
31 |
32 | $params = getopt('l::');
33 | if (!empty($params['l'])) {
34 | $limit = (int)$params['l'];
35 | } else {
36 | $limit = \Bitrix\Main\Config\Option::get('dev2fun.imagecompress', 'cache_delete_length', 1000);
37 | }
38 |
39 | if (empty($limit)) {
40 | $limit = 1000;
41 | }
42 |
43 | \Bitrix\Main\Data\CacheEngineFiles::delayedDelete($limit);
44 |
45 | require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/console/convert.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
5 | * @version 0.8.0
6 | * @since 0.7.4
7 | * @example ./convert.php -l=10
8 | */
9 |
10 | set_time_limit(3600);
11 | $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../../';
12 |
13 | define("NOT_CHECK_PERMISSIONS", true);
14 | //define("BX_UTF", true);
15 | define("NO_KEEP_STATISTIC", true);
16 | //define("NOT_CHECK_PERMISSIONS", true);
17 | define("BX_BUFFER_USED", true);
18 | error_reporting(E_ALL | E_ERROR | E_PARSE);
19 | ini_set("display_errors", "On");
20 |
21 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
22 |
23 | //error_reporting(E_ALL|E_ERROR|E_PARSE);
24 | //ini_set("display_errors","On");
25 |
26 | \Bitrix\Main\Loader::includeModule('main');
27 | \Bitrix\Main\Loader::includeModule('iblock');
28 | \Bitrix\Main\Loader::includeModule('dev2fun.imagecompress');
29 |
30 | $params = getopt('l::');
31 | if (!empty($params['l'])) {
32 | $limit = (int)$params['l'];
33 | } else {
34 | $limit = 500;
35 | }
36 |
37 | $connection = \Bitrix\Main\Application::getConnection();
38 | $sqlHelper = $connection->getSqlHelper();
39 | $cnt = $connection->queryScalar(
40 | "SELECT COUNT(*) FROM b_file WHERE CONTENT_TYPE IN ('image/jpeg', 'image/png', 'image/gif')"
41 | );
42 |
43 | echo "Found {$cnt} files" . PHP_EOL;
44 |
45 | $convert = \Dev2fun\ImageCompress\Convert::getInstance();
46 |
47 | if (!$convert->enable) {
48 | echo "Converter is not active. Please activate function convert in module settings." . PHP_EOL;
49 | die();
50 | }
51 |
52 | echo "Start progress" . PHP_EOL;
53 |
54 | $lastId = null;
55 | $upload_dir = \Bitrix\Main\Config\Option::get('main', 'upload_dir', 'upload');
56 |
57 | //$files = [];
58 | $stepOnPage = 0;
59 | for ($i=1; $i<=$cnt; $i+=$limit) {
60 | $sql = "SELECT f.* FROM b_file f WHERE f.CONTENT_TYPE IN ('image/jpeg', 'image/png', 'image/gif')";
61 | if ($lastId) {
62 | $sql .= " AND f.ID>{$sqlHelper->forSql($lastId)}";
63 | }
64 | $sql .= " ORDER BY f.ID ASC LIMIT {$sqlHelper->forSql($limit)}";
65 | $recordset = $connection->query($sql);
66 | while ($arFile = $recordset->fetch()) {
67 | $stepOnPage++;
68 | $progressValue = round($stepOnPage / $cnt * 100, 2);
69 | $pathFile = "{$_SERVER["DOCUMENT_ROOT"]}/{$upload_dir}/{$arFile["SUBDIR"]}/{$arFile["FILE_NAME"]}";
70 | if (!is_file($pathFile)) {
71 | echo "Warning: file #{$arFile['ID']} not fount. Continue." . PHP_EOL;
72 | continue;
73 | }
74 | echo "Progress: convert image #{$arFile['ID']}" . PHP_EOL;
75 |
76 | if(!$convert->process($arFile) && $convert->LAST_ERROR) {
77 | echo "ERROR! {$convert->LAST_ERROR}" . PHP_EOL;
78 | } else {
79 | echo "Success. Image #{$arFile['ID']} converted." . PHP_EOL;
80 | }
81 |
82 | $lastId = $arFile['ID'];
83 | echo "Progress: {$progressValue}%" . PHP_EOL;
84 | }
85 | }
86 |
87 | echo "Finish progress" . PHP_EOL;
88 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/console/optimize.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
5 | * @version 0.7.4
6 | * @copyright dev2fun
7 | */
8 | set_time_limit(3600);
9 | $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../../';
10 |
11 | define("NOT_CHECK_PERMISSIONS", true);
12 | //define("BX_UTF", true);
13 | define("NO_KEEP_STATISTIC", true);
14 | //define("NOT_CHECK_PERMISSIONS", true);
15 | define("BX_BUFFER_USED", true);
16 | error_reporting(E_ALL | E_ERROR | E_PARSE);
17 | ini_set("display_errors", "On");
18 |
19 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
20 |
21 | //error_reporting(E_ALL|E_ERROR|E_PARSE);
22 | //ini_set("display_errors","On");
23 |
24 | \Bitrix\Main\Loader::includeModule('main');
25 | \Bitrix\Main\Loader::includeModule('iblock');
26 | \Bitrix\Main\Loader::includeModule('dev2fun.imagecompress');
27 |
28 | $params = getopt('c::', ['limit::']);
29 |
30 | $limit = \Bitrix\Main\Config\Option::get('dev2fun.imagecompress', "cnt_step", 30);
31 | if (isset($params['limit'])) {
32 | $limit = (int)$params['limit'];
33 | }
34 |
35 | $noCompress = true;
36 | if (isset($params['c'])) {
37 | $noCompress = $params['c'] === 'N' ? false : true;
38 | }
39 |
40 | $filterList = [
41 | // 'COMRESSED' => 'N',
42 | '@CONTENT_TYPE' => [
43 | 'image/jpeg',
44 | 'image/png',
45 | 'application/pdf',
46 | ],
47 | ];
48 | if ($noCompress) {
49 | $filterList['COMRESSED'] = 'N';
50 | }
51 |
52 | $rsRes = \Dev2fun\ImageCompress\Compress::getInstance()->getFileList(
53 | [],
54 | $filterList,
55 | $limit
56 | );
57 |
58 | //$pageSize = \Bitrix\Main\Config\Option::get('dev2fun.imagecompress', "cnt_step", 30);
59 | $rsRes->NavStart($limit, false);
60 |
61 | $navPageCount = $rsRes->NavPageCount;
62 | $currentPageSize = $rsRes->NavPageSize;
63 | if (!$navPageCount) $navPageCount = 1;
64 | $stepOnPage = 1;
65 |
66 | while ($arFile = $rsRes->NavNext(true)) {
67 | $strFilePath = \CFile::GetPath($arFile["ID"]);
68 | $progressValue = $stepOnPage / $currentPageSize * 100;
69 | if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $strFilePath)) {
70 | \Dev2fun\ImageCompress\Compress::getInstance()->addCompressTable($arFile['ID'], [
71 | 'FILE_ID' => $arFile['ID'],
72 | 'SIZE_BEFORE' => 0,
73 | 'SIZE_AFTER' => 0,
74 | ]);
75 | echo "Error. Image #{$arFile['ID']} is not compressed! File not found!" . PHP_EOL;
76 | echo "Progress: {$progressValue}%" . PHP_EOL;
77 | $stepOnPage++;
78 | continue;
79 | }
80 | echo "Success. Image #{$arFile['ID']} compressed." . PHP_EOL;
81 | echo "Progress: {$progressValue}%" . PHP_EOL;
82 | $recCompress = \Dev2fun\ImageCompress\Compress::getInstance()->compressImageByID($arFile['ID']);
83 | $stepOnPage++;
84 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/default_option.php:
--------------------------------------------------------------------------------
1 | {
9 | let publicPath
10 | switch (dir) {
11 | case 'devserver':
12 | publicPath = '/bitrix/js/dev2fun.imagecompress/vue/'
13 | break
14 | case 'server':
15 | publicPath = '/bitrix/js/dev2fun.imagecompress/vue/'
16 | break
17 | default:
18 | publicPath = '/bitrix/js/dev2fun.imagecompress/vue/'
19 | break
20 | }
21 | return publicPath
22 | })(process.env.DIR)
23 |
24 | const path = require('node:path')
25 |
26 | const PATHS = {
27 | src: path.join(__dirname, '../src'),
28 | // dist: path.join(__dirname, '../dist', destinationDir),
29 | dist: path.join(__dirname, '../../../../js/dev2fun.imagecompress/vue'),
30 | // assets: 'assets/',
31 | }
32 |
33 | const webpackConfig = merge(commonConfig, {
34 | mode: 'development',
35 | devtool: 'cheap-module-source-map',
36 | // entry: {
37 | // vendor: ['bootstrap_vue', 'icons'],
38 | // },
39 | output: {
40 | path: PATHS.dist,
41 | publicPath,
42 | filename: 'js/[name].bundle.js',
43 | chunkFilename: 'js/[name].[contenthash:8].chunk.js',
44 | },
45 | optimization: {
46 | minimizer: [
47 | new TerserPlugin({
48 | // cache: true,
49 | parallel: true,
50 | terserOptions: {
51 | warnings: false,
52 | ie8: false,
53 | output: {
54 | comments: false,
55 | },
56 | },
57 | extractComments: false,
58 | }),
59 | ],
60 | splitChunks: {
61 | // chunks: 'all',
62 | maxInitialRequests: Infinity,
63 | minSize: 0,
64 | },
65 | },
66 | plugins: [
67 | new webpack.EnvironmentPlugin(environment),
68 | new webpack.HotModuleReplacementPlugin(),
69 | new webpack.optimize.ModuleConcatenationPlugin(),
70 | ],
71 | })
72 |
73 | module.exports = webpackConfig
74 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
13 |
17 |
21 |
25 | Document
26 |
27 |
28 |
29 |
30 |
34 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "berry-vuetify-vuejs",
3 | "version": "1.3.0",
4 | "private": true,
5 | "author": "CodedThemes",
6 | "scripts": {
7 | "preview": "vite preview --port 5050",
8 | "preview:school": "cross-env NODE_ENV=development PROJECT=school vite preview --port 5050",
9 | "typecheck": "vue-tsc --noEmit",
10 | "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
11 | "dev": "cross-env NODE_ENV=development PROJECT=school DIR=devserver TYPE=stage webpack --watch",
12 | "build": "cross-env NODE_ENV=production PROJECT=school DIR=server TYPE=prod webpack --progress ",
13 | "clean:school": "shx rm -rf ./dist/school",
14 | "format": "prettier . --write"
15 | },
16 | "dependencies": {
17 | "@mdi/js": "^7.4.47",
18 | "@suadelabs/vue3-multiselect": "^1.0.2",
19 | "@tabler/icons-vue": "^3.21.0",
20 | "@types/aos": "3.0.7",
21 | "aos": "2.3.4",
22 | "axios": "^1.7.7",
23 | "cross-env": "^7.0.3",
24 | "empty-lite": "^2.0.0",
25 | "lodash": "4.17.21",
26 | "sweetalert2": "^11.6.13",
27 | "tailwindcss": "^3.4.15",
28 | "vee-validate": "4.12.5",
29 | "vue-clipboard3": "2.0.0",
30 | "vue-draggable-next": "2.2.1",
31 | "vue-svg-inline-plugin": "^2.2.3",
32 | "vue-tabler-icons": "2.21.0"
33 | },
34 | "devDependencies": {
35 | "@babel/core": "^7.24.4",
36 | "@babel/eslint-parser": "^7.25.1",
37 | "@babel/preset-env": "^7.24.4",
38 | "@mdi/font": "^7.4.47",
39 | "@rushstack/eslint-patch": "^1.7.2",
40 | "@tsconfig/node20": "^20.1.2",
41 | "@types/chance": "1.1.6",
42 | "@types/lodash": "^4.14.202",
43 | "@types/node": "^20.11.18",
44 | "@vitejs/plugin-vue": "5.0.4",
45 | "@vue/eslint-config-airbnb": "^8.0.0",
46 | "@vue/eslint-config-prettier": "9.0.0",
47 | "@vue/eslint-config-typescript": "12.0.0",
48 | "@vue/tsconfig": "0.5.1",
49 | "autoprefixer": "^10.4.20",
50 | "babel-loader": "^9.1.3",
51 | "clean-webpack-plugin": "^4.0.0",
52 | "compression-webpack-plugin": "^11.1.0",
53 | "copy-webpack-plugin": "^12.0.2",
54 | "css-loader": "^7.1.1",
55 | "css-minimizer-webpack-plugin": "^6.0.0",
56 | "eslint": "^8.56.0",
57 | "eslint-config-prettier": "^9.1.0",
58 | "eslint-plugin-require": "^0.0.1",
59 | "eslint-plugin-vue": "^9.21.1",
60 | "mini-css-extract-plugin": "^2.9.0",
61 | "postcss": "^8.4.49",
62 | "postcss-loader": "^8.1.1",
63 | "postcss-preset-env": "^10.1.1",
64 | "prettier": "3.2.5",
65 | "sass": "1.70.0",
66 | "sass-loader": "^14.1.0",
67 | "style-loader": "^4.0.0",
68 | "svgo-loader": "^4.0.0",
69 | "terser-webpack-plugin": "^5.3.10",
70 | "ts-loader": "^9.5.1",
71 | "typescript": "5.3.3",
72 | "url-loader": "^4.1.1",
73 | "vue-cli-plugin-vuetify": "2.5.8",
74 | "vue-loader": "^17.4.2",
75 | "vue-style-loader": "^4.1.3",
76 | "vue-svg-loader-2": "^0.17.1",
77 | "vue-template-compiler": "^0.1.0",
78 | "vue-tsc": "^2.1.10",
79 | "webpack": "^5.91.0",
80 | "webpack-bundle-analyzer": "^4.10.2",
81 | "webpack-cli": "^5.1.4",
82 | "webpack-hot-middleware": "^2.26.1",
83 | "webpack-merge": "^5.10.0"
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/postcss.config.js:
--------------------------------------------------------------------------------
1 | const autoprefixer = require('autoprefixer');
2 | const tailwindcss = require('tailwindcss');
3 |
4 | module.exports = {
5 | plugins: [
6 | "postcss-preset-env",
7 | tailwindcss,
8 | autoprefixer,
9 | ],
10 | }
11 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
38 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/components/AdminMessage.vue:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
29 |
30 |
31 | {{ title }}
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
42 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/components/AdminNote.vue:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
38 |
39 |
40 |
43 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/components/ProgressBar.vue:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
24 |
25 |
26 | {{ title }}
27 |
28 |
29 |
35 |
36 | {{ progressText }}
37 |
38 |
39 |
{{ progressText }}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/main.ts:
--------------------------------------------------------------------------------
1 | import {createApp, defineAsyncComponent} from 'vue'
2 | import '@/scss/style.scss'
3 |
4 | const MoverFiles = defineAsyncComponent(() => import('@/components/MoverFiles.vue'))
5 |
6 | const app = createApp({
7 | components: {
8 | MoverFiles
9 | }
10 | })
11 |
12 | app.config.globalProperties.appName = 'dev2fun.imagecompress'
13 | app.config.globalProperties.appVersion = '1.0.0'
14 | app.config.compilerOptions.whitespace = 'preserve'
15 |
16 | app.mount('#dev2fun_imagecompress_convert_move')
17 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/methods/configMain.js:
--------------------------------------------------------------------------------
1 | export const configMain = {
2 | debug: true,
3 | // version: 'v1',
4 | url() {
5 | // return `/api/${this.version}`;
6 | return '/bitrix/admin/dev2fun_imagecompress_convert_move.php'
7 | },
8 | }
9 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/methods/http.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import { configMain } from './configMain'
3 |
4 | const http = axios.create({
5 | // baseURL: process.env.VUE_APP_ROOT_API,
6 | baseURL: configMain.url(),
7 | timeout: 60000,
8 | // headers: {
9 | // 'Content-Type': 'application/json',
10 | // // 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
11 | // },
12 | // transformRequest: (data, headers) => {
13 | // // console.log(data);
14 | // if (data) data = stringify(data);
15 | // return data;
16 | // }
17 | })
18 |
19 | http.interceptors.request.use(
20 | (config) => {
21 |
22 | // if (config.method === 'post') {
23 | // config.params = Object.assign({}, config.params, {sessid: BX.bitrix_sessid()})
24 | // }
25 | config.params = Object.assign({}, config.params, {sessid: BX.bitrix_sessid()})
26 |
27 | return config
28 | },
29 | (error) => {
30 | if (configMain.debug) {
31 | console.log(error)
32 | }
33 | return Promise.reject(error)
34 | },
35 | )
36 |
37 | http.interceptors.response.use(
38 | (response) => {
39 | const res = response.data
40 | if (configMain.debug) {
41 | console.log(res)
42 | }
43 | return res
44 | },
45 | (error) => {
46 | if (configMain.debug) {
47 | console.log(`err: ${error}`) // for debug
48 | }
49 | return Promise.reject(error)
50 | },
51 | )
52 |
53 | export default http
54 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/src/scss/style.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/utf8/dev2fun.imagecompress/frontend/src/scss/style.scss
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | module.exports = {
3 | purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
4 | darkMode: false,
5 | content: [],
6 | theme: {
7 | extend: {},
8 | },
9 | plugins: [],
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@vue/tsconfig/tsconfig.dom.json",
3 | "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/types/.d.ts"],
4 | "compilerOptions": {
5 | "ignoreDeprecations": "5.0",
6 | "baseUrl": ".",
7 | "paths": {
8 | "@/*": ["./src/*"]
9 | },
10 | "allowJs": true
11 | },
12 | "references": [
13 | {
14 | "path": "./tsconfig.vite-config.json"
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/frontend/webpack.config.js:
--------------------------------------------------------------------------------
1 | const environment = (process.env.NODE_ENV || 'development').trim()
2 |
3 | if (environment === 'development') {
4 | module.exports = require('./config/webpack.config.dev')
5 | } else {
6 | module.exports = require('./config/webpack.config.prod')
7 | }
8 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/include/options/gif.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.5.0
6 | */
7 |
8 | /**
9 | * @var string $optType
10 | */
11 | use \Bitrix\Main\Localization\Loc;
12 | use \Bitrix\Main\Config\Option;
13 | ?>
14 |
15 |
16 | = Loc::getMessage('D2F_IMAGECOMPRESS_HEADING_TEXT_SETTINGS', ['#MODULE#' => $optType]) ?>
17 | |
18 |
19 |
20 |
21 |
24 | |
25 |
26 |
35 | />
36 | |
37 |
38 |
39 |
40 |
41 | |
42 |
43 |
52 | |
53 |
54 |
55 |
56 |
59 | |
60 |
61 | "
65 | /> /gifsicle
66 | |
67 |
68 |
69 |
70 |
71 |
72 |
75 | |
76 |
77 |
84 | |
85 |
86 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/include/options/svg.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.8.5
6 | */
7 |
8 | /**
9 | * @var string $optType
10 | */
11 | use \Bitrix\Main\Localization\Loc;
12 | use \Bitrix\Main\Config\Option;
13 | ?>
14 |
15 |
16 | = Loc::getMessage('D2F_IMAGECOMPRESS_HEADING_TEXT_SETTINGS', ['#MODULE#' => $optType]) ?>
17 | |
18 |
19 |
20 |
21 |
24 | |
25 |
26 |
36 | />
37 | |
38 |
39 |
40 |
41 |
42 |
43 | |
44 |
45 |
54 | |
55 |
56 |
57 |
58 |
59 |
62 | |
63 |
64 | "
68 | /> /node
69 | |
70 |
71 |
72 |
73 |
74 |
77 | |
78 |
79 | "
83 | /> /svgo
84 | |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/admin/dev2fun_imagecompress_convert.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/error.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.2.1
6 | */
7 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
8 | if(!check_bitrix_sessid()) return;
9 |
10 | use Bitrix\Main\Loader,
11 | Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | Loader::includeModule('main');
16 |
17 | CAdminMessage::ShowMessage(array(
18 | "MESSAGE"=>$GLOBALS['D2F_COMPRESSIMAGE_ERROR'],
19 | "TYPE"=>"ERROR"
20 | ));
21 | echo BeginNote();
22 | echo $GLOBALS['D2F_COMPRESSIMAGE_ERROR_NOTES'];
23 | echo EndNote();
24 |
25 | echo ''.Loc::getMessage('D2F_COMPRESSIMAGE_GOTO_FIRST').'
';
26 | echo ''.Loc::getMessage('D2F_COMPRESSIMAGE_GOTO_MODULES').'';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/final.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.2.1
6 | */
7 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
8 | if(!check_bitrix_sessid()) return;
9 |
10 | use Bitrix\Main\Loader,
11 | Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | Loader::includeModule('main');
16 |
17 | CAdminMessage::ShowMessage(array(
18 | "MESSAGE"=>Loc::getMessage('D2F_IMAGECOMPRESS_INSTALL_SUCCESS'),
19 | "TYPE"=>"OK"
20 | ));
21 | echo BeginNote();
22 | echo Loc::getMessage("D2F_IMAGECOMPRESS_INSTALL_LAST_MSG");
23 | echo EndNote();
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/js/vue/css/bundle.css:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/js/vue/js/265.70db9293.chunk.js:
--------------------------------------------------------------------------------
1 | "use strict";(self.webpackChunkberry_vuetify_vuejs=self.webpackChunkberry_vuetify_vuejs||[]).push([[265],{RtvE:(e,s,a)=>{a.r(s),a.d(s,{default:()=>d});var t=a("L75T");const i={class:"adm-info-message"},n={class:"adm-info-message-title"},d=(0,t.pM)({__name:"AdminMessage",props:{title:{type:String,default:"Заголовок"},type:{type:String,default:"ERROR"}},setup(e){const s=e,a=(0,t.EW)((()=>"OK"===s.type?"adm-info-message-green":"adm-info-message-red"));return(s,d)=>((0,t.uX)(),(0,t.CE)("div",{class:(0,t.C4)(["adm-info-message-wrap",a.value])},[(0,t.Lk)("div",i,[(0,t.Lk)("div",n,(0,t.v_)(e.title),1),d[0]||(d[0]=(0,t.Lk)("div",{class:"adm-info-message-icon"},null,-1))])],2))}})}}]);
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/js/vue/js/534.e3a55a2c.chunk.js:
--------------------------------------------------------------------------------
1 | "use strict";(self.webpackChunkberry_vuetify_vuejs=self.webpackChunkberry_vuetify_vuejs||[]).push([[534],{If9R:(e,s,a)=>{a.r(s),a.d(s,{default:()=>o});var r=a("L75T");const t={class:"adm-info-message"},o=(0,r.pM)({__name:"AdminNote",props:{style:{type:String||Object,default:{position:"relative",top:"-15px"}},color:{type:String,default:""}},setup:e=>(s,a)=>((0,r.uX)(),(0,r.CE)("div",{class:(0,r.C4)(["adm-info-message-wrap",{"adm-info-message-gray":"gray"===e.color,"adm-info-message-red":"red"===e.color,"adm-info-message-green":"green"===e.color}]),style:(0,r.Tr)(e.style)},[(0,r.Lk)("div",t,[(0,r.RG)(s.$slots,"default")])],6))})}}]);
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/js/vue/js/683.9c04fc2e.chunk.js:
--------------------------------------------------------------------------------
1 | "use strict";(self.webpackChunkberry_vuetify_vuejs=self.webpackChunkberry_vuetify_vuejs||[]).push([[683],{ks9F:(s,e,r)=>{r.r(e),r.d(e,{default:()=>n});var a=r("L75T");const t={class:"adm-info-message-wrap adm-info-message-gray"},i={class:"adm-info-message"},l={class:"adm-info-message-title"},d={class:"adm-progress-bar-outer",style:{width:"500px"}},p={class:"adm-progress-bar-inner-text",style:{width:"500px"}},n=(0,a.pM)({__name:"ProgressBar",props:{title:{type:String,default:"Заголовок"},progressText:{type:String,default:"Прогрес темплейт"},progress:{type:Number,default:0}},setup:s=>(e,r)=>((0,a.uX)(),(0,a.CE)("div",t,[(0,a.Lk)("div",i,[(0,a.Lk)("div",l,(0,a.v_)(s.title),1),(0,a.Lk)("div",d,[(0,a.Lk)("div",{class:"adm-progress-bar-inner",style:(0,a.Tr)({width:`${s.progress}%`})},[(0,a.Lk)("div",p,[(0,a.Lk)("span",null,(0,a.v_)(s.progressText),1)])],4),(0,a.Lk)("span",null,(0,a.v_)(s.progressText),1)]),r[0]||(r[0]=(0,a.Lk)("div",{class:"adm-info-message-buttons"},null,-1))])]))})}}]);
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/step1.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.7.2
6 | */
7 |
8 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
9 | if (!check_bitrix_sessid()) return;
10 |
11 | use Bitrix\Main\Loader,
12 | Bitrix\Main\Localization\Loc,
13 | Bitrix\Main\Config\Option;
14 |
15 | IncludeModuleLangFile(__FILE__);
16 |
17 | Loader::includeModule('main');
18 | $moduleName = 'dev2fun.imagecompress';
19 |
20 | Loader::registerAutoLoadClasses(
21 | $moduleName,
22 | [
23 | 'Dev2fun\ImageCompress\ImageCompressTable' => 'classes/general/ImageCompressTable.php',
24 | 'Dev2fun\ImageCompress\AdminList' => 'lib/AdminList.php',
25 | 'Dev2fun\ImageCompress\Check' => 'lib/Check.php',
26 | 'Dev2fun\ImageCompress\Compress' => 'lib/Compress.php',
27 | "Dev2funImageCompress" => 'include.php',
28 |
29 | "Dev2fun\ImageCompress\Jpegoptim" => 'lib/Jpegoptim.php',
30 | "Dev2fun\ImageCompress\Optipng" => 'lib/Optipng.php',
31 | ]
32 | );
33 | echo BeginNote();
34 | echo Loc::getMessage('D2F_MODULE_IMAGECOMPRESS_STEP1_NOTES');
35 | echo EndNote();
36 | ?>
37 |
65 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/themes/.default/dev2fun.imagecompress.css:
--------------------------------------------------------------------------------
1 | /*Menu icon*/
2 | .dev2fun_compressimage_menu_icon {
3 | background-image:url('icons/dev2fun.imagecompress/dev2fun_imagecompress.png');
4 | background-position: 9px 4px;
5 | }
6 | #dev2fun_compressimage_menu_icon {
7 | background-image:url('icons/dev2fun.imagecompress/dev2fun_imagecompress.png');
8 | }
9 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/themes/.default/icons/dev2fun.imagecompress/dev2fun_imagecompress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/utf8/dev2fun.imagecompress/install/themes/.default/icons/dev2fun.imagecompress/dev2fun_imagecompress.png
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/unstep1.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.7.2
6 | */
7 |
8 | if (!check_bitrix_sessid()) return;
9 | IncludeModuleLangFile(__FILE__);
10 |
11 | CModule::IncludeModule("main");
12 |
13 | use \Bitrix\Main\Localization\Loc;
14 |
15 | ?>
16 |
37 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/install/version.php:
--------------------------------------------------------------------------------
1 | '0.11.5',
4 | 'VERSION_DATE' => '2025-05-26 00:40:00',
5 | ];
6 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/admin/dev2fun_imagecompress_convert.php:
--------------------------------------------------------------------------------
1 | Поддержать разработчиков";
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/install/error.php:
--------------------------------------------------------------------------------
1 |
4 | * Date: 06.05.2017
5 | */
6 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
7 | $MESS['D2F_COMPRESSIMAGE_GOTO_FIRST'] = 'Перейти к первому шагу';
8 | $MESS['D2F_COMPRESSIMAGE_GOTO_MODULES'] = 'Перейти к списку модулей';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/install/final.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 06.05.2017
6 | */
7 |
8 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
9 | /**
10 | * Created by PhpStorm.
11 | * User: darkfriend
12 | * Date: 04.05.2017
13 | */
14 | $MESS["D2F_MODULE_NAME_IMAGECOMPRESS"] = "Оптимизация картинок";
15 | $MESS["D2F_MODULE_DESCRIPTION_IMAGECOMPRESS"] = "Данный модуль оптимизирует картинки для веб.";
16 | $MESS["D2F_IMAGECOMPRESS_INSTALL_SUCCESS"] = 'Модуль успешно установлен';
17 | $MESS["D2F_IMAGECOMPRESS_UNINSTALL_SUCCESS"] = 'Модуль успешно удален из системы';
18 | $MESS["D2F_IMAGECOMPRESS_INSTALL_LAST_MSG"] = "Будем благодарны предложениям по улучшению модуля
Если вам необходимо программирование, дизайн или продвижение обращайтесь на почту: sale@dev2fun.com";
19 | $MESS["D2F_IMAGECOMPRESS_UNINSTALL_LAST_MSG"] = 'Вы удалили модуль. Мы будем очень благодарны, если напишите причину удаления.
Это поможет нам в будущем быть лучше. Спасибо!';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/install/index.php:
--------------------------------------------------------------------------------
1 |
6 | * Date: 04.05.2017
7 | */
8 | $MESS["D2F_MODULE_NAME_IMAGECOMPRESS"] = "Оптимизация картинок";
9 | $MESS["D2F_MODULE_DESCRIPTION_IMAGECOMPRESS"] = "Данный модуль оптимизирует картинки для веб.";
10 | $MESS["D2F_IMAGECOMPRESS_INSTALL_SUCCESS"] = 'Модуль успешно установлен';
11 | $MESS["D2F_IMAGECOMPRESS_UNINSTALL_SUCCESS"] = 'Модуль успешно удален из системы';
12 | $MESS["D2F_IMAGECOMPRESS_INSTALL_LAST_MSG"] = "Будем благодарны предложениям по улучшению модуля
Если вам необходимо программирование, дизайн, продвижение или увеличение кол-ва заказов обращайтесь на почту: sale@dev2fun.com";
13 | $MESS["D2F_IMAGECOMPRESS_UNINSTALL_LAST_MSG"] = 'Вы удалили модуль. Мы будем очень благодарны, если напишите причину удаления.
Это поможет нам в будущем быть лучше. Спасибо!';
14 |
15 | $MESS["D2F_MODULE_IMAGECOMPRESS_STEP1"] = "Установка модуля dev2fun.imagecompress. Шаг 1.";
16 | $MESS["D2F_MODULE_IMAGECOMPRESS_STEP_ERROR"] = "Ошибка при установки модуля dev2fun.imagecompress";
17 | $MESS["D2F_IMAGECOMPRESS_ERROR_CHECK_NOFOUND"] = "Не найден #MODULE#. Установите на сервере #MODULE#";
18 | $MESS["D2F_IMAGECOMPRESS_ERROR_CHECK_NOFOUND_HEADING"] = "Установка модуля не возможна!";
19 | $MESS["D2F_IMAGECOMPRESS_ERROR_CHECK_NOFOUND_NOTES"] = "Установка модуля dev2fun.imagecompress не возможна.
На сервере не хватает ключевых компонентов.
Без этих компонентов оптимизация картинок не возможна.
Требуются компоненты: jpegoptim и optipng";
20 |
21 |
22 | $MESS["D2F_MODULE_IMAGECOMPRESS_UNSTEP1"] = "Удаление модуля dev2fun.imagecompress. Шаг 1.";
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/install/step1.php:
--------------------------------------------------------------------------------
1 |
6 | * Date: 04.05.2017
7 | */
8 | $MESS["D2F_MODULE_IMAGECOMPRESS_STEP1"] = "Проверка системы переустановкой модуля dev2fun.imagecompress";
9 | $MESS["D2F_IMAGECOMPRESS_ERROR_CHECK_NOFOUND"] = "Не найден #MODULE#.
Установите на сервере #MODULE#";
10 |
11 | $MESS["D2F_COMPRESS_REFERENCES_PATH_JPEGOPTI"] = "Путь до jpegoptim";
12 | $MESS["D2F_COMPRESS_REFERENCES_PATH_PNGOPTI"] = "Путь до optipng";
13 | $MESS["D2F_COMPRESS_REFERENCES_GOTO_INSTALL"] = "Перейти к установке";
14 | $MESS["D2F_MODULE_IMAGECOMPRESS_STEP1_NOTES"] = "На этом шаге вам нужно указать путь до jpegoptim и optipng
Если вы его не знаете, то уточните у вашего системного администратора.
Без этих компонентов модуль работать не будет";
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/install/unstep1.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 23.06.2018
6 | * Time: 21:06
7 | */
8 |
9 | $MESS["D2F_IMAGECOMPRESS_UNINSTALL_DB"] = "Удалить данные об оптимизированных картинках";
10 | $MESS["D2F_COMPRESS_REFERENCES_GOTO_UNINSTALL"] = "Продолжить";
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/lib/AdminList.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 05.05.2017
6 | * Time: 19:57
7 | */
8 |
9 | $MESS["D2F_COMPRESS_BTN_ALL"] = "Сжать все картинки";
10 | $MESS["D2F_IMAGECOMPRESS_COMPRESS_IMAGE_STATUS_SUCCESS"] = "Файлы успешно оптимизированы";
11 | $MESS["D2F_IMAGECOMPRESS_CONVERT_IMAGE_STATUS_SUCCESS"] = "Файлы успешно сконвертированы";
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/lib/Check.php:
--------------------------------------------------------------------------------
1 |
4 | * Date: 04.05.2017
5 | */
6 | $MESS['DEV2FUN_IMAGECOMPRESS_NOT_WRITE_IGAME'] = 'Не смог перезаписать файл';
7 | $MESS['DEV2FUN_IMAGECOMPRESS_NO_MODULE'] = 'Не смог обнаружить #MODULE#.
Проверьте стоит ли на сервере #MODULE#';
8 | $MESS['DEV2FUN_IMAGECOMPRESS_NOT_CHOICE'] = 'Не выбран алгоритм для #ALGORITHM#';
9 | $MESS['DEV2FUN_IMAGECOMPRESS_NO_PATH'] = 'Не указан путь до #MODULE#';
10 | $MESS['DEV2FUN_IMAGECOMPRESS_ERROR_IN_ALGORITHM'] = 'Ошибка с алгоритмом #MODULE#';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/lib/Compress.php:
--------------------------------------------------------------------------------
1 |
4 | * Date: 04.05.2017
5 | */
6 | $MESS['DEV2FUN_IMAGECOMPRESS_CONTENT_TYPE'] = '#TYPE# не поддерживается';
7 | $MESS['DEV2FUN_IMAGECOMPRESS_NO_MODULE'] = 'Не смог обнаружить #MODULE#.
Проверьте стоит ли на сервере #MODULE#';
8 | $MESS['DEV2FUN_IMAGECOMPRESS_ERROR_NO_ACTIVE'] = 'Не включена оптимизация для "#TYPE#"';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/lib/Convert.php:
--------------------------------------------------------------------------------
1 | Перейти к очистке';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/lib/Jpegoptim.php:
--------------------------------------------------------------------------------
1 |
4 | * Date: 04.05.2017
5 | */
6 | $MESS['DEV2FUN_IMAGECOMPRESS_NOT_WRITE_IGAME'] = 'Не смог перезаписать файл';
7 | $MESS['DEV2FUN_IMAGECOMPRESS_NO_MODULE'] = 'Не смог обнаружить #MODULE#.
Проверьте стоит ли на сервере #MODULE#';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/lib/Optipng.php:
--------------------------------------------------------------------------------
1 |
4 | * Date: 04.05.2017
5 | */
6 | $MESS['DEV2FUN_IMAGECOMPRESS_NOT_WRITE_IGAME'] = 'Не смог перезаписать файл';
7 | $MESS['DEV2FUN_IMAGECOMPRESS_NO_MODULE'] = 'Не смог обнаружить #MODULE#.
Проверьте стоит ли на сервере #MODULE#';
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lang/ru/updater.php:
--------------------------------------------------------------------------------
1 | ссылка";
4 |
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/Cache.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.11.4
6 | * @since 0.9.0
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | use Bitrix\Main\Config\Option;
12 | use CAgent;
13 |
14 | IncludeModuleLangFile(__FILE__);
15 |
16 | class Cache
17 | {
18 | const OPTION_NAME_DELETE_AGENT = 'cache_delete_agent';
19 |
20 | /**
21 | * Return current cache engine
22 | * @return string
23 | */
24 | public static function getCacheEngine()
25 | {
26 | return \Bitrix\Main\Data\Cache::getCacheEngineType();
27 | }
28 |
29 | /**
30 | * Run agent
31 | * @return string
32 | */
33 | public static function agentRun()
34 | {
35 | if (self::getCacheEngine() === 'cacheenginefiles') {
36 | $cache = \Bitrix\Main\Data\Cache::createCacheEngine();
37 | $cache->delayedDelete();
38 | }
39 |
40 | return self::class . '::agentRun();';
41 | }
42 |
43 | /**
44 | * Return agent id after add agent
45 | * @return int
46 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
47 | */
48 | public static function addAgent(): int
49 | {
50 | $startTime = ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 120, 'FULL');
51 | $agentId = CAgent::AddAgent(
52 | self::class . '::agentRun();',
53 | \Dev2funImageCompress::MODULE_ID,
54 | 'Y',
55 | 120,
56 | '',
57 | 'N',
58 | $startTime,
59 | 100,
60 | false,
61 | false
62 | );
63 | if (!$agentId) {
64 | throw new \Exception('Error when add agent for cache-delete');
65 | }
66 |
67 | Option::set(\Dev2funImageCompress::MODULE_ID, self::OPTION_NAME_DELETE_AGENT, $agentId);
68 |
69 | return $agentId;
70 | }
71 |
72 | /**
73 | * Return agent id from bitrix options
74 | * @return int|null
75 | */
76 | public static function getAgentIdOption(): ?int
77 | {
78 | return Option::get(\Dev2funImageCompress::MODULE_ID, self::OPTION_NAME_DELETE_AGENT) ?: null;
79 | }
80 |
81 | /**
82 | * @return array|false|null
83 | */
84 | public static function getAgent()
85 | {
86 | static $agent = null;;
87 | if ($agent === null) {
88 | $rs = CAgent::GetList([], ['NAME' => self::class . '::agentRun();']);
89 | $agent = $rs ? $rs->Fetch() : [];
90 | }
91 |
92 | return $agent;
93 | }
94 |
95 | /**
96 | * Return agent id from agents list
97 | * @return int|null
98 | */
99 | public static function getAgentIdDb(): ?int
100 | {
101 | $rs = self::getAgent();
102 | return $rs ? $rs['ID'] : null;
103 | }
104 |
105 | /**
106 | * @return int|null
107 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
108 | */
109 | public static function getAgentId(): ?int
110 | {
111 | $agentId = self::getAgentIdOption();
112 | if (!$agentId) {
113 | $agentId = self::getAgentIdDb();
114 | if (!$agentId) {
115 | $agentId = self::addAgent();
116 | }
117 | }
118 |
119 | return $agentId;
120 | }
121 |
122 | /**
123 | * Activate agent
124 | * @return bool
125 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
126 | */
127 | public static function activateAgent(): bool
128 | {
129 | $agentId = self::getAgentId();
130 | return (bool)CAgent::Update($agentId, ['ACTIVE' => 'Y']);
131 | }
132 |
133 | /**
134 | * @return bool
135 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
136 | */
137 | public static function deactivateAgent(): bool
138 | {
139 | $agentId = self::getAgentId();
140 | return (bool)CAgent::Update($agentId, ['ACTIVE' => 'N']);
141 | }
142 |
143 | /**
144 | * @return string
145 | */
146 | public static function getAgentActiveValue(): string
147 | {
148 | return self::getAgent()['ACTIVE'] ?? 'N';
149 | }
150 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/ConvertAgent.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.11.5
6 | * @since 0.11.4
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | use Bitrix\Main\Config\Option;
12 | use CAgent;
13 |
14 | IncludeModuleLangFile(__FILE__);
15 |
16 | class ConvertAgent
17 | {
18 | const OPTION_NAME_AGENT = 'image_convert_agent';
19 |
20 | /**
21 | * Return agent id after add agent
22 | * @return int
23 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
24 | */
25 | public static function addAgent(): int
26 | {
27 | $startTime = ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 60, 'FULL');
28 | $agentId = CAgent::AddAgent(
29 | LazyConvert::class . '::agentRun();',
30 | \Dev2funImageCompress::MODULE_ID,
31 | 'Y',
32 | 120,
33 | '',
34 | 'Y',
35 | $startTime,
36 | 100,
37 | false,
38 | false
39 | );
40 | if (!$agentId) {
41 | throw new \Exception('Error when add agent for cache-delete');
42 | }
43 |
44 | self::saveAgentIdOption($agentId);
45 |
46 | return $agentId;
47 | }
48 |
49 | /**
50 | * Return agent id from bitrix options
51 | * @return int|null
52 | */
53 | public static function getAgentIdOption(): ?int
54 | {
55 | return Option::get(\Dev2funImageCompress::MODULE_ID, self::OPTION_NAME_AGENT) ?: null;
56 | }
57 |
58 | /**
59 | * Save id agent in option
60 | * @param int $agentId
61 | * @return void
62 | */
63 | public static function saveAgentIdOption(int $agentId): void
64 | {
65 | Option::set(\Dev2funImageCompress::MODULE_ID, self::OPTION_NAME_AGENT, $agentId);
66 | }
67 |
68 | /**
69 | * @return array|false|null
70 | */
71 | public static function getAgent()
72 | {
73 | static $agent = null;
74 | if ($agent === null) {
75 | $rs = CAgent::GetList([], ['NAME' => LazyConvert::class . '::agentRun();']);
76 | $agent = $rs ? $rs->Fetch() : [];
77 | }
78 |
79 | return $agent;
80 | }
81 |
82 | /**
83 | * Return agent id from agents list
84 | * @return int|null
85 | */
86 | public static function getAgentIdDb(): ?int
87 | {
88 | $rs = self::getAgent();
89 | return $rs ? $rs['ID'] : null;
90 | }
91 |
92 | /**
93 | * @return int|null
94 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
95 | */
96 | public static function getAgentId(): ?int
97 | {
98 | $agentId = self::getAgentIdOption();
99 | if (!$agentId) {
100 | $agentId = self::getAgentIdDb();
101 | if (!$agentId) {
102 | $agentId = self::addAgent();
103 | } else {
104 | self::saveAgentIdOption($agentId);
105 | }
106 | }
107 |
108 | return $agentId;
109 | }
110 |
111 | /**
112 | * Activate agent
113 | * @return bool
114 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
115 | */
116 | public static function activateAgent(): bool
117 | {
118 | return (bool)CAgent::Update(self::getAgentId(), ['ACTIVE' => 'Y']);
119 | }
120 |
121 | /**
122 | * @return bool
123 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
124 | */
125 | public static function deactivateAgent(): bool
126 | {
127 | return (bool)CAgent::Update(self::getAgentId(), ['ACTIVE' => 'N']);
128 | }
129 |
130 | /**
131 | * @return string
132 | */
133 | public static function getAgentActiveValue(): string
134 | {
135 | return self::getAgent()['ACTIVE'] ?? 'N';
136 | }
137 |
138 | /**
139 | * Проверка, что агенты переведены на крон
140 | * @return bool
141 | */
142 | public static function agentsUseCrontab(): bool
143 | {
144 | return \Bitrix\Main\Config\Option::get("main", 'agents_use_crontab', 'N') === 'N';
145 | }
146 |
147 | /**
148 | * Проверка, что включена работа агентов
149 | * @return bool
150 | */
151 | public static function checkAgents(): bool
152 | {
153 | return \Bitrix\Main\Config\Option::get("main", 'agents_use_crontab', 'Y') === 'N';
154 | }
155 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/ConvertSearchPictures.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.11.5
6 | * @since 0.11.5
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | class ConvertSearchPictures
12 | {
13 | /**
14 | * @param string $path
15 | * @param array $excludePaths
16 | * @return bool
17 | */
18 | public static function isExcluded(string $path, array $excludePaths): bool
19 | {
20 | return IO::isExcluded($path, $excludePaths);
21 | }
22 |
23 | /**
24 | * @param string $path
25 | * @return int
26 | */
27 | public static function getCountFiles(string $path): int
28 | {
29 | return IO::getCountFiles($path);
30 | }
31 |
32 | /**
33 | * @param string $dir
34 | * @param array $excludePaths
35 | * @param int $chunkFiles
36 | * @return array|null
37 | * @throws \Bitrix\Main\ArgumentException
38 | * @throws \Bitrix\Main\ArgumentTypeException
39 | * @throws \Bitrix\Main\DB\SqlQueryException
40 | * @throws \Bitrix\Main\ObjectPropertyException
41 | * @throws \Bitrix\Main\SystemException
42 | */
43 | public static function scanFiles(string $dir, array $excludePaths = [], int $chunkFiles = 500): ?array
44 | {
45 | $iterator = new \RecursiveIteratorIterator(
46 | new \RecursiveDirectoryIterator(
47 | $dir,
48 | \FilesystemIterator::SKIP_DOTS
49 | ),
50 | \RecursiveIteratorIterator::SELF_FIRST
51 | );
52 |
53 | $extSupport = [
54 | 'jpeg',
55 | 'jpg',
56 | 'png',
57 | ];
58 | $files = [];
59 | $lastFile = null;
60 | $cntProcess = 0;
61 | /** @var \SplFileInfo $file */
62 | foreach ($iterator as $file) {
63 | if (self::isExcluded($file->getPathname(), $excludePaths)) {
64 | continue;
65 | }
66 |
67 | if ($file->isFile()) {
68 | if (!in_array($file->getExtension(), $extSupport)) {
69 | continue;
70 | }
71 |
72 | $files[] = $file->getPathname();
73 | $cntProcess++;
74 |
75 | if (count($files) >= $chunkFiles) {
76 | self::insertImage($files);
77 | $files = [];
78 | }
79 | }
80 |
81 | $lastFile = $file->getPathname();
82 | }
83 |
84 | if ($files) {
85 | self::insertImage($files);
86 | }
87 |
88 | return [
89 | 'cnt' => $cntProcess,
90 | 'lastFile' => $lastFile,
91 | ];
92 | }
93 |
94 | /**
95 | * @param array $files
96 | * @return void
97 | * @throws \Bitrix\Main\ArgumentException
98 | * @throws \Bitrix\Main\ArgumentTypeException
99 | * @throws \Bitrix\Main\DB\SqlQueryException
100 | * @throws \Bitrix\Main\ObjectPropertyException
101 | * @throws \Bitrix\Main\SystemException
102 | */
103 | public static function insertImage(array $files): void
104 | {
105 | $currentFiles = LazyConvert::findFiles($files);
106 | $rows = [];
107 | foreach ($files as $file) {
108 | $md5 = md5_file($file);
109 | if (empty($currentFiles[$md5])) {
110 | $fileUrl = str_replace($_SERVER['DOCUMENT_ROOT'], '', $file);
111 | $rows[] = [
112 | 'IMAGE_PATH' => $fileUrl,
113 | 'IMAGE_HASH' => $md5,
114 | 'IMAGE_IGNORE' => 'N',
115 | ];
116 | }
117 | }
118 |
119 | $sql = MySqlHelper::getInsertIgnoreMulti(
120 | ImageCompressImagesTable::getTableName(),
121 | $rows
122 | );
123 |
124 | \Bitrix\Main\Application::getInstance()
125 | ->getConnection()
126 | ->queryExecute($sql);
127 | }
128 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/Gif.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.4.0
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Localization\Loc;
11 | use Bitrix\Main\Config\Option;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class Gif
16 | {
17 | private static $instance;
18 | public $lastError;
19 |
20 | private $MODULE_ID = 'dev2fun.imagecompress';
21 | private $path = '';
22 | private $active = false;
23 | private static $isOptim = null;
24 |
25 | public function __construct()
26 | {
27 | $this->path = Option::get($this->MODULE_ID, 'path_to_gif', '/usr/bin');
28 | $this->active = Option::get($this->MODULE_ID, 'enable_gif', 'N') === 'Y';
29 | }
30 |
31 | /**
32 | * @static
33 | * @return Ps2Pdf
34 | */
35 | public static function getInstance()
36 | {
37 | if (!isset(self::$instance)) {
38 | $c = __CLASS__;
39 | self::$instance = new $c;
40 | }
41 | return self::$instance;
42 | }
43 |
44 | /**
45 | * Return has active state
46 | * @return bool
47 | */
48 | public function isActive(): bool
49 | {
50 | return $this->active;
51 | }
52 |
53 | /**
54 | * Check optimize for gif
55 | * @param string|null $path
56 | * @return bool
57 | */
58 | public function isOptim(?string $path = null)
59 | {
60 | if (!$path) {
61 | $path = $this->path;
62 | }
63 | if (self::$isOptim === null || $path !== $this->path) {
64 | exec($path . '/gifsicle --version', $s);
65 | self::$isOptim = (bool)$s;
66 | }
67 | return self::$isOptim;
68 | }
69 |
70 | /**
71 | * Процесс оптимизации JPEG
72 | * @param string $strFilePath - абсолютный путь до картинки
73 | * @param array $params - дополнительные параметры
74 | * @return bool
75 | * @throws \Exception
76 | */
77 | public function compress($strFilePath, $params = [])
78 | {
79 | if(!$this->isActive()) {
80 | $this->lastError = 'no_active';
81 | return false;
82 | }
83 | $strFilePath = strtr(
84 | $strFilePath,
85 | [
86 | ' ' => '\ ',
87 | '(' => '\(',
88 | ')' => '\)',
89 | ']' => '\]',
90 | '[' => '\[',
91 | ]
92 | );
93 |
94 | if(empty($params['compression'])) {
95 | $params['compression'] = Option::get($this->MODULE_ID, 'gif_compress', 2);
96 | }
97 |
98 | $event = new \Bitrix\Main\Event(
99 | $this->MODULE_ID,
100 | "OnBeforeResizeImageGif",
101 | [&$strFilePath, &$params]
102 | );
103 | $event->send();
104 |
105 | $strCommand = '';
106 | if(!empty($params['compression'])) {
107 | $strCommand .= "-O{$params['compression']} ";
108 | }
109 |
110 | exec($this->path . "/gifsicle $strCommand $strFilePath -o $strFilePath 2>&1", $res);
111 |
112 | if (!empty($params['changeChmod'])) {
113 | chmod($strFilePath, $params['changeChmod']);
114 | }
115 | $event = new \Bitrix\Main\Event(
116 | $this->MODULE_ID,
117 | "OnAfterResize",
118 | [&$strFilePath]
119 | );
120 | $event->send();
121 | return true;
122 | }
123 |
124 | public function getOptionsSettings($advanceSettings=[])
125 | {
126 | $settings = [
127 | 'gif_compress' => 'string',
128 | ];
129 | $post = [
130 | 'checkbox' => [],
131 | 'string' => [],
132 | ];
133 | foreach ($settings as $option=>$setting) {
134 | if(empty($advanceSettings[$setting][$option])) {
135 | if($setting==='checkbox') {
136 | $post[$setting][$option] = 'N';
137 | } else {
138 | $post[$setting][$option] = '';
139 | }
140 | } else {
141 | $post[$setting][$option] = $advanceSettings[$setting][$option];
142 | }
143 | }
144 | return $post;
145 | }
146 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/IO.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.11.5
6 | * @since 0.11.0
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | class IO
12 | {
13 | /**
14 | * Проверяет директорию на пустоту
15 | * @param string $path
16 | * @return bool
17 | */
18 | public static function isEmptyDir(string $path): bool
19 | {
20 | if (!is_dir($path)) {
21 | return false;
22 | }
23 | $path = realpath($path);
24 | if ($path) {
25 | foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS)) as $object){
26 | if ($object->isFile()) {
27 | return false;
28 | }
29 | }
30 | }
31 | return true;
32 | }
33 |
34 | /**
35 | * @param string $path
36 | * @param array $excludePaths
37 | * @return bool
38 | */
39 | public static function isExcluded(string $path, array $excludePaths): bool
40 | {
41 | foreach ($excludePaths as $excludePath) {
42 | if (strpos($path, $excludePath) === 0) {
43 | return true;
44 | }
45 | }
46 | return false;
47 | }
48 |
49 | /**
50 | * @param string $path
51 | * @return int
52 | */
53 | public static function getCountFiles(string $path, array $excludePaths = []): int
54 | {
55 | $count = 0;
56 | $path = realpath($path);
57 | if ($path && file_exists($path)) {
58 | /** @var \RecursiveDirectoryIterator $object */
59 | foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS)) as $object){
60 | if ($object->isFile() && !self::isExcluded($object->getPathname(), $excludePaths)) {
61 | $count++;
62 | }
63 | }
64 | }
65 |
66 | return $count;
67 | }
68 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/Process.php:
--------------------------------------------------------------------------------
1 |
5 | * @version 0.4.0
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Config\Option;
11 |
12 | class Process
13 | {
14 | /**
15 | * @param array $params = [
16 | * 'sort' => [],
17 | * 'filters' => [
18 | * 'contentType' => [],
19 | * 'compressed' => 'N',
20 | * ],
21 | * 'limit' => 30,
22 | * ]
23 | * @return array[]|bool
24 | * @throws \Bitrix\Main\ArgumentNullException
25 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
26 | */
27 | public static function start(array $params = [])
28 | {
29 | if(!Compress::getEnable()) return false;
30 | $params['filters'] = array_merge(
31 | [
32 | 'contentType' => [
33 | 'image/jpeg',
34 | 'image/png',
35 | 'application/pdf',
36 | ],
37 | 'compressed' => 'N'
38 | ],
39 | isset($params['filters']) ? $params['filters'] : []
40 | );
41 |
42 | if(empty($params['limit'])) {
43 | $params['limit'] = Option::get('dev2fun.imagecompress', "cnt_step", 30);
44 | }
45 | if(!isset($params['sort'])) {
46 | $params['sort'] = [];
47 | }
48 |
49 | $compress = Compress::getInstance();
50 | $rsRes = static::getQuery([
51 | 'sort' => $params['sort'],
52 | 'filters' => [
53 | '@CONTENT_TYPE' => $params['filters']['contentType'],
54 | 'COMRESSED' => $params['filters']['compressed'],
55 | ]
56 | ]);
57 | // $rsRes = $compress->getFileList(
58 | // [],
59 | // [
60 | // '@CONTENT_TYPE' => $params['filters']['contentType'],
61 | // 'COMRESSED' => $params['filters']['compressed'],
62 | // ]
63 | // );
64 | $rsRes->NavStart($params['limit'], false);
65 |
66 | $result = [
67 | 'error' => [],
68 | 'success' => [],
69 | ];
70 | $stepOnPage = 1;
71 | while ($arFile = $rsRes->NavNext(true)) {
72 | $strFilePath = \CFile::GetPath($arFile["ID"]);
73 | if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $strFilePath)) {
74 | $compress->addCompressTable($arFile['ID'], [
75 | 'FILE_ID' => $arFile['ID'],
76 | 'SIZE_BEFORE' => 0,
77 | 'SIZE_AFTER' => 0,
78 | ]);
79 | $result['error'][] = $arFile['ID'];
80 | } else {
81 | $compress->compressImageByID($arFile['ID']);
82 | $result['success'][] = $arFile['ID'];
83 | }
84 | $stepOnPage++;
85 | }
86 |
87 | $result['updFiles'] = $stepOnPage;
88 | return $result;
89 | }
90 |
91 | /**
92 | * @param array $params = [
93 | * 'sort' => [],
94 | * 'filters' => [],
95 | * ]
96 | * @return bool|\CDBResult
97 | */
98 | public static function getQuery(array $params = [])
99 | {
100 | if(!isset($params['sort'])) {
101 | $params['sort'] = array();
102 | }
103 | if(!isset($params['filters'])) {
104 | $params['filters'] = array();
105 | }
106 | return Compress::getInstance()->getFileList(
107 | $params['sort'],
108 | $params['filters']
109 | );
110 | }
111 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/Ps2Pdf.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.7.4
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Localization\Loc;
11 | use Bitrix\Main\Config\Option;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class Ps2Pdf
16 | {
17 | private static $instance;
18 | public $lastError;
19 |
20 | private $MODULE_ID = 'dev2fun.imagecompress';
21 | private $path = '';
22 | private $pdfSetting = 'ebook';
23 | private static $isOptim = null;
24 | private $active = false;
25 |
26 | /**
27 | * @param string|null $siteId
28 | */
29 | public function __construct()
30 | {
31 | $this->path = Option::get($this->MODULE_ID, 'path_to_ps2pdf', '');
32 | $this->active = Option::get($this->MODULE_ID, 'enable_pdf', 'N') === 'Y';
33 | $this->pdfSetting = Option::get($this->MODULE_ID, 'pdf_setting', 'ebook');
34 | }
35 |
36 | /**
37 | * Return has active state
38 | * @return bool
39 | */
40 | public function isActive(): bool
41 | {
42 | return $this->active;
43 | }
44 |
45 | /**
46 | * @static
47 | * @return Ps2Pdf
48 | */
49 | public static function getInstance()
50 | {
51 | if (!isset(self::$instance)) {
52 | $c = __CLASS__;
53 | self::$instance = new $c;
54 | }
55 | return self::$instance;
56 | }
57 |
58 | /**
59 | * Check available optimization pdf
60 | * @return bool
61 | * @deprecated
62 | * @uses isOptim()
63 | */
64 | public function isPdfOptim()
65 | {
66 | return $this->isOptim();
67 | }
68 |
69 | /**
70 | * Check available optimization pdf
71 | * @param string|null $path
72 | * @return bool
73 | */
74 | public function isOptim(?string $path = null)
75 | {
76 | if (!$path) {
77 | $path = $this->path;
78 | }
79 | if (self::$isOptim === null || $path !== $this->path) {
80 | \exec($path . '/gs -v', $s);
81 | self::$isOptim = (bool)$s;;
82 | }
83 | return self::$isOptim;
84 | }
85 |
86 | /**
87 | * Процесс оптимизации JPEG
88 | * @param string $strFilePath - абсолютный путь до картинки
89 | * @param array $params - дополнительные параметры
90 | * @return bool
91 | * @throws \Exception
92 | */
93 | public function compress($strFilePath, $params = [])
94 | {
95 | if(!$this->active) {
96 | $this->lastError = 'no_active';
97 | return false;
98 | }
99 | $strFilePath = \strtr(
100 | $strFilePath,
101 | [
102 | ' ' => '\ ',
103 | '(' => '\(',
104 | ')' => '\)',
105 | ']' => '\]',
106 | '[' => '\[',
107 | ]
108 | );
109 | if(!isset($params['pdfSetting'])) {
110 | $params['pdfSetting'] = $this->pdfSetting;
111 | }
112 |
113 | $event = new \Bitrix\Main\Event(
114 | $this->MODULE_ID,
115 | "OnBeforeResizeImagePs2Pdf",
116 | [&$strFilePath, &$params]
117 | );
118 | $event->send();
119 |
120 | $strFilePathNew = $strFilePath.'.pdf';
121 | $strCommand = "-sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/{$params['pdfSetting']} -dNOPAUSE -dQUIET -dBATCH";
122 |
123 | \exec($this->path . "/gs {$strCommand} -sOutputFile='{$strFilePathNew}' '{$strFilePath}' 2>&1", $res);
124 | // exec($this->path . "/ps2pdf $strCommand $strFilePath $strFilePathNew 2>&1", $res);
125 |
126 | if(\file_exists($strFilePathNew)) {
127 | \unlink($strFilePath);
128 | \rename($strFilePathNew, $strFilePath);
129 | }
130 |
131 | if (!empty($params['changeChmod'])) {
132 | \chmod($strFilePath, $params['changeChmod']);
133 | }
134 | $event = new \Bitrix\Main\Event(
135 | $this->MODULE_ID,
136 | "OnAfterResize",
137 | [&$strFilePath]
138 | );
139 | $event->send();
140 | return true;
141 | }
142 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/Resize.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 26.08.2018
6 | * Time: 20:40
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | use Bitrix\Main\Localization\Loc;
12 | use Bitrix\Main\Config\Option;
13 |
14 | class Resize
15 | {
16 | private static $instance;
17 | public $lastError;
18 |
19 | private $MODULE_ID = 'dev2fun.imagecompress';
20 | private $width = '';
21 | private $height = '';
22 | private $algorithm = '';
23 | private $enable = false;
24 |
25 | /**
26 | * @param string|null $siteId
27 | */
28 | public function __construct(?string $siteId = null)
29 | {
30 | // if (!$siteId) {
31 | // $siteId = \Dev2funImageCompress::getSiteId();
32 | // }
33 | $this->width = Option::get($this->MODULE_ID, 'resize_width', '');
34 | $this->height = Option::get($this->MODULE_ID, 'resize_height', '');
35 | $this->algorithm = Option::get($this->MODULE_ID, 'resize_algorithm', '');
36 | $this->enable = Option::get($this->MODULE_ID, 'resize_enable', 'N') === 'Y';
37 | if (!$this->algorithm) {
38 | $this->algorithm = BX_RESIZE_IMAGE_PROPORTIONAL;
39 | }
40 | }
41 |
42 | /**
43 | * @static
44 | * @return Resize
45 | */
46 | public static function getInstance()
47 | {
48 | if (!isset(self::$instance)) {
49 | $c = __CLASS__;
50 | self::$instance = new $c;
51 | }
52 | return self::$instance;
53 | }
54 |
55 | public function resize($strFilePath)
56 | {
57 | if (!$strFilePath || !$this->enable) {
58 | return false;
59 | }
60 | $destinationFile = $_SERVER['DOCUMENT_ROOT'] . "/upload/{$this->MODULE_ID}/" . basename($strFilePath);
61 | $res = \CFile::ResizeImageFile(
62 | $strFilePath,
63 | $destinationFile,
64 | [
65 | 'width' => $this->width,
66 | 'height' => $this->height,
67 | ],
68 | $this->algorithm
69 | );
70 | if ($res) {
71 | chmod($destinationFile, 0777);
72 | copy($destinationFile, $strFilePath);
73 | unlink($destinationFile);
74 | }
75 | return $res;
76 | }
77 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/Svg.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.8.5
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Localization\Loc;
11 | use Bitrix\Main\Config\Option;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class Svg
16 | {
17 | private static $instance;
18 | private static $isOptim = null;
19 | public $lastError;
20 | public $binaryName = 'svgo';
21 | private $MODULE_ID = 'dev2fun.imagecompress';
22 | /** @var string путь до svgo */
23 | private $path = '';
24 | /** @var string путь до nodejs */
25 | public $pathNodejs;
26 | private $active = false;
27 |
28 | /**
29 | * @param string|null $siteId
30 | */
31 | public function __construct()
32 | {
33 | $this->path = Option::get($this->MODULE_ID, 'path_to_svg', '/usr/bin');
34 | $this->pathNodejs = Option::get($this->MODULE_ID, 'path_to_node', '/usr/bin');
35 | $this->active = Option::get($this->MODULE_ID, 'enable_svg', 'N') === 'Y';
36 | }
37 |
38 | /**
39 | * @static
40 | * @return Ps2Pdf
41 | */
42 | public static function getInstance()
43 | {
44 | if (!isset(self::$instance)) {
45 | $c = __CLASS__;
46 | self::$instance = new $c;
47 | }
48 | return self::$instance;
49 | }
50 |
51 | /**
52 | * Return has active state
53 | * @return bool
54 | */
55 | public function isActive(): bool
56 | {
57 | return $this->active;
58 | }
59 |
60 | /**
61 | * Check available optimization svg
62 | * @param string|null $path
63 | * @param string|null $pathNodejs
64 | * @return bool
65 | */
66 | public function isOptim(?string $path = null, ?string $pathNodejs = null): bool
67 | {
68 | if (!$path) {
69 | $path = $this->path;
70 | }
71 | if (!$pathNodejs) {
72 | $pathNodejs = $this->pathNodejs;
73 | }
74 | if (self::$isOptim === null || $path !== $this->path || $pathNodejs !== $this->pathNodejs) {
75 | exec("{$pathNodejs}/node {$path}/{$this->binaryName} -v", $s);
76 | self::$isOptim = (bool)$s;
77 | }
78 | return self::$isOptim;
79 | }
80 |
81 | /**
82 | * Процесс оптимизации JPEG
83 | * @param string $strFilePath - абсолютный путь до картинки
84 | * @param array $params - дополнительные параметры
85 | * @return bool
86 | * @throws \Exception
87 | */
88 | public function compress($strFilePath, $params = [])
89 | {
90 | if (!$this->active) {
91 | $this->lastError = 'no_active';
92 | return false;
93 | }
94 | $strFilePath = strtr(
95 | $strFilePath,
96 | [
97 | ' ' => '\ ',
98 | '(' => '\(',
99 | ')' => '\)',
100 | ']' => '\]',
101 | '[' => '\[',
102 | ]
103 | );
104 |
105 | $event = new \Bitrix\Main\Event(
106 | $this->MODULE_ID,
107 | "OnBeforeResizeImageSvg",
108 | [&$strFilePath, &$params]
109 | );
110 | $event->send();
111 |
112 | $strCommand = '';
113 |
114 | exec(
115 | "{$this->pathNodejs}/node {$this->path}/{$this->binaryName} $strCommand --input=$strFilePath --output=$strFilePath 2>&1",
116 | $res
117 | );
118 |
119 | // if(file_exists($strFilePathNew)) {
120 | // unlink($strFilePath);
121 | // rename($strFilePathNew, $strFilePath);
122 | // }
123 |
124 | if (!empty($params['changeChmod'])) {
125 | chmod($strFilePath, $params['changeChmod']);
126 | }
127 | $event = new \Bitrix\Main\Event(
128 | $this->MODULE_ID,
129 | "OnAfterResize",
130 | [&$strFilePath]
131 | );
132 | $event->send();
133 | return true;
134 | }
135 |
136 | public function getOptionsSettings($advanceSettings=[])
137 | {
138 | return [];
139 | }
140 | }
--------------------------------------------------------------------------------
/utf8/dev2fun.imagecompress/lib/script.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author darkfriend
3 | * @version 0.11.5
4 | */
5 | function SendPropcess(step, type) {
6 | let objRequest = {
7 | AJAX_IC: 'Y',
8 | PAGEN_1: step,
9 | };
10 | let wrapId = 'compressAllStatus';
11 | switch (type) {
12 | case 'convert':
13 | objRequest.convert_all = 'Y';
14 | wrapId = 'convertAllStatus';
15 | break;
16 | default:
17 | objRequest.compress_all = 'Y';
18 | }
19 | BX.ajax({
20 | url: window.location.pathname + window.location.search,
21 | data: objRequest,
22 | method: 'POST',
23 | timeout: 600,
24 | dataType: 'json',
25 | cache: false,
26 | onsuccess: function (data) {
27 | BX(wrapId).innerHTML = data.html;
28 | data.step = parseInt(data.step);
29 | data.allStep = parseInt(data.allStep);
30 | if (
31 | data.step > 0
32 | && data.step <= data.allStep
33 | && !data.error
34 | ) {
35 | SendPropcess(data.step, type);
36 | } else {
37 | BX.closeWait(wrapId);
38 | }
39 | if (data.step > data.allStep || !(data.step > 0)) {
40 | window.location.href = window.location.pathname + '?process_result=Y&status=success';
41 | }
42 | },
43 | onfailure: function () {
44 | BX.closeWait(wrapId);
45 | BX(wrapId).innerHTML = 'Error!';
46 | }
47 | });
48 | }
49 |
50 | function SearchPictures() {
51 | let objRequest = {
52 | AJAX_IC: 'Y',
53 | action: 'searchPicture',
54 | };
55 | let wrapId = '';
56 | BX.showWait();
57 | BX.ajax({
58 | url: window.location.pathname + window.location.search,
59 | data: objRequest,
60 | method: 'POST',
61 | timeout: 600,
62 | dataType: 'json',
63 | cache: false,
64 | onsuccess: function (data) {
65 | BX.closeWait();
66 | if (data.success) {
67 | window.location.href = window.location.pathname + '?process_search_result=Y&status=success';
68 | } else {
69 | let err = data.msg ? data.msg : 'Unknow error!'
70 | BX(wrapId).innerHTML = 'Error! ' + err;
71 | }
72 | },
73 | onfailure: function () {
74 | BX.closeWait();
75 | BX(wrapId).innerHTML = 'Error!';
76 | }
77 | });
78 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/admin/menu.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.11.0
5 | */
6 |
7 | IncludeModuleLangFile(__FILE__);
8 |
9 | use Bitrix\Main\Localization\Loc;
10 |
11 | if(!is_object($GLOBALS["USER_FIELD_MANAGER"])) {
12 | return false;
13 | }
14 |
15 | if(!$USER->CanDoOperation("dev2fun.imagecompress")) {
16 | return false;
17 | }
18 |
19 | $moduleId = 'dev2fun.imagecompress';
20 | if (!\Bitrix\Main\Loader::includeModule($moduleId)) {
21 | return false;
22 | }
23 |
24 | $items[] = [
25 | 'text' => Loc::getMessage('DEV2FUN_IMAGECOMPRESS_MENU_ITEM_FILES'),
26 | 'url' => "dev2fun_imagecompress_files.php?lang=".LANGUAGE_ID,
27 | 'module_id' => $moduleId,
28 | 'items_id' => 'menu_dev2fun_imagecompress_files',
29 | 'more_url' => [
30 | 'dev2fun_imagecompress_files.php',
31 | ],
32 | ];
33 | $items[] = [
34 | 'text' => Loc::getMessage('DEV2FUN_IMAGECOMPRESS_MENU_ITEM_CONVERT'),
35 | 'url' => "dev2fun_imagecompress_convert.php?lang=".LANGUAGE_ID,
36 | 'module_id' => $moduleId,
37 | 'items_id' => 'menu_dev2fun_imagecompress_convert',
38 | 'more_url' => [
39 | 'dev2fun_imagecompress_convert.php',
40 | ],
41 | ];
42 | $items[] = [
43 | 'text' => Loc::getMessage('DEV2FUN_IMAGECOMPRESS_MENU_ITEM_CONVERT_MOVE'),
44 | 'url' => "dev2fun_imagecompress_convert_move.php?lang=".LANGUAGE_ID,
45 | 'module_id' => $moduleId,
46 | 'items_id' => 'menu_dev2fun_imagecompress_convert_move',
47 | 'more_url' => [
48 | 'dev2fun_imagecompress_convert_move.php',
49 | ],
50 | ];
51 |
52 | $arMenu = [
53 | "parent_menu" => "global_menu_settings",
54 | "section" => "dev2fun_imagecompress",
55 | "items_id" => "dev2fun_imagecompress",
56 | // "section" => "settings",
57 | "sort" => 900,
58 | "text" => Loc::getMessage("DEV2FUN_IMAGECOMPRESS_MENU_TEXT"),
59 | "title" => Loc::getMessage("DEV2FUN_IMAGECOMPRESS_MENU_TITLE"),
60 | "url" => "dev2fun_imagecompress_files.php?lang=".LANGUAGE_ID,
61 | "more_url" => [
62 | "dev2fun_imagecompress_files.php",
63 | "dev2fun_imagecompress_convert.php",
64 | "dev2fun_imagecompress_convert_move.php",
65 | ],
66 | "icon" => "dev2fun_compressimage_menu_icon",
67 | "page_icon" => "dev2fun_compressimage_page_icon",
68 | "items" => $items,
69 | ];
70 |
71 | return $arMenu;
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/classes/general/ImageCompressImagesConvertedTable.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.8.3
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | use Bitrix\Main;
10 | use Bitrix\Main\Entity;
11 | use Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class ImageCompressImagesConvertedTable extends Entity\DataManager
16 | {
17 | static $module_id = "dev2fun.imagecompress";
18 |
19 | public static function getFilePath()
20 | {
21 | return __FILE__;
22 | }
23 |
24 | public static function getTableName()
25 | {
26 | return 'b_d2f_imagecompress_images_converted';
27 | // return 'b_d2f_imagecompress_webp_images';
28 | }
29 |
30 | public static function getTableTitle()
31 | {
32 | return Loc::getMessage('DEV2FUN_IMAGECOMPRESS_PAGES_TITLE');
33 | }
34 |
35 | public static function getMap()
36 | {
37 | return [
38 | new Entity\IntegerField('ID', [
39 | 'primary' => true,
40 | 'autocomplete' => true,
41 | ]),
42 |
43 | new Entity\StringField('IMAGE_PATH', [
44 | 'required' => true,
45 | ]),
46 |
47 | new Entity\StringField('ORIGINAL_IMAGE_HASH', [
48 | 'required' => true,
49 | ]),
50 |
51 | new Entity\EnumField('IMAGE_TYPE', [
52 | 'values' => [
53 | Convert::TYPE_WEBP,
54 | Convert::TYPE_AVIF,
55 | ],
56 | 'required' => true,
57 | ]),
58 |
59 | ];
60 | }
61 |
62 | /**
63 | * Create table
64 | * @return void
65 | * @throws Main\ArgumentException
66 | * @throws Main\DB\SqlQueryException
67 | * @throws Main\SystemException
68 | */
69 | public static function createTable()
70 | {
71 | static::getEntity()->createDbTable();
72 | /** @var Main\DB\MysqlCommonConnection $connection */
73 | $connection = static::getEntity()->getConnection();
74 |
75 | $connection->createIndex(
76 | static::getTableName(),
77 | 'unique_image_path_type',
78 | ['IMAGE_PATH', 'IMAGE_TYPE'],
79 | $connection::INDEX_UNIQUE
80 | );
81 | }
82 |
83 | /**
84 | * Drop table
85 | * @return void
86 | * @throws Main\ArgumentException
87 | * @throws Main\DB\SqlQueryException
88 | * @throws Main\SystemException
89 | */
90 | public static function dropTable()
91 | {
92 | static::getEntity()->getConnection()->dropTable(static::getTableName());
93 | }
94 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/classes/general/ImageCompressImagesTable.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.11.2
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | use Bitrix\Main;
10 | use Bitrix\Main\Entity;
11 | use Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class ImageCompressImagesTable extends Entity\DataManager
16 | {
17 | static $module_id = "dev2fun.imagecompress";
18 |
19 | public static function getFilePath()
20 | {
21 | return __FILE__;
22 | }
23 |
24 | public static function getTableName()
25 | {
26 | return 'b_d2f_imagecompress_images';
27 | }
28 |
29 | public static function getTableTitle()
30 | {
31 | return Loc::getMessage('DEV2FUN_IMAGECOMPRESS_PAGES_TITLE');
32 | }
33 |
34 | public static function getMap()
35 | {
36 | return [
37 | new Entity\IntegerField('ID', [
38 | 'primary' => true,
39 | 'autocomplete' => true,
40 | ]),
41 |
42 | new Entity\StringField('IMAGE_PATH', [
43 | 'unique' => true,
44 | ]),
45 |
46 | new Entity\StringField('IMAGE_HASH', [
47 | 'nullable' => true,
48 | ]),
49 |
50 | new Entity\BooleanField('IMAGE_IGNORE', [
51 | 'values' => ['N', 'Y'],
52 | 'default_value' => 'N',
53 | ]),
54 | // ->configureValues('N', 'Y')
55 | // ->configureDefaultValue('N'),
56 |
57 | new Entity\DatetimeField('DATE_CHECK', [
58 | 'nullable' => true,
59 | ]),
60 | // ->configureNullable(),
61 |
62 | new Entity\DatetimeField('DATE_UPDATE', [
63 | 'nullable' => true,
64 | ]),
65 | // ->configureNullable(),
66 |
67 | (new Entity\ReferenceField(
68 | 'CONVERTED_IMAGE',
69 | ImageCompressImagesToConvertedTable::class,
70 | [
71 | '=this.ID' => 'ref.IMAGE_ID',
72 | // '=this.IMAGE_TYPE' => 'ref.IMAGE_TYPE',
73 | ]
74 | // ['join_type' => 'INNER']
75 | )),
76 |
77 | ];
78 | }
79 |
80 | /**
81 | * Create table
82 | * @return void
83 | * @throws Main\ArgumentException
84 | * @throws Main\DB\SqlQueryException
85 | * @throws Main\SystemException
86 | */
87 | public static function createTable()
88 | {
89 | static::getEntity()->createDbTable();
90 | /** @var Main\DB\MysqlCommonConnection $connection */
91 | $connection = static::getEntity()->getConnection();
92 |
93 | $connection->createIndex(
94 | static::getTableName(),
95 | 'indx_date_check',
96 | ['DATE_CHECK']
97 | );
98 |
99 | if (!$connection->isIndexExists(static::getTableName(), ['IMAGE_HASH', 'IMAGE_IGNORE'])) {
100 | $connection->createIndex(
101 | static::getTableName(),
102 | 'indx_image_hash',
103 | ['IMAGE_HASH', 'IMAGE_IGNORE']
104 | );
105 | }
106 | }
107 |
108 | /**
109 | * Drop table
110 | * @return void
111 | * @throws Main\ArgumentException
112 | * @throws Main\DB\SqlQueryException
113 | * @throws Main\SystemException
114 | */
115 | public static function dropTable()
116 | {
117 | static::getEntity()->getConnection()->dropTable(static::getTableName());
118 | }
119 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/classes/general/ImageCompressTable.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.8.3
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | use Bitrix\Main\Entity;
10 | use Bitrix\Main\Localization\Loc;
11 |
12 | //Loc::loadMessages(__FILE__);
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class ImageCompressTable extends Entity\DataManager
16 | {
17 | static $module_id = "dev2fun.imagecompress";
18 |
19 | public static function getFilePath()
20 | {
21 | return __FILE__;
22 | }
23 |
24 | public static function getTableName()
25 | {
26 | return 'b_d2f_imagecompress_files';
27 | }
28 |
29 | public static function getTableTitle()
30 | {
31 | return Loc::getMessage('DEV2FUN_IMAGECOMPRESS_REDIRECTS_TITLE');
32 | }
33 |
34 | public static function getMap()
35 | {
36 | return array(
37 | new Entity\IntegerField('SIZE_BEFORE'),
38 | new Entity\IntegerField('SIZE_AFTER'),
39 | new Entity\IntegerField('FILE_ID', [
40 | 'primary' => true,
41 | ]),
42 | new Entity\ReferenceField(
43 | 'FILE',
44 | 'Bitrix\Main\FileTable',
45 | [
46 | '=this.FILE_ID' => 'ref.ID'
47 | ]
48 | ),
49 | );
50 | }
51 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/classes/general/MySqlHelper.php:
--------------------------------------------------------------------------------
1 |
4 | * @version 0.8.0
5 | */
6 |
7 | namespace Dev2fun\ImageCompress;
8 |
9 | class MySqlHelper
10 | {
11 | /**
12 | * @param string $tableName
13 | * @param array $insertRowsFields
14 | * @return string
15 | * @throws \Bitrix\Main\ArgumentTypeException
16 | * @throws \Bitrix\Main\DB\SqlQueryException
17 | */
18 | public static function getInsertIgnore(string $tableName, array $insertFields): string
19 | {
20 | $connection = \Bitrix\Main\Application::getInstance()->getConnection();
21 | $sqlHelper = $connection->getSqlHelper();
22 |
23 | $insert = $sqlHelper->prepareInsert($tableName, $insertFields);
24 |
25 | if ($tableName && !empty($insert[0]) && !empty($insert[1])) {
26 | $sql = "
27 | INSERT IGNORE INTO {$sqlHelper->quote($tableName)} ({$insert[0]})
28 | VALUES ({$insert[1]})";
29 | } else {
30 | $sql = '';
31 | }
32 |
33 | return $sql;
34 | }
35 |
36 | /**
37 | * @param string $tableName
38 | * @param array $insertRowsFields
39 | * @return string
40 | * @throws \Bitrix\Main\ArgumentTypeException
41 | * @throws \Bitrix\Main\DB\SqlQueryException
42 | */
43 | public static function getInsertIgnoreMulti(string $tableName, array $insertRowsFields): string
44 | {
45 | $connection = \Bitrix\Main\Application::getInstance()->getConnection();
46 | $sqlHelper = $connection->getSqlHelper();
47 |
48 | $columns = null;
49 | $insertRows = [];
50 | foreach ($insertRowsFields as $insertFields) {
51 | $insert = $sqlHelper->prepareInsert($tableName, $insertFields);
52 | if (empty($columns) && !empty($insert[0])) {
53 | $columns = $insert[0];
54 | }
55 | if (!empty($insert[1])) {
56 | $insertRows[] = "({$insert[1]})";
57 | }
58 | }
59 |
60 | if ($columns && $insertRows && $tableName) {
61 | $sql = "
62 | INSERT IGNORE INTO {$sqlHelper->quote($tableName)} ({$columns})
63 | VALUES ".implode(', ', $insertRows);
64 | } else {
65 | $sql = '';
66 | }
67 |
68 | return $sql;
69 | }
70 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/console/cache-delayed-delete.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
5 | * @version 0.9.0
6 | * @since 0.9.0
7 | * @example /path_to_module/console/cache-delayed-delete.php -l=1000
8 | * @example /2 * * * * php -f /path_to_module/console/cache-delayed-delete.php -l=1000
9 | */
10 |
11 | set_time_limit(3600);
12 | $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../../';
13 |
14 | define("NOT_CHECK_PERMISSIONS", true);
15 | //define("BX_UTF", true);
16 | define("NO_KEEP_STATISTIC", true);
17 | define("NO_AGENT_STATISTIC", true);
18 | //define("NOT_CHECK_PERMISSIONS", true);
19 | define("NO_AGENT_CHECK", true);
20 | define("BX_BUFFER_USED", true);
21 | error_reporting(E_ALL | E_ERROR | E_PARSE);
22 | ini_set("display_errors", "On");
23 |
24 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
25 |
26 | //error_reporting(E_ALL|E_ERROR|E_PARSE);
27 | //ini_set("display_errors","On");
28 |
29 | \Bitrix\Main\Loader::includeModule('main');
30 | \Bitrix\Main\Loader::includeModule('dev2fun.imagecompress');
31 |
32 | $params = getopt('l::');
33 | if (!empty($params['l'])) {
34 | $limit = (int)$params['l'];
35 | } else {
36 | $limit = \Bitrix\Main\Config\Option::get('dev2fun.imagecompress', 'cache_delete_length', 1000);
37 | }
38 |
39 | if (empty($limit)) {
40 | $limit = 1000;
41 | }
42 |
43 | \Bitrix\Main\Data\CacheEngineFiles::delayedDelete($limit);
44 |
45 | require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/console/convert.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
5 | * @version 0.8.0
6 | * @since 0.7.4
7 | * @example ./convert.php -l=10
8 | */
9 |
10 | set_time_limit(3600);
11 | $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../../';
12 |
13 | define("NOT_CHECK_PERMISSIONS", true);
14 | //define("BX_UTF", true);
15 | define("NO_KEEP_STATISTIC", true);
16 | //define("NOT_CHECK_PERMISSIONS", true);
17 | define("BX_BUFFER_USED", true);
18 | error_reporting(E_ALL | E_ERROR | E_PARSE);
19 | ini_set("display_errors", "On");
20 |
21 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
22 |
23 | //error_reporting(E_ALL|E_ERROR|E_PARSE);
24 | //ini_set("display_errors","On");
25 |
26 | \Bitrix\Main\Loader::includeModule('main');
27 | \Bitrix\Main\Loader::includeModule('iblock');
28 | \Bitrix\Main\Loader::includeModule('dev2fun.imagecompress');
29 |
30 | $params = getopt('l::');
31 | if (!empty($params['l'])) {
32 | $limit = (int)$params['l'];
33 | } else {
34 | $limit = 500;
35 | }
36 |
37 | $connection = \Bitrix\Main\Application::getConnection();
38 | $sqlHelper = $connection->getSqlHelper();
39 | $cnt = $connection->queryScalar(
40 | "SELECT COUNT(*) FROM b_file WHERE CONTENT_TYPE IN ('image/jpeg', 'image/png', 'image/gif')"
41 | );
42 |
43 | echo "Found {$cnt} files" . PHP_EOL;
44 |
45 | $convert = \Dev2fun\ImageCompress\Convert::getInstance();
46 |
47 | if (!$convert->enable) {
48 | echo "Converter is not active. Please activate function convert in module settings." . PHP_EOL;
49 | die();
50 | }
51 |
52 | echo "Start progress" . PHP_EOL;
53 |
54 | $lastId = null;
55 | $upload_dir = \Bitrix\Main\Config\Option::get('main', 'upload_dir', 'upload');
56 |
57 | //$files = [];
58 | $stepOnPage = 0;
59 | for ($i=1; $i<=$cnt; $i+=$limit) {
60 | $sql = "SELECT f.* FROM b_file f WHERE f.CONTENT_TYPE IN ('image/jpeg', 'image/png', 'image/gif')";
61 | if ($lastId) {
62 | $sql .= " AND f.ID>{$sqlHelper->forSql($lastId)}";
63 | }
64 | $sql .= " ORDER BY f.ID ASC LIMIT {$sqlHelper->forSql($limit)}";
65 | $recordset = $connection->query($sql);
66 | while ($arFile = $recordset->fetch()) {
67 | $stepOnPage++;
68 | $progressValue = round($stepOnPage / $cnt * 100, 2);
69 | $pathFile = "{$_SERVER["DOCUMENT_ROOT"]}/{$upload_dir}/{$arFile["SUBDIR"]}/{$arFile["FILE_NAME"]}";
70 | if (!is_file($pathFile)) {
71 | echo "Warning: file #{$arFile['ID']} not fount. Continue." . PHP_EOL;
72 | continue;
73 | }
74 | echo "Progress: convert image #{$arFile['ID']}" . PHP_EOL;
75 |
76 | if(!$convert->process($arFile) && $convert->LAST_ERROR) {
77 | echo "ERROR! {$convert->LAST_ERROR}" . PHP_EOL;
78 | } else {
79 | echo "Success. Image #{$arFile['ID']} converted." . PHP_EOL;
80 | }
81 |
82 | $lastId = $arFile['ID'];
83 | echo "Progress: {$progressValue}%" . PHP_EOL;
84 | }
85 | }
86 |
87 | echo "Finish progress" . PHP_EOL;
88 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/console/optimize.php:
--------------------------------------------------------------------------------
1 | #!/usr/bin/php
2 |
5 | * @version 0.7.4
6 | * @copyright dev2fun
7 | */
8 | set_time_limit(3600);
9 | $_SERVER['DOCUMENT_ROOT'] = __DIR__ . '/../../../../';
10 |
11 | define("NOT_CHECK_PERMISSIONS", true);
12 | //define("BX_UTF", true);
13 | define("NO_KEEP_STATISTIC", true);
14 | //define("NOT_CHECK_PERMISSIONS", true);
15 | define("BX_BUFFER_USED", true);
16 | error_reporting(E_ALL | E_ERROR | E_PARSE);
17 | ini_set("display_errors", "On");
18 |
19 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
20 |
21 | //error_reporting(E_ALL|E_ERROR|E_PARSE);
22 | //ini_set("display_errors","On");
23 |
24 | \Bitrix\Main\Loader::includeModule('main');
25 | \Bitrix\Main\Loader::includeModule('iblock');
26 | \Bitrix\Main\Loader::includeModule('dev2fun.imagecompress');
27 |
28 | $params = getopt('c::', ['limit::']);
29 |
30 | $limit = \Bitrix\Main\Config\Option::get('dev2fun.imagecompress', "cnt_step", 30);
31 | if (isset($params['limit'])) {
32 | $limit = (int)$params['limit'];
33 | }
34 |
35 | $noCompress = true;
36 | if (isset($params['c'])) {
37 | $noCompress = $params['c'] === 'N' ? false : true;
38 | }
39 |
40 | $filterList = [
41 | // 'COMRESSED' => 'N',
42 | '@CONTENT_TYPE' => [
43 | 'image/jpeg',
44 | 'image/png',
45 | 'application/pdf',
46 | ],
47 | ];
48 | if ($noCompress) {
49 | $filterList['COMRESSED'] = 'N';
50 | }
51 |
52 | $rsRes = \Dev2fun\ImageCompress\Compress::getInstance()->getFileList(
53 | [],
54 | $filterList,
55 | $limit
56 | );
57 |
58 | //$pageSize = \Bitrix\Main\Config\Option::get('dev2fun.imagecompress', "cnt_step", 30);
59 | $rsRes->NavStart($limit, false);
60 |
61 | $navPageCount = $rsRes->NavPageCount;
62 | $currentPageSize = $rsRes->NavPageSize;
63 | if (!$navPageCount) $navPageCount = 1;
64 | $stepOnPage = 1;
65 |
66 | while ($arFile = $rsRes->NavNext(true)) {
67 | $strFilePath = \CFile::GetPath($arFile["ID"]);
68 | $progressValue = $stepOnPage / $currentPageSize * 100;
69 | if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $strFilePath)) {
70 | \Dev2fun\ImageCompress\Compress::getInstance()->addCompressTable($arFile['ID'], [
71 | 'FILE_ID' => $arFile['ID'],
72 | 'SIZE_BEFORE' => 0,
73 | 'SIZE_AFTER' => 0,
74 | ]);
75 | echo "Error. Image #{$arFile['ID']} is not compressed! File not found!" . PHP_EOL;
76 | echo "Progress: {$progressValue}%" . PHP_EOL;
77 | $stepOnPage++;
78 | continue;
79 | }
80 | echo "Success. Image #{$arFile['ID']} compressed." . PHP_EOL;
81 | echo "Progress: {$progressValue}%" . PHP_EOL;
82 | $recCompress = \Dev2fun\ImageCompress\Compress::getInstance()->compressImageByID($arFile['ID']);
83 | $stepOnPage++;
84 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/default_option.php:
--------------------------------------------------------------------------------
1 | {
9 | let publicPath
10 | switch (dir) {
11 | case 'devserver':
12 | publicPath = '/bitrix/js/dev2fun.imagecompress/vue/'
13 | break
14 | case 'server':
15 | publicPath = '/bitrix/js/dev2fun.imagecompress/vue/'
16 | break
17 | default:
18 | publicPath = '/bitrix/js/dev2fun.imagecompress/vue/'
19 | break
20 | }
21 | return publicPath
22 | })(process.env.DIR)
23 |
24 | const path = require('node:path')
25 |
26 | const PATHS = {
27 | src: path.join(__dirname, '../src'),
28 | // dist: path.join(__dirname, '../dist', destinationDir),
29 | dist: path.join(__dirname, '../../../../js/dev2fun.imagecompress/vue'),
30 | // assets: 'assets/',
31 | }
32 |
33 | const webpackConfig = merge(commonConfig, {
34 | mode: 'development',
35 | devtool: 'cheap-module-source-map',
36 | // entry: {
37 | // vendor: ['bootstrap_vue', 'icons'],
38 | // },
39 | output: {
40 | path: PATHS.dist,
41 | publicPath,
42 | filename: 'js/[name].bundle.js',
43 | chunkFilename: 'js/[name].[contenthash:8].chunk.js',
44 | },
45 | optimization: {
46 | minimizer: [
47 | new TerserPlugin({
48 | // cache: true,
49 | parallel: true,
50 | terserOptions: {
51 | warnings: false,
52 | ie8: false,
53 | output: {
54 | comments: false,
55 | },
56 | },
57 | extractComments: false,
58 | }),
59 | ],
60 | splitChunks: {
61 | // chunks: 'all',
62 | maxInitialRequests: Infinity,
63 | minSize: 0,
64 | },
65 | },
66 | plugins: [
67 | new webpack.EnvironmentPlugin(environment),
68 | new webpack.HotModuleReplacementPlugin(),
69 | new webpack.optimize.ModuleConcatenationPlugin(),
70 | ],
71 | })
72 |
73 | module.exports = webpackConfig
74 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
13 |
17 |
21 |
25 | Document
26 |
27 |
28 |
29 |
30 |
34 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "berry-vuetify-vuejs",
3 | "version": "1.3.0",
4 | "private": true,
5 | "author": "CodedThemes",
6 | "scripts": {
7 | "preview": "vite preview --port 5050",
8 | "preview:school": "cross-env NODE_ENV=development PROJECT=school vite preview --port 5050",
9 | "typecheck": "vue-tsc --noEmit",
10 | "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
11 | "dev": "cross-env NODE_ENV=development PROJECT=school DIR=devserver TYPE=stage webpack --watch",
12 | "build": "cross-env NODE_ENV=production PROJECT=school DIR=server TYPE=prod webpack --progress ",
13 | "clean:school": "shx rm -rf ./dist/school",
14 | "format": "prettier . --write"
15 | },
16 | "dependencies": {
17 | "@mdi/js": "^7.4.47",
18 | "@suadelabs/vue3-multiselect": "^1.0.2",
19 | "@tabler/icons-vue": "^3.21.0",
20 | "@types/aos": "3.0.7",
21 | "aos": "2.3.4",
22 | "axios": "^1.7.7",
23 | "cross-env": "^7.0.3",
24 | "empty-lite": "^2.0.0",
25 | "lodash": "4.17.21",
26 | "sweetalert2": "^11.6.13",
27 | "tailwindcss": "^3.4.15",
28 | "vee-validate": "4.12.5",
29 | "vue-clipboard3": "2.0.0",
30 | "vue-draggable-next": "2.2.1",
31 | "vue-svg-inline-plugin": "^2.2.3",
32 | "vue-tabler-icons": "2.21.0"
33 | },
34 | "devDependencies": {
35 | "@babel/core": "^7.24.4",
36 | "@babel/eslint-parser": "^7.25.1",
37 | "@babel/preset-env": "^7.24.4",
38 | "@mdi/font": "^7.4.47",
39 | "@rushstack/eslint-patch": "^1.7.2",
40 | "@tsconfig/node20": "^20.1.2",
41 | "@types/chance": "1.1.6",
42 | "@types/lodash": "^4.14.202",
43 | "@types/node": "^20.11.18",
44 | "@vitejs/plugin-vue": "5.0.4",
45 | "@vue/eslint-config-airbnb": "^8.0.0",
46 | "@vue/eslint-config-prettier": "9.0.0",
47 | "@vue/eslint-config-typescript": "12.0.0",
48 | "@vue/tsconfig": "0.5.1",
49 | "autoprefixer": "^10.4.20",
50 | "babel-loader": "^9.1.3",
51 | "clean-webpack-plugin": "^4.0.0",
52 | "compression-webpack-plugin": "^11.1.0",
53 | "copy-webpack-plugin": "^12.0.2",
54 | "css-loader": "^7.1.1",
55 | "css-minimizer-webpack-plugin": "^6.0.0",
56 | "eslint": "^8.56.0",
57 | "eslint-config-prettier": "^9.1.0",
58 | "eslint-plugin-require": "^0.0.1",
59 | "eslint-plugin-vue": "^9.21.1",
60 | "mini-css-extract-plugin": "^2.9.0",
61 | "postcss": "^8.4.49",
62 | "postcss-loader": "^8.1.1",
63 | "postcss-preset-env": "^10.1.1",
64 | "prettier": "3.2.5",
65 | "sass": "1.70.0",
66 | "sass-loader": "^14.1.0",
67 | "style-loader": "^4.0.0",
68 | "svgo-loader": "^4.0.0",
69 | "terser-webpack-plugin": "^5.3.10",
70 | "ts-loader": "^9.5.1",
71 | "typescript": "5.3.3",
72 | "url-loader": "^4.1.1",
73 | "vue-cli-plugin-vuetify": "2.5.8",
74 | "vue-loader": "^17.4.2",
75 | "vue-style-loader": "^4.1.3",
76 | "vue-svg-loader-2": "^0.17.1",
77 | "vue-template-compiler": "^0.1.0",
78 | "vue-tsc": "^2.1.10",
79 | "webpack": "^5.91.0",
80 | "webpack-bundle-analyzer": "^4.10.2",
81 | "webpack-cli": "^5.1.4",
82 | "webpack-hot-middleware": "^2.26.1",
83 | "webpack-merge": "^5.10.0"
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/postcss.config.js:
--------------------------------------------------------------------------------
1 | const autoprefixer = require('autoprefixer');
2 | const tailwindcss = require('tailwindcss');
3 |
4 | module.exports = {
5 | plugins: [
6 | "postcss-preset-env",
7 | tailwindcss,
8 | autoprefixer,
9 | ],
10 | }
11 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
38 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/components/AdminMessage.vue:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
29 |
30 |
31 | {{ title }}
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
42 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/components/AdminNote.vue:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
38 |
39 |
40 |
43 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/components/ProgressBar.vue:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
24 |
25 |
26 | {{ title }}
27 |
28 |
29 |
35 |
36 | {{ progressText }}
37 |
38 |
39 |
{{ progressText }}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/main.ts:
--------------------------------------------------------------------------------
1 | import {createApp, defineAsyncComponent} from 'vue'
2 | import '@/scss/style.scss'
3 |
4 | const MoverFiles = defineAsyncComponent(() => import('@/components/MoverFiles.vue'))
5 |
6 | const app = createApp({
7 | components: {
8 | MoverFiles
9 | }
10 | })
11 |
12 | app.config.globalProperties.appName = 'dev2fun.imagecompress'
13 | app.config.globalProperties.appVersion = '1.0.0'
14 | app.config.compilerOptions.whitespace = 'preserve'
15 |
16 | app.mount('#dev2fun_imagecompress_convert_move')
17 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/methods/configMain.js:
--------------------------------------------------------------------------------
1 | export const configMain = {
2 | debug: true,
3 | // version: 'v1',
4 | url() {
5 | // return `/api/${this.version}`;
6 | return '/bitrix/admin/dev2fun_imagecompress_convert_move.php'
7 | },
8 | }
9 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/methods/http.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import { configMain } from './configMain'
3 |
4 | const http = axios.create({
5 | // baseURL: process.env.VUE_APP_ROOT_API,
6 | baseURL: configMain.url(),
7 | timeout: 60000,
8 | // headers: {
9 | // 'Content-Type': 'application/json',
10 | // // 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
11 | // },
12 | // transformRequest: (data, headers) => {
13 | // // console.log(data);
14 | // if (data) data = stringify(data);
15 | // return data;
16 | // }
17 | })
18 |
19 | http.interceptors.request.use(
20 | (config) => {
21 |
22 | // if (config.method === 'post') {
23 | // config.params = Object.assign({}, config.params, {sessid: BX.bitrix_sessid()})
24 | // }
25 | config.params = Object.assign({}, config.params, {sessid: BX.bitrix_sessid()})
26 |
27 | return config
28 | },
29 | (error) => {
30 | if (configMain.debug) {
31 | console.log(error)
32 | }
33 | return Promise.reject(error)
34 | },
35 | )
36 |
37 | http.interceptors.response.use(
38 | (response) => {
39 | const res = response.data
40 | if (configMain.debug) {
41 | console.log(res)
42 | }
43 | return res
44 | },
45 | (error) => {
46 | if (configMain.debug) {
47 | console.log(`err: ${error}`) // for debug
48 | }
49 | return Promise.reject(error)
50 | },
51 | )
52 |
53 | export default http
54 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/src/scss/style.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/frontend/src/scss/style.scss
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | module.exports = {
3 | purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
4 | darkMode: false,
5 | content: [],
6 | theme: {
7 | extend: {},
8 | },
9 | plugins: [],
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@vue/tsconfig/tsconfig.dom.json",
3 | "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/types/.d.ts"],
4 | "compilerOptions": {
5 | "ignoreDeprecations": "5.0",
6 | "baseUrl": ".",
7 | "paths": {
8 | "@/*": ["./src/*"]
9 | },
10 | "allowJs": true
11 | },
12 | "references": [
13 | {
14 | "path": "./tsconfig.vite-config.json"
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/frontend/webpack.config.js:
--------------------------------------------------------------------------------
1 | const environment = (process.env.NODE_ENV || 'development').trim()
2 |
3 | if (environment === 'development') {
4 | module.exports = require('./config/webpack.config.dev')
5 | } else {
6 | module.exports = require('./config/webpack.config.prod')
7 | }
8 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/include/options/gif.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.5.0
6 | */
7 |
8 | /**
9 | * @var string $optType
10 | */
11 | use \Bitrix\Main\Localization\Loc;
12 | use \Bitrix\Main\Config\Option;
13 | ?>
14 |
15 |
16 | = Loc::getMessage('D2F_IMAGECOMPRESS_HEADING_TEXT_SETTINGS', ['#MODULE#' => $optType]) ?>
17 | |
18 |
19 |
20 |
21 |
24 | |
25 |
26 |
35 | />
36 | |
37 |
38 |
39 |
40 |
41 | |
42 |
43 |
52 | |
53 |
54 |
55 |
56 |
59 | |
60 |
61 | "
65 | /> /gifsicle
66 | |
67 |
68 |
69 |
70 |
71 |
72 |
75 | |
76 |
77 |
84 | |
85 |
86 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/include/options/svg.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.8.5
6 | */
7 |
8 | /**
9 | * @var string $optType
10 | */
11 | use \Bitrix\Main\Localization\Loc;
12 | use \Bitrix\Main\Config\Option;
13 | ?>
14 |
15 |
16 | = Loc::getMessage('D2F_IMAGECOMPRESS_HEADING_TEXT_SETTINGS', ['#MODULE#' => $optType]) ?>
17 | |
18 |
19 |
20 |
21 |
24 | |
25 |
26 |
36 | />
37 | |
38 |
39 |
40 |
41 |
42 |
43 | |
44 |
45 |
54 | |
55 |
56 |
57 |
58 |
59 |
62 | |
63 |
64 | "
68 | /> /node
69 | |
70 |
71 |
72 |
73 |
74 |
77 | |
78 |
79 | "
83 | /> /svgo
84 | |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/admin/dev2fun_imagecompress_convert.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/error.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.2.1
6 | */
7 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
8 | if(!check_bitrix_sessid()) return;
9 |
10 | use Bitrix\Main\Loader,
11 | Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | Loader::includeModule('main');
16 |
17 | CAdminMessage::ShowMessage(array(
18 | "MESSAGE"=>$GLOBALS['D2F_COMPRESSIMAGE_ERROR'],
19 | "TYPE"=>"ERROR"
20 | ));
21 | echo BeginNote();
22 | echo $GLOBALS['D2F_COMPRESSIMAGE_ERROR_NOTES'];
23 | echo EndNote();
24 |
25 | echo ''.Loc::getMessage('D2F_COMPRESSIMAGE_GOTO_FIRST').'
';
26 | echo ''.Loc::getMessage('D2F_COMPRESSIMAGE_GOTO_MODULES').'';
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/final.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.2.1
6 | */
7 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
8 | if(!check_bitrix_sessid()) return;
9 |
10 | use Bitrix\Main\Loader,
11 | Bitrix\Main\Localization\Loc;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | Loader::includeModule('main');
16 |
17 | CAdminMessage::ShowMessage(array(
18 | "MESSAGE"=>Loc::getMessage('D2F_IMAGECOMPRESS_INSTALL_SUCCESS'),
19 | "TYPE"=>"OK"
20 | ));
21 | echo BeginNote();
22 | echo Loc::getMessage("D2F_IMAGECOMPRESS_INSTALL_LAST_MSG");
23 | echo EndNote();
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/js/vue/css/bundle.css:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/js/vue/js/265.70db9293.chunk.js:
--------------------------------------------------------------------------------
1 | "use strict";(self.webpackChunkberry_vuetify_vuejs=self.webpackChunkberry_vuetify_vuejs||[]).push([[265],{RtvE:(e,s,a)=>{a.r(s),a.d(s,{default:()=>d});var t=a("L75T");const i={class:"adm-info-message"},n={class:"adm-info-message-title"},d=(0,t.pM)({__name:"AdminMessage",props:{title:{type:String,default:"Заголовок"},type:{type:String,default:"ERROR"}},setup(e){const s=e,a=(0,t.EW)((()=>"OK"===s.type?"adm-info-message-green":"adm-info-message-red"));return(s,d)=>((0,t.uX)(),(0,t.CE)("div",{class:(0,t.C4)(["adm-info-message-wrap",a.value])},[(0,t.Lk)("div",i,[(0,t.Lk)("div",n,(0,t.v_)(e.title),1),d[0]||(d[0]=(0,t.Lk)("div",{class:"adm-info-message-icon"},null,-1))])],2))}})}}]);
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/js/vue/js/534.e3a55a2c.chunk.js:
--------------------------------------------------------------------------------
1 | "use strict";(self.webpackChunkberry_vuetify_vuejs=self.webpackChunkberry_vuetify_vuejs||[]).push([[534],{If9R:(e,s,a)=>{a.r(s),a.d(s,{default:()=>o});var r=a("L75T");const t={class:"adm-info-message"},o=(0,r.pM)({__name:"AdminNote",props:{style:{type:String||Object,default:{position:"relative",top:"-15px"}},color:{type:String,default:""}},setup:e=>(s,a)=>((0,r.uX)(),(0,r.CE)("div",{class:(0,r.C4)(["adm-info-message-wrap",{"adm-info-message-gray":"gray"===e.color,"adm-info-message-red":"red"===e.color,"adm-info-message-green":"green"===e.color}]),style:(0,r.Tr)(e.style)},[(0,r.Lk)("div",t,[(0,r.RG)(s.$slots,"default")])],6))})}}]);
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/js/vue/js/683.9c04fc2e.chunk.js:
--------------------------------------------------------------------------------
1 | "use strict";(self.webpackChunkberry_vuetify_vuejs=self.webpackChunkberry_vuetify_vuejs||[]).push([[683],{ks9F:(s,e,r)=>{r.r(e),r.d(e,{default:()=>n});var a=r("L75T");const t={class:"adm-info-message-wrap adm-info-message-gray"},i={class:"adm-info-message"},l={class:"adm-info-message-title"},d={class:"adm-progress-bar-outer",style:{width:"500px"}},p={class:"adm-progress-bar-inner-text",style:{width:"500px"}},n=(0,a.pM)({__name:"ProgressBar",props:{title:{type:String,default:"Заголовок"},progressText:{type:String,default:"Прогрес темплейт"},progress:{type:Number,default:0}},setup:s=>(e,r)=>((0,a.uX)(),(0,a.CE)("div",t,[(0,a.Lk)("div",i,[(0,a.Lk)("div",l,(0,a.v_)(s.title),1),(0,a.Lk)("div",d,[(0,a.Lk)("div",{class:"adm-progress-bar-inner",style:(0,a.Tr)({width:`${s.progress}%`})},[(0,a.Lk)("div",p,[(0,a.Lk)("span",null,(0,a.v_)(s.progressText),1)])],4),(0,a.Lk)("span",null,(0,a.v_)(s.progressText),1)]),r[0]||(r[0]=(0,a.Lk)("div",{class:"adm-info-message-buttons"},null,-1))])]))})}}]);
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/step1.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.7.2
6 | */
7 |
8 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
9 | if (!check_bitrix_sessid()) return;
10 |
11 | use Bitrix\Main\Loader,
12 | Bitrix\Main\Localization\Loc,
13 | Bitrix\Main\Config\Option;
14 |
15 | IncludeModuleLangFile(__FILE__);
16 |
17 | Loader::includeModule('main');
18 | $moduleName = 'dev2fun.imagecompress';
19 |
20 | Loader::registerAutoLoadClasses(
21 | $moduleName,
22 | [
23 | 'Dev2fun\ImageCompress\ImageCompressTable' => 'classes/general/ImageCompressTable.php',
24 | 'Dev2fun\ImageCompress\AdminList' => 'lib/AdminList.php',
25 | 'Dev2fun\ImageCompress\Check' => 'lib/Check.php',
26 | 'Dev2fun\ImageCompress\Compress' => 'lib/Compress.php',
27 | "Dev2funImageCompress" => 'include.php',
28 |
29 | "Dev2fun\ImageCompress\Jpegoptim" => 'lib/Jpegoptim.php',
30 | "Dev2fun\ImageCompress\Optipng" => 'lib/Optipng.php',
31 | ]
32 | );
33 | echo BeginNote();
34 | echo Loc::getMessage('D2F_MODULE_IMAGECOMPRESS_STEP1_NOTES');
35 | echo EndNote();
36 | ?>
37 |
65 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/themes/.default/dev2fun.imagecompress.css:
--------------------------------------------------------------------------------
1 | /*Menu icon*/
2 | .dev2fun_compressimage_menu_icon {
3 | background-image:url('icons/dev2fun.imagecompress/dev2fun_imagecompress.png');
4 | background-position: 9px 4px;
5 | }
6 | #dev2fun_compressimage_menu_icon {
7 | background-image:url('icons/dev2fun.imagecompress/dev2fun_imagecompress.png');
8 | }
9 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/themes/.default/icons/dev2fun.imagecompress/dev2fun_imagecompress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/install/themes/.default/icons/dev2fun.imagecompress/dev2fun_imagecompress.png
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/unstep1.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.7.2
6 | */
7 |
8 | if (!check_bitrix_sessid()) return;
9 | IncludeModuleLangFile(__FILE__);
10 |
11 | CModule::IncludeModule("main");
12 |
13 | use \Bitrix\Main\Localization\Loc;
14 |
15 | ?>
16 |
37 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/install/version.php:
--------------------------------------------------------------------------------
1 | '0.11.5',
4 | 'VERSION_DATE' => '2025-05-26 00:40:00',
5 | ];
6 |
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/admin/dev2fun_imagecompress_convert.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/admin/dev2fun_imagecompress_convert.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/admin/dev2fun_imagecompress_convert_move.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/admin/dev2fun_imagecompress_convert_move.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/admin/dev2fun_imagecompress_files.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/admin/dev2fun_imagecompress_files.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/admin/menu.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/admin/menu.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/classes/general/ImageCompressImagesToConvertedTable.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/classes/general/ImageCompressImagesToConvertedTable.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/classes/general/ImageCompressTable.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/classes/general/ImageCompressTable.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/include.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/include.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/install/error.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/install/error.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/install/final.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/install/final.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/install/index.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/install/index.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/install/step1.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/install/step1.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/install/unstep1.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/install/unstep1.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/lib/AdminList.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/lib/AdminList.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/lib/Check.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/lib/Check.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/lib/Compress.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/lib/Compress.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/lib/Convert.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/lib/Convert.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/lib/Jpegoptim.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/lib/Jpegoptim.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/lib/Optipng.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/lib/Optipng.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/options.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/options.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lang/ru/updater.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darkfriend/dev2fun.imagecompress/89a12c4794d402999635f120b0a39c653b2457b3/win1251/dev2fun.imagecompress/lang/ru/updater.php
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/Cache.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.11.4
6 | * @since 0.9.0
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | use Bitrix\Main\Config\Option;
12 | use CAgent;
13 |
14 | IncludeModuleLangFile(__FILE__);
15 |
16 | class Cache
17 | {
18 | const OPTION_NAME_DELETE_AGENT = 'cache_delete_agent';
19 |
20 | /**
21 | * Return current cache engine
22 | * @return string
23 | */
24 | public static function getCacheEngine()
25 | {
26 | return \Bitrix\Main\Data\Cache::getCacheEngineType();
27 | }
28 |
29 | /**
30 | * Run agent
31 | * @return string
32 | */
33 | public static function agentRun()
34 | {
35 | if (self::getCacheEngine() === 'cacheenginefiles') {
36 | $cache = \Bitrix\Main\Data\Cache::createCacheEngine();
37 | $cache->delayedDelete();
38 | }
39 |
40 | return self::class . '::agentRun();';
41 | }
42 |
43 | /**
44 | * Return agent id after add agent
45 | * @return int
46 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
47 | */
48 | public static function addAgent(): int
49 | {
50 | $startTime = ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 120, 'FULL');
51 | $agentId = CAgent::AddAgent(
52 | self::class . '::agentRun();',
53 | \Dev2funImageCompress::MODULE_ID,
54 | 'Y',
55 | 120,
56 | '',
57 | 'N',
58 | $startTime,
59 | 100,
60 | false,
61 | false
62 | );
63 | if (!$agentId) {
64 | throw new \Exception('Error when add agent for cache-delete');
65 | }
66 |
67 | Option::set(\Dev2funImageCompress::MODULE_ID, self::OPTION_NAME_DELETE_AGENT, $agentId);
68 |
69 | return $agentId;
70 | }
71 |
72 | /**
73 | * Return agent id from bitrix options
74 | * @return int|null
75 | */
76 | public static function getAgentIdOption(): ?int
77 | {
78 | return Option::get(\Dev2funImageCompress::MODULE_ID, self::OPTION_NAME_DELETE_AGENT) ?: null;
79 | }
80 |
81 | /**
82 | * @return array|false|null
83 | */
84 | public static function getAgent()
85 | {
86 | static $agent = null;;
87 | if ($agent === null) {
88 | $rs = CAgent::GetList([], ['NAME' => self::class . '::agentRun();']);
89 | $agent = $rs ? $rs->Fetch() : [];
90 | }
91 |
92 | return $agent;
93 | }
94 |
95 | /**
96 | * Return agent id from agents list
97 | * @return int|null
98 | */
99 | public static function getAgentIdDb(): ?int
100 | {
101 | $rs = self::getAgent();
102 | return $rs ? $rs['ID'] : null;
103 | }
104 |
105 | /**
106 | * @return int|null
107 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
108 | */
109 | public static function getAgentId(): ?int
110 | {
111 | $agentId = self::getAgentIdOption();
112 | if (!$agentId) {
113 | $agentId = self::getAgentIdDb();
114 | if (!$agentId) {
115 | $agentId = self::addAgent();
116 | }
117 | }
118 |
119 | return $agentId;
120 | }
121 |
122 | /**
123 | * Activate agent
124 | * @return bool
125 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
126 | */
127 | public static function activateAgent(): bool
128 | {
129 | $agentId = self::getAgentId();
130 | return (bool)CAgent::Update($agentId, ['ACTIVE' => 'Y']);
131 | }
132 |
133 | /**
134 | * @return bool
135 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
136 | */
137 | public static function deactivateAgent(): bool
138 | {
139 | $agentId = self::getAgentId();
140 | return (bool)CAgent::Update($agentId, ['ACTIVE' => 'N']);
141 | }
142 |
143 | /**
144 | * @return string
145 | */
146 | public static function getAgentActiveValue(): string
147 | {
148 | return self::getAgent()['ACTIVE'] ?? 'N';
149 | }
150 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/ConvertSearchPictures.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.11.5
6 | * @since 0.11.5
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | class ConvertSearchPictures
12 | {
13 | /**
14 | * @param string $path
15 | * @param array $excludePaths
16 | * @return bool
17 | */
18 | public static function isExcluded(string $path, array $excludePaths): bool
19 | {
20 | return IO::isExcluded($path, $excludePaths);
21 | }
22 |
23 | /**
24 | * @param string $path
25 | * @return int
26 | */
27 | public static function getCountFiles(string $path): int
28 | {
29 | return IO::getCountFiles($path);
30 | }
31 |
32 | /**
33 | * @param string $dir
34 | * @param array $excludePaths
35 | * @param int $chunkFiles
36 | * @return array|null
37 | * @throws \Bitrix\Main\ArgumentException
38 | * @throws \Bitrix\Main\ArgumentTypeException
39 | * @throws \Bitrix\Main\DB\SqlQueryException
40 | * @throws \Bitrix\Main\ObjectPropertyException
41 | * @throws \Bitrix\Main\SystemException
42 | */
43 | public static function scanFiles(string $dir, array $excludePaths = [], int $chunkFiles = 500): ?array
44 | {
45 | $iterator = new \RecursiveIteratorIterator(
46 | new \RecursiveDirectoryIterator(
47 | $dir,
48 | \FilesystemIterator::SKIP_DOTS
49 | ),
50 | \RecursiveIteratorIterator::SELF_FIRST
51 | );
52 |
53 | $extSupport = [
54 | 'jpeg',
55 | 'jpg',
56 | 'png',
57 | ];
58 | $files = [];
59 | $lastFile = null;
60 | $cntProcess = 0;
61 | /** @var \SplFileInfo $file */
62 | foreach ($iterator as $file) {
63 | if (self::isExcluded($file->getPathname(), $excludePaths)) {
64 | continue;
65 | }
66 |
67 | if ($file->isFile()) {
68 | if (!in_array($file->getExtension(), $extSupport)) {
69 | continue;
70 | }
71 |
72 | $files[] = $file->getPathname();
73 | $cntProcess++;
74 |
75 | if (count($files) >= $chunkFiles) {
76 | self::insertImage($files);
77 | $files = [];
78 | }
79 | }
80 |
81 | $lastFile = $file->getPathname();
82 | }
83 |
84 | if ($files) {
85 | self::insertImage($files);
86 | }
87 |
88 | return [
89 | 'cnt' => $cntProcess,
90 | 'lastFile' => $lastFile,
91 | ];
92 | }
93 |
94 | /**
95 | * @param array $files
96 | * @return void
97 | * @throws \Bitrix\Main\ArgumentException
98 | * @throws \Bitrix\Main\ArgumentTypeException
99 | * @throws \Bitrix\Main\DB\SqlQueryException
100 | * @throws \Bitrix\Main\ObjectPropertyException
101 | * @throws \Bitrix\Main\SystemException
102 | */
103 | public static function insertImage(array $files): void
104 | {
105 | $currentFiles = LazyConvert::findFiles($files);
106 | $rows = [];
107 | foreach ($files as $file) {
108 | $md5 = md5_file($file);
109 | if (empty($currentFiles[$md5])) {
110 | $fileUrl = str_replace($_SERVER['DOCUMENT_ROOT'], '', $file);
111 | $rows[] = [
112 | 'IMAGE_PATH' => $fileUrl,
113 | 'IMAGE_HASH' => $md5,
114 | 'IMAGE_IGNORE' => 'N',
115 | ];
116 | }
117 | }
118 |
119 | $sql = MySqlHelper::getInsertIgnoreMulti(
120 | ImageCompressImagesTable::getTableName(),
121 | $rows
122 | );
123 |
124 | \Bitrix\Main\Application::getInstance()
125 | ->getConnection()
126 | ->queryExecute($sql);
127 | }
128 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/Gif.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.4.0
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Localization\Loc;
11 | use Bitrix\Main\Config\Option;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class Gif
16 | {
17 | private static $instance;
18 | public $lastError;
19 |
20 | private $MODULE_ID = 'dev2fun.imagecompress';
21 | private $path = '';
22 | private $active = false;
23 | private static $isOptim = null;
24 |
25 | public function __construct()
26 | {
27 | $this->path = Option::get($this->MODULE_ID, 'path_to_gif', '/usr/bin');
28 | $this->active = Option::get($this->MODULE_ID, 'enable_gif', 'N') === 'Y';
29 | }
30 |
31 | /**
32 | * @static
33 | * @return Ps2Pdf
34 | */
35 | public static function getInstance()
36 | {
37 | if (!isset(self::$instance)) {
38 | $c = __CLASS__;
39 | self::$instance = new $c;
40 | }
41 | return self::$instance;
42 | }
43 |
44 | /**
45 | * Return has active state
46 | * @return bool
47 | */
48 | public function isActive(): bool
49 | {
50 | return $this->active;
51 | }
52 |
53 | /**
54 | * Check optimize for gif
55 | * @param string|null $path
56 | * @return bool
57 | */
58 | public function isOptim(?string $path = null)
59 | {
60 | if (!$path) {
61 | $path = $this->path;
62 | }
63 | if (self::$isOptim === null || $path !== $this->path) {
64 | exec($path . '/gifsicle --version', $s);
65 | self::$isOptim = (bool)$s;
66 | }
67 | return self::$isOptim;
68 | }
69 |
70 | /**
71 | * Процесс оптимизации JPEG
72 | * @param string $strFilePath - абсолютный путь до картинки
73 | * @param array $params - дополнительные параметры
74 | * @return bool
75 | * @throws \Exception
76 | */
77 | public function compress($strFilePath, $params = [])
78 | {
79 | if(!$this->isActive()) {
80 | $this->lastError = 'no_active';
81 | return false;
82 | }
83 | $strFilePath = strtr(
84 | $strFilePath,
85 | [
86 | ' ' => '\ ',
87 | '(' => '\(',
88 | ')' => '\)',
89 | ']' => '\]',
90 | '[' => '\[',
91 | ]
92 | );
93 |
94 | if(empty($params['compression'])) {
95 | $params['compression'] = Option::get($this->MODULE_ID, 'gif_compress', 2);
96 | }
97 |
98 | $event = new \Bitrix\Main\Event(
99 | $this->MODULE_ID,
100 | "OnBeforeResizeImageGif",
101 | [&$strFilePath, &$params]
102 | );
103 | $event->send();
104 |
105 | $strCommand = '';
106 | if(!empty($params['compression'])) {
107 | $strCommand .= "-O{$params['compression']} ";
108 | }
109 |
110 | exec($this->path . "/gifsicle $strCommand $strFilePath -o $strFilePath 2>&1", $res);
111 |
112 | if (!empty($params['changeChmod'])) {
113 | chmod($strFilePath, $params['changeChmod']);
114 | }
115 | $event = new \Bitrix\Main\Event(
116 | $this->MODULE_ID,
117 | "OnAfterResize",
118 | [&$strFilePath]
119 | );
120 | $event->send();
121 | return true;
122 | }
123 |
124 | public function getOptionsSettings($advanceSettings=[])
125 | {
126 | $settings = [
127 | 'gif_compress' => 'string',
128 | ];
129 | $post = [
130 | 'checkbox' => [],
131 | 'string' => [],
132 | ];
133 | foreach ($settings as $option=>$setting) {
134 | if(empty($advanceSettings[$setting][$option])) {
135 | if($setting==='checkbox') {
136 | $post[$setting][$option] = 'N';
137 | } else {
138 | $post[$setting][$option] = '';
139 | }
140 | } else {
141 | $post[$setting][$option] = $advanceSettings[$setting][$option];
142 | }
143 | }
144 | return $post;
145 | }
146 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/IO.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.11.5
6 | * @since 0.11.0
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | class IO
12 | {
13 | /**
14 | * Проверяет директорию на пустоту
15 | * @param string $path
16 | * @return bool
17 | */
18 | public static function isEmptyDir(string $path): bool
19 | {
20 | if (!is_dir($path)) {
21 | return false;
22 | }
23 | $path = realpath($path);
24 | if ($path) {
25 | foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS)) as $object){
26 | if ($object->isFile()) {
27 | return false;
28 | }
29 | }
30 | }
31 | return true;
32 | }
33 |
34 | /**
35 | * @param string $path
36 | * @param array $excludePaths
37 | * @return bool
38 | */
39 | public static function isExcluded(string $path, array $excludePaths): bool
40 | {
41 | foreach ($excludePaths as $excludePath) {
42 | if (strpos($path, $excludePath) === 0) {
43 | return true;
44 | }
45 | }
46 | return false;
47 | }
48 |
49 | /**
50 | * @param string $path
51 | * @return int
52 | */
53 | public static function getCountFiles(string $path, array $excludePaths = []): int
54 | {
55 | $count = 0;
56 | $path = realpath($path);
57 | if ($path && file_exists($path)) {
58 | /** @var \RecursiveDirectoryIterator $object */
59 | foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS)) as $object){
60 | if ($object->isFile() && !self::isExcluded($object->getPathname(), $excludePaths)) {
61 | $count++;
62 | }
63 | }
64 | }
65 |
66 | return $count;
67 | }
68 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/Process.php:
--------------------------------------------------------------------------------
1 |
5 | * @version 0.4.0
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Config\Option;
11 |
12 | class Process
13 | {
14 | /**
15 | * @param array $params = [
16 | * 'sort' => [],
17 | * 'filters' => [
18 | * 'contentType' => [],
19 | * 'compressed' => 'N',
20 | * ],
21 | * 'limit' => 30,
22 | * ]
23 | * @return array[]|bool
24 | * @throws \Bitrix\Main\ArgumentNullException
25 | * @throws \Bitrix\Main\ArgumentOutOfRangeException
26 | */
27 | public static function start(array $params = [])
28 | {
29 | if(!Compress::getEnable()) return false;
30 | $params['filters'] = array_merge(
31 | [
32 | 'contentType' => [
33 | 'image/jpeg',
34 | 'image/png',
35 | 'application/pdf',
36 | ],
37 | 'compressed' => 'N'
38 | ],
39 | isset($params['filters']) ? $params['filters'] : []
40 | );
41 |
42 | if(empty($params['limit'])) {
43 | $params['limit'] = Option::get('dev2fun.imagecompress', "cnt_step", 30);
44 | }
45 | if(!isset($params['sort'])) {
46 | $params['sort'] = [];
47 | }
48 |
49 | $compress = Compress::getInstance();
50 | $rsRes = static::getQuery([
51 | 'sort' => $params['sort'],
52 | 'filters' => [
53 | '@CONTENT_TYPE' => $params['filters']['contentType'],
54 | 'COMRESSED' => $params['filters']['compressed'],
55 | ]
56 | ]);
57 | // $rsRes = $compress->getFileList(
58 | // [],
59 | // [
60 | // '@CONTENT_TYPE' => $params['filters']['contentType'],
61 | // 'COMRESSED' => $params['filters']['compressed'],
62 | // ]
63 | // );
64 | $rsRes->NavStart($params['limit'], false);
65 |
66 | $result = [
67 | 'error' => [],
68 | 'success' => [],
69 | ];
70 | $stepOnPage = 1;
71 | while ($arFile = $rsRes->NavNext(true)) {
72 | $strFilePath = \CFile::GetPath($arFile["ID"]);
73 | if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $strFilePath)) {
74 | $compress->addCompressTable($arFile['ID'], [
75 | 'FILE_ID' => $arFile['ID'],
76 | 'SIZE_BEFORE' => 0,
77 | 'SIZE_AFTER' => 0,
78 | ]);
79 | $result['error'][] = $arFile['ID'];
80 | } else {
81 | $compress->compressImageByID($arFile['ID']);
82 | $result['success'][] = $arFile['ID'];
83 | }
84 | $stepOnPage++;
85 | }
86 |
87 | $result['updFiles'] = $stepOnPage;
88 | return $result;
89 | }
90 |
91 | /**
92 | * @param array $params = [
93 | * 'sort' => [],
94 | * 'filters' => [],
95 | * ]
96 | * @return bool|\CDBResult
97 | */
98 | public static function getQuery(array $params = [])
99 | {
100 | if(!isset($params['sort'])) {
101 | $params['sort'] = array();
102 | }
103 | if(!isset($params['filters'])) {
104 | $params['filters'] = array();
105 | }
106 | return Compress::getInstance()->getFileList(
107 | $params['sort'],
108 | $params['filters']
109 | );
110 | }
111 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/Ps2Pdf.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.7.4
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Localization\Loc;
11 | use Bitrix\Main\Config\Option;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class Ps2Pdf
16 | {
17 | private static $instance;
18 | public $lastError;
19 |
20 | private $MODULE_ID = 'dev2fun.imagecompress';
21 | private $path = '';
22 | private $pdfSetting = 'ebook';
23 | private static $isOptim = null;
24 | private $active = false;
25 |
26 | /**
27 | * @param string|null $siteId
28 | */
29 | public function __construct()
30 | {
31 | $this->path = Option::get($this->MODULE_ID, 'path_to_ps2pdf', '');
32 | $this->active = Option::get($this->MODULE_ID, 'enable_pdf', 'N') === 'Y';
33 | $this->pdfSetting = Option::get($this->MODULE_ID, 'pdf_setting', 'ebook');
34 | }
35 |
36 | /**
37 | * Return has active state
38 | * @return bool
39 | */
40 | public function isActive(): bool
41 | {
42 | return $this->active;
43 | }
44 |
45 | /**
46 | * @static
47 | * @return Ps2Pdf
48 | */
49 | public static function getInstance()
50 | {
51 | if (!isset(self::$instance)) {
52 | $c = __CLASS__;
53 | self::$instance = new $c;
54 | }
55 | return self::$instance;
56 | }
57 |
58 | /**
59 | * Check available optimization pdf
60 | * @return bool
61 | * @deprecated
62 | * @uses isOptim()
63 | */
64 | public function isPdfOptim()
65 | {
66 | return $this->isOptim();
67 | }
68 |
69 | /**
70 | * Check available optimization pdf
71 | * @param string|null $path
72 | * @return bool
73 | */
74 | public function isOptim(?string $path = null)
75 | {
76 | if (!$path) {
77 | $path = $this->path;
78 | }
79 | if (self::$isOptim === null || $path !== $this->path) {
80 | \exec($path . '/gs -v', $s);
81 | self::$isOptim = (bool)$s;;
82 | }
83 | return self::$isOptim;
84 | }
85 |
86 | /**
87 | * Процесс оптимизации JPEG
88 | * @param string $strFilePath - абсолютный путь до картинки
89 | * @param array $params - дополнительные параметры
90 | * @return bool
91 | * @throws \Exception
92 | */
93 | public function compress($strFilePath, $params = [])
94 | {
95 | if(!$this->active) {
96 | $this->lastError = 'no_active';
97 | return false;
98 | }
99 | $strFilePath = \strtr(
100 | $strFilePath,
101 | [
102 | ' ' => '\ ',
103 | '(' => '\(',
104 | ')' => '\)',
105 | ']' => '\]',
106 | '[' => '\[',
107 | ]
108 | );
109 | if(!isset($params['pdfSetting'])) {
110 | $params['pdfSetting'] = $this->pdfSetting;
111 | }
112 |
113 | $event = new \Bitrix\Main\Event(
114 | $this->MODULE_ID,
115 | "OnBeforeResizeImagePs2Pdf",
116 | [&$strFilePath, &$params]
117 | );
118 | $event->send();
119 |
120 | $strFilePathNew = $strFilePath.'.pdf';
121 | $strCommand = "-sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/{$params['pdfSetting']} -dNOPAUSE -dQUIET -dBATCH";
122 |
123 | \exec($this->path . "/gs {$strCommand} -sOutputFile='{$strFilePathNew}' '{$strFilePath}' 2>&1", $res);
124 | // exec($this->path . "/ps2pdf $strCommand $strFilePath $strFilePathNew 2>&1", $res);
125 |
126 | if(\file_exists($strFilePathNew)) {
127 | \unlink($strFilePath);
128 | \rename($strFilePathNew, $strFilePath);
129 | }
130 |
131 | if (!empty($params['changeChmod'])) {
132 | \chmod($strFilePath, $params['changeChmod']);
133 | }
134 | $event = new \Bitrix\Main\Event(
135 | $this->MODULE_ID,
136 | "OnAfterResize",
137 | [&$strFilePath]
138 | );
139 | $event->send();
140 | return true;
141 | }
142 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/Resize.php:
--------------------------------------------------------------------------------
1 |
5 | * Date: 26.08.2018
6 | * Time: 20:40
7 | */
8 |
9 | namespace Dev2fun\ImageCompress;
10 |
11 | use Bitrix\Main\Localization\Loc;
12 | use Bitrix\Main\Config\Option;
13 |
14 | class Resize
15 | {
16 | private static $instance;
17 | public $lastError;
18 |
19 | private $MODULE_ID = 'dev2fun.imagecompress';
20 | private $width = '';
21 | private $height = '';
22 | private $algorithm = '';
23 | private $enable = false;
24 |
25 | /**
26 | * @param string|null $siteId
27 | */
28 | public function __construct(?string $siteId = null)
29 | {
30 | // if (!$siteId) {
31 | // $siteId = \Dev2funImageCompress::getSiteId();
32 | // }
33 | $this->width = Option::get($this->MODULE_ID, 'resize_width', '');
34 | $this->height = Option::get($this->MODULE_ID, 'resize_height', '');
35 | $this->algorithm = Option::get($this->MODULE_ID, 'resize_algorithm', '');
36 | $this->enable = Option::get($this->MODULE_ID, 'resize_enable', 'N') === 'Y';
37 | if (!$this->algorithm) {
38 | $this->algorithm = BX_RESIZE_IMAGE_PROPORTIONAL;
39 | }
40 | }
41 |
42 | /**
43 | * @static
44 | * @return Resize
45 | */
46 | public static function getInstance()
47 | {
48 | if (!isset(self::$instance)) {
49 | $c = __CLASS__;
50 | self::$instance = new $c;
51 | }
52 | return self::$instance;
53 | }
54 |
55 | public function resize($strFilePath)
56 | {
57 | if (!$strFilePath || !$this->enable) {
58 | return false;
59 | }
60 | $destinationFile = $_SERVER['DOCUMENT_ROOT'] . "/upload/{$this->MODULE_ID}/" . basename($strFilePath);
61 | $res = \CFile::ResizeImageFile(
62 | $strFilePath,
63 | $destinationFile,
64 | [
65 | 'width' => $this->width,
66 | 'height' => $this->height,
67 | ],
68 | $this->algorithm
69 | );
70 | if ($res) {
71 | chmod($destinationFile, 0777);
72 | copy($destinationFile, $strFilePath);
73 | unlink($destinationFile);
74 | }
75 | return $res;
76 | }
77 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/Svg.php:
--------------------------------------------------------------------------------
1 |
4 | * @copyright dev2fun
5 | * @version 0.8.5
6 | */
7 |
8 | namespace Dev2fun\ImageCompress;
9 |
10 | use Bitrix\Main\Localization\Loc;
11 | use Bitrix\Main\Config\Option;
12 |
13 | IncludeModuleLangFile(__FILE__);
14 |
15 | class Svg
16 | {
17 | private static $instance;
18 | private static $isOptim = null;
19 | public $lastError;
20 | public $binaryName = 'svgo';
21 | private $MODULE_ID = 'dev2fun.imagecompress';
22 | /** @var string путь до svgo */
23 | private $path = '';
24 | /** @var string путь до nodejs */
25 | public $pathNodejs;
26 | private $active = false;
27 |
28 | /**
29 | * @param string|null $siteId
30 | */
31 | public function __construct()
32 | {
33 | $this->path = Option::get($this->MODULE_ID, 'path_to_svg', '/usr/bin');
34 | $this->pathNodejs = Option::get($this->MODULE_ID, 'path_to_node', '/usr/bin');
35 | $this->active = Option::get($this->MODULE_ID, 'enable_svg', 'N') === 'Y';
36 | }
37 |
38 | /**
39 | * @static
40 | * @return Ps2Pdf
41 | */
42 | public static function getInstance()
43 | {
44 | if (!isset(self::$instance)) {
45 | $c = __CLASS__;
46 | self::$instance = new $c;
47 | }
48 | return self::$instance;
49 | }
50 |
51 | /**
52 | * Return has active state
53 | * @return bool
54 | */
55 | public function isActive(): bool
56 | {
57 | return $this->active;
58 | }
59 |
60 | /**
61 | * Check available optimization svg
62 | * @param string|null $path
63 | * @param string|null $pathNodejs
64 | * @return bool
65 | */
66 | public function isOptim(?string $path = null, ?string $pathNodejs = null): bool
67 | {
68 | if (!$path) {
69 | $path = $this->path;
70 | }
71 | if (!$pathNodejs) {
72 | $pathNodejs = $this->pathNodejs;
73 | }
74 | if (self::$isOptim === null || $path !== $this->path || $pathNodejs !== $this->pathNodejs) {
75 | exec("{$pathNodejs}/node {$path}/{$this->binaryName} -v", $s);
76 | self::$isOptim = (bool)$s;
77 | }
78 | return self::$isOptim;
79 | }
80 |
81 | /**
82 | * Процесс оптимизации JPEG
83 | * @param string $strFilePath - абсолютный путь до картинки
84 | * @param array $params - дополнительные параметры
85 | * @return bool
86 | * @throws \Exception
87 | */
88 | public function compress($strFilePath, $params = [])
89 | {
90 | if (!$this->active) {
91 | $this->lastError = 'no_active';
92 | return false;
93 | }
94 | $strFilePath = strtr(
95 | $strFilePath,
96 | [
97 | ' ' => '\ ',
98 | '(' => '\(',
99 | ')' => '\)',
100 | ']' => '\]',
101 | '[' => '\[',
102 | ]
103 | );
104 |
105 | $event = new \Bitrix\Main\Event(
106 | $this->MODULE_ID,
107 | "OnBeforeResizeImageSvg",
108 | [&$strFilePath, &$params]
109 | );
110 | $event->send();
111 |
112 | $strCommand = '';
113 |
114 | exec(
115 | "{$this->pathNodejs}/node {$this->path}/{$this->binaryName} $strCommand --input=$strFilePath --output=$strFilePath 2>&1",
116 | $res
117 | );
118 |
119 | // if(file_exists($strFilePathNew)) {
120 | // unlink($strFilePath);
121 | // rename($strFilePathNew, $strFilePath);
122 | // }
123 |
124 | if (!empty($params['changeChmod'])) {
125 | chmod($strFilePath, $params['changeChmod']);
126 | }
127 | $event = new \Bitrix\Main\Event(
128 | $this->MODULE_ID,
129 | "OnAfterResize",
130 | [&$strFilePath]
131 | );
132 | $event->send();
133 | return true;
134 | }
135 |
136 | public function getOptionsSettings($advanceSettings=[])
137 | {
138 | return [];
139 | }
140 | }
--------------------------------------------------------------------------------
/win1251/dev2fun.imagecompress/lib/script.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author darkfriend
3 | * @version 0.11.5
4 | */
5 | function SendPropcess(step, type) {
6 | let objRequest = {
7 | AJAX_IC: 'Y',
8 | PAGEN_1: step,
9 | };
10 | let wrapId = 'compressAllStatus';
11 | switch (type) {
12 | case 'convert':
13 | objRequest.convert_all = 'Y';
14 | wrapId = 'convertAllStatus';
15 | break;
16 | default:
17 | objRequest.compress_all = 'Y';
18 | }
19 | BX.ajax({
20 | url: window.location.pathname + window.location.search,
21 | data: objRequest,
22 | method: 'POST',
23 | timeout: 600,
24 | dataType: 'json',
25 | cache: false,
26 | onsuccess: function (data) {
27 | BX(wrapId).innerHTML = data.html;
28 | data.step = parseInt(data.step);
29 | data.allStep = parseInt(data.allStep);
30 | if (
31 | data.step > 0
32 | && data.step <= data.allStep
33 | && !data.error
34 | ) {
35 | SendPropcess(data.step, type);
36 | } else {
37 | BX.closeWait(wrapId);
38 | }
39 | if (data.step > data.allStep || !(data.step > 0)) {
40 | window.location.href = window.location.pathname + '?process_result=Y&status=success';
41 | }
42 | },
43 | onfailure: function () {
44 | BX.closeWait(wrapId);
45 | BX(wrapId).innerHTML = 'Error!';
46 | }
47 | });
48 | }
49 |
50 | function SearchPictures() {
51 | let objRequest = {
52 | AJAX_IC: 'Y',
53 | action: 'searchPicture',
54 | };
55 | let wrapId = '';
56 | BX.showWait();
57 | BX.ajax({
58 | url: window.location.pathname + window.location.search,
59 | data: objRequest,
60 | method: 'POST',
61 | timeout: 600,
62 | dataType: 'json',
63 | cache: false,
64 | onsuccess: function (data) {
65 | BX.closeWait();
66 | if (data.success) {
67 | window.location.href = window.location.pathname + '?process_search_result=Y&status=success';
68 | } else {
69 | let err = data.msg ? data.msg : 'Unknow error!'
70 | BX(wrapId).innerHTML = 'Error! ' + err;
71 | }
72 | },
73 | onfailure: function () {
74 | BX.closeWait();
75 | BX(wrapId).innerHTML = 'Error!';
76 | }
77 | });
78 | }
--------------------------------------------------------------------------------