Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 290 Rev 334
Línea 11... Línea 11...
11
     */
11
     */
12
    private static $_instance;
12
    private static $_instance;
Línea 13... Línea 13...
13
    
13
    
14
    /**
14
    /**
15
     *
-
 
16
     * @var \LeadersLinked\Library\Storage
-
 
17
     */
-
 
18
    private $storage;
-
 
19
    
-
 
20
    /**
-
 
21
     * 
15
     *
22
     * @var array
16
     * @var array
23
     */
17
     */
24
    private $config;
18
    private $config;
25
    
19
 
26
    /**
20
     /**
27
     *
21
     * 
28
     * @param array $config
22
     * @param array $config
29
     */
23
     */
30
    private function __construct($config)
24
    private function __construct($config) 
31
    {
25
    {
32
        $this->config = $config;
-
 
33
        $this->storage = Storage::getInstance($config);
26
        $this->config       = $config;
Línea 34... Línea 27...
34
    }
27
    }
35
    
28
    
36
    /**
29
    /**
Línea 45... Línea 38...
45
        }
38
        }
Línea 46... Línea 39...
46
        
39
        
47
        return self::$_instance;
40
        return self::$_instance;
Línea 48... Línea -...
48
    }
-
 
49
    
-
 
50
    /**
-
 
51
     * 
-
 
52
     * @return \LeadersLinked\Library\Storage
-
 
53
     */
-
 
54
    public function getStorage()
-
 
55
    {
-
 
56
        return $this->storage;
-
 
57
    }
-
 
Línea 58... Línea 41...
58
    
41
    }
59
  
42
    
60
    
43
    
61
    /**
-
 
62
     * 
-
 
63
     * @param string $source
44
    /**
64
     * @param string $target_path
45
     * 
65
     * @param string $target_code
46
     * @param string $source
66
     * @param string $target_filename
47
     * @param string $target_filename
67
     * @param number $target_width
-
 
68
     * @param number $target_height
48
     * @param number $target_width
69
     * @param boolean $crop_to_dimensions
49
     * @param number $target_height
70
     * @param boolean $unlink_source
50
     * @param boolean $crop_to_dimensions
71
     * @return boolean
51
     * @return boolean
72
     */
-
 
-
 
52
     */
Línea 73... Línea 53...
73
    public function uploadImageChangeSize($source, $target_path, $target_code, $target_filename, $target_width, $target_height,  $crop_to_dimensions, $unlink_source)
53
    public function uploadProcessChangeSize($source, $target_filename, $target_width, $target_height,  $crop_to_dimensions)
74
    {
-
 
Línea 75... Línea -...
75
        
-
 
-
 
54
    {
76
       
55
        $temp_filename = '';
Línea 77... Línea 56...
77
        
56
       
78
        try {
57
        
Línea 120... Línea 99...
120
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
99
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
121
                imagefill($new_image, 0, 0, $transparent);
100
                imagefill($new_image, 0, 0, $transparent);
122
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
101
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
Línea 123... Línea 102...
123
                
102
                
124
                    
103
                    
Línea 125... Línea -...
125
                $temp_filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $target_filename;
-
 
126
                imagepng($new_image, $temp_filename);
-
 
Línea 127... Línea -...
127
 
-
 
128
                $result = $this->storage->putFile($target_path, $target_code, $temp_filename);
-
 
129
                @unlink($temp_filename);
-
 
Línea 130... Línea -...
130
                
-
 
131
                if($unlink_source) {
104
                $temp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $target_filename;
132
                    unlink($source);
-
 
133
                }
105
                imagepng($new_image, $temp_filename);
134
                
106
 
Línea 135... Línea 107...
135
                return $result;
107
                
136
            } else {
108
                
137
            
109
            } else {
138
                return true;
-
 
-
 
110
                $temp_filename = '';
139
            }
111
            }
-
 
112
            
140
            
113
        }
-
 
114
        catch (\Throwable $e)
-
 
115
        {
-
 
116
            
141
        }
117
            $temp_filename = '';
Línea 142... Línea 118...
142
        catch (\Throwable $e)
118
            
143
        {
119
        }
144
            error_log($e->getTraceAsString());
120
        
145
            return false;
-
 
146
        }
-
 
147
    }
121
        @unlink($source);
148
    
-
 
149
    /**
122
        return $temp_filename;
150
     * 
123
    }
151
     * @param string $source
124
    
152
     * @param string $target_path
125
    /**
-
 
126
     * 
153
     * @param string $target_code
127
     * @param string $source
154
     * @param string $target_filename
-
 
155
     * @param boolean $unlink_source
-
 
156
     * @return boolean
128
     * @param string $target_filename
157
     */
129
     * @return boolean
158
    public function uploadImageRaw($source, $target_path, $target_code, $target_filename, $unlink_source)
-
 
159
    {
-
 
160
        
130
     */
Línea 161... Línea 131...
161
        
131
    public function uploadProcessWithOutChangeSize($source, $target_filename)
Línea 162... Línea 132...
162
        
132
    {
163
        try {
133
        $temp_filename = '';
Línea 197... Línea 167...
197
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
167
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
198
                imagefill($new_image, 0, 0, $transparent);
168
                imagefill($new_image, 0, 0, $transparent);
199
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
169
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
Línea 200... Línea -...
200
                
-
 
201
                
-
 
202
                $target = $target_path . DIRECTORY_SEPARATOR . $target_filename;
-
 
203
                if(file_exists($target)) {
-
 
-
 
170
                
Línea 204... Línea 171...
204
                    @unlink($target);
171
                
205
                }
172
       
Línea 206... Línea -...
206
                
-
 
207
                $temp_filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $target_filename;
-
 
Línea -... Línea 173...
-
 
173
                
208
                imagepng($new_image, $temp_filename);
174
                $temp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $target_filename;
209
                
175
                imagepng($new_image, $temp_filename);
Línea 210... Línea -...
210
                $result = $this->storage->putFile($target_path, $target_code, $temp_filename);
-
 
211
                unlink($temp_filename);
-
 
212
                
-
 
213
                
176
                
214
                return $result;
177
                
215
            }
178
                
216
            
-
 
-
 
179
            } else {
217
            
180
                $temp_filename = '';
-
 
181
            }
218
            return true;
182
            
-
 
183
        }
-
 
184
        catch (\Throwable $e)
-
 
185
        {
-
 
186
            
219
            
187
            $temp_filename = '';
220
        }
188
            
221
        catch (\Throwable $e)
189
        }