Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17050 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17050 Rev 17051
Línea 664... Línea 664...
664
     * @param DailyPulseEmoji $emoji Emoji a actualizar
664
     * @param DailyPulseEmoji $emoji Emoji a actualizar
665
     * @return bool True si la imagen se procesó correctamente
665
     * @return bool True si la imagen se procesó correctamente
666
     */
666
     */
667
    private function processAndUpdateImage(DailyPulseEmoji $emoji)
667
    private function processAndUpdateImage(DailyPulseEmoji $emoji)
668
    {
668
    {
669
        $image = Image::getInstance($this->config);
-
 
670
        $storage = Storage::getInstance($this->config, $this->adapter);
669
        $storage = Storage::getInstance($this->config, $this->adapter);
671
        $target_path = $storage->getPathDailyPulse();
670
        $target_path = $storage->getPathDailyPulse();
Línea 672... Línea 671...
672
        
671
        
-
 
672
        if(!$storage->setCurrentFilename('image')) {
-
 
673
            return false;
-
 
674
        }
673
        $files = $this->getRequest()->getFiles()->toArray();
675
        
674
        $tmp_filename = $files['image']['tmp_name'];
676
        $source_filename = $storage->getTmpFilename();
675
        $filename = explode('.', $files['image']['name']);
677
        $filename = 'emoji-' . uniqid() . '.png';
-
 
678
        $target_filename = $storage->composePathToFilename(
-
 
679
            Storage::TYPE_DAILY_PULSE,
-
 
680
            $emoji->uuid,
-
 
681
            $filename
Línea 676... Línea 682...
676
        $filename = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0] . '.png');
682
        );
677
        
683
        
Línea 678... Línea -...
678
        $target_size = $this->config['leaderslinked.image_sizes.emoji'];
-
 
679
        list($target_width, $target_height) = explode('x', $target_size);
684
        $target_size = $this->config['leaderslinked.image_sizes.emoji'];
680
        
685
        list($target_width, $target_height) = explode('x', $target_size);
681
        $crop_to_dimensions = true;
686
        
682
        $full_tmp_filename = $image->uploadProcessChangeSize(
687
        $full_tmp_filename = $storage->uploadImageCrop(
683
            $tmp_filename,
688
            $source_filename,
684
            $filename,
-
 
685
            $target_width,
689
            $target_filename,
Línea 686... Línea 690...
686
            $target_height,
690
            $target_width,
687
            $crop_to_dimensions
691
            $target_height
688
        );
692
        );
Línea 694... Línea 698...
694
        // Eliminar imagen anterior si existe
698
        // Eliminar imagen anterior si existe
695
        if ($emoji->image) {
699
        if ($emoji->image) {
696
            $storage->deleteFile($target_path, $emoji->uuid, $emoji->image);
700
            $storage->deleteFile($target_path, $emoji->uuid, $emoji->image);
697
        }
701
        }
Línea 698... Línea -...
698
 
-
 
699
        // Guardar nueva imagen
-
 
700
        if (!$storage->putFile($target_path, $emoji->uuid, $full_tmp_filename)) {
-
 
701
            return false;
-
 
702
        }
-
 
703
 
702
 
704
        $emoji->image = $filename;
703
        $emoji->image = $filename;
705
        return true;
704
        return true;
Línea 706... Línea 705...
706
    }
705
    }