Passed
Branch feature/2.0 (be78a0)
by Jonathan
11:57
created
src/Webtrees/ImageBuilder.php 1 patch
Indentation   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -22,61 +22,61 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class ImageBuilder {
24 24
     
25
-    /**
26
-     * Reference media
27
-     * @var Media $media
28
-     */
29
-    protected $media;
25
+	/**
26
+	 * Reference media
27
+	 * @var Media $media
28
+	 */
29
+	protected $media;
30 30
     
31
-    /**
32
-     * Use TTF font
33
-     * @var bool $use_ttf
34
-     */
35
-    protected $use_ttf;
31
+	/**
32
+	 * Use TTF font
33
+	 * @var bool $use_ttf
34
+	 */
35
+	protected $use_ttf;
36 36
     
37
-    /**
38
-     * Expiration offset. Default is one day.
39
-     * @var int $expire_offset
40
-     */
41
-    protected $expire_offset;
37
+	/**
38
+	 * Expiration offset. Default is one day.
39
+	 * @var int $expire_offset
40
+	 */
41
+	protected $expire_offset;
42 42
    
43
-    /**
44
-     * Should the certificate display a watermark
45
-     * @var bool $show_watermark
46
-     */
47
-    protected $show_watermark;
43
+	/**
44
+	 * Should the certificate display a watermark
45
+	 * @var bool $show_watermark
46
+	 */
47
+	protected $show_watermark;
48 48
         
49
-    /**
50
-     * Maximum watermark font size. Default is 18.
51
-     * @var int $font_max_size
52
-     */
53
-    protected $font_max_size;
49
+	/**
50
+	 * Maximum watermark font size. Default is 18.
51
+	 * @var int $font_max_size
52
+	 */
53
+	protected $font_max_size;
54 54
     
55
-    /**
56
-     * Watermark font color, in hexadecimal. Default is #4D6DF3.
57
-     * @var string $font_color
58
-     */
59
-    protected $font_color;
55
+	/**
56
+	 * Watermark font color, in hexadecimal. Default is #4D6DF3.
57
+	 * @var string $font_color
58
+	 */
59
+	protected $font_color;
60 60
     
61
-    /**
62
-     * Should the image be rendered as attachment (vs inline)     * 
63
-     * @var bool $as_attachment
64
-     */
65
-    protected $as_attachment;
61
+	/**
62
+	 * Should the image be rendered as attachment (vs inline)     * 
63
+	 * @var bool $as_attachment
64
+	 */
65
+	protected $as_attachment;
66 66
     
67 67
 	/**
68
-	* Contructor for ImageBuilder
69
-	*
70
-	* @param Media|null $media Reference media object
71
-	*/
68
+	 * Contructor for ImageBuilder
69
+	 *
70
+	 * @param Media|null $media Reference media object
71
+	 */
72 72
 	public function __construct(Media $media = null){
73
-	    $this->media = $media;
74
-	    $this->use_ttf = function_exists('imagettftext');
75
-	    $this->expire_offset = 3600 * 24;
76
-	    $this->show_watermark = true;
77
-	    $this->font_max_size = 18;
78
-	    $this->font_color = '#4D6DF3';
79
-	    $this->as_attachment = false;
73
+		$this->media = $media;
74
+		$this->use_ttf = function_exists('imagettftext');
75
+		$this->expire_offset = 3600 * 24;
76
+		$this->show_watermark = true;
77
+		$this->font_max_size = 18;
78
+		$this->font_color = '#4D6DF3';
79
+		$this->as_attachment = false;
80 80
 	}
81 81
 	
82 82
 	/**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @return int
86 86
 	 */
87 87
 	public function getExpireOffset() {
88
-	    return $this->expire_offset;
88
+		return $this->expire_offset;
89 89
 	}
90 90
 	
91 91
 	/**
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	 * @return ImageBuilder
96 96
 	 */
97 97
 	public function setExpireOffset($expireOffset) {
98
-	    if($expireOffset) $this->expire_offset = $expireOffset;
99
-	    return $this;
98
+		if($expireOffset) $this->expire_offset = $expireOffset;
99
+		return $this;
100 100
 	}
101 101
 	
102 102
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @return bool
106 106
 	 */
107 107
 	public function isShowWatermark() {
108
-	    return $this->show_watermark;
108
+		return $this->show_watermark;
109 109
 	}
110 110
 	
111 111
 	/**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @return ImageBuilder
116 116
 	 */
117 117
 	public function setShowWatermark($show_watermark) {
118
-	    if(!is_null($show_watermark)) $this->show_watermark = $show_watermark;
119
-	    return $this;
118
+		if(!is_null($show_watermark)) $this->show_watermark = $show_watermark;
119
+		return $this;
120 120
 	}
121 121
 	
122 122
 	/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
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;
130
-	    return $this;
129
+		if($font_max_size) $this->font_max_size = $font_max_size;
130
+		return $this;
131 131
 	}
132 132
 	
133 133
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 * @return ImageBuilder
138 138
 	 */
139 139
 	public function setFontColor($font_color) {
140
-	    if($font_color) $this->font_color = $font_color;
141
-	    return $this;
140
+		if($font_color) $this->font_color = $font_color;
141
+		return $this;
142 142
 	}
143 143
 	
144 144
 	/**
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @return ImageBuilder
149 149
 	 */
150 150
 	public function setAsAttachment($is_attachement) {
151
-	    if(is_bool($is_attachement)) $this->as_attachment = $is_attachement;
152
-	    return $this;
151
+		if(is_bool($is_attachement)) $this->as_attachment = $is_attachement;
152
+		return $this;
153 153
 	}
154 154
 	
155 155
 	/**
@@ -157,135 +157,135 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function render(){
159 159
 	    
160
-	    if (!$this->media || !$this->media->canShow()) {
161
-	        Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.'));
162
-	        $this->renderError();
163
-	    }
160
+		if (!$this->media || !$this->media->canShow()) {
161
+			Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.'));
162
+			$this->renderError();
163
+		}
164 164
 	    
165
-	    $serverFilename = $this->media->getServerFilename();
165
+		$serverFilename = $this->media->getServerFilename();
166 166
 	    
167
-	    if (!file_exists($serverFilename)) {
168
-	        Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
169
-	        $this->renderError();
170
-	    }
167
+		if (!file_exists($serverFilename)) {
168
+			Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
169
+			$this->renderError();
170
+		}
171 171
 	    
172
-	    $mimetype = $this->media->mimeType();
173
-	    $imgsize = $this->media->getImageAttributes();
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';
172
+		$mimetype = $this->media->mimeType();
173
+		$imgsize = $this->media->getImageAttributes();
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';
177 177
 	    
178
-	    $type = Functions::isImageTypeSupported($imgsize['ext']);
179
-	    $usewatermark = false;
180
-	    // if this image supports watermarks and the watermark module is intalled...
181
-	    if ($type) {
182
-	        $usewatermark = $this->isShowWatermark();
183
-	    }
178
+		$type = Functions::isImageTypeSupported($imgsize['ext']);
179
+		$usewatermark = false;
180
+		// if this image supports watermarks and the watermark module is intalled...
181
+		if ($type) {
182
+			$usewatermark = $this->isShowWatermark();
183
+		}
184 184
 	    
185
-	    // determine whether we have enough memory to watermark this image
186
-	    if ($usewatermark) {
187
-	        if (!FunctionsMedia::hasMemoryForImage($serverFilename)) {
188
-	            // not enough memory to watermark this file
189
-	            $usewatermark = false;
190
-	        }
191
-	    }
185
+		// determine whether we have enough memory to watermark this image
186
+		if ($usewatermark) {
187
+			if (!FunctionsMedia::hasMemoryForImage($serverFilename)) {
188
+				// not enough memory to watermark this file
189
+				$usewatermark = false;
190
+			}
191
+		}
192 192
 	    
193
-	    $etag = $this->media->getEtag();
193
+		$etag = $this->media->getEtag();
194 194
 	    
195
-	    // parse IF_MODIFIED_SINCE header from client
196
-	    $if_modified_since = 'x';
197
-	    if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) {
198
-	        $if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE'));
199
-	    }
195
+		// parse IF_MODIFIED_SINCE header from client
196
+		$if_modified_since = 'x';
197
+		if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) {
198
+			$if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE'));
199
+		}
200 200
 	    
201
-	    // parse IF_NONE_MATCH header from client
202
-	    $if_none_match = 'x';
203
-	    if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) {
204
-	        $if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH'));
205
-	    }
201
+		// parse IF_NONE_MATCH header from client
202
+		$if_none_match = 'x';
203
+		if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) {
204
+			$if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH'));
205
+		}
206 206
 	    
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');
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');
212 212
 	    
213
-	    // if this file is already in the user’s cache, don’t resend it
214
-	    // first check if the if_modified_since param matches
215
-	    if ($if_modified_since === $filetimeHeader) {
216
-	        // then check if the etag matches
217
-	        if ($if_none_match === $etag) {
218
-	            http_response_code(304);
213
+		// if this file is already in the user’s cache, don’t resend it
214
+		// first check if the if_modified_since param matches
215
+		if ($if_modified_since === $filetimeHeader) {
216
+			// then check if the etag matches
217
+			if ($if_none_match === $etag) {
218
+				http_response_code(304);
219 219
 	    
220
-	            return;
221
-	        }
222
-	    }	    
220
+				return;
221
+			}
222
+		}	    
223 223
 
224
-	    // send headers for the image
225
-	    $disposition = $this->as_attachment ? 'attachment' : 'inline';
226
-	    header('Content-Type: ' . $mimetype);
227
-	    header('Content-Disposition: ' . $disposition . '; filename="' . addslashes(basename($this->media->getFilename())) . '"');
224
+		// send headers for the image
225
+		$disposition = $this->as_attachment ? 'attachment' : 'inline';
226
+		header('Content-Type: ' . $mimetype);
227
+		header('Content-Disposition: ' . $disposition . '; filename="' . addslashes(basename($this->media->getFilename())) . '"');
228 228
 	     
229
-	    if ($usewatermark) {
230
-	        // generate the watermarked image
231
-	        $imCreateFunc = 'imagecreatefrom' . $type;
232
-	        $imSendFunc   = 'image' . $type;
229
+		if ($usewatermark) {
230
+			// generate the watermarked image
231
+			$imCreateFunc = 'imagecreatefrom' . $type;
232
+			$imSendFunc   = 'image' . $type;
233 233
 	    
234
-	        if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
235
-	            $im = $imCreateFunc($serverFilename);
236
-	            $im = $this->applyWatermark($im);
234
+			if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
235
+				$im = $imCreateFunc($serverFilename);
236
+				$im = $this->applyWatermark($im);
237 237
 	    	    
238
-	            // send the image
239
-	            $imSendFunc($im);
240
-	            imagedestroy($im);
238
+				// send the image
239
+				$imSendFunc($im);
240
+				imagedestroy($im);
241 241
 	    
242
-	            return;
243
-	        } else {
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());
246
-	        }
247
-	    }
242
+				return;
243
+			} else {
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());
246
+			}
247
+		}
248 248
 	    
249
-	    // determine filesize of image (could be original or watermarked version)
250
-	    $filesize = filesize($serverFilename);
249
+		// determine filesize of image (could be original or watermarked version)
250
+		$filesize = filesize($serverFilename);
251 251
 	    
252
-	    // set content-length header, send file
253
-	    header('Content-Length: ' . $filesize);
252
+		// set content-length header, send file
253
+		header('Content-Length: ' . $filesize);
254 254
 	    
255
-	    // Some servers disable fpassthru() and readfile()
256
-	    if (function_exists('readfile')) {
257
-	        readfile($serverFilename);
258
-	    } else {
259
-	        $fp = fopen($serverFilename, 'rb');
260
-	        if (function_exists('fpassthru')) {
261
-	            fpassthru($fp);
262
-	        } else {
263
-	            while (!feof($fp)) {
264
-	                echo fread($fp, 65536);
265
-	            }
266
-	        }
267
-	        fclose($fp);
268
-	    }	    
255
+		// Some servers disable fpassthru() and readfile()
256
+		if (function_exists('readfile')) {
257
+			readfile($serverFilename);
258
+		} else {
259
+			$fp = fopen($serverFilename, 'rb');
260
+			if (function_exists('fpassthru')) {
261
+				fpassthru($fp);
262
+			} else {
263
+				while (!feof($fp)) {
264
+					echo fread($fp, 65536);
265
+				}
266
+			}
267
+			fclose($fp);
268
+		}	    
269 269
 	}
270 270
 	
271 271
 	/**
272 272
 	 * Render an error as an image.
273 273
 	 */
