@@ -65,14 +65,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -38,9 +38,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | * @param string $data Text to encrypt |
137 | 137 | * @return string Encrypted and encoded text |
138 | 138 | */ |
139 | - public static function encryptToSafeBase64($data){ |
|
139 | + public static function encryptToSafeBase64($data) { |
|
140 | 140 | $key = 'STANDARDKEYIFNOSERVER'; |
141 | - if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) |
|
141 | + if (Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) |
|
142 | 142 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
143 | 143 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
144 | - $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
|
144 | + $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); |
|
145 | 145 | $encrypted = base64_encode($iv.$id); |
146 | 146 | // +, / and = are not URL-compatible |
147 | 147 | $encrypted = str_replace('+', '-', $encrypted); |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | * @param string $encrypted Text to decrypt |
157 | 157 | * @return string Decrypted text |
158 | 158 | */ |
159 | - public static function decryptFromSafeBase64($encrypted){ |
|
159 | + public static function decryptFromSafeBase64($encrypted) { |
|
160 | 160 | $key = 'STANDARDKEYIFNOSERVER'; |
161 | - if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) |
|
161 | + if (Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) |
|
162 | 162 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
163 | 163 | $encrypted = str_replace('-', '+', $encrypted); |
164 | 164 | $encrypted = str_replace('_', '/', $encrypted); |
165 | 165 | $encrypted = str_replace('*', '=', $encrypted); |
166 | 166 | $encrypted = base64_decode($encrypted); |
167 | - if(!$encrypted) |
|
167 | + if (!$encrypted) |
|
168 | 168 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
169 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
169 | + if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
170 | 170 | throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
171 | 171 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
172 | 172 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
173 | 173 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
174 | - return preg_replace('~(?:\\000+)$~','',$decrypted); |
|
174 | + return preg_replace('~(?:\\000+)$~', '', $decrypted); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param string $string Filesystem encoded string to encode |
181 | 181 | * @return string UTF-8 encoded string |
182 | 182 | */ |
183 | - public static function encodeFileSystemToUtf8($string){ |
|
183 | + public static function encodeFileSystemToUtf8($string) { |
|
184 | 184 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
185 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
185 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
186 | 186 | } |
187 | 187 | return $string; |
188 | 188 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @param string $string UTF-8 encoded string to encode |
194 | 194 | * @return string Filesystem encoded string |
195 | 195 | */ |
196 | - public static function encodeUtf8ToFileSystem($string){ |
|
196 | + public static function encodeUtf8ToFileSystem($string) { |
|
197 | 197 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
198 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
198 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
199 | 199 | } |
200 | 200 | return $string; |
201 | 201 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @return boolean True if path valid |
209 | 209 | */ |
210 | 210 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
211 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
211 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return array Array of month short names |
221 | 221 | */ |
222 | 222 | public static function getCalendarShortMonths($calendarId = 0) { |
223 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
223 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
224 | 224 | $calendar_info = cal_info($calendarId); |
225 | 225 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
226 | 226 | } |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param int $sosa Sosa number |
234 | 234 | * @return number |
235 | 235 | */ |
236 | - public static function getGeneration($sosa){ |
|
237 | - return(int)log($sosa, 2)+1; |
|
236 | + public static function getGeneration($sosa) { |
|
237 | + return(int)log($sosa, 2) + 1; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 |