Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16769 | Rev 17002 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16769 Rev 16943
Línea 486... Línea 486...
486
                $slideMapper = CompanyMicrolearningSlideMapper::getInstance($this->adapter);
486
                $slideMapper = CompanyMicrolearningSlideMapper::getInstance($this->adapter);
487
                if($slideMapper->insert($slide)) {
487
                if($slideMapper->insert($slide)) {
488
                    $slide = $slideMapper->fetchOne($slide->id);
488
                    $slide = $slideMapper->fetchOne($slide->id);
Línea 489... Línea 489...
489
                    
489
                    
490
                    $files = $this->getRequest()->getFiles()->toArray();
-
 
491
                    
-
 
492
                    
-
 
493
 
-
 
494
                    if($slide->type == CompanyMicrolearningSlide::TYPE_IMAGE) {
-
 
495
                        $fileBase64Content = $this->params()->fromPost('file');
-
 
496
 
-
 
497
                        try {
-
 
498
                        
-
 
499
                            $fileBase64Content = base64_decode($fileBase64Content);
-
 
500
                            $filename      = 'slide-' .uniqid() . '.jpg';
-
 
501
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
502
                            $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
-
 
503
                            if(!file_exists($target_path)) {
-
 
504
                                mkdir($target_path, 0755, true);
-
 
505
                            }
-
 
506
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $filename;
-
 
507
                                file_put_contents($tmp_filename, $fileBase64Content);
-
 
508
                            
-
 
509
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
510
    
-
 
511
                            $crop_to_dimensions = true;
-
 
512
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions )) {
-
 
513
                                $slide->file = basename($filename);
-
 
514
                                $slideMapper->update($slide);
-
 
515
                            }
-
 
516
                        } catch(\Throwable $e) {
-
 
517
                            error_log($e->getTraceAsString());
-
 
518
                        }     
-
 
519
 
-
 
520
                    }
-
 
521
 
-
 
522
 
-
 
523
 
-
 
524
 
490
                    $files = $this->getRequest()->getFiles()->toArray();
525
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
491
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
526
                    if(!file_exists($target_path)) {
492
                    if(!file_exists($target_path)) {
527
                        mkdir($target_path, 0755, true);
493
                        mkdir($target_path, 0755, true);
Línea 528... Línea -...
528
                    }
-
 
529
                    
494
                    }
-
 
495
                    
530
                    
