Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17018 Rev 17052
Línea 229... Línea 229...
229
                $habitEmojiMapper = HabitEmojiMapper::getInstance($this->adapter);
229
                $habitEmojiMapper = HabitEmojiMapper::getInstance($this->adapter);
230
                if($habitEmojiMapper->insert($habitEmoji)) {
230
                if($habitEmojiMapper->insert($habitEmoji)) {
Línea 231... Línea 231...
231
                    
231
                    
Línea -... Línea 232...
-
 
232
                    $habitEmoji = $habitEmojiMapper->fetchOne($habitEmoji->id);
-
 
233
                    
-
 
234
                    $storage = Storage::getInstance($this->config, $this->adapter);
-
 
235
                    $storage->setFiles($this->getRequest()->getFiles()->toArray());
-
 
236
 
-
 
237
                    if (!$storage->setCurrentFilename('image')) {
-
 
238
                        return new JsonModel([
-
 
239
                            'success'   => false,
-
 
240
                            'data'      => 'ERROR_UPLOAD_IMAGE'
-
 
241
                        ]);
232
                    $habitEmoji = $habitEmojiMapper->fetchOne($habitEmoji->id);
242
                    }
233
                    
243
 
234
                    $target_size = $this->config['leaderslinked.image_sizes.emoji'];
-
 
235
                    list($target_width, $target_height) = explode('x', $target_size);
-
 
236
                    
-
 
237
                    
-
 
238
                    $image = \LeadersLinked\Library\Image::getInstance($this->config);
-
 
239
                    $storage = \LeadersLinked\Library\Storage::getInstance($this->config, $this->adapter);
-
 
240
                    $target_path = $storage->getPathHabitEmoji();
-
 
Línea 241... Línea -...
241
                    
-
 
242
                    $files = $this->getRequest()->getFiles()->toArray();
244
                    $target_size = $this->config['leaderslinked.image_sizes.emoji'];
243
 
245
                    list($target_width, $target_height) = explode('x', $target_size);
244
                    
246
 
245
                    if(isset($files['image']) && empty($files['image']['error'])) {
247
                    $source_filename = $storage->getTmpFilename();
246
                        $tmp_filename  = $files['image']['tmp_name'];
-
 
247
                        $filename      = explode('.',  $files['image']['name']); 
248
                    $filename = 'habit-emoji-' . uniqid() . '.png';
248
                        $filename       = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
249
                    $target_filename = $storage->composePathToFilename(
-
 
250
                        Storage::TYPE_HABIT_EMOJI,
249
                     
251
                        $habitEmoji->uuid,
250
                        $crop_to_dimensions = true;
-
 
251
                        $full_tmp_filename = $image->uploadProcessChangeSize($tmp_filename, $filename, $target_width, $target_height, $crop_to_dimensions);
252
                        $filename
252
                        
253
                    );
253
                        if($full_tmp_filename) {
254
 
254
                            if($storage->putFile($target_path, $habitEmoji->uuid,  $full_tmp_filename)) {
255
                    if (!$storage->uploadImageCrop($source_filename, $target_filename, $target_width, $target_height)) {
255
                                $habitEmoji->image = $filename;
256
                        return new JsonModel([
256
                                $habitEmojiMapper->update($habitEmoji);
-
 
257
                            }
257
                            'success'   => false,
-
 
258
                            'data'      => 'ERROR_UPLOAD_IMAGE'
-
 
259
                        ]);
Línea -... Línea 260...
-
 
260
                    }
-
 
261
            
-
 
262
                    $habitEmoji->image = $filename;
-
 
263
                    
-
 
264
                    if(!$habitEmojiMapper->update($habitEmoji)) {
-
 
265
                        return new JsonModel([
Línea 258... Línea 266...
258
                        }
266
                            'success'   => false,
Línea 259... Línea 267...
259
                
267
                            'data'      => $habitEmojiMapper->getError()
260
                    }
268
                        ]);