From 47271d9413af15a221bb8f52b712368b2c7a337c Mon Sep 17 00:00:00 2001 From: Bellord Date: Wed, 3 Jun 2026 11:11:05 +0300 Subject: [PATCH] fix --- .module.json | 2 +- admin/main/lang/ru/config.php | 2 +- .../submenu/nullable_table/lang/ru/index.php | 2 +- .../nullable_table/submenu/row/index.php | 3 - .../submenu/row/lang/ru/config.php | 2 +- admin/main/submenu/settings/lang/ru/index.php | 2 +- clone.php | 2 + clone.php.bkp | 122 ++++++++++++++++++ readme.md | 2 +- 9 files changed, 130 insertions(+), 9 deletions(-) create mode 100644 clone.php.bkp diff --git a/.module.json b/.module.json index fb2614b..1244823 100644 --- a/.module.json +++ b/.module.json @@ -4,6 +4,6 @@ "namespace": "Bx\\Nullable", "gitUrl": "https://bitbucket.org/bellord13/bx.null/", "version": "1.0.0", - "date": "2025-01-01 00:00:00", + "date": "2026-01-01 00:00:00", "deps": ["wt.core"] } \ No newline at end of file diff --git a/admin/main/lang/ru/config.php b/admin/main/lang/ru/config.php index a9f0ebd..9532459 100644 --- a/admin/main/lang/ru/config.php +++ b/admin/main/lang/ru/config.php @@ -1,2 +1,2 @@ -checkPermission(); $AdminPageTableRow->start(); -\CJSCore::Init('jquery'); - require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin.php'); \ No newline at end of file diff --git a/admin/main/submenu/nullable_table/submenu/row/lang/ru/config.php b/admin/main/submenu/nullable_table/submenu/row/lang/ru/config.php index a9f0ebd..9532459 100644 --- a/admin/main/submenu/nullable_table/submenu/row/lang/ru/config.php +++ b/admin/main/submenu/nullable_table/submenu/row/lang/ru/config.php @@ -1,2 +1,2 @@ -getPath(), $newEntity->getPath(), true, true, '/\.module\.json/', '/clone\.php/', '/readme\.md/', + '/src\/\.env$/', + '/src\/config\.php$/', ], function ($d1, &$d2) use ($nullableEntity, $newEntity){ $lastModuleName = collect(explode('.', $newEntity->fields()->id))->last(); $lastNullableModuleName = collect(explode('.', $nullableEntity->fields()->id))->last(); diff --git a/clone.php.bkp b/clone.php.bkp new file mode 100644 index 0000000..adf9e43 --- /dev/null +++ b/clone.php.bkp @@ -0,0 +1,122 @@ +read() ) ) { + if ( $entry != '.' && $entry != '..' ) + copy_folder_safe( "$d1/$entry", "$d2/$entry", $upd, $force, $exclude, $handler); + } + $d->close(); + } + else { + $ok = copy_safe( $d1, $d2, $upd ); + } +} + +function mkdir_safe( $dir, $force ) { + if (file_exists($dir)) { + if (is_dir($dir)) return $dir; + elseif (!$force) return false; + unlink($dir); + } + return (mkdir($dir, 0777, true)) ? $dir : false; +} + +function copy_safe ($f1, $f2, $upd) { + $time1 = filemtime($f1); + if (file_exists($f2)) { + $time2 = filemtime($f2); + if ($time2 >= $time1 && $upd) return false; + } + $ok = copy($f1, $f2); + if ($ok) touch($f2, $time1); + return $ok; +} + +function fs_log($str) { + return; + $log = fopen('./fs_log.txt', 'a'); + $time = date('Y-m-d H:i:s'); + fwrite($log, "$str ($time)\n"); + fclose($log); +} + +function _fix(ModuleEntity $newEntity, ModuleEntity $nullableEntity){ + $d = new RecursiveDirectoryIterator( $newEntity->getPath() ); + foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){ + if( is_file( $path ) && str_ends_with($path, '.php')){ + $orig_file = file_get_contents($path); + + $new_file = $orig_file; + $cr = 0; + $new_file = str_replace($nullableEntity->getLangPrefix(), $newEntity->getLangPrefix(), $new_file, $cr); + $new_file = str_replace($nullableEntity->getId(), $newEntity->getId(), $new_file, $cr); + $new_file = str_replace($nullableEntity->getPrefix(), $newEntity->getPrefix(), $new_file, $cr); + $new_file = str_replace($nullableEntity->getNamespace(), $newEntity->getNamespace(), $new_file, $cr); + + $new_file = str_replace( + ucfirst($nullableEntity->getProductCode()) . ': ' . ucfirst($nullableEntity->getProductCode()), + ucfirst($newEntity->getProductCode()) . ': ' . ucfirst($newEntity->getProductCode()), + $new_file, + $cr + ); + + $new_file = str_replace(ucfirst($nullableEntity->getProductCode()), ucfirst($newEntity->getProductCode()), $new_file, $cr); + $new_file = str_replace(ucfirst($nullableEntity->getCompanyCode()), ucfirst($newEntity->getCompanyCode()), $new_file, $cr); + $new_file = str_replace($nullableEntity->getProductCode(), $newEntity->getProductCode(), $new_file, $cr); + $new_file = str_replace($nullableEntity->getCompanyCode(), $newEntity->getCompanyCode(), $new_file, $cr); + + + + echo $cr . ' ' .$path . PHP_EOL; + + if($orig_file != $new_file){ + file_put_contents($path, $new_file); + } + } + } +} + +echo $newEntity->getId() . PHP_EOL; + + +copy_folder_safe($nullableEntity->getPath(), $newEntity->getPath(), true, true, [ + '/\.git$/', + '/\.module\.json/', + '/clone\.php/', + '/readme\.md/', + '/src\/\.env$/', + '/src\/config\.php$/', +], function ($d1, &$d2) use ($nullableEntity, $newEntity){ + $lastModuleName = collect(explode('.', $newEntity->fields()->id))->last(); + $lastNullableModuleName = collect(explode('.', $nullableEntity->fields()->id))->last(); + + + $d2 = str_replace(ucfirst($lastNullableModuleName), ucfirst($lastModuleName), $d2, $cr); + $d2 = str_replace(strtolower($lastNullableModuleName), strtolower($lastModuleName), $d2, $cr); +}); + +_fix($newEntity, $nullableEntity); diff --git a/readme.md b/readme.md index c360687..cbbf964 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,3 @@ 1) создаем папку с модулем 2) копируем и конфигурируем файл .module.json -3) запускаем php -f clone.php ./path_to_new_module \ No newline at end of file +3) запускаем php -f clone.php ../path_to_new_module \ No newline at end of file