Completed
Push — master ( b746e6...94717f )
by Jonathan
06:37
created
src/Webtrees/ImageBuilder.php 3 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	*
63 63
 	* @param Media|null $media Reference media object
64 64
 	*/
65
-	public function __construct(Media $media = null){
65
+	public function __construct(Media $media = null) {
66 66
 	    $this->media = $media;
67 67
 	    $this->use_ttf = function_exists('imagettftext');
68 68
 	    $this->expire_offset = 3600 * 24;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return ImageBuilder
88 88
 	 */
89 89
 	public function setExpireOffset($expireOffset) {
90
-	    if($expireOffset) $this->expire_offset = $expireOffset;
90
+	    if ($expireOffset) $this->expire_offset = $expireOffset;
91 91
 	    return $this;
92 92
 	}
93 93
 	
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return ImageBuilder
108 108
 	 */
109 109
 	public function setShowWatermark($show_watermark) {
110
-	    if(!is_null($show_watermark)) $this->show_watermark = $show_watermark;
110
+	    if (!is_null($show_watermark)) $this->show_watermark = $show_watermark;
111 111
 	    return $this;
112 112
 	}
113 113
 	
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @return ImageBuilder
119 119
 	 */
120 120
 	public function setFontMaxSize($font_max_size) {
121
-	    if($font_max_size) $this->font_max_size = $font_max_size;
121
+	    if ($font_max_size) $this->font_max_size = $font_max_size;
122 122
 	    return $this;
123 123
 	}
124 124
 	
@@ -129,32 +129,32 @@  discard block
 block discarded – undo
129 129
 	 * @return ImageBuilder
130 130
 	 */
131 131
 	public function setFontColor($font_color) {
132
-	    if($font_color) $this->font_color = $font_color;
132
+	    if ($font_color) $this->font_color = $font_color;
133 133
 	    return $this;
134 134
 	}
135 135
 	
136 136
 	/**
137 137
 	 * Render the image to the output.
138 138
 	 */
139
-	public function render(){
139
+	public function render() {
140 140
 	    
141 141
 	    if (!$this->media || !$this->media->canShow()) {
142
-	        Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.'));
142
+	        Log::addMediaLog('Image Builder error: >'.I18N::translate('Missing or private media object.'));
143 143
 	        $this->renderError();
144 144
 	    }
145 145
 	    
146 146
 	    $serverFilename = $this->media->getServerFilename();
147 147
 	    
148 148
 	    if (!file_exists($serverFilename)) {
149
-	        Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
149
+	        Log::addMediaLog('Image Builder error: >'.I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
150 150
 	        $this->renderError();
151 151
 	    }
152 152
 	    
153 153
 	    $mimetype = $this->media->mimeType();
154 154
 	    $imgsize = $this->media->getImageAttributes();
155 155
 	    $filetime = $this->media->getFiletime();
156
-	    $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';	    
157
-	    $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT';
156
+	    $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime).' GMT';	    
157
+	    $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()).' GMT';
158 158
 	    
159 159
 	    $type = Functions::isImageTypeSupported($imgsize['ext']);
160 160
 	    $usewatermark = false;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 	    }
187 187
 	    
188 188
 	    // add caching headers.  allow browser to cache file, but not proxy
189
-	    header('Last-Modified: ' . $filetimeHeader);
190
-	    header('ETag: "' . $etag . '"');
191
-	    header('Expires: ' . $expireHeader);
192
-	    header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate');
189
+	    header('Last-Modified: '.$filetimeHeader);
190
+	    header('ETag: "'.$etag.'"');
191
+	    header('Expires: '.$expireHeader);
192
+	    header('Cache-Control: max-age='.$this->getExpireOffset().', s-maxage=0, proxy-revalidate');
193 193
 	    
194 194
 	    // if this file is already in the user’s cache, don’t resend it
195 195
 	    // first check if the if_modified_since param matches
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 	    }	    
204 204
 
205 205
 	    // send headers for the image
206
-	    header('Content-Type: ' . $mimetype);
207
-	    header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"');
206
+	    header('Content-Type: '.$mimetype);
207
+	    header('Content-Disposition: filename="'.addslashes(basename($this->media->getFilename())).'"');
208 208
 	     
209 209
 	    if ($usewatermark) {
210 210
 	        // generate the watermarked image
211
-	        $imCreateFunc = 'imagecreatefrom' . $type;
212
-	        $imSendFunc   = 'image' . $type;
211
+	        $imCreateFunc = 'imagecreatefrom'.$type;
212
+	        $imSendFunc   = 'image'.$type;
213 213
 	    
214 214
 	        if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
215 215
 	            $im = $imCreateFunc($serverFilename);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	            return;
223 223
 	        } else {
224 224
 	            // this image is defective.  log it
225
-	            Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage());
225
+	            Log::addMediaLog('Image Builder error: >'.I18N::translate('This media file is broken and cannot be watermarked.').'< in file >'.$serverFilename.'< memory used: '.memory_get_usage());
226 226
 	        }
227 227
 	    }
228 228
 	    
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	    $filesize = filesize($serverFilename);
231 231
 	    
232 232
 	    // set content-length header, send file
233
-	    header('Content-Length: ' . $filesize);
233
+	    header('Content-Length: '.$filesize);
234 234
 	    
235 235
 	    // Some servers disable fpassthru() and readfile()
236 236
 	    if (function_exists('readfile')) {
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     	$bgc    = imagecolorallocate($im, 255, 255, 255); /* set background color */
261 261
     	imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */
262 262
     
263
-    	$this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left');
263
+    	$this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, 'top', 'left');
264 264
     
265 265
     	http_response_code(404);
