Skip to content

Commit

Permalink
v3.6.4
Browse files Browse the repository at this point in the history
- use iterator instead of arrays
- fix card move btn
  • Loading branch information
ctf0 committed Dec 11, 2019
1 parent d5bae67 commit e609444
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 36 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"php": "~7.0",
"illuminate/support": "^5.4 || ^6.0",
"maennchen/zipstream-php": "~1.0",
"ctf0/package-changelog": "*"
"ctf0/package-changelog": "*",
"jhofm/flysystem-iterator": "^2.2"
},
"suggest": {
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (~1.0)."
Expand Down
4 changes: 2 additions & 2 deletions src/App/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace ctf0\MediaManager\App\Controllers;

use App\Http\Controllers\Controller;
use League\Flysystem\Plugin\ListWith;
use Jhofm\FlysystemIterator\Plugin\IteratorPlugin;
use ctf0\MediaManager\App\Controllers\Moduels\Lock;
use ctf0\MediaManager\App\Controllers\Moduels\Move;
use ctf0\MediaManager\App\Controllers\Moduels\Utils;
Expand Down Expand Up @@ -64,7 +64,7 @@ public function __construct()
->connection($config['database_connection'] ?? 'mediamanager')
->table($config['table_locked'] ?? 'locked');

$this->storageDisk->addPlugin(new ListWith());
$this->storageDisk->addPlugin(new IteratorPlugin());
}

/**
Expand Down
65 changes: 34 additions & 31 deletions src/App/Controllers/Modules/GetContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,41 +54,37 @@ protected function getData($dir)
$path = $folder['path'];
$time = $folder['timestamp'];

if (!preg_grep($pattern, [$path])) {
if ($this->GFI) {
$info = $this->getFolderInfoFromList($this->getFolderContent($path, true));
}

$list[] = [
'name' => $folder['basename'],
'type' => 'folder',
'path' => $this->resolveUrl($path),
'storage_path' => $path,
'size' => isset($info) ? $info['size'] : 0,
'count' => isset($info) ? $info['count'] : 0,
'last_modified' => $time,
'last_modified_formated' => $this->getItemTime($time),
];
if ($this->GFI) {
$info = $this->getFolderInfoFromList($this->getFolderContent($path, true));
}

$list[] = [
'name' => $folder['basename'],
'type' => 'folder',
'path' => $this->resolveUrl($path),
'storage_path' => $path,
'size' => isset($info) ? $info['size'] : 0,
'count' => isset($info) ? $info['count'] : 0,
'last_modified' => $time,
'last_modified_formated' => $this->getItemTime($time),
];
}

// files
foreach ($storageFiles as $file) {
$path = $file['path'];
$time = $file['timestamp'];

if (!preg_grep($pattern, [$path])) {
$list[] = [
'name' => $file['basename'],
'type' => $file['mimetype'],
'path' => $this->resolveUrl($path),
'storage_path' => $path,
'size' => $file['size'],
'visibility' => $file['visibility'],
'last_modified' => $time,
'last_modified_formated' => $this->getItemTime($time),
];
}
$list[] = [
'name' => $file['basename'],
'type' => $file['mimetype'],
'path' => $this->resolveUrl($path),
'storage_path' => $path,
'size' => $file['size'],
'visibility' => $file['visibility'],
'last_modified' => $time,
'last_modified_formated' => $this->getItemTime($time),
];
}

return $list;
Expand All @@ -102,10 +98,17 @@ protected function getData($dir)
*/
protected function getFolderContent($folder, $rec = false)
{
return $this->storageDisk->listWith(
['mimetype', 'visibility', 'timestamp', 'size'],
$folder,
$rec
$pattern = $this->ignoreFiles;

return $this->storageDisk->createIterator(
[
'list-with' => ['mimetype', 'visibility', 'timestamp', 'size'],
'recursive' => $rec,
'filter' => function ($item) use ($pattern) {
return !preg_grep($pattern, [$item['basename']]);
},
],
$folder ?: '/'
);
}

Expand Down
6 changes: 4 additions & 2 deletions src/resources/views/partials/card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ class="icon is-large link"
<div class="card-footer-item">
<button class="button btn-plain is-fullwidth"
:disabled="ops_btn_disable"
@click.stop="moveItem()">
@click.stop="addToMovableList()">
<span class="icon is-small"><icon name="share"></icon></span>
<span>{{ trans('MediaManager::messages.move.main') }}</span>

<span v-if="inMovableList()">{{ trans('MediaManager::messages.add.added') }}</span>
<span v-else>{{ trans('MediaManager::messages.add.list') }}</span>
</button>
</div>

Expand Down

0 comments on commit e609444

Please sign in to comment.