Skip to content

Commit 63517a4

Browse files
authored
Merge branch 'master' into master
2 parents 990d163 + 2372f39 commit 63517a4

File tree

13 files changed

+392
-30
lines changed

13 files changed

+392
-30
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
}
2424
],
2525
"require": {
26-
"php": ">=5.4.0",
26+
"php": ">=7.2.0",
2727
"ext-exif": "*",
2828
"ext-fileinfo": "*",
2929
"intervention/image": "2.*",
30-
"illuminate/config": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
31-
"illuminate/filesystem": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
32-
"illuminate/support": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
33-
"illuminate/http": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0",
34-
"illuminate/container": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0"
30+
"illuminate/config": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0",
31+
"illuminate/filesystem": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0",
32+
"illuminate/support": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0",
33+
"illuminate/http": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0",
34+
"illuminate/container": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0"
3535
},
3636
"require-dev": {
3737
"phpunit/phpunit": "^6.2",

public/css/lfm.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ a {
189189

190190
/* Items */
191191

192-
#content.preserve_actions_space {
192+
#pagination.preserve_actions_space {
193+
padding-top: 1em;
193194
padding-bottom: 4rem; /* preserve space for main actions */
194195
}
195196

public/js/script.js

Lines changed: 146 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ var refreshFoldersAndItems = function (data) {
297297

298298
var hideNavAndShowEditor = function (data) {
299299
$('#nav-buttons > ul').addClass('d-none');
300-
$('#content').html(data).removeClass('preserve_actions_space');
300+
$('#content').html(data);
301+
$('#pagination').removeClass('preserve_actions_space')
301302
clearSelected();
302303
}
303304

@@ -309,20 +310,131 @@ function loadFolders() {
309310
});
310311
}
311312