274 274
 	protected function renderError() {	
275
-	    $error = I18N::translate('The media file was not found in this family tree.');
275
+		$error = I18N::translate('The media file was not found in this family tree.');
276 276
 
277
-    	$width  = (mb_strlen($error) * 6.5 + 50) * 1.15;
278
-    	$height = 60;
279
-    	$im     = imagecreatetruecolor($width, $height); /* Create a black image */
280
-    	$bgc    = imagecolorallocate($im, 255, 255, 255); /* set background color */
281
-    	imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */
277
+		$width  = (mb_strlen($error) * 6.5 + 50) * 1.15;
278
+		$height = 60;
279
+		$im     = imagecreatetruecolor($width, $height); /* Create a black image */
280
+		$bgc    = imagecolorallocate($im, 255, 255, 255); /* set background color */
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
-    	http_response_code(404);
286
-    	header('Content-Type: image/png');
287
-    	imagepng($im);
288
-    	imagedestroy($im);
285
+		http_response_code(404);
286
+		header('Content-Type: image/png');
287
+		imagepng($im);
288
+		imagedestroy($im);
289 289
 	}
290 290
 	
291 291
 	/**
@@ -297,25 +297,25 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	protected function applyWatermark($im) {
299 299
 	    
300
-	    // text to watermark with	    
301
-	    if(method_exists($this->media, 'getWatermarkText')) {
302
-	       $word1_text = $this->media->getWatermarkText();
303
-	    }
304
-	    else {
305
-	        $word1_text = $this->media->getTitle();
306
-	    }
300
+		// text to watermark with	    
301
+		if(method_exists($this->media, 'getWatermarkText')) {
302
+		   $word1_text = $this->media->getWatermarkText();
303
+		}
304
+		else {
305
+			$word1_text = $this->media->getTitle();
306
+		}
307 307
 	
308
-	    $this->embedText(
309
-	        $im, 
310
-	        $word1_text, 
311
-	        $this->font_max_size,
312
-	        $this->font_color,
313
-	        WT_ROOT . Config::FONT_DEJAVU_SANS_TTF,
314
-	        'top', 
315
-	        'left'
316
-	     );
308
+		$this->embedText(
309
+			$im, 
310
+			$word1_text, 
311
+			$this->font_max_size,
312
+			$this->font_color,
313
+			WT_ROOT . Config::FONT_DEJAVU_SANS_TTF,
314
+			'top', 
315
+			'left'
316
+		 );
317 317
 	
318
-	    return ($im);
318
+		return ($im);
319 319
 	}
320 320
 	
321 321
 	/**
@@ -332,94 +332,94 @@  discard block
 block discarded – undo
332 332
 	 */
333 333
 	protected function embedText($im, $text, $maxsize, $color, $font, $vpos, $hpos) {
334 334
 	    
335
-	    // there are two ways to embed text with PHP
336
-	    // (preferred) using GD and FreeType you can embed text using any True Type font
337
-	    // (fall back) if that is not available, you can insert basic monospaced text
335
+		// there are two ways to embed text with PHP
336
+		// (preferred) using GD and FreeType you can embed text using any True Type font
337
+		// (fall back) if that is not available, you can insert basic monospaced text
338 338
 	    
339
-	    $col = $this->hexrgb($color);
340
-	    $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']);
339
+		$col = $this->hexrgb($color);
340
+		$textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']);
341 341
 	    
342
-	    // make adjustments to settings that imagestring and imagestringup can’t handle
343
-	    if (!$this->use_ttf) {
344
-	        // imagestringup only writes up, can’t use top2bottom
345
-	        if ($hpos === 'top2bottom') {
346
-	            $hpos = 'bottom2top';
347
-	        }
348
-	    }
342
+		// make adjustments to settings that imagestring and imagestringup can’t handle
343
+		if (!$this->use_ttf) {
344
+			// imagestringup only writes up, can’t use top2bottom
345
+			if ($hpos === 'top2bottom') {
346
+				$hpos = 'bottom2top';
347
+			}
348
+		}
349 349
 	    
350
-	    $text       = I18N::reverseText($text);
351
-	    $height     = imagesy($im);
352
-	    $width      = imagesx($im);
353
-	    $calc_angle = rad2deg(atan($height / $width));
354
-	    $hypoth     = $height / sin(deg2rad($calc_angle));
350
+		$text       = I18N::reverseText($text);
351
+		$height     = imagesy($im);
352
+		$width      = imagesx($im);
353
+		$calc_angle = rad2deg(atan($height / $width));
354
+		$hypoth     = $height / sin(deg2rad($calc_angle));
355 355
 	    
356
-	    // vertical and horizontal position of the text
357
-	    switch ($vpos) {
358
-	        default:
359
-	        case 'top':
360
-	            $taille   = $this->textLength($maxsize, $width, $text);
361
-	            $pos_y    = $height * 0.15 + $taille;
362
-	            $pos_x    = $width * 0.15;
363
-	            $rotation = 0;
364
-	            break;
365
-	        case 'middle':
366
-	            $taille   = $this->textLength($maxsize, $width, $text);
367
-	            $pos_y    = ($height + $taille) / 2;
368
-	            $pos_x    = $width * 0.15;
369
-	            $rotation = 0;
370
-	            break;
371
-	        case 'bottom':
372
-	            $taille   = $this->textLength($maxsize, $width, $text);
373
-	            $pos_y    = ($height * .85 - $taille);
374
-	            $pos_x    = $width * 0.15;
375
-	            $rotation = 0;
376
-	            break;
377
-	        case 'across':
378
-	            switch ($hpos) {
379
-	                default:
380
-	                case 'left':
381
-	                    $taille   = $this->textLength($maxsize, $hypoth, $text);
382
-	                    $pos_y    = ($height * .85 - $taille);
383
-	                    $pos_x    = $width * 0.15;
384
-	                    $rotation = $calc_angle;
385
-	                    break;
386
-	                case 'right':
387
-	                    $taille   = $this->textLength($maxsize, $hypoth, $text);
388
-	                    $pos_y    = ($height * .15 - $taille);
389
-	                    $pos_x    = $width * 0.85;
390
-	                    $rotation = $calc_angle + 180;
391
-	                    break;
392
-	                case 'top2bottom':
393
-	                    $taille   = $this->textLength($maxsize, $height, $text);
394
-	                    $pos_y    = ($height * .15 - $taille);
395
-	                    $pos_x    = ($width * .90 - $taille);
396
-	                    $rotation = -90;
397
-	                    break;
398
-	                case 'bottom2top':
399
-	                    $taille   = $this->textLength($maxsize, $height, $text);
400
-	                    $pos_y    = $height * 0.85;
401
-	                    $pos_x    = $width * 0.15;
402
-	                    $rotation = 90;
403
-	                    break;
404
-	            }
405
-	            break;
406
-	    }
356
+		// vertical and horizontal position of the text
357
+		switch ($vpos) {
358
+			default:
359
+			case 'top':
360
+				$taille   = $this->textLength($maxsize, $width, $text);
361
+				$pos_y    = $height * 0.15 + $taille;
362
+				$pos_x    = $width * 0.15;
363
+				$rotation = 0;
364
+				break;
365
+			case 'middle':
366
+				$taille   = $this->textLength($maxsize, $width, $text);
367
+				$pos_y    = ($height + $taille) / 2;
368
+				$pos_x    = $width * 0.15;
369
+				$rotation = 0;
370
+				break;
371
+			case 'bottom':
372
+				$taille   = $this->textLength($maxsize, $width, $text);
373
+				$pos_y    = ($height * .85 - $taille);
374
+				$pos_x    = $width * 0.15;
375
+				$rotation = 0;
376
+				break;
377
+			case 'across':
378
+				switch ($hpos) {
379
+					default:
380
+					case 'left':
381
+						$taille   = $this->textLength($maxsize, $hypoth, $text);
382
+						$pos_y    = ($height * .85 - $taille);
383
+						$pos_x    = $width * 0.15;
384
+						$rotation = $calc_angle;
385
+						break;
386
+					case 'right':
387
+						$taille   = $this->textLength($maxsize, $hypoth, $text);
388
+						$pos_y    = ($height * .15 - $taille);
389
+						$pos_x    = $width * 0.85;
390
+						$rotation = $calc_angle + 180;
391
+						break;
392
+					case 'top2bottom':
393
+						$taille   = $this->textLength($maxsize, $height, $text);
394
+						$pos_y    = ($height * .15 - $taille);
395
+						$pos_x    = ($width * .90 - $taille);
396
+						$rotation = -90;
397
+						break;
398
+					case 'bottom2top':
399
+						$taille   = $this->textLength($maxsize, $height, $text);
400
+						$pos_y    = $height * 0.85;
401
+						$pos_x    = $width * 0.15;
402
+						$rotation = 90;
403
+						break;
404
+				}
405
+				break;
406
+		}
407 407
 	    
408
-	    // apply the text
409
-	    if ($this->use_ttf) {
410
-	        // if imagettftext throws errors, catch them with a custom error handler
411
-	        set_error_handler(array($this, 'imageTtfTextErrorHandler'));
412
-	        imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text);
413
-	        restore_error_handler();
414
-	    }
415
-	    // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false
416
-	    if (!$this->use_ttf) {
417
-	        if ($rotation !== 90) {
418
-	            imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor);
419
-	        } else {
420
-	            imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor);
421
-	        }
422
-	    }
408
+		// apply the text
409
+		if ($this->use_ttf) {
410
+			// if imagettftext throws errors, catch them with a custom error handler
411
+			set_error_handler(array($this, 'imageTtfTextErrorHandler'));
412
+			imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text);
413
+			restore_error_handler();
414
+		}
415
+		// Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false
416
+		if (!$this->use_ttf) {
417
+			if ($rotation !== 90) {
418
+				imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor);
419
+			} else {
420
+				imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor);
421
+			}
422
+		}
423 423
 	
