Completed
Push — master ( 0f93c5...bdc52b )
by Jonathan
04:53
created
src/Webtrees/Family.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 	/**
53 53
 	 * Find the spouse of a person, using the Xref comparison.
54 54
 	 *
55
-	 * @param Individual $person
55
+	 * @param fw\Individual $person
56 56
 	 *
57 57
 	 * @return Individual|null
58 58
 	 */
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@
 block discarded – undo
39 39
 	}
40 40
 	
41 41
 	/**
42
-	* Check if this family's marriages are sourced
43
-	*
44
-	* @return int Level of sources
45
-	* */
42
+	 * Check if this family's marriages are sourced
43
+	 *
44
+	 * @return int Level of sources
45
+	 * */
46 46
 	function isMarriageSourced(){
47 47
 		if($this->_ismarriagesourced != null) return $this->_ismarriagesourced;
48 48
 		$this->_ismarriagesourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC');
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	 * @param string $gedcom
31 31
 	 * @return NULL|\MyArtJaub\Webtrees\Family
32 32
 	 */
33
-	public static function getIntance($xref, Tree $tree, $gedcom = null){
33
+	public static function getIntance($xref, Tree $tree, $gedcom = null) {
34 34
 		$dfam = null;
35 35
 		$fam = fw\Family::getInstance($xref, $tree, $gedcom);
36
-		if($fam){
36
+		if ($fam) {
37 37
 			$dfam = new Family($fam);
38 38
 		}
39 39
 		return $dfam;
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	*
45 45
 	* @return int Level of sources
46 46
 	* */
47
-	function isMarriageSourced(){
48
-		if($this->is_marriage_sourced !== null) return $this->is_marriage_sourced;
47
+	function isMarriageSourced() {
48
+		if ($this->is_marriage_sourced !== null) return $this->is_marriage_sourced;
49 49
 		$this->is_marriage_sourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC');
50 50
 		return $this->is_marriage_sourced;
51 51
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@
 block discarded – undo
45 45
 	* @return int Level of sources
46 46
 	* */
47 47
 	function isMarriageSourced(){
48
-		if($this->is_marriage_sourced !== null) return $this->is_marriage_sourced;
48
+		if($this->is_marriage_sourced !== null) {
49
+			return $this->is_marriage_sourced;
50
+		}
49 51
 		$this->is_marriage_sourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC');
50 52
 		return $this->is_marriage_sourced;
51 53
 	}
Please login to merge, or discard this patch.
src/Webtrees/Functions/Functions.php 4 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * 
52 52
 	 * @param integer $num Numerator
53 53
 	 * @param integer $denom Denominator
54
-	 * @param float $default Default value if denominator null or 0
55
-	 * @return float Result of the safe division
54
+	 * @param integer $default Default value if denominator null or 0
55
+	 * @return integer Result of the safe division
56 56
 	 */
57 57
 	public static function safeDivision($num, $denom, $default = 0) {
58 58
 		if($denom && $denom!=0){
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param int $num Numerator
68 68
 	 * @param int $denom Denominator
69
-	 * @param float $default Default value if denominator null or 0
70
-	 * @return float Percentage
69
+	 * @param integer $default Default value if denominator null or 0
70
+	 * @return integer Percentage
71 71
 	 */
72 72
 	public static function getPercentage($num, $denom, $default = 0){
73 73
 		return 100 * self::safeDivision($num, $denom, $default);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param string $file The image to resize
80 80
 	 * @param int $target	The final max width/height
81
-	 * @return array array of ($width, $height). One of them must be $target
81
+	 * @return integer[] array of ($width, $height). One of them must be $target
82 82
 	 */
83 83
 	static public function getResizedImageSize($file, $target=25){
84 84
 		list($width, $height, $type, $attr) = getimagesize($file);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * Returns the generation associated with a Sosa number
234 234
 	 *
235 235
 	 * @param int $sosa Sosa number
236
-	 * @return number
236
+	 * @return integer
237 237
 	 */
238 238
 	public static function getGeneration($sosa){
239 239
 		return(int)log($sosa, 2)+1;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * Returns whether the image type is supported by the system, and if so, return the standardised type
247 247
 	 *
248 248
 	 * @param string $reqtype Extension to test
249
-	 * @return boolean|string Is supported?
249
+	 * @return false|string Is supported?
250 250
 	 */
251 251
 	public static function isImageTypeSupported($reqtype) {
252 252
 	    $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return boolean
136 136
 	 */
137 137
 	public static function isEncryptionCompatible() {
138
-	    return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt');
138
+		return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt');
139 139
 	}
140 140
 	
141 141
 	/**	  
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @return string Encrypted and encoded text
147 147
 	 */
148 148
 	public static function encryptToSafeBase64($data){
149
-	    if(!self::isEncryptionCompatible())
150
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
149
+		if(!self::isEncryptionCompatible())
150
+			throw new \Exception('MCrypt PHP extension is required to use encryption.');
151 151
 	    
152 152
 		$key = 'STANDARDKEYIFNOSERVER';
153 153
 		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 * @return string Decrypted text
170 170
 	 */
171 171
 	public static function decryptFromSafeBase64($encrypted){
172
-	    if(!self::isEncryptionCompatible())
173
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
172
+		if(!self::isEncryptionCompatible())
173
+			throw new \Exception('MCrypt PHP extension is required to use encryption.');
174 174
 	    
175 175
 		$key = 'STANDARDKEYIFNOSERVER';
176 176
 		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public static function encodeFileSystemToUtf8($string){
199 199
 		if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') {
200
-		    return iconv('cp1252', 'utf-8//IGNORE',$string);
200
+			return iconv('cp1252', 'utf-8//IGNORE',$string);
201 201
 		}
202 202
 		return $string;
203 203
 	}
@@ -262,20 +262,20 @@  discard block
 block discarded – undo
262 262
 	 * @return boolean|string Is supported?
263 263
 	 */
264 264
 	public static function isImageTypeSupported($reqtype) {
265
-	    $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
266
-	    $reqtype = strtolower($reqtype);
265
+		$supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
266
+		$reqtype = strtolower($reqtype);
267 267
 	
268
-	    if (empty($supportByGD[$reqtype])) {
269
-	        return false;
270
-	    }
268
+		if (empty($supportByGD[$reqtype])) {
269
+			return false;
270
+		}
271 271
 	
272
-	    $type = $supportByGD[$reqtype];
272
+		$type = $supportByGD[$reqtype];
273 273
 	
274
-	    if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) {
275
-	        return $type;
276
-	    }
274
+		if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) {
275
+			return $type;
276
+		}
277 277
 	
278
-	    return false;
278
+		return false;
279 279
 	}
280 280
 		
281 281
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param string $text Text to display
40 40
 	 */
41
-	static public function promptAlert($text){
41
+	static public function promptAlert($text) {
42 42
 		echo '<script>';
43
-		echo 'alert("',fw\Filter::escapeHtml($text),'")';
43
+		echo 'alert("', fw\Filter::escapeHtml($text), '")';
44 44
 		echo '</script>';
45 45
 	}
46 46
 	
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return float Result of the safe division
54 54
 	 */
55 55
 	public static function safeDivision($num, $denom, $default = 0) {
56
-		if($denom && $denom!=0){
56
+		if ($denom && $denom != 0) {
57 57
 			return $num / $denom;
58 58
 		}
59 59
 		return $default;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param float $default Default value if denominator null or 0
68 68
 	 * @return float Percentage
69 69
 	 */
70
-	public static function getPercentage($num, $denom, $default = 0){
70
+	public static function getPercentage($num, $denom, $default = 0) {
71 71
 		return 100 * self::safeDivision($num, $denom, $default);
72 72
 	}
73 73
 	
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param int $target	The final max width/height
79 79
 	 * @return array array of ($width, $height). One of them must be $target
80 80
 	 */
81
-	static public function getResizedImageSize($file, $target=25){
82
-		list($width, $height, , ) = getimagesize($file);
81
+	static public function getResizedImageSize($file, $target = 25) {
82
+		list($width, $height,,) = getimagesize($file);
83 83
 		$max = max($width, $height);
84 84
 		$rapp = $target / $max;
85 85
 		$width = intval($rapp * $width);
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 	 * @param int $length Length of the token, default to 32
110 110
 	 * @return string Random token
111 111
 	 */
112
-	public static function generateRandomToken($length=32) {
112
+	public static function generateRandomToken($length = 32) {
113 113
 		$chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
114 114
 		$len_chars = count($chars);
115 115
 		$token = '';
116 116
 		
117 117
 		for ($i = 0; $i < $length; $i++)
118
-			$token .= $chars[ mt_rand(0, $len_chars - 1) ];
118
+			$token .= $chars[mt_rand(0, $len_chars - 1)];
119 119
 		
120 120
 		# Number of 32 char chunks
121
-		$chunks = ceil( strlen($token) / 32 );
121
+		$chunks = ceil(strlen($token) / 32);
122 122
 		$md5token = '';
123 123
 		
124 124
 		# Run each chunk through md5
125
-		for ( $i=1; $i<=$chunks; $i++ )
126
-			$md5token .= md5( substr($token, $i * 32 - 32, 32) );
125
+		for ($i = 1; $i <= $chunks; $i++)
126
+			$md5token .= md5(substr($token, $i * 32 - 32, 32));
127 127
 		
128 128
 			# Trim the token
129 129
 		return substr($md5token, 0, $length);		
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 	 * @param string $data Text to encrypt
146 146
 	 * @return string Encrypted and encoded text
147 147
 	 */
148
-	public static function encryptToSafeBase64($data){
149
-	    if(!self::isEncryptionCompatible())
148
+	public static function encryptToSafeBase64($data) {
149
+	    if (!self::isEncryptionCompatible())
150 150
 	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
151 151
 	    
152 152
 		$key = 'STANDARDKEYIFNOSERVER';
153
-		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
153
+		if (Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
154 154
 			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
155 155
 		$iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND);
156
-		$id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv);
156
+		$id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
157 157
 		$encrypted = base64_encode($iv.$id);
158 158
 		// +, / and = are not URL-compatible
159 159
 		$encrypted = str_replace('+', '-', $encrypted);
@@ -168,25 +168,25 @@  discard block
 block discarded – undo
168 168
 	 * @param string $encrypted Text to decrypt
169 169
 	 * @return string Decrypted text
170 170
 	 */
171
-	public static function decryptFromSafeBase64($encrypted){
172
-	    if(!self::isEncryptionCompatible())
171
+	public static function decryptFromSafeBase64($encrypted) {
172
+	    if (!self::isEncryptionCompatible())
173 173
 	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
174 174
 	    
175 175
 		$key = 'STANDARDKEYIFNOSERVER';
176
-		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
176
+		if (Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
177 177
 			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
178 178
 		$encrypted = str_replace('-', '+', $encrypted);
179 179
 		$encrypted = str_replace('_', '/', $encrypted);
180 180
 		$encrypted = str_replace('*', '=', $encrypted);
181 181
 		$encrypted = base64_decode($encrypted);
182
-		if(!$encrypted)
182
+		if (!$encrypted)
183 183
 			throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.');
184
-		if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) 
184
+		if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) 
185 185
 			throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.');
186 186
 		$iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE);
187 187
 		$encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE);
188 188
 		$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec);
189
-		return  preg_replace('~(?:\\000+)$~','',$decrypted);
189
+		return  preg_replace('~(?:\\000+)$~', '', $decrypted);
190 190
 	}
191 191
 	
192 192
 	/**
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	 * @param string $string Filesystem encoded string to encode
196 196
 	 * @return string UTF-8 encoded string
197 197
 	 */
198
-	public static function encodeFileSystemToUtf8($string){
198
+	public static function encodeFileSystemToUtf8($string) {
199 199
 		if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') {
200
-		    return iconv('cp1252', 'utf-8//IGNORE',$string);
200
+		    return iconv('cp1252', 'utf-8//IGNORE', $string);
201 201
 		}
202 202
 		return $string;
203 203
 	}
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 	 * @param string $string UTF-8 encoded string to encode
209 209
 	 * @return string Filesystem encoded string
210 210
 	 */
211
-	public static function encodeUtf8ToFileSystem($string){
211
+	public static function encodeUtf8ToFileSystem($string) {
212 212
 		if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') {
213
-			return iconv('utf-8', 'cp1252//IGNORE' ,  $string);
213
+			return iconv('utf-8', 'cp1252//IGNORE', $string);
214 214
 		}
215 215
 		return $string;
216 216
 	}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @return boolean True if path valid
224 224
 	 */
225 225
 	public static function isValidPath($filename, $acceptfolder = FALSE) {		
226
-		if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true;
226
+		if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true;
227 227
 		return false;
228 228
 	}
229 229
 	
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @return array Array of month short names
236 236
 	 */
237 237
 	public static function getCalendarShortMonths($calendarId = 0) {
238
-		if(!isset(self::$calendarShortMonths[$calendarId])) {
238
+		if (!isset(self::$calendarShortMonths[$calendarId])) {
239 239
 			$calendar_info = cal_info($calendarId);
240 240
 			self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths'];
241 241
 		}		
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param int $sosa Sosa number
249 249
 	 * @return number
250 250
 	 */
251
-	public static function getGeneration($sosa){
252
-		return(int)log($sosa, 2)+1;
251
+	public static function getGeneration($sosa) {
252
+		return(int)log($sosa, 2) + 1;
253 253
 	}
254 254
 	
255 255
 	
Please login to merge, or discard this patch.
Braces   +27 added lines, -17 removed lines patch added patch discarded remove patch
@@ -114,16 +114,18 @@  discard block
 block discarded – undo
114 114
 		$len_chars = count($chars);
115 115
 		$token = '';
116 116
 		
117
-		for ($i = 0; $i < $length; $i++)
118
-			$token .= $chars[ mt_rand(0, $len_chars - 1) ];
117
+		for ($i = 0; $i < $length; $i++) {
118
+					$token .= $chars[ mt_rand(0, $len_chars - 1) ];
119
+		}
119 120
 		
120 121
 		# Number of 32 char chunks
121 122
 		$chunks = ceil( strlen($token) / 32 );
122 123
 		$md5token = '';
123 124
 		
124 125
 		# Run each chunk through md5
125
-		for ( $i=1; $i<=$chunks; $i++ )
126
-			$md5token .= md5( substr($token, $i * 32 - 32, 32) );
126
+		for ( $i=1; $i<=$chunks; $i++ ) {
127
+					$md5token .= md5( substr($token, $i * 32 - 32, 32) );
128
+		}
127 129
 		
128 130
 			# Trim the token
129 131
 		return substr($md5token, 0, $length);		
@@ -146,12 +148,14 @@  discard block
 block discarded – undo
146 148
 	 * @return string Encrypted and encoded text
147 149
 	 */
148 150
 	public static function encryptToSafeBase64($data){
149
-	    if(!self::isEncryptionCompatible())
150
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
151
+	    if(!self::isEncryptionCompatible()) {
152
+	    	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
153
+	    }
151 154
 	    
152 155
 		$key = 'STANDARDKEYIFNOSERVER';
153
-		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
154
-			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
156
+		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) {
157
+					$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
158
+		}
155 159
 		$iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND);
156 160
 		$id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv);
157 161
 		$encrypted = base64_encode($iv.$id);
@@ -169,20 +173,24 @@  discard block
 block discarded – undo
169 173
 	 * @return string Decrypted text
170 174
 	 */
171 175
 	public static function decryptFromSafeBase64($encrypted){
172
-	    if(!self::isEncryptionCompatible())
173
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
176
+	    if(!self::isEncryptionCompatible()) {
177
+	    	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
178
+	    }
174 179
 	    
175 180
 		$key = 'STANDARDKEYIFNOSERVER';
176
-		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE'))
177
-			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
181
+		if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) {
182
+					$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
183
+		}
178 184
 		$encrypted = str_replace('-', '+', $encrypted);
179 185
 		$encrypted = str_replace('_', '/', $encrypted);
180 186
 		$encrypted = str_replace('*', '=', $encrypted);
181 187
 		$encrypted = base64_decode($encrypted);
182
-		if(!$encrypted)
183
-			throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.');
184
-		if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) 
185
-			throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.');
188
+		if(!$encrypted) {
189
+					throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.');
190
+		}
191
+		if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) {
192
+					throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.');
193
+		}
186 194
 		$iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE);
187 195
 		$encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE);
188 196
 		$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec);
@@ -223,7 +231,9 @@  discard block
 block discarded – undo
223 231
 	 * @return boolean True if path valid
224 232
 	 */
225 233
 	public static function isValidPath($filename, $acceptfolder = FALSE) {		
226
-		if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true;
234
+		if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) {
235
+			return true;
236
+		}
227 237
 		return false;
228 238
 	}
229 239
 	
Please login to merge, or discard this patch.
src/Webtrees/Functions/FunctionsPrint.php 4 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * 
75 75
 	 * @param \Fisharebest\Webtrees\Place $place
76 76
 	 * @param string $icon_path
77
-	 * @param number $size
77
+	 * @param integer $size
78 78
 	 * @return string HTML code of the inserted flag
79 79
 	 */
80 80
 	public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) {
@@ -184,7 +184,6 @@  discard block
 block discarded – undo
184 184
 	/**
185 185
 	 * Format date to display short (just years)
186 186
 	 *
187
-	 * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date
188 187
 	 * @param boolean $anchor option to print a link to calendar
189 188
 	 * @return string HTML code for short date
190 189
 	 */
@@ -212,7 +211,6 @@  discard block
 block discarded – undo
212 211
 	/**
213 212
 	 * Format fact place to display short
214 213
 	 *
215
-	 * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date
216 214
 	 * @param string $format Format of the place
217 215
 	 * @param boolean $anchor option to print a link to placelist
218 216
 	 * @return string HTML code for short place
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @return string List of elements
33 33
 	 */
34 34
 	static public function getListFromArray(array $array) {
35
-		$n=count($array);
35
+		$n = count($array);
36 36
 		switch ($n) {
37 37
 			case 0:
38 38
 				return '';
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 			default:
42 42
 				return implode(
43 43
 						/* I18N: list separator */ I18N::translate(', '), 
44
-						array_slice($array, 0, $n-1)
45
-					) .
46
-					/* I18N: last list separator, " and " in English, " et " in French  */ I18N::translate(' and ') . 
47
-					$array[$n-1];
44
+						array_slice($array, 0, $n - 1)
45
+					).
46
+					/* I18N: last list separator, " and " in English, " et " in French  */ I18N::translate(' and '). 
47
+					$array[$n - 1];
48 48
 		}
49 49
 	}
50 50
 
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 			\Fisharebest\Webtrees\Fact $fact,
60 60
 			\MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider
61 61
 	) {
62
-		$html='';
63
-		if($place = $fact->getPlace()) {
64
-			$iconPlace= $mapProvider->getPlaceIcon($place);	
65
-			if($iconPlace && strlen($iconPlace) > 0){
66
-				$html.=	'<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>';
62
+		$html = '';
63
+		if ($place = $fact->getPlace()) {
64
+			$iconPlace = $mapProvider->getPlaceIcon($place);	
65
+			if ($iconPlace && strlen($iconPlace) > 0) {
66
+				$html .= '<div class="fact_flag">'.self::htmlPlaceIcon($place, $iconPlace, 50).'</div>';
67 67
 			}
68 68
 		}
69 69
 		return $html;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 * @param number $size
78 78
 	 * @return string HTML code of the inserted flag
79 79
 	 */
80
-	public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) {
81
-	    return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />';
80
+	public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path, $size = 50) {
81
+	    return '<img class="flag_gm_h'.$size.'" src="'.$icon_path.'" title="'.$place->getGedcomName().'" alt="'.$place->getGedcomName().'" />';
82 82
 	}
83 83
 	
84 84
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		$minimum = PHP_INT_MAX;
97 97
 		$maximum = 1;
98 98
 		foreach ($list as $item => $params) {
99
-			if(array_key_exists('count', $params)) {
99
+			if (array_key_exists('count', $params)) {
100 100
 				$maximum = max($maximum, $params['count']);
101 101
 				$minimum = min($minimum, $params['count']);
102 102
 			}
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 				$size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum);
115 115
 			}
116 116
 			
117
-			$html .= '<a style="font-size:' . $size . '%" href="' . $url . '">';
117
+			$html .= '<a style="font-size:'.$size.'%" href="'.$url.'">';
118 118
 			if ($totals) {
119
-				$html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $text . '</span>', I18N::number($count));
119
+				$html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">'.$text.'</span>', I18N::number($count));
120 120
 			} else {
121 121
 				$html .= $text;
122 122
 			}
123 123
 			$html .= '</a>';
124 124
 		}
125
-		return '<div class="tag_cloud">' . $html . '</div>';
125
+		return '<div class="tag_cloud">'.$html.'</div>';
126 126
 	}
127 127
 	
128 128
 
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 * @param bool $isStrong Bolden the name ?
158 158
 	 * @return string HTML Code for individual item
159 159
 	 */
160
-	public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){
160
+	public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true) {
161 161
 		$html = '';
162 162
 		$tag = 'em';
163
-		if($isStrong) $tag = 'strong';
164
-		if($individual && $individual->canShow()){
163
+		if ($isStrong) $tag = 'strong';
164
+		if ($individual && $individual->canShow()) {
165 165
 			$dindi = new Individual($individual);
166 166
 			$html = $individual->getSexImage();
167 167
 			$html .= '<a class="list_item" href="'.
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 			$html .= '</a>';
177 177
 		}
178 178
 		else {
179
-			$html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>';
179
+			$html .= '<span class=\"list_item\"><'.$tag.'>'.I18N::translate('Private').'</'.$tag.'></span>';
180 180
 		}
181 181
 		return $html;
182 182
 	}
@@ -188,22 +188,22 @@  discard block
 block discarded – undo
188 188
 	 * @param boolean $anchor option to print a link to calendar
189 189
 	 * @return string HTML code for short date
190 190
 	 */
191
-	public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor=false) {
191
+	public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor = false) {
192 192
 		global $SEARCH_SPIDER;
193 193
 
194
-		$html='';
194
+		$html = '';
195 195
 		$date = $fact->getDate();
196
-		if($date->isOK()){
197
-			$html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y');
196
+		if ($date->isOK()) {
197
+			$html .= ' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y');
198 198
 		}
199
-		else{
199
+		else {
200 200
 			// 1 DEAT Y with no DATE => print YES
201 201
 			// 1 BIRT 2 SOUR @S1@ => print YES
202 202
 			// 1 DEAT N is not allowed
203 203
 			// It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen.
204 204
 			$factdetail = explode(' ', trim($fact->getGedcom()));
205 205
 			if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || (count($factdetail) == 4 && $factdetail[2] == 'SOUR')) {
206
-				$html.=I18N::translate('yes');
206
+				$html .= I18N::translate('yes');
207 207
 			}
208 208
 		}
209 209
 		return $html;
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
 	 * @param boolean $anchor option to print a link to placelist
218 218
 	 * @return string HTML code for short place
219 219
 	 */
220
-	public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){
221
-		$html='';
220
+	public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false) {
221
+		$html = '';
222 222
 		
223 223
 		if ($fact === null) return $html;
224 224
 		$place = $fact->getPlace();
225
-		if($place){
225
+		if ($place) {
226 226
 			$dplace = new Place($place);
227 227
 			$html .= $dplace->htmlFormattedName($format, $anchor);
228 228
 		}
@@ -240,21 +240,21 @@  discard block
 block discarded – undo
240 240
 	 * @param string $size CSS size for the icon. A CSS style css_$size is required
241 241
 	 * @return string HTML code for the formatted Sosa numbers
242 242
 	 */
243
-	public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small'){
243
+	public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small') {
244 244
 		$html = '';
245
-		switch($format){
245
+		switch ($format) {
246 246
 			case 1:
247
-				if(count($sosatab)>0){
247
+				if (count($sosatab) > 0) {
248 248
 					$html = '<i class="icon-maj-sosa_'.$size.'" title="'.I18N::translate('Sosa').'"></i>';
249 249
 				}
250 250
 				break;
251 251
 			case 2:
252
-				if(count($sosatab)>0){
252
+				if (count($sosatab) > 0) {
253 253
 					ksort($sosatab);
254 254
 					$tmp_html = array();
255 255
 					foreach ($sosatab as $sosa => $gen) {
256 256
 						$tmp_html[] = sprintf(
257
-								'<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i>&nbsp;<strong>%2$d&nbsp;'.I18N::translate('(G%s)', $gen) .'</strong>',
257
+								'<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i>&nbsp;<strong>%2$d&nbsp;'.I18N::translate('(G%s)', $gen).'</strong>',
258 258
 								$size,
259 259
 								$sosa
260 260
 							);
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
 	 * @param string $size CSS size for the icon. A CSS style css_$size is required
281 281
 	 * @return string HTML code for IsSourced icon
282 282
 	 */
283
-	public static function formatIsSourcedIcon($sourceType, $isSourced, $tag='EVEN', $format = 1, $size='normal'){
284
-		$html='';
285
-		$image=null;
286
-		$title=null;
287
-		switch($format){
283
+	public static function formatIsSourcedIcon($sourceType, $isSourced, $tag = 'EVEN', $format = 1, $size = 'normal') {
284
+		$html = '';
285
+		$image = null;
286
+		$title = null;
287
+		switch ($format) {
288 288
 			case 1:
289
-				switch($sourceType){
289
+				switch ($sourceType) {
290 290
 					case 'E':
291
-						switch($isSourced){
291
+						switch ($isSourced) {
292 292
 							case 0:
293 293
 								$image = 'event_unknown';
294 294
 								$title = I18N::translate('%s not found', GedcomTag::getLabel($tag));
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 						}
319 319
 						break;
320 320
 					case 'R':
321
-						switch($isSourced){
321
+						switch ($isSourced) {
322 322
 							case -1:
323 323
 								$image = 'record_notsourced';
324 324
 								$title = I18N::translate('%s not sourced', GedcomTag::getLabel($tag));
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 					default:
340 340
 						break;
341 341
 				}
342
-				if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>';
342
+				if ($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>';
343 343
 				break;
344 344
 			default:
345 345
 				break;
Please login to merge, or discard this patch.
Braces   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -160,7 +160,9 @@  discard block
 block discarded – undo
160 160
 	public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){
161 161
 		$html = '';
162 162
 		$tag = 'em';
163
-		if($isStrong) $tag = 'strong';
163
+		if($isStrong) {
164
+			$tag = 'strong';
165
+		}
164 166
 		if($individual && $individual->canShow()){
165 167
 			$dindi = new Individual($individual);
166 168
 			$html = $individual->getSexImage();
@@ -174,8 +176,7 @@  discard block
 block discarded – undo
174 176
 			$html .= '&nbsp;<span><small><em>'.$dindi->format_first_major_fact(WT_EVENTS_BIRT, 10).'</em></small></span>';
175 177
 			$html .= '&nbsp;<span><small><em>'.$dindi->format_first_major_fact(WT_EVENTS_DEAT, 10).'</em></small></span>';
176 178
 			$html .= '</a>';
177
-		}
178
-		else {
179
+		} else {
179 180
 			$html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>';
180 181
 		}
181 182
 		return $html;
@@ -195,8 +196,7 @@  discard block
 block discarded – undo
195 196
 		$date = $fact->getDate();
196 197
 		if($date->isOK()){
197 198
 			$html.=' '.$date->Display($anchor && !$SEARCH_SPIDER, '%Y');
198
-		}
199
-		else{
199
+		} else{
200 200
 			// 1 DEAT Y with no DATE => print YES
201 201
 			// 1 BIRT 2 SOUR @S1@ => print YES
202 202
 			// 1 DEAT N is not allowed
@@ -220,7 +220,9 @@  discard block
 block discarded – undo
220 220
 	public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){
221 221
 		$html='';
222 222
 		
223
-		if ($fact === null) return $html;
223
+		if ($fact === null) {
224
+			return $html;
225
+		}
224 226
 		$place = $fact->getPlace();
225 227
 		if($place){
226 228
 			$dplace = new Place($place);
@@ -339,7 +341,9 @@  discard block
 block discarded – undo
339 341
 					default:
340 342
 						break;
341 343
 				}
342
-				if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>';
344
+				if($image && $title) {
345
+					$html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>';
346
+				}
343 347
 				break;
344 348
 			default:
345 349
 				break;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @return string HTML code of the inserted flag
80 80
 	 */
81 81
 	public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) {
82
-	    return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />';
82
+		return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />';
83 83
 	}
84 84
 	
85 85
 	/**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return boolean
356 356
 	 */
357 357
 	public static function isDateWithinChartsRange(Date $date) {
358
-	    return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030;
358
+		return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030;
359 359
 	}
360 360
 
361 361
 }
Please login to merge, or discard this patch.
src/Webtrees/Individual.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * Returns an estimated birth place based on statistics on the base
94 94
 	 *
95 95
 	 * @param boolean $perc Should the coefficient of reliability be returned
96
-	 * @return string|array Estimated birth place if found, null otherwise
96
+	 * @return string Estimated birth place if found, null otherwise
97 97
 	 */
98 98
 	public function getEstimatedBirthPlace($perc=false){
99 99
 		if($bplace = $this->gedcomrecord->getBirthPlace()){
@@ -110,7 +110,6 @@  discard block
 block discarded – undo
110 110
 	/**
111 111
 	 * Returns a significant place for the individual
112 112
 	 *
113
-	 * @param boolean $perc Should the coefficient of reliability be returned
114 113
 	 * @return string|array Estimated birth place if found, null otherwise
115 114
 	 */
116 115
 	public function getSignificantPlace(){
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -113,29 +113,29 @@  discard block
 block discarded – undo
113 113
 	 * @return string|array Estimated birth place if found, null otherwise
114 114
 	 */
115 115
 	public function getSignificantPlace(){
116
-	    if($bplace = $this->gedcomrecord->getBirthPlace()){
117
-	        return $bplace;
118
-	    }
116
+		if($bplace = $this->gedcomrecord->getBirthPlace()){
117
+			return $bplace;
118
+		}
119 119
 	
120
-	    foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) {
121
-	        if ($rplace) {
122
-	            return $rplace;
123
-	        }
124
-	    }
120
+		foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) {
121
+			if ($rplace) {
122
+				return $rplace;
123
+			}
124
+		}
125 125
 	
126
-	    if($dplace = $this->gedcomrecord->getDeathPlace()){
127
-	        return $dplace;
128
-	    }
126
+		if($dplace = $this->gedcomrecord->getDeathPlace()){
127
+			return $dplace;
128
+		}
129 129
 	
130
-	    foreach($this->gedcomrecord->getSpouseFamilies() as $fams) {
131
-	        foreach ($fams->getAllEventPlaces('RESI') as $rplace) {
132
-	            if ($rplace) {
133
-	                return $rplace;
134
-	            }
135
-	        }
136
-	    }
130
+		foreach($this->gedcomrecord->getSpouseFamilies() as $fams) {
131
+			foreach ($fams->getAllEventPlaces('RESI') as $rplace) {
132
+				if ($rplace) {
133
+					return $rplace;
134
+				}
135
+			}
136
+		}
137 137
 	
138
-	    return null;
138
+		return null;
139 139
 	}
140 140
 	
141 141
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return boolean Is the individual a Sosa ancestor
145 145
 	 */
146 146
 	public function isSosa(){
147
-	    return count($this->getSosaNumbers()) > 0;
147
+		return count($this->getSosaNumbers()) > 0;
148 148
 	}
149 149
 	
150 150
 	/**
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	 * @return array List of Sosa numbers
156 156
 	 */
157 157
 	public function getSosaNumbers(){
158
-	    if($this->sosa === null) {
159
-	        $provider = new SosaProvider($this->gedcomrecord->getTree());
160
-	        $this->sosa = $provider->getSosaNumbers($this->gedcomrecord);	        
161
-	    }
162
-	    return $this->sosa;
158
+		if($this->sosa === null) {
159
+			$provider = new SosaProvider($this->gedcomrecord->getTree());
160
+			$this->sosa = $provider->getSosaNumbers($this->gedcomrecord);	        
161
+		}
162
+		return $this->sosa;
163 163
 	}
164 164
 		
165 165
 	/** 
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 	
176 176
 	/**
177
-	* Check if this individual's death is sourced
178
-	*
179
-	* @return int Level of sources
180
-	* */
177
+	 * Check if this individual's death is sourced
178
+	 *
179
+	 * @return int Level of sources
180
+	 * */
181 181
 	public function isDeathSourced(){
182 182
 		if($this->is_death_sourced !== null) return $this->is_death_sourced;
183 183
 		$this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT);
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 class Individual extends GedcomRecord {
22 22
 
23 23
 	/** @var array|null List of titles the individal holds */	
24
-	protected $titles=null;
24
+	protected $titles = null;
25 25
 	
26 26
 	/** @var string|null Individual's primary surname, without any privacy applied to it */
27 27
 	protected $unprotected_prim_surname = null;
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 * @param null|string $gedcom
44 44
 	 * @return null|Individual
45 45
 	 */
46
-	public static function getIntance($xref, Tree $tree, $gedcom = null){
46
+	public static function getIntance($xref, Tree $tree, $gedcom = null) {
47 47
 		$indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom);
48
-		if($indi){
48
+		if ($indi) {
49 49
 			return new Individual($indi);
50 50
 		}
51 51
 		return null;
@@ -56,18 +56,18 @@  discard block
 block discarded – undo
56 56
 	 * 
57 57
 	 * @return array Array of titles
58 58
 	 */
59
-	public function getTitles(){
60
-		if(is_null($this->titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)){
59
+	public function getTitles() {
60
+		if (is_null($this->titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)) {
61 61
 			$pattern = '/(.*) (('.$module->getSetting('MAJ_TITLE_PREFIX', '').')(.*))/';
62
-			$this->titles=array();
62
+			$this->titles = array();
63 63
 			$titlefacts = $this->gedcomrecord->getFacts('TITL');
64
-			foreach($titlefacts as $titlefact){
64
+			foreach ($titlefacts as $titlefact) {
65 65
 				$ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2);
66
-				if($ct2>0){
67
-					$this->titles[$match2[1][0]][]= trim($match2[2][0]);
66
+				if ($ct2 > 0) {
67
+					$this->titles[$match2[1][0]][] = trim($match2[2][0]);
68 68
 				}
69
-				else{
70
-					$this->titles[$titlefact->getValue()][]='';
69
+				else {
70
+					$this->titles[$titlefact->getValue()][] = '';
71 71
 				}
72 72
 			}
73 73
 		}
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 * @return string Primary surname
82 82
 	 */
83 83
 	public function getUnprotectedPrimarySurname() {
84
-		if(!$this->unprotected_prim_surname){
85
-			$tmp=$this->gedcomrecord->getAllNames();
84
+		if (!$this->unprotected_prim_surname) {
85
+			$tmp = $this->gedcomrecord->getAllNames();
86 86
 			$this->unprotected_prim_surname = $tmp[$this->gedcomrecord->getPrimaryName()]['surname'];
87 87
 		}
88 88
 		return $this->unprotected_prim_surname;
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 	 * @param boolean $perc Should the coefficient of reliability be returned
95 95
 	 * @return string|array Estimated birth place if found, null otherwise
96 96
 	 */
97
-	public function getEstimatedBirthPlace($perc=false){
98
-		if($bplace = $this->gedcomrecord->getBirthPlace()){
99
-			if($perc){
100
-				return array ($bplace, 1);
97
+	public function getEstimatedBirthPlace($perc = false) {
98
+		if ($bplace = $this->gedcomrecord->getBirthPlace()) {
99
+			if ($perc) {
100
+				return array($bplace, 1);
101 101
 			}
102
-			else{
102
+			else {
103 103
 				return $bplace;
104 104
 			}
105 105
 		}
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * @param boolean $perc Should the coefficient of reliability be returned
113 113
 	 * @return string|array Estimated birth place if found, null otherwise
114 114
 	 */
115
-	public function getSignificantPlace(){
116
-	    if($bplace = $this->gedcomrecord->getBirthPlace()){
115
+	public function getSignificantPlace() {
116
+	    if ($bplace = $this->gedcomrecord->getBirthPlace()) {
117 117
 	        return $bplace;
118 118
 	    }
119 119
 	
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 	        }
124 124
 	    }
125 125
 	
126
-	    if($dplace = $this->gedcomrecord->getDeathPlace()){
126
+	    if ($dplace = $this->gedcomrecord->getDeathPlace()) {
127 127
 	        return $dplace;
128 128
 	    }
129 129
 	
130
-	    foreach($this->gedcomrecord->getSpouseFamilies() as $fams) {
130
+	    foreach ($this->gedcomrecord->getSpouseFamilies() as $fams) {
131 131
 	        foreach ($fams->getAllEventPlaces('RESI') as $rplace) {
132 132
 	            if ($rplace) {
133 133
 	                return $rplace;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @return boolean Is the individual a Sosa ancestor
145 145
 	 */
146
-	public function isSosa(){
146
+	public function isSosa() {
147 147
 	    return count($this->getSosaNumbers()) > 0;
148 148
 	}
149 149
 	
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 	 * @uses \MyArtJaub\Webtrees\Functions\ModuleManager
155 155
 	 * @return array List of Sosa numbers
156 156
 	 */
157
-	public function getSosaNumbers(){
158
-	    if($this->sosa === null) {
157
+	public function getSosaNumbers() {
158
+	    if ($this->sosa === null) {
159 159
 	        $provider = new SosaProvider($this->gedcomrecord->getTree());
160 160
 	        $this->sosa = $provider->getSosaNumbers($this->gedcomrecord);	        
161 161
 	    }
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return int Level of sources
169 169
 	 * */
170
-	public function isBirthSourced(){
171
-		if($this->is_birth_sourced !== null) return $this->is_birth_sourced;
170
+	public function isBirthSourced() {
171
+		if ($this->is_birth_sourced !== null) return $this->is_birth_sourced;
172 172
 		$this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT);
173 173
 		return $this->is_birth_sourced;
174 174
 	}
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 	*
179 179
 	* @return int Level of sources
180 180
 	* */
181
-	public function isDeathSourced(){
182
-		if($this->is_death_sourced !== null) return $this->is_death_sourced;
181
+	public function isDeathSourced() {
182
+		if ($this->is_death_sourced !== null) return $this->is_death_sourced;
183 183
 		$this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT);
184 184
 		return $this->is_death_sourced;
185 185
 	}
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@  discard block
 block discarded – undo
65 65
 				$ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2);
66 66
 				if($ct2>0){
67 67
 					$this->titles[$match2[1][0]][]= trim($match2[2][0]);
68
-				}
69
-				else{
68
+				} else{
70 69
 					$this->titles[$titlefact->getValue()][]='';
71 70
 				}
72 71
 			}
@@ -98,8 +97,7 @@  discard block
 block discarded – undo
98 97
 		if($bplace = $this->gedcomrecord->getBirthPlace()){
99 98
 			if($perc){
100 99
 				return array ($bplace, 1);
101
-			}
102
-			else{
100
+			} else{
103 101
 				return $bplace;
104 102
 			}
105 103
 		}
@@ -168,7 +166,9 @@  discard block
 block discarded – undo
168 166
 	 * @return int Level of sources
169 167
 	 * */
170 168
 	public function isBirthSourced(){
171
-		if($this->is_birth_sourced !== null) return $this->is_birth_sourced;
169
+		if($this->is_birth_sourced !== null) {
170
+			return $this->is_birth_sourced;
171
+		}
172 172
 		$this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT);
173 173
 		return $this->is_birth_sourced;
174 174
 	}
@@ -179,7 +179,9 @@  discard block
 block discarded – undo
179 179
 	* @return int Level of sources
180 180
 	* */
181 181
 	public function isDeathSourced(){
182
-		if($this->is_death_sourced !== null) return $this->is_death_sourced;
182
+		if($this->is_death_sourced !== null) {
183
+			return $this->is_death_sourced;
184
+		}
183 185
 		$this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT);
184 186
 		return $this->is_death_sourced;
185 187
 	}
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Model/AbstractTask.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@
 block discarded – undo
110 110
      * Set parameters of the Task
111 111
      *
112 112
      * @param bool $is_enabled Status of the task
113
-     * @param \DateTime $lastupdated Time of the last task run
113
+     * @param \DateTime $last_updated Time of the last task run
114 114
      * @param bool $last_result Result of the last run, true for success, false for failure
115 115
      * @param int $frequency Frequency of execution in minutes
116 116
      * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -236,7 +236,9 @@  discard block
 block discarded – undo
236 236
 	 * @return bool
237 237
 	 */
238 238
 	public function save() {
239
-	    if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.');
239
+	    if(!$this->provider) {
240
+	    	throw new \Exception('The task has not been initialised with a provider.');
241
+	    }
240 242
 		return $this->provider->updateTask($this);
241 243
 	}
242 244
 	
@@ -246,8 +248,9 @@  discard block
 block discarded – undo
246 248
      */
247 249
     public function execute(){
248 250
     
249
-        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime())
250
-            $this->is_running = false;
251
+        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) {
252
+                    $this->is_running = false;
253
+        }
251 254
     
252 255
         if(!$this->is_running){  //TODO put in place a time_out for running...
253 256
             //TODO Log the executions in the logs
@@ -261,7 +264,9 @@  discard block
 block discarded – undo
261 264
                 $this->last_updated = new \DateTime();
262 265
                 if($this->nb_occurrences > 0){
263 266
                     $this->nb_occurrences--;
264
-                    if($this->nb_occurrences == 0) $this->is_enabled = false;
267
+                    if($this->nb_occurrences == 0) {
268
+                    	$this->is_enabled = false;
269
+                    }
265 270
                 }
266 271
             }
267 272
             $this->is_running = false;
Please login to merge, or discard this patch.
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -20,253 +20,253 @@
 block discarded – undo
20 20
  */
21 21
 abstract class AbstractTask {
22 22
     
23
-    /**
24
-     * Time out for runnign tasks, in seconds. Default 5 min
25
-     * @var int TASK_TIME_OUT
26
-     */
27
-    const TASK_TIME_OUT = 300;
23
+	/**
24
+	 * Time out for runnign tasks, in seconds. Default 5 min
25
+	 * @var int TASK_TIME_OUT
26
+	 */
27
+	const TASK_TIME_OUT = 300;
28 28
               
29
-    /**
30
-     * Task provider
31
-     * @var TaskProviderInterface $provider
32
-     */
29
+	/**
30
+	 * Task provider
31
+	 * @var TaskProviderInterface $provider
32
+	 */
33 33
 	protected $provider;
34 34
 			
35 35
 	/**
36 36
 	 * Task name
37 37
 	 * @var string $name
38 38
 	 */
39
-    protected $name;
39
+	protected $name;
40 40
     
41
-    /**
42
-     * Status of the task
43
-     * @var bool $is_enabled
44
-     */
45
-    protected $is_enabled;
41
+	/**
42
+	 * Status of the task
43
+	 * @var bool $is_enabled
44
+	 */
45
+	protected $is_enabled;
46 46
     
47
-    /**
48
-     * Last updated date
49
-     * @var \DateTime $last_updated
50
-     */
51
-    protected $last_updated;
47
+	/**
48
+	 * Last updated date
49
+	 * @var \DateTime $last_updated
50
+	 */
51
+	protected $last_updated;
52 52
     
53
-    /**
54
-     * Last run result
55
-     * @var bool $last_result
56
-     */
57
-    protected $last_result;
53
+	/**
54
+	 * Last run result
55
+	 * @var bool $last_result
56
+	 */
57
+	protected $last_result;
58 58
     
59
-    /**
60
-     * Task run frequency
61
-     * @var int $frequency
62
-     */
63
-    protected $frequency;
59
+	/**
60
+	 * Task run frequency
61
+	 * @var int $frequency
62
+	 */
63
+	protected $frequency;
64 64
     
65
-    /**
66
-     * Task remaining runs
67
-     * @var int $nb_occurrences
68
-     */
69
-    protected $nb_occurrences;
65
+	/**
66
+	 * Task remaining runs
67
+	 * @var int $nb_occurrences
68
+	 */
69
+	protected $nb_occurrences;
70 70
     
71
-    /**
72
-     * Current running status of the task
73
-     * @var bool $is_running
74
-     */
75
-    protected $is_running;
71
+	/**
72
+	 * Current running status of the task
73
+	 * @var bool $is_running
74
+	 */
75
+	protected $is_running;
76 76
     
77
-    /**
78
-     * Constructor for the Admin task class
77
+	/**
78
+	 * Constructor for the Admin task class
79 79
 	 *
80 80
 	 * @param string $file Filename containing the task object
81 81
 	 * @param TaskProviderInterface $provider Provider for tasks
82
-     */
83
-    public function __construct($file, TaskProviderInterface $provider = null){
84
-        $this->name = trim(basename($file, '.php'));
82
+	 */
83
+	public function __construct($file, TaskProviderInterface $provider = null){
84
+		$this->name = trim(basename($file, '.php'));
85 85
 		$this->provider = $provider;
86
-    }
86
+	}
87 87
     
88
-    /**
89
-     * Get the provider.
90
-     *
91
-     * @return TaskProviderInterface 
92
-     */
93
-    public function getProvider(){
94
-        return $this->provider;
95
-    }
88
+	/**
89
+	 * Get the provider.
90
+	 *
91
+	 * @return TaskProviderInterface 
92
+	 */
93
+	public function getProvider(){
94
+		return $this->provider;
95
+	}
96 96
     
97
-    /**
98
-     * Set the provider.
99
-     *
100
-     * @param TaskProviderInterface $provider
101
-     * @return self Enable method-chaining
102
-     */
103
-    public function setProvider(TaskProviderInterface $provider){
104
-        $this->provider = $provider;
105
-        return $this;
106
-    }
97
+	/**
98
+	 * Set the provider.
99
+	 *
100
+	 * @param TaskProviderInterface $provider
101
+	 * @return self Enable method-chaining
102
+	 */
103
+	public function setProvider(TaskProviderInterface $provider){
104
+		$this->provider = $provider;
105
+		return $this;
106
+	}
107 107
     
108
-    /**
109
-     * Set parameters of the Task
110
-     *
111
-     * @param bool $is_enabled Status of the task
112
-     * @param \DateTime $lastupdated Time of the last task run
113
-     * @param bool $last_result Result of the last run, true for success, false for failure
114
-     * @param int $frequency Frequency of execution in minutes
115
-     * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited
116
-     * @param bool $is_running Indicates if the task is currently running
117
-     */
118
-    public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){
119
-        $this->is_enabled = $is_enabled;
120
-        $this->last_updated = $last_updated;
121
-        $this->last_result = $last_result;
122
-        $this->frequency = $frequency;
123
-        $this->nb_occurrences = $nb_occur;
124
-        $this->is_running = $is_running;
125
-    }
108
+	/**
109
+	 * Set parameters of the Task
110
+	 *
111
+	 * @param bool $is_enabled Status of the task
112
+	 * @param \DateTime $lastupdated Time of the last task run
113
+	 * @param bool $last_result Result of the last run, true for success, false for failure
114
+	 * @param int $frequency Frequency of execution in minutes
115
+	 * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited
116
+	 * @param bool $is_running Indicates if the task is currently running
117
+	 */
118
+	public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){
119
+		$this->is_enabled = $is_enabled;
120
+		$this->last_updated = $last_updated;
121
+		$this->last_result = $last_result;
122
+		$this->frequency = $frequency;
123
+		$this->nb_occurrences = $nb_occur;
124
+		$this->is_running = $is_running;
125
+	}
126 126
     
127
-    /**
128
-     * Get the name of the task
129
-     *
130
-     * @return string
131
-     */
132
-    public function getName(){
133
-        return $this->name;
134
-    }
127
+	/**
128
+	 * Get the name of the task
129
+	 *
130
+	 * @return string
131
+	 */
132
+	public function getName(){
133
+		return $this->name;
134
+	}
135 135
     
136 136
     
137
-    /**
138
-     * Return the status of the task in a boolean way
139
-     *
140
-     * @return boolean True if enabled
141
-     */
142
-    public function isEnabled(){
143
-        return $this->is_enabled;
144
-    }
137
+	/**
138
+	 * Return the status of the task in a boolean way
139
+	 *
140
+	 * @return boolean True if enabled
141
+	 */
142
+	public function isEnabled(){
143
+		return $this->is_enabled;
144
+	}
145 145
     
146
-    /**
147
-     * Get the last updated time.
148
-     *
149
-     * @return \DateTime
150
-     */
151
-    public function getLastUpdated(){
152
-        return $this->last_updated;
153
-    }
146
+	/**
147
+	 * Get the last updated time.
148
+	 *
149
+	 * @return \DateTime
150
+	 */
151
+	public function getLastUpdated(){
152
+		return $this->last_updated;
153
+	}
154 154
     
155
-    /**
156
-     * Check if the last result has been successful.
157
-     *
158
-     * @return bool
159
-     */
160
-    public function isLastRunSuccess(){
161
-        return $this->last_result;
162
-    }
155
+	/**
156
+	 * Check if the last result has been successful.
157
+	 *
158
+	 * @return bool
159
+	 */
160
+	public function isLastRunSuccess(){
161
+		return $this->last_result;
162
+	}
163 163
     
164
-    /**
165
-     * Get the task frequency.
166
-     *
167
-     * @return int
168
-     */
169
-    public function getFrequency(){
170
-        return $this->frequency;
171
-    }
164
+	/**
165
+	 * Get the task frequency.
166
+	 *
167
+	 * @return int
168
+	 */
169
+	public function getFrequency(){
170
+		return $this->frequency;
171
+	}
172 172
 	
173 173
 	/**
174
-     * Set the task frequency.
175
-     *
174
+	 * Set the task frequency.
175
+	 *
176 176
 	 * @param int $frequency
177
-     * @return self Enable method-chaining
178
-     */
179
-    public function setFrequency($frequency){
180
-        $this->frequency = $frequency;
177
+	 * @return self Enable method-chaining
178
+	 */
179
+	public function setFrequency($frequency){
180
+		$this->frequency = $frequency;
181 181
 		return $this;
182
-    }
182
+	}
183 183
     
184
-    /**
185
-     * Get the number of remaining occurrences.
186
-     *
187
-     * @return int
188
-     */
189
-    public function getRemainingOccurrences(){
190
-        return $this->nb_occurrences;
191
-    }
184
+	/**
185
+	 * Get the number of remaining occurrences.
186
+	 *
187
+	 * @return int
188
+	 */
189
+	public function getRemainingOccurrences(){
190
+		return $this->nb_occurrences;
191
+	}
192 192
 	
193 193
 	/**
194
-     * Set the number of remaining occurrences.
195
-     *
194
+	 * Set the number of remaining occurrences.
195
+	 *
196 196
 	 * @param int $nb_occur
197
-     * @return self Enable method-chaining
198
-     */
199
-    public function setRemainingOccurrences($nb_occur){
200
-        $this->nb_occurrences = $nb_occur;
197
+	 * @return self Enable method-chaining
198
+	 */
199
+	public function setRemainingOccurrences($nb_occur){
200
+		$this->nb_occurrences = $nb_occur;
201 201
 		return $this;
202
-    }
202
+	}
203 203
     
204
-    /**
205
-     * Check if the task if running.
206
-     *
207
-     * @return bool
208
-     */
209
-    public function isRunning(){
210
-        return $this->is_running;
211
-    }
204
+	/**
205
+	 * Check if the task if running.
206
+	 *
207
+	 * @return bool
208
+	 */
209
+	public function isRunning(){
210
+		return $this->is_running;
211
+	}
212 212
     
213 213
     
214
-    /**
215
-     * Return the name to display for the task
216
-     *
217
-     * @return string Title for the task
218
-     */
219
-    abstract public function getTitle();
214
+	/**
215
+	 * Return the name to display for the task
216
+	 *
217
+	 * @return string Title for the task
218
+	 */
219
+	abstract public function getTitle();
220 220
     
221
-    /**
222
-     * Return the default frequency for the execution of the task
223
-     *
224
-     * @return int Frequency for the execution of the task
225
-     */
226
-    abstract public function getDefaultFrequency();
221
+	/**
222
+	 * Return the default frequency for the execution of the task
223
+	 *
224
+	 * @return int Frequency for the execution of the task
225
+	 */
226
+	abstract public function getDefaultFrequency();
227 227
     
228
-    /**
229
-     * Execute the task's actions
230
-     */
231
-    abstract protected function executeSteps();
228
+	/**
229
+	 * Execute the task's actions
230
+	 */
231
+	abstract protected function executeSteps();
232 232
     
233 233
 	/**
234 234
 	 * Persist task state into database.
235 235
 	 * @return bool
236 236
 	 */
237 237
 	public function save() {
238
-	    if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.');
238
+		if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.');
239 239
 		return $this->provider->updateTask($this);
240 240
 	}
241 241
 	
242
-    /**
243
-     * Execute the task, default skeleton
244
-     *
245
-     */
246
-    public function execute(){
242
+	/**
243
+	 * Execute the task, default skeleton
244
+	 *
245
+	 */
246
+	public function execute(){
247 247
     
248
-        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime())
249
-            $this->is_running = false;
248
+		if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime())
249
+			$this->is_running = false;
250 250
     
251
-        if(!$this->is_running){
252
-            $this->last_result = false;
253
-            $this->is_running = true;
254
-            $this->save();
251
+		if(!$this->is_running){
252
+			$this->last_result = false;
253
+			$this->is_running = true;
254
+			$this->save();
255 255
     
256
-            Log::addDebugLog('Start execution of Admin task: '.$this->getTitle());
257
-            $this->last_result = $this->executeSteps();
258
-            if($this->last_result){
259
-                $this->last_updated = new \DateTime();
260
-                if($this->nb_occurrences > 0){
261
-                    $this->nb_occurrences--;
262
-                    if($this->nb_occurrences == 0) $this->is_enabled = false;
263
-                }
264
-            }
265
-            $this->is_running = false;
266
-            $this->save();
267
-            Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure'));
268
-        }
269
-    }
256
+			Log::addDebugLog('Start execution of Admin task: '.$this->getTitle());
257
+			$this->last_result = $this->executeSteps();
258
+			if($this->last_result){
259
+				$this->last_updated = new \DateTime();
260
+				if($this->nb_occurrences > 0){
261
+					$this->nb_occurrences--;
262
+					if($this->nb_occurrences == 0) $this->is_enabled = false;
263
+				}
264
+			}
265
+			$this->is_running = false;
266
+			$this->save();
267
+			Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure'));
268
+		}
269
+	}
270 270
     
271 271
     
272 272
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param string $file Filename containing the task object
81 81
 	 * @param TaskProviderInterface $provider Provider for tasks
82 82
      */
83
-    public function __construct($file, TaskProviderInterface $provider = null){
83
+    public function __construct($file, TaskProviderInterface $provider = null) {
84 84
         $this->name = trim(basename($file, '.php'));
85 85
 		$this->provider = $provider;
86 86
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return TaskProviderInterface 
92 92
      */
93
-    public function getProvider(){
93
+    public function getProvider() {
94 94
         return $this->provider;
95 95
     }
96 96
     
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * @param TaskProviderInterface $provider
101 101
      * @return self Enable method-chaining
102 102
      */
103
-    public function setProvider(TaskProviderInterface $provider){
103
+    public function setProvider(TaskProviderInterface $provider) {
104 104
         $this->provider = $provider;
105 105
         return $this;
106 106
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited
116 116
      * @param bool $is_running Indicates if the task is currently running
117 117
      */
118
-    public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){
118
+    public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running) {
119 119
         $this->is_enabled = $is_enabled;
120 120
         $this->last_updated = $last_updated;
121 121
         $this->last_result = $last_result;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @return string
131 131
      */
132
-    public function getName(){
132
+    public function getName() {
133 133
         return $this->name;
134 134
     }
135 135
     
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      *
140 140
      * @return boolean True if enabled
141 141
      */
142
-    public function isEnabled(){
142
+    public function isEnabled() {
143 143
         return $this->is_enabled;
144 144
     }
145 145
     
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @return \DateTime
150 150
      */
151
-    public function getLastUpdated(){
151
+    public function getLastUpdated() {
152 152
         return $this->last_updated;
153 153
     }
154 154
     
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      *
158 158
      * @return bool
159 159
      */
160
-    public function isLastRunSuccess(){
160
+    public function isLastRunSuccess() {
161 161
         return $this->last_result;
162 162
     }
163 163
     
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      *
167 167
      * @return int
168 168
      */
169
-    public function getFrequency(){
169
+    public function getFrequency() {
170 170
         return $this->frequency;
171 171
     }
172 172
 	
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @param int $frequency
177 177
      * @return self Enable method-chaining
178 178
      */
179
-    public function setFrequency($frequency){
179
+    public function setFrequency($frequency) {
180 180
         $this->frequency = $frequency;
181 181
 		return $this;
182 182
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      *
187 187
      * @return int
188 188
      */
189
-    public function getRemainingOccurrences(){
189
+    public function getRemainingOccurrences() {
190 190
         return $this->nb_occurrences;
191 191
     }
192 192
 	
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @param int $nb_occur
197 197
      * @return self Enable method-chaining
198 198
      */
199
-    public function setRemainingOccurrences($nb_occur){
199
+    public function setRemainingOccurrences($nb_occur) {
200 200
         $this->nb_occurrences = $nb_occur;
201 201
 		return $this;
202 202
     }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      *
207 207
      * @return bool
208 208
      */
209
-    public function isRunning(){
209
+    public function isRunning() {
210 210
         return $this->is_running;
211 211
     }
212 212
     
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @return bool
236 236
 	 */
237 237
 	public function save() {
238
-	    if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.');
238
+	    if (!$this->provider) throw new \Exception('The task has not been initialised with a provider.');
239 239
 		return $this->provider->updateTask($this);
240 240
 	}
241 241
 	
@@ -243,23 +243,23 @@  discard block
 block discarded – undo
243 243
      * Execute the task, default skeleton
244 244
      *
245 245
      */
246
-    public function execute(){
246
+    public function execute() {
247 247
     
248
-        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime())
248
+        if ($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime())
249 249
             $this->is_running = false;
250 250
     
251
-        if(!$this->is_running){
251
+        if (!$this->is_running) {
252 252
             $this->last_result = false;
253 253
             $this->is_running = true;
254 254
             $this->save();
255 255
     
256 256
             Log::addDebugLog('Start execution of Admin task: '.$this->getTitle());
257 257
             $this->last_result = $this->executeSteps();
258
-            if($this->last_result){
258
+            if ($this->last_result) {
259 259
                 $this->last_updated = new \DateTime();
260
-                if($this->nb_occurrences > 0){
260
+                if ($this->nb_occurrences > 0) {
261 261
                     $this->nb_occurrences--;
262
-                    if($this->nb_occurrences == 0) $this->is_enabled = false;
262
+                    if ($this->nb_occurrences == 0) $this->is_enabled = false;
263 263
                 }
264 264
             }
265 265
             $this->is_running = false;
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Model/TaskProviderInterface.php 2 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 * Set the status of a specific admin task.
33 33
 	 * The status can be enabled (true), or disabled (false).
34 34
 	 *
35
-	 * @param AbstractTask $ga
36 35
 	 * @param bool $status
36
+	 * @return void
37 37
 	 */
38 38
 	public function setTaskStatus(AbstractTask $task, $status);
39 39
 		
@@ -49,6 +49,7 @@  discard block
 block discarded – undo
49 49
      * Delete the task from the database, in a transactional manner.
50 50
      *
51 51
      * @param string $task_name Task to delete
52
+     * @return boolean
52 53
      */
53 54
     public function deleteTask($task_name);
54 55
     
@@ -75,7 +76,7 @@  discard block
 block discarded – undo
75 76
      * Returns the list of tasks that are currently meant to run.
76 77
      * Tasks to run can be forced, or can be limited to only one.
77 78
      * 
78
-     * @param string|null $force Force the enabled tasks to run.
79
+     * @param boolean $force Force the enabled tasks to run.
79 80
      * @param string|null $task_name Name of the specific task to run
80 81
      */
81 82
 	function getTasksToRun($force = false, $task_name = null);
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -37,47 +37,47 @@
 block discarded – undo
37 37
 	 */
38 38
 	public function setTaskStatus(AbstractTask $task, $status);
39 39
 		
40
-    /**
41
-     * Update an Admin Task in the database.
42
-     * 
43
-     * @param AbstractTask $task Task to update
44
-     * @return bool
45
-     */
46
-    function updateTask(AbstractTask $task);    
40
+	/**
41
+	 * Update an Admin Task in the database.
42
+	 * 
43
+	 * @param AbstractTask $task Task to update
44
+	 * @return bool
45
+	 */
46
+	function updateTask(AbstractTask $task);    
47 47
     
48
-    /**
49
-     * Delete the task from the database, in a transactional manner.
50
-     *
51
-     * @param string $task_name Task to delete
52
-     */
53
-    public function deleteTask($task_name);
48
+	/**
49
+	 * Delete the task from the database, in a transactional manner.
50
+	 *
51
+	 * @param string $task_name Task to delete
52
+	 */
53
+	public function deleteTask($task_name);
54 54
     
55 55
 
56
-    /**
57
-     * Returns the number of Admin Tasks (active and inactive).
58
-     *
59
-     * @return int
60
-     */
61
-    public function getTasksCount();
56
+	/**
57
+	 * Returns the number of Admin Tasks (active and inactive).
58
+	 *
59
+	 * @return int
60
+	 */
61
+	public function getTasksCount();
62 62
     
63
-    /**
64
-     * Return the list of Admin Tasks matching specified criterias.
65
-     *
66
-     * @param string $search Search criteria in analysis description
67
-     * @param array $order_by Columns to order by
68
-     * @param int $start Offset to start with (for pagination)
69
-     * @param int|null $limit Max number of items to return (for pagination)
70
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
71
-     */
72
-    function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null);
63
+	/**
64
+	 * Return the list of Admin Tasks matching specified criterias.
65
+	 *
66
+	 * @param string $search Search criteria in analysis description
67
+	 * @param array $order_by Columns to order by
68
+	 * @param int $start Offset to start with (for pagination)
69
+	 * @param int|null $limit Max number of items to return (for pagination)
70
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
71
+	 */
72
+	function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null);
73 73
     
74
-    /**
75
-     * Returns the list of tasks that are currently meant to run.
76
-     * Tasks to run can be forced, or can be limited to only one.
77
-     * 
78
-     * @param string|null $force Force the enabled tasks to run.
79
-     * @param string|null $task_name Name of the specific task to run
80
-     */
74
+	/**
75
+	 * Returns the list of tasks that are currently meant to run.
76
+	 * Tasks to run can be forced, or can be limited to only one.
77
+	 * 
78
+	 * @param string|null $force Force the enabled tasks to run.
79
+	 * @param string|null $task_name Name of the specific task to run
80
+	 */
81 81
 	function getTasksToRun($force = false, $task_name = null);
82 82
 		
83 83
 	/**
Please login to merge, or discard this patch.
src/Webtrees/Module/Certificates/Model/Certificate.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -109,6 +109,7 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * {@inhericDoc}
111 111
 	 * @see \Fisharebest\Webtrees\GedcomRecord::getInstance()
112
+	 * @param string $xref
112 113
 	 */	
113 114
 	static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) {
114 115
 		try{
@@ -150,7 +151,7 @@  discard block
 block discarded – undo
150 151
 	/**
151 152
 	 * Define a source associated with the certificate
152 153
 	 *
153
-	 * @param string|Source $xref
154
+	 * @param string|null $xref
154 155
 	 */
155 156
 	public function setSource($xref){
156 157
 		if($xref instanceof Source){
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class Certificate extends Media {
37 37
     
38
-    const URL_PREFIX  = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid=';
38
+	const URL_PREFIX  = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid=';
39 39
 		
40
-    /** @var string The "TITL" value from the GEDCOM 
41
-     * This is a tweak to overcome the private level from the parent object...
42
-     */
43
-    protected $title = '';
40
+	/** @var string The "TITL" value from the GEDCOM 
41
+	 * This is a tweak to overcome the private level from the parent object...
42
+	 */
43
+	protected $title = '';
44 44
     
45 45
 	/**
46 46
 	 * Certificate provider
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param CertificateProviderInterface $provider
81 81
 	 */
82 82
 	public function __construct($data, Tree $tree, CertificateProviderInterface $provider) {
83
-	    $this->provider = $provider;
83
+		$this->provider = $provider;
84 84
 		// Data is only the file name
85 85
 		$data = str_replace("\\", '/', $data);
86 86
 		$xref = Functions::encryptToSafeBase64($data);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @see \Fisharebest\Webtrees\Media::getTitle()
166 166
 	 */
167 167
 	public function getTitle() {
168
-	    return $this->title;
168
+		return $this->title;
169 169
 	}
170 170
 	
171 171
 	/**
@@ -241,26 +241,26 @@  discard block
 block discarded – undo
241 241
 	 	$module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME);
242 242
 	 	
243 243
 	 	if($module) {
244
-    		$wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.'));
245
-    		$sid= Filter::get('sid', WT_REGEX_XREF);	
244
+			$wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.'));
245
+			$sid= Filter::get('sid', WT_REGEX_XREF);	
246 246
     	
247
-    		if($sid){
248
-    			$this->source = Source::getInstance($sid, $this->tree);
249
-    		}
250
-    		else{
251
-    			$this->fetchALinkedSource();  // the method already attach the source to the Certificate object;
252
-    		}
247
+			if($sid){
248
+				$this->source = Source::getInstance($sid, $this->tree);
249
+			}
250
+			else{
251
+				$this->fetchALinkedSource();  // the method already attach the source to the Certificate object;
252
+			}
253 253
     		
254
-    		if($this->source) {
255
-    			$wmtext = '&copy;';
256
-    			$repofact = $this->source->getFirstFact('REPO');
257
-    			if($repofact) {
258
-    				$repo = $repofact->getTarget();
259
-    				if($repo && $repo instanceof Repository)  $wmtext .= ' '.$repo->getFullName().' - ';
260
-    			}
261
-    			$wmtext .= $this->source->getFullName();			
262
-    		}	
263
-    		return $wmtext;
254
+			if($this->source) {
255
+				$wmtext = '&copy;';
256
+				$repofact = $this->source->getFirstFact('REPO');
257
+				if($repofact) {
258
+					$repo = $repofact->getTarget();
259
+					if($repo && $repo instanceof Repository)  $wmtext .= ' '.$repo->getFullName().' - ';
260
+				}
261
+				$wmtext .= $this->source->getFullName();			
262
+			}	
263
+			return $wmtext;
264 264
 	 	}
265 265
 	 	return '';
266 266
 	}
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 				' FROM `##individuals`'.
324 324
 				' WHERE i_file= :gedcom_id AND i_gedcom LIKE :gedcom')
325 325
 		->execute(array(
326
-		    'gedcom_id' => $this->tree->getTreeId(),
327
-		    'gedcom' => '%_ACT '.$this->getFilename().'%'		    
326
+			'gedcom_id' => $this->tree->getTreeId(),
327
+			'gedcom' => '%_ACT '.$this->getFilename().'%'		    
328 328
 		))->fetchAll();
329 329
 		
330 330
 		$list = array();
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 				' FROM `##families`'.
348 348
 				' WHERE f_file= :gedcom_id AND f_gedcom LIKE :gedcom')
349 349
 		->execute(array(
350
-		    'gedcom_id' => $this->tree->getTreeId(),
351
-		    'gedcom' => '%_ACT '.$this->getFilename().'%'		    
350
+			'gedcom_id' => $this->tree->getTreeId(),
351
+			'gedcom' => '%_ACT '.$this->getFilename().'%'		    
352 352
 		))->fetchAll();
353 353
 		
354 354
 		$list = array();
@@ -375,25 +375,25 @@  discard block
 block discarded – undo
375 375
 				'SELECT i_gedcom AS gedrec FROM `##individuals`'.
376 376
 				' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom')
377 377
 		  ->execute(array(
378
-		      'gedcom_id' => $this->tree->getTreeId(), 
379
-		      'gedcom' => '%_ACT '.$this->getFilename().'%'		      
378
+			  'gedcom_id' => $this->tree->getTreeId(), 
379
+			  'gedcom' => '%_ACT '.$this->getFilename().'%'		      
380 380
 		  ))->fetchOne();
381 381
 		if(!$ged){
382 382
 			$ged = Database::prepare(
383 383
 					'SELECT f_gedcom AS gedrec FROM `##families`'.
384 384
 					' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom')
385
-			     ->execute(array(
386
-			         'gedcom_id' => $this->tree->getTreeId(), 
387
-			         'gedcom' => '%_ACT '.$this->getFilename().'%'			         
388
-			     ))->fetchOne();
385
+				 ->execute(array(
386
+					 'gedcom_id' => $this->tree->getTreeId(), 
387
+					 'gedcom' => '%_ACT '.$this->getFilename().'%'			         
388
+				 ))->fetchOne();
389 389
 			if(!$ged){
390 390
 				$ged = Database::prepare(
391
-				    'SELECT o_gedcom AS gedrec FROM `##other`'.
392
-				    ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom')
393
-				    ->execute(array(
394
-				        'gedcom_id' => $this->tree->getTreeId(),
395
-				        'gedcom' => '%_ACT '.$this->getFilename().'%'				        
396
-				    ))->fetchOne();
391
+					'SELECT o_gedcom AS gedrec FROM `##other`'.
392
+					' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom')
393
+					->execute(array(
394
+						'gedcom_id' => $this->tree->getTreeId(),
395
+						'gedcom' => '%_ACT '.$this->getFilename().'%'				        
396
+					))->fetchOne();
397 397
 			}
398 398
 		}
399 399
 		//If a record has been found, parse it to find the source reference.
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class Certificate extends Media {
37 37
     
38
-    const URL_PREFIX  = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid=';
38
+    const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid=';
39 39
 		
40 40
     /** @var string The "TITL" value from the GEDCOM 
41 41
      * This is a tweak to overcome the private level from the parent object...
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 		$this->title = basename($this->getFilename(), '.'.$this->extension());
95 95
 		
96 96
 		$ct = preg_match("/(?<year>\d{1,4})(\.(?<month>\d{1,2}))?(\.(?<day>\d{1,2}))?( (?<type>[A-Z]{1,2}) )?(?<details>.*)/", $this->title, $match);
97
-		if($ct > 0){
98
-			$monthId = (int) $match['month'];
97
+		if ($ct > 0) {
98
+			$monthId = (int)$match['month'];
99 99
 			$calendarShortMonths = Functions::getCalendarShortMonths();
100 100
 			$monthShortName = array_key_exists($monthId, $calendarShortMonths) ? $calendarShortMonths[$monthId] : $monthId;
101 101
 			$this->certDate = new Date($match['day'].' '.strtoupper($monthShortName).' '.$match['year']);
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @see \Fisharebest\Webtrees\GedcomRecord::getInstance()
112 112
 	 */	
113 113
 	static public function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) {
114
-		try{
114
+		try {
115 115
 			$certfile = Functions::decryptFromSafeBase64($xref);
116 116
 			
117 117
 			//NEED TO CHECK THAT !!!
118
-			if(Functions::isValidPath($certfile, true)) {
118
+			if (Functions::isValidPath($certfile, true)) {
119 119
 				return new Certificate($certfile, $tree, $provider);
120 120
 			}
121 121
 		}
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @param string|Source $xref
154 154
 	 */
155
-	public function setSource($xref){
156
-		if($xref instanceof Source){
155
+	public function setSource($xref) {
156
+		if ($xref instanceof Source) {
157 157
 			$this->source = $data;
158 158
 		} else {
159 159
 			$this->source = Source::getInstance($xref, $this->tree);
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return Date Certificate date
175 175
 	 */
176
-	public function getCertificateDate(){
176
+	public function getCertificateDate() {
177 177
 		return $this->certDate;
178 178
 	}
179 179
 	
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return string Certificate date
184 184
 	 */
185
-	public function getCertificateType(){
185
+	public function getCertificateType() {
186 186
 		return $this->certType;
187 187
 	}
188 188
 	
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return string Certificate details
193 193
 	 */
194
-	public function getCertificateDetails(){
194
+	public function getCertificateDetails() {
195 195
 		return $this->certDetails;
196 196
 	}
197 197
 	
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return string|NULL Certificate city
202 202
 	 */
203
-	public function getCity(){
203
+	public function getCity() {
204 204
 		$chunks = explode('/', $this->getFilename(), 2);
205
-		if(count($chunks) > 1) return $chunks[0];
205
+		if (count($chunks) > 1) return $chunks[0];
206 206
 		return null;
207 207
 	}
208 208
 	
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	 * {@inhericDoc}
211 211
 	 * @see \Fisharebest\Webtrees\Media::getServerFilename()
212 212
 	 */
213
-	public function getServerFilename($which='main') {
214
-		$filename =  $this->provider->getRealCertificatesDirectory() . $this->getFilename();
213
+	public function getServerFilename($which = 'main') {
214
+		$filename = $this->provider->getRealCertificatesDirectory().$this->getFilename();
215 215
 		return Functions::encodeUtf8ToFileSystem($filename);
216 216
 	}
217 217
 	
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	public function getHtmlUrlDirect($which = 'main', $download = false) {
223 223
 		$sidstr = ($this->source) ? '&sid='.$this->source->getXref() : '';
224 224
 		return
225
-			'module.php?mod='. \MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME . 
226
-			'&mod_action=Certificate@image' . 
227
-			'&ged='. $this->tree->getNameUrl() .
228
-			'&cid=' . $this->getXref() . $sidstr .
229
-			'&cb=' . $this->getEtag($which);
225
+			'module.php?mod='.\MyArtJaub\Webtrees\Constants::MODULE_MAJ_CERTIF_NAME. 
226
+			'&mod_action=Certificate@image'. 
227
+			'&ged='.$this->tree->getNameUrl().
228
+			'&cid='.$this->getXref().$sidstr.
229
+			'&cb='.$this->getEtag($which);
230 230
 	}
231 231
 	
232 232
 	/**
@@ -237,26 +237,26 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return string Watermark text
239 239
 	 */
240
-	 public function getWatermarkText(){	
240
+	 public function getWatermarkText() {	
241 241
 	 	$module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME);
242 242
 	 	
243
-	 	if($module) {
243
+	 	if ($module) {
244 244
     		$wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.'));
245
-    		$sid= Filter::get('sid', WT_REGEX_XREF);	
245
+    		$sid = Filter::get('sid', WT_REGEX_XREF);	
246 246
     	
247
-    		if($sid){
247
+    		if ($sid) {
248 248
     			$this->source = Source::getInstance($sid, $this->tree);
249 249
     		}
250
-    		else{
251
-    			$this->fetchALinkedSource();  // the method already attach the source to the Certificate object;
250
+    		else {
251
+    			$this->fetchALinkedSource(); // the method already attach the source to the Certificate object;
252 252
     		}
253 253
     		
254
-    		if($this->source) {
254
+    		if ($this->source) {
255 255
     			$wmtext = '&copy;';
256 256
     			$repofact = $this->source->getFirstFact('REPO');
257
-    			if($repofact) {
257
+    			if ($repofact) {
258 258
     				$repo = $repofact->getTarget();
259
-    				if($repo && $repo instanceof Repository)  $wmtext .= ' '.$repo->getFullName().' - ';
259
+    				if ($repo && $repo instanceof Repository)  $wmtext .= ' '.$repo->getFullName().' - ';
260 260
     			}
261 261
     			$wmtext .= $this->source->getFullName();			
262 262
     		}	
@@ -279,45 +279,45 @@  discard block
 block discarded – undo
279 279
 		';
280 280
 		
281 281
 		$script = '';
282
-		if($controller && !($controller instanceof IndividualController)){
282
+		if ($controller && !($controller instanceof IndividualController)) {
283 283
 			$controller->addInlineJavascript('$(document).ready(function() { '.$js.' });');
284 284
 		} else {
285
-			$script = '<script>' . $js . '</script>';
285
+			$script = '<script>'.$js.'</script>';
286 286
 		}
287 287
 		
288 288
 		if ($which == 'icon' || !file_exists($this->getServerFilename())) {
289 289
 			// Use an icon
290 290
 			$image =
291
-			'<i dir="auto" class="icon-maj-certificate margin-h-2"' .
292
-			' title="' . strip_tags($this->getFullName()) . '"' .
291
+			'<i dir="auto" class="icon-maj-certificate margin-h-2"'.
292
+			' title="'.strip_tags($this->getFullName()).'"'.
293 293
 			'></i>';
294 294
 		} else {
295 295
 			$imgsize = getimagesize($this->getServerFilename());
296 296
 			$image =
297
-			'<img' .
298
-			' class ="'. 'certif_image'					 	. '"' .
299
-			' dir="'   . 'auto'                           	. '"' . // For the tool-tip
300
-			' src="'   . $this->getHtmlUrlDirect() 			. '"' .
301
-			' alt="'   . strip_tags($this->getFullName()) 	. '"' .
302
-			' title="' . strip_tags($this->getFullName()) 	. '"' .
303
-			$imgsize[3] . // height="yyy" width="xxx"
297
+			'<img'.
298
+			' class ="'.'certif_image'.'"'.
299
+			' dir="'.'auto'.'"'.// For the tool-tip
300
+			' src="'.$this->getHtmlUrlDirect().'"'.
301
+			' alt="'.strip_tags($this->getFullName()).'"'.
302
+			' title="'.strip_tags($this->getFullName()).'"'.
303
+			$imgsize[3].// height="yyy" width="xxx"
304 304
 			'>';
305 305
 		}	
306 306
 		return
307
-		'<a' .
308
-		' class="'          . 'certgallery'                          . '"' .
309
-		' href="'           . $this->getHtmlUrlDirect()    		 . '"' .
310
-		' type="'           . $this->mimeType()                  . '"' .
311
-		' data-obje-url="'  . $this->getHtmlUrl()                . '"' .
312
-		' data-title="'     . strip_tags($this->getFullName())   . '"' .
313
-		'>' . $image . '</a>'.$script;
307
+		'<a'.
308
+		' class="'.'certgallery'.'"'.
309
+		' href="'.$this->getHtmlUrlDirect().'"'.
310
+		' type="'.$this->mimeType().'"'.
311
+		' data-obje-url="'.$this->getHtmlUrl().'"'.
312
+		' data-title="'.strip_tags($this->getFullName()).'"'.
313
+		'>'.$image.'</a>'.$script;
314 314
 	}
315 315
 	
316 316
 	/**
317 317
 	 * {@inhericDoc}
318 318
 	 * @see \Fisharebest\Webtrees\GedcomRecord::linkedIndividuals()
319 319
 	 */
320
-	public function linkedIndividuals($link = '_ACT'){
320
+	public function linkedIndividuals($link = '_ACT') {
321 321
 		$rows = Database::prepare(
322 322
 				'SELECT i_id AS xref, i_gedcom AS gedcom'.
323 323
 				' FROM `##individuals`'.
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	 * {@inhericDoc}
342 342
 	 * @see \Fisharebest\Webtrees\GedcomRecord::linkedFamilies()
343 343
 	 */
344
-	public function linkedFamilies($link = '_ACT'){
344
+	public function linkedFamilies($link = '_ACT') {
345 345
 		$rows = Database::prepare(
346 346
 				'SELECT f_id AS xref, f_gedcom AS gedcom'.
347 347
 				' FROM `##families`'.
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @return Source|NULL Linked source
368 368
 	 */
369
-	public function fetchALinkedSource(){		
369
+	public function fetchALinkedSource() {		
370 370
 		$sid = null;
371 371
 		
372 372
 		// Try to find in individual, then families, then other types of records. We are interested in the first available value.
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 		      'gedcom_id' => $this->tree->getTreeId(), 
379 379
 		      'gedcom' => '%_ACT '.$this->getFilename().'%'		      
380 380
 		  ))->fetchOne();
381
-		if(!$ged){
381
+		if (!$ged) {
382 382
 			$ged = Database::prepare(
383 383
 					'SELECT f_gedcom AS gedrec FROM `##families`'.
384 384
 					' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom')
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			         'gedcom_id' => $this->tree->getTreeId(), 
387 387
 			         'gedcom' => '%_ACT '.$this->getFilename().'%'			         
388 388
 			     ))->fetchOne();
389
-			if(!$ged){
389
+			if (!$ged) {
390 390
 				$ged = Database::prepare(
391 391
 				    'SELECT o_gedcom AS gedrec FROM `##other`'.
392 392
 				    ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom')
@@ -397,28 +397,28 @@  discard block
 block discarded – undo
397 397
 			}
398 398
 		}
399 399
 		//If a record has been found, parse it to find the source reference.
400
-		if($ged){
400
+		if ($ged) {
401 401
 			$gedlines = explode("\n", $ged);
402 402
 			$level = 0;
403 403
 			$levelsource = -1;
404
-			$sid_tmp=null;
404
+			$sid_tmp = null;
405 405
 			$sourcefound = false;
406
-			foreach($gedlines as $gedline){
406
+			foreach ($gedlines as $gedline) {
407 407
 				// Get the level
408 408
 				if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) {
409 409
 					$level = $match[1];
410 410
 					//If we are not any more within the context of a source, reset
411
-					if($level <= $levelsource){
411
+					if ($level <= $levelsource) {
412 412
 						$levelsource = -1;
413 413
 						$sid_tmp = null;
414 414
 					}
415 415
 					// If a source, get the level and the reference
416 416
 					if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) {
417 417
 						$levelsource = $level;
418
-						$sid_tmp=$match2[1];
418
+						$sid_tmp = $match2[1];
419 419
 					}
420 420
 					// If the image has be found, get the source reference and exit.
421
-					if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){
421
+					if ($levelsource >= 0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)) {
422 422
 						$sid = $sid_tmp;
423 423
 						$sourcefound = true;
424 424
 					}
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 			}
427 427
 		}
428 428
 		
429
-		if($sid) $this->source = Source::getInstance($sid, $this->tree);
429
+		if ($sid) $this->source = Source::getInstance($sid, $this->tree);
430 430
 		
431 431
 		return $this->source;	
432 432
 	}
Please login to merge, or discard this patch.
Braces   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -118,8 +118,7 @@  discard block
 block discarded – undo
118 118
 			if(Functions::isValidPath($certfile, true)) {
119 119
 				return new Certificate($certfile, $tree, $provider);
120 120
 			}
121
-		}
122
-		catch (\Exception $ex) { 
121
+		} catch (\Exception $ex) { 
123 122
 			Log::addErrorLog('Certificate module error : > '.$ex->getMessage().' < with data > '.$xref.' <');
124 123
 		}	
125 124
 
@@ -202,7 +201,9 @@  discard block
 block discarded – undo
202 201
 	 */
203 202
 	public function getCity(){
204 203
 		$chunks = explode('/', $this->getFilename(), 2);
205
-		if(count($chunks) > 1) return $chunks[0];
204
+		if(count($chunks) > 1) {
205
+			return $chunks[0];
206
+		}
206 207
 		return null;
207 208
 	}
208 209
 	
@@ -246,8 +247,7 @@  discard block
 block discarded – undo
246 247
     	
247 248
     		if($sid){
248 249
     			$this->source = Source::getInstance($sid, $this->tree);
249
-    		}
250
-    		else{
250
+    		} else{
251 251
     			$this->fetchALinkedSource();  // the method already attach the source to the Certificate object;
252 252
     		}
253 253
     		
@@ -256,7 +256,9 @@  discard block
 block discarded – undo
256 256
     			$repofact = $this->source->getFirstFact('REPO');
257 257
     			if($repofact) {
258 258
     				$repo = $repofact->getTarget();
259
-    				if($repo && $repo instanceof Repository)  $wmtext .= ' '.$repo->getFullName().' - ';
259
+    				if($repo && $repo instanceof Repository) {
260
+    					$wmtext .= ' '.$repo->getFullName().' - ';
261
+    				}
260 262
     			}
261 263
     			$wmtext .= $this->source->getFullName();			
262 264
     		}	
@@ -426,7 +428,9 @@  discard block
 block discarded – undo
426 428
 			}
427 429
 		}
428 430
 		
429
-		if($sid) $this->source = Source::getInstance($sid, $this->tree);
431
+		if($sid) {
432
+			$this->source = Source::getInstance($sid, $this->tree);
433
+		}
430 434
 		
431 435
 		return $this->source;	
432 436
 	}
Please login to merge, or discard this patch.
src/Webtrees/Module/CertificatesModule.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@
 block discarded – undo
252 252
     /**
253 253
      * Return the HTML code for custom simple tag _ACT
254 254
      *
255
-     * @param Certificate $certificatePath Certificate (as per the GEDCOM)
255
+     * @param Certificate $certificate Certificate (as per the GEDCOM)
256 256
      * @param string|null $sid Linked Source ID, if it exists
257 257
      */
258 258
     protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -105,7 +105,9 @@  discard block
 block discarded – undo
105 105
         $sid=null;
106 106
         
107 107
         if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){
108
-            if (!$srec || strlen($srec) == 0) return $html;
108
+            if (!$srec || strlen($srec) == 0) {
109
+            	return $html;
110
+            }
109 111
             	
110 112
             $certificate = null;
111 113
             $subrecords = explode("\n", $srec);
@@ -118,11 +120,14 @@  discard block
 block discarded – undo
118 120
                 $level = substr($subrecords[$i], 0, 1);
119 121
                 $tag = substr($subrecords[$i], 2, 4);
120 122
                 $text = substr($subrecords[$i], 7);
121
-                if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider());
123
+                if($tag == '_ACT') {
124
+                	$certificate= new Certificate($text, $WT_TREE, $this->getProvider());
125
+                }
122 126
             }
123 127
             	
124
-            if($certificate && $certificate->canShow())
125
-                $html = $this->getDisplay_ACT($certificate, $sid);
128
+            if($certificate && $certificate->canShow()) {
129
+                            $html = $this->getDisplay_ACT($certificate, $sid);
130
+            }
126 131
                 	
127 132
         }
128 133
         return $html;
@@ -150,7 +155,9 @@  discard block
 block discarded – undo
150 155
         $html = '';
151 156
         switch($tag){
152 157
             case '_ACT':
153
-                if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
158
+                if($context == 'SOUR') {
159
+                	$html = $this->getDisplay_ACT($value, $contextid);
160
+                }
154 161
                 break;
155 162
         }
156 163
         return $html;
@@ -180,7 +187,9 @@  discard block
 block discarded – undo
180 187
 				$html .= '<select id="certifCity'.$element_id.'" class="_CITY">';
181 188
 				foreach ($tabCities as $cities){
182 189
 					$selectedCity='';
183
-					if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"';
190
+					if($certificate && $cities== $certificate->getCity()) {
191
+						$selectedCity='selected="true"';
192
+					}
184 193
 					$html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>';
185 194
 				}
186 195
 				$html .= '</select>';
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
68 68
      */
69 69
     public function getConfigLink() {
70
-        return 'module.php?mod=' . $this->getName() . '&amp;mod_action=AdminConfig';
70
+        return 'module.php?mod='.$this->getName().'&amp;mod_action=AdminConfig';
71 71
     }
72 72
     
73 73
     /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function getMenu(Tree $tree, $reference = null) {
94 94
         $tree_url = $tree ? $tree->getNameUrl() : '';
95
-        return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
95
+        return new Menu($this->getTitle(), 'module.php?mod='.$this->getName().'&mod_action=Certificate@listAll&ged='.$tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
96 96
     }
97 97
     
98 98
     /**
@@ -102,27 +102,27 @@  discard block
 block discarded – undo
102 102
     public function hFactSourcePrepend($srec) {
103 103
         global $WT_TREE;
104 104
         
105
-        $html='';
106
-        $sid=null;
105
+        $html = '';
106
+        $sid = null;
107 107
         
108
-        if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){
108
+        if ($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)) {
109 109
             if (!$srec || strlen($srec) == 0) return $html;
110 110
             	
111 111
             $certificate = null;
112 112
             $subrecords = explode("\n", $srec);
113 113
             $levelSOUR = substr($subrecords[0], 0, 1);
114 114
             if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) {
115
-                $sid=$match[1];
115
+                $sid = $match[1];
116 116
             };
117 117
             $nb_subrecords = count($subrecords);
118
-            for ($i=0; $i < $nb_subrecords; $i++) {
118
+            for ($i = 0; $i < $nb_subrecords; $i++) {
119 119
                 $subrecords[$i] = trim($subrecords[$i]);
120 120
                 $tag = substr($subrecords[$i], 2, 4);
121 121
                 $text = substr($subrecords[$i], 7);
122
-                if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider());
122
+                if ($tag == '_ACT') $certificate = new Certificate($text, $WT_TREE, $this->getProvider());
123 123
             }
124 124
             	
125
-            if($certificate && $certificate->canShow())
125
+            if ($certificate && $certificate->canShow())
126 126
                 $html = $this->getDisplay_ACT($certificate, $sid);
127 127
                 	
128 128
         }
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) {
151 151
         $html = '';
152
-        switch($tag){
152
+        switch ($tag) {
153 153
             case '_ACT':
154
-                if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
154
+                if ($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
155 155
                 break;
156 156
         }
157 157
         return $html;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         
167 167
         $html = '';
168 168
 		
169
-		switch($tag){
169
+		switch ($tag) {
170 170
 			case '_ACT':
171 171
 				$element_id = Uuid::uuid4();
172 172
 				$controller
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 					->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/autocomplete.js')
175 175
 					->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/updatecertificatevalues.js');
176 176
 				$certificate = null;
177
-				if($value){
177
+				if ($value) {
178 178
 					$certificate = new Certificate($value, $WT_TREE, $this->getProvider());
179 179
 				}
180 180
 				$tabCities = $this->getProvider()->getCitiesList();
181 181
 				$html .= '<select id="certifCity'.$element_id.'" class="_CITY">';
182
-				foreach ($tabCities as $cities){
183
-					$selectedCity='';
184
-					if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"';
182
+				foreach ($tabCities as $cities) {
183
+					$selectedCity = '';
184
+					if ($certificate && $cities == $certificate->getCity()) $selectedCity = 'selected="true"';
185 185
 					$html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>';
186 186
 				}
187 187
 				$html .= '</select>';
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag()
200 200
      */
201 201
     public function hAddSimpleTag($context, $level) {
202
-        switch($context){
202
+        switch ($context) {
203 203
             case 'SOUR':
204 204
                 FunctionsEdit::addSimpleTag($level.' _ACT');
205 205
                 break;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag()
212 212
      */
213 213
     public function hHasHelpTextTag($tag) {
214
-        switch($tag){
214
+        switch ($tag) {
215 215
 			case '_ACT':
216 216
 				return true;
217 217
 				break;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag()
225 225
      */
226 226
     public function hGetHelpTextTag($tag) {
227
-        switch($tag){
227
+        switch ($tag) {
228 228
             case '_ACT':
229 229
                 return array(
230 230
                 I18N::translate('Certificate'),
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     public function getProvider() {
243 243
         global $WT_TREE;
244 244
     
245
-        if(!$this->provider) {
245
+        if (!$this->provider) {
246 246
             $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/');
247 247
             $this->provider = new CertificateFileProvider($root_path, $WT_TREE);
248 248
         }
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
      * @param Certificate $certificatePath Certificate (as per the GEDCOM)
257 257
      * @param string|null $sid Linked Source ID, if it exists
258 258
      */
259
-    protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
259
+    protected function getDisplay_ACT(Certificate $certificate, $sid = null) {    
260 260
         $html = '';
261
-        if($certificate){
261
+        if ($certificate) {
262 262
             $certificate->setSource($sid);
263 263
             $html = $certificate->displayImage('icon');
264 264
         }
Please login to merge, or discard this patch.
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -30,151 +30,151 @@  discard block
 block discarded – undo
30 30
  * Certificates Module.
31 31
  */
32 32
 class CertificatesModule 
33
-    extends AbstractModule 
34
-    implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface, DependentInterface
33
+	extends AbstractModule 
34
+	implements HookSubscriberInterface, ModuleConfigInterface, ModuleMenuItemInterface, FactSourceTextExtenderInterface, CustomSimpleTagManagerInterface, DependentInterface
35 35
 {
36
-    /** @var string For custom modules - link for support, upgrades, etc. */
37
-    const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
36
+	/** @var string For custom modules - link for support, upgrades, etc. */
37
+	const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib';
38 38
         
39
-    /**
40
-     * Provider for Certificates
41
-     * @var CertificateProviderInterface $provider
42
-     */
43
-    protected $provider;
39
+	/**
40
+	 * Provider for Certificates
41
+	 * @var CertificateProviderInterface $provider
42
+	 */
43
+	protected $provider;
44 44
     
45
-    /**
46
-     * {@inhericDoc}
47
-     */
48
-    public function getTitle() {
49
-        return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates');
50
-    }
45
+	/**
46
+	 * {@inhericDoc}
47
+	 */
48
+	public function getTitle() {
49
+		return /* I18N: Name of the “Certificates” module */ I18N::translate('Certificates');
50
+	}
51 51
     
52
-    /**
53
-     * {@inhericDoc}
54
-     */
55
-    public function getDescription() {
56
-        return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.');
57
-    }
52
+	/**
53
+	 * {@inhericDoc}
54
+	 */
55
+	public function getDescription() {
56
+		return /* I18N: Description of the “Certificates” module */ I18N::translate('Display and edition of certificates linked to sources.');
57
+	}
58 58
     
59
-    /**
60
-     * {@inhericDoc}
61
-     */
62
-    public function modAction($mod_action) {
63
-        \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
64
-    }
59
+	/**
60
+	 * {@inhericDoc}
61
+	 */
62
+	public function modAction($mod_action) {
63
+		\MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action);
64
+	}
65 65
 
66
-    /**
67
-     * {@inheritDoc}
68
-     * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
69
-     */
70
-    public function validatePrerequisites() {
71
-        return Functions::isEncryptionCompatible();    
72
-    }
66
+	/**
67
+	 * {@inheritDoc}
68
+	 * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites()
69
+	 */
70
+	public function validatePrerequisites() {
71
+		return Functions::isEncryptionCompatible();    
72
+	}
73 73
     
74
-    /**
75
-     * {@inhericDoc}
76
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
77
-     */
78
-    public function getConfigLink() {
79
-        return 'module.php?mod=' . $this->getName() . '&amp;mod_action=AdminConfig';
80
-    }
74
+	/**
75
+	 * {@inhericDoc}
76
+	 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
77
+	 */
78
+	public function getConfigLink() {
79
+		return 'module.php?mod=' . $this->getName() . '&amp;mod_action=AdminConfig';
80
+	}
81 81
     
82
-    /**
83
-     * {@inhericDoc}
84
-     * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks()
85
-     */
86
-    public function getSubscribedHooks() {
87
-        return array(
88
-            'hFactSourcePrepend' => 50,
89
-            'hGetExpectedTags' => 50,
90
-            'hHtmlSimpleTagDisplay#_ACT' => 50,
91
-            'hHtmlSimpleTagEditor#_ACT'	=> 50,
92
-            'hAddSimpleTag#SOUR'	=> 50,
93
-            'hHasHelpTextTag#_ACT'	=> 50,
94
-            'hGetHelpTextTag#_ACT'	=> 50
95
-        );
96
-    }
82
+	/**
83
+	 * {@inhericDoc}
84
+	 * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks()
85
+	 */
86
+	public function getSubscribedHooks() {
87
+		return array(
88
+			'hFactSourcePrepend' => 50,
89
+			'hGetExpectedTags' => 50,
90
+			'hHtmlSimpleTagDisplay#_ACT' => 50,
91
+			'hHtmlSimpleTagEditor#_ACT'	=> 50,
92
+			'hAddSimpleTag#SOUR'	=> 50,
93
+			'hHasHelpTextTag#_ACT'	=> 50,
94
+			'hGetHelpTextTag#_ACT'	=> 50
95
+		);
96
+	}
97 97
     
98
-    /**
99
-     * {@inhericDoc}
100
-     * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu()
101
-     */
102
-    public function getMenu(Tree $tree, $reference = null) {
103
-        $tree_url = $tree ? $tree->getNameUrl() : '';
104
-        return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
105
-    }
98
+	/**
99
+	 * {@inhericDoc}
100
+	 * @see \MyArtJaub\Webtrees\Module\ModuleMenuItemInterface::getMenu()
101
+	 */
102
+	public function getMenu(Tree $tree, $reference = null) {
103
+		$tree_url = $tree ? $tree->getNameUrl() : '';
104
+		return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow'));
105
+	}
106 106
     
107
-    /**
108
-     * {@inhericDoc}
109
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend()
110
-     */
111
-    public function hFactSourcePrepend($srec) {
112
-        global $WT_TREE;
107
+	/**
108
+	 * {@inhericDoc}
109
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourcePrepend()
110
+	 */
111
+	public function hFactSourcePrepend($srec) {
112
+		global $WT_TREE;
113 113
         
114
-        $html='';
115
-        $sid=null;
114
+		$html='';
115
+		$sid=null;
116 116
         
117
-        if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){
118
-            if (!$srec || strlen($srec) == 0) return $html;
117
+		if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){
118
+			if (!$srec || strlen($srec) == 0) return $html;
119 119
             	
120
-            $certificate = null;
121
-            $subrecords = explode("\n", $srec);
122
-            $levelSOUR = substr($subrecords[0], 0, 1);
123
-            $match = null;
124
-            if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) {
125
-                $sid=$match[1];
126
-            };
127
-            $nb_subrecords = count($subrecords);
128
-            for ($i=0; $i < $nb_subrecords; $i++) {
129
-                $subrecords[$i] = trim($subrecords[$i]);
130
-                $tag = substr($subrecords[$i], 2, 4);
131
-                $text = substr($subrecords[$i], 7);
132
-                if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider());
133
-            }
120
+			$certificate = null;
121
+			$subrecords = explode("\n", $srec);
122
+			$levelSOUR = substr($subrecords[0], 0, 1);
123
+			$match = null;
124
+			if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) {
125
+				$sid=$match[1];
126
+			};
127
+			$nb_subrecords = count($subrecords);
128
+			for ($i=0; $i < $nb_subrecords; $i++) {
129
+				$subrecords[$i] = trim($subrecords[$i]);
130
+				$tag = substr($subrecords[$i], 2, 4);
131
+				$text = substr($subrecords[$i], 7);
132
+				if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider());
133
+			}
134 134
             	
135
-            if($certificate && $certificate->canShow())
136
-                $html = $this->getDisplay_ACT($certificate, $sid);
135
+			if($certificate && $certificate->canShow())
136
+				$html = $this->getDisplay_ACT($certificate, $sid);
137 137
                 	
138
-        }
139
-        return $html;
140
-    }
138
+		}
139
+		return $html;
140
+	}
141 141
    
142
-    /**
143
-     * {@inhericDoc}
144
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend()
145
-     */
146
-    public function hFactSourceAppend($srec) { }
142
+	/**
143
+	 * {@inhericDoc}
144
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\FactSourceTextExtenderInterface::hFactSourceAppend()
145
+	 */
146
+	public function hFactSourceAppend($srec) { }
147 147
     
148
-    /**
149
-     * {@inhericDoc}
150
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags()
151
-     */
152
-    public function hGetExpectedTags() {
153
-        return array('SOUR' => '_ACT');
154
-    }
148
+	/**
149
+	 * {@inhericDoc}
150
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetExpectedTags()
151
+	 */
152
+	public function hGetExpectedTags() {
153
+		return array('SOUR' => '_ACT');
154
+	}
155 155
     
156
-    /**
157
-     * {@inhericDoc}
158
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay()
159
-     */
160
-    public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) {
161
-        $html = '';
162
-        switch($tag){
163
-            case '_ACT':
164
-                if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
165
-                break;
166
-        }
167
-        return $html;
168
-    }
156
+	/**
157
+	 * {@inhericDoc}
158
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagDisplay()
159
+	 */
160
+	public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) {
161
+		$html = '';
162
+		switch($tag){
163
+			case '_ACT':
164
+				if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid);
165
+				break;
166
+		}
167
+		return $html;
168
+	}
169 169
     
170
-    /**
171
-     * {@inhericDoc}
172
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor()
173
-     */
174
-    public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) {
175
-        global $controller, $WT_TREE;
170
+	/**
171
+	 * {@inhericDoc}
172
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHtmlSimpleTagEditor()
173
+	 */
174
+	public function hHtmlSimpleTagEditor($tag, $value = null, $element_id = '', $element_name = '', $context = null, $contextid = null) {
175
+		global $controller, $WT_TREE;
176 176
         
177
-        $html = '';
177
+		$html = '';
178 178
 		
179 179
 		switch($tag){
180 180
 			case '_ACT':
@@ -202,77 +202,77 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 		
204 204
 		return $html;
205
-    }
205
+	}
206 206
     
207
-    /**
208
-     * {@inhericDoc}
209
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag()
210
-     */
211
-    public function hAddSimpleTag($context, $level) {
212
-        switch($context){
213
-            case 'SOUR':
214
-                FunctionsEdit::addSimpleTag($level.' _ACT');
215
-                break;
216
-        }
217
-    }
207
+	/**
208
+	 * {@inhericDoc}
209
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag()
210
+	 */
211
+	public function hAddSimpleTag($context, $level) {
212
+		switch($context){
213
+			case 'SOUR':
214
+				FunctionsEdit::addSimpleTag($level.' _ACT');
215
+				break;
216
+		}
217
+	}
218 218
     
219
-    /**
220
-     * {@inhericDoc}
221
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag()
222
-     */
223
-    public function hHasHelpTextTag($tag) {
224
-        switch($tag){
219
+	/**
220
+	 * {@inhericDoc}
221
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag()
222
+	 */
223
+	public function hHasHelpTextTag($tag) {
224
+		switch($tag){
225 225
 			case '_ACT':
226 226
 				return true;
227 227
 		}
228 228
 		return false;
229
-    }
229
+	}
230 230
     
231
-    /**
232
-     * {@inhericDoc}
233
-     * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag()
234
-     */
235
-    public function hGetHelpTextTag($tag) {
236
-        switch($tag){
237
-            case '_ACT':
238
-                return array(
239
-                I18N::translate('Certificate'),
240
-                '<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>');
241
-            default:
242
-                return null;
243
-        }
244
-    }
231
+	/**
232
+	 * {@inhericDoc}
233
+	 * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag()
234
+	 */
235
+	public function hGetHelpTextTag($tag) {
236
+		switch($tag){
237
+			case '_ACT':
238
+				return array(
239
+				I18N::translate('Certificate'),
240
+				'<p>'.I18N::translate('Path to a certificate linked to a source reference.').'</p>');
241
+			default:
242
+				return null;
243
+		}
244
+	}
245 245
 
246
-    /**
247
-     * Returns the default Certificate File Provider, as configured in the module
248
-     *
249
-     * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface
250
-     */
251
-    public function getProvider() {
252
-        global $WT_TREE;
246
+	/**
247
+	 * Returns the default Certificate File Provider, as configured in the module
248
+	 *
249
+	 * @return \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface
250
+	 */
251
+	public function getProvider() {
252
+		global $WT_TREE;
253 253
     
254
-        if(!$this->provider) {
255
-            $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/');
256
-            $this->provider = new CertificateFileProvider($root_path, $WT_TREE);
257
-        }
258
-        return $this->provider;
259
-    }
254
+		if(!$this->provider) {
255
+			$root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/');
256
+			$this->provider = new CertificateFileProvider($root_path, $WT_TREE);
257
+		}
258
+		return $this->provider;
259
+	}
260 260
     
261 261
     
262
-    /**
263
-     * Return the HTML code for custom simple tag _ACT
264
-     *
265
-     * @param Certificate $certificatePath Certificate (as per the GEDCOM)
266
-     * @param string|null $sid Linked Source ID, if it exists
267
-     */
268
-    protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
269
-        $html = '';
270
-        if($certificate){
271
-            $certificate->setSource($sid);
272
-            $html = $certificate->displayImage('icon');
273
-        }
274
-        return $html;
275
-    }
262
+	/**
263
+	 * Return the HTML code for custom simple tag _ACT
264
+	 *
265
+	 * @param Certificate $certificatePath Certificate (as per the GEDCOM)
266
+	 * @param string|null $sid Linked Source ID, if it exists
267
+	 */
268
+	protected function getDisplay_ACT(Certificate $certificate, $sid = null){    
269
+		$html = '';
270
+		if($certificate){
271
+			$certificate->setSource($sid);
272
+			$html = $certificate->displayImage('icon');
273
+		}
274
+		return $html;
275
+	}
276 276
 
277 277
 
278 278
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
     /**
90 90
      * Returns the number of geographical analysis (active and inactive). 
91 91
      * 
92
-     * @return int
92
+     * @return string
93 93
      */
94 94
     public function getGeoAnalysisCount() {
95 95
         return Database::prepare(
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 			$ga = $this->getGeoAnalysis($id, false);
168 168
 			
169 169
 			$id = Database::commit();
170
-		}
171
-		catch(\Exception $ex) {
170
+		} catch(\Exception $ex) {
172 171
 			Database::rollback();
173 172
 			$ga = null;
174 173
 			Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage());
@@ -210,8 +209,7 @@  discard block
 block discarded – undo
210 209
 			$ga = $this->getGeoAnalysis($ga->getId(), false);
211 210
 			
212 211
 			$id = Database::commit();
213
-		}
214
-		catch(\Exception $ex) {		    
212
+		} catch(\Exception $ex) {		    
215 213
 			Database::rollback();
216 214
 			Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage());
217 215
 			$ga = null;
@@ -350,8 +348,7 @@  discard block
 block discarded – undo
350 348
         if(!$this->place_hierarchy) {
351 349
             if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352 350
                 $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
-            }
354
-            else {
351
+            } else {
355 352
                 $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData());
356 353
             }            
357 354
         }
Please login to merge, or discard this patch.
Indentation   +327 added lines, -327 removed lines patch added patch discarded remove patch
@@ -21,130 +21,130 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class GeoAnalysisProvider {
23 23
     
24
-    /**
25
-     * Reference tree
26
-     * @var Tree $tree
27
-     */
28
-    protected $tree;
24
+	/**
25
+	 * Reference tree
26
+	 * @var Tree $tree
27
+	 */
28
+	protected $tree;
29 29
     
30
-    /**
31
-     * Cached hierarchy of places in the Gedcom file.
32
-     * 
33
-     * @var (array|null) $place_hierarchy
34
-     */
35
-    protected $place_hierarchy;
30
+	/**
31
+	 * Cached hierarchy of places in the Gedcom file.
32
+	 * 
33
+	 * @var (array|null) $place_hierarchy
34
+	 */
35
+	protected $place_hierarchy;
36 36
     
37
-    /**
38
-     * Constructor for GeoAnalysis Provider.
39
-     * A provider is defined in relation to a specific tree.
40
-     *
41
-     * @param Tree $tree
42
-     */
43
-    public function __construct(Tree $tree) {
44
-        $this->tree = $tree;
45
-        $this->place_hierarchy = null;
46
-    }
37
+	/**
38
+	 * Constructor for GeoAnalysis Provider.
39
+	 * A provider is defined in relation to a specific tree.
40
+	 *
41
+	 * @param Tree $tree
42
+	 */
43
+	public function __construct(Tree $tree) {
44
+		$this->tree = $tree;
45
+		$this->place_hierarchy = null;
46
+	}
47 47
     
48
-    /**
49
-     * Creates and returns a GeoAnalysis object from a data row.
50
-     * The row data is expected to be an array with the indexes:
51
-     *  - majgd_id: geodispersion analysis ID
52
-     *  - majgd_descr: geodispersion analysis description/title
53
-     *  - majgd_sublevel: Analysis level
54
-     *  - majgd_useflagsgen: Use flags in places display
55
-     *  - majgd_detailsgen: Number of top places
56
-     *  - majgd_map: file name of the map
57
-     *  - majgd_toplevel: parent level for the map
58
-     * 
59
-     * @param array $row
60
-     * @return GeoAnalysis
61
-     */
62
-    protected function loadGeoAnalysisFromRow($row) {
63
-        $options = new GeoDisplayOptions();
64
-        $options
65
-        ->setUsingFlags($row['majgd_useflagsgen'] == 'yes')
66
-        ->setMaxDetailsInGen($row['majgd_detailsgen']);
48
+	/**
49
+	 * Creates and returns a GeoAnalysis object from a data row.
50
+	 * The row data is expected to be an array with the indexes:
51
+	 *  - majgd_id: geodispersion analysis ID
52
+	 *  - majgd_descr: geodispersion analysis description/title
53
+	 *  - majgd_sublevel: Analysis level
54
+	 *  - majgd_useflagsgen: Use flags in places display
55
+	 *  - majgd_detailsgen: Number of top places
56
+	 *  - majgd_map: file name of the map
57
+	 *  - majgd_toplevel: parent level for the map
58
+	 * 
59
+	 * @param array $row
60
+	 * @return GeoAnalysis
61
+	 */
62
+	protected function loadGeoAnalysisFromRow($row) {
63
+		$options = new GeoDisplayOptions();
64
+		$options
65
+		->setUsingFlags($row['majgd_useflagsgen'] == 'yes')
66
+		->setMaxDetailsInGen($row['majgd_detailsgen']);
67 67
         
68
-        if($row['majgd_map']) {
69
-            $options
70
-            ->setMap(new OutlineMap($row['majgd_map']))
71
-            ->setMapLevel($row['majgd_toplevel']);
72
-        }
68
+		if($row['majgd_map']) {
69
+			$options
70
+			->setMap(new OutlineMap($row['majgd_map']))
71
+			->setMapLevel($row['majgd_toplevel']);
72
+		}
73 73
         
74
-        $enabled = true;
75
-        if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
76
-            $enabled = false;
77
-        }
74
+		$enabled = true;
75
+		if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
76
+			$enabled = false;
77
+		}
78 78
         
79
-        return new GeoAnalysis(
80
-            $this->tree,
81
-            $row['majgd_id'],
82
-            $row['majgd_descr'],
83
-            $row['majgd_sublevel'],
84
-            $options,
85
-            $enabled
86
-            );
87
-    }
79
+		return new GeoAnalysis(
80
+			$this->tree,
81
+			$row['majgd_id'],
82
+			$row['majgd_descr'],
83
+			$row['majgd_sublevel'],
84
+			$options,
85
+			$enabled
86
+			);
87
+	}
88 88
     
89
-    /**
90
-     * Returns the number of geographical analysis (active and inactive). 
91
-     * 
92
-     * @return int
93
-     */
94
-    public function getGeoAnalysisCount() {
95
-        return Database::prepare(
96
-            'SELECT COUNT(majgd_id)' .
97
-            ' FROM `##maj_geodispersion`' .
98
-            ' WHERE majgd_file = :gedcom_id'
99
-            )->execute(array(
100
-                'gedcom_id' => $this->tree->getTreeId()
101
-            ))->fetchOne();
102
-    }
89
+	/**
90
+	 * Returns the number of geographical analysis (active and inactive). 
91
+	 * 
92
+	 * @return int
93
+	 */
94
+	public function getGeoAnalysisCount() {
95
+		return Database::prepare(
96
+			'SELECT COUNT(majgd_id)' .
97
+			' FROM `##maj_geodispersion`' .
98
+			' WHERE majgd_file = :gedcom_id'
99
+			)->execute(array(
100
+				'gedcom_id' => $this->tree->getTreeId()
101
+			))->fetchOne();
102
+	}
103 103
     
104
-    /**
105
-     * Get a geographical analysis by its ID.
106
-     * The function can only search for only enabled analysis, or all.
107
-     * 
108
-     * @param int $id geodispersion analysis ID
109
-     * @param bool $only_enabled Search for only enabled geodispersion analysis
110
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL
111
-     */
112
-    public function getGeoAnalysis($id, $only_enabled = true) {
113
-        $args = array (
114
-            'gedcom_id' => $this->tree->getTreeId(),
115
-            'ga_id' => $id
116
-        );
104
+	/**
105
+	 * Get a geographical analysis by its ID.
106
+	 * The function can only search for only enabled analysis, or all.
107
+	 * 
108
+	 * @param int $id geodispersion analysis ID
109
+	 * @param bool $only_enabled Search for only enabled geodispersion analysis
110
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL
111
+	 */
112
+	public function getGeoAnalysis($id, $only_enabled = true) {
113
+		$args = array (
114
+			'gedcom_id' => $this->tree->getTreeId(),
115
+			'ga_id' => $id
116
+		);
117 117
         
118
-        $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
119
-            ' FROM `##maj_geodispersion`' .
120
-            ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id';
121
-        if($only_enabled) {
122
-            $sql .= ' AND majgd_status = :status';
123
-            $args['status'] = 'enabled';
124
-        }
125
-        $sql .= ' ORDER BY majgd_descr';
118
+		$sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
119
+			' FROM `##maj_geodispersion`' .
120
+			' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id';
121
+		if($only_enabled) {
122
+			$sql .= ' AND majgd_status = :status';
123
+			$args['status'] = 'enabled';
124
+		}
125
+		$sql .= ' ORDER BY majgd_descr';
126 126
         
127
-        $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
127
+		$ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
128 128
         
129
-        if($ga_array) {
130
-            return $this->loadGeoAnalysisFromRow($ga_array);
131
-        }
129
+		if($ga_array) {
130
+			return $this->loadGeoAnalysisFromRow($ga_array);
131
+		}
132 132
         
133
-        return null;            
134
-    }
133
+		return null;            
134
+	}
135 135
     
136
-    /**
137
-     * Add a new geodispersion analysis in the database, in a transactional manner.
138
-     * When successful, eturns the newly created GeoAnalysis object.
139
-     * 
140
-     * @param string $description geodispersion analysis title
141
-     * @param int $analysis_level Analysis level
142
-     * @param string $map_file Filename of the map
143
-     * @param int $map_top_level Parent level of the map
144
-     * @param bool $use_flags Use flag in the place display
145
-     * @param int $gen_details Number of top places to display
146
-     * @return GeoAnalysis
147
-     */
136
+	/**
137
+	 * Add a new geodispersion analysis in the database, in a transactional manner.
138
+	 * When successful, eturns the newly created GeoAnalysis object.
139
+	 * 
140
+	 * @param string $description geodispersion analysis title
141
+	 * @param int $analysis_level Analysis level
142
+	 * @param string $map_file Filename of the map
143
+	 * @param int $map_top_level Parent level of the map
144
+	 * @param bool $use_flags Use flag in the place display
145
+	 * @param int $gen_details Number of top places to display
146
+	 * @return GeoAnalysis
147
+	 */
148 148
 	public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) {
149 149
 		try{
150 150
 			Database::beginTransaction();
@@ -174,17 +174,17 @@  discard block
 block discarded – undo
174 174
 			Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage());
175 175
 		}
176 176
 		return $ga;
177
-    }
177
+	}
178 178
 	
179
-    /**
180
-     * Update a geodispersion analysis in the database, in transactional manner.
181
-     * When successful, returns the updated GeoAnalysis object
182
-     *  
183
-     * @param GeoAnalysis $ga
184
-     * @return GeoAnalysis
185
-     */
186
-    public function updateGeoAnalysis(GeoAnalysis $ga) {
187
-        try {
179
+	/**
180
+	 * Update a geodispersion analysis in the database, in transactional manner.
181
+	 * When successful, returns the updated GeoAnalysis object
182
+	 *  
183
+	 * @param GeoAnalysis $ga
184
+	 * @return GeoAnalysis
185
+	 */
186
+	public function updateGeoAnalysis(GeoAnalysis $ga) {
187
+		try {
188 188
 			Database::beginTransaction();
189 189
 		
190 190
 			Database::prepare(
@@ -217,236 +217,236 @@  discard block
 block discarded – undo
217 217
 			$ga = null;
218 218
 		}
219 219
 		return $ga;
220
-    }
220
+	}
221 221
     
222
-    /**
223
-     * Set the status of a specific analysis.
224
-     * The status can be enabled (true), or disabled (false).
225
-     * 
226
-     * @param GeoAnalysis $ga
227
-     * @param bool $status
228
-     */
229
-    public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) {
230
-        Database::prepare(
231
-            'UPDATE `##maj_geodispersion`'.
232
-            ' SET majgd_status = :status'.
233
-            ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
234
-        )->execute(array(
235
-                'gedcom_id' => $this->tree->getTreeId(),
236
-                'status' => $status ? 'enabled' : 'disabled',
237
-                'ga_id' => $ga->getId()
238
-        ));
239
-    }
222
+	/**
223
+	 * Set the status of a specific analysis.
224
+	 * The status can be enabled (true), or disabled (false).
225
+	 * 
226
+	 * @param GeoAnalysis $ga
227
+	 * @param bool $status
228
+	 */
229
+	public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) {
230
+		Database::prepare(
231
+			'UPDATE `##maj_geodispersion`'.
232
+			' SET majgd_status = :status'.
233
+			' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
234
+		)->execute(array(
235
+				'gedcom_id' => $this->tree->getTreeId(),
236
+				'status' => $status ? 'enabled' : 'disabled',
237
+				'ga_id' => $ga->getId()
238
+		));
239
+	}
240 240
     
241
-    /**
242
-     * Delete a geodispersion analysis from the database.
243
-     * 
244
-     * @param GeoAnalysis $ga
245
-     */
246
-    public function deleteGeoAnalysis(GeoAnalysis $ga) {
247
-        Database::prepare(
248
-            'DELETE FROM `##maj_geodispersion`'.
249
-            ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
250
-            )->execute(array(
251
-                'gedcom_id' => $this->tree->getTreeId(),
252
-                'ga_id' => $ga->getId()
253
-            ));
254
-    }
241
+	/**
242
+	 * Delete a geodispersion analysis from the database.
243
+	 * 
244
+	 * @param GeoAnalysis $ga
245
+	 */
246
+	public function deleteGeoAnalysis(GeoAnalysis $ga) {
247
+		Database::prepare(
248
+			'DELETE FROM `##maj_geodispersion`'.
249
+			' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'
250
+			)->execute(array(
251
+				'gedcom_id' => $this->tree->getTreeId(),
252
+				'ga_id' => $ga->getId()
253
+			));
254
+	}
255 255
         
256
-    /**
257
-     * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM
258
-     *
259
-     * @return array List of enabled maps
260
-     */
261
-    public function getGeoAnalysisList(){
262
-        $res = array();
256
+	/**
257
+	 * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM
258
+	 *
259
+	 * @return array List of enabled maps
260
+	 */
261
+	public function getGeoAnalysisList(){
262
+		$res = array();
263 263
         
264
-        $list = Database::prepare(
265
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' .
266
-            ' FROM `##maj_geodispersion`' .
267
-            ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'.
268
-            ' ORDER BY majgd_descr'
269
-        )->execute(array(
270
-            'gedcom_id' => $this->tree->getTreeId(),
271
-            'status' => 'enabled'
272
-        ))->fetchAll(\PDO::FETCH_ASSOC);
264
+		$list = Database::prepare(
265
+			'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' .
266
+			' FROM `##maj_geodispersion`' .
267
+			' WHERE majgd_file = :gedcom_id AND majgd_status = :status'.
268
+			' ORDER BY majgd_descr'
269
+		)->execute(array(
270
+			'gedcom_id' => $this->tree->getTreeId(),
271
+			'status' => 'enabled'
272
+		))->fetchAll(\PDO::FETCH_ASSOC);
273 273
         
274
-        foreach($list as $ga) {
275
-           $res[] = $this->loadGeoAnalysisFromRow($ga);
276
-        }
274
+		foreach($list as $ga) {
275
+		   $res[] = $this->loadGeoAnalysisFromRow($ga);
276
+		}
277 277
         
278
-        return $res;
279
-    }
278
+		return $res;
279
+	}
280 280
     
281
-    /**
282
-     * Return the list of geodispersion analysis matching specified criterias.
283
-     * 
284
-     * @param string $search Search criteria in analysis description
285
-     * @param array $order_by Columns to order by
286
-     * @param int $start Offset to start with (for pagination)
287
-     * @param int|null $limit Max number of items to return (for pagination)
288
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
289
-     */
290
-    public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){
291
-        $res = array();
281
+	/**
282
+	 * Return the list of geodispersion analysis matching specified criterias.
283
+	 * 
284
+	 * @param string $search Search criteria in analysis description
285
+	 * @param array $order_by Columns to order by
286
+	 * @param int $start Offset to start with (for pagination)
287
+	 * @param int|null $limit Max number of items to return (for pagination)
288
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
289
+	 */
290
+	public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){
291
+		$res = array();
292 292
             
293
-        $sql = 
294
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
295
-            ' FROM `##maj_geodispersion`' .
296
-            ' WHERE majgd_file = :gedcom_id';
293
+		$sql = 
294
+			'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
295
+			' FROM `##maj_geodispersion`' .
296
+			' WHERE majgd_file = :gedcom_id';
297 297
         
298
-        $args = array('gedcom_id'=> $this->tree->getTreeId());
298
+		$args = array('gedcom_id'=> $this->tree->getTreeId());
299 299
         
300
-        if($search) {
301
-            $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')';
302
-            $args['search'] = $search;
303
-        }
300
+		if($search) {
301
+			$sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')';
302
+			$args['search'] = $search;
303
+		}
304 304
         
305
-        if ($order_by) {
306
-            $sql .= ' ORDER BY ';
307
-            foreach ($order_by as $key => $value) {
308
-                if ($key > 0) {
309
-                    $sql .= ',';
310
-                }
305
+		if ($order_by) {
306
+			$sql .= ' ORDER BY ';
307
+			foreach ($order_by as $key => $value) {
308
+				if ($key > 0) {
309
+					$sql .= ',';
310
+				}
311 311
                 
312
-                switch ($value['dir']) {
313
-                    case 'asc':
314
-                        $sql .= $value['column'] . ' ASC ';
315
-                        break;
316
-                    case 'desc':
317
-                        $sql .= $value['column'] . ' DESC ';
318
-                        break;
319
-                }
320
-            }
321
-        } else {
322
-            $sql = " ORDER BY majgd_descr ASC";
323
-        }
312
+				switch ($value['dir']) {
313
+					case 'asc':
314
+						$sql .= $value['column'] . ' ASC ';
315
+						break;
316
+					case 'desc':
317
+						$sql .= $value['column'] . ' DESC ';
318
+						break;
319
+				}
320
+			}
321
+		} else {
322
+			$sql = " ORDER BY majgd_descr ASC";
323
+		}
324 324
         
325
-        if ($limit) {
326
-            $sql .= " LIMIT :limit OFFSET :offset";
327
-            $args['limit']  = $limit;
328
-            $args['offset'] = $start;
329
-        }
325
+		if ($limit) {
326
+			$sql .= " LIMIT :limit OFFSET :offset";
327
+			$args['limit']  = $limit;
328
+			$args['offset'] = $start;
329
+		}
330 330
             
331
-        $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
331
+		$data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
332 332
 
333
-        foreach($data as $ga) {
334
-            $res[] = $this->loadGeoAnalysisFromRow($ga);
335
-        }
333
+		foreach($data as $ga) {
334
+			$res[] = $this->loadGeoAnalysisFromRow($ga);
335
+		}
336 336
         
337
-        return $res;
338
-    }
337
+		return $res;
338
+	}
339 339
             
340
-    /**
341
-     * Returns the infered place hierarchy, determined from the Gedcom data.
342
-     * Depending on the data, it can be based on the Gedcom Header description, or from a place example.
343
-     * This is returned as an associative array:
344
-     *      - type:    describe the source of the data (<em>header<em> / <em>data</em>)
345
-     *      - hierarchy: an array of the place hierarchy (in reverse order of the gedcom)
346
-     *      
347
-     * @return array
348
-     */
349
-    public function getPlacesHierarchy() {
350
-        if(!$this->place_hierarchy) {
351
-            if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352
-                $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
-            }
354
-            else {
355
-                $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData());
356
-            }            
357
-        }
358
-        return $this->place_hierarchy;        
359
-    }
340
+	/**
341
+	 * Returns the infered place hierarchy, determined from the Gedcom data.
342
+	 * Depending on the data, it can be based on the Gedcom Header description, or from a place example.
343
+	 * This is returned as an associative array:
344
+	 *      - type:    describe the source of the data (<em>header<em> / <em>data</em>)
345
+	 *      - hierarchy: an array of the place hierarchy (in reverse order of the gedcom)
346
+	 *      
347
+	 * @return array
348
+	 */
349
+	public function getPlacesHierarchy() {
350
+		if(!$this->place_hierarchy) {
351
+			if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352
+				$this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
+			}
354
+			else {
355
+				$this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData());
356
+			}            
357
+		}
358
+		return $this->place_hierarchy;        
359
+	}
360 360
     
361
-    /**
362
-     * Returns an array of the place hierarchy, as defined in the GEDCOM header.
363
-     * The places are reversed compared to normal GEDCOM structure.
364
-     * 
365
-     * @return array|null
366
-     */
367
-    protected function getPlacesHierarchyFromHeader() {
368
-        $head = GedcomRecord::getInstance('HEAD', $this->tree);
369
-        $head_place = $head->getFirstFact('PLAC');
370
-        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
371
-            return array_reverse(array_map('trim',explode(',', $head_place_value)));
372
-        }
373
-        return null;
374
-    }
361
+	/**
362
+	 * Returns an array of the place hierarchy, as defined in the GEDCOM header.
363
+	 * The places are reversed compared to normal GEDCOM structure.
364
+	 * 
365
+	 * @return array|null
366
+	 */
367
+	protected function getPlacesHierarchyFromHeader() {
368
+		$head = GedcomRecord::getInstance('HEAD', $this->tree);
369
+		$head_place = $head->getFirstFact('PLAC');
370
+		if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
371
+			return array_reverse(array_map('trim',explode(',', $head_place_value)));
372
+		}
373
+		return null;
374
+	}
375 375
     
376
-    /**
377
-     * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
378
-     * It will look for the longest hierarchy in the tree.
379
-     * The places are reversed compared to normal GEDCOM structure.
380
-     * 
381
-     * @return array
382
-     */
383
-    protected function getPlacesHierarchyFromData() {
384
-        $nb_levels = 0;
376
+	/**
377
+	 * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
378
+	 * It will look for the longest hierarchy in the tree.
379
+	 * The places are reversed compared to normal GEDCOM structure.
380
+	 * 
381
+	 * @return array
382
+	 */
383
+	protected function getPlacesHierarchyFromData() {
384
+		$nb_levels = 0;
385 385
         
386
-        //Select all '2 PLAC ' tags in the file and create array
387
-        $places_list=array();
388
-        $ged_data = Database::prepare(
389
-            'SELECT i_gedcom AS gedcom'.
390
-            ' FROM `##individuals`'.
391
-            ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
392
-            ' UNION ALL'.
393
-            'SELECT f_gedcom AS gedcom'.
394
-            ' FROM `##families`'.
395
-            ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
396
-        )->execute(array(
397
-            'gedcom' => '%\n2 PLAC %',
398
-            'gedcom_id' => $this->tree->getTreeId()            
399
-        ))->fetchOneColumn();
400
-        foreach ($ged_data as $ged_datum) {
401
-            $matches = null;
402
-            preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
403
-            foreach ($matches[1] as $match) {
404
-                $places_list[$match]=true;
405
-            }
406
-        }
386
+		//Select all '2 PLAC ' tags in the file and create array
387
+		$places_list=array();
388
+		$ged_data = Database::prepare(
389
+			'SELECT i_gedcom AS gedcom'.
390
+			' FROM `##individuals`'.
391
+			' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
392
+			' UNION ALL'.
393
+			'SELECT f_gedcom AS gedcom'.
394
+			' FROM `##families`'.
395
+			' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
396
+		)->execute(array(
397
+			'gedcom' => '%\n2 PLAC %',
398
+			'gedcom_id' => $this->tree->getTreeId()            
399
+		))->fetchOneColumn();
400
+		foreach ($ged_data as $ged_datum) {
401
+			$matches = null;
402
+			preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
403
+			foreach ($matches[1] as $match) {
404
+				$places_list[$match]=true;
405
+			}
406
+		}
407 407
         
408
-        // Unique list of places
409
-        $places_list=array_keys($places_list);
408
+		// Unique list of places
409
+		$places_list=array_keys($places_list);
410 410
         
411
-        //sort the array, limit to unique values, and count them
412
-        usort($places_list, array('I18N', 'strcasecmp'));
411
+		//sort the array, limit to unique values, and count them
412
+		usort($places_list, array('I18N', 'strcasecmp'));
413 413
         
414
-        //calculate maximum no. of levels to display
415
-        $has_found_good_example = false;
416
-        foreach($places_list as $place){
417
-            $levels = explode(",", $place);
418
-            $parts = count($levels);
419
-            if ($parts >= $nb_levels){
420
-                $nb_levels = $parts;
421
-                if(!$has_found_good_example){
422
-                    $random_place = $place;
423
-                    if(min(array_map('strlen', $levels)) > 0){
424
-                        $has_found_good_example = true;
425
-                    }
426
-                }
427
-            }
428
-        }
414
+		//calculate maximum no. of levels to display
415
+		$has_found_good_example = false;
416
+		foreach($places_list as $place){
417
+			$levels = explode(",", $place);
418
+			$parts = count($levels);
419
+			if ($parts >= $nb_levels){
420
+				$nb_levels = $parts;
421
+				if(!$has_found_good_example){
422
+					$random_place = $place;
423
+					if(min(array_map('strlen', $levels)) > 0){
424
+						$has_found_good_example = true;
425
+					}
426
+				}
427
+			}
428
+		}
429 429
         
430
-        return array_reverse(array_map('trim',explode(',', $random_place)));
431
-    }
430
+		return array_reverse(array_map('trim',explode(',', $random_place)));
431
+	}
432 432
     
433
-    /**
434
-     * Returns the list of geodispersion maps available within the maps folder.
435
-     * 
436
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
437
-     */
438
-    public function getOutlineMapsList() {
439
-        $res = array();
440
-        $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
441
-        if(is_dir($root_path)){
442
-            $dir = opendir($root_path);
443
-            while (($file=readdir($dir))!== false) {
444
-                if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
445
-                    $res[base64_encode($file)] = new OutlineMap($file, true);
446
-                }
447
-            }
448
-        }
449
-        return $res;
450
-    }
433
+	/**
434
+	 * Returns the list of geodispersion maps available within the maps folder.
435
+	 * 
436
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
437
+	 */
438
+	public function getOutlineMapsList() {
439
+		$res = array();
440
+		$root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
441
+		if(is_dir($root_path)){
442
+			$dir = opendir($root_path);
443
+			while (($file=readdir($dir))!== false) {
444
+				if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
445
+					$res[base64_encode($file)] = new OutlineMap($file, true);
446
+				}
447
+			}
448
+		}
449
+		return $res;
450
+	}
451 451
 }
452 452
  
453 453
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
         ->setUsingFlags($row['majgd_useflagsgen'] == 'yes')
66 66
         ->setMaxDetailsInGen($row['majgd_detailsgen']);
67 67
         
68
-        if($row['majgd_map']) {
68
+        if ($row['majgd_map']) {
69 69
             $options
70 70
             ->setMap(new OutlineMap($row['majgd_map']))
71 71
             ->setMapLevel($row['majgd_toplevel']);
72 72
         }
73 73
         
74 74
         $enabled = true;
75
-        if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
75
+        if (isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
76 76
             $enabled = false;
77 77
         }
78 78
         
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getGeoAnalysisCount() {
95 95
         return Database::prepare(
96
-            'SELECT COUNT(majgd_id)' .
97
-            ' FROM `##maj_geodispersion`' .
96
+            'SELECT COUNT(majgd_id)'.
97
+            ' FROM `##maj_geodispersion`'.
98 98
             ' WHERE majgd_file = :gedcom_id'
99 99
             )->execute(array(
100 100
                 'gedcom_id' => $this->tree->getTreeId()
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
      * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL
111 111
      */
112 112
     public function getGeoAnalysis($id, $only_enabled = true) {
113
-        $args = array (
113
+        $args = array(
114 114
             'gedcom_id' => $this->tree->getTreeId(),
115 115
             'ga_id' => $id
116 116
         );
117 117
         
118
-        $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
119
-            ' FROM `##maj_geodispersion`' .
118
+        $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'.
119
+            ' FROM `##maj_geodispersion`'.
120 120
             ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id';
121
-        if($only_enabled) {
121
+        if ($only_enabled) {
122 122
             $sql .= ' AND majgd_status = :status';
123 123
             $args['status'] = 'enabled';
124 124
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         
127 127
         $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
128 128
         
129
-        if($ga_array) {
129
+        if ($ga_array) {
130 130
             return $this->loadGeoAnalysisFromRow($ga_array);
131 131
         }
132 132
         
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * @return GeoAnalysis
147 147
      */
148 148
 	public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) {
149
-		try{
149
+		try {
150 150
 			Database::beginTransaction();
151 151
 		
152 152
 			Database::prepare(
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 			
169 169
 			Database::commit();
170 170
 		}
171
-		catch(\Exception $ex) {
171
+		catch (\Exception $ex) {
172 172
 			Database::rollback();
173 173
 			$ga = null;
174 174
 			Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage());
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 			
212 212
 			 Database::commit();
213 213
 		}
214
-		catch(\Exception $ex) {		    
214
+		catch (\Exception $ex) {		    
215 215
 			Database::rollback();
216
-			Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage());
216
+			Log::addErrorLog('The Geo Analysis ID “'.$ga->getId().'” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage());
217 217
 			$ga = null;
218 218
 		}
219 219
 		return $ga;
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
      *
259 259
      * @return array List of enabled maps
260 260
      */
261
-    public function getGeoAnalysisList(){
261
+    public function getGeoAnalysisList() {
262 262
         $res = array();
263 263
         
264 264
         $list = Database::prepare(
265
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' .
266
-            ' FROM `##maj_geodispersion`' .
265
+            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen'.
266
+            ' FROM `##maj_geodispersion`'.
267 267
             ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'.
268 268
             ' ORDER BY majgd_descr'
269 269
         )->execute(array(
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             'status' => 'enabled'
272 272
         ))->fetchAll(\PDO::FETCH_ASSOC);
273 273
         
274
-        foreach($list as $ga) {
274
+        foreach ($list as $ga) {
275 275
            $res[] = $this->loadGeoAnalysisFromRow($ga);
276 276
         }
277 277
         
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
      * @param int|null $limit Max number of items to return (for pagination)
288 288
      * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
289 289
      */
290
-    public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){
290
+    public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null) {
291 291
         $res = array();
292 292
             
293 293
         $sql = 
294
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
295
-            ' FROM `##maj_geodispersion`' .
294
+            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'.
295
+            ' FROM `##maj_geodispersion`'.
296 296
             ' WHERE majgd_file = :gedcom_id';
297 297
         
298 298
         $args = array('gedcom_id'=> $this->tree->getTreeId());
299 299
         
300
-        if($search) {
300
+        if ($search) {
301 301
             $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')';
302 302
             $args['search'] = $search;
303 303
         }
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
                 
312 312
                 switch ($value['dir']) {
313 313
                     case 'asc':
314
-                        $sql .= $value['column'] . ' ASC ';
314
+                        $sql .= $value['column'].' ASC ';
315 315
                         break;
316 316
                     case 'desc':
317
-                        $sql .= $value['column'] . ' DESC ';
317
+                        $sql .= $value['column'].' DESC ';
318 318
                         break;
319 319
                 }
320 320
             }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             
331 331
         $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
332 332
 
333
-        foreach($data as $ga) {
333
+        foreach ($data as $ga) {
334 334
             $res[] = $this->loadGeoAnalysisFromRow($ga);
335 335
         }
336 336
         
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
      * @return array
348 348
      */
349 349
     public function getPlacesHierarchy() {
350
-        if(!$this->place_hierarchy) {
351
-            if($place_structure = $this->getPlacesHierarchyFromHeader()) {
350
+        if (!$this->place_hierarchy) {
351
+            if ($place_structure = $this->getPlacesHierarchyFromHeader()) {
352 352
                 $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353 353
             }
354 354
             else {
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
     protected function getPlacesHierarchyFromHeader() {
368 368
         $head = GedcomRecord::getInstance('HEAD', $this->tree);
369 369
         $head_place = $head->getFirstFact('PLAC');
370
-        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
371
-            return array_reverse(array_map('trim',explode(',', $head_place_value)));
370
+        if ($head_place && $head_place_value = $head_place->getAttribute('FORM')) {
371
+            return array_reverse(array_map('trim', explode(',', $head_place_value)));
372 372
         }
373 373
         return null;
374 374
     }
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
         $nb_levels = 0;
385 385
         
386 386
         //Select all '2 PLAC ' tags in the file and create array
387
-        $places_list=array();
387
+        $places_list = array();
388 388
         $ged_data = Database::prepare(
389 389
             'SELECT i_gedcom AS gedcom'.
390 390
             ' FROM `##individuals`'.
@@ -401,33 +401,33 @@  discard block
 block discarded – undo
401 401
             $matches = null;
402 402
             preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
403 403
             foreach ($matches[1] as $match) {
404
-                $places_list[$match]=true;
404
+                $places_list[$match] = true;
405 405
             }
406 406
         }
407 407
         
408 408
         // Unique list of places
409
-        $places_list=array_keys($places_list);
409
+        $places_list = array_keys($places_list);
410 410
         
411 411
         //sort the array, limit to unique values, and count them
412 412
         usort($places_list, array('I18N', 'strcasecmp'));
413 413
         
414 414
         //calculate maximum no. of levels to display
415 415
         $has_found_good_example = false;
416
-        foreach($places_list as $place){
416
+        foreach ($places_list as $place) {
417 417
             $levels = explode(",", $place);
418 418
             $parts = count($levels);
419
-            if ($parts >= $nb_levels){
419
+            if ($parts >= $nb_levels) {
420 420
                 $nb_levels = $parts;
421
-                if(!$has_found_good_example){
421
+                if (!$has_found_good_example) {
422 422
                     $random_place = $place;
423
-                    if(min(array_map('strlen', $levels)) > 0){
423
+                    if (min(array_map('strlen', $levels)) > 0) {
424 424
                         $has_found_good_example = true;
425 425
                     }
426 426
                 }
427 427
             }
428 428
         }
429 429
         
430
-        return array_reverse(array_map('trim',explode(',', $random_place)));
430
+        return array_reverse(array_map('trim', explode(',', $random_place)));
431 431
     }
432 432
     
433 433
     /**
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
     public function getOutlineMapsList() {
439 439
         $res = array();
440 440
         $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
441
-        if(is_dir($root_path)){
441
+        if (is_dir($root_path)) {
442 442
             $dir = opendir($root_path);
443
-            while (($file=readdir($dir))!== false) {
443
+            while (($file = readdir($dir)) !== false) {
444 444
                 if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
445 445
                     $res[base64_encode($file)] = new OutlineMap($file, true);
446 446
                 }
Please login to merge, or discard this patch.