Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17052 Rev 17053
Línea 414... Línea 414...
414
        
414
        
415
        if($request->isGet()) {
415
        if($request->isGet()) {
416
            $storage = Storage::getInstance($this->config, $this->adapter);
416
            $storage = Storage::getInstance($this->config, $this->adapter);
Línea 417... Línea -...
417
            $path = $storage->getPathHabitEmoji();
-
 
418
            
417
            $path = $storage->getPathHabitEmoji();
419
            
418
            
420
            $data = [
419
            $data = [
421
                'success' => true,
420
                'success' => true,
422
                'data' => [
421
                'data' => [
Línea 451... Línea 450...
451
                    
450
                    
452
                    
451
                    
Línea -... Línea 452...
-
 
452
                    $target_size = $this->config['leaderslinked.image_sizes.emoji'];
-
 
453
                    list($target_width, $target_height) = explode('x', $target_size);
Línea -... Línea 454...
-
 
454
                   
-
 
455
                    $storage = Storage::getInstance($this->config, $this->adapter);
-
 
456
                    $storage->setFiles($this->getRequest()->getFiles()->toArray());
-
 
457
                    
-
 
458
                    if (!$storage->setCurrentFilename('image')) {
-
 
459
                        return new JsonModel([
Línea 453... Línea -...
453
                    $target_size = $this->config['leaderslinked.image_sizes.emoji'];
-
 
454
                    list($target_width, $target_height) = explode('x', $target_size);
-
 
455
                   
-
 
456
                    
-
 
457
                    
-
 
458
                    
-
 
459
                    $files = $this->getRequest()->getFiles()->toArray();
-
 
460
                    if(isset($files['image']) && empty($files['image']['error'])) {
460
                            'success'   => false,
461
                        
-
 
462
                        $image      = \LeadersLinked\Library\Image::getInstance($this->config);
461
                            'data'      => 'ERROR_UPLOAD_IMAGE'
463
                        $storage    = \LeadersLinked\Library\Storage::getInstance($this->config, $this->adapter);
462
                        ]);
464
                        
-
 
465
                        $target_path =  $storage->getPathHabitEmoji();
-
 
466
                        
-
 
467
                        $tmp_filename  = $files['image']['tmp_name'];
-
 
468
                        $filename      = explode('.',  $files['image']['name']);
-
 
469
                        $filename       = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
-
 
470
                        
-
 
471
                        $crop_to_dimensions = true;
-
 
472
                        $full_tmp_filename = $image->uploadProcessChangeSize($tmp_filename, $filename, $target_width, $target_height,  $crop_to_dimensions);
-
 
473
                        
-
 
474
                        if($full_tmp_filename) {
-
 
475
                            
-
 
476
                            if($habitEmoji->image) {
-
 
477
                                $image->getStorage()->deleteFile($target_path, $habitEmoji->uuid, $habitEmoji->image);
-
 
478
                            }
-
 
479
                            
-
 
480
                            
-
 
Línea -... Línea 463...
-
 
463
                    }
-
 
464
                    
-
 
465
                    $target_path =  $storage->getPathHabitEmoji();
-
 
466
                    $target_size = $this->config['leaderslinked.image_sizes.emoji'];
-
 
467
                    list($target_width, $target_height) = explode('x', $target_size);
-
 
468
 
-
 
469
                    $source_filename = $storage->getTmpFilename();
481
                            if($storage->putFile($target_path, $habitEmoji->uuid,  $full_tmp_filename)) {
470
                    $filename = 'habit-emoji-' . uniqid() . '.png';
-
 
471
                    $target_filename = $storage->composePathToFilename(
-
 
472
                        Storage::TYPE_HABIT_EMOJI,
-
 
473
                        $habitEmoji->uuid,
-
 
474
                        $filename
-
 
475
                    );
482
                                $habitEmoji->image = $filename;
476
 
-
 
477
                    if (!$storage->uploadImageCrop($source_filename, $target_filename, $target_width, $target_height)) {
-
 
478
                        return new JsonModel([
-
 
479
                            'success'   => false,
-
 
480
                            'data'      => 'ERROR_UPLOAD_IMAGE'
-
 
481
                        ]);
-
 
482
                    }
Línea -... Línea 483...
-
 
483
 
-
 
484
                    if ($habitEmoji->image) {
-
 
485
                        $storage->deleteFile($target_path, $habitEmoji->uuid, $habitEmoji->image);
-
 
486
                    }
-
 
487
 
-
 
488
                    $habitEmoji->image = $filename;
483
                                $habitEmojiMapper->update($habitEmoji);
-
 
Línea 484... Línea 489...
484
                            }
489
                    
Línea 485... Línea 490...
485
                        }
490
                    if(!$habitEmojiMapper->update($habitEmoji)) {
486
 
491
                        return new JsonModel([