Skip to content

Commit 5033904

Browse files
committed
FIXES AND IMPROVEMENTS
Fix errors on Media Manager component in windows platform regarding directory separators..
1 parent a5758bc commit 5033904

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

src/Darryldecode/Backend/Base/Registrar/Registrar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Registrar {
1313
/**
1414
* the laravel backend version
1515
*/
16-
const VERSION = '1.0.26';
16+
const VERSION = '1.0.27';
1717
const VERSION_NAME = 'Alpha';
1818

1919
/**

src/Darryldecode/Backend/Components/MediaManager/Commands/ListCommand.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct($path = null, $disablePermissionChecking = false)
3939
*/
4040
public function handle(Filesystem $filesystem, Repository $config)
4141
{
42-
$path = (is_null($this->path)) ? '/' : $this->path;
42+
$path = (is_null($this->path)) ? DIRECTORY_SEPARATOR : $this->path;
4343

4444
$response = [];
4545
$response['files'] = $filesystem->files($path);
@@ -73,10 +73,9 @@ protected function isResultIsEmpty($files, $directories)
7373
*/
7474
protected function breakDownPath($path)
7575
{
76-
7776
if( $path == '/' ) return array('/');
7877

79-
$paths = explode('/',trim($path,'/'));
78+
$paths = explode(DIRECTORY_SEPARATOR,trim($path,'/'));
8079

8180
array_unshift($paths, '/');
8281

src/Darryldecode/Backend/Components/MediaManager/Commands/UploadCommand.php

+22-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ public function __construct($files = null, $path = null, $disablePermissionCheck
4242
/**
4343
* @param Repository $config
4444
* @param Image $image
45+
* @param Filesystem $filesystem
4546
* @return CommandResult
4647
*/
47-
public function handle(Repository $config,Image $image)
48+
public function handle(Repository $config,Image $image,Filesystem $filesystem)
4849
{
4950
// check if user has permission
5051
if( ! $this->disablePermissionChecking )
@@ -65,11 +66,11 @@ public function handle(Repository $config,Image $image)
6566

6667
// save the file
6768
$file->move(
68-
$config->get('filesystems.disks.local.root').'/'.$this->normalizePath($path),
69+
$this->getCurrentFullPath($config,$path),
6970
$normalizedFileName
7071
);
7172

72-
$filePath = $config->get('filesystems.disks.local.root').'/'.$this->normalizePath($path).'/'.$normalizedFileName;
73+
$filePath = $this->getCurrentFullPath($config,$path).$normalizedFileName;
7374
$file_name = pathinfo($filePath, PATHINFO_FILENAME);
7475
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
7576

@@ -80,11 +81,18 @@ public function handle(Repository $config,Image $image)
8081
{
8182
foreach($sizes as $key => $dimension)
8283
{
84+
$targetDir = $this->getCurrentFullPath($config,$path).$key.DIRECTORY_SEPARATOR;
85+
86+
if( ! $filesystem->exists($targetDir) )
87+
{
88+
$filesystem->makeDirectory($this->normalizePath($path).DIRECTORY_SEPARATOR.$key.DIRECTORY_SEPARATOR);
89+
}
90+
8391
$image::createThumbnail(
8492
$filePath,
8593
$dimension[0],
8694
$dimension[1],
87-
$config->get('filesystems.disks.local.root').'/'.$this->normalizePath($path).'/'.$this->produceThumbFileName($file_name,$key,$extension)
95+
$targetDir.$file_name.'.'.$extension
8896
);
8997
}
9098
}
@@ -121,6 +129,16 @@ protected function produceThumbFileName($file_name, $file_size_name, $file_exten
121129
return $file_name.'_'.$file_size_name.'.'.$file_extension;
122130
}
123131

132+
/**
133+
* @param Repository $config
134+
* @param string $path
135+
* @return string
136+
*/
137+
protected function getCurrentFullPath($config, $path)
138+
{
139+
return $config->get('filesystems.disks.local.root').DIRECTORY_SEPARATOR.$this->normalizePath($path).DIRECTORY_SEPARATOR;
140+
}
141+
124142
/**
125143
* when uploading a file, we will remove dashes because dashes are use in UI as size convention
126144
*

src/Darryldecode/Backend/Components/MediaManager/Views/mediaManager.blade.php

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
</div>
5959
<div data-ng-repeat="f in files.files" class="col-lg-2 col-md-2 col-sm-4">
6060
<div class="file-thumb">
61-
<label class="label label-info pull-left label-file-size">Size: @{{::getSizeName(f)}}</label>
6261
<file-preview file-source="@{{f}}"></file-preview>
6362
<div class="text-wrap meta-data-holder trim-info-xs">
6463
<a href="" data-toggle="tooltip" data-placement="bottom" title="@{{f}}" class="file-name">@{{::getLastSegment(f)}}</a>

0 commit comments

Comments
 (0)