Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17002 Rev 17018
Línea 293... Línea 293...
293
                $type = Message::TYPE_TEXT;
293
                $type = Message::TYPE_TEXT;
Línea 294... Línea 294...
294
                
294
                
295
                $files = $this->getRequest()->getFiles()->toArray();
295
                $files = $this->getRequest()->getFiles()->toArray();
296
                if(isset($files['file']) && empty($files['file']['error'])) {
296
                if(isset($files['file']) && empty($files['file']['error'])) {
297
                    $message_tmp_filename  = $files['file']['tmp_name'];
297
                    $message_tmp_filename  = $files['file']['tmp_name'];
Línea 298... Línea 298...
298
                    $message_filename      = $this->normalizeString($files['file']['name']);
298
                    $message_filename      = \LeadersLinked\Library\Functions::normalizeStringFilename($files['file']['name']);
Línea 299... Línea 299...
299
                    
299
                    
Línea 392... Línea 392...
392
                                
392
                                
393
                                $message_filename = substr($message_filename, 0, strrpos($message_filename, '.'))  . '.png';
393
                                $message_filename = substr($message_filename, 0, strrpos($message_filename, '.'))  . '.png';
Línea 394... Línea 394...
394
                                $crop_to_dimensions = false;
394
                                $crop_to_dimensions = false;
395
                                
395
                                
396
                                $image = Image::getInstance($this->config);
-
 
397
                                $target_path = $this->config['leaderslinked.fullpath.message'] . $message->uuid;
-
 
Línea -... Línea 396...
-
 
396
                                $image = Image::getInstance($this->config);
-
 
397
                                $storage = \LeadersLinked\Library\Storage::getInstance($this->config, $this->adapter);
Línea 398... Línea 398...
398
                                $unlink_source = true;
398
                                
-
 
399
                                $target_path = $storage ->getPathMessage();
-
 
400
                   
-
 
401
                                
399
                                if($image->uploadImageChangeSize($message_tmp_filename, $target_path, $target_code, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source))
402
                                $full_tmp_filename = $image->uploadProcessChangeSize($message_tmp_filename, $message_filename, $target_width, $target_height, $crop_to_dimensions);
400
                                
403
                                
401
                                
404
                                if($full_tmp_filename) {
-
 
405
                                    if($storage->putFile($target_path, $message->uuid,  $full_tmp_filename)) {
402
                                if(Image::uploadImage($message_tmp_filename, $target_path, $message_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
406
                                        $message->type = $type;
-
 
407
                                        $message->filename = basename($message_filename);
-
 
408
                                        $messageMapper->update($message);
-
 
409
                                    }
-
 
410
                                }
403
                                    $message->type = $type;
411
                                
404
                                    $message->filename = basename($message_filename);
412
                                $full_tmp_filename =  $image->uploadProcessChangeSize($message_tmp_filename, $message_filename, $target_width, $target_height,  $crop_to_dimensions);
405
                                    $messageMapper->update($message);
413
                                
406
                                }
414
                 
407
                            } catch(\Throwable $e) {
415
                            } catch(\Throwable $e) {
Línea 492... Línea 500...
492
            ]);
500
            ]);
493
        }
501
        }
Línea 494... Línea 502...
494
 
502
 
Línea 495... Línea -...
495
    }
-
 
496
 
-
 
497
    private function normalizeString ($str = '')
-
 
498
    {
-
 
499
        $basename  = substr($str, 0, strrpos($str, '.'));
-
 
500
        $basename  = str_replace('.', '-', $basename);
-
 
501
        
503
    }
502
        $extension  = substr($str, strrpos($str, '.'));
-
 
503
        
-
 
504
        $str = $basename . $extension;
-
 
505
        
-
 
506
        $str = strip_tags($str);
-
 
507
        $str = preg_replace('/[\r\n\t ]+/', ' ', $str);
-
 
508
        $str = preg_replace('/[\"\*\/\:\<\>\?\'\|\,]+/', ' ', $str);
-
 
509
        $str = strtolower($str);
-
 
510
        $str = html_entity_decode( $str, ENT_QUOTES, "utf-8" );
-
 
511
        $str = htmlentities($str, ENT_QUOTES, "utf-8");
-
 
512
        $str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str);
-
 
513
        $str = str_replace(' ', '-', $str);
-
 
514
        $str = rawurlencode($str);
-
 
515
        $str = str_replace('%', '-', $str);
-
 
Línea 516... Línea 504...
516
        return trim(strtolower($str));
504
 
517
    }
505