424 424
 	}
425 425
 	
@@ -431,53 +431,53 @@  discard block
 block discarded – undo
431 431
 	 */
432 432
 	protected function hexrgb ($hexstr)
433 433
 	{
434
-	    $int = hexdec($hexstr);
434
+		$int = hexdec($hexstr);
435 435
 	
436
-	    return array('red' => 0xFF & ($int >> 0x10),
437
-	        'green' => 0xFF & ($int >> 0x8),
438
-	        'blue' => 0xFF & $int);
436
+		return array('red' => 0xFF & ($int >> 0x10),
437
+			'green' => 0xFF & ($int >> 0x8),
438
+			'blue' => 0xFF & $int);
439 439
 	}
440 440
 	
441
-    /**
442
-     * Generate an approximate length of text, in pixels.
443
-     *
444
-     * @param int    $t
445
-     * @param int    $mxl
446
-     * @param string $text
447
-     *
448
-     * @return int
449
-     */
450
-    function textLength($t, $mxl, $text) {
451
-    	$taille_c = $t;
452
-    	$len      = mb_strlen($text);
453
-    	while (($taille_c - 2) * $len > $mxl) {
454
-    		$taille_c--;
455
-    		if ($taille_c == 2) {
456
-    			break;
457
-    		}
458
-    	}
441
+	/**
442
+	 * Generate an approximate length of text, in pixels.
443
+	 *
444
+	 * @param int    $t
445
+	 * @param int    $mxl
446
+	 * @param string $text
447
+	 *
448
+	 * @return int
449
+	 */
450
+	function textLength($t, $mxl, $text) {
451
+		$taille_c = $t;
452
+		$len      = mb_strlen($text);
453
+		while (($taille_c - 2) * $len > $mxl) {
454
+			$taille_c--;
455
+			if ($taille_c == 2) {
456
+				break;
457
+			}
458
+		}
459 459
     
460
-    	return $taille_c;
461
-    }
460
+		return $taille_c;
461
+	}
462 462
     
463
-    /**
464
-     * imagettftext is the function that is most likely to throw an error
465
-     * use this custom error handler to catch and log it
466
-     *
467
-     * @param int    $errno
468
-     * @param string $errstr
469
-     *
470
-     * @return bool
471
-     */
472
-    function imageTtfTextErrorHandler($errno, $errstr) {
473
-        // log the error
474
-        Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<');
463
+	/**
464
+	 * imagettftext is the function that is most likely to throw an error
465
+	 * use this custom error handler to catch and log it
466
+	 *
467
+	 * @param int    $errno
468
+	 * @param string $errstr
469
+	 *
470
+	 * @return bool
471
+	 */
472
+	function imageTtfTextErrorHandler($errno, $errstr) {
473
+		// log the error
474
+		Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<');
475 475
     
476
-        // change value of useTTF to false so the fallback watermarking can be used.
477
-        $this->use_ttf = false;
476
+		// change value of useTTF to false so the fallback watermarking can be used.
477
+		$this->use_ttf = false;
478 478
     
479
-        return true;
480
-    }
479
+		return true;
480
+	}
481 481
 		
482 482
 }
483 483
 
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php 1 patch
Indentation   +329 added lines, -329 removed lines patch added patch discarded remove patch
@@ -21,130 +21,130 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class GeoAnalysisProvider {
23 23
     
24
-    /**
25
-     * Reference tree
26
-     * @var Tree $tree
27
-     */
28
-    protected $tree;
24
+	/**
25
+	 * Reference tree
26
+	 * @var Tree $tree
27
+	 */
28
+	protected $tree;
29 29
     
30
-    /**
31
-     * Cached hierarchy of places in the Gedcom file.
32
-     * 
33
-     * @var (array|null) $place_hierarchy
34
-     */
35
-    protected $place_hierarchy;
30
+	/**
31
+	 * Cached hierarchy of places in the Gedcom file.
32
+	 * 
33
+	 * @var (array|null) $place_hierarchy
34
+	 */
35
+	protected $place_hierarchy;
36 36
     
37
-    /**
38
-     * Constructor for GeoAnalysis Provider.
39
-     * A provider is defined in relation to a specific tree.
40
-     *
41
-     * @param Tree $tree
42
-     */
43
-    public function __construct(Tree $tree) {
44
-        $this->tree = $tree;
45
-        $this->place_hierarchy = null;
46
-    }
37
+	/**
38
+	 * Constructor for GeoAnalysis Provider.
39
+	 * A provider is defined in relation to a specific tree.
40
+	 *
41
+	 * @param Tree $tree
42
+	 */
43
+	public function __construct(Tree $tree) {
44
+		$this->tree = $tree;
45
+		$this->place_hierarchy = null;
46
+	}
47 47
     
48
-    /**
49
-     * Creates and returns a GeoAnalysis object from a data row.
50
-     * The row data is expected to be an array with the indexes:
51
-     *  - majgd_id: geodispersion analysis ID
52
-     *  - majgd_descr: geodispersion analysis description/title
53
-     *  - majgd_sublevel: Analysis level
54
-     *  - majgd_useflagsgen: Use flags in places display
55
-     *  - majgd_detailsgen: Number of top places
56
-     *  - majgd_map: file name of the map
57
-     *  - majgd_toplevel: parent level for the map
58
-     * 
59
-     * @param array $row
60
-     * @return GeoAnalysis
61
-     */
62
-    protected function loadGeoAnalysisFromRow($row) {
63
-        $options = new GeoDisplayOptions();
64
-        $options
65
-        ->setUsingFlags($row['majgd_useflagsgen'] == 'yes')
66
-        ->setMaxDetailsInGen($row['majgd_detailsgen']);
48
+	/**
49
+	 * Creates and returns a GeoAnalysis object from a data row.
50
+	 * The row data is expected to be an array with the indexes:
51
+	 *  - majgd_id: geodispersion analysis ID
52
+	 *  - majgd_descr: geodispersion analysis description/title
53
+	 *  - majgd_sublevel: Analysis level
54
+	 *  - majgd_useflagsgen: Use flags in places display
55
+	 *  - majgd_detailsgen: Number of top places
56
+	 *  - majgd_map: file name of the map
57
+	 *  - majgd_toplevel: parent level for the map
58
+	 * 
59
+	 * @param array $row
60
+	 * @return GeoAnalysis
61
+	 */
62
+	protected function loadGeoAnalysisFromRow($row) {
63
+		$options = new GeoDisplayOptions();
64
+		$options
65
+		->setUsingFlags($row['majgd_useflagsgen'] == 'yes')
66
+		->setMaxDetailsInGen($row['majgd_detailsgen']);
67 67
         
68
-        if($row['majgd_map']) {
69
-            $options
70
-            ->setMap(new OutlineMap($row['majgd_map']))
71
-            ->setMapLevel($row['majgd_toplevel']);
72
-        }
68
+		if($row['majgd_map']) {
69
+			$options
70
+			->setMap(new OutlineMap($row['majgd_map']))
71
+			->setMapLevel($row['majgd_toplevel']);
72
+		}
73 73
         
74
-        $enabled = true;
75
-        if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
76
-            $enabled = false;
77
-        }
74
+		$enabled = true;
75
+		if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
76
+			$enabled = false;
77
+		}
78 78
         
79
-        return new GeoAnalysis(
80
-            $this->tree,
81
-            $row['majgd_id'],
82
-            $row['majgd_descr'],
83
-            $row['majgd_sublevel'],
84
-            $options,
85
-            $enabled
86
-            );
87
-    }
79
+		return new GeoAnalysis(
80
+			$this->tree,
81
+			$row['majgd_id'],
82
+			$row['majgd_descr'],
83
+			$row['majgd_sublevel'],
84
+			$options,
85
+			$enabled
86
+			);
87
+	}
88 88
     
89
-    /**
90
-     * Returns the number of geographical analysis (active and inactive). 
91
-     * 
92
-     * @return int
93
-     */
94
-    public function getGeoAnalysisCount() {
95
-        return Database::prepare(
96
-            'SELECT COUNT(majgd_id)' .
97
-            ' FROM `##maj_geodispersion`' .
98
-            ' WHERE majgd_file = :gedcom_id'
99
-            )->execute(array(
100
-                'gedcom_id' => $this->tree->getTreeId()
101
-            ))->fetchOne();
102
-    }
89
+	/**
90
+	 * Returns the number of geographical analysis (active and inactive). 
91
+	 * 
92
+	 * @return int
93
+	 */
94
+	public function getGeoAnalysisCount() {
95
+		return Database::prepare(
96
+			'SELECT COUNT(majgd_id)' .
97
+			' FROM `##maj_geodispersion`' .
98
+			' WHERE majgd_file = :gedcom_id'
99
+			)->execute(array(
100
+				'gedcom_id' => $this->tree->getTreeId()
101
+			))->fetchOne();
102
+	}
103 103
     
104
-    /**
105
-     * Get a geographical analysis by its ID.
106
-     * The function can only search for only enabled analysis, or all.
107
-     * 
108
-     * @param int $id geodispersion analysis ID
109
-     * @param bool $only_enabled Search for only enabled geodispersion analysis
110
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL
111
-     */
112
-    public function getGeoAnalysis($id, $only_enabled = true) {
113
-        $args = array (
114
-            'gedcom_id' => $this->tree->getTreeId(),
115
-            'ga_id' => $id
116
-        );
104
+	/**
105
+	 * Get a geographical analysis by its ID.
106
+	 * The function can only search for only enabled analysis, or all.
107
+	 * 
108
+	 * @param int $id geodispersion analysis ID
109
+	 * @param bool $only_enabled Search for only enabled geodispersion analysis
110
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL
111
+	 */
112
+	public function getGeoAnalysis($id, $only_enabled = true) {
113
+		$args = array (
114
+			'gedcom_id' => $this->tree->getTreeId(),
115
+			'ga_id' => $id
116
+		);
117 117
         
118
-        $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
119
-            ' FROM `##maj_geodispersion`' .
120
-            ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id';
121
-        if($only_enabled) {
122
-            $sql .= ' AND majgd_status = :status';
123
-            $args['status'] = 'enabled';
124
-        }
125
-        $sql .= ' ORDER BY majgd_descr';
118
+		$sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
119
+			' FROM `##maj_geodispersion`' .
120
+			' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id';
121
+		if($only_enabled) {
122
+			$sql .= ' AND majgd_status = :status';
123
+			$args['status'] = 'enabled';
124
+		}
125
+		$sql .= ' ORDER BY majgd_descr';
126 126
         
127
-        $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
127
+		$ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
128 128
         
129
-        if($ga_array) {
130
-            return $this->loadGeoAnalysisFromRow($ga_array);
131
-        }
129
+		if($ga_array) {
130
+			return $this->loadGeoAnalysisFromRow($ga_array);
131
+		}
132 132
         
133
-        return null;            
134
-    }
133
+		return null;            
134
+	}
135 135
     
