Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16769 Rev 16943
Línea 372... Línea 372...
372
                    
372
                    
373
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_capsule'] .  $capsule->uuid;
373
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_capsule'] .  $capsule->uuid;
374
                    if(!file_exists($target_path)) {
374
                    if(!file_exists($target_path)) {
375
                        mkdir($target_path, 0755, true);
375
                        mkdir($target_path, 0755, true);
376
                    }
-
 
377
                    
376
                    }
378
                    
377
     
379
                    $files = $this->getRequest()->getFiles()->toArray();
-
 
380
 
-
 
381
                    $fileBase64Content = $this->params()->fromPost('file');
-
 
382
                    try {
-
 
383
                        
-
 
384
                        $fileBase64Content = base64_decode($fileBase64Content);
-
 
385
                        $target_path = $this->config['leaderslinked.fullpath.microlearning_capsule'] . $capsule->uuid;
-
 
386
                        $capsule_filename      = 'capsule-' .uniqid() . '.jpg';
-
 
387
                        $capsule_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
388
                        if(!file_exists($capsule_tmp_filename)) {
-
 
389
                            mkdir($capsule_tmp_filename, 0755, true);
-
 
390
                        }
-
 
391
                        $capsule_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $capsule_filename;
-
 
392
                            file_put_contents($capsule_tmp_filename, $fileBase64Content);
-
 
393
                        
-
 
394
                        list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
395
 
-
 
396
                        $crop_to_dimensions = false;
-
 
397
                        if(Image::uploadImage($capsule_tmp_filename, $target_path, $capsule_filename, $target_width, $target_height, $crop_to_dimensions )) {
-
 
398
                            $capsule->image = basename($capsule_filename);
-
 
399
                            $capsuleMapper->update($capsule);
-
 
400
                        }
-
 
401
                    } catch(\Throwable $e) {
-
 
402
                        error_log($e->getTraceAsString());
-
 
403
                    }  
-
 
404
 
-
 
405
                    $fileBase64Content2 = $this->params()->fromPost('marketplace'); 
-
 
406
                    try {
-
 
407
                        
-
 
408
                        $fileBase64Content2 = base64_decode($fileBase64Content2);
-
 
409
                        $target_path2 = $this->config['leaderslinked.fullpath.microlearning_capsule'] . $capsule->uuid;
-
 
410
                        $capsule_filename2  = 'marketplace-' .uniqid() . '.jpg';
-
 
411
                        $capsule_tmp_filename2 = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
412
                        if(!file_exists($capsule_tmp_filename2)) {
-
 
413
                            mkdir($capsule_tmp_filename2, 0755, true);
-
 
414
                        }
-
 
415
                        $capsule_tmp_filename2 = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $capsule_filename2;
-
 
416
                            file_put_contents($capsule_tmp_filename2, $fileBase64Content2);
-
 
417
                         
-
 
418
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.marketplace']);
-
 
419
 
-
 
420
                        $crop_to_dimensions = false;
-
 
421
                        if(Image::uploadImage($capsule_tmp_filename2, $target_path2, $capsule_filename2, $target_width, $target_height, $crop_to_dimensions )) {
-
 
422
                            $capsule->marketplace = basename($capsule_filename2);
-
 
423
                            $capsuleMapper->update($capsule);
-
 
424
                        }
-
 
425
                    } catch(\Throwable $e) {
-
 
426
                        error_log($e->getTraceAsString());
-
 
427
                    }  
-
 
428
 
-
 
429
                    /*
378
                    $files = $this->getRequest()->getFiles()->toArray();
430
                    if(isset($files['file']) && empty($files['file']['error'])) {
379
                    if(isset($files['file']) && empty($files['file']['error'])) {
431
                        $tmp_filename  = $files['file']['tmp_name'];
380
                        $tmp_filename  = $files['file']['tmp_name'];
Línea 432... Línea 381...
432
                        //$filename      = $this->normalizeString($files['file']['name']);
381
                        // $filename      = $this->normalizeString($files['file']['name']);
433
                        
382
                        
Línea 434... Línea 383...
434
                        try {
383
                        try {
435
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
384
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
436
                            
385
                            
437
                            $filename = 'capsule-' .uniqid() . '.png';
386
                            $filename = 'capsule-' .uniqid() . '.jpg';
438
                            $crop_to_dimensions = true;
387
                            $crop_to_dimensions = false;
439
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
388
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
440
                                $capsule->image = $filename;
389
                                $capsule->image = $filename;
441
                                $capsuleMapper->update($capsule);
390
                                $capsuleMapper->update($capsule);
442
                            }
391
                            }
443
                        } catch(\Throwable $e) {
392
                        } catch(\Throwable $e) {
444
                            error_log($e->getTraceAsString());
-
 
445
                        }
-
 
Línea 446... Línea 393...
446
                    }
393
                            error_log($e->getTraceAsString());
447
                    */
