Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 17015 Rev 17018
Línea 9... Línea 9...
9
     *
9
     *
10
     * @var \LeadersLinked\Library\Image
10
     * @var \LeadersLinked\Library\Image
11
     */
11
     */
12
    private static $_instance;
12
    private static $_instance;
Línea 13... Línea -...
13
    
-
 
14
    /**
-
 
15
     *
-
 
16
     * @var \LeadersLinked\Library\Storage
-
 
17
     */
-
 
Línea 18... Línea 13...
18
    private $storage;
13
    
19
    
14
    
20
    /**
15
    /**
21
     * 
16
     *
22
     * @var array
17
     * @var array
23
     */
18
     */
24
    private $config;
19
    private $config;
25
    
20
 
26
    /**
21
     /**
27
     *
22
     * 
28
     * @param array $config
23
     * @param array $config
29
     */
24
     */
30
    private function __construct($config)
25
    private function __construct($config) 
31
    {
-
 
32
        $this->config = $config;
26
    {
Línea 33... Línea 27...
33
        $this->storage = Storage::getInstance($config);
27
        $this->config       = $config;
34
    }
28
    }
35
    
29
    
Línea 45... Línea 39...
45
        }
39
        }
Línea 46... Línea 40...
46
        
40
        
47
        return self::$_instance;
41
        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;
42
    }
Línea 57... Línea 43...
57
    }
43
    
58
    
44
 
59
   
45
   
60
    
-
 
61
    /**
-
 
62
     * 
46
    
63
     * @param string $source
47
    /**
64
     * @param string $target_path
48
     * 
65
     * @param string $target_code
49
     * @param string $source
66
     * @param string $target_filename
-
 
67
     * @param number $target_width
50
     * @param string $target_filename
68
     * @param number $target_height
51
     * @param number $target_width
69
     * @param boolean $crop_to_dimensions
52
     * @param number $target_height
70
     * @param boolean $unlink_source
53
     * @param boolean $crop_to_dimensions
71
     * @return boolean
-
 
-
 
54
     * @return boolean
Línea 72... Línea 55...
72
     */
55
     */
Línea 73... Línea 56...
73
    public function uploadImageChangeSize($source, $target_path, $target_code, $target_filename, $target_width, $target_height,  $crop_to_dimensions, $unlink_source)
56
    public function uploadProcessChangeSize($source, $target_filename, $target_width, $target_height,  $crop_to_dimensions)
Línea 119... Línea 102...
119
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
102
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
120
                imagefill($new_image, 0, 0, $transparent);
103
                imagefill($new_image, 0, 0, $transparent);
121
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
104
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
Línea 122... Línea 105...
122
                
105
                
123
                    
106
                    
124
                $temp_filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $target_filename;
107
                $temp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $target_filename;
125
                imagepng($new_image, $temp_filename);
-
 
126
                
-
 
127
                $result = $this->storage->putFile($target_path, $target_code, $temp_filename);
-
 
128
                unlink($temp_filename);
-
 
129
                
-
 
130
                
-
 
131
                if($unlink_source) {
-
 
132
                    @unlink($source);
-
 
Línea 133... Línea -...
133
                }
-
 
134
                
108
                imagepng($new_image, $temp_filename);
135
                
-
 
136
                
-
 
137
                return $result;
-
 
138
            } else {
-
 
139
                
-
 
140
                
-
 
141
                if($unlink_source) {
-
 
142
                    @unlink($source);
109
 
143
                }
110
                
Línea 144... Línea 111...
144
                
111
                
145
            
112
            } else {
146
                return true;
113
                $temp_filename = '';
Línea 147... Línea -...
147
            }
-
 
148
            
114
            }
149
        }
-
 
150
        catch (\Throwable $e)
-
 
Línea 151... Línea -...
151
        {
-
 
152
            
-
 
153
            if($unlink_source) {
115
            
-
 
116
        }
-
 
117
        catch (\Throwable $e)
-
 
118
        {
154
                @unlink($source);
119
            
Línea 155... Línea 120...
155
            }
120
            $temp_filename = '';
156
            
121
            
157
            
122
        }
158
            error_log($e->getTraceAsString());
-
 
159
            return false;
-
 
160
        }
123
        
161
    }
-
 
162
    
124
        @unlink($source);
163
    /**
125
        return $temp_filename;
164
     * 
126
    }
165
     * @param string $source
127
    
-
 
128
    /**
166
     * @param string $target_path
129
     * 
167
     * @param string $target_code
-
 
168
     * @param string $target_filename
-
 
169
     * @param boolean $unlink_source
130
     * @param string $source
170
     * @return boolean
131
     * @param string $target_filename
Línea 171... Línea 132...
171
     */
132
     * @return boolean
Línea 209... Línea 170...
209
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
170
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
210
                imagefill($new_image, 0, 0, $transparent);
171
                imagefill($new_image, 0, 0, $transparent);
211
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
172
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
Línea 212... Línea -...
212
                
-
 
213
                
-
 
214
                $target = $target_path . DIRECTORY_SEPARATOR . $target_filename;
-
 
215
                if(file_exists($target)) {
-
 
-
 
173
                
Línea 216... Línea 174...
216
                    @unlink($target);
174
                
217
                }
175
       
Línea 218... Línea -...
218
                
-
 
219
                $temp_filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $target_filename;
-
 
Línea 220... Línea -...
220
                imagepng($new_image, $temp_filename);
-
 
221
                
-
 
222
                $result = $this->storage->putFile($target_path, $target_code, $temp_filename);
-
 
Línea 223... Línea -...
223
                unlink($temp_filename);
-
 
224
                
176
                
225
                if($unlink_source) {
-
 
226
                    unlink($source);
-
 
227
                }
177
                $temp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $target_filename;
228
                
178
                imagepng($new_image, $temp_filename);
Línea 229... Línea -...
229
                return $result;
-
 
230
            }
-
 
231
            
-
 
232
            if($unlink_source) {
179
                
233
                unlink($source);
180
                
234
            }
181
                
235
            
-
 
236
            
-
 
237
            return true;
-
 
Línea 238... Línea -...
238
            
-
 
239
        }
182
            } else {
-
 
183
                $temp_filename = '';
240
        catch (\Throwable $e)
184
            }
-
 
185
            
-
 
186
        }
-
 
187
        catch (\Throwable $e)
-
 
188
        {
241
        {
189
            
242
            if($unlink_source) {
190
            $temp_filename = '';
243
                unlink($source);
191