136
-    /**
137
-     * Add a new geodispersion analysis in the database, in a transactional manner.
138
-     * When successful, eturns the newly created GeoAnalysis object.
139
-     * 
140
-     * @param string $description geodispersion analysis title
141
-     * @param int $analysis_level Analysis level
142
-     * @param string $map_file Filename of the map
143
-     * @param int $map_top_level Parent level of the map
144
-     * @param bool $use_flags Use flag in the place display
145
-     * @param int $gen_details Number of top places to display
146
-     * @return GeoAnalysis
147
-     */
136
+	/**
137
+	 * Add a new geodispersion analysis in the database, in a transactional manner.
138
+	 * When successful, eturns the newly created GeoAnalysis object.
139
+	 * 
140
+	 * @param string $description geodispersion analysis title
141
+	 * @param int $analysis_level Analysis level
142
+	 * @param string $map_file Filename of the map
143
+	 * @param int $map_top_level Parent level of the map
144
+	 * @param bool $use_flags Use flag in the place display
145
+	 * @param int $gen_details Number of top places to display
146
+	 * @return GeoAnalysis
147
+	 */
148 148
 	public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) {
149 149
 		try{
150 150
 			Database::beginTransaction();
@@ -174,17 +174,17 @@  discard block
 block discarded – undo
174 174
 			Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage());
175 175
 		}
176 176
 		return $ga;
177
-    }
177
+	}
178 178
 	
179
-    /**
180
-     * Update a geodispersion analysis in the database, in transactional manner.
181
-     * When successful, returns the updated GeoAnalysis object
182
-     *  
183
-     * @param GeoAnalysis $ga
184
-     * @return GeoAnalysis
185
-     */
186
-    public function updateGeoAnalysis(GeoAnalysis $ga) {
187
-        try {
179
+	/**
180
+	 * Update a geodispersion analysis in the database, in transactional manner.
181
+	 * When successful, returns the updated GeoAnalysis object
182
+	 *  
183
+	 * @param GeoAnalysis $ga
184
+	 * @return GeoAnalysis
185
+	 */
186
+	public function updateGeoAnalysis(GeoAnalysis $ga) {
187
+		try {
188 188
 			Database::beginTransaction();
189 189
 		
190 190
 			Database::prepare(
@@ -217,239 +217,239 @@  discard block
 block discarded – undo
217 217
 			$ga = null;
218 218
 		}
219 219
 		return $ga;
220
-    }
220
+	}
221 221
     
222
-    /**
223
-     * Set the status of a specific analysis.
224
-     * The status can be enabled (true), or disabled (false).
225
-     * 
226
-     * @param GeoAnalysis $ga
227
-     * @param bool $status
228
-     */
229
-    public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) {
230
-        Database::prepare(
231
-            'UPDATE `##maj_geodispersion`'.
232
-            ' SET majgd_status = :status'.
233
-            ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
234
-        )->execute(array(
235
-                'gedcom_id' => $this->tree->getTreeId(),
236
-                'status' => $status ? 'enabled' : 'disabled',
237
-                'ga_id' => $ga->getId()
238
-        ));
239
-    }
222
+	/**
223
+	 * Set the status of a specific analysis.
224
+	 * The status can be enabled (true), or disabled (false).
225
+	 * 
226
+	 * @param GeoAnalysis $ga
227
+	 * @param bool $status
228
+	 */
229
+	public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) {
230
+		Database::prepare(
231
+			'UPDATE `##maj_geodispersion`'.
232
+			' SET majgd_status = :status'.
233
+			' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
234
+		)->execute(array(
235
+				'gedcom_id' => $this->tree->getTreeId(),
236
+				'status' => $status ? 'enabled' : 'disabled',
237
+				'ga_id' => $ga->getId()
238
+		));
239
+	}
240 240
     
241
-    /**
242
-     * Delete a geodispersion analysis from the database.
243
-     * 
244
-     * @param GeoAnalysis $ga
245
-     */
246
-    public function deleteGeoAnalysis(GeoAnalysis $ga) {
247
-        Database::prepare(
248
-            'DELETE FROM `##maj_geodispersion`'.
249
-            ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
250
-            )->execute(array(
251
-                'gedcom_id' => $this->tree->getTreeId(),
252
-                'ga_id' => $ga->getId()
253
-            ));
254
-    }
241
+	/**
242
+	 * Delete a geodispersion analysis from the database.
243
+	 * 
244
+	 * @param GeoAnalysis $ga
245
+	 */
246
+	public function deleteGeoAnalysis(GeoAnalysis $ga) {
247
+		Database::prepare(
248
+			'DELETE FROM `##maj_geodispersion`'.
249
+			' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
250
+			)->execute(array(
251
+				'gedcom_id' => $this->tree->getTreeId(),
252
+				'ga_id' => $ga->getId()
253
+			));
254
+	}
255 255
         
256
-    /**
257
-     * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM
258
-     *
259
-     * @return array List of enabled maps
260
-     */
261
-    public function getGeoAnalysisList(){
262
-        $res = array();
256
+	/**
257
+	 * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM
258
+	 *
259
+	 * @return array List of enabled maps
260
+	 */
261
+	public function getGeoAnalysisList(){
262
+		$res = array();
263 263
         
264
-        $list = Database::prepare(
265
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' .
266
-            ' FROM `##maj_geodispersion`' .
267
-            ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'.
268
-            ' ORDER BY majgd_descr'
269
-        )->execute(array(
270
-            'gedcom_id' => $this->tree->getTreeId(),
271
-            'status' => 'enabled'
272
-        ))->fetchAll(\PDO::FETCH_ASSOC);
264
+		$list = Database::prepare(
265
+			'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' .
266
+			' FROM `##maj_geodispersion`' .
267
+			' WHERE majgd_file = :gedcom_id AND majgd_status = :status'.
268
+			' ORDER BY majgd_descr'
269
+		)->execute(array(
270
+			'gedcom_id' => $this->tree->getTreeId(),
271
+			'status' => 'enabled'
272
+		))->fetchAll(\PDO::FETCH_ASSOC);
273 273
         
274
-        foreach($list as $ga) {
275
-           $res[] = $this->loadGeoAnalysisFromRow($ga);
276
-        }
274
+		foreach($list as $ga) {
275
+		   $res[] = $this->loadGeoAnalysisFromRow($ga);
276
+		}
277 277
         
278
-        return $res;
279
-    }
278
+		return $res;
279
+	}
280 280
     
281
-    /**
282
-     * Return the list of geodispersion analysis matching specified criterias.
283
-     * 
284
-     * @param string $search Search criteria in analysis description
285
-     * @param array $order_by Columns to order by
286
-     * @param int $start Offset to start with (for pagination)
287
-     * @param int|null $limit Max number of items to return (for pagination)
288
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
289
-     */
290
-    public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){
291
-        $res = array();
281
+	/**
282
+	 * Return the list of geodispersion analysis matching specified criterias.
283
+	 * 
284
+	 * @param string $search Search criteria in analysis description
285
+	 * @param array $order_by Columns to order by
286
+	 * @param int $start Offset to start with (for pagination)
287
+	 * @param int|null $limit Max number of items to return (for pagination)
288
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
289
+	 */
290
+	public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){
291
+		$res = array();
292 292
             
293
-        $sql = 
294
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
295
-            ' FROM `##maj_geodispersion`' .
296
-            ' WHERE majgd_file = :gedcom_id';
293
+		$sql = 
294
+			'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
295
+			' FROM `##maj_geodispersion`' .
296
+			' WHERE majgd_file = :gedcom_id';
297 297
         
298
-        $args = array('gedcom_id'=> $this->tree->getTreeId());
298
+		$args = array('gedcom_id'=> $this->tree->getTreeId());
299 299
         
300
-        if($search) {
301
-            $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')';
302
-            $args['search'] = $search;
303
-        }
300
+		if($search) {
301
+			$sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')';
302
+			$args['search'] = $search;
303
+		}
304 304
         
305
-        if ($order_by) {
306
-            $sql .= ' ORDER BY ';
307
-            foreach ($order_by as $key => $value) {
308
-                if ($key > 0) {
309
-                    $sql .= ',';
310
-                }
305
+		if ($order_by) {
306
+			$sql .= ' ORDER BY ';
307
+			foreach ($order_by as $key => $value) {
308
+				if ($key > 0) {
309
+					$sql .= ',';
310
+				}
311 311
                 
312
-                switch ($value['dir']) {
313
-                    case 'asc':
314
-                        $sql .= $value['column'] . ' ASC ';
315
-                        break;
316
-                    case 'desc':
317
-                        $sql .= $value['column'] . ' DESC ';
318
-                        break;
319
-                }
320
-            }
321
-        } else {
322
-            $sql .= ' ORDER BY majgd_descr ASC';
323
-        }
312
+				switch ($value['dir']) {
313
+					case 'asc':
314
+						$sql .= $value['column'] . ' ASC ';
315
+						break;
316
+					case 'desc':
317
+						$sql .= $value['column'] . ' DESC ';
318
+						break;
319
+				}
320
+			}
321
+		} else {
322
+			$sql .= ' ORDER BY majgd_descr ASC';
323
+		}
324 324
         
325
-        if ($limit) {
326
-            $sql .= " LIMIT :limit OFFSET :offset";
327
-            $args['limit']  = $limit;
328
-            $args['offset'] = $start;
329
-        }
325
+		if ($limit) {
326
+			$sql .= " LIMIT :limit OFFSET :offset";
327
+			$args['limit']  = $limit;
328
+			$args['offset'] = $start;
329
+		}
330 330
             
331
-        $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
331
+		$data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
332 332
 
333
-        foreach($data as $ga) {
334
-            $res[] = $this->loadGeoAnalysisFromRow($ga);
335
-        }
333
+		foreach($data as $ga) {
334
+			$res[] = $this->loadGeoAnalysisFromRow($ga);
335
+		}
336 336
         
337
-        return $res;
338
-    }
337
+		return $res;
338
+	}
339 339
             
340
-    /**
341
-     * Returns the infered place hierarchy, determined from the Gedcom data.
342
-     * Depending on the data, it can be based on the Gedcom Header description, or from a place example.
343
-     * This is returned as an associative array:
344
-     *      - type:    describe the source of the data (<em>header<em> / <em>data</em> / <em>none</em>)
345
-     *      - hierarchy: an array of the place hierarchy (in reverse order of the gedcom)
346
-     *      
347
-     * @return array
348
-     */
349
-    public function getPlacesHierarchy() {
350
-        if(!$this->place_hierarchy) {
351
-            if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352
-                $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
-            }
354
-            elseif ($place_structure = $this->getPlacesHierarchyFromData()){
355
-                $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure);
356
-            }
357
-            else {
358
-                $this->place_hierarchy = array('type' => 'none', 'hierarchy' => null);
359
-            }
360
-        }
361
-        return $this->place_hierarchy;        
362
-    }
340
+	/**
341
+	 * Returns the infered place hierarchy, determined from the Gedcom data.
342
+	 * Depending on the data, it can be based on the Gedcom Header description, or from a place example.
343
+	 * This is returned as an associative array:
344
+	 *      - type:    describe the source of the data (<em>header<em> / <em>data</em> / <em>none</em>)
345
+	 *      - hierarchy: an array of the place hierarchy (in reverse order of the gedcom)
346
+	 *      
347
+	 * @return array
348
+	 */
349
+	public function getPlacesHierarchy() {
350
+		if(!$this->place_hierarchy) {
351
+			if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352
+				$this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
+			}
354
+			elseif ($place_structure = $this->getPlacesHierarchyFromData()){
355
+				$this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure);
356
+			}
357
+			else {
358
+				$this->place_hierarchy = array('type' => 'none', 'hierarchy' => null);
359
+			}
360
+		}
361
+		return $this->place_hierarchy;        
362
+	}
363 363
     