394
                        }
448
                    
395
                    }
Línea 449... Línea 396...
449
                    
396
                    
-
 
397
                    if(isset($files['marketplace']) && empty($files['marketplace']['error'])) {
Línea 450... Línea -...
450
                   /* if(isset($files['marketplace']) && empty($files['marketplace']['error'])) {
-
 
451
                        $tmp_filename  = $files['marketplace']['tmp_name'];
-
 
452
                        //$filename      = $this->normalizeString($files['marketplace']['name']);
398
                        $tmp_filename  = $files['marketplace']['tmp_name'];
453
                        
399
                        // $filename      = $this->normalizeString($files['file']['name']);
454
                        try {
400
                        
455
                            
401
                        try {
456
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.marketplace']);
402
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
457
                            
403
                            
458
                            $filename = 'marketplace-' .uniqid() . '.png';
404
                            $filename = 'marketplace-' .uniqid() . '.jpg';
459
                            $crop_to_dimensions = true;
405
                            $crop_to_dimensions = false;
460
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
406
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
461
                                $capsule->marketplace = $filename;
407
                                $capsule->marketplace = $filename;
462
                                $capsuleMapper->update($capsule);
-
 
-
 
408
                                $capsuleMapper->update($capsule);
-
 
409
                            }
463
                            }
410
                        } catch(\Throwable $e) {
Línea 464... Línea 411...
464
                        } catch(\Throwable $e) {
411
                            error_log($e->getTraceAsString());
465
                            error_log($e->getTraceAsString());
412
                        }
466
                        }
413
                    }
Línea 680... Línea 627...
680
                $capsule->marketplace = null;
627
                $capsule->marketplace = null;
Línea 681... Línea 628...
681
                
628
                
Línea 682... Línea 629...
682
                if($capsuleMapper->update($capsule)) {
629
                if($capsuleMapper->update($capsule)) {
683
                    
-
 
684
                    $capsule = $capsuleMapper->fetchOne($capsule->id);
-
 
685
                  
-
 
686
                    $fileBase64Content = $this->params()->fromPost('file');
-
 
687
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_capsule'] . $capsule->uuid;
-
 
688
                    try {
-
 
689
                        if($capsule->image) {
-
 
690
                                
-
 
691
                            if(!image ::delete($target_path, $capsule->image)) {
-
 
692
                                return new JsonModel([
-
 
693
                                    'success'   => false,
-
 
694
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
695
                                ]);
-
 
696
                            }
-
 
697
                        }
-
 
698
                        
-
 
699
                        $fileBase64Content = base64_decode($fileBase64Content);
-
 
700
                        
-
 
701
                        $capsule_filename      = 'capsule-' .uniqid() . '.jpg';
-
 
702
                        $capsule_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
703
                        if(!file_exists($capsule_tmp_filename)) {
-
 
704
                            mkdir($capsule_tmp_filename, 0755, true);
-
 
705
                        }
-
 
706
                        $capsule_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $capsule_filename;
-
 
707
                            file_put_contents($capsule_tmp_filename, $fileBase64Content);
-
 
708
                        
-
 
709
                        list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
710
 
-
 
711
                        $crop_to_dimensions = false;
-
 
712
                        if(Image::uploadImage($capsule_tmp_filename, $target_path, $capsule_filename, $target_width, $target_height, $crop_to_dimensions )) {
-
 
713
                            $capsule->image = basename($capsule_filename);
-
 
714
                            $capsuleMapper->update($capsule);
-
 
715
                        }
-
 
716
                    } catch(\Throwable $e) {
-
 
717
                        error_log($e->getTraceAsString());
-
 
718
                    }  
-
 
719
 
-
 
720
                    $fileBase64Content2 = $this->params()->fromPost('marketplace'); 
-
 
721
                    try {
-
 
722
                        if($capsule->marketplace) {
-
 
723
                                
-
 
724
                            if(!image ::delete($target_path, $capsule->marketplace)) {
-
 
725
                                return new JsonModel([
-
 
726
                                    'success'   => false,
-
 
727
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
728
                                ]);
-
 
729
                            }
-
 
730
                        }
-
 
731
                        $fileBase64Content2 = base64_decode($fileBase64Content2);
-
 
732
                        $capsule_filename2  = 'marketplace-' .uniqid() . '.jpg';
-
 
733
                        $capsule_tmp_filename2 = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
734
                        if(!file_exists($capsule_tmp_filename2)) {
-
 
735
                            mkdir($capsule_tmp_filename2, 0755, true);
-
 
736
                        }
-
 
737
                        $capsule_tmp_filename2 = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $capsule_filename2;
-
 
738
                            file_put_contents($capsule_tmp_filename2, $fileBase64Content2);
-
 
739
                         
630
                    
740
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.marketplace']);
-
 
741
 
-
 
742
                        $crop_to_dimensions = false;
-
 
743
                        if(Image::uploadImage($capsule_tmp_filename2, $target_path, $capsule_filename2, $target_width, $target_height, $crop_to_dimensions )) {
-
 
744
                            $capsule->marketplace = basename($capsule_filename2);
-
 
745
                            $capsuleMapper->update($capsule);
-
 
746
                        }
-
 
747
                    } catch(\Throwable $e) {
-
 
748
                        error_log($e->getTraceAsString());
-
 
749
                    }  
631
                    $capsule = $capsuleMapper->fetchOne($capsule->id);
-
 
632
                    
-
 
633
                    $files = $this->getRequest()->getFiles()->toArray();
-
 
634
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_capsule'] .  $capsule->uuid;
-
 
635
                    if(!file_exists($target_path)) {
-
 
636
                        mkdir($target_path, 0755, true);
750
                    /*
637
                    }
751
                    $files = $this->getRequest()->getFiles()->toArray();
638
                    
752
                    if(isset($files['file']) && empty($files['file']['error'])) {
639
                    if(isset($files['file']) && empty($files['file']['error'])) {
Línea 753... Línea 640...
753
                        $tmp_filename  = $files['file']['tmp_name'];
640
                        $tmp_filename  = $files['file']['tmp_name'];
754
                        //$filename      = $this->normalizeString($files['file']['name']);
641
                        // $filename      = $this->normalizeString($files['file']['name']);
Línea 755... Línea 642...
755
                        
642
                        
756
                        try {
643
                        try {
757
                            if($topic->image) {
644
                            if($capsule->image) {
758
                                
645
                                
759
                                if(!image ::delete($target_path, $capsule->image)) {
646
                                if(!image ::delete($target_path, $capsule->image)) {
760
                                    return new JsonModel([
647
                                    return new JsonModel([
761
                                        'success'   => false,
648
                                        'success'   => false,
Línea -... Línea 649...
-
 
649
                                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
762
                                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
650
                                    ]);
Línea 763... Línea 651...
763
                                    ]);
651
                                }
764
                                }
652
                            }
765
                            }
653
                            
766
                            
654
                            
767
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
655
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
768
                            
656
                            
769
                            $filename = 'capsule-' .uniqid() . '.png';
657
                            $filename = 'capsule-' .uniqid() . '.jpg';
770
                            $crop_to_dimensions = true;
658
                            $crop_to_dimensions = false;
771
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
659
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
772
                                $capsule->image = $filename;
660
                                $capsule->image = $filename;
Línea 773... Línea -...
773
                                $capsuleMapper->update($capsule);
-
 
774
                            }
-
 
775
                        } catch(\Throwable $e) {
661
                                $capsuleMapper->update($capsule);
776
                            error_log($e->getTraceAsString());
662
                            }
777
                        }
663
                        } catch(\Throwable $e) {
Línea 778... Línea 664...
778
                    }
664
                            error_log($e->getTraceAsString());
779
                    
665
                        }
Línea 780... Línea 666...
780
                    
666
                    }
781
                    
667
                    
782
                    if(isset($files['marketplace']) && empty($files['marketplace']['error'])) {
668
                    if(isset($files['marketplace']) && empty($files['marketplace']['error'])) {
783
                        $tmp_filename  = $files['marketplace']['tmp_name'];
669
                        $tmp_filename  = $files['marketplace']['tmp_name'];
784
                        //$filename      = $this->normalizeString($files['marketplace']['name']);
670
                        // $filename      = $this->normalizeString($files['file']['name']);
785
                        
671
                        
786
                        try {
672
                        try {
Línea 787... Línea 673...
787
                            if($topic->marketplace) {
673
                            if($capsule->image) {
Línea 788... Línea 674...
788
                                
674
                                
789
                                if(!image ::delete($target_path, $capsule->marketplace)) {
675
                                if(!image ::delete($target_path, $capsule->marketplace)) {
790
                                    return new JsonModel([
676
                                    return new JsonModel([
791
                                        'success'   => false,
677
                                        'success'   => false,
792
                                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
678
                                        'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
793
                                    ]);
679
                                    ]);
794
                                }
680
                                }
795
                            }
681
                            }
796
                            
682
                            
797
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.marketplace']);
683
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
798
                            
-
 
-
 
684
                            
-
 
685
                            $filename = 'marketplace-' .uniqid() . '.jpg';
799
                            $filename = 'marketplace-' .uniqid() . '.png';
686
                            $crop_to_dimensions = false;
Línea 800... Línea 687...
800
                            $crop_to_dimensions = true;
687
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
801
                            if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
688
                                $capsule->marketplace = $filename;
802
                                $capsule->marketplace = $filename;
689
                                $capsuleMapper->update($capsule);