diff --git a/composer.lock b/composer.lock index e496d497b6..a3e729a696 100644 --- a/composer.lock +++ b/composer.lock @@ -752,16 +752,16 @@ }, { "name": "laminas/laminas-diactoros", - "version": "3.3.0", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "4db52734837c60259c9b2d7caf08eef8f7f9b9ac" + "reference": "74cfb9a7522ffd2a161d1ebe10db2fc2abb9df45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/4db52734837c60259c9b2d7caf08eef8f7f9b9ac", - "reference": "4db52734837c60259c9b2d7caf08eef8f7f9b9ac", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/74cfb9a7522ffd2a161d1ebe10db2fc2abb9df45", + "reference": "74cfb9a7522ffd2a161d1ebe10db2fc2abb9df45", "shasum": "" }, "require": { @@ -781,9 +781,9 @@ "http-interop/http-factory-tests": "^0.9.0", "laminas/laminas-coding-standard": "~2.5.0", "php-http/psr7-integration-tests": "^1.3", - "phpunit/phpunit": "^9.5.28", + "phpunit/phpunit": "^9.6.16", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.15.0" + "vimeo/psalm": "^5.22.1" }, "type": "library", "extra": { @@ -833,7 +833,7 @@ "type": "community_bridge" } ], - "time": "2023-10-26T11:01:07+00:00" + "time": "2024-02-16T16:06:16+00:00" }, { "name": "laminas/laminas-httphandlerrunner", @@ -5546,16 +5546,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.1", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", "shasum": "" }, "require": { @@ -5622,7 +5622,7 @@ "type": "open_collective" } ], - "time": "2024-01-11T20:47:48+00:00" + "time": "2024-02-16T15:06:51+00:00" }, { "name": "symfony/finder", diff --git a/composer_installer.php b/composer_installer.php index 6d6d371e16..bfbbe50c4d 100644 --- a/composer_installer.php +++ b/composer_installer.php @@ -50,6 +50,7 @@ function whichPhp() function command($phpPath) { + $phpPath = escapeshellarg($phpPath); if (!$phpPath) $phpPath = 'php'; if (!is_writable(ROOT_DIR . 'composer')) { throw new Exception('/composer に書き込み権限がありません。書き込み権限を与えてください。'); diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php index a6dff8317b..7506441d13 100644 --- a/plugins/baser-core/src/Model/Table/ContentsTable.php +++ b/plugins/baser-core/src/Model/Table/ContentsTable.php @@ -1288,7 +1288,7 @@ public function updateChildrenUrl($id) if ($children) { foreach($children as $child) { // サイト全体を更新する為、サイト規模によってはかなり時間がかかる為、SQLを利用 - $connection->update('contents', ['url' => $this->createUrl($child->id)], ['id' => $child->id]); + $connection->update($this->getTable(), ['url' => $this->createUrl($child->id)], ['id' => $child->id]); } } return true; diff --git a/plugins/baser-core/src/Plugin.php b/plugins/baser-core/src/Plugin.php index 74f2404f6e..a46bc2241f 100644 --- a/plugins/baser-core/src/Plugin.php +++ b/plugins/baser-core/src/Plugin.php @@ -210,10 +210,14 @@ public function addTheme(PluginApplicationInterface $application) foreach($sites as $site) { if ($site->theme) { BcUtil::includePluginClass($site->theme); - $application->addPlugin($site->theme); - $pluginPath = CorePlugin::path($site->theme) . 'plugins' . DS; - if(!is_dir($pluginPath)) continue; - $path[] = $pluginPath; + try { + $application->addPlugin($site->theme); + $pluginPath = CorePlugin::path($site->theme) . 'plugins' . DS; + if (!is_dir($pluginPath)) continue; + $path[] = $pluginPath; + } catch (MissingPluginException $e) { + $this->log($e->getMessage()); + } } } // テーマプラグインを追加 diff --git a/plugins/baser-core/src/Utility/BcFolder.php b/plugins/baser-core/src/Utility/BcFolder.php index a7e5500182..57b474dadd 100644 --- a/plugins/baser-core/src/Utility/BcFolder.php +++ b/plugins/baser-core/src/Utility/BcFolder.php @@ -84,7 +84,7 @@ public function create(int $mask = 0777) $parent = dirname($path); if (!is_dir($parent)) { $this->path = $parent; - if($this->create($mask)) { + if ($this->create($mask)) { $this->path = $path; } else { $this->path = $path; @@ -113,7 +113,7 @@ public function getFiles(array $options = []) ], $options); $files = []; $dir = new \DirectoryIterator($this->path); - foreach ($dir as $fileInfo) { + foreach($dir as $fileInfo) { $filename = $fileInfo->getFilename(); if ($fileInfo->isFile() && !in_array($filename, $options['exclude'])) { $files[] = $options['full']? $fileInfo->getPathname() : $fileInfo->getFilename();; @@ -140,7 +140,7 @@ public function getFolders(array $options = []) $folders = []; $dir = new \DirectoryIterator($this->path); /** @var $fileInfo \SplFileInfo */ - foreach ($dir as $fileInfo) { + foreach($dir as $fileInfo) { $filename = $fileInfo->getFilename(); if ($fileInfo->isDir() && !$fileInfo->isDot() && !in_array($filename, $options['exclude'])) { $folders[] = $options['full']? $fileInfo->getPathname() : $fileInfo->getFilename(); @@ -160,12 +160,12 @@ public function delete() { if (!is_dir($this->path)) return false; $files = $this->getFiles(['full' => true]); - foreach ($files as $file) { + foreach($files as $file) { unlink($file); } $folders = $this->getFolders(['full' => true]); $path = $this->path; - foreach ($folders as $folder) { + foreach($folders as $folder) { $this->path = $folder; $this->delete(); } @@ -180,28 +180,31 @@ public function delete() * @noTodo * @unitTest */ - public function copy($dest): bool + public function copy($dest, $mode = 0777): bool { - $source=$this->path; + $source = $this->path; if (!is_dir($source)) return false; - if(is_dir($source)) { - $dir_handle=opendir($source); - if(!file_exists($dest)){ - mkdir($dest); + if (is_dir($source)) { + $dir_handle = opendir($source); + if (!file_exists($dest)) { + (new BcFolder($dest))->create(); + chmod($dest, $mode); } - while($file=readdir($dir_handle)){ - if($file!="." && $file!=".."){ - if(is_dir($source."/".$file)){ - $this->path = $source .DS. $file; - self::copy( $dest .DS. $file); + while($file = readdir($dir_handle)) { + if ($file != "." && $file != "..") { + if (is_dir($source . "/" . $file)) { + $this->path = $source . DS . $file; + self::copy($dest . DS . $file); } else { - copy($source."/".$file, $dest."/".$file); + copy($source . "/" . $file, $dest . "/" . $file); + chmod($dest . "/" . $file, $mode); } } } closedir($dir_handle); } else { copy($source, $dest); + chmod($dest, $mode); } return true; } @@ -249,8 +252,8 @@ public function chmod(?int $mode = null, bool $recursive = true, array $exceptio if (is_dir($path)) { $paths = $this->tree($path); - foreach ($paths as $type) { - foreach ($type as $fullpath) { + foreach($paths as $type) { + foreach($type as $fullpath) { $check = explode(DIRECTORY_SEPARATOR, $fullpath); $count = count($check); @@ -321,7 +324,7 @@ public function tree(?string $path = null, $exceptions = false, ?string $type = * @var string $itemPath * @var RecursiveDirectoryIterator $fsIterator */ - foreach ($iterator as $itemPath => $fsIterator) { + foreach($iterator as $itemPath => $fsIterator) { if ($skipHidden) { $subPathName = $fsIterator->getSubPathname(); if ($subPathName[0] === '.' || str_contains($subPathName, DIRECTORY_SEPARATOR . '.')) { diff --git a/plugins/baser-core/src/View/Helper/BcFormHelper.php b/plugins/baser-core/src/View/Helper/BcFormHelper.php index a5a00c4ff3..682e172681 100644 --- a/plugins/baser-core/src/View/Helper/BcFormHelper.php +++ b/plugins/baser-core/src/View/Helper/BcFormHelper.php @@ -865,7 +865,9 @@ public function file($fieldName, $options = []): string // PHP5.3対応のため、is_string($value) 判別を実行 $delCheckTag = ''; - if ($fileLinkTag && $linkOptions['delCheck'] && (is_string($value) || empty($value['session_key']))) { + if ($fileLinkTag && $linkOptions['delCheck'] && (is_string($value) || + (is_array($value) && empty($value['session_key'])) || + (is_object($value) && $value->getError() == UPLOAD_ERR_NO_FILE))) { $delCheckTag = $this->Html->tag('span', $this->checkbox($fieldName . '_delete', $deleteCheckboxOptions) . $this->label($fieldName . '_delete', __d('baser_core', '削除する'), $deleteLabelOptions), $deleteSpanOptions); } $hiddenValue = $this->getSourceValue($fieldName . '_'); @@ -873,10 +875,10 @@ public function file($fieldName, $options = []): string $hiddenTag = ''; if ($fileLinkTag) { - if (is_array($fileValue) && empty($fileValue['tmp_name']) && $hiddenValue) { + if (is_object($fileValue) && empty($fileValue->getClientFileName()) && $hiddenValue) { $hiddenTag = $this->hidden($fieldName . '_', ['value' => $hiddenValue]); } else { - if (is_array($fileValue)) { + if (is_array($fileValue) || is_object($fileValue)) { $fileValue = null; } $hiddenTag = $this->hidden($fieldName . '_', ['value' => $fileValue]); diff --git a/plugins/bc-admin-third/src/bc_blog/js/admin/blog_posts/form.js b/plugins/bc-admin-third/src/bc_blog/js/admin/blog_posts/form.js index b865c7a42b..b6e3f55112 100755 --- a/plugins/bc-admin-third/src/bc_blog/js/admin/blog_posts/form.js +++ b/plugins/bc-admin-third/src/bc_blog/js/admin/blog_posts/form.js @@ -51,8 +51,8 @@ $(function () { } else { previewurl += '?url=' + fullUrl + '&preview=' + previewMode; } - if (typeof $.bcCkeditor.editor['editor_detail_tmp'] !== undefined) { - $.bcCkeditor.editor['editor_detail_tmp'].execCommand('synchronize'); + if (typeof $.bcCkeditor.editor.editor_contents_tmp !== "undefined") { + $.bcCkeditor.editor.editor_contents_tmp.execCommand('synchronize'); } form.attr('target', 'preview'); form.attr('action', previewurl); @@ -70,8 +70,8 @@ $(function () { */ $("#BtnSave").click(function () { $.bcUtil.showLoader(); - if (typeof $.bcCkeditor.editor['editor_detail_tmp'] !== undefined) { - $.bcCkeditor.editor['editor_detail_tmp'].execCommand('synchronize'); + if (typeof $.bcCkeditor.editor.editor_contents_tmp !== "undefined") { + $.bcCkeditor.editor.editor_contents_tmp.execCommand('synchronize'); } $("#BlogPostMode").val('save'); $.bcToken.check(function () { diff --git a/plugins/bc-admin-third/src/css/components/_section.scss b/plugins/bc-admin-third/src/css/components/_section.scss index a9604b003f..8d97c939f3 100644 --- a/plugins/bc-admin-third/src/css/components/_section.scss +++ b/plugins/bc-admin-third/src/css/components/_section.scss @@ -1,4 +1,5 @@ .bca-section { + margin-bottom: 20px; &__post-detail { margin-bottom: 1.5em; } @@ -56,4 +57,4 @@ &[data-bca-section-type=form-group] { margin-bottom: 60px; } -} \ No newline at end of file +} diff --git a/plugins/bc-admin-third/src/js/admin/sites/form.js b/plugins/bc-admin-third/src/js/admin/sites/form.js index b95cc5d183..f3fa389c3c 100644 --- a/plugins/bc-admin-third/src/js/admin/sites/form.js +++ b/plugins/bc-admin-third/src/js/admin/sites/form.js @@ -9,13 +9,49 @@ */ /** - * サイト編集 + * sites form */ +const sitesForm = { -$(function () { - var alias = $("#alias").val(); - $("#BtnSave").click(function () { - if (alias && alias != $("#alias").val()) { + /** + * 現在のエイリアス + */ + currentAlias : '', + + /** + * 初期化 + */ + mounted() { + this.initView(); + this.alias = $("#alias").val() + }, + + /** + * 表示初期化 + */ + initView() { + this.registerEvents(); + this.loadDeviceAndLang(); + this.changeUseDomain(); + }, + + /** + * イベント登録 + */ + registerEvents() { + $("#BtnSave").click(this.save); + $("#main-site-id").change(this.loadDeviceAndLang); + $("#device, #lang").change(this.loadOptions); + $('input[name="same_main_url"]').click(this.loadOptions); + $("input[name='use_subdomain']").click(this.changeUseDomain); + }, + + /** + * 保存 + * @returns {boolean} + */ + save() { + if (sitesForm.alias && sitesForm.alias !== $("#alias").val()) { $.bcConfirm.show({ 'title': bcI18n.confirmTitle1, 'message': bcI18n.confirmMessage2, @@ -27,76 +63,90 @@ $(function () { return false; } $.bcUtil.showLoader(); - }); - - $("#main-site-id").change(loadDeviceAndLang); - $("#device, #lang").change(loadOptions); - $('input[name="same_main_url"]').click(loadOptions); - - loadDeviceAndLang(); + }, /** * デバイスと言語の表示設定 */ - function loadDeviceAndLang() { - var currentId = $("#id").val(); - var mainSiteId = $("#main-site-id").val(); - if(mainSiteId === undefined) { + loadDeviceAndLang() { + let currentId = $("#id").val(); + let mainSiteId = $("#main-site-id").val(); + if (mainSiteId === undefined) { mainSiteId = 1; } - var url = $.bcUtil.apiAdminBaseUrl + 'baser-core/sites/get_selectable_devices_and_lang/' + mainSiteId; - if(currentId !== undefined) { + let url = $.bcUtil.apiAdminBaseUrl + 'baser-core/sites/get_selectable_devices_and_lang/' + mainSiteId; + if (currentId !== undefined) { url += '/' + currentId; } url += '.json'; $.bcUtil.ajax(url, function (result) { - var selectDevice = $("#device"); - var selectLang = $("#lang"); - var device = selectDevice.val(); - var lang = selectLang.val(); - selectDevice.find('option').remove(); - selectLang.find('option').remove(); + const $selectDevice = $("#device"); + const $selectLang = $("#lang"); + let device = $selectDevice.val(); + let lang = $selectLang.val(); + $selectDevice.find('option').remove(); + $selectLang.find('option').remove(); result = $.parseJSON(result); $.each(result.devices, function (value, name) { - selectDevice.append($('