Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17012 Rev 17018
Línea 637... Línea 637...
637
    
637
    
638
                    $files = $this->getRequest()->getFiles()->toArray();
638
                    $files = $this->getRequest()->getFiles()->toArray();
639
                    $file_type = '';
639
                    $file_type = '';
640
                    if (isset($files['file']) && empty($files['file']['error'])) {
640
                    if (isset($files['file']) && empty($files['file']['error'])) {
641
                        $feed_tmp_filename  = $files['file']['tmp_name'];
641
                        $feed_tmp_filename  = $files['file']['tmp_name'];
Línea 642... Línea 642...
642
                        $feed_filename      = $this->normalizeString($files['file']['name']);
642
                        $feed_filename      = \LeadersLinked\Library\Functions::normalizeStringFilename($files['file']['name']);
643
    
643
    
644
                        $mime_type = mime_content_type($feed_tmp_filename);
644
                        $mime_type = mime_content_type($feed_tmp_filename);
645
                        if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
645
                        if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
Línea 659... Línea 659...
659
                    if ($result) {
659
                    if ($result) {
Línea 660... Línea 660...
660
    
660
    
Línea 661... Línea 661...
661
                        $feed = $feedMapper->fetchOne($feed->id);
661
                        $feed = $feedMapper->fetchOne($feed->id);
662
                        
662
                        
663
                        
663
                        
664
                        $storage = Storage::getInstance($this->config);
664
                        $storage = Storage::getInstance($this->config, $this->adapter);
665
                        $target_path = $storage->getPathFeed();
665
                        $target_path = $storage->getPathFeed();
666
                        $interal_path   = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
666
                        $interal_path   = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
Línea 685... Línea 685...
685
                            
685
                            
686
                            $feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.'))  . '.png';
686
                            $feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.'))  . '.png';
687
                            $crop_to_dimensions = false;
687
                            $crop_to_dimensions = false;
Línea 688... Línea 688...
688
                            $unlink_source = true;
688
                            $unlink_source = true;
689
                            
689
                            
690
                            if(!$image->uploadImageChangeSize($feed_tmp_filename, $target_path, $feed->uuid, $feed_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
690
                            if(!$image->uploadProcessChangeSize($feed_tmp_filename, $target_path, $feed->uuid, $feed_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
691
                                $feed->file_type = $file_type;
691
                                $feed->file_type = $file_type;
692
                                $feed->file_name = $feed_filename;
692
                                $feed->file_name = $feed_filename;
693
                                $feedMapper->update($feed);
693
                                $feedMapper->update($feed);
Línea 1041... Línea 1041...
1041
            }*/
1041
            }*/
Línea 1042... Línea 1042...
1042
 
1042
 
1043
            return new JsonModel($response);
1043
            return new JsonModel($response);
1044
        }
1044
        }
1045
    }
-
 
1046
    /**
-
 
1047
     *
-
 
1048
     * @param string $str
-
 
1049
     * @return string
-
 
1050
     */
-
 
1051
    private function normalizeString($str = '')
-
 
1052
    {
-
 
1053
        $basename  = substr($str, 0, strrpos($str, '.'));
-
 
1054
        $basename  = str_replace('.', '-', $basename);
-
 
1055
 
-
 
1056
        $extension  = substr($str, strrpos($str, '.'));
1045
    }
1057
 
-
 
1058
        $str = $basename . $extension;
-
 
1059
 
-
 
1060
        $str = strip_tags($str);
-
 
1061
        $str = preg_replace('/[\r\n\t ]+/', ' ', $str);
-
 
1062
        $str = preg_replace('/[\"\*\/\:\<\>\?\'\|\,]+/', ' ', $str);
-
 
1063
        $str = strtolower($str);
-
 
1064
        $str = html_entity_decode($str, ENT_QUOTES, "utf-8");
-
 
1065
        $str = htmlentities($str, ENT_QUOTES, "utf-8");
-
 
1066
        $str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str);
-
 
1067
        $str = str_replace(' ', '-', $str);
-
 
1068
        $str = rawurlencode($str);
-
 
1069
        $str = str_replace('%', '-', $str);
-
 
1070
        return trim(strtolower($str));
-
 
1071
    }
-
 
Línea 1072... Línea 1046...
1072
 
1046
    
1073
 
1047
 
1074
 
1048
 
Línea 1103... Línea 1077...
1103
 
1077
 
1104
        $params = [
1078
        $params = [
1105
            'id' => $feed->uuid
1079
            'id' => $feed->uuid
Línea 1106... Línea 1080...
1106
        ];
1080
        ];
1107
 
1081
 
Línea 1108... Línea 1082...
1108
        $storage = Storage::getInstance($this->config);
1082
        $storage = Storage::getInstance($this->config, $this->adapter);
1109
        $path = $storage->getPathFeed();
1083
        $path = $storage->getPathFeed();
1110
 
1084
 
Línea 1308... Línea 1282...
1308
 
1282
 
1309
 
1283
 
Línea 1310... Línea 1284...
1310
            $item = [];
1284
            $item = [];
Línea 1311... Línea 1285...
1311
            $item['unique'] = uniqid();
1285
            $item['unique'] = uniqid();
1312
 
1286
 
1313
            $storage = Storage::getInstance($this->config);
1287
            $storage = Storage::getInstance($this->config, $this->adapter);