364
-    /**
365
-     * Returns an array of the place hierarchy, as defined in the GEDCOM header.
366
-     * The places are reversed compared to normal GEDCOM structure.
367
-     * 
368
-     * @return array|null
369
-     */
370
-    protected function getPlacesHierarchyFromHeader() {
371
-        $head = GedcomRecord::getInstance('HEAD', $this->tree);
372
-        $head_place = $head->getFirstFact('PLAC');
373
-        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
374
-            return array_reverse(array_map('trim',explode(',', $head_place_value)));
375
-        }
376
-        return null;
377
-    }
364
+	/**
365
+	 * Returns an array of the place hierarchy, as defined in the GEDCOM header.
366
+	 * The places are reversed compared to normal GEDCOM structure.
367
+	 * 
368
+	 * @return array|null
369
+	 */
370
+	protected function getPlacesHierarchyFromHeader() {
371
+		$head = GedcomRecord::getInstance('HEAD', $this->tree);
372
+		$head_place = $head->getFirstFact('PLAC');
373
+		if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
374
+			return array_reverse(array_map('trim',explode(',', $head_place_value)));
375
+		}
376
+		return null;
377
+	}
378 378
     
379
-    /**
380
-     * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
381
-     * It will look for the longest hierarchy in the tree.
382
-     * The places are reversed compared to normal GEDCOM structure.
383
-     * 
384
-     * @return array
385
-     */
386
-    protected function getPlacesHierarchyFromData() {
387
-        $nb_levels = 0;
379
+	/**
380
+	 * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
381
+	 * It will look for the longest hierarchy in the tree.
382
+	 * The places are reversed compared to normal GEDCOM structure.
383
+	 * 
384
+	 * @return array
385
+	 */
386
+	protected function getPlacesHierarchyFromData() {
387
+		$nb_levels = 0;
388 388
         
389
-        //Select all '2 PLAC ' tags in the file and create array
390
-        $places_list=array();
391
-        $ged_data = Database::prepare(
392
-            'SELECT i_gedcom AS gedcom'.
393
-            ' FROM `##individuals`'.
394
-            ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
395
-            ' UNION ALL'.
396
-            ' SELECT f_gedcom AS gedcom'.
397
-            ' FROM `##families`'.
398
-            ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
399
-        )->execute(array(
400
-            'gedcom' => '%2 PLAC %',
401
-            'gedcom_id' => $this->tree->getTreeId()
402
-        ))->fetchOneColumn();
403
-        foreach ($ged_data as $ged_datum) {
404
-            $matches = null;
405
-            preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
406
-            foreach ($matches[1] as $match) {
407
-                $places_list[$match]=true;
408
-            }
409
-        }
389
+		//Select all '2 PLAC ' tags in the file and create array
390
+		$places_list=array();
391
+		$ged_data = Database::prepare(
392
+			'SELECT i_gedcom AS gedcom'.
393
+			' FROM `##individuals`'.
394
+			' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
395
+			' UNION ALL'.
396
+			' SELECT f_gedcom AS gedcom'.
397
+			' FROM `##families`'.
398
+			' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
399
+		)->execute(array(
400
+			'gedcom' => '%2 PLAC %',
401
+			'gedcom_id' => $this->tree->getTreeId()
402
+		))->fetchOneColumn();
403
+		foreach ($ged_data as $ged_datum) {
404
+			$matches = null;
405
+			preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
406
+			foreach ($matches[1] as $match) {
407
+				$places_list[$match]=true;
408
+			}
409
+		}
410 410
         
411
-        // Get the places with higest numbers of levels
412
-        $places_with_high_level = array();
413
-        $max_level = 0;
411
+		// Get the places with higest numbers of levels
412
+		$places_with_high_level = array();
413
+		$max_level = 0;
414 414
         
415
-        foreach ($places_list as $place => $value) {
416
-            $levels = array_filter(array_map('trim', explode(",", $place)));
417
-            $parts = count($levels);
418
-            if($parts > $max_level) {
419
-                $max_level = $parts;
420
-                $places_with_high_level = array($place);
421
-            }
422
-            else if ($parts == $max_level) {
423
-                $places_with_high_level[] = $place;
424
-            }
425
-        }
415
+		foreach ($places_list as $place => $value) {
416
+			$levels = array_filter(array_map('trim', explode(",", $place)));
417
+			$parts = count($levels);
418
+			if($parts > $max_level) {
419
+				$max_level = $parts;
420
+				$places_with_high_level = array($place);
421
+			}
422
+			else if ($parts == $max_level) {
423
+				$places_with_high_level[] = $place;
424
+			}
425
+		}
426 426
         
427
-        // If empty array, then return null
428
-        if($max_level == 0) return null;
427
+		// If empty array, then return null
428
+		if($max_level == 0) return null;
429 429
                 
430
-        // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used
431
-        usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp'));        
432
-        return array_reverse(array_map('trim',explode(',', $places_with_high_level[0])));
430
+		// Else, return the first alphabetical element -- cannot return random to ensure always the same example if used
431
+		usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp'));        
432
+		return array_reverse(array_map('trim',explode(',', $places_with_high_level[0])));
433 433
         
434
-    }
434
+	}
435 435
     
436
-    /**
437
-     * Returns the list of geodispersion maps available within the maps folder.
438
-     * 
439
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
440
-     */
441
-    public function getOutlineMapsList() {
442
-        $res = array();
443
-        $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
444
-        if(is_dir($root_path)){
445
-            $dir = opendir($root_path);
446
-            while (($file=readdir($dir))!== false) {
447
-                if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
448
-                    $res[base64_encode($file)] = new OutlineMap($file, true);
449
-                }
450
-            }
451
-        }
452
-        return $res;
453
-    }
436
+	/**
437
+	 * Returns the list of geodispersion maps available within the maps folder.
438
+	 * 
439
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
440
+	 */
441
+	public function getOutlineMapsList() {
442
+		$res = array();
443
+		$root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
444
+		if(is_dir($root_path)){
445
+			$dir = opendir($root_path);
446
+			while (($file=readdir($dir))!== false) {
447
+				if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
448
+					$res[base64_encode($file)] = new OutlineMap($file, true);
449
+				}
450
+			}
451
+		}
452
+		return $res;
453
+	}
454 454
 }
455 455
  
456 456
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/Views/GeoAnalysisEditView.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 	 * {@inhericDoc}
26 26
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
27 27
 	 */
28
-    protected function renderContent() {
28
+	protected function renderContent() {
29 29
         
30
-        /** @var GeoAnalysis $ga */
31
-        $ga = $this->data->get('geo_analysis');
32
-        $is_new = is_null($ga);
30
+		/** @var GeoAnalysis $ga */
31
+		$ga = $this->data->get('geo_analysis');
32
+		$is_new = is_null($ga);
33 33
         
34
-        $places_hierarchy = $this->data->get('places_hierarchy');
35
-        ?>        
34
+		$places_hierarchy = $this->data->get('places_hierarchy');
35
+		?>        
36 36
         <ol class="breadcrumb small">
37 37
         	<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
38 38
 			<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     	</form>
160 160
 		
161 161
 		<?php }
162
-    }
162
+	}
163 163
     
164 164
 }
165 165
  
166 166
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/Views/AdminConfigView.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	 * {@inhericDoc}
24 24
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
25 25
 	 */
26
-    protected function renderContent() {
26
+	protected function renderContent() {
27 27
         
28
-        /** @var Tree $tree  */
29
-        $tree = $this->data->get('tree');
30
-        $root_url = $this->data->get('root_url');
31
-        $other_trees = $this->data->get('other_trees');
32
-        $table_id = $this->data->get('table_id');
33
-        ?>        
28
+		/** @var Tree $tree  */
29
+		$tree = $this->data->get('tree');
30
+		$root_url = $this->data->get('root_url');
31
+		$other_trees = $this->data->get('other_trees');
32
+		$table_id = $this->data->get('table_id');
33
+		?>        
34 34
         <ol class="breadcrumb small">
35 35
         	<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
36 36
 			<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
@@ -63,23 +63,23 @@  discard block
 block discarded – undo
63 63
 		<p>
64 64
 		<?php $places_hierarchy = $this->data->get('places_hierarchy'); 
65 65
 		if($places_hierarchy && $places_hierarchy['type'] != 'none') {
66
-		    switch ($places_hierarchy['type']) {
67
-		        case 'header':
68
-		            echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: ');
69
-		            break;
70
-		        case 'data':
71
-		            echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.').
72
-		            '<br/>'.
73
-		            I18N::translate('Here is an example of your place data: ');
74
-		            break;
75
-		        default:
76
-		            break;
77
-		    }
78
-		    $str_hierarchy = array();
79
-		    foreach($places_hierarchy['hierarchy'] as $key => $level) {
80
-		        $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level);
81
-		    }
82
-		    echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>';
66
+			switch ($places_hierarchy['type']) {
67
+				case 'header':
68
+					echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: ');
69
+					break;
70
+				case 'data':
71
+					echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.').
72
+					'<br/>'.
73
+					I18N::translate('Here is an example of your place data: ');
74
+					break;
75
+				default:
76
+					break;
77
+			}
78
+			$str_hierarchy = array();
79
+			foreach($places_hierarchy['hierarchy'] as $key => $level) {
80
+				$str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level);
81
+			}
82
+			echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>';
83 83
 		}
84 84
 		?>
85 85
 		</p>
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         </a>
110 110
 		
111 111
 		<?php        
112
-    }
112
+	}
113 113
     
114 114
 }
115 115
  