312-
function loadItems() {
313+
function generatePaginationHTML(el, args) {
314+
var template = '<li class="page-item"><\/li>';
315+
var linkTemplate = '<a class="page-link"><\/a>';
316+
var currentPage = args.currentPage;
317+
var totalPage = args.totalPage;
318+
var rangeStart = args.rangeStart;
319+
var rangeEnd = args.rangeEnd;
320+
var i;
321+
322+
// Disable page range, display all the pages
323+
if (args.pageRange === null) {
324+
for (i = 1; i <= totalPage; i++) {
325+
var button = $(template)
326+
.attr('data-num', i)
327+
.append($(linkTemplate).html(i));
328+
if (i == currentPage) {
329+
button.addClass('active');
330+
}
331+
el.append(button);
332+
}
333+
334+
return;
335+
}
336+
337+
if (rangeStart <= 3) {
338+
for (i = 1; i < rangeStart; i++) {
339+
var button = $(template)
340+
.attr('data-num', i)
341+
.append($(linkTemplate).html(i));
342+
if (i == currentPage) {
343+
button.addClass('active');
344+
}
345+
el.append(button);
346+
}
347+
} else {
348+
var button = $(template)
349+
.attr('data-num', 1)
350+
.append($(linkTemplate).html(1));
351+
el.append(button);
352+
353+
var button = $(template)
354+
.addClass('disabled')
355+
.append($(linkTemplate).html('...'));
356+
el.append(button);
357+
}
358+
359+
for (i = rangeStart; i <= rangeEnd; i++) {
360+
var button = $(template)
361+
.attr('data-num', i)
362+
.append($(linkTemplate).html(i));
363+
if (i == currentPage) {
364+
button.addClass('active');
365+
}
366+
el.append(button);
367+
}
368+
369+
if (rangeEnd >= totalPage - 2) {
370+
for (i = rangeEnd + 1; i <= totalPage; i++) {
371+
var button = $(template)
372+
.attr('data-num', i)
373+
.append($(linkTemplate).html(i));
374+
el.append(button);
375+
}
376+
} else {
377+
var button = $(template)
378+
.addClass('disabled')
379+
.append($(linkTemplate).html('...'));
380+
el.append(button);
381+
382+
var button = $(template)
383+
.attr('data-num', totalPage)
384+
.append($(linkTemplate).html(totalPage));
385+
el.append(button);
386+
}
387+
}
388+
389+
function createPagination(paginationSetting) {
390+
var el = $('<ul class="pagination" role="navigation"></ul>');
391+
392+
var currentPage = paginationSetting.current_page;
393+
var pageRange = 5;
394+
var totalPage = Math.ceil(paginationSetting.total / paginationSetting.per_page);
395+
396+
var rangeStart = currentPage - pageRange;
397+
var rangeEnd = currentPage + pageRange;
398+
399+
if (rangeEnd > totalPage) {
400+
rangeEnd = totalPage;
401+
rangeStart = totalPage - pageRange * 2;
402+
rangeStart = rangeStart < 1 ? 1 : rangeStart;
403+
}
404+
405+
if (rangeStart <= 1) {
406+
rangeStart = 1;
407+
rangeEnd = Math.min(pageRange * 2 + 1, totalPage);
408+
}
409+
410+
generatePaginationHTML(el, {
411+
totalPage: totalPage,
412+
currentPage: currentPage,
413+
pageRange: pageRange,
414+
rangeStart: rangeStart,
415+
rangeEnd: rangeEnd
416+
});
417+
418+
$('#pagination').append(el);
419+
}
420+
421+
function loadItems(page) {
313422
loading(true);
314-
performLfmRequest('jsonitems', {show_list: show_list, sort_type: sort_type}, 'html')
423+
performLfmRequest('jsonitems', {show_list: show_list, sort_type: sort_type, page: page || 1}, 'html')
315424
.done(function (data) {
316425
selected = [];
317426
var response = JSON.parse(data);
318427
var working_dir = response.working_dir;
319428
items = response.items;
320429
var hasItems = items.length !== 0;
430+
var hasPaginator = !!response.paginator;
321431
$('#empty').toggleClass('d-none', hasItems);
322432
$('#content').html('').removeAttr('class');
433+
$('#pagination').html('').removeAttr('class');
323434

324435
if (hasItems) {
325-
$('#content').addClass(response.display).addClass('preserve_actions_space');
436+
$('#content').addClass(response.display);
437+
$('#pagination').addClass('preserve_actions_space');
326438

327439
items.forEach(function (item, index) {
328440
var template = $('#item-template').clone()
@@ -352,6 +464,18 @@ function loadItems() {
352464
});
353465
}
354466

467+
if (hasPaginator) {
468+
createPagination(response.paginator);
469+
470+
$('#pagination a').on('click', function(event) {
471+
event.preventDefault();
472+
473+
loadItems($(this).closest('li')[0].getAttribute('data-num'));
474+
475+
return false;
476+
});
477+
}
478+
355479
$('#nav-buttons > ul').removeClass('d-none');
356480

357481
$('#working_dir').val(working_dir);
@@ -558,6 +682,17 @@ function use(items) {
558682
}
559683
}
560684

685+
function useTinymce5(url){
686+
if (!usingTinymce5()) { return; }
687+
688+
parent.postMessage({
689+
mceAction: 'insert',
690+
content: url
691+
});
692+
693+
parent.postMessage({ mceAction: 'close' });
694+
}
695+
561696
function useCkeditor3(url) {
562697
if (!usingCkeditor3()) { return; }
563698

@@ -589,6 +724,8 @@ function use(items) {
589724

590725
useTinymce4AndColorbox(url);
591726

727+
useTinymce5(url);
728+
592729
useCkeditor3(url);
593730

594731
useFckeditor2(url);
@@ -626,6 +763,10 @@ function usingTinymce4AndColorbox() {
626763
return !!getUrlParam('field_name');
627764
}
628765

766+
function usingTinymce5(){
767+
return !!getUrlParam('editor');
768+
}
769+
629770
function usingCkeditor3() {
630771
return !!getUrlParam('CKEditor') || !!getUrlParam('CKEditorCleanUpFuncNum');
631772
}
@@ -635,7 +776,7 @@ function usingFckeditor2() {
635776
}
636777

637778
function usingWysiwygEditor() {
638-
return usingTinymce3() || usingTinymce4AndColorbox() || usingCkeditor3() || usingFckeditor2();
779+
return usingTinymce3() || usingTinymce4AndColorbox() || usingTinymce5() || usingCkeditor3() || usingFckeditor2();
639780
}
640781

641782
// ==================================

src/Controllers/ItemsController.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ class ItemsController extends LfmController
1616
*/
1717
public function getItems()
1818
{
19+
$currentPage = self::getCurrentPageFromRequest();
20+
21+
$perPage = $this->helper->getPaginationPerPage();
22+
$items = array_merge($this->lfm->folders(), $this->lfm->files());
23+
1924
return [
2025
'items' => array_map(function ($item) {
2126
return $item->fill()->attributes;
22-
}, array_merge($this->lfm->folders(), $this->lfm->files())),
27+
}, array_slice($items, ($currentPage - 1) * $perPage, $perPage)),
28+
'paginator' => [
29+
'current_page' => $currentPage,
30+
'total' => count($items),
31+
'per_page' => $perPage,
32+
],
2333
'display' => $this->helper->getDisplayMode(),
2434
'working_dir' => $this->lfm->path('working_dir'),
2535
];
@@ -76,4 +86,12 @@ public function domove()
7686

7787
return parent::$success_response;
7888
}
89+
90+
private static function getCurrentPageFromRequest()
91+
{
92+
$currentPage = (int) request()->get('page', 1);
93+
$currentPage = $currentPage < 1 ? 1 : $currentPage;
94+
95+
return $currentPage;
96+
}
7997
}

src/Lfm.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public function maxUploadSize()
153153
return $this->config->get('lfm.folder_categories.' . $this->currentLfmType() . '.max_size');
154154
}
155155

156+
public function getPaginationPerPage()
157+
{
158+
return $this->config->get("lfm.paginator.perPage", 30);
159+
}
160+
156161
/**
157162
* Check if users are allowed to use their private folders.
158163
*

src/LfmItem.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Support\Str;
66
use Symfony\Component\HttpFoundation\File\UploadedFile;
7+
use Illuminate\Support\Str;
78

89
class LfmItem
910
{

src/config/lfm.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@
7474
],
7575
],
7676

77+
/*
78+
|--------------------------------------------------------------------------
79+
| Pagination
80+
|--------------------------------------------------------------------------
81+
*/
82+
83+
'paginator' => [
84+
'perPage' => 30,
85+
],
86+
7787
/*
7888
|--------------------------------------------------------------------------
7989
| Upload / Validation

src/lang/az/lfm.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
return [
4+
'nav-back' => 'Geri',
5+
'nav-new' => 'Yeni qovluq',
6+
'nav-upload' => 'Yüklə',
7+
'nav-thumbnails' => 'Kiçik formatda (thumb)',
8+
'nav-list' => 'Siyahı',
9+
'nav-sort' => 'Sırala',
10+
'nav-sort-alphabetic'=> 'A-Z Sırala',
11+
'nav-sort-time' => 'Zamana Görə Sırala',
12+
13+
'menu-rename' => 'Ad dəyişmək',
14+
'menu-delete' => 'Sil',
15+
'menu-view' => 'Görüntülə',
16+
'menu-download' => 'Endir',
17+
'menu-resize' => 'Ölçüləndir',
18+
'menu-crop' => 'Kəsmək',
19+
20+
'title-page' => 'Fayl menecer',
21+
'title-panel' => 'Fayl menecer',
22+
'title-upload' => 'Fayl yülə',
23+
'title-view' => 'Fayla bax',
24+
'title-root' => 'Fayllarım',
25+
'title-shares' => 'Paylaşılan Fayllar',
26+
'title-item' => 'Faylalr',
27+
'title-size' => 'Böyütmək',
28+
'title-type' => 'Tip',
29+
'title-modified' => 'Dəyişmək',
30+
'title-action' => 'Funksiyalar',
31+
32+
'type-folder' => 'Qovluq',
33+
34+
'message-empty' => 'Qovluq boşdur',
35+
'message-choose' => 'Fayl seç',
36+
'message-delete' => 'Bu faylı silmək istədiyinizə əminsiniz?',
37+
'message-name' => 'Qovluq adı:',
38+
'message-rename' => 'Yeni ad:',
39+
'message-extension_not_found' => 'Xahiş olunur , Şəkilləri kəsmək və ya yenidən ölçü vermək istəyirsinizsə gd və ya imagick genişlənmələriniz serverinizdə aktiov edin.',
40+
41+
'error-rename' => 'Fayl adı artıq istifadə olunur!',
42+
'error-file-name' => 'Dosya adı boş bırakılamaz!',
43+
'error-file-empty' => 'Fayl adı boş ola bilməz!',
44+
'error-file-exist' => 'Bu adda bir fayl artıq var!',
45+
'error-file-size' => 'Fayl ölçüsü limiti keçir! (maximum ölçü: :max)',
46+
'error-delete-folder'=> 'Qovluq boş olmadığından silmək mümkün olmadı!',
47+
'error-folder-name' => 'Qovluq adı boş ola bilməz!',
48+
'error-folder-exist'=> 'Bu adda qovluq artıq var!',
49+
'error-folder-alnum'=> 'Yalnız hərf və rəqəmdən ibarət adlara icazə verilir',
50+
'error-folder-not-found'=> 'Qovluq tapılmadı! (:folder)',
51+
'error-mime' => 'İcazə verilməyən fayl tipi: ',
52+
'error-size' => 'Həcm limiti keçir:',
53+
'error-instance' => 'Yüklənən fayl, UploadedFile nümunəsi kimi olmalıdır',
54+
'error-invalid' => 'Yükləmə istəyi doğru deyil',
55+
'error-other' => 'Xəta bax verdi: ',
56+
'error-too-large' => 'Yüklənmə sayı limiti keçir!',
57+
58+
'btn-upload' => 'Yüklə',
59+
'btn-uploading' => 'Yüklenir...',
60+
'btn-close' => 'Bağla',
61+
'btn-crop' => 'Kəs',
62+
'btn-copy-crop' => 'Kopyala & Kəs',
63+
'btn-cancel' => 'İmtina',
64+
'btn-resize' => 'Ölçünü dəyiş',
65+
66+
'resize-ratio' => 'Nisbət:',
67+
'resize-scaled' => 'Böyüdüldü:',
68+
'resize-true' => 'Bəli',
69+
'resize-old-height' => 'Original Hündürlür:',
70+
'resize-old-width' => 'Original En:',
71+
'resize-new-height' => 'Hündürlük:',
72+
'resize-new-width' => 'En:',
73+
74+
'locale-bootbox' => 'az',
75+
];

0 commit comments

Comments
 (0)