496
                    if(isset($files['file']) && empty($files['file']['error'])) {
531
                    if(isset($files['file']) && empty($files['file']['error'])) {
497
                    
532
                        $tmp_filename       = $files['file']['tmp_name'];
498
                        switch($slide->type)
-
 
499
                        {
Línea 533... Línea 500...
533
                        $original_filename  = trim(strtolower($files['file']['name']));
500
 
-
 
501
                            case CompanyMicrolearningSlide::TYPE_IMAGE : 
-
 
502
                        
-
 
503
                           
-
 
504
                                $tmp_filename  = $files['file']['tmp_name'];
-
 
505
                                // $filename      = $this->normalizeString($files['file']['name']);
-
 
506
                                
-
 
507
                                try {
-
 
508
                                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
509
                                    
-
 
510
                                    $filename =  'slide-' .uniqid() . '.jpg';
-
 
511
                                    $crop_to_dimensions = false;
-
 
512
                                    if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
-
 
513
                                        $slide->file = basename($filename);
-
 
514
                                        $slideMapper->update($slide);
-
 
515
                                    
-
 
516
                                    }
-
 
517
                                } catch(\Throwable $e) {
-
 
518
                                    error_log($e->getTraceAsString());
-
 
519
                                }
Línea 534... Línea -...
534
                        
-
 
535
                        
-
 
536
           
520
                                
537
                        
-
 
538
 
-
 
539
                        if($slide->file) {
521
                                break;
540
                            if(!image ::delete($target_path, $slide->file)) {
-
 
541
                                return new JsonModel([
-
 
542
                                    'success'   => false,
-
 
543
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
544
                                ]);
522
                       
545
                            }
-
 
Línea 546... Línea -...
546
                        }
-
 
547
 
-
 
Línea 548... Línea 523...
548
                        if($slide->type == CompanyMicrolearningSlide::TYPE_DOCUMENT) {
523
                        
549
                            try {
524
                            case CompanyMicrolearningSlide::TYPE_DOCUMENT : 
550
                                
525
                                $tmp_filename       = $files['file']['tmp_name'];
551
                                $parts = explode('.', $original_filename);
526
                                $original_filename  = trim(strtolower($files['file']['name']));
-
 
527
                                
-
 
528
                                
-
 
529
                                if($slide->file) {
552
                                $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
530
                                    if(!image ::delete($target_path, $slide->file)) {
553
                                
-
 
554
                                $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
-
 
555
                                if(move_uploaded_file($tmp_filename, $full_filename)) {
-
 
556
                                    $slide->file = basename($full_filename);
-
 
557
                                    $slideMapper->update($slide);
-
 
558
                                }
-
 
559
                            } catch(\Throwable $e) {
-
 
560
                                error_log($e->getTraceAsString());
-
 
561
                            }
-
 
562
                        }
-
 
Línea 563... Línea -...
563
                        
-
 
564
                        if($slide->type == CompanyMicrolearningSlide::TYPE_AUDIO) {
531
                                        return new JsonModel([
565
                            try {
-
 
Línea 566... Línea 532...
566
                                
532
                                            'success'   => false,
567
                                $parts = explode('.', $original_filename);
533
                                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
568
                                $filename = 'audio-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
-
 
569
                                
-
 
Línea -... Línea 534...
-
 
534
                                        ]);
-
 
535
                                    }
570
                                $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
536
                                }
571
                                if(move_uploaded_file($tmp_filename , $full_filename)) {
537
                                
-
 
538
                                try {
-
 
539
                                    
-
 
540
                                    $parts = explode('.', $original_filename);
572
                                    
541
                                    $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
-
 
542
                                    
-
 
543
                                    $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
-
 
544
                                    if(move_uploaded_file($tmp_filename, $full_filename)) {
-
 
545
                                        $slide->file = basename($full_filename);
-
 
546
                                        $slideMapper->update($slide);
-
 
547
                                    }
Línea 573... Línea -...
573
                                    
-
 
574
                                    $generateFileName   = substr($filename, 0, strrpos($filename, '.'));
-
 
575
                                    $generateFile       =  $target_path  . DIRECTORY_SEPARATOR . $generateFileName .  '.mp3';
-
 
576
                                    $cmd                = "/usr/bin/ffmpeg -i $full_filename -b:a 320000 $generateFile";
-
 
577
                                    exec($cmd);
-
 
578
                                    
-
 
579
                                    $slide->file = basename($full_filename);
-
 
580
                                    $slideMapper->update($slide);
-
 
581
                                }
-
 
Línea -... Línea 548...
-
 
548
                                } catch(\Throwable $e) {
582
                                
549
                                    error_log($e->getTraceAsString());
-
 
550
                                }
-
 
551
 
-
 
552
                                break;
-
 
553
                                
-
 
554
                            case  CompanyMicrolearningSlide::TYPE_AUDIO : 
-
 
555
                                $tmp_filename       = $files['file']['tmp_name'];
Línea 583... Línea 556...
583
                            } catch(\Throwable $e) {
556
                                $original_filename  = trim(strtolower($files['file']['name']));
Línea 584... Línea -...
584
                                error_log($e->getTraceAsString());
-
 
585
                            }
557
                                
586
                        }
558
                                
Línea -... Línea 559...
-
 
559
                                if($slide->file) {
-
 
560
                                    if(!image ::delete($target_path, $slide->file)) {
-
 
561
                                        return new JsonModel([
-
 
562
                                            'success'   => false,
587
                        
563
                                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
564
                                        ]);
-
 
565
                                    }
-
 
566
                                }
-
 
567
                                
-
 
568
                                try {
588
                        if($slide->type == CompanyMicrolearningSlide::TYPE_VIDEO) {
569
                                    
-
 
570
                                    $parts = explode('.', $original_filename);
Línea 589... Línea 571...
589
                            try {
571
                                    $filename = 'audio-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
590
                                $parts = explode('.', $original_filename);
572
                                    
591
                                $filename = 'video-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
573
                                    $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
Línea 592... Línea -...
592
                                
-
 
593
                                $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
574
                                    if(move_uploaded_file($tmp_filename , $full_filename)) {
Línea -... Línea 575...
-
 
575
                                        
-
 
576
                                        
-
 
577
                                        $generateFileName   = substr($filename, 0, strrpos($filename, '.'));
-
 
578
                                        $generateFile       =  $target_path  . DIRECTORY_SEPARATOR . $generateFileName .  '.mp3';
-
 
579
                                        $cmd                = "/usr/bin/ffmpeg -i $full_filename -b:a 320000 $generateFile";
-
 
580
                                        exec($cmd);
-
 
581
                                        
-
 
582
                                        $slide->file = basename($full_filename);
-
 
583
                                        $slideMapper->update($slide);
-
 
584
                                    }
-
 
585
                                    
-
 
586
                                } catch(\Throwable $e) {
-
 
587
                                    error_log($e->getTraceAsString());
-
 
588
                                }
-
 
589
                                
-
 
590
                                break;
-
 
591
                                
-
 
592
                                
-
 
593
                            case CompanyMicrolearningSlide::TYPE_VIDEO : 
-
 
594
                                $tmp_filename       = $files['file']['tmp_name'];
-
 
595
                                $original_filename  = trim(strtolower($files['file']['name']));
-
 
596
                                
-
 
597
                                
-
 
598
                                if($slide->file) {
-
 
599
                                    if(!image ::delete($target_path, $slide->file)) {
-
 
600
                                        return new JsonModel([
-
 
601
                                            'success'   => false,
-
 
602
                                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
603
                                        ]);
-
 
604
                                    }
-
 
605
                                }
-
 
606
 
-
 
607
                                try {
-
 
608
                                    $parts = explode('.', $original_filename);
-
 
609
                                    $filename = 'video-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
-
 
610
                                    
-
 
611
                                    $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
594
                                
612
                                    
595
                                if(move_uploaded_file($tmp_filename , $full_filename)) {
613
                                    if(move_uploaded_file($tmp_filename , $full_filename)) {
-
 
614
                                        
596
                                    
615
                                        $videoConvert = new VideoConvert();
597
                                    $videoConvert = new VideoConvert();
-
 
598
                                    $videoConvert->filename = $full_filename;
-
 
599
                                    $videoConvert->type = VideoConvert::TYPE_MICRO_LEARNING;
616
                                        $videoConvert->filename = $full_filename;
600
                                    
-
 
601
                                    $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
-
 
602
                                    $videoConvertMapper->insert($videoConvert);
-
 
603
                                    
-
 
604
                                    $slide->file = basename($full_filename);
-
 
605
                                    $slideMapper->update($slide);
-
 
606
                                }
-
 
607
                                
-
 
608
                            } catch(\Throwable $e) {
-
 
609
                                echo $e->getMessage();
-
 
610
                                
-
 
611
                                error_log($e->getTraceAsString());
-
 
612
                            }
-
 
613
                        }
-
 
614
                        
-
 
615
                        
-
 
616
                    }
-
 
617
                  
-
 
618
                        $fileBase64Content = $this->params()->fromPost('background');
-
 
619
                        $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
-
 
620
                        if($slide->background) {
-
 
621
                            if(!image ::delete($target_path, $slide->background)) {
-
 
622
                                return new JsonModel([
-
 
623
                                    'success'   => false,
-
 
624
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
625
                                ]);
-
 
626
                            }
-
 
627
                        }
-
 
628
 
-
 
629
                        try {
-
 
630
                        
-
 
631
                            $fileBase64Content = base64_decode($fileBase64Content);
-
 
632
                            $filename      = 'background-' .uniqid() . '.jpg';
-
 
633
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
Línea 634... Línea 617...
634
                            if(!file_exists($target_path)) {
617
                                        $videoConvert->type = VideoConvert::TYPE_MICRO_LEARNING;
635
                                mkdir($target_path, 0755, true);
618
                                        
636
                            }
619
                                        $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
637
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $filename;
620
                                        $videoConvertMapper->insert($videoConvert);
638
                                file_put_contents($tmp_filename, $fileBase64Content);
621
                                        
639
                            
622
                                        $slide->file = basename($full_filename);
Línea 671... Línea 654...
671
                                $slideMapper->update($slide);
654
                                $slideMapper->update($slide);
672
                            }
655
                            }
673
                        } catch(\Throwable $e) {
656
                        } catch(\Throwable $e) {
674
                            error_log($e->getTraceAsString());
657
                            error_log($e->getTraceAsString());
675
                        }
658
                        }
676
                    }*/
659
                    }
Línea 677... Línea 660...
677
                    
660
                    
Línea 678... Línea 661...
678
                    $this->logger->info('Se agrego la diapositiva ' . $slide->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
661
                    $this->logger->info('Se agrego la diapositiva ' . $slide->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
679
                    
662
                    
Línea 949... Línea 932...
949
                
932
                
950
                if($slideMapper->update($slide)) {
933
                if($slideMapper->update($slide)) {
Línea -... Línea 934...
-
 
934
                    $slide = $slideMapper->fetchOne($slide->id);    
951
                    $slide = $slideMapper->fetchOne($slide->id);    
935
                    
952
                    
936
                    
953
                    
937
                    $files = $this->getRequest()->getFiles()->toArray();
954
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
938
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
Línea 955... Línea -...
955
                    if(!file_exists($target_path)) {
-
 
956
                        mkdir($target_path, 0755, true);
-
 
957
                    }
-
 
958
                    
-
 
959
                    $files = $this->getRequest()->getFiles()->toArray();
-
 
960
                   
-
 
961
                    if($slide->type == CompanyMicrolearningSlide::TYPE_IMAGE) {
-
 
962
                            $fileBase64Content = $this->params()->fromPost('file');
-
 
963
                        
-
 
964
                        try {
-
 
965
                            
-
 
966
                            $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
-
 
967
                            if($slide->file) {
-
 
968
                                if(!image ::delete($target_path, $slide->file)) {
-
 
969
                                    return new JsonModel([
-
 
970
                                        'success'   => false,
-
 
971
                                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
972
                                    ]);
-
 
973
                                }
-
 
974
                            }
-
 
975
                            $fileBase64Content = base64_decode($fileBase64Content);
-
 
976
                            $filename      = 'slide-' .uniqid() . '.png';
-
 
977
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
978
                            if(!file_exists($target_path)) {
-
 
979
                                mkdir($target_path, 0755, true);
-
 
980
                            }
-
 
981
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $filename;
-
 
982
                                file_put_contents($tmp_filename, $fileBase64Content);
-
 
983
                            
-
 
984
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
985
 
-
 
986
                            $crop_to_dimensions = true;
-
 
987
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions )) {
-
 
988
                                $slide->file = basename($filename);
-
 
989
                                $slideMapper->update($slide);
-
 
990
                            }
-
 
991
                        } catch(\Throwable $e) {
-
 
992
                            error_log($e->getTraceAsString());
-
 
993
                        }     
-
 
994
                        /*
-
 
995
                        try {
-
 
996
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
997
                            
-
 
998
                            $filename = 'slide-' .uniqid() . '.png';
-
 
999
                            $crop_to_dimensions = true;
-
 
1000
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
-
 
1001
                                $slide->file = $filename;
-
 
1002
                                $slideMapper->update($slide);
-
 
1003
                            }
-
 
1004
                        } catch(\Throwable $e) {
-
 
1005
                            error_log($e->getTraceAsString());
939
                    if(!file_exists($target_path)) {
1006
                        }*/
-
 
1007
                    }
-
 
1008
 
-
 
1009
                    if(isset($files['file']) && empty($files['file']['error'])) {
-
 
1010
                        $tmp_filename       = $files['file']['tmp_name'];
-
 
1011
                        $original_filename  = trim(strtolower($files['file']['name']));
-
 
1012
 
-
 
1013
                        
-
 
1014
                        if($slide->file) {
-
 
1015
                            if(!image ::delete($target_path, $slide->file)) {
-
 
1016
                                return new JsonModel([
-
 
1017
                                    'success'   => false,
-
 
Línea 1018... Línea 940...
1018
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
940
                        mkdir($target_path, 0755, true);
1019
                                ]);
941
                    }
-
 
942
                    
-
 
943
                    if(isset($files['file']) && empty($files['file']['error'])) {
-
 
944
                        
Línea 1020... Línea 945...
1020
                            }
945
                        switch($slide->type)
1021
                        }
946
                        {
Línea -... Línea 947...
-
 
947
                            
-
 
948
                            case CompanyMicrolearningSlide::TYPE_IMAGE :
-
 
949
                                
1022
                        
950
                                
1023
                        if($slide->type == CompanyMicrolearningSlide::TYPE_DOCUMENT) {
951
                                $tmp_filename  = $files['file']['tmp_name'];
-
 
952
                                // $filename      = $this->normalizeString($files['file']['name']);
1024
                            try {
953
                                
1025
                                
954
                                try {
-
 
955
                                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
956
                                    
-
 
957
                                    $filename =  'slide-' .uniqid() . '.jpg';
-
 
958
                                    $crop_to_dimensions = false;
1026
                                $parts = explode('.', $original_filename);
959
                                    if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
1027
                                $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
-
 
1028
                                
-
 
1029
                                $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
-
 
1030
                                if(move_uploaded_file($tmp_filename, $full_filename)) {
-
 
1031
                                    $slide->file = basename($full_filename);
-
 
1032
                                    $slideMapper->update($slide);
-
 
1033
                                }
-
 
Línea 1034... Línea 960...
1034
                            } catch(\Throwable $e) {
960
                                        $slide->file = basename($filename);
1035
                                error_log($e->getTraceAsString());
-
 
Línea -... Línea 961...
-
 
961
                                        $slideMapper->update($slide);
-
 
962
                                        
1036
                            }
963
                                    }
-
 
964
                                } catch(\Throwable $e) {
-
 
965
                                    error_log($e->getTraceAsString());
-
 
966
                                }
-
 
967
                                
1037
                        }
968
                                break;
-
 
969
                                
-
 
970
                                
-
 
971
                            case CompanyMicrolearningSlide::TYPE_DOCUMENT :
-
 
972
                                $tmp_filename       = $files['file']['tmp_name'];
-
 
973
                                $original_filename  = trim(strtolower($files['file']['name']));
-
 
974
                                
1038
                        
975
                                
-
 
976
                                if($slide->file) {
Línea 1039... Línea 977...
1039
                        if($slide->type == CompanyMicrolearningSlide::TYPE_AUDIO) {
977
                                    if(!image ::delete($target_path, $slide->file)) {
1040
                            try {
978
                                        return new JsonModel([
1041
                                
-
 
1042
                                $parts = explode('.', $original_filename);
-
 
Línea -... Línea 979...
-
 
979
                                            'success'   => false,
-
 
980
                                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
1043
                                $filename = 'audio-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
981
                                        ]);
1044
                                
982
                                    }
-
 
983
                                }
-
 
984
                                
-
 
985
                                try {
1045
                                $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
986
                                    
Línea 1046... Línea -...
1046
                                if(move_uploaded_file($tmp_filename , $full_filename)) {
-
 
1047
                                    
-
 
1048
                                    
-
 
1049
                                    $generateFileName   = substr($filename, 0, strrpos($filename, '.'));
-
 
1050
                                    $generateFile       =  $target_path  . DIRECTORY_SEPARATOR . $generateFileName .  '.mp3';
-
 
1051
                                    $cmd                = "/usr/bin/ffmpeg -i $full_filename -b:a 320000 $generateFile";
-
 
1052
                                    exec($cmd);
987
                                    $parts = explode('.', $original_filename);
1053
                                    
-
 
1054
                                    $slide->file = basename($full_filename);
-
 
Línea -... Línea 988...
-
 
988
                                    $filename = 'document-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
1055
                                    $slideMapper->update($slide);
989
                                    
-
 
990
                                    $full_filename = $target_path  . DIRECTORY_SEPARATOR .$filename;
-
 
991
                                    if(move_uploaded_file($tmp_filename, $full_filename)) {
1056
                                }
992
                                        $slide->file = basename($full_filename);
-
 
993
                                        $slideMapper->update($slide);
1057
                                
994
                                    }
-
 
995
                                } catch(\Throwable $e) {
-
 
996
                                    error_log($e->getTraceAsString());
-
 
997
                                }
-
 
998
                                
-
 
999
                                break;
-
 
1000
                                
-
 
1001
                            case  CompanyMicrolearningSlide::TYPE_AUDIO :
-
 
1002
                                $tmp_filename       = $files['file']['tmp_name'];
Línea 1058... Línea -...
1058
                            } catch(\Throwable $e) {
-
 
1059
                                error_log($e->getTraceAsString());
1003
                                $original_filename  = trim(strtolower($files['file']['name']));
1060
                            }
1004
                                
Línea -... Línea 1005...
-
 
1005
                                
-
 
1006
                                if($slide->file) {
-
 
1007
                                    if(!image ::delete($target_path, $slide->file)) {
-
 
1008
                                        return new JsonModel([
1061
                        }
1009
                                            'success'   => false,
-
 
1010
                                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
1011
                                        ]);
-
 
1012
                                    }
-
 
1013
                                }
-
 
1014
                                
1062
                        
1015
                                try {
-
 
1016
                                    
Línea 1063... Línea 1017...
1063
                        if($slide->type == CompanyMicrolearningSlide::TYPE_VIDEO) {
1017
                                    $parts = explode('.', $original_filename);
1064
                            try {
1018
                                    $filename = 'audio-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
1065
                                $parts = explode('.', $original_filename);
1019
                                    
Línea 1066... Línea -...
1066
                                $filename = 'video-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
-
 
1067
                                
1020
                                    $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
Línea -... Línea 1021...
-
 
1021
                                    if(move_uploaded_file($tmp_filename , $full_filename)) {
-
 
1022
                                        
-
 
1023
                                        
-
 
1024
                                        $generateFileName   = substr($filename, 0, strrpos($filename, '.'));
-
 
1025
                                        $generateFile       =  $target_path  . DIRECTORY_SEPARATOR . $generateFileName .  '.mp3';
-
 
1026
                                        $cmd                = "/usr/bin/ffmpeg -i $full_filename -b:a 320000 $generateFile";
-
 
1027
                                        exec($cmd);
-
 
1028
                                        
-
 
1029
                                        $slide->file = basename($full_filename);
-
 
1030
                                        $slideMapper->update($slide);
-
 
1031
                                    }
-
 
1032
                                    
-
 
1033
                                } catch(\Throwable $e) {
-
 
1034
                                    error_log($e->getTraceAsString());
-
 
1035
                                }
-
 
1036
                                
-
 
1037
                                break;
-
 
1038
                                
-
 
1039
                                
-
 
1040
                            case CompanyMicrolearningSlide::TYPE_VIDEO :
-
 
1041
                                $tmp_filename       = $files['file']['tmp_name'];
-
 
1042
                                $original_filename  = trim(strtolower($files['file']['name']));
-
 
1043
                                
-
 
1044
                                
-
 
1045
                                if($slide->file) {
-
 
1046
                                    if(!image ::delete($target_path, $slide->file)) {
-
 
1047
                                        return new JsonModel([
-
 
1048
                                            'success'   => false,
-
 
1049
                                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
1050
                                        ]);
-
 
1051
                                    }
-
 
1052
                                }
-
 
1053
                                
-
 
1054
                                try {
-
 
1055
                                    $parts = explode('.', $original_filename);
-
 
1056
                                    $filename = 'video-' . uniqid() . '.' . $parts[ count($parts) - 1 ];
-
 
1057
                                    
1068
                                $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
1058
                                    $full_filename      = $target_path  . DIRECTORY_SEPARATOR .$filename;
1069
                               
1059
                                    
-
 
1060
                                    if(move_uploaded_file($tmp_filename , $full_filename)) {
1070
                                if(move_uploaded_file($tmp_filename , $full_filename)) {
1061
                                        
1071
                                    
-
 
1072
                                    $videoConvert = new VideoConvert();
-
 
1073
                                    $videoConvert->filename = $full_filename;
1062
                                        $videoConvert = new VideoConvert();
1074
                                    $videoConvert->type = VideoConvert::TYPE_MICRO_LEARNING;
-
 
1075
                                    
-
 
1076
                                    $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
-
 
1077
                                    $videoConvertMapper->insert($videoConvert);
-
 
1078
                                    
-
 
1079
                                    $slide->file = basename($full_filename);
-
 
1080
                                    $slideMapper->update($slide);
-
 
1081
                                }
-
 
1082
                                
-
 
1083
                            } catch(\Throwable $e) {
-
 
1084
                                echo $e->getMessage();
-
 
1085
                                
-
 
1086
                                error_log($e->getTraceAsString());
-
 
1087
                            }
-
 
1088
                        }
-
 
1089
                        
-
 
1090
                      
-
 
1091
                    }
-
 
1092
                    $fileBase64Content = $this->params()->fromPost('background');
-
 
1093
                        $target_path = $this->config['leaderslinked.fullpath.microlearning_slide'] .  $slide->uuid;
-
 
1094
                        if($slide->background) {
-
 
1095
                            if(!image ::delete($target_path, $slide->background)) {
-
 
1096
                                return new JsonModel([
-
 
1097
                                    'success'   => false,
-
 
1098
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
1099
                                ]);
-
 
1100
                            }
-
 
1101
                        }
-
 
1102
 
-
 
1103
                        try {
-
 
1104
                        
-
 
1105
                            $fileBase64Content = base64_decode($fileBase64Content);
-
 
Línea 1106... Línea -...
1106
                            $filename      = 'background-' .uniqid() . '.png';
-
 
1107
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
1063
                                        $videoConvert->filename = $full_filename;
1108
                            if(!file_exists($target_path)) {
1064
                                        $videoConvert->type = VideoConvert::TYPE_MICRO_LEARNING;
1109
                                mkdir($target_path, 0755, true);
1065
                                        
1110
                            }
1066
                                        $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
1111
                            $tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $filename;
1067
                                        $videoConvertMapper->insert($videoConvert);
Línea 1145... Línea 1101...
1145
                                $slideMapper->update($slide);
1101
                                $slideMapper->update($slide);
1146
                            }
1102
                            }
1147
                        } catch(\Throwable $e) {
1103
                        } catch(\Throwable $e) {
1148
                            error_log($e->getTraceAsString());
1104
                            error_log($e->getTraceAsString());
1149
                        }
1105
                        }
1150
                    }*/
1106
                    }
Línea 1151... Línea 1107...
1151
                    
1107
                    
Línea 1152... Línea 1108...
1152
                    $this->logger->info('Se edito la diapositiva ' . $slide->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1108
                    $this->logger->info('Se edito la diapositiva ' . $slide->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
1153
                    
1109