@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @param Media|null $media Reference media object |
71 | 71 | */ |
72 | - public function __construct(Media $media = null){ |
|
72 | + public function __construct(Media $media = null) { |
|
73 | 73 | $this->media = $media; |
74 | 74 | $this->use_ttf = function_exists('imagettftext'); |
75 | 75 | $this->expire_offset = 3600 * 24; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return ImageBuilder |
96 | 96 | */ |
97 | 97 | public function setExpireOffset($expireOffset) { |
98 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
98 | + if ($expireOffset) $this->expire_offset = $expireOffset; |
|
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return ImageBuilder |
116 | 116 | */ |
117 | 117 | public function setShowWatermark($show_watermark) { |
118 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
118 | + if (!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return ImageBuilder |
127 | 127 | */ |
128 | 128 | public function setFontMaxSize($font_max_size) { |
129 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
129 | + if ($font_max_size) $this->font_max_size = $font_max_size; |
|
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return ImageBuilder |
138 | 138 | */ |
139 | 139 | public function setFontColor($font_color) { |
140 | - if($font_color) $this->font_color = $font_color; |
|
140 | + if ($font_color) $this->font_color = $font_color; |
|
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
@@ -148,32 +148,32 @@ discard block |
||
148 | 148 | * @return ImageBuilder |
149 | 149 | */ |
150 | 150 | public function setAsAttachment($is_attachement) { |
151 | - if(is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
151 | + if (is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Render the image to the output. |
157 | 157 | */ |
158 | - public function render(){ |
|
158 | + public function render() { |
|
159 | 159 | |
160 | 160 | if (!$this->media || !$this->media->canShow()) { |
161 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
161 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('Missing or private media object.')); |
|
162 | 162 | $this->renderError(); |
163 | 163 | } |
164 | 164 | |
165 | 165 | $serverFilename = $this->media->getServerFilename(); |
166 | 166 | |
167 | 167 | if (!file_exists($serverFilename)) { |
168 | - Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
168 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
169 | 169 | $this->renderError(); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $mimetype = $this->media->mimeType(); |
173 | 173 | $imgsize = $this->media->getImageAttributes(); |
174 | 174 | $filetime = $this->media->getFiletime(); |
175 | - $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
176 | - $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
175 | + $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime).' GMT'; |
|
176 | + $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()).' GMT'; |
|
177 | 177 | |
178 | 178 | $type = Functions::isImageTypeSupported($imgsize['ext']); |
179 | 179 | $usewatermark = false; |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | // add caching headers. allow browser to cache file, but not proxy |
208 | - header('Last-Modified: ' . $filetimeHeader); |
|
209 | - header('ETag: "' . $etag . '"'); |
|
210 | - header('Expires: ' . $expireHeader); |
|
211 | - header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
208 | + header('Last-Modified: '.$filetimeHeader); |
|
209 | + header('ETag: "'.$etag.'"'); |
|
210 | + header('Expires: '.$expireHeader); |
|
211 | + header('Cache-Control: max-age='.$this->getExpireOffset().', s-maxage=0, proxy-revalidate'); |
|
212 | 212 | |
213 | 213 | // if this file is already in the user’s cache, don’t resend it |
214 | 214 | // first check if the if_modified_since param matches |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | |
224 | 224 | // send headers for the image |
225 | 225 | $disposition = $this->as_attachment ? 'attachment' : 'inline'; |
226 | - header('Content-Type: ' . $mimetype); |
|
227 | - header('Content-Disposition: ' . $disposition . '; filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
226 | + header('Content-Type: '.$mimetype); |
|
227 | + header('Content-Disposition: '.$disposition.'; filename="'.addslashes(basename($this->media->getFilename())).'"'); |
|
228 | 228 | |
229 | 229 | if ($usewatermark) { |
230 | 230 | // generate the watermarked image |
231 | - $imCreateFunc = 'imagecreatefrom' . $type; |
|
232 | - $imSendFunc = 'image' . $type; |
|
231 | + $imCreateFunc = 'imagecreatefrom'.$type; |
|
232 | + $imSendFunc = 'image'.$type; |
|
233 | 233 | |
234 | 234 | if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
235 | 235 | $im = $imCreateFunc($serverFilename); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | return; |
243 | 243 | } else { |
244 | 244 | // this image is defective. log it |
245 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
245 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('This media file is broken and cannot be watermarked.').'< in file >'.$serverFilename.'< memory used: '.memory_get_usage()); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $filesize = filesize($serverFilename); |
251 | 251 | |
252 | 252 | // set content-length header, send file |
253 | - header('Content-Length: ' . $filesize); |
|
253 | + header('Content-Length: '.$filesize); |
|
254 | 254 | |
255 | 255 | // Some servers disable fpassthru() and readfile() |
256 | 256 | if (function_exists('readfile')) { |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
281 | 281 | imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
282 | 282 | |
283 | - $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
283 | + $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
284 | 284 | |
285 | 285 | http_response_code(404); |
286 | 286 | header('Content-Type: image/png'); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | protected function applyWatermark($im) { |
299 | 299 | |
300 | 300 | // text to watermark with |
301 | - if(method_exists($this->media, 'getWatermarkText')) { |
|
301 | + if (method_exists($this->media, 'getWatermarkText')) { |
|
302 | 302 | $word1_text = $this->media->getWatermarkText(); |
303 | 303 | } |
304 | 304 | else { |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $word1_text, |
311 | 311 | $this->font_max_size, |
312 | 312 | $this->font_color, |
313 | - WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
313 | + WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, |
|
314 | 314 | 'top', |
315 | 315 | 'left' |
316 | 316 | ); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @param string $hexstr |
430 | 430 | * @return int[] |
431 | 431 | */ |
432 | - protected function hexrgb ($hexstr) |
|
432 | + protected function hexrgb($hexstr) |
|
433 | 433 | { |
434 | 434 | $int = hexdec($hexstr); |
435 | 435 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | function imageTtfTextErrorHandler($errno, $errstr) { |
473 | 473 | // log the error |
474 | - Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
474 | + Log::addErrorLog('Image Builder error: >'.$errno.'/'.$errstr.'< while processing file >'.$this->media->getServerFilename().'<'); |
|
475 | 475 | |
476 | 476 | // change value of useTTF to false so the fallback watermarking can be used. |
477 | 477 | $this->use_ttf = false; |