@@ -378,7 +378,6 @@ private function get_modified_storages(): array
378
378
foreach ($ this ->storage_collection as $ storage )
379
379
{
380
380
$ storage_name = $ storage ->get_name ();
381
- $ options = $ this ->storage_helper ->get_provider_options ($ this ->storage_helper ->get_current_provider ($ storage_name ));
382
381
383
382
$ modified = false ;
384
383
@@ -389,6 +388,8 @@ private function get_modified_storages(): array
389
388
}
390
389
else
391
390
{
391
+ $ options = $ this ->storage_helper ->get_provider_options ($ this ->storage_helper ->get_current_provider ($ storage_name ));
392
+
392
393
// Check if options have been modified
393
394
foreach (array_keys ($ options ) as $ definition )
394
395
{
@@ -431,8 +432,8 @@ protected function storage_stats(): void
431
432
432
433
$ storage_stats [] = [
433
434
'name ' => $ this ->lang ->lang ('STORAGE_ ' . strtoupper ($ storage ->get_name ()) . '_TITLE ' ),
434
- 'files ' => $ storage ->get_num_files (),
435
- 'size ' => get_formatted_filesize ($ storage ->get_size ()),
435
+ 'files ' => $ storage ->total_files (),
436
+ 'size ' => get_formatted_filesize ($ storage ->total_size ()),
436
437
'free_space ' => $ free_space ,
437
438
];
438
439
}
@@ -535,30 +536,29 @@ protected function validate_data(string $storage_name, array &$messages): void
535
536
$ this ->validate_path ($ storage_name , $ messages );
536
537
537
538
// Check options
538
- $ new_options = $ this ->storage_helper -> get_provider_options ($ this ->request ->variable ([$ storage_name , 'provider ' ], '' ));
539
+ $ new_provider = $ this ->provider_collection -> get_by_class ($ this ->request ->variable ([$ storage_name , 'provider ' ], '' ));
539
540
540
- foreach ($ new_options as $ definition_key => $ definition_value )
541
+ foreach ($ new_provider -> get_options () as $ definition_key => $ definition_value )
541
542
{
542
- $ provider = $ this ->provider_collection ->get_by_class ($ this ->request ->variable ([$ storage_name , 'provider ' ], '' ));
543
- $ definition_title = $ this ->lang ->lang ('STORAGE_ADAPTER_ ' . strtoupper ($ provider ->get_name ()) . '_OPTION_ ' . strtoupper ($ definition_key ));
544
543
544
+ $ definition_title = $ definition_value ['title ' ];
545
545
$ value = $ this ->request ->variable ([$ storage_name , $ definition_key ], '' );
546
546
547
- switch ($ definition_value ['tag ' ])
547
+ switch ($ definition_value ['form_macro ' ][ ' tag ' ])
548
548
{
549
549
case 'text ' :
550
- if ($ definition_value ['type ' ] == 'email ' && filter_var ($ value , FILTER_VALIDATE_EMAIL ))
550
+ if ($ definition_value ['form_macro ' ][ ' type ' ] = == 'email ' && filter_var ($ value , FILTER_VALIDATE_EMAIL ))
551
551
{
552
552
$ messages [] = $ this ->lang ->lang ('STORAGE_FORM_TYPE_EMAIL_INCORRECT_FORMAT ' , $ definition_title , $ storage_title );
553
553
}
554
554
555
- $ maxlength = $ definition_value ['max ' ] ?? 255 ;
555
+ $ maxlength = $ definition_value ['form_macro ' ][ ' max ' ] ?? 255 ;
556
556
if (strlen ($ value ) > $ maxlength )
557
557
{
558
558
$ messages [] = $ this ->lang ->lang ('STORAGE_FORM_TYPE_TEXT_TOO_LONG ' , $ definition_title , $ storage_title );
559
559
}
560
560
561
- if ($ provider ->get_name () == 'local ' && $ definition_key == 'path ' )
561
+ if ($ new_provider ->get_name () === 'local ' && $ definition_key = == 'path ' )
562
562
{
563
563
$ path = $ value ;
564
564
@@ -575,7 +575,7 @@ protected function validate_data(string $storage_name, array &$messages): void
575
575
576
576
case 'radio ' :
577
577
$ found = false ;
578
- foreach ($ definition_value ['buttons ' ] as $ button )
578
+ foreach ($ definition_value ['form_macro ' ][ ' buttons ' ] as $ button )
579
579
{
580
580
if ($ button ['value ' ] == $ value )
581
581
{
@@ -592,7 +592,7 @@ protected function validate_data(string $storage_name, array &$messages): void
592
592
593
593
case 'select ' :
594
594
$ found = false ;
595
- foreach ($ definition_value ['options ' ] as $ option )
595
+ foreach ($ definition_value ['form_macro ' ][ ' options ' ] as $ option )
596
596
{
597
597
if ($ option ['value ' ] == $ value )
598
598
{
@@ -619,10 +619,18 @@ protected function validate_data(string $storage_name, array &$messages): void
619
619
*/
620
620
protected function validate_path (string $ storage_name , array &$ messages ) : void
621
621
{
622
- $ current_provider = $ this ->storage_helper ->get_current_provider ($ storage_name );
623
- $ options = $ this ->storage_helper ->get_provider_options ($ current_provider );
622
+ if ($ this ->request ->is_set_post ('submit ' ))
623
+ {
624
+ $ provider = $ this ->request ->variable ([$ storage_name , 'provider ' ], '' );
625
+ }
626
+ else
627
+ {
628
+ $ provider = $ this ->storage_helper ->get_current_provider ($ storage_name );
629
+ }
630
+
631
+ $ options = $ this ->storage_helper ->get_provider_options ($ provider );
624
632
625
- if ($ this ->provider_collection ->get_by_class ($ current_provider )->get_name () == 'local ' && isset ($ options ['path ' ]))
633
+ if ($ this ->provider_collection ->get_by_class ($ provider )->get_name () = == 'local ' && isset ($ options ['path ' ]))
626
634
{
627
635
$ path = $ this ->request ->is_set_post ('submit ' ) ? $ this ->request ->variable ([$ storage_name , 'path ' ], '' ) : $ this ->storage_helper ->get_current_definition ($ storage_name , 'path ' );
628
636
0 commit comments