Skip to content

Commit 98a9584

Browse files
committed
working file mgmnt/display
1 parent 09920b0 commit 98a9584

File tree

2 files changed

+130
-1
lines changed

2 files changed

+130
-1
lines changed

src/controllers/ItemsController.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,58 @@ function __construct()
3737

3838
public function getFiles()
3939
{
40-
return "List of files";
40+
if (Input::has('base'))
41+
{
42+
$files = File::files(base_path($this->file_location . Input::get('base')));
43+
$all_directories = File::directories(base_path($this->file_location . Input::get('base')));
44+
} else
45+
{
46+
$files = File::files(base_path($this->file_location));
47+
$all_directories = File::directories(base_path($this->file_location));
48+
}
49+
50+
$directories = [];
51+
52+
foreach ($all_directories as $directory)
53+
{
54+
$directories[] = basename($directory);
55+
}
56+
57+
$file_info = [];
58+
59+
foreach ($files as $file)
60+
{
61+
$file_name = $file;
62+
$file_size = 1;
63+
64+
$file_created = filemtime($file);
65+
$file_type = '';
66+
$file_info[] = [
67+
'name' => $file_name,
68+
'size' => $file_size,
69+
'created' => $file_created,
70+
'type' => $file_type,
71+
'icon' => 'fa-file-archive-o'
72+
];
73+
}
74+
75+
76+
if (Input::get('show_list') == 1)
77+
{
78+
return View::make('laravel-filemanager::files-list')
79+
->with('directories', $directories)
80+
->with('base', Input::get('base'))
81+
->with('file_info', $file_info)
82+
->with('dir_location', $this->file_location);
83+
} else
84+
{
85+
return View::make('laravel-filemanager::files')
86+
->with('files', $files)
87+
->with('directories', $directories)
88+
->with('base', Input::get('base'))
89+
->with('file_info', $file_info)
90+
->with('dir_location', $this->file_location);
91+
}
4192
}
4293

4394

src/views/files.blade.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<div class="container">
2+
<div class="row">
3+
4+
@if((sizeof($files) > 0) || (sizeof($directories) > 0))
5+
6+
@foreach($directories as $key => $dir)
7+
<div class="col-sm-6 col-md-2">
8+
<div class="thumbnail text-center" data-id="{{ basename($dir) }}">
9+
<a id="large_folder_{{ $key }}" data-id="{{ $dir }}"
10+
onclick="clickFolder('large_folder_{{ $key }}',1)"
11+
class="folder-icon pointer">
12+
<img src="/vendor/laravel-filemanager/img/folder.jpg">
13+
</a>
14+
</div>
15+
<div class="caption text-center">
16+
<div class="btn-group">
17+
<button type="button" onclick="clickFolder('large_folder_{{ $key }}',1)"
18+
class="btn btn-default btn-xs">
19+
{!! str_limit(basename($dir), $limit = 10, $end = '...') !!}
20+
</button>
21+
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown"
22+
aria-expanded="false">
23+
<span class="caret"></span>
24+
<span class="sr-only">Toggle Dropdown</span>
25+
</button>
26+
<ul class="dropdown-menu" role="menu">
27+
<li><a href="javascript:rename('{!! basename($dir) !!}')">Rename</a></li>
28+
<li><a href="javascript:trash('{!! basename($dir) !!}')">Delete</a></li>
29+
</ul>
30+
</div>
31+
32+
</div>
33+
</div>
34+
@endforeach
35+
36+
@foreach($file_info as $key => $file)
37+
38+
<div class="col-sm-6 col-md-2 img-row">
39+
40+
<div class="thumbnail thumbnail-img text-center" data-id="{{ basename($file['name']) }}" id="img_thumbnail_{{ $key }}">
41+
<i class="fa <?= $file['icon'] ?> fa-5x"></i>
42+
</div>
43+
44+
<div class="caption text-center">
45+
<div class="btn-group ">
46+
<button type="button" onclick="useFile('<?= basename($file['name']) ?>')" class="btn btn-default btn-xs">
47+
{!! str_limit(basename($file['name']), $limit = 10, $end = '...') !!}
48+
</button>
49+
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown"
50+
aria-expanded="false">
51+
<span class="caret"></span>
52+
<span class="sr-only">Toggle Dropdown</span>
53+
</button>
54+
<ul class="dropdown-menu" role="menu">
55+
<li><a href="javascript:rename('<?= basename($file['name']) ?>')">Rename</a></li>
56+
<li><a href="javascript:fileView('<?= basename($file['name']) ?>')">View</a></li>
57+
<li><a href="javascript:download('<?= basename($file['name']) ?>')">Download</a></li>
58+
<li class="divider"></li>
59+
<li><a href="javascript:notImp()">Rotate</a></li>
60+
<li><a href="javascript:resizeImage('<?= basename($file['name']) ?>')">Resize</a></li>
61+
<li><a href="javascript:cropImage('<?= basename($file['name']) ?>')">Crop</a></li>
62+
<li class="divider"></li>
63+
<li><a href="javascript:trash('<?= basename($file['name']) ?>')">Delete</a></li>
64+
</ul>
65+
</div>
66+
</div>
67+
</div>
68+
69+
@endforeach
70+
71+
@else
72+
<div class="col-md-12">
73+
<p>Folder is empty.</p>
74+
</div>
75+
@endif
76+
77+
</div>
78+
</div>

0 commit comments

Comments
 (0)