Skip to content

Commit

Permalink
Merge branch 'dev-#2773' of github.com:baserproject/basercms into dev-#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Oct 9, 2023
2 parents c800c80 + 6d0e862 commit 1ed9f35
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
17 changes: 7 additions & 10 deletions plugins/baser-core/src/Utility/BcFileUploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
namespace BaserCore\Utility;

use ArrayObject;
use Cake\Filesystem\File;
use Cake\Http\Session;
use Cake\ORM\Entity;
use Cake\ORM\Table;
use Cake\Routing\Router;
use Cake\Utility\Hash;
use Cake\Filesystem\File;
use Cake\Filesystem\Folder;
use BaserCore\Vendor\Imageresizer;
use Cake\Datasource\EntityInterface;
use BaserCore\Annotation\Note;
Expand Down Expand Up @@ -116,9 +115,8 @@ public function initialize(array $config, $table): void
$this->settings = $this->getSettings($config);
$this->savePath = $this->getSaveDir();
if (!is_dir($this->savePath)) {
$Folder = new Folder();
$Folder->create($this->savePath);
$Folder->chmod($this->savePath, 0777, true);
$Folder = new BcFolder($this->savePath);
$Folder->create();
}
$this->existsCheckDirs = $this->getExistsCheckDirs();
$this->Session = new Session();
Expand Down Expand Up @@ -466,9 +464,9 @@ public function moveFileSessionToTmp($data, $fieldName)
}

// ファイルを一時ファイルとして保存
$file = new File($tmpName, true, 0666);
$file = new BcFile($tmpName);
$file->create();
$file->write($fileData);
$file->close();

// アップロードされたデータとしてデータを復元する
$uploadInfo['error'] = 0;
Expand Down Expand Up @@ -784,9 +782,8 @@ public function getFieldBasename($setting, $file, $entity)
$subdir = str_replace('/', DS, $subdir);
$path = $this->savePath . $subdir;
if (!is_dir($path)) {
$Folder = new Folder();
$Folder->create($path);
$Folder->chmod($path, 0777);
$Folder = new BcFolder($path);
$Folder->create();
}
}
if(empty($file['ext'])) {
Expand Down
10 changes: 5 additions & 5 deletions plugins/baser-core/src/View/BcFrontAppView.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace BaserCore\View;

use BaserCore\Utility\BcFolder;
use BaserCore\Utility\BcUtil;
use BaserCore\View\Helper\BcTextHelper;
use Cake\Core\Configure;
Expand All @@ -19,7 +20,6 @@
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\Note;
use Cake\Core\Plugin;
use Cake\Filesystem\Folder;
use Cake\Utility\Inflector;

/**
Expand Down Expand Up @@ -61,11 +61,11 @@ protected function setThemeHelpers(): void
$theme = BcUtil::getCurrentTheme();
if(!$theme) return;
$themeHelpersPath = Plugin::path($theme) . 'src' . DS . 'View' . DS . 'Helper';
$Folder = new Folder($themeHelpersPath);
$files = $Folder->read(true, true);
if (empty($files[1])) return;
$Folder = new BcFolder($themeHelpersPath);
$files = $Folder->getFiles();
if (empty($files)) return;

foreach($files[1] as $file) {
foreach($files as $file) {
$this->loadHelper(Inflector::camelize($theme, '-') . '.' . basename($file, 'Helper.php'));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

use ArrayObject;
use BaserCore\Model\Entity\Content;
use BaserCore\Utility\BcFile;
use BaserCore\Utility\BcFileUploader;
use Cake\ORM\Entity;
use ReflectionClass;
use Cake\Filesystem\File;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
use BaserCore\Model\Table\ContentsTable;
Expand Down Expand Up @@ -507,9 +507,9 @@ public function testMoveFileSessionToTmp()
$this->uploadedData['eyecatch']['ext'] = $ext;

// ダミーファイルの作成
$file = new File($tmpPath);
$file = new BcFile($tmpPath);
$file->create();
$file->write('dummy');
$file->close();

// セッションを設定
$entity = $this->BcFileUploader->saveTmpFiles($this->uploadedData, $tmpId);
Expand Down

0 comments on commit 1ed9f35

Please sign in to comment.