266 266
     	header('Content-Type: image/png');
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	protected function applyWatermark($im) {
279 279
 	    
280 280
 	    // text to watermark with	    
281
-	    if(method_exists($this->media, 'getWatermarkText')) {
281
+	    if (method_exists($this->media, 'getWatermarkText')) {
282 282
 	       $word1_text = $this->media->getWatermarkText();
283 283
 	    }
284 284
 	    else {
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	        $word1_text, 
291 291
 	        $this->font_max_size,
292 292
 	        $this->font_color,
293
-	        WT_ROOT . Config::FONT_DEJAVU_SANS_TTF,
293
+	        WT_ROOT.Config::FONT_DEJAVU_SANS_TTF,
294 294
 	        'top', 
295 295
 	        'left'
296 296
 	     );
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 	 * @param string $hexstr
410 410
 	 * @return int[]
411 411
 	 */
412
-	protected function hexrgb ($hexstr)
412
+	protected function hexrgb($hexstr)
413 413
 	{
414 414
 	    $int = hexdec($hexstr);
415 415
 	
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
      */
452 452
     function imageTtfTextErrorHandler($errno, $errstr) {
453 453
         // log the error
454
-        Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<');
454
+        Log::addErrorLog('Image Builder error: >'.$errno.'/'.$errstr.'< while processing file >'.$this->media->getServerFilename().'<');
455 455
     
456 456
         // change value of useTTF to false so the fallback watermarking can be used.
457 457
         $this->use_ttf = false;
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -87,7 +87,9 @@  discard block
 block discarded – undo
87 87
 	 * @return ImageBuilder
88 88
 	 */
89 89
 	public function setExpireOffset($expireOffset) {
90
-	    if($expireOffset) $this->expire_offset = $expireOffset;
90
+	    if($expireOffset) {
91
+	    	$this->expire_offset = $expireOffset;
92
+	    }
91 93
 	    return $this;
92 94
 	}
93 95
 	
@@ -107,7 +109,9 @@  discard block
 block discarded – undo
107 109
 	 * @return ImageBuilder
108 110
 	 */
109 111
 	public function setShowWatermark($show_watermark) {
110
-	    if(!is_null($show_watermark)) $this->show_watermark = $show_watermark;
112
+	    if(!is_null($show_watermark)) {
113
+	    	$this->show_watermark = $show_watermark;
114
+	    }
111 115
 	    return $this;
112 116
 	}
113 117
 	
@@ -118,7 +122,9 @@  discard block
 block discarded – undo
118 122
 	 * @return ImageBuilder
119 123
 	 */
120 124
 	public function setFontMaxSize($font_max_size) {
121
-	    if($font_max_size) $this->font_max_size = $font_max_size;
125
+	    if($font_max_size) {
126
+	    	$this->font_max_size = $font_max_size;
127
+	    }
122 128
 	    return $this;
123 129
 	}
124 130
 	
@@ -129,7 +135,9 @@  discard block
 block discarded – undo
129 135
 	 * @return ImageBuilder
130 136
 	 */
131 137
 	public function setFontColor($font_color) {
132
-	    if($font_color) $this->font_color = $font_color;
138
+	    if($font_color) {
139
+	    	$this->font_color = $font_color;
140
+	    }
133 141
 	    return $this;
134 142
 	}
135 143
 	
@@ -280,8 +288,7 @@  discard block
 block discarded – undo
280 288
 	    // text to watermark with	    
281 289
 	    if(method_exists($this->media, 'getWatermarkText')) {
282 290
 	       $word1_text = $this->media->getWatermarkText();
283
-	    }
284
-	    else {
291
+	    } else {
285 292
 	        $word1_text = $this->media->getTitle();
286 293
 	    }
287 294
 	
Please login to merge, or discard this patch.
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -22,54 +22,54 @@  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 61
 	/**
62
-	* Contructor for ImageBuilder
63
-	*
64
-	* @param Media|null $media Reference media object
65
-	*/
62
+	 * Contructor for ImageBuilder
63
+	 *
64
+	 * @param Media|null $media Reference media object
65
+	 */
66 66
 	public function __construct(Media $media = null){
67
-	    $this->media = $media;
68
-	    $this->use_ttf = function_exists('imagettftext');
69
-	    $this->expire_offset = 3600 * 24;
70
-	    $this->show_watermark = true;
71
-	    $this->font_max_size = 18;
72
-	    $this->font_color = '#4D6DF3';
67
+		$this->media = $media;
68
+		$this->use_ttf = function_exists('imagettftext');
69
+		$this->expire_offset = 3600 * 24;
70
+		$this->show_watermark = true;
71
+		$this->font_max_size = 18;
72
+		$this->font_color = '#4D6DF3';
73 73
 	}
74 74
 	
75 75
 	/**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return int
79 79
 	 */
80 80
 	public function getExpireOffset() {
81
-	    return $this->expire_offset;
81
+		return $this->expire_offset;
82 82
 	}
83 83
 	
84 84
 	/**
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 * @return ImageBuilder
89 89
 	 */
90 90
 	public function setExpireOffset($expireOffset) {
91
-	    if($expireOffset) $this->expire_offset = $expireOffset;
92
-	    return $this;
91
+		if($expireOffset) $this->expire_offset = $expireOffset;
92
+		return $this;
93 93
 	}
94 94
 	
95 95
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @return bool
99 99
 	 */
100 100
 	public function isShowWatermark() {
101
-	    return $this->show_watermark;
101
+		return $this->show_watermark;
102 102
 	}
103 103
 	
104 104
 	/**
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @return ImageBuilder
109 109
 	 */
110 110
 	public function setShowWatermark($show_watermark) {
111
-	    if(!is_null($show_watermark)) $this->show_watermark = $show_watermark;
112
-	    return $this;
111
+		if(!is_null($show_watermark)) $this->show_watermark = $show_watermark;
112
+		return $this;
113 113
 	}
114 114
 	
115 115
 	/**
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @return ImageBuilder
120 120
 	 */
121 121
 	public function setFontMaxSize($font_max_size) {
122
-	    if($font_max_size) $this->font_max_size = $font_max_size;
123
-	    return $this;
122
+		if($font_max_size) $this->font_max_size = $font_max_size;
123
+		return $this;
124 124
 	}
125 125
 	
126 126
 	/**
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	 * @return ImageBuilder
131 131
 	 */
132 132
 	public function setFontColor($font_color) {
133
-	    if($font_color) $this->font_color = $font_color;
134
-	    return $this;
133
+		if($font_color) $this->font_color = $font_color;
134
+		return $this;
135 135
 	}
136 136
 	
137 137
 	/**
@@ -139,134 +139,134 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public function render(){
141 141
 	    
142
-	    if (!$this->media || !$this->media->canShow()) {
143
-	        Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.'));
144
-	        $this->renderError();
145
-	    }
142
+		if (!$this->media || !$this->media->canShow()) {
143
+			Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.'));
144
+			$this->renderError();
145
+		}
146 146
 	    
147
-	    $serverFilename = $this->media->getServerFilename();
147
+		$serverFilename = $this->media->getServerFilename();
148 148
 	    
149
-	    if (!file_exists($serverFilename)) {
150
-	        Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
151
-	        $this->renderError();
152
-	    }
149
+		if (!file_exists($serverFilename)) {
150
+			Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
151
+			$this->renderError();
152
+		}
153 153
 	    
154
-	    $mimetype = $this->media->mimeType();
155
-	    $imgsize = $this->media->getImageAttributes();
156
-	    $filetime = $this->media->getFiletime();
157
-	    $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';	    
158
-	    $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT';
154
+		$mimetype = $this->media->mimeType();
155
+		$imgsize = $this->media->getImageAttributes();
156
+		$filetime = $this->media->getFiletime();
157
+		$filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';	    
158
+		$expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT';
159 159
 	    
160
-	    $type = Functions::isImageTypeSupported($imgsize['ext']);
161
-	    $usewatermark = false;
162
-	    // if this image supports watermarks and the watermark module is intalled...
163
-	    if ($type) {
164
-	        $usewatermark = $this->isShowWatermark();
165
-	    }
160
+		$type = Functions::isImageTypeSupported($imgsize['ext']);
161
+		$usewatermark = false;
162
+		// if this image supports watermarks and the watermark module is intalled...
163
+		if ($type) {
164
+			$usewatermark = $this->isShowWatermark();
165
+		}
166 166
 	    
167
-	    // determine whether we have enough memory to watermark this image
168
-	    if ($usewatermark) {
169
-	        if (!FunctionsMedia::hasMemoryForImage($serverFilename)) {
170
-	            // not enough memory to watermark this file
171
-	            $usewatermark = false;
172
-	        }
173
-	    }
167
+		// determine whether we have enough memory to watermark this image
168
+		if ($usewatermark) {
169
+			if (!FunctionsMedia::hasMemoryForImage($serverFilename)) {
170
+				// not enough memory to watermark this file
171
+				$usewatermark = false;
172
+			}
173
+		}
174 174
 	    
175
-	    $etag = $this->media->getEtag();
175
+		$etag = $this->media->getEtag();
176 176
 	    
177
-	    // parse IF_MODIFIED_SINCE header from client
178
-	    $if_modified_since = 'x';
179
-	    if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) {
180
-	        $if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE'));
181
-	    }
177
+		// parse IF_MODIFIED_SINCE header from client
178
+		$if_modified_since = 'x';
179
+		if (!empty(Filter::server('HTTP_IF_MODIFIED_SINCE'))) {
180
+			$if_modified_since = preg_replace('/;.*$/', '', Filter::server('HTTP_IF_MODIFIED_SINCE'));
181
+		}
182 182
 	    
183
-	    // parse IF_NONE_MATCH header from client
184
-	    $if_none_match = 'x';
185
-	    if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) {
186
-	        $if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH'));
187
-	    }
183
+		// parse IF_NONE_MATCH header from client
184
+		$if_none_match = 'x';
185
+		if (!empty(Filter::server('HTTP_IF_NONE_MATCH'))) {
186
+			$if_none_match = str_replace('"', '', Filter::server('HTTP_IF_NONE_MATCH'));
187
+		}
188 188
 	    
189
-	    // add caching headers.  allow browser to cache file, but not proxy
190
-	    header('Last-Modified: ' . $filetimeHeader);
191
-	    header('ETag: "' . $etag . '"');
192
-	    header('Expires: ' . $expireHeader);
193
-	    header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate');
189
+		// add caching headers.  allow browser to cache file, but not proxy
190
+		header('Last-Modified: ' . $filetimeHeader);
191
+		header('ETag: "' . $etag . '"');
192
+		header('Expires: ' . $expireHeader);
193
+		header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate');
194 194
 	    
195
-	    // if this file is already in the user’s cache, don’t resend it
196
-	    // first check if the if_modified_since param matches
197
-	    if ($if_modified_since === $filetimeHeader) {
198
-	        // then check if the etag matches
199
-	        if ($if_none_match === $etag) {
200
-	            http_response_code(304);
195
+		// if this file is already in the user’s cache, don’t resend it
196
+		// first check if the if_modified_since param matches
197
+		if ($if_modified_since === $filetimeHeader) {
198
+			// then check if the etag matches
199
+			if ($if_none_match === $etag) {
200
+				http_response_code(304);
201 201
 	    
202
-	            return;
203
-	        }
204
-	    }	    
202
+				return;
203
+			}
204
+		}	    
205 205
 
206
-	    // send headers for the image
207
-	    header('Content-Type: ' . $mimetype);
208
-	    header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"');
206
+		// send headers for the image
207
+		header('Content-Type: ' . $mimetype);
208
+		header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"');
209 209
 	     
210
-	    if ($usewatermark) {
211
-	        // generate the watermarked image
212
-	        $imCreateFunc = 'imagecreatefrom' . $type;
213
-	        $imSendFunc   = 'image' . $type;
210
+		if ($usewatermark) {
211
+			// generate the watermarked image
212
+			$imCreateFunc = 'imagecreatefrom' . $type;
213
+			$imSendFunc   = 'image' . $type;
214 214
 	    
215
-	        if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
216
-	            $im = $imCreateFunc($serverFilename);
217
-	            $im = $this->applyWatermark($im);
215
+			if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
216
+				$im = $imCreateFunc($serverFilename);
217
+				$im = $this->applyWatermark($im);
218 218
 	    	    
219
-	            // send the image
220
-	            $imSendFunc($im);
221
-	            imagedestroy($im);
219
+				// send the image
220
+				$imSendFunc($im);
221
+				imagedestroy($im);
222 222
 	    
223
-	            return;
224
-	        } else {
225
-	            // this image is defective.  log it
226
-	            Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage());
227
-	        }
228
-	    }
223
+				return;
224
+			} else {
225
+				// this image is defective.  log it
226
+				Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage());
227
+			}
228
+		}
229 229
 	    
230
-	    // determine filesize of image (could be original or watermarked version)
231
-	    $filesize = filesize($serverFilename);
230
+		// determine filesize of image (could be original or watermarked version)
231
+		$filesize = filesize($serverFilename);
232 232
 	    
233
-	    // set content-length header, send file
234
-	    header('Content-Length: ' . $filesize);
233
+		// set content-length header, send file
234
+		header('Content-Length: ' . $filesize);
235 235
 	    
236
-	    // Some servers disable fpassthru() and readfile()
237
-	    if (function_exists('readfile')) {
238
-	        readfile($serverFilename);
239
-	    } else {
240
-	        $fp = fopen($serverFilename, 'rb');
241
-	        if (function_exists('fpassthru')) {
242
-	            fpassthru($fp);
243
-	        } else {
244
-	            while (!feof($fp)) {
245
-	                echo fread($fp, 65536);
246
-	            }
247
-	        }
248
-	        fclose($fp);
249
-	    }	    
236
+		// Some servers disable fpassthru() and readfile()
237
+		if (function_exists('readfile')) {
238
+			readfile($serverFilename);
239
+		} else {
240
+			$fp = fopen($serverFilename, 'rb');
241
+			if (function_exists('fpassthru')) {
242
+				fpassthru($fp);
243
+			} else {
244
+				while (!feof($fp)) {
245
+					echo fread($fp, 65536);
246
+				}
247
+			}
248
+			fclose($fp);
249
+		}	    
250 250
 	}
251 251
 	
252 252
 	/**
253 253
 	 * Render an error as an image.
254 254
 	 */
255 255
 	protected function renderError() {	
256
-	    $error = I18N::translate('The media file was not found in this family tree.');
256
+		$error = I18N::translate('The media file was not found in this family tree.');
257 257
 
258
-    	$width  = (mb_strlen($error) * 6.5 + 50) * 1.15;
259
-    	$height = 60;
260
-    	$im     = imagecreatetruecolor($width, $height); /* Create a black image */
261
-    	$bgc    = imagecolorallocate($im, 255, 255, 255); /* set background color */
262
-    	imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */
258
+		$width  = (mb_strlen($error) * 6.5 + 50) * 1.15;
259
+		$height = 60;
260
+		$im     = imagecreatetruecolor($width, $height); /* Create a black image */
261
+		$bgc    = imagecolorallocate($im, 255, 255, 255); /* set background color */
262
+		imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */
263 263
     
264
-    	$this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left');
264
+		$this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left');
265 265
     
266
-    	http_response_code(404);
267
-    	header('Content-Type: image/png');
268
-    	imagepng($im);
269
-    	imagedestroy($im);
266
+		http_response_code(404);
267
+		header('Content-Type: image/png');
268
+		imagepng($im);
269
+		imagedestroy($im);
270 270
 	}
271 271
 	
272 272
 	/**
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	protected function applyWatermark($im) {
280 280
 	    
281
-	    // text to watermark with	    
282
-	    if(method_exists($this->media, 'getWatermarkText')) {
283
-	       $word1_text = $this->media->getWatermarkText();
284
-	    }
285
-	    else {
286
-	        $word1_text = $this->media->getTitle();
287
-	    }
281
+		// text to watermark with	    
282
+		if(method_exists($this->media, 'getWatermarkText')) {
283
+		   $word1_text = $this->media->getWatermarkText();
284
+		}
285
+		else {
286
+			$word1_text = $this->media->getTitle();
287
+		}
288 288
 	
289
-	    $this->embedText(
290
-	        $im, 
291
-	        $word1_text, 
292
-	        $this->font_max_size,
293
-	        $this->font_color,
294
-	        WT_ROOT . Config::FONT_DEJAVU_SANS_TTF,
295
-	        'top', 
296
-	        'left'
297
-	     );
289
+		$this->embedText(
290
+			$im, 
291
+			$word1_text, 
292
+			$this->font_max_size,
293
+			$this->font_color,
294
+			WT_ROOT . Config::FONT_DEJAVU_SANS_TTF,
295
+			'top', 
296
+			'left'
297
+		 );
298 298
 	
299
-	    return ($im);
299
+		return ($im);
300 300
 	}
301 301
 	
302 302
 	/**
@@ -313,94 +313,94 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	protected function embedText($im, $text, $maxsize, $color, $font, $vpos, $hpos) {
315 315
 	    
316
-	    // there are two ways to embed text with PHP
317
-	    // (preferred) using GD and FreeType you can embed text using any True Type font
318
-	    // (fall back) if that is not available, you can insert basic monospaced text
316
+		// there are two ways to embed text with PHP
317
+		// (preferred) using GD and FreeType you can embed text using any True Type font
318
+		// (fall back) if that is not available, you can insert basic monospaced text
319 319
 	    
320
-	    $col = $this->hexrgb($color);
321
-	    $textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']);
320
+		$col = $this->hexrgb($color);
321
+		$textcolor = imagecolorallocate($im, $col['red'], $col['green'], $col['blue']);
322 322
 	    
323
-	    // make adjustments to settings that imagestring and imagestringup can’t handle
324
-	    if (!$this->use_ttf) {
325
-	        // imagestringup only writes up, can’t use top2bottom
326
-	        if ($hpos === 'top2bottom') {
327
-	            $hpos = 'bottom2top';
328
-	        }
329
-	    }
323
+		// make adjustments to settings that imagestring and imagestringup can’t handle
324
+		if (!$this->use_ttf) {
325
+			// imagestringup only writes up, can’t use top2bottom
326
+			if ($hpos === 'top2bottom') {
327
+				$hpos = 'bottom2top';
328
+			}
329
+		}
330 330
 	    
331
-	    $text       = I18N::reverseText($text);
332
-	    $height     = imagesy($im);
333
-	    $width      = imagesx($im);
334
-	    $calc_angle = rad2deg(atan($height / $width));
335
-	    $hypoth     = $height / sin(deg2rad($calc_angle));
331
+		$text       = I18N::reverseText($text);
332
+		$height     = imagesy($im);
333
+		$width      = imagesx($im);
334
+		$calc_angle = rad2deg(atan($height / $width));
335
+		$hypoth     = $height / sin(deg2rad($calc_angle));
336 336
 	    
337
-	    // vertical and horizontal position of the text
338
-	    switch ($vpos) {
339
-	        default:
340
-	        case 'top':
341
-	            $taille   = $this->textLength($maxsize, $width, $text);
342
-	            $pos_y    = $height * 0.15 + $taille;
343
-	            $pos_x    = $width * 0.15;
344
-	            $rotation = 0;
345
-	            break;
346
-	        case 'middle':
347
-	            $taille   = $this->textLength($maxsize, $width, $text);
348
-	            $pos_y    = ($height + $taille) / 2;
349
-	            $pos_x    = $width * 0.15;
350
-	            $rotation = 0;
351
-	            break;
352
-	        case 'bottom':
353
-	            $taille   = $this->textLength($maxsize, $width, $text);
354
-	            $pos_y    = ($height * .85 - $taille);
355
-	            $pos_x    = $width * 0.15;
356
-	            $rotation = 0;
357
-	            break;
358
-	        case 'across':
359
-	            switch ($hpos) {
360
-	                default:
361
-	                case 'left':
362
-	                    $taille   = $this->textLength($maxsize, $hypoth, $text);
363
-	                    $pos_y    = ($height * .85 - $taille);
364
-	                    $pos_x    = $width * 0.15;
365
-	                    $rotation = $calc_angle;
366
-	                    break;
367
-	                case 'right':
368
-	                    $taille   = $this->textLength($maxsize, $hypoth, $text);
369
-	                    $pos_y    = ($height * .15 - $taille);
370
-	                    $pos_x    = $width * 0.85;
371
-	                    $rotation = $calc_angle + 180;
372
-	                    break;
373
-	                case 'top2bottom':
374
-	                    $taille   = $this->textLength($maxsize, $height, $text);
375
-	                    $pos_y    = ($height * .15 - $taille);
376
-	                    $pos_x    = ($width * .90 - $taille);
377
-	                    $rotation = -90;
378
-	                    break;
379
-	                case 'bottom2top':
380
-	                    $taille   = $this->textLength($maxsize, $height, $text);
381
-	                    $pos_y    = $height * 0.85;
382
-	                    $pos_x    = $width * 0.15;
383
-	                    $rotation = 90;
384
-	                    break;
385
-	            }
386
-	            break;
387
-	    }
337
+		// vertical and horizontal position of the text
338
+		switch ($vpos) {
339
+			default:
340
+			case 'top':
341
+				$taille   = $this->textLength($maxsize, $width, $text);
342
+				$pos_y    = $height * 0.15 + $taille;
343
+				$pos_x    = $width * 0.15;
344
+				$rotation = 0;
345
+				break;
346
+			case 'middle':
347
+				$taille   = $this->textLength($maxsize, $width, $text);
348
+				$pos_y    = ($height + $taille) / 2;
349
+				$pos_x    = $width * 0.15;
350
+				$rotation = 0;
351
+				break;
352
+			case 'bottom':
353
+				$taille   = $this->textLength($maxsize, $width, $text);
354
+				$pos_y    = ($height * .85 - $taille);
355
+				$pos_x    = $width * 0.15;
356
+				$rotation = 0;
357
+				break;
358
+			case 'across':
359
+				switch ($hpos) {
360
+					default:
361
+					case 'left':
362
+						$taille   = $this->textLength($maxsize, $hypoth, $text);
363
+						$pos_y    = ($height * .85 - $taille);
364
+						$pos_x    = $width * 0.15;
365
+						$rotation = $calc_angle;
366
+						break;
367
+					case 'right':
368
+						$taille   = $this->textLength($maxsize, $hypoth, $text);
369
+						$pos_y    = ($height * .15 - $taille);
370
+						$pos_x    = $width * 0.85;
371
+						$rotation = $calc_angle + 180;
372
+						break;
373
+					case 'top2bottom':
374
+						$taille   = $this->textLength($maxsize, $height, $text);
375
+						$pos_y    = ($height * .15 - $taille);
376
+						$pos_x    = ($width * .90 - $taille);
377
+						$rotation = -90;
378
+						break;
379
+					case 'bottom2top':
380
+						$taille   = $this->textLength($maxsize, $height, $text);
381
+						$pos_y    = $height * 0.85;
382
+						$pos_x    = $width * 0.15;
383
+						$rotation = 90;
384
+						break;
385
+				}
386
+				break;
387
+		}
388 388
 	    
389
-	    // apply the text
390
-	    if ($this->use_ttf) {
391
-	        // if imagettftext throws errors, catch them with a custom error handler
392
-	        set_error_handler(array($this, 'imageTtfTextErrorHandler'));
393
-	        imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text);
394
-	        restore_error_handler();
395
-	    }
396
-	    // Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false
397
-	    if (!$this->use_ttf) {
398
-	        if ($rotation !== 90) {
399
-	            imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor);
400
-	        } else {
401
-	            imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor);
402
-	        }
403
-	    }
389
+		// apply the text
390
+		if ($this->use_ttf) {
391
+			// if imagettftext throws errors, catch them with a custom error handler
392
+			set_error_handler(array($this, 'imageTtfTextErrorHandler'));
393
+			imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, $font, $text);
394
+			restore_error_handler();
395
+		}
396
+		// Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false
397
+		if (!$this->use_ttf) {
398
+			if ($rotation !== 90) {
399
+				imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor);
400
+			} else {
401
+				imagestringup($im, 5, $pos_x, $pos_y, $text, $textcolor);
402
+			}
403
+		}
404 404
 	
405 405
 	}
406 406
 	
@@ -412,53 +412,53 @@  discard block
 block discarded – undo
412 412
 	 */
413 413
 	protected function hexrgb ($hexstr)
414 414
 	{
415
-	    $int = hexdec($hexstr);
415
+		$int = hexdec($hexstr);
416 416
 	
417
-	    return array('red' => 0xFF & ($int >> 0x10),
418
-	        'green' => 0xFF & ($int >> 0x8),
419
-	        'blue' => 0xFF & $int);
417
+		return array('red' => 0xFF & ($int >> 0x10),
418
+			'green' => 0xFF & ($int >> 0x8),
419
+			'blue' => 0xFF & $int);
420 420
 	}
421 421
 	
422
-    /**
423
-     * Generate an approximate length of text, in pixels.
424
-     *
425
-     * @param int    $t
426
-     * @param int    $mxl
427
-     * @param string $text
428
-     *
429
-     * @return int
430
-     */
431
-    function textLength($t, $mxl, $text) {
432
-    	$taille_c = $t;
433
-    	$len      = mb_strlen($text);
434
-    	while (($taille_c - 2) * $len > $mxl) {
435
-    		$taille_c--;
436
-    		if ($taille_c == 2) {
437
-    			break;
438
-    		}
439
-    	}
422
+	/**
423
+	 * Generate an approximate length of text, in pixels.
424
+	 *
425
+	 * @param int    $t
426
+	 * @param int    $mxl
427
+	 * @param string $text
428
+	 *
429
+	 * @return int
430
+	 */
431
+	function textLength($t, $mxl, $text) {
432
+		$taille_c = $t;
433
+		$len      = mb_strlen($text);
434
+		while (($taille_c - 2) * $len > $mxl) {
435
+			$taille_c--;
436
+			if ($taille_c == 2) {
437
+				break;
438
+			}
439
+		}
440 440
     
441
-    	return $taille_c;
442
-    }
441
+		return $taille_c;
442
+	}
443 443
     
444
-    /**
445
-     * imagettftext is the function that is most likely to throw an error
446
-     * use this custom error handler to catch and log it
447
-     *
448
-     * @param int    $errno
449
-     * @param string $errstr
450
-     *
451
-     * @return bool
452
-     */
453
-    function imageTtfTextErrorHandler($errno, $errstr) {
454
-        // log the error
455
-        Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<');
444
+	/**
445
+	 * imagettftext is the function that is most likely to throw an error
446
+	 * use this custom error handler to catch and log it
447
+	 *
448
+	 * @param int    $errno
449
+	 * @param string $errstr
450
+	 *
451
+	 * @return bool
452
+	 */
453
+	function imageTtfTextErrorHandler($errno, $errstr) {
454
+		// log the error
455
+		Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<');
456 456
     
457
-        // change value of useTTF to false so the fallback watermarking can be used.
458
-        $this->use_ttf = false;
457
+		// change value of useTTF to false so the fallback watermarking can be used.
458
+		$this->use_ttf = false;
459 459
     
460
-        return true;
461
-    }
460
+		return true;
461
+	}
462 462
 		
463 463
 }
464 464
 
Please login to merge, or discard this patch.
src/Webtrees/Hook/HookSubscriberInterface.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
  */
16 16
 interface HookSubscriberInterface {
17 17
 	
18
-    /**
18
+	/**
19 19
 	 * Return the list of functions implementented in the class which needs to be registered as hooks.
20 20
 	 * The format is either { function1, function 2,...} in which case the priority is the default one
21 21
 	 * or { function1 => priority1, function2 => priority2, ...}
22 22
 	 * 
23 23
 	 * @return array Array of hooks
24 24
 	 */
25
-    public function getSubscribedHooks();
25
+	public function getSubscribedHooks();
26 26
     
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Hook/HookInterfaces/FactSourceTextExtenderInterface.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -19,6 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * Insert some content before the fact source text.
20 20
 	 * 
21 21
 	 * @param string $srec Source fact record
22
+	 * @return string
22 23
 	 */
23 24
 	public function hFactSourcePrepend($srec);
24 25
 	
@@ -26,6 +27,7 @@  discard block
 block discarded – undo
26 27
 	 * Insert some content after the fact source text.
27 28
 	 * 
28 29
 	 * @param string $srec Source fact record
30
+	 * @return void
29 31
 	 */
30 32
 	public function hFactSourceAppend($srec);
31 33
 	
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
  /**
3
- * webtrees-lib: MyArtJaub library for webtrees
4
- *
5
- * @package MyArtJaub\Webtrees
6
- * @subpackage Hook
7
- * @author Jonathan Jaubart <[email protected]>
8
- * @copyright Copyright (c) 2011-2016, Jonathan Jaubart
9
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
10
- */
3
+  * webtrees-lib: MyArtJaub library for webtrees
4
+  *
5
+  * @package MyArtJaub\Webtrees
6
+  * @subpackage Hook
7
+  * @author Jonathan Jaubart <[email protected]>
8
+  * @copyright Copyright (c) 2011-2016, Jonathan Jaubart
9
+  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
10
+  */
11 11
 namespace MyArtJaub\Webtrees\Hook\HookInterfaces;
12 12
 
13 13
 /**
Please login to merge, or discard this patch.
src/Webtrees/Cache.php 4 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,9 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 */
82 82
 	protected function checkInit(){
83
-		if(!$this->is_init) $this->init();
83
+		if(!$this->is_init) {
84
+			$this->init();
85
+		}
84 86
 	}
85 87
 	
86 88
 	/**
@@ -93,7 +95,9 @@  discard block
 block discarded – undo
93 95
 	protected function getKeyName($value, AbstractModule $mod = null){
94 96
 	    $this->checkInit();
95 97
 		$mod_name = 'myartjaub';
96
-		if($mod !== null) $mod_name = $mod->getName();
98
+		if($mod !== null) {
99
+			$mod_name = $mod->getName();
100
+		}
97 101
 		return $mod_name.'_'.$value;
98 102
 	}
99 103
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
 	/**
147 147
 	 * Static invocation of the *save* method.
148 148
 	 *
149
-	 * @param string|\Psr\Cache\CacheItemInterface $value Value name
149
+	 * @param CacheItemInterface $value Value name
150 150
 	 * @param mixed $data Value
151 151
 	 * @param AbstractModule $mod Calling module
152 152
 	 */
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Cache{
24 24
 	
25
-    /**
26
-     * Underlying Cache object
27
-     * @var CacheItemPoolInterface $cache
28
-     */
25
+	/**
26
+	 * Underlying Cache object
27
+	 * @var CacheItemPoolInterface $cache
28
+	 */
29 29
 	protected $cache=null;
30 30
 	
31 31
 	/**
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	protected static function getInstance()
49 49
 	{
50
-	    if (null === static::$instance) {
51
-	        static::$instance = new static();
52
-	    }
50
+		if (null === static::$instance) {
51
+			static::$instance = new static();
52
+		}
53 53
 	
54
-	    return static::$instance;
54
+		return static::$instance;
55 55
 	}
56 56
 	
57 57
 	/**
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 */
61 61
 	protected function init() {		
62
-	    if(Apc::isAvailable()) {
63
-		    $driver = new Apc();
62
+		if(Apc::isAvailable()) {
63
+			$driver = new Apc();
64 64
 		} else {
65 65
 			if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
66 66
 				// We may not have permission - especially during setup, before we instruct
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				@mkdir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache');
69 69
 			}
70 70
 			if (is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
71
-			    $driver = new FileSystem(array('path' => WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache'));
71
+				$driver = new FileSystem(array('path' => WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache'));
72 72
 			} else {
73 73
 				// No cache available, let's just use a basic one :-(
74 74
 				$driver = new Ephemeral();
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return string Cached key name
96 96
 	 */
97 97
 	protected function getKeyName($value, AbstractModule $mod = null){
98
-	    $this->checkInit();
98
+		$this->checkInit();
99 99
 		$mod_name = 'myartjaub';
100 100
 		if($mod !== null) $mod_name = $mod->getName();
101 101
 		return $mod_name.'_'.$value;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return \Psr\Cache\CacheItemInterface
110 110
 	 */
111 111
 	public function getI($value, AbstractModule $mod = null){
112
-	    $this->checkInit();
112
+		$this->checkInit();
113 113
 		return $this->cache->getItem($this->getKeyName($value, $mod));
114 114
 	}
115 115
 	
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return \Psr\Cache\CacheItemInterface
122 122
 	 */
123 123
 	public static function get($value, AbstractModule $mod = null){
124
-	    return self::getInstance()->getI($value, $mod);
124
+		return self::getInstance()->getI($value, $mod);
125 125
 	}
126 126
 	
127 127
 	/**
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 		
137 137
 		$item = $value;
138 138
 		if(!($value instanceof CacheItemInterface)) {
139
-		    $item = new \Stash\Item();
140
-    		$item->setKey($this->getKeyName($value, $mod));
139
+			$item = new \Stash\Item();
140
+			$item->setKey($this->getKeyName($value, $mod));
141 141
 		}		
142 142
 		$item->set($data);
143 143
 		$this->cache->save($item);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @param AbstractModule $mod Calling module
152 152
 	 */
153 153
 	public static function save($value, $data, AbstractModule $mod = null){
154
-	    self::getInstance()->saveI($value, $data, $mod);
154
+		self::getInstance()->saveI($value, $data, $mod);
155 155
 	}
156 156
 	
157 157
 	/**
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @return bool Deletion successful?
163 163
 	 */
164 164
 	public function deleteI($value, AbstractModule $mod = null){
165
-	    $this->checkInit();	
166
-	    return $this->cache->deleteItem($this->getKeyName($value, $mod));
165
+		$this->checkInit();	
166
+		return $this->cache->deleteItem($this->getKeyName($value, $mod));
167 167
 	}
168 168
 	
169 169
 	/**
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return bool Deletion successful?
175 175
 	 */
176 176
 	public static function delete($value, AbstractModule $mod = null){
177
-	    return self::getInstance()->deleteI($value, $mod);
177
+		return self::getInstance()->deleteI($value, $mod);
178 178
 	}
179 179
 	
180 180
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 */
184 184
 	public function cleanI(){
185
-	    $this->checkInit();
185
+		$this->checkInit();
186 186
 		$this->cache->clear();
187 187
 	}
188 188
 	
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * Static invocation of the *clean* method.
191 191
 	 */
192 192
 	public static function clean() {
193
-	    self::getInstance()->cleanI();
193
+		self::getInstance()->cleanI();
194 194
 	}
195 195
 	
196 196
 }
197 197
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Cache component to speed up some potential data retrievals
22 22
  */
23
-class Cache{
23
+class Cache {
24 24
 	
25 25
     /**
26 26
      * Underlying Cache object
27 27
      * @var CacheItemPoolInterface $cache
28 28
      */
29
-	protected $cache=null;
29
+	protected $cache = null;
30 30
 	
31 31
 	/**
32 32
 	 * Defines whether the cache has been initialised
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 */
61 61
 	protected function init() {		
62
-	    if(Apc::isAvailable()) {
62
+	    if (Apc::isAvailable()) {
63 63
 		    $driver = new Apc();
64 64
 		} else {
65 65
 			if (!is_dir(WT_DATA_DIR.DIRECTORY_SEPARATOR.'cache')) {
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 * Initiliase the Cache if not done.
84 84
 	 *
85 85
 	 */
86
-	protected function checkInit(){
87
-		if(!$this->is_init) $this->init();
86
+	protected function checkInit() {
87
+		if (!$this->is_init) $this->init();
88 88
 	}
89 89
 	
90 90
 	/**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 	 * @param AbstractModule $mod Calling module
95 95
 	 * @return string Cached key name
96 96
 	 */
97
-	protected function getKeyName($value, AbstractModule $mod = null){
97
+	protected function getKeyName($value, AbstractModule $mod = null) {
98 98
 	    $this->checkInit();
99 99
 		$mod_name = 'myartjaub';
100
-		if($mod !== null) $mod_name = $mod->getName();
100
+		if ($mod !== null) $mod_name = $mod->getName();
101 101
 		return $mod_name.'_'.$value;
102 102
 	}
103 103
 	
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @param AbstractModule $mod Calling module
109 109
 	 * @return \Psr\Cache\CacheItemInterface
110 110
 	 */
111
-	public function getI($value, AbstractModule $mod = null){
111
+	public function getI($value, AbstractModule $mod = null) {
112 112
 	    $this->checkInit();
113 113
 		return $this->cache->getItem($this->getKeyName($value, $mod));
114 114
 	}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param AbstractModule $mod Calling module
121 121
 	 * @return \Psr\Cache\CacheItemInterface
122 122
 	 */
123
-	public static function get($value, AbstractModule $mod = null){
123
+	public static function get($value, AbstractModule $mod = null) {
124 124
 	    return self::getInstance()->getI($value, $mod);
125 125
 	}
126 126
 	
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 	 * @param mixed $data Value
132 132
 	 * @param AbstractModule $mod Calling module
133 133
 	 */
134
-	public function saveI($value, $data, AbstractModule $mod = null){
134
+	public function saveI($value, $data, AbstractModule $mod = null) {
135 135
 		$this->checkInit();
136 136
 		
137 137
 		$item = $value;
138
-		if(!($value instanceof CacheItemInterface)) {
138
+		if (!($value instanceof CacheItemInterface)) {
139 139
 		    $item = new \Stash\Item();
140 140
     		$item->setKey($this->getKeyName($value, $mod));
141 141
 		}		
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param mixed $data Value
151 151
 	 * @param AbstractModule $mod Calling module
152 152
 	 */
153
-	public static function save($value, $data, AbstractModule $mod = null){
153
+	public static function save($value, $data, AbstractModule $mod = null) {
154 154
 	    self::getInstance()->saveI($value, $data, $mod);
155 155
 	}
156 156
 	
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @param AbstractModule $mod Calling module
162 162
 	 * @return bool Deletion successful?
163 163
 	 */
164
-	public function deleteI($value, AbstractModule $mod = null){
164
+	public function deleteI($value, AbstractModule $mod = null) {
165 165
 	    $this->checkInit();	
166 166
 	    return $this->cache->deleteItem($this->getKeyName($value, $mod));
167 167
 	}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 * @param AbstractModule $mod Calling module
174 174
 	 * @return bool Deletion successful?
175 175
 	 */
176
-	public static function delete($value, AbstractModule $mod = null){
176
+	public static function delete($value, AbstractModule $mod = null) {
177 177
 	    return self::getInstance()->deleteI($value, $mod);
178 178
 	}
179 179
 	
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * Clean the cache
182 182
 	 *
183 183
 	 */
184
-	public function cleanI(){
184
+	public function cleanI() {
185 185
 	    $this->checkInit();
186 186
 		$this->cache->clear();
187 187
 	}
Please login to merge, or discard this patch.
src/Webtrees/GedcomRecord.php 3 patches
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -104,9 +104,12 @@  discard block
 block discarded – undo
104 104
 	public function canDisplayIsSourced($access_level = null){
105 105
 		global $global_facts;
106 106
 
107
-		if(!$this->gedcomrecord->canShow($access_level)) return false;
108
-		if($access_level === null )
109
-		    $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree());
107
+		if(!$this->gedcomrecord->canShow($access_level)) {
108
+			return false;
109
+		}
110
+		if($access_level === null ) {
111
+				    $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree());
112
+		}
110 113
 
111 114
 		if (isset($global_facts['SOUR'])) {
112 115
 			return $global_facts['SOUR'] >= $access_level;
@@ -125,7 +128,9 @@  discard block
 block discarded – undo
125 128
 	 * @return int Level of sources
126 129
 	 */
127 130
 	public function isSourced(){
128
-		if($this->_issourced !== null) return $this->_issourced;
131
+		if($this->_issourced !== null) {
132
+			return $this->_issourced;
133
+		}
129 134
 		$this->_issourced=-1;
130 135
 		$sourcesfacts = $this->gedcomrecord->getFacts('SOUR');
131 136
 		foreach($sourcesfacts as $sourcefact){
@@ -144,7 +149,9 @@  discard block
 block discarded – undo
144 149
 	 * @return int Level of sources
145 150
 	 */
146 151
 	public function isFactSourced($eventslist){
147
-	    if(empty($eventslist)) return 0;
152
+	    if(empty($eventslist)) {
153
+	    	return 0;
154
+	    }
148 155
 		$isSourced=0;
149 156
 		$facts = $this->gedcomrecord->getFacts($eventslist);
150 157
 		foreach($facts as $fact){
@@ -154,8 +161,7 @@  discard block
 block discarded – undo
154 161
 				if($tmpIsSourced != 0) {
155 162
 					if($isSourced==0) {
156 163
 						$isSourced =  $tmpIsSourced;
157
-					}
158
-					else{
164
+					} else{
159 165
 						$isSourced = max($isSourced, $tmpIsSourced);
160 166
 					}
161 167
 				}
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		if(!$this->gedcomrecord->canShow($access_level)) return false;
93 93
 		if($access_level === null )
94
-		    $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree());
94
+			$access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree());
95 95
 
96 96
 		if (isset($global_facts['SOUR'])) {
97 97
 			return $global_facts['SOUR'] >= $access_level;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @return int Level of sources
130 130
 	 */
131 131
 	public function isFactSourced($eventslist){
132
-	    if(empty($eventslist)) return 0;
132
+		if(empty($eventslist)) return 0;
133 133
 		$isSourced=0;
134 134
 		$facts = $this->gedcomrecord->getFacts($eventslist);
135 135
 		foreach($facts as $fact){
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	protected $gedcomrecord;
24 24
 
25 25
 	/** @var bool Is the GedcomRecord sourced (cache) */ 
26
-	protected $_issourced=null;
26
+	protected $_issourced = null;
27 27
 
28 28
 	/**
29 29
 	 * Contructor for the decorator
30 30
 	 *
31 31
 	 * @param \Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in The GedcomRecord to extend
32 32
 	 */
33
-	public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in){
33
+	public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in) {
34 34
 		$this->gedcomrecord = $gedcomrecord_in;
35 35
 	}
36 36
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return \Fisharebest\Webtrees\GedcomRecord Embedded gedcom record
41 41
 	 */
42
-	public function getDerivedRecord(){
42
+	public function getDerivedRecord() {
43 43
 		return $this->gedcomrecord;
44 44
 	}
45 45
 	
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			if (($fact->getDate() || $fact->getPlace()) && $fact->canShow()) {
71 71
 				switch ($style) {
72 72
 					case 10:
73
-						return '<i>'.$fact->getLabel().' '. mw\Functions\FunctionsPrint::formatFactDateShort($fact) .'&nbsp;'. mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1') .'</i>';
73
+						return '<i>'.$fact->getLabel().' '.mw\Functions\FunctionsPrint::formatFactDateShort($fact).'&nbsp;'.mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1').'</i>';
74 74
 					default:
75 75
 						return $this->gedcomrecord->formatFirstMajorFact($facts, $style);
76 76
 				}
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 	 * @param int $access_level
86 86
 	 * @return boolean
87 87
 	 */
88
-	public function canDisplayIsSourced($access_level = null){
88
+	public function canDisplayIsSourced($access_level = null) {
89 89
 		global $global_facts;
90 90
 
91
-		if(!$this->gedcomrecord->canShow($access_level)) return false;
92
-		if($access_level === null )
91
+		if (!$this->gedcomrecord->canShow($access_level)) return false;
92
+		if ($access_level === null)
93 93
 		    $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree());
94 94
 
95 95
 		if (isset($global_facts['SOUR'])) {
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return int Level of sources
110 110
 	 */
111
-	public function isSourced(){
112
-		if($this->_issourced !== null) return $this->_issourced;
113
-		$this->_issourced=-1;
111
+	public function isSourced() {
112
+		if ($this->_issourced !== null) return $this->_issourced;
113
+		$this->_issourced = -1;
114 114
 		$sourcesfacts = $this->gedcomrecord->getFacts('SOUR');
115
-		foreach($sourcesfacts as $sourcefact){
116
-			$this->_issourced=max($this->_issourced, 1);
117
-			if($sourcefact->getAttribute('_ACT')){
118
-				$this->_issourced=max($this->_issourced, 2);
115
+		foreach ($sourcesfacts as $sourcefact) {
116
+			$this->_issourced = max($this->_issourced, 1);
117
+			if ($sourcefact->getAttribute('_ACT')) {
118
+				$this->_issourced = max($this->_issourced, 2);
119 119
 			}
120 120
 		}
121 121
 		return $this->_issourced;
@@ -127,19 +127,19 @@  discard block
 block discarded – undo
127 127
 	 * @param string $eventslist
128 128
 	 * @return int Level of sources
129 129
 	 */
130
-	public function isFactSourced($eventslist){
131
-	    if(empty($eventslist)) return 0;
132
-		$isSourced=0;
130
+	public function isFactSourced($eventslist) {
131
+	    if (empty($eventslist)) return 0;
132
+		$isSourced = 0;
133 133
 		$facts = $this->gedcomrecord->getFacts($eventslist);
134
-		foreach($facts as $fact){
135
-			if($isSourced < Fact::MAX_IS_SOURCED_LEVEL){
134
+		foreach ($facts as $fact) {
135
+			if ($isSourced < Fact::MAX_IS_SOURCED_LEVEL) {
136 136
 				$dfact = new Fact($fact);
137 137
 				$tmpIsSourced = $dfact->isSourced();
138
-				if($tmpIsSourced != 0) {
139
-					if($isSourced==0) {
140
-						$isSourced =  $tmpIsSourced;
138
+				if ($tmpIsSourced != 0) {
139
+					if ($isSourced == 0) {
140
+						$isSourced = $tmpIsSourced;
141 141
 					}
142
-					else{
142
+					else {
143 143
 						$isSourced = max($isSourced, $tmpIsSourced);
144 144
 					}
145 145
 				}
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageBuilder.php 2 patches
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -54,30 +54,30 @@  discard block
 block discarded – undo
54 54
 	public function buildLineages() {				
55 55
 		$indis = \Fisharebest\Webtrees\Query\QueryName::individuals($this->tree, $this->surname, null, null, false, false);
56 56
 		
57
-		if(count($indis) == 0) return null;
57
+		if (count($indis) == 0) return null;
58 58
 		
59 59
 		$root_lineages = array();
60 60
 		
61
-		foreach($indis as $indi) {
61
+		foreach ($indis as $indi) {
62 62
 			$pid = $indi->getXref();
63
-			if(!isset($this->used_indis[$pid])){
63
+			if (!isset($this->used_indis[$pid])) {
64 64
 				//Find the root of the lineage
65 65
 				/** @var Fisharebest\Webtrees\Individual $indiFirst  */
66
-				$indiFirst= $this->getLineageRootIndividual($indi);
67
-				if($indiFirst){
66
+				$indiFirst = $this->getLineageRootIndividual($indi);
67
+				if ($indiFirst) {
68 68
 					$this->used_indis[$indiFirst->getXref()] = true;
69
-					if($indiFirst->canShow()){
69
+					if ($indiFirst->canShow()) {
70 70
 						//Check if the root individual has brothers and sisters, without parents
71 71
 						$indiChildFamily = $indiFirst->getPrimaryChildFamily();
72
-						if($indiChildFamily !== null){
72
+						if ($indiChildFamily !== null) {
73 73
 							$root_node = new LineageRootNode(null); 
74 74
 							$root_node->addFamily($indiChildFamily);
75 75
 						}
76
-						else{
76
+						else {
77 77
 							$root_node = new LineageRootNode($indiFirst);
78 78
 						}
79 79
 						$root_node = $this->buildLineage($root_node);		
80
-						if($root_node) $root_lineages[] = $root_node;
80
+						if ($root_node) $root_lineages[] = $root_node;
81 81
 					}
82 82
 				}
83 83
 			}
@@ -94,45 +94,45 @@  discard block
 block discarded – undo
94 94
 	 * @return (Individual|null) Root individual
95 95
 	 */
96 96
 	protected function getLineageRootIndividual(Individual $indi) {
97
-		$is_first=false;
97
+		$is_first = false;
98 98
 		$dindi = new \MyArtJaub\Webtrees\Individual($indi);
99
-		$indi_surname=$dindi->getUnprotectedPrimarySurname();
99
+		$indi_surname = $dindi->getUnprotectedPrimarySurname();
100 100
 		$resIndi = $indi;
101
-		while(!$is_first){
101
+		while (!$is_first) {
102 102
 			//Get the individual parents family
103
-			$fam=$resIndi->getPrimaryChildFamily();
104
-			if($fam){
105
-				$husb=$fam->getHusband();
106
-				$wife=$fam->getWife();
103
+			$fam = $resIndi->getPrimaryChildFamily();
104
+			if ($fam) {
105
+				$husb = $fam->getHusband();
106
+				$wife = $fam->getWife();
107 107
 				//If the father exists, take him
108
-				if($husb){
108
+				if ($husb) {
109 109
 					$dhusb = new \MyArtJaub\Webtrees\Individual($husb);
110
-					$dhusb->isNewAddition() ? $is_first = true : $resIndi=$husb;
110
+					$dhusb->isNewAddition() ? $is_first = true : $resIndi = $husb;
111 111
 				}
112 112
 				//If only a mother exists
113
-				else if($wife){
113
+				else if ($wife) {
114 114
 					$dwife = new \MyArtJaub\Webtrees\Individual($wife);
115
-					$wife_surname=$dwife->getUnprotectedPrimarySurname();
115
+					$wife_surname = $dwife->getUnprotectedPrimarySurname();
116 116
 					//Check if the child is a natural child of the mother (based on the surname - Warning : surname must be identical)
117
-					if(!$dwife->isNewAddition() && I18N::strcasecmp($wife_surname, $indi_surname) == 0){
118
-						$resIndi=$wife;
117
+					if (!$dwife->isNewAddition() && I18N::strcasecmp($wife_surname, $indi_surname) == 0) {
118
+						$resIndi = $wife;
119 119
 					}
120
-					else{
121
-						$is_first=true;
120
+					else {
121
+						$is_first = true;
122 122
 					}
123 123
 				}
124
-				else{
125
-					$is_first=true;
124
+				else {
125
+					$is_first = true;
126 126
 				}
127 127
 			}
128
-			else{
129
-				$is_first=true;
128
+			else {
129
+				$is_first = true;
130 130
 			}
131 131
 		}
132
-		if(isset($this->used_indis[$resIndi->getXref()])){
132
+		if (isset($this->used_indis[$resIndi->getXref()])) {
133 133
 			return null;
134 134
 		}
135
-		else{
135
+		else {
136 136
 			return $resIndi;
137 137
 		}
138 138
 	}
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 	 * @return LineageNode Computed lineage
146 146
 	 */
147 147
 	protected function buildLineage(LineageNode $node) {
148
-		if($node === null) return;
148
+		if ($node === null) return;
149 149
 		
150 150
 		$indi_surname = null;
151 151
 		
152 152
 		$indi_node = $node->getIndividual();			
153
-		if($indi_node) {
154
-			if(count($node->getFamiliesNodes()) == 0) {
153
+		if ($indi_node) {
154
+			if (count($node->getFamiliesNodes()) == 0) {
155 155
 				$indiSpouseFamilies = $indi_node->getSpouseFamilies();
156
-				foreach($indiSpouseFamilies as $indiSpouseFamily) {
156
+				foreach ($indiSpouseFamilies as $indiSpouseFamily) {
157 157
 					$node->addFamily($indiSpouseFamily);
158 158
 				}
159 159
 			}
@@ -162,62 +162,62 @@  discard block
 block discarded – undo
162 162
 			$indi_surname = $dindi_node->getUnprotectedPrimarySurname();
163 163
 			
164 164
 			//Get the estimated birth place and put it in the place table
165
-			$place=$dindi_node->getEstimatedBirthPlace(false);
166
-			if($place && strlen($place) > 0){
167
-				$place=trim($place);
165
+			$place = $dindi_node->getEstimatedBirthPlace(false);
166
+			if ($place && strlen($place) > 0) {
167
+				$place = trim($place);
168 168
 				$node->getRootNode()->addPlace(new Place($place, $this->tree));
169 169
 			}
170 170
 				
171 171
 			//Tag the individual as used
172
-			$this->used_indis[$indi_node->getXref()]=true;
172
+			$this->used_indis[$indi_node->getXref()] = true;
173 173
 		}
174 174
 		
175
-		foreach($node->getFamiliesNodes() as $family) {
175
+		foreach ($node->getFamiliesNodes() as $family) {
176 176
 			$spouse_surname = null;
177
-			if($indi_node && $spouse = $family->getSpouse($indi_node)) {
177
+			if ($indi_node && $spouse = $family->getSpouse($indi_node)) {
178 178
 				$dspouse = new \MyArtJaub\Webtrees\Individual($spouse);
179
-				$spouse_surname=$dspouse->getUnprotectedPrimarySurname();
179
+				$spouse_surname = $dspouse->getUnprotectedPrimarySurname();
180 180
 			}
181 181
 			
182 182
 			$children = $family->getChildren();
183 183
 
184
-			$nbChildren=0;
185
-			$nbNatural=0;
184
+			$nbChildren = 0;
185
+			$nbNatural = 0;
186 186
 			
187
-			foreach($children as $child){
187
+			foreach ($children as $child) {
188 188
 				$dchild = new \MyArtJaub\Webtrees\Individual($child);
189
-				$child_surname=$dchild->getUnprotectedPrimarySurname();
189
+				$child_surname = $dchild->getUnprotectedPrimarySurname();
190 190
 				
191
-				if(!$dchild->isNewAddition()) {
191
+				if (!$dchild->isNewAddition()) {
192 192
 					$nbChildren++;
193 193
 					//If the root individual is the mother
194
-					if($indi_node && I18N::strcasecmp($indi_node->getSex(), 'F') == 0) {
194
+					if ($indi_node && I18N::strcasecmp($indi_node->getSex(), 'F') == 0) {
195 195
 						//Print only lineages of children with the same surname as their mother (supposing they are natural children)
196
-						if(!$spouse || ($spouse_surname && I18N::strcasecmp($child_surname, $spouse_surname) != 0)){
197
-							if(I18N::strcasecmp($child_surname, $indi_surname) == 0){
196
+						if (!$spouse || ($spouse_surname && I18N::strcasecmp($child_surname, $spouse_surname) != 0)) {
197
+							if (I18N::strcasecmp($child_surname, $indi_surname) == 0) {
198 198
 								$nbNatural++;
199 199
 								$node_child = new LineageNode($child, $node->getRootNode());							
200 200
 								$node_child = $this->buildLineage($node_child);
201
-								if($node_child) $node->addChild($family, $node_child);
201
+								if ($node_child) $node->addChild($family, $node_child);
202 202
 							}
203 203
 						}
204 204
 					}
205 205
 					//If the root individual is the father
206 206
 					else {
207 207
 						//Print if the children does not bear the same name as his mother (and different from his father)
208
-						if( strlen($child_surname) == 0 || strlen($indi_surname) == 0 || strlen($spouse_surname) == 0 ||
208
+						if (strlen($child_surname) == 0 || strlen($indi_surname) == 0 || strlen($spouse_surname) == 0 ||
209 209
 							I18N::strcasecmp($child_surname, $indi_surname) == 0 ||
210
-							I18N::strcasecmp($child_surname, $spouse_surname) != 0 )
210
+							I18N::strcasecmp($child_surname, $spouse_surname) != 0)
211 211
 						{
212 212
 							$nbNatural++;
213 213
 							$node_child = new LineageNode($child, $node->getRootNode());							
214 214
 							$node_child = $this->buildLineage($node_child);
215
-							if($node_child) $node->addChild($family, $node_child);
215
+							if ($node_child) $node->addChild($family, $node_child);
216 216
 						}
217 217
 						else {
218 218
 							$nbNatural++;
219 219
 							$node_child = new LineageNode($child, $node->getRootNode(), $child_surname);
220
-							if($node_child) $node->addChild($family, $node_child);
220
+							if ($node_child) $node->addChild($family, $node_child);
221 221
 						}
222 222
 					}
223 223
 				}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 
227 227
 			//Do not print other children
228
-			if(($nbChildren-$nbNatural)>0){
228
+			if (($nbChildren - $nbNatural) > 0) {
229 229
 				$node->addChild($family, null);
230 230
 			}
231 231
 		}
Please login to merge, or discard this patch.
Braces   +24 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 	public function buildLineages() {				
55 55
 		$indis = \Fisharebest\Webtrees\Query\QueryName::individuals($this->tree, $this->surname, null, null, false, false);
56 56
 		
57
-		if(count($indis) == 0) return null;
57
+		if(count($indis) == 0) {
58
+			return null;
59
+		}
58 60
 		
59 61
 		$root_lineages = array();
60 62
 		
@@ -72,12 +74,13 @@  discard block
 block discarded – undo
72 74
 						if($indiChildFamily !== null){
73 75
 							$root_node = new LineageRootNode(null); 
74 76
 							$root_node->addFamily($indiChildFamily);
75
-						}
76
-						else{
77
+						} else{
77 78
 							$root_node = new LineageRootNode($indiFirst);
78 79
 						}
79 80
 						$root_node = $this->buildLineage($root_node);		
80
-						if($root_node) $root_lineages[] = $root_node;
81
+						if($root_node) {
82
+							$root_lineages[] = $root_node;
83
+						}
81 84
 					}
82 85
 				}
83 86
 			}
@@ -116,23 +119,19 @@  discard block
 block discarded – undo
116 119
 					//Check if the child is a natural child of the mother (based on the surname - Warning : surname must be identical)
117 120
 					if(!$dwife->isNewAddition() && I18N::strcasecmp($wife_surname, $indi_surname) == 0){
118 121
 						$resIndi=$wife;
119
-					}
120
-					else{
122
+					} else{
121 123
 						$is_first=true;
122 124
 					}
123
-				}
124
-				else{
125
+				} else{
125 126
 					$is_first=true;
126 127
 				}
127
-			}
128
-			else{
128
+			} else{
129 129
 				$is_first=true;
130 130
 			}
131 131
 		}
132 132
 		if(isset($this->used_indis[$resIndi->getXref()])){
133 133
 			return null;
134
-		}
135
-		else{
134
+		} else{
136 135
 			return $resIndi;
137 136
 		}
138 137
 	}
@@ -145,7 +144,9 @@  discard block
 block discarded – undo
145 144
 	 * @return LineageNode Computed lineage
146 145
 	 */
147 146
 	protected function buildLineage(LineageNode $node) {
148
-		if($node === null) return;
147
+		if($node === null) {
148
+			return;
149
+		}
149 150
 		
150 151
 		$indi_surname = null;
151 152
 		
@@ -198,7 +199,9 @@  discard block
 block discarded – undo
198 199
 								$nbNatural++;
199 200
 								$node_child = new LineageNode($child, $node->getRootNode());							
200 201
 								$node_child = $this->buildLineage($node_child);
201
-								if($node_child) $node->addChild($family, $node_child);
202
+								if($node_child) {
203
+									$node->addChild($family, $node_child);
204
+								}
202 205
 							}
203 206
 						}
204 207
 					}
@@ -212,12 +215,15 @@  discard block
 block discarded – undo
212 215
 							$nbNatural++;
213 216
 							$node_child = new LineageNode($child, $node->getRootNode());							
214 217
 							$node_child = $this->buildLineage($node_child);
215
-							if($node_child) $node->addChild($family, $node_child);
216
-						}
217
-						else {
218
+							if($node_child) {
219
+								$node->addChild($family, $node_child);
220
+							}
221
+						} else {
218 222
 							$nbNatural++;
219 223
 							$node_child = new LineageNode($child, $node->getRootNode(), $child_surname);
220
-							if($node_child) $node->addChild($family, $node_child);
224
+							if($node_child) {
225
+								$node->addChild($family, $node_child);
226
+							}
221 227
 						}
222 228
 					}
223 229
 				}
Please login to merge, or discard this patch.
src/Webtrees/Module/Certificates/AdminConfigController.php 3 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -28,77 +28,77 @@
 block discarded – undo
28 28
  */
29 29
 class AdminConfigController extends MvcController
30 30
 {
31
-    /**
32
-     * Manage updates sent from the AdminConfig@index form.
33
-     */
34
-    protected function update() {
31
+	/**
32
+	 * Manage updates sent from the AdminConfig@index form.
33
+	 */
34
+	protected function update() {
35 35
         
36
-        if(Auth::isAdmin()){
36
+		if(Auth::isAdmin()){
37 37
             
38
-            $this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT'));
39
-            $this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK'));
38
+			$this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT'));
39
+			$this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK'));
40 40
             
41
-            if($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
42
-                $this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT);
43
-            }
41
+			if($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
42
+				$this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT);
43
+			}
44 44
             
45
-            if($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
46
-                $this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE);
47
-            }
45
+			if($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
46
+				$this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE);
47
+			}
48 48
             
49
-            // Only accept valid color for MAJ_WM_FONT_COLOR
50
-            $MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}');            
51
-            if($MAJ_WM_FONT_COLOR) {
52
-                $this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR);
53
-            }
49
+			// Only accept valid color for MAJ_WM_FONT_COLOR
50
+			$MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}');            
51
+			if($MAJ_WM_FONT_COLOR) {
52
+				$this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR);
53
+			}
54 54
             
55
-            // Only accept valid folders for MAJ_CERT_ROOTDIR
56
-            $MAJ_CERT_ROOTDIR = preg_replace('/[\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/');
57
-            if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') {
58
-                $MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1);
59
-            }
55
+			// Only accept valid folders for MAJ_CERT_ROOTDIR
56
+			$MAJ_CERT_ROOTDIR = preg_replace('/[\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/');
57
+			if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') {
58
+				$MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1);
59
+			}
60 60
             
61
-            if ($MAJ_CERT_ROOTDIR) {
62
-                if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
63
-                    $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
64
-                } elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
65
-                    $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
66
-                    FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info');
67
-                } else {
68
-                    FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger');
69
-                }
70
-            }
61
+			if ($MAJ_CERT_ROOTDIR) {
62
+				if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
63
+					$this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
64
+				} elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
65
+					$this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
66
+					FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info');
67
+				} else {
68
+					FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger');
69
+				}
70
+			}
71 71
             
72
-            FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
72
+			FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
73 73
             
74
-            return;
75
-        }
76
-    }
74
+			return;
75
+		}
76
+	}
77 77
     
78
-    /**
79
-     * Pages
80
-     */
78
+	/**
79
+	 * Pages
80
+	 */
81 81
         
82
-    /**
83
-     * AdminConfig@index
84
-     */
85
-    public function index() {      
86
-        global $WT_TREE;
82
+	/**
83
+	 * AdminConfig@index
84
+	 */
85
+	public function index() {      
86
+		global $WT_TREE;
87 87
         
88
-        $action = Filter::post('action');        
89
-        if($action == 'update' && Filter::checkCsrf()) $this->update();
88
+		$action = Filter::post('action');        
89
+		if($action == 'update' && Filter::checkCsrf()) $this->update();
90 90
         
91
-        Theme::theme(new AdministrationTheme)->init($WT_TREE);        
92
-        $ctrl = new PageController();
93
-        $ctrl
94
-            ->restrictAccess(Auth::isAdmin())
95
-            ->setPageTitle($this->module->getTitle());
91
+		Theme::theme(new AdministrationTheme)->init($WT_TREE);        
92
+		$ctrl = new PageController();
93
+		$ctrl
94
+			->restrictAccess(Auth::isAdmin())
95
+			->setPageTitle($this->module->getTitle());
96 96
 
97
-        $view_bag = new ViewBag();
98
-        $view_bag->set('title', $ctrl->getPageTitle());
99
-        $view_bag->set('module', $this->module);
97
+		$view_bag = new ViewBag();
98
+		$view_bag->set('title', $ctrl->getPageTitle());
99
+		$view_bag->set('module', $this->module);
100 100
         
101
-        ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render();
102
-    }
101
+		ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render();
102
+	}
103 103
         
104 104
 }
105 105
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -33,39 +33,39 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function update() {
35 35
         
36
-        if(Auth::isAdmin()){
36
+        if (Auth::isAdmin()) {
37 37
             
38 38
             $this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT'));
39 39
             $this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK'));
40 40
             
41
-            if($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
41
+            if ($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
42 42
                 $this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT);
43 43
             }
44 44
             
45
-            if($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
45
+            if ($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
46 46
                 $this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE);
47 47
             }
48 48
             
49 49
             // Only accept valid color for MAJ_WM_FONT_COLOR
50 50
             $MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}');            
51
-            if($MAJ_WM_FONT_COLOR) {
51
+            if ($MAJ_WM_FONT_COLOR) {
52 52
                 $this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR);
53 53
             }
54 54
             
55 55
             // Only accept valid folders for MAJ_CERT_ROOTDIR
56
-            $MAJ_CERT_ROOTDIR = preg_replace('/[\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/');
56
+            $MAJ_CERT_ROOTDIR = preg_replace('/[\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR').'/');
57 57
             if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') {
58 58
                 $MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1);
59 59
             }
60 60
             
61 61
             if ($MAJ_CERT_ROOTDIR) {
62
-                if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
62
+                if (is_dir(WT_DATA_DIR.$MAJ_CERT_ROOTDIR)) {
63 63
                     $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
64
-                } elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
64
+                } elseif (File::mkdir(WT_DATA_DIR.$MAJ_CERT_ROOTDIR)) {
65 65
                     $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
66
-                    FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info');
66
+                    FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR.$MAJ_CERT_ROOTDIR)), 'info');
67 67
                 } else {
68
-                    FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger');
68
+                    FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR.$MAJ_CERT_ROOTDIR)), 'danger');
69 69
                 }
70 70
             }
71 71
             
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         global $WT_TREE;
87 87
         
88 88
         $action = Filter::post('action');        
89
-        if($action == 'update' && Filter::checkCsrf()) $this->update();
89
+        if ($action == 'update' && Filter::checkCsrf()) $this->update();
90 90
         
91 91
         Theme::theme(new AdministrationTheme)->init($WT_TREE);        
92 92
         $ctrl = new PageController();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@
 block discarded – undo
66 66
         global $WT_TREE;
67 67
         
68 68
         $action = Filter::post('action');        
69
-        if($action == 'update' && Filter::checkCsrf()) $this->update();
69
+        if($action == 'update' && Filter::checkCsrf()) {
70
+        	$this->update();
71
+        }
70 72
         
71 73
         Theme::theme(new AdministrationTheme)->init($WT_TREE);        
72 74
         $ctrl = new PageController();
Please login to merge, or discard this patch.
src/Webtrees/Module/Certificates/Model/CertificateFileProvider.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -20,111 +20,111 @@
 block discarded – undo
20 20
  */
21 21
 class CertificateFileProvider implements CertificateProviderInterface {
22 22
     
23
-    /**
24
-     * Relative path to the root certificate folder
25
-     * @var string $root_path
26
-     */
27
-    protected $root_path;
23
+	/**
24
+	 * Relative path to the root certificate folder
25
+	 * @var string $root_path
26
+	 */
27
+	protected $root_path;
28 28
     
29
-    /**
30
-     * Reference tree
31
-     * @var Tree $tree
32
-     */
33
-    protected $tree;
29
+	/**
30
+	 * Reference tree
31
+	 * @var Tree $tree
32
+	 */
33
+	protected $tree;
34 34
     
35
-    /**
36
-     * Cached list of certificates' cities.
37
-     * @var (null|array) $cities_list
38
-     */
39
-    protected $cities_list = null;
35
+	/**
36
+	 * Cached list of certificates' cities.
37
+	 * @var (null|array) $cities_list
38
+	 */
39
+	protected $cities_list = null;
40 40
     
41
-    /**
42
-     * Constructor for the File Provider
43
-     * @param string $root_path
44
-     * @param Tree $tree
45
-     */
46
-    public function __construct($root_path, Tree $tree) {
47
-        $this->root_path = $root_path;
48
-        $this->tree = $tree;
49
-    }
41
+	/**
42
+	 * Constructor for the File Provider
43
+	 * @param string $root_path
44
+	 * @param Tree $tree
45
+	 */
46
+	public function __construct($root_path, Tree $tree) {
47
+		$this->root_path = $root_path;
48
+		$this->tree = $tree;
49
+	}
50 50
         
51
-    /**
52
-     * {@inhericDoc}
53
-     * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getRealCertificatesDirectory()
54
-     */
55
-    public function getRealCertificatesDirectory(){
56
-        return WT_DATA_DIR . $this->root_path;
57
-    }
51
+	/**
52
+	 * {@inhericDoc}
53
+	 * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getRealCertificatesDirectory()
54
+	 */
55
+	public function getRealCertificatesDirectory(){
56
+		return WT_DATA_DIR . $this->root_path;
57
+	}
58 58
     
59
-    /**
60
-     * {@inhericDoc}
61
-     * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCitiesList()
62
-     */
63
-    public function getCitiesList(){
64
-        if(!isset($this->cities_list) || is_null($this->cities_list)){
65
-            $certdir = $this->getRealCertificatesDirectory();
66
-            $this->cities_list = array();
59
+	/**
60
+	 * {@inhericDoc}
61
+	 * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCitiesList()
62
+	 */
63
+	public function getCitiesList(){
64
+		if(!isset($this->cities_list) || is_null($this->cities_list)){
65
+			$certdir = $this->getRealCertificatesDirectory();
66
+			$this->cities_list = array();
67 67
     
68
-            $dir = opendir($certdir);
68
+			$dir = opendir($certdir);
69 69
             
70
-            while($entry = readdir($dir)){
71
-                if($entry != '.' && $entry != '..' && is_dir($certdir.$entry)){
72
-                    $this->cities_list[]= Functions::encodeFileSystemToUtf8($entry);
73
-                }
74
-            }
75
-            sort($this->cities_list);
76
-        }
77
-        return $this->cities_list;
78
-    }
70
+			while($entry = readdir($dir)){
71
+				if($entry != '.' && $entry != '..' && is_dir($certdir.$entry)){
72
+					$this->cities_list[]= Functions::encodeFileSystemToUtf8($entry);
73
+				}
74
+			}
75
+			sort($this->cities_list);
76
+		}
77
+		return $this->cities_list;
78
+	}
79 79
     
80
-    /**
81
-     * {@inhericDoc}
82
-     * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesList()
83
-     */
84
-    public function getCertificatesList($selCity){
80
+	/**
81
+	 * {@inhericDoc}
82
+	 * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesList()
83
+	 */
84
+	public function getCertificatesList($selCity){
85 85
     
86
-        $selCity = Functions::encodeUtf8ToFileSystem($selCity);
86
+		$selCity = Functions::encodeUtf8ToFileSystem($selCity);
87 87
     
88
-        $certdir = $this->getRealCertificatesDirectory();
89
-        $tabCertif= array();
88
+		$certdir = $this->getRealCertificatesDirectory();
89
+		$tabCertif= array();
90 90
     
91
-        if(is_dir($certdir.$selCity)){
92
-            $dir=opendir($certdir.$selCity);
93
-            while($entry = readdir($dir)){
94
-                if($entry!='.' && $entry!='..' && !is_dir($certdir.$entry.'/')){
95
-                    $path = Functions::encodeFileSystemToUtf8($selCity.'/'.$entry);
96
-                    $certificate = new Certificate($path, $this->tree, $this);
97
-                    if(Functions::isImageTypeSupported($certificate->extension())){
98
-                        $tabCertif[] = 	$certificate;
99
-                    }
100
-                }
101
-            }
102
-        }
103
-        return $tabCertif;
104
-    }
91
+		if(is_dir($certdir.$selCity)){
92
+			$dir=opendir($certdir.$selCity);
93
+			while($entry = readdir($dir)){
94
+				if($entry!='.' && $entry!='..' && !is_dir($certdir.$entry.'/')){
95
+					$path = Functions::encodeFileSystemToUtf8($selCity.'/'.$entry);
96
+					$certificate = new Certificate($path, $this->tree, $this);
97
+					if(Functions::isImageTypeSupported($certificate->extension())){
98
+						$tabCertif[] = 	$certificate;
99
+					}
100
+				}
101
+			}
102
+		}
103
+		return $tabCertif;
104
+	}
105 105
     
106
-    /**
107
-     * {@inhericDoc}
108
-     * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesListBeginWith()
109
-     */
110
-    public function getCertificatesListBeginWith($city, $contains, $limit= 9999){
111
-        $tabFiles= array();
112
-        $dirPath= $this->getRealCertificatesDirectory() . Functions::encodeUtf8ToFileSystem($city).'/';
113
-        $contains = utf8_decode($contains);
114
-        $nbCert = 0;
106
+	/**
107
+	 * {@inhericDoc}
108
+	 * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesListBeginWith()
109
+	 */
110
+	public function getCertificatesListBeginWith($city, $contains, $limit= 9999){
111
+		$tabFiles= array();
112
+		$dirPath= $this->getRealCertificatesDirectory() . Functions::encodeUtf8ToFileSystem($city).'/';
113
+		$contains = utf8_decode($contains);
114
+		$nbCert = 0;
115 115
     
116
-        if(is_dir($dirPath)){
117
-            $dir=opendir($dirPath);
118
-            while(($entry = readdir($dir)) && $nbCert < $limit){
119
-                if($entry!='.' && $entry!='..' && $entry!='Thumbs.db' &&!is_dir($dirPath.$entry.'/') && stripos($entry, $contains)!== false){
120
-                    $tabFiles[]= Functions::encodeFileSystemToUtf8($entry);
121
-                    $nbCert++;
122
-                }
123
-            }
124
-        }
125
-        sort($tabFiles);
126
-        return $tabFiles;
127
-    }
116
+		if(is_dir($dirPath)){
117
+			$dir=opendir($dirPath);
118
+			while(($entry = readdir($dir)) && $nbCert < $limit){
119
+				if($entry!='.' && $entry!='..' && $entry!='Thumbs.db' &&!is_dir($dirPath.$entry.'/') && stripos($entry, $contains)!== false){
120
+					$tabFiles[]= Functions::encodeFileSystemToUtf8($entry);
121
+					$nbCert++;
122
+				}
123
+			}
124
+		}
125
+		sort($tabFiles);
126
+		return $tabFiles;
127
+	}
128 128
     
129 129
 }
130 130
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,24 +52,24 @@  discard block
 block discarded – undo
52 52
      * {@inhericDoc}
53 53
      * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getRealCertificatesDirectory()
54 54
      */
55
-    public function getRealCertificatesDirectory(){
56
-        return WT_DATA_DIR . $this->root_path;
55
+    public function getRealCertificatesDirectory() {
56
+        return WT_DATA_DIR.$this->root_path;
57 57
     }
58 58
     
59 59
     /**
60 60
      * {@inhericDoc}
61 61
      * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCitiesList()
62 62
      */
63
-    public function getCitiesList(){
64
-        if(!isset($this->cities_list) || is_null($this->cities_list)){
63
+    public function getCitiesList() {
64
+        if (!isset($this->cities_list) || is_null($this->cities_list)) {
65 65
             $certdir = $this->getRealCertificatesDirectory();
66 66
             $this->cities_list = array();
67 67
     
68 68
             $dir = opendir($certdir);
69 69
             
70
-            while($entry = readdir($dir)){
71
-                if($entry != '.' && $entry != '..' && is_dir($certdir.$entry)){
72
-                    $this->cities_list[]= Functions::encodeFileSystemToUtf8($entry);
70
+            while ($entry = readdir($dir)) {
71
+                if ($entry != '.' && $entry != '..' && is_dir($certdir.$entry)) {
72
+                    $this->cities_list[] = Functions::encodeFileSystemToUtf8($entry);
73 73
                 }
74 74
             }
75 75
             sort($this->cities_list);
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
      * {@inhericDoc}
82 82
      * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesList()
83 83
      */
84
-    public function getCertificatesList($selCity){
84
+    public function getCertificatesList($selCity) {
85 85
     
86 86
         $selCity = Functions::encodeUtf8ToFileSystem($selCity);
87 87
     
88 88
         $certdir = $this->getRealCertificatesDirectory();
89
-        $tabCertif= array();
89
+        $tabCertif = array();
90 90
     
91
-        if(is_dir($certdir.$selCity)){
92
-            $dir=opendir($certdir.$selCity);
93
-            while($entry = readdir($dir)){
94
-                if($entry!='.' && $entry!='..' && !is_dir($certdir.$entry.'/')){
91
+        if (is_dir($certdir.$selCity)) {
92
+            $dir = opendir($certdir.$selCity);
93
+            while ($entry = readdir($dir)) {
94
+                if ($entry != '.' && $entry != '..' && !is_dir($certdir.$entry.'/')) {
95 95
                     $path = Functions::encodeFileSystemToUtf8($selCity.'/'.$entry);
96 96
                     $certificate = new Certificate($path, $this->tree, $this);
97
-                    if(Functions::isImageTypeSupported($certificate->extension())){
98
-                        $tabCertif[] = 	$certificate;
97
+                    if (Functions::isImageTypeSupported($certificate->extension())) {
98
+                        $tabCertif[] = $certificate;
99 99
                     }
100 100
                 }
101 101
             }
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
      * {@inhericDoc}
108 108
      * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesListBeginWith()
109 109
      */
110
-    public function getCertificatesListBeginWith($city, $contains, $limit= 9999){
111
-        $tabFiles= array();
112
-        $dirPath= $this->getRealCertificatesDirectory() . Functions::encodeUtf8ToFileSystem($city).'/';
110
+    public function getCertificatesListBeginWith($city, $contains, $limit = 9999) {
111
+        $tabFiles = array();
112
+        $dirPath = $this->getRealCertificatesDirectory().Functions::encodeUtf8ToFileSystem($city).'/';
113 113
         $contains = utf8_decode($contains);
114 114
         $nbCert = 0;
115 115
     
116
-        if(is_dir($dirPath)){
117
-            $dir=opendir($dirPath);
118
-            while(($entry = readdir($dir)) && $nbCert < $limit){
119
-                if($entry!='.' && $entry!='..' && $entry!='Thumbs.db' &&!is_dir($dirPath.$entry.'/') && stripos($entry, $contains)!== false){
120
-                    $tabFiles[]= Functions::encodeFileSystemToUtf8($entry);
116
+        if (is_dir($dirPath)) {
117
+            $dir = opendir($dirPath);
118
+            while (($entry = readdir($dir)) && $nbCert < $limit) {
119
+                if ($entry != '.' && $entry != '..' && $entry != 'Thumbs.db' && !is_dir($dirPath.$entry.'/') && stripos($entry, $contains) !== false) {
120
+                    $tabFiles[] = Functions::encodeFileSystemToUtf8($entry);
121 121
                     $nbCert++;
122 122
                 }
123 123
             }
Please login to merge, or discard this patch.
src/Webtrees/Module/Certificates/CertificateController.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -124,7 +124,9 @@
 block discarded – undo
124 124
         
125 125
         $cid   = Filter::get('cid');
126 126
         $certificate = null;
127
-        if(!empty($cid)) $certificate =  Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
127
+        if(!empty($cid)) {
128
+        	$certificate =  Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
129
+        }
128 130
         
129 131
         $imageBuilder = new ImageBuilder($certificate);
130 132
         
Please login to merge, or discard this patch.
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -32,158 +32,158 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class CertificateController extends MvcController
34 34
 {
35
-    /**
36
-     * Certificate Provider
37
-     * @var CertificateProviderInterface $provider
38
-     */
39
-    protected $provider;
35
+	/**
36
+	 * Certificate Provider
37
+	 * @var CertificateProviderInterface $provider
38
+	 */
39
+	protected $provider;
40 40
     
41
-    /**
42
-     * Constructor for Certificate controller
43
-     * @param AbstractModule $module
44
-     */
45
-    public function __construct(AbstractModule $module) {
46
-        parent::__construct($module);
47
-        
48
-        $this->provider = $this->module->getProvider();
49
-    }
41
+	/**
42
+	 * Constructor for Certificate controller
43
+	 * @param AbstractModule $module
44
+	 */
45
+	public function __construct(AbstractModule $module) {
46
+		parent::__construct($module);
47
+        
48
+		$this->provider = $this->module->getProvider();
49
+	}
50 50
     
51 51
     
52
-    /**
53
-     * Pages
54
-     */
55
-        
56
-    /**
57
-     * Certificate@index
58
-     */
59
-    public function index() {
60
-        global $WT_TREE;
61
-        
62
-        $controller = new PageController();
63
-        $controller
64
-        ->setPageTitle(I18N::translate('Certificate'))
65
-        ->restrictAccess(
66
-            $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
67
-        );
68
-        
69
-        $cid = Filter::get('cid');
70
-        
71
-        $certificate = null;
72
-        if(!empty($cid) && strlen($cid) > 22){
73
-            $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
74
-        }
75
-        
76
-        $data = new ViewBag();
77
-        $data->set('title', $controller->getPageTitle());
78
-        
79
-        $data->set('has_certif', false);
80
-        if($certificate) {
81
-            $controller->restrictAccess($certificate->canShow());
82
-            $data->set('title', $certificate->getTitle());
83
-            $data->set('has_certif', true);
84
-            $data->set('certificate', $certificate);
52
+	/**
53
+	 * Pages
54
+	 */
55
+        
56
+	/**
57
+	 * Certificate@index
58
+	 */
59
+	public function index() {
60
+		global $WT_TREE;
61
+        
62
+		$controller = new PageController();
63
+		$controller
64
+		->setPageTitle(I18N::translate('Certificate'))
65
+		->restrictAccess(
66
+			$this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
67
+		);
68
+        
69
+		$cid = Filter::get('cid');
70
+        
71
+		$certificate = null;
72
+		if(!empty($cid) && strlen($cid) > 22){
73
+			$certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
74
+		}
75
+        
76
+		$data = new ViewBag();
77
+		$data->set('title', $controller->getPageTitle());
78
+        
79
+		$data->set('has_certif', false);
80
+		if($certificate) {
81
+			$controller->restrictAccess($certificate->canShow());
82
+			$data->set('title', $certificate->getTitle());
83
+			$data->set('has_certif', true);
84
+			$data->set('certificate', $certificate);
85 85
             
86
-            $data->set(
87
-                'url_certif_city', 
88
-                'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . 
89
-                    '&mod_action=Certificate@listAll' .
90
-                    '&ged=' . $WT_TREE->getNameUrl() .
91
-                    '&city=' . Functions::encryptToSafeBase64($certificate->getCity())
92
-            );
86
+			$data->set(
87
+				'url_certif_city', 
88
+				'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . 
89
+					'&mod_action=Certificate@listAll' .
90
+					'&ged=' . $WT_TREE->getNameUrl() .
91
+					'&city=' . Functions::encryptToSafeBase64($certificate->getCity())
92
+			);
93 93
             
94
-            $controller->addInlineJavascript('
94
+			$controller->addInlineJavascript('
95 95
                 jQuery("#certificate-tabs").tabs();
96 96
 			    jQuery("#certificate-tabs").css("visibility", "visible");    
97 97
             ');
98 98
             
99
-            $data->set('has_linked_indis', false);
100
-            $data->set('has_linked_fams', false);
99
+			$data->set('has_linked_indis', false);
100
+			$data->set('has_linked_fams', false);
101 101
             
102
-            $linked_indis = $certificate->linkedIndividuals();
103
-            $linked_fams = $certificate->linkedFamilies();
102
+			$linked_indis = $certificate->linkedIndividuals();
103
+			$linked_fams = $certificate->linkedFamilies();
104 104
                         
105
-            if($linked_indis && count($linked_indis) > 0) {
106
-                $data->set('has_linked_indis', true);
107
-                $data->set('linked_indis', $linked_indis);
108
-            }
105
+			if($linked_indis && count($linked_indis) > 0) {
106
+				$data->set('has_linked_indis', true);
107
+				$data->set('linked_indis', $linked_indis);
108
+			}
109 109
             
110
-            if(!empty($linked_fams)) {
111
-                $data->set('has_linked_fams', true);
112
-                $data->set('linked_fams', $linked_fams);
113
-            }
114
-        }
115
-        
116
-        ViewFactory::make('Certificate', $this, $controller, $data)->render();
117
-    }
110
+			if(!empty($linked_fams)) {
111
+				$data->set('has_linked_fams', true);
112
+				$data->set('linked_fams', $linked_fams);
113
+			}
114
+		}
115
+        
116
+		ViewFactory::make('Certificate', $this, $controller, $data)->render();
117
+	}
118 118
     
119
-    /**
120
-     * Certificate@image
121
-     */
122
-    public function image() {      
123
-        global $WT_TREE;
119
+	/**
120
+	 * Certificate@image
121
+	 */
122
+	public function image() {      
123
+		global $WT_TREE;
124 124
         
125
-        $cid   = Filter::get('cid');
126
-        $certificate = null;
127
-        if(!empty($cid)) $certificate =  Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
125
+		$cid   = Filter::get('cid');
126
+		$certificate = null;
127
+		if(!empty($cid)) $certificate =  Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
128 128
         
129
-        $imageBuilder = new ImageBuilder($certificate);
129
+		$imageBuilder = new ImageBuilder($certificate);
130 130
         
131
-        if (!empty(Filter::get('cb'))) {
132
-            $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7);
133
-        }
131
+		if (!empty(Filter::get('cb'))) {
132
+			$imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7);
133
+		}
134 134
         
135
-        $imageBuilder
136
-            ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE))
137
-            ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18))
138
-            ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3'))
139
-        ;
135
+		$imageBuilder
136
+			->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE))
137
+			->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18))
138
+			->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3'))
139
+		;
140 140
         
141
-        $imageBuilder->render();
141
+		$imageBuilder->render();
142 142
         
143
-    }
143
+	}
144 144
     
145
-    /**
146
-     * Certificate@listAll
147
-     */
148
-    public function listAll() {
149
-        global $WT_TREE;
150
-        
151
-        $controller = new PageController();
152
-        $controller
153
-            ->setPageTitle(I18N::translate('Certificates'))
154
-            ->restrictAccess(
155
-                $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
156
-            );
157
-        
158
-        $city = Filter::get('city');
159
-        
160
-        if(!empty($city) && strlen($city) > 22){
161
-            $city = Functions::decryptFromSafeBase64($city);
162
-            $controller->setPageTitle(I18N::translate('Certificates for %s', $city));
163
-        }
164
-        
165
-        $data = new ViewBag();
166
-        $data->set('title', $controller->getPageTitle());
167
-        $data->set('url_module', $this->module->getName());
168
-        $data->set('url_action', 'Certificate@listAll');
169
-        $data->set('url_ged', $WT_TREE->getNameUrl());
170
-        
171
-        $data->set('cities', $this->provider->getCitiesList());
172
-        $data->set('selected_city', $city);
173
-        
174
-        $data->set('has_list', false);        
175
-        if(!empty($city)) {            
176
-            $table_id = 'table-certiflist-' . Uuid::uuid4();
145
+	/**
146
+	 * Certificate@listAll
147
+	 */
148
+	public function listAll() {
149
+		global $WT_TREE;
150
+        
151
+		$controller = new PageController();
152
+		$controller
153
+			->setPageTitle(I18N::translate('Certificates'))
154
+			->restrictAccess(
155
+				$this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)
156
+			);
157
+        
158
+		$city = Filter::get('city');
159
+        
160
+		if(!empty($city) && strlen($city) > 22){
161
+			$city = Functions::decryptFromSafeBase64($city);
162
+			$controller->setPageTitle(I18N::translate('Certificates for %s', $city));
163
+		}
164
+        
165
+		$data = new ViewBag();
166
+		$data->set('title', $controller->getPageTitle());
167
+		$data->set('url_module', $this->module->getName());
168
+		$data->set('url_action', 'Certificate@listAll');
169
+		$data->set('url_ged', $WT_TREE->getNameUrl());
170
+        
171
+		$data->set('cities', $this->provider->getCitiesList());
172
+		$data->set('selected_city', $city);
173
+        
174
+		$data->set('has_list', false);        
175
+		if(!empty($city)) {            
176
+			$table_id = 'table-certiflist-' . Uuid::uuid4();
177 177
             
178
-            $certif_list = $this->provider->getCertificatesList($city);            
179
-            if(!empty($certif_list)) {                
180
-                $data->set('has_list', true);
181
-                $data->set('table_id', $table_id);
182
-                $data->set('certificate_list', $certif_list);
178
+			$certif_list = $this->provider->getCertificatesList($city);            
179
+			if(!empty($certif_list)) {                
180
+				$data->set('has_list', true);
181
+				$data->set('table_id', $table_id);
182
+				$data->set('certificate_list', $certif_list);
183 183
                 
184
-                $controller
185
-                    ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
186
-                    ->addInlineJavascript('
184
+				$controller
185
+					->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
186
+					->addInlineJavascript('
187 187
 				        jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
188 188
 				        jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
189 189
                         
@@ -205,29 +205,29 @@  discard block
 block discarded – undo
205 205
         				jQuery(".certificate-list").css("visibility", "visible");
206 206
         				jQuery(".loading-image").css("display", "none");
207 207
                     ');
208
-            }
209
-        }
208
+			}
209
+		}
210 210
         
211
-        ViewFactory::make('CertificatesList', $this, $controller, $data)->render();
211
+		ViewFactory::make('CertificatesList', $this, $controller, $data)->render();
212 212
         
213
-    }
213
+	}
214 214
     
215
-    /**
216
-     * Certificate@autocomplete
217
-     */
218
-    public function autocomplete() {
219
-        global $WT_TREE;
215
+	/**
216
+	 * Certificate@autocomplete
217
+	 */
218
+	public function autocomplete() {
219
+		global $WT_TREE;
220 220
         
221
-        $controller = new JsonController();
221
+		$controller = new JsonController();
222 222
         
223
-        $city = Filter::get('city');
224
-        $contains = Filter::get('term');        
223
+		$city = Filter::get('city');
224
+		$contains = Filter::get('term');        
225 225
 
226
-        $controller
227
-            ->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains))
228
-            ->pageHeader();
226
+		$controller
227
+			->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains))
228
+			->pageHeader();
229 229
         
230
-        $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); 
231
-        $controller->encode($listCert);
232
-    }
230
+		$listCert = $this->provider->getCertificatesListBeginWith($city, $contains); 
231
+		$controller->encode($listCert);
232
+	}
233 233
 }
234 234
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $cid = Filter::get('cid');
70 70
         
71 71
         $certificate = null;
72
-        if(!empty($cid) && strlen($cid) > 22){
72
+        if (!empty($cid) && strlen($cid) > 22) {
73 73
             $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
74 74
         }
75 75
         
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $data->set('title', $controller->getPageTitle());
78 78
         
79 79
         $data->set('has_certif', false);
80
-        if($certificate) {
80
+        if ($certificate) {
81 81
             $controller->restrictAccess($certificate->canShow());
82 82
             $data->set('title', $certificate->getTitle());
83 83
             $data->set('has_certif', true);
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
             
86 86
             $data->set(
87 87
                 'url_certif_city', 
88
-                'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . 
89
-                    '&mod_action=Certificate@listAll' .
90
-                    '&ged=' . $WT_TREE->getNameUrl() .
91
-                    '&city=' . Functions::encryptToSafeBase64($certificate->getCity())
88
+                'module.php?mod='.Constants::MODULE_MAJ_CERTIF_NAME. 
89
+                    '&mod_action=Certificate@listAll'.
90
+                    '&ged='.$WT_TREE->getNameUrl().
91
+                    '&city='.Functions::encryptToSafeBase64($certificate->getCity())
92 92
             );
93 93
             
94 94
             $controller->addInlineJavascript('
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
             $linked_indis = $certificate->linkedIndividuals();
103 103
             $linked_fams = $certificate->linkedFamilies();
104 104
                         
105
-            if($linked_indis && count($linked_indis) > 0) {
105
+            if ($linked_indis && count($linked_indis) > 0) {
106 106
                 $data->set('has_linked_indis', true);
107 107
                 $data->set('linked_indis', $linked_indis);
108 108
             }
109 109
             
110
-            if(!empty($linked_fams)) {
110
+            if (!empty($linked_fams)) {
111 111
                 $data->set('has_linked_fams', true);
112 112
                 $data->set('linked_fams', $linked_fams);
113 113
             }
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
     public function image() {      
123 123
         global $WT_TREE;
124 124
         
125
-        $cid   = Filter::get('cid');
125
+        $cid = Filter::get('cid');
126 126
         $certificate = null;
127
-        if(!empty($cid)) $certificate =  Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
127
+        if (!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider);
128 128
         
129 129
         $imageBuilder = new ImageBuilder($certificate);
130 130
         
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         
158 158
         $city = Filter::get('city');
159 159
         
160
-        if(!empty($city) && strlen($city) > 22){
160
+        if (!empty($city) && strlen($city) > 22) {
161 161
             $city = Functions::decryptFromSafeBase64($city);
162 162
             $controller->setPageTitle(I18N::translate('Certificates for %s', $city));
163 163
         }
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
         $data->set('selected_city', $city);
173 173
         
174 174
         $data->set('has_list', false);        
175
-        if(!empty($city)) {            
176
-            $table_id = 'table-certiflist-' . Uuid::uuid4();
175
+        if (!empty($city)) {            
176
+            $table_id = 'table-certiflist-'.Uuid::uuid4();
177 177
             
178 178
             $certif_list = $this->provider->getCertificatesList($city);            
179
-            if(!empty($certif_list)) {                
179
+            if (!empty($certif_list)) {                
180 180
                 $data->set('has_list', true);
181 181
                 $data->set('table_id', $table_id);
182 182
                 $data->set('certificate_list', $certif_list);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 				        jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
189 189
                         
190 190
                         jQuery("#'.$table_id.'").dataTable( {
191
-        					dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
191
+        					dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\',
192 192
     					    '.I18N::datatablesI18N().',
193 193
     					    jQueryUI: true,
194 194
         					autoWidth: false,
Please login to merge, or discard this patch.