116 116
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/AdminConfigController.php 1 patch
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -36,58 +36,58 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class AdminConfigController extends MvcController
38 38
 {    
39
-    /**
40
-     * GeoAnalysis Provider
41
-     * @var GeoAnalysisProvider $provider
42
-     */
43
-    protected $provider;    
39
+	/**
40
+	 * GeoAnalysis Provider
41
+	 * @var GeoAnalysisProvider $provider
42
+	 */
43
+	protected $provider;    
44 44
     
45
-    /**
46
-     * Constructor for Admin Config controller
47
-     * @param AbstractModule $module
48
-     */
49
-    public function __construct(AbstractModule $module) {
50
-        parent::__construct($module);
45
+	/**
46
+	 * Constructor for Admin Config controller
47
+	 * @param AbstractModule $module
48
+	 */
49
+	public function __construct(AbstractModule $module) {
50
+		parent::__construct($module);
51 51
         
52
-        $this->provider = $this->module->getProvider();
53
-    }    
52
+		$this->provider = $this->module->getProvider();
53
+	}    
54 54
     
55
-    /**
56
-     * Pages
57
-     */
55
+	/**
56
+	 * Pages
57
+	 */
58 58
         
59
-    /**
60
-     * AdminConfig@index
61
-     */
62
-    public function index() {
63
-        $wt_tree = Globals::getTree();
64
-        Theme::theme(new AdministrationTheme)->init($wt_tree);
65
-        $controller = new PageController();
66
-        $controller
67
-            ->restrictAccess(Auth::isManager($wt_tree))
68
-            ->setPageTitle($this->module->getTitle());
59
+	/**
60
+	 * AdminConfig@index
61
+	 */
62
+	public function index() {
63
+		$wt_tree = Globals::getTree();
64
+		Theme::theme(new AdministrationTheme)->init($wt_tree);
65
+		$controller = new PageController();
66
+		$controller
67
+			->restrictAccess(Auth::isManager($wt_tree))
68
+			->setPageTitle($this->module->getTitle());
69 69
         
70
-        $data = new ViewBag();
71
-        $data->set('title', $controller->getPageTitle());
72
-        $data->set('tree', $wt_tree);
70
+		$data = new ViewBag();
71
+		$data->set('title', $controller->getPageTitle());
72
+		$data->set('tree', $wt_tree);
73 73
         
74
-        $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
74
+		$data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
75 75
                 
76
-        $table_id = 'table-geoanalysis-' . Uuid::uuid4();
77
-        $data->set('table_id', $table_id);
76
+		$table_id = 'table-geoanalysis-' . Uuid::uuid4();
77
+		$data->set('table_id', $table_id);
78 78
         
79
-        $other_trees = array();
80
-        foreach (Tree::getAll() as $tree) {
81
-            if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
82
-        }      
83
-        $data->set('other_trees', $other_trees);
79
+		$other_trees = array();
80
+		foreach (Tree::getAll() as $tree) {
81
+			if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
82
+		}      
83
+		$data->set('other_trees', $other_trees);
84 84
         
85
-        $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
85
+		$data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
86 86
         
87
-        $controller
88
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
89
-            ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
90
-            ->addInlineJavascript('
87
+		$controller
88
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
89
+			->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
90
+			->addInlineJavascript('
91 91
 				jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
92 92
 				jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
93 93
                 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 				});
120 120
                 
121 121
                 ')
122
-                ->addInlineJavascript('				
122
+				->addInlineJavascript('				
123 123
                     function set_geoanalysis_status(ga_id, status, gedcom) {
124 124
                 		jQuery.ajax({
125 125
                             url: "module.php", 
@@ -163,54 +163,54 @@  discard block
 block discarded – undo
163 163
                 ');
164 164
         
165 165
         
166
-        ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
167
-    }
166
+		ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
167
+	}
168 168
 
169
-    /**
170
-     * AdminConfig@jsonGeoAnalysisList
171
-     */
172
-    public function jsonGeoAnalysisList() {
173
-        $wt_tree = Globals::getTree();
174
-        $controller = new JsonController();
175
-        $controller
176
-            ->restrictAccess(Auth::isManager($wt_tree));
169
+	/**
170
+	 * AdminConfig@jsonGeoAnalysisList
171
+	 */
172
+	public function jsonGeoAnalysisList() {
173
+		$wt_tree = Globals::getTree();
174
+		$controller = new JsonController();
175
+		$controller
176
+			->restrictAccess(Auth::isManager($wt_tree));
177 177
         
178
-        // Generate an AJAX/JSON response for datatables to load a block of rows
179
-        $search = Filter::postArray('search');
180
-        if($search) $search = $search['value'];
181
-        $start  = Filter::postInteger('start');
182
-        $length = Filter::postInteger('length');
183
-        $order  = Filter::postArray('order');
178
+		// Generate an AJAX/JSON response for datatables to load a block of rows
179
+		$search = Filter::postArray('search');
180
+		if($search) $search = $search['value'];
181
+		$start  = Filter::postInteger('start');
182
+		$length = Filter::postInteger('length');
183
+		$order  = Filter::postArray('order');
184 184
         
185
-        foreach($order as $key => &$value) {
186
-            switch($value['column']) {
187
-                case 3:
188
-                    $value['column'] = 'majgd_descr';
189
-                    break;
190
-                case 5;
191
-                    $value['column'] = 'majgd_sublevel';
192
-                    break;
193
-                default:
194
-                    unset($order[$key]);
195
-            }
196
-        }
185
+		foreach($order as $key => &$value) {
186
+			switch($value['column']) {
187
+				case 3:
188
+					$value['column'] = 'majgd_descr';
189
+					break;
190
+				case 5;
191
+					$value['column'] = 'majgd_sublevel';
192
+					break;
193
+				default:
194
+					unset($order[$key]);
195
+			}
196
+		}
197 197
         
198
-        /** @var GeoAnalysisProvider $provider */
199
-        $provider = $this->module->getProvider();
198
+		/** @var GeoAnalysisProvider $provider */
199
+		$provider = $this->module->getProvider();
200 200
         
201
-        $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length);
202
-        $recordsFiltered = count($list);
203
-        $recordsTotal = $this->provider->getGeoAnalysisCount();
201
+		$list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length);
202
+		$recordsFiltered = count($list);
203
+		$recordsTotal = $this->provider->getGeoAnalysisCount();
204 204
         
205
-        $data = array();
206
-        $place_hierarchy = $this->provider->getPlacesHierarchy();
207
-        foreach($list as $ga) {
208
-            /** @var GeoAnalysis $ga */
205
+		$data = array();
206
+		$place_hierarchy = $this->provider->getPlacesHierarchy();
207
+		foreach($list as $ga) {
208
+			/** @var GeoAnalysis $ga */
209 209
             
210
-            $datum = array();
211
-            $options= $ga->getOptions();
210
+			$datum = array();
211
+			$options= $ga->getOptions();
212 212
             
213
-            $datum[0] = '
213
+			$datum[0] = '
214 214
                 <div class="btn-group">
215 215
                     <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
216 216
                         <i class="fa fa-pencil"></i><span class="caret"></span>
@@ -234,116 +234,116 @@  discard block
 block discarded – undo
234 234
                        </li>
235 235
                     </ul>
236 236
                 </div>';
237
-		    $datum[1] = $ga->getId();
238
-		    $datum[2] = $ga->isEnabled() ? 
237
+			$datum[1] = $ga->getId();
238
+			$datum[2] = $ga->isEnabled() ? 
239 239
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : 
240 240
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
241
-		    $datum[3] = $ga->getTitle();
242
-		    $analysis_level = $ga->getAnalysisLevel();
243
-		    if($place_hierarchy['type'] == 'header') {
244
-		        $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
245
-		    } elseif ($place_hierarchy['type'] == 'data') {
246
-		        $datum[4] = $analysis_level . ' (' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
247
-		    } else {
248
-		        $datum[4] = $analysis_level;
249
-		    }
250
-		    $datum[5] = $ga->getAnalysisLevel();
251
-		    $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
252
-		    $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
253
-		    if($ga->hasMap()) {
254
-		        if($options->getMap()->isLoaded()) {
255
-    		        $datum[6] = $options->getMap()->getDescription();
256
-    		        $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
257
-    		        $top_level = $options->getMapLevel();
258
-    		        if($place_hierarchy['type'] == 'header') {
259
-    		            $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
260
-    		        } elseif ($place_hierarchy['type'] == 'data') {
261
-    		            $datum[7] .= $top_level . ' (' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
262
-    		        } else {
263
-    		            $datum[7] .= $top_level;
264
-    		        }
265
-    		        $datum[7] .= '</span>';
266
-		        }
267
-		        else {
268
-		            $datum[6] = I18N::translate('Error when loading map.');
269
-		        }
270
-		    }
271
-		    $datum[8] = $options->isUsingFlags() ? 
241
+			$datum[3] = $ga->getTitle();
242
+			$analysis_level = $ga->getAnalysisLevel();
243
+			if($place_hierarchy['type'] == 'header') {
244
+				$datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
245
+			} elseif ($place_hierarchy['type'] == 'data') {
246
+				$datum[4] = $analysis_level . ' (' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
247
+			} else {
248
+				$datum[4] = $analysis_level;
249
+			}
250
+			$datum[5] = $ga->getAnalysisLevel();
251
+			$datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
252
+			$datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
253
+			if($ga->hasMap()) {
254
+				if($options->getMap()->isLoaded()) {
255
+					$datum[6] = $options->getMap()->getDescription();
256
+					$datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
257
+					$top_level = $options->getMapLevel();
258
+					if($place_hierarchy['type'] == 'header') {
259
+						$datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
260
+					} elseif ($place_hierarchy['type'] == 'data') {
261
+						$datum[7] .= $top_level . ' (' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
262
+					} else {
263
+						$datum[7] .= $top_level;
264
+					}
265
+					$datum[7] .= '</span>';
266
+				}
267
+				else {
268
+					$datum[6] = I18N::translate('Error when loading map.');
269
+				}
270
+			}
271
+			$datum[8] = $options->isUsingFlags() ? 
272 272
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : 
273 273
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
274
-		    $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
274
+			$datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
275 275
 		    
276
-		    $data[] = $datum;
277
-        }
276
+			$data[] = $datum;
277
+		}
278 278
         
279
-        $controller->pageHeader();
279
+		$controller->pageHeader();
280 280
         
281
-        $controller->encode(array(
282
-            'draw'            => Filter::getInteger('draw'),
283
-            'recordsTotal'    => $recordsTotal,
284
-            'recordsFiltered' => $recordsFiltered,
285
-            'data'            => $data
286
-        ));
281
+		$controller->encode(array(
282
+			'draw'            => Filter::getInteger('draw'),
283
+			'recordsTotal'    => $recordsTotal,
284
+			'recordsFiltered' => $recordsFiltered,
285
+			'data'            => $data
286
+		));
287 287
         
288
-    }
288
+	}
289 289
 
290
-    /**
291
-     * AdminConfig@edit
292
-     */
293
-    public function edit() {
294
-        $ga_id = Filter::getInteger('ga_id');
295
-        $ga = $this->provider->getGeoAnalysis($ga_id, false);
290
+	/**
291
+	 * AdminConfig@edit
292
+	 */
293
+	public function edit() {
294
+		$ga_id = Filter::getInteger('ga_id');
295
+		$ga = $this->provider->getGeoAnalysis($ga_id, false);
296 296
         
297
-        $this->renderEdit($ga);
298
-    }
297
+		$this->renderEdit($ga);
298
+	}
299 299
     
300
-    /**
301
-     * AdminConfig@add
302
-     */
303
-    public function add() {
304
-        $this->renderEdit(null);
305
-    }
300
+	/**
301
+	 * AdminConfig@add
302
+	 */
303
+	public function add() {
304
+		$this->renderEdit(null);
305
+	}
306 306
     
307
-    /**
308
-     * AdminConfig@save
309
-     */
310
-    public function save() {
311
-        $wt_tree = Globals::getTree();
312
-        $tmp_contrl = new PageController();
313
-        $tmp_contrl->restrictAccess(
314
-            Auth::isManager($wt_tree) 
315
-            && Filter::checkCsrf()
316
-         );
307
+	/**
308
+	 * AdminConfig@save
309
+	 */
310
+	public function save() {
311
+		$wt_tree = Globals::getTree();
312
+		$tmp_contrl = new PageController();
313
+		$tmp_contrl->restrictAccess(
314
+			Auth::isManager($wt_tree) 
315
+			&& Filter::checkCsrf()
316
+		 );
317 317
         
318
-        $ga_id          = Filter::postInteger('ga_id');
319
-        $description    = Filter::post('description');
320
-        $analysislevel  = Filter::postInteger('analysislevel');
321
-        $use_map        = Filter::postBool('use_map');
322
-        if($use_map) {
323
-            $map_file   = base64_decode(Filter::post('map_file'));
324
-            $map_top_level   = Filter::postInteger('map_top_level');
325
-        }
326
-        $use_flags      = Filter::postBool('use_flags');
327
-        $gen_details    = Filter::postInteger('gen_details');
318
+		$ga_id          = Filter::postInteger('ga_id');
319
+		$description    = Filter::post('description');
320
+		$analysislevel  = Filter::postInteger('analysislevel');
321
+		$use_map        = Filter::postBool('use_map');
322
+		if($use_map) {
323
+			$map_file   = base64_decode(Filter::post('map_file'));
324
+			$map_top_level   = Filter::postInteger('map_top_level');
325
+		}
326
+		$use_flags      = Filter::postBool('use_flags');
327
+		$gen_details    = Filter::postInteger('gen_details');
328 328
         
329
-        $success = false; 
330
-        if($ga_id) {
331
-            $ga = $this->provider->getGeoAnalysis($ga_id, false);
332
-            if($ga) {
333
-                $ga->setTitle($description);
334
-                $ga->setAnalysisLevel($analysislevel + 1);
335
-                $options = $ga->getOptions();
336
-                if($options) {
337
-                    $options->setUsingFlags($use_flags);
338
-                    $options->setMaxDetailsInGen($gen_details);
339
-                    if($use_map) {
340
-                        $options->setMap(new OutlineMap($map_file));
341
-                        $options->setMapLevel($map_top_level + 1);
342
-                    }
343
-                    else {
344
-                        $options->setMap(null);
345
-                    }
346
-                }
329
+		$success = false; 
330
+		if($ga_id) {
331
+			$ga = $this->provider->getGeoAnalysis($ga_id, false);
332
+			if($ga) {
333
+				$ga->setTitle($description);
334
+				$ga->setAnalysisLevel($analysislevel + 1);
335
+				$options = $ga->getOptions();
336
+				if($options) {
337
+					$options->setUsingFlags($use_flags);
338
+					$options->setMaxDetailsInGen($gen_details);
339
+					if($use_map) {
340
+						$options->setMap(new OutlineMap($map_file));
341
+						$options->setMapLevel($map_top_level + 1);
342
+					}
343
+					else {
344
+						$options->setMap(null);
345
+					}
346
+				}
347 347
 				
348 348
 				$res = $this->provider->updateGeoAnalysis($ga);
349 349
 				if($res) {
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 					FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger');
357 357
 					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.');
358 358
 				}
359
-            }
360
-        } else {
359
+			}
360
+		} else {
361 361
 			$ga = $this->provider->createGeoAnalysis(
362 362
 				$description,
363 363
 				$analysislevel + 1,
@@ -375,33 +375,33 @@  discard block
 block discarded – undo
375 375
 				FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger');
376 376
 				Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.');
377 377
 			}
378
-        }
378
+		}
379 379
         
380
-        $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl();
381
-        if(!$success) {			
382
-            if($ga) {
383
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl();
384
-            }
385
-            else {
386
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl();
387
-            }
388
-        }        
389
-        header('Location: ' . WT_BASE_URL . $redirection_url);
380
+		$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl();
381
+		if(!$success) {			
382
+			if($ga) {
383
+				$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl();
384
+			}
385
+			else {
386
+				$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl();
387
+			}
388
+		}        
389
+		header('Location: ' . WT_BASE_URL . $redirection_url);
390 390
         
391
-    }
391
+	}
392 392
      
393 393
 	/**
394 394
 	 * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one.
395 395
 	 * 
396 396
 	 * @param (GeoAnalysis!null) $ga GeoAnalysis to edit
397 397
 	 */
398
-    protected function renderEdit(GeoAnalysis $ga = null) {
399
-        $wt_tree = Globals::getTree();
400
-        Theme::theme(new AdministrationTheme)->init($wt_tree);
401
-        $controller = new PageController();        
402
-        $controller
403
-            ->restrictAccess(Auth::isManager($wt_tree))
404
-            ->addInlineJavascript('
398
+	protected function renderEdit(GeoAnalysis $ga = null) {
399
+		$wt_tree = Globals::getTree();
400
+		Theme::theme(new AdministrationTheme)->init($wt_tree);
401
+		$controller = new PageController();        
402
+		$controller
403
+			->restrictAccess(Auth::isManager($wt_tree))
404
+			->addInlineJavascript('
405 405
                 function toggleMapOptions() {
406 406
                     if($("input:radio[name=\'use_map\']:checked").val() == 1) {
407 407
                         $("#map_options").show();
@@ -415,34 +415,34 @@  discard block
 block discarded – undo
415 415
                 toggleMapOptions();
416 416
             ');
417 417
         
418
-        $data = new ViewBag();
419
-        if($ga) {
420
-            $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
421
-            $data->set('geo_analysis', $ga);
422
-        } else {
423
-            $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
424
-        }
418
+		$data = new ViewBag();
419
+		if($ga) {
420
+			$controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
421
+			$data->set('geo_analysis', $ga);
422
+		} else {
423
+			$controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
424
+		}
425 425
         
426
-        $data->set('title', $controller->getPageTitle());
427
-        $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl());
428
-        $data->set('module_title', $this->module->getTitle());
429
-        $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl());
430
-        $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
426
+		$data->set('title', $controller->getPageTitle());
427
+		$data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl());
428
+		$data->set('module_title', $this->module->getTitle());
429
+		$data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl());
430
+		$data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
431 431
     
432
-        $map_list = array_map(
433
-            function(OutlineMap $map) {
434
-                return $map->getDescription();
435
-            },
436
-            $this->provider->getOutlineMapsList()
437
-            );
438
-        asort($map_list);
439
-        $data->set('map_list', $map_list);
432
+		$map_list = array_map(
433
+			function(OutlineMap $map) {
434
+				return $map->getDescription();
435
+			},
436
+			$this->provider->getOutlineMapsList()
437
+			);
438
+		asort($map_list);
439
+		$data->set('map_list', $map_list);
440 440
     
441
-        $gen_details = array(0 => I18N::translate('All'));
442
-        for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
443
-        $data->set('generation_details', $gen_details);
441
+		$gen_details = array(0 => I18N::translate('All'));
442
+		for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
443
+		$data->set('generation_details', $gen_details);
444 444
     
445
-        ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
446
-    }
445
+		ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
446
+	}
447 447
     
448 448
 }
449 449
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageRootNode.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -24,68 +24,68 @@
 block discarded – undo
24 24
 class LineageRootNode extends LineageNode
25 25
 {
26 26
     
27
-    /**
28
-     * @var Collection $places Places for the lineage node
29
-     */
30
-    private $places;
27
+	/**
28
+	 * @var Collection $places Places for the lineage node
29
+	 */
30
+	private $places;
31 31
    
32
-    /**
33
-     * @var int $nb_children Number of node childs
34
-     */
35
-    private $nb_children;
32
+	/**
33
+	 * @var int $nb_children Number of node childs
34
+	 */
35
+	private $nb_children;
36 36
   
37
-    /**
38
-     * Constructor for LineageRootNode
39
-     *
40
-     * @param Individual|null $node_indi
41
-     */
42
-    public function __construct(?Individual $node_indi = null)
43
-    {
44
-        parent::__construct($node_indi, $this);
45
-        $this->places = new Collection();
46
-        $this->nb_children = 0;
47
-    }
37
+	/**
38
+	 * Constructor for LineageRootNode
39
+	 *
40
+	 * @param Individual|null $node_indi
41
+	 */
42
+	public function __construct(?Individual $node_indi = null)
43
+	{
44
+		parent::__construct($node_indi, $this);
45
+		$this->places = new Collection();
46
+		$this->nb_children = 0;
47
+	}
48 48
    
49
-    /**
50
-     * Adds a place to the list of lineage's place
51
-     *
52
-     * @param Place $place
53
-     */
54
-    public function addPlace(Place $place): void
55
-    {
56
-        $place_name = $place->gedcomName();
57
-        if (mb_strlen($place_name) > 0) {
58
-            $this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
-        }
60
-    }
49
+	/**
50
+	 * Adds a place to the list of lineage's place
51
+	 *
52
+	 * @param Place $place
53
+	 */
54
+	public function addPlace(Place $place): void
55
+	{
56
+		$place_name = $place->gedcomName();
57
+		if (mb_strlen($place_name) > 0) {
58
+			$this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
+		}
60
+	}
61 61
     
62
-    /**
63
-     * Returns the number of child nodes.
64
-     * This number is more to be used as indication rather than an accurate one.
65
-     *
66
-     * @return int
67
-     */
68
-    public function numberChildNodes(): int
69
-    {
70
-        return $this->nb_children;
71
-    }
62
+	/**
63
+	 * Returns the number of child nodes.
64
+	 * This number is more to be used as indication rather than an accurate one.
65
+	 *
66
+	 * @return int
67
+	 */
68
+	public function numberChildNodes(): int
69
+	{
70
+		return $this->nb_children;
71
+	}
72 72
    
73
-    /**
74
-     * Increments the number of child nodes by one
75
-     *
76
-     */
77
-    public function incrementChildNodes(): void
78
-    {
79
-        $this->nb_children++;
80
-    }
73
+	/**
74
+	 * Increments the number of child nodes by one
75
+	 *
76
+	 */
77
+	public function incrementChildNodes(): void
78
+	{
79
+		$this->nb_children++;
80
+	}
81 81
    
82
-    /**
83
-     * Returns the list of place for the lineage
84
-     *
85
-     * @return Collection
86
-     */
87
-    public function places(): Collection
88
-    {
89
-        return $this->places;
90
-    }
82
+	/**
83
+	 * Returns the list of place for the lineage
84
+	 *
85
+	 * @return Collection
86
+	 */
87
+	public function places(): Collection
88
+	{
89
+		return $this->places;
90
+	}
91 91
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AbstractModuleMaj.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -26,89 +26,89 @@
 block discarded – undo
26 26
  */
27 27
 abstract class AbstractModuleMaj extends AbstractModule implements ModuleCustomInterface
28 28
 {    
29
-    use ModuleCustomTrait;
29
+	use ModuleCustomTrait;
30 30
     
31
-    /**
32
-     * {@inheritDoc}
33
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
34
-     */
35
-    public function boot() : void
36
-    {
37
-        View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/');
31
+	/**
32
+	 * {@inheritDoc}
33
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::boot()
34
+	 */
35
+	public function boot() : void
36
+	{
37
+		View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/');
38 38
         
39
-        $this->loadRoutes(app(RouterContainer::class)->getMap());
40
-    }
39
+		$this->loadRoutes(app(RouterContainer::class)->getMap());
40
+	}
41 41
     
42
-    /**
43
-     * {@inheritDoc}
44
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder()
45
-     */
46
-    public function resourcesFolder(): string
47
-    {
48
-        return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/';
49
-    }
42
+	/**
43
+	 * {@inheritDoc}
44
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder()
45
+	 */
46
+	public function resourcesFolder(): string
47
+	{
48
+		return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/';
49
+	}
50 50
     
51
-    /**
52
-     * {@inheritDoc}
53
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName()
54
-     */
55
-    public function customModuleAuthorName() : string
56
-    {
57
-        return 'Jonathan Jaubart';
58
-    }
51
+	/**
52
+	 * {@inheritDoc}
53
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName()
54
+	 */
55
+	public function customModuleAuthorName() : string
56
+	{
57
+		return 'Jonathan Jaubart';
58
+	}
59 59
     
60
-    /**
61
-     * {@inheritDoc}
62
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl()
63
-     */
64
-    public function customModuleSupportUrl() : string
65
-    {
66
-        return 'https://github.com/jon48/webtrees-lib';
67
-    }
60
+	/**
61
+	 * {@inheritDoc}
62
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl()
63
+	 */
64
+	public function customModuleSupportUrl() : string
65
+	{
66
+		return 'https://github.com/jon48/webtrees-lib';
67
+	}
68 68
     
69
-    /**
70
-     * {@inheritDoc}
71
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations()
72
-     */
73
-    public function customTranslations(string $language) : array
74
-    {
75
-        $translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php';
69
+	/**
70
+	 * {@inheritDoc}
71
+	 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations()
72
+	 */
73
+	public function customTranslations(string $language) : array
74
+	{
75
+		$translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php';
76 76
         
77
-        try {
78
-            $translation  = new Translation($translation_file);
79
-            return $translation->asArray();
80
-        } catch (\Exception $e) { }
77
+		try {
78
+			$translation  = new Translation($translation_file);
79
+			return $translation->asArray();
80
+		} catch (\Exception $e) { }
81 81
         
82
-        return array();
83
-    }
82
+		return array();
83
+	}
84 84
     
85
-    /**
86
-     * Add module routes to webtrees route loader
87
-     * 
88
-     * @param Map $router
89
-     */
90
-    public abstract function loadRoutes(Map $router) : void;
85
+	/**
86
+	 * Add module routes to webtrees route loader
87
+	 * 
88
+	 * @param Map $router
89
+	 */
90
+	public abstract function loadRoutes(Map $router) : void;
91 91
     
92
-    /**
93
-     * Returns the URL of the module specific stylesheets.
94
-     * It will look for a CSS file matching the theme name (e.g. xenea.min.css),
95
-     * and fallback to default.min.css if none are found
96
-     * 
97
-     * @return string
98
-     */
99
-    public function moduleCssUrl() : string
100
-    {
101
-        /** @var ModuleThemeInterface $theme */
102
-        $theme = app(ModuleThemeInterface::class);
103
-        $css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css';
92
+	/**
93
+	 * Returns the URL of the module specific stylesheets.
94
+	 * It will look for a CSS file matching the theme name (e.g. xenea.min.css),
95
+	 * and fallback to default.min.css if none are found
96
+	 * 
97
+	 * @return string
98
+	 */
99
+	public function moduleCssUrl() : string
100
+	{
101
+		/** @var ModuleThemeInterface $theme */
102
+		$theme = app(ModuleThemeInterface::class);
103
+		$css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css';
104 104
         
105
-        if(file_exists($css_file)) {
106
-            return $this->assetUrl('css/' . $theme->name() . '.min.css');
107
-        }
108
-        else {
109
-            return $this->assetUrl('css/default.min.css');
110
-        }
111
-    }
105
+		if(file_exists($css_file)) {
106
+			return $this->assetUrl('css/' . $theme->name() . '.min.css');
107
+		}
108
+		else {
109
+			return $this->assetUrl('css/default.min.css');
110
+		}
111
+	}
112 112
     
113 113
 }
114 114
  
115 115
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Http/RequestHandlers/TaskStatusAction.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -30,65 +30,65 @@
 block discarded – undo
30 30
 class TaskStatusAction implements RequestHandlerInterface
31 31
 {
32 32
     
33
-    /**
34
-     * @var AdminTasksModule $module
35
-     */
36
-    private $module;
33
+	/**
34
+	 * @var AdminTasksModule $module
35
+	 */
36
+	private $module;
37 37
     
38
-    /**
39
-     * @var TaskScheduleService $taskschedules_service
40
-     */
41
-    private $taskschedules_service;
38
+	/**
39
+	 * @var TaskScheduleService $taskschedules_service
40
+	 */
41
+	private $taskschedules_service;
42 42
     
43
-    /**
44
-     * Constructor for TaskStatusAction Request Handler
45
-     *
46
-     * @param ModuleService $module_service
47
-     * @param TaskScheduleService $taskschedules_service
48
-     */
49
-    public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
50
-    {
51
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
52
-        $this->taskschedules_service = $taskschedules_service;
53
-    }
43
+	/**
44
+	 * Constructor for TaskStatusAction Request Handler
45
+	 *
46
+	 * @param ModuleService $module_service
47
+	 * @param TaskScheduleService $taskschedules_service
48
+	 */
49
+	public function __construct(ModuleService $module_service, TaskScheduleService $taskschedules_service)
50
+	{
51
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
52
+		$this->taskschedules_service = $taskschedules_service;
53
+	}
54 54
     
55
-    /**
56
-     * {@inheritDoc}
57
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
58
-     */
59
-    public function handle(ServerRequestInterface $request): ResponseInterface
60
-    {
61
-        $task_sched_id = (int) $request->getAttribute('task');
62
-        $task_schedule = $this->taskschedules_service->find($task_sched_id);
55
+	/**
56
+	 * {@inheritDoc}
57
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
58
+	 */
59
+	public function handle(ServerRequestInterface $request): ResponseInterface
60
+	{
61
+		$task_sched_id = (int) $request->getAttribute('task');
62
+		$task_schedule = $this->taskschedules_service->find($task_sched_id);
63 63
         
64
-        $admin_config_route = route(AdminConfigPage::class);
64
+		$admin_config_route = route(AdminConfigPage::class);
65 65
         
66
-        if ($task_schedule === null) {
67
-            FlashMessages::addMessage(
68
-                I18N::translate('The task shedule with ID “%d” does not exist.', I18N::number($task_sched_id)),
69
-                'danger'
70
-            );
71
-            return redirect($admin_config_route);
72
-        }
66
+		if ($task_schedule === null) {
67
+			FlashMessages::addMessage(
68
+				I18N::translate('The task shedule with ID “%d” does not exist.', I18N::number($task_sched_id)),
69
+				'danger'
70
+			);
71
+			return redirect($admin_config_route);
72
+		}
73 73
         
74
-        ((bool) $request->getAttribute('enable', false)) ? $task_schedule->enable() : $task_schedule->disable();
74
+		((bool) $request->getAttribute('enable', false)) ? $task_schedule->enable() : $task_schedule->disable();
75 75
         
76
-        if ($this->taskschedules_service->update($task_schedule) > 0) {
77
-            FlashMessages::addMessage(
78
-                I18N::translate('The scheduled task has been successfully updated'),
79
-                'success'
80
-            );
81
-            //phpcs:ignore Generic.Files.LineLength.TooLong
82
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
83
-        } else {
84
-            FlashMessages::addMessage(
85
-                I18N::translate('An error occured while updating the scheduled task'),
86
-                'danger'
87
-            );
88
-            //phpcs:ignore Generic.Files.LineLength.TooLong
89
-            Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
90
-        }
76
+		if ($this->taskschedules_service->update($task_schedule) > 0) {
77
+			FlashMessages::addMessage(
78
+				I18N::translate('The scheduled task has been successfully updated'),
79
+				'success'
80
+			);
81
+			//phpcs:ignore Generic.Files.LineLength.TooLong
82
+			Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” has been updated.');
83
+		} else {
84
+			FlashMessages::addMessage(
85
+				I18N::translate('An error occured while updating the scheduled task'),
86
+				'danger'
87
+			);
88
+			//phpcs:ignore Generic.Files.LineLength.TooLong
89
+			Log::addConfigurationLog('Module ' . $this->module->title() . ' : Task Schedule “' . $task_schedule->id() . '” could not be updated. See error log.');
90
+		}
91 91
         
92
-        return redirect($admin_config_route);
93
-    }
92
+		return redirect($admin_config_route);
93
+	}
94 94
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Http/RequestHandlers/AdminConfigPage.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -30,55 +30,55 @@
 block discarded – undo
30 30
  */
31 31
 class AdminConfigPage implements RequestHandlerInterface
32 32
 {
33
-    use ViewResponseTrait;
33
+	use ViewResponseTrait;
34 34
 
35
-    /**
36
-     * @var AdminTasksModule $module
37
-     */
38
-    private $module;
35
+	/**
36
+	 * @var AdminTasksModule $module
37
+	 */
38
+	private $module;
39 39
     
40
-    /**
41
-     *
42
-     * @var UserService $user_service
43
-     */
44
-    private $user_service;
40
+	/**
41
+	 *
42
+	 * @var UserService $user_service
43
+	 */
44
+	private $user_service;
45 45
     
46
-    /**
47
-     * Constructor for Admin Config request handler
48
-     *
49
-     * @param ModuleService $module_service
50
-     * @param UserService $user_service
51
-     */
52
-    public function __construct(ModuleService $module_service, UserService $user_service)
53
-    {
54
-        $this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
55
-        $this->user_service = $user_service;
56
-    }
46
+	/**
47
+	 * Constructor for Admin Config request handler
48
+	 *
49
+	 * @param ModuleService $module_service
50
+	 * @param UserService $user_service
51
+	 */
52
+	public function __construct(ModuleService $module_service, UserService $user_service)
53
+	{
54
+		$this->module = $module_service->findByInterface(AdminTasksModule::class)->first();
55
+		$this->user_service = $user_service;
56
+	}
57 57
 
58
-    /**
59
-     * {@inheritDoc}
60
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
61
-     */
62
-    public function handle(ServerRequestInterface $request): ResponseInterface
63
-    {
64
-        $this->layout = 'layouts/administration';
58
+	/**
59
+	 * {@inheritDoc}
60
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
61
+	 */
62
+	public function handle(ServerRequestInterface $request): ResponseInterface
63
+	{
64
+		$this->layout = 'layouts/administration';
65 65
         
66
-        if ($this->module === null) {
67
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
68
-        }
66
+		if ($this->module === null) {
67
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
68
+		}
69 69
         
70
-        $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
71
-        if ($token === '') {
72
-            $token = Functions::generateRandomToken();
73
-            $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token);
74
-        }
70
+		$token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN');
71
+		if ($token === '') {
72
+			$token = Functions::generateRandomToken();
73
+			$this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token);
74
+		}
75 75
         
76
-        return $this->viewResponse($this->module->name() . '::admin/config', [
77
-            'title'             =>  $this->module->title(),
78
-            'trigger_token'     =>  $token,
79
-            'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
80
-            'new_token_route'   =>  route(TokenGenerate::class),
81
-            'tasks_data_route'  =>  route(TasksList::class)
82
-        ]);
83
-    }
76
+		return $this->viewResponse($this->module->name() . '::admin/config', [
77
+			'title'             =>  $this->module->title(),
78
+			'trigger_token'     =>  $token,
79
+			'trigger_route'     =>  route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']),
80
+			'new_token_route'   =>  route(TokenGenerate::class),
81
+			'tasks_data_route'  =>  route(TasksList::class)
82
+		]);
83
+	}
84 84
 }
Please login to merge, or discard this patch.