@@ -28,8 +28,8 @@ |
||
28 | 28 | ' majat_name VARCHAR(32) NOT NULL,'. |
29 | 29 | ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
30 | 30 | ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'.// 0 means error, 1 is success |
|
32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'.// In min, Default every week |
|
33 | 33 | ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
34 | 34 | ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
35 | 35 | ' PRIMARY KEY (majat_name)'. |
@@ -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 | } |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | <?php |
31 | 31 | /** @var \Fisharebest\Webtrees\Individual $root_indi */ |
32 | 32 | $root_indi = $this->data->get('root_indi'); |
33 | - if($root_indi !== null && $root_indi->canShowName()) { ?> |
|
33 | + if ($root_indi !== null && $root_indi->canShowName()) { ?> |
|
34 | 34 | <h4 class="center"><?= I18N::translate('%s: %s', I18N::translate('Root individual'), $root_indi->getFullName()); ?><h4> |
35 | 35 | <?php } ?> |
36 | 36 | |
37 | - <?php if($this->data->get('is_setup')) { |
|
37 | + <?php if ($this->data->get('is_setup')) { |
|
38 | 38 | $general_stats = $this->data->get('general_stats'); ?> |
39 | 39 | <h3><?php echo I18N::translate('General statistics'); ?></h3> |
40 | 40 | <div class="maj-table"> |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | </div> |
57 | 57 | <div class="maj-row"> |
58 | 58 | <div class="label"><?php echo I18N::translate('Mean generation time'); ?></div> |
59 | - <div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1)); ?></div> |
|
59 | + <div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1)); ?></div> |
|
60 | 60 | </div> |
61 | 61 | </div> |
62 | 62 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | </tr> |
97 | 97 | </thead> |
98 | 98 | <tbody> |
99 | - <?php foreach($this->data->get('generation_stats') as $gen => $row) { ?> |
|
99 | + <?php foreach ($this->data->get('generation_stats') as $gen => $row) { ?> |
|
100 | 100 | <tr class="maj-row"> |
101 | 101 | <td class="label"><?php echo I18N::translate('<strong>G%d</strong>', $gen); ?></td> |
102 | 102 | <td class="label"><?php echo I18N::translate('%1$s <> %2$s', $row['gen_min_birth'], $row['gen_max_birth']); ?></td> |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | <td class="value"><?php echo I18N::number($row['different']); ?></td> |
111 | 111 | <td class="value left percent_container"> |
112 | 112 | <div class="percent_frame"> |
113 | - <div class="percent_cell" style="width:<?php echo 100*$row['perc_different'] ?>%;"> |
|
113 | + <div class="percent_cell" style="width:<?php echo 100 * $row['perc_different'] ?>%;"> |
|
114 | 114 | <?php echo I18N::percentage($row['perc_different']); ?> |
115 | 115 | </div> |
116 | 116 | </div> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | <tfoot> |
124 | 124 | <tr class="maj-row"> |
125 | 125 | <td class="label" colspan="13"> |
126 | - <?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'),2)); ?> |
|
126 | + <?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'), 2)); ?> |
|
127 | 127 | </td> |
128 | 128 | </tr> |
129 | 129 | </tfoot> |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | |
133 | 133 | <h3><?php echo I18N::translate('Known Sosa ancestors\' family dispersion'); ?></h3> |
134 | 134 | <div class="center"> |
135 | - <?php echo $this->data->get('chart_img_g2') ?: '' ; ?> |
|
136 | - <?php echo $this->data->get('chart_img_g3') ?: '' ; ?> |
|
135 | + <?php echo $this->data->get('chart_img_g2') ?: ''; ?> |
|
136 | + <?php echo $this->data->get('chart_img_g3') ?: ''; ?> |
|
137 | 137 | <!-- <canvas id="chart_ancestors_g2" width="300" height="300"></canvas> --> |
138 | 138 | </div> |
139 | 139 |
@@ -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); |
@@ -145,15 +145,15 @@ discard block |
||
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(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
153 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(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 |
||
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(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
176 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | public function handle(fw\Module\AbstractModule $module, $request) { |
50 | 50 | |
51 | 51 | $fq_modclass_name = get_class($module); |
52 | - $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
|
52 | + $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\'; |
|
53 | 53 | |
54 | - $args = explode( '@', $request, 2); |
|
55 | - switch(count($args)) { |
|
54 | + $args = explode('@', $request, 2); |
|
55 | + switch (count($args)) { |
|
56 | 56 | case 1: |
57 | 57 | $ctrl_name = $args[0]; |
58 | 58 | $method = 'index'; |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | - $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
|
68 | - if(class_exists($ctrl_class) |
|
67 | + $ctrl_class = $ctrl_namespace.$ctrl_name.'Controller'; |
|
68 | + if (class_exists($ctrl_class) |
|
69 | 69 | && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
70 | - && $ctrl = new $ctrl_class($module) ) { |
|
71 | - if(method_exists($ctrl, $method)) { |
|
70 | + && $ctrl = new $ctrl_class($module)) { |
|
71 | + if (method_exists($ctrl, $method)) { |
|
72 | 72 | try { |
73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
74 | 74 | } |
75 | 75 | catch (MvcException $ex) { |
76 | - if(!headers_sent()) { |
|
76 | + if (!headers_sent()) { |
|
77 | 77 | http_response_code($ex->getHttpCode()); |
78 | 78 | } |
79 | 79 | echo $ex->getMessage(); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | class MvcException extends \Exception { |
18 | 18 | |
19 | 19 | /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
20 | - protected static $VALID_HTTP = array( |
|
20 | + protected static $VALID_HTTP = array( |
|
21 | 21 | 100, 101, |
22 | 22 | 200, 201, 202, 203, 204, 205, 206, |
23 | 23 | 300, 301, 302, 303, 304, 305, 306, 307, |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @throws InvalidArgumentException Thrown if not valid Http code |
59 | 59 | */ |
60 | 60 | public function setHttpCode($http_code) { |
61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
61 | + if (!in_array($http_code, self::$VALID_HTTP)) |
|
62 | 62 | throw new \InvalidArgumentException('Invalid HTTP code'); |
63 | - $this->http_code= $http_code; |
|
63 | + $this->http_code = $http_code; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getProviderPlaceId() |
26 | 26 | */ |
27 | 27 | public function getProviderPlaceId(\Fisharebest\Webtrees\Place $place) { |
28 | - if(!$place->isEmpty()) { |
|
29 | - $parent = array_reverse(explode (',', $place->getGedcomName())); |
|
28 | + if (!$place->isEmpty()) { |
|
29 | + $parent = array_reverse(explode(',', $place->getGedcomName())); |
|
30 | 30 | $place_id = 0; |
31 | 31 | $nb_levels = count($parent); |
32 | - for ($i=0; $i < $nb_levels; $i++) { |
|
32 | + for ($i = 0; $i < $nb_levels; $i++) { |
|
33 | 33 | $parent[$i] = trim($parent[$i]); |
34 | - if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | - $pl_id=Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
34 | + if (empty($parent[$i])) $parent[$i] = 'unknown'; // GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | + $pl_id = Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
36 | 36 | ->execute(array($i, $place_id, $parent[$i])) |
37 | 37 | ->fetchOne(); |
38 | 38 | if (empty($pl_id)) break; |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getPlaceIcon() |
49 | 49 | */ |
50 | 50 | public function getPlaceIcon(\Fisharebest\Webtrees\Place $place) { |
51 | - if(!$place->isEmpty()){ |
|
51 | + if (!$place->isEmpty()) { |
|
52 | 52 | $place_details = |
53 | 53 | Database::prepare('SELECT SQL_CACHE pl_icon FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place') |
54 | 54 | ->execute(array($this->getProviderPlaceId($place))) |
55 | 55 | ->fetchOneRow(); |
56 | - if($place_details){ |
|
56 | + if ($place_details) { |
|
57 | 57 | return WT_MODULES_DIR.'googlemap/'.$place_details->pl_icon; |
58 | 58 | } |
59 | 59 | } |
@@ -47,13 +47,13 @@ |
||
47 | 47 | <div class="value"> |
48 | 48 | <?php |
49 | 49 | $users = $this->data->get('users_settings'); |
50 | - if(count($users) == 1) { |
|
51 | - $root_indi = $users[0]['rootid']; ?> |
|
50 | + if (count($users) == 1) { |
|
51 | + $root_indi = $users[0]['rootid']; ?> |
|
52 | 52 | <label> |
53 | 53 | <input id="maj_sosa_input_userid" type="hidden" name="userid" value="<?php echo $users[0]['user']->getUserId(); ?>" /> |
54 | 54 | <?php echo $users[0]['user']->getRealNameHtml() ?> |
55 | 55 | </label> |
56 | - <?php } else if(count($users) > 1) { ?> |
|
56 | + <?php } else if (count($users) > 1) { ?> |
|
57 | 57 | <select id='maj-sosa-config-select' name="userid"> |
58 | 58 | <?php |
59 | 59 | $root_indi = $users[0]['rootid']; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getPossibleHooks() |
72 | 72 | */ |
73 | 73 | public function getPossibleHooks() { |
74 | - static $hooks=null; |
|
74 | + static $hooks = null; |
|
75 | 75 | if ($hooks === null) { |
76 | 76 | $hooks = array(); |
77 | 77 | |
@@ -83,31 +83,31 @@ discard block |
||
83 | 83 | 'SELECT SQL_CACHE module_name FROM `##module`' |
84 | 84 | )->fetchOneColumn(); |
85 | 85 | |
86 | - foreach($module_names as $module_name) { |
|
86 | + foreach ($module_names as $module_name) { |
|
87 | 87 | $module = Module::getModuleByName($module_name); |
88 | 88 | |
89 | - if($module instanceof HookSubscriberInterface){ |
|
89 | + if ($module instanceof HookSubscriberInterface) { |
|
90 | 90 | $subscribedhooks = $module->getSubscribedHooks(); |
91 | - if(is_array($subscribedhooks)){ |
|
92 | - foreach($subscribedhooks as $key => $value){ |
|
93 | - if(is_int($key)) { |
|
91 | + if (is_array($subscribedhooks)) { |
|
92 | + foreach ($subscribedhooks as $key => $value) { |
|
93 | + if (is_int($key)) { |
|
94 | 94 | $hook_item = $value; |
95 | 95 | $priority = self::DEFAULT_PRIORITY; |
96 | 96 | } |
97 | - else{ |
|
97 | + else { |
|
98 | 98 | $hook_item = explode('#', $key, 2); |
99 | 99 | $priority = $value; |
100 | 100 | } |
101 | - if($hook_item && count($hook_item) == 2){ |
|
101 | + if ($hook_item && count($hook_item) == 2) { |
|
102 | 102 | $hook_func = $hook_item[0]; |
103 | 103 | $hook_cont = $hook_item[1]; |
104 | 104 | } |
105 | - else{ |
|
105 | + else { |
|
106 | 106 | $hook_func = $hook_item[0]; |
107 | 107 | $hook_cont = 'all'; |
108 | 108 | } |
109 | - if(method_exists($module, $hook_func)){ |
|
110 | - $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont]=$priority; |
|
109 | + if (method_exists($module, $hook_func)) { |
|
110 | + $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont] = $priority; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * {@inheritDoc} |
122 | 122 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getRawInstalledHooks() |
123 | 123 | */ |
124 | - public function getRawInstalledHooks(){ |
|
125 | - if(self::isModuleOperational()){ |
|
124 | + public function getRawInstalledHooks() { |
|
125 | + if (self::isModuleOperational()) { |
|
126 | 126 | return Database::prepare( |
127 | 127 | "SELECT majh_id AS id, majh_module_name AS module, majh_hook_function AS hook, majh_hook_context as context, majh_module_priority AS priority, majh_status AS status". |
128 | 128 | " FROM `##maj_hooks`". |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * {@inheritDoc} |
137 | 137 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getInstalledHooks() |
138 | 138 | */ |
139 | - public function getInstalledHooks(){ |
|
140 | - static $installedhooks =null; |
|
141 | - if($installedhooks===null){ |
|
142 | - $dbhooks=self::getRawInstalledHooks(); |
|
143 | - foreach($dbhooks as $dbhook){ |
|
139 | + public function getInstalledHooks() { |
|
140 | + static $installedhooks = null; |
|
141 | + if ($installedhooks === null) { |
|
142 | + $dbhooks = self::getRawInstalledHooks(); |
|
143 | + foreach ($dbhooks as $dbhook) { |
|
144 | 144 | $installedhooks[($dbhook->module).'#'.($dbhook->hook).'#'.($dbhook->context)] = array('id' => $dbhook->id, 'status' => $dbhook->status, 'priority' => $dbhook->priority); |
145 | 145 | } |
146 | 146 | } |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function updateHooks() { |
155 | 155 | |
156 | - if(Auth::isAdmin()){ |
|
156 | + if (Auth::isAdmin()) { |
|
157 | 157 | $ihooks = self::getInstalledHooks(); |
158 | 158 | $phooks = self::getPossibleHooks(); |
159 | 159 | |
160 | 160 | // Insert hooks not existing yet in the DB |
161 | - if($phooks !== null){ |
|
162 | - foreach($phooks as $phook => $priority){ |
|
161 | + if ($phooks !== null) { |
|
162 | + foreach ($phooks as $phook => $priority) { |
|
163 | 163 | $array_hook = explode('#', $phook); |
164 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
164 | + if ($ihooks === null || !array_key_exists($phook, $ihooks)) { |
|
165 | 165 | $chook = new Hook($array_hook[1], $array_hook[2]); |
166 | 166 | $chook->subscribe($array_hook[0]); |
167 | 167 | $chook->setPriority($array_hook[0], $priority); |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | //Remove hooks not existing any more in the file system |
173 | - if($ihooks !== null){ |
|
174 | - foreach(array_keys($ihooks) as $ihook){ |
|
173 | + if ($ihooks !== null) { |
|
174 | + foreach (array_keys($ihooks) as $ihook) { |
|
175 | 175 | $array_hook = explode('#', $ihook); |
176 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
176 | + if ($phooks === null || !array_key_exists($ihook, $phooks)) { |
|
177 | 177 | $chook = new Hook($array_hook[1], $array_hook[2]); |
178 | 178 | $chook->remove($array_hook[0]); |
179 | 179 | } |