@@ -94,14 +94,15 @@ discard block |
||
94 | 94 | $this->provider->setTaskStatus($task, $status); |
95 | 95 | $res['status'] = $status; |
96 | 96 | Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
97 | - } |
|
98 | - catch (\Exception $ex) { |
|
97 | + } catch (\Exception $ex) { |
|
99 | 98 | $res['error'] = $ex->getMessage(); |
100 | 99 | Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
101 | 100 | } |
102 | 101 | |
103 | 102 | $controller->pageHeader(); |
104 | - if($res['error']) http_response_code(500); |
|
103 | + if($res['error']) { |
|
104 | + http_response_code(500); |
|
105 | + } |
|
105 | 106 | |
106 | 107 | $controller->encode($res); |
107 | 108 | } |
@@ -169,8 +170,7 @@ discard block |
||
169 | 170 | $task->setFrequency($frequency); |
170 | 171 | if($is_limited == 1) { |
171 | 172 | $task->setRemainingOccurrences($nb_occur); |
172 | - } |
|
173 | - else { |
|
173 | + } else { |
|
174 | 174 | $task->setRemainingOccurrences(0); |
175 | 175 | } |
176 | 176 | |
@@ -191,8 +191,7 @@ discard block |
||
191 | 191 | Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName() .'” has been updated.'); |
192 | 192 | $success = true; |
193 | 193 | } |
194 | - } |
|
195 | - else { |
|
194 | + } else { |
|
196 | 195 | FlashMessages::addMessage(I18N::translate('An error occured while updating the administrative task “%s”', $task->getTitle()), 'danger'); |
197 | 196 | Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.'); |
198 | 197 | } |
@@ -235,7 +235,9 @@ discard block |
||
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) { |
|
239 | + throw new \Exception('The task has not been initialised with a provider.'); |
|
240 | + } |
|
239 | 241 | return $this->provider->updateTask($this); |
240 | 242 | } |
241 | 243 | |
@@ -245,8 +247,9 @@ discard block |
||
245 | 247 | */ |
246 | 248 | public function execute(){ |
247 | 249 | |
248 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
249 | - $this->is_running = false; |
|
250 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) { |
|
251 | + $this->is_running = false; |
|
252 | + } |
|
250 | 253 | |
251 | 254 | if(!$this->is_running){ |
252 | 255 | $this->last_result = false; |
@@ -259,7 +262,9 @@ discard block |
||
259 | 262 | $this->last_updated = new \DateTime(); |
260 | 263 | if($this->nb_occurrences > 0){ |
261 | 264 | $this->nb_occurrences--; |
262 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
265 | + if($this->nb_occurrences == 0) { |
|
266 | + $this->is_enabled = false; |
|
267 | + } |
|
263 | 268 | } |
264 | 269 | } |
265 | 270 | $this->is_running = false; |
@@ -167,8 +167,7 @@ discard block |
||
167 | 167 | $ga = $this->getGeoAnalysis($id, false); |
168 | 168 | |
169 | 169 | 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 |
||
210 | 209 | $ga = $this->getGeoAnalysis($ga->getId(), false); |
211 | 210 | |
212 | 211 | 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 |
||
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 | } |
@@ -145,14 +145,15 @@ discard block |
||
145 | 145 | $this->provider->setGeoAnalysisStatus($ga, $status); |
146 | 146 | $res['status'] = $status; |
147 | 147 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
148 | - } |
|
149 | - catch (\Exception $ex) { |
|
148 | + } catch (\Exception $ex) { |
|
150 | 149 | $res['error'] = $ex->getMessage(); |
151 | 150 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
152 | 151 | } |
153 | 152 | |
154 | 153 | $controller->pageHeader(); |
155 | - if($res['error']) http_response_code(500); |
|
154 | + if($res['error']) { |
|
155 | + http_response_code(500); |
|
156 | + } |
|
156 | 157 | |
157 | 158 | $controller->encode($res); |
158 | 159 | } |
@@ -178,14 +179,15 @@ discard block |
||
178 | 179 | try{ |
179 | 180 | $this->provider->deleteGeoAnalysis($ga); |
180 | 181 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
181 | - } |
|
182 | - catch (\Exception $ex) { |
|
182 | + } catch (\Exception $ex) { |
|
183 | 183 | $res['error'] = $ex->getMessage(); |
184 | 184 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
185 | 185 | } |
186 | 186 | |
187 | 187 | $controller->pageHeader(); |
188 | - if($res['error']) http_response_code(500); |
|
188 | + if($res['error']) { |
|
189 | + http_response_code(500); |
|
190 | + } |
|
189 | 191 | |
190 | 192 | $controller->encode($res); |
191 | 193 | } |
@@ -240,7 +242,9 @@ discard block |
||
240 | 242 | |
241 | 243 | $nb_found = $placesGeneralResults['knownsum']; |
242 | 244 | $nb_other = 0; |
243 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
245 | + if(isset($placesGeneralResults['other'])) { |
|
246 | + $nb_other =$placesGeneralResults['other']; |
|
247 | + } |
|
244 | 248 | $nb_unknown = $placesGeneralResults['unknown']; |
245 | 249 | |
246 | 250 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -260,11 +264,12 @@ discard block |
||
260 | 264 | if($level_map >= 0 && $level_map < count($levelvalues)) { |
261 | 265 | $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
262 | 266 | if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
263 | - } |
|
264 | - else { |
|
267 | + } else { |
|
265 | 268 | $levelref = $levelvalues[0]; |
266 | 269 | } |
267 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
270 | + if(isset($places_mappings[$levelref])) { |
|
271 | + $levelref = $places_mappings[$levelref]; |
|
272 | + } |
|
268 | 273 | if(isset($results_by_subdivs[$levelref])) { |
269 | 274 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
270 | 275 | $count_subd += $count; |
@@ -281,8 +286,7 @@ discard block |
||
281 | 286 | $data->set('results_by_subdivisions', $results_by_subdivs); |
282 | 287 | |
283 | 288 | $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
284 | - } |
|
285 | - else { |
|
289 | + } else { |
|
286 | 290 | $results = $placesGeneralResults['places']; |
287 | 291 | arsort($results); |
288 | 292 | $data->set('results', $results); |
@@ -290,8 +294,7 @@ discard block |
||
290 | 294 | |
291 | 295 | $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
292 | 296 | } |
293 | - } |
|
294 | - else { |
|
297 | + } else { |
|
295 | 298 | $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
296 | 299 | } |
297 | 300 | return $html; |
@@ -325,9 +328,15 @@ discard block |
||
325 | 328 | $sum = 0; |
326 | 329 | $other = 0; |
327 | 330 | $unknown = 0; |
328 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
329 | - if(isset($genData['other'])) $other = $genData['other']; |
|
330 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
331 | + if(isset($genData['sum'])) { |
|
332 | + $sum = $genData['sum']; |
|
333 | + } |
|
334 | + if(isset($genData['other'])) { |
|
335 | + $other = $genData['other']; |
|
336 | + } |
|
337 | + if(isset($genData['unknown'])) { |
|
338 | + $unknown = $genData['unknown']; |
|
339 | + } |
|
331 | 340 | |
332 | 341 | if($sum > 0) { |
333 | 342 | $results_by_gen[$gen]['sum'] = $sum; |
@@ -345,8 +354,7 @@ discard block |
||
345 | 354 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
346 | 355 | } |
347 | 356 | } |
348 | - } |
|
349 | - else { |
|
357 | + } else { |
|
350 | 358 | $tmp = $genData['places']; |
351 | 359 | if($other > 0) { |
352 | 360 | $tmp = array_slice($tmp, 0, 5, true); |
@@ -362,8 +370,7 @@ discard block |
||
362 | 370 | |
363 | 371 | $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
364 | 372 | |
365 | - } |
|
366 | - else { |
|
373 | + } else { |
|
367 | 374 | $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
368 | 375 | } |
369 | 376 | return $html; |
@@ -31,11 +31,16 @@ |
||
31 | 31 | $nb_levels = count($parent); |
32 | 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 , , |
|
34 | + if (empty($parent[$i])) { |
|
35 | + $parent[$i]='unknown'; |
|
36 | + } |
|
37 | + // GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | 38 | $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 | 39 | ->execute(array($i, $place_id, $parent[$i])) |
37 | 40 | ->fetchOne(); |
38 | - if (empty($pl_id)) break; |
|
41 | + if (empty($pl_id)) { |
|
42 | + break; |
|
43 | + } |
|
39 | 44 | $place_id = $pl_id; |
40 | 45 | } |
41 | 46 | return $place_id; |
@@ -65,8 +65,9 @@ discard block |
||
65 | 65 | public function hExtendIndiHeaderIcons(IndividualController $ctrlIndi) { |
66 | 66 | if($ctrlIndi){ |
67 | 67 | $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
68 | - if ($dindi->canDisplayIsSourced()) |
|
69 | - return FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, 'large'); |
|
68 | + if ($dindi->canDisplayIsSourced()) { |
|
69 | + return FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, 'large'); |
|
70 | + } |
|
70 | 71 | } |
71 | 72 | return ''; |
72 | 73 | } |
@@ -99,8 +100,9 @@ discard block |
||
99 | 100 | $dindi = new Individual($grec); |
100 | 101 | $html .= FunctionsPrint::formatIsSourcedIcon('R', $dindi->isSourced(), 'INDI', 1, $size); |
101 | 102 | $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isBirthSourced(), 'BIRT', 1, $size); |
102 | - if($grec->isDead()) |
|
103 | - $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1, $size); |
|
103 | + if($grec->isDead()) { |
|
104 | + $html .= FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1, $size); |
|
105 | + } |
|
104 | 106 | } |
105 | 107 | return $html; |
106 | 108 | } |
@@ -173,12 +175,13 @@ discard block |
||
173 | 175 | </tr>'; |
174 | 176 | } |
175 | 177 | |
176 | - if( $root->isDead() ) |
|
177 | - echo ' |
|
178 | + if( $root->isDead() ) { |
|
179 | + echo ' |
|
178 | 180 | <tr> |
179 | 181 | <td class="slabel">' . GedcomTag::getLabel('DEAT') . '</td> |
180 | 182 | <td class="svalue">' . FunctionsPrint::formatIsSourcedIcon('E', $dindi->isDeathSourced(), 'DEAT', 1).'</td> |
181 | 183 | </tr>'; |
184 | + } |
|
182 | 185 | |
183 | 186 | echo '</table>'; |
184 | 187 | } |
@@ -45,7 +45,9 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if(!$this->ctrl) { |
|
49 | + throw new \Exception('Controller not initialised'); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | $controller = $this->ctrl; |
51 | 53 | $this->ctrl->pageHeader(); |
@@ -86,9 +86,12 @@ discard block |
||
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | 88 | public function canDisplayIsSourced($access_level = null){ |
89 | - if(!$this->gedcomrecord->canShow($access_level)) return false; |
|
90 | - if($access_level === null ) |
|
91 | - $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
89 | + if(!$this->gedcomrecord->canShow($access_level)) { |
|
90 | + return false; |
|
91 | + } |
|
92 | + if($access_level === null ) { |
|
93 | + $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
94 | + } |
|
92 | 95 | |
93 | 96 | $global_facts = Globals::getGlobalFacts(); |
94 | 97 | if (isset($global_facts['SOUR'])) { |
@@ -108,7 +111,9 @@ discard block |
||
108 | 111 | * @return int Level of sources |
109 | 112 | */ |
110 | 113 | public function isSourced(){ |
111 | - if($this->_issourced !== null) return $this->_issourced; |
|
114 | + if($this->_issourced !== null) { |
|
115 | + return $this->_issourced; |
|
116 | + } |
|
112 | 117 | $this->_issourced=-1; |
113 | 118 | $sourcesfacts = $this->gedcomrecord->getFacts('SOUR'); |
114 | 119 | foreach($sourcesfacts as $sourcefact){ |
@@ -127,7 +132,9 @@ discard block |
||
127 | 132 | * @return int Level of sources |
128 | 133 | */ |
129 | 134 | public function isFactSourced($eventslist){ |
130 | - if(empty($eventslist)) return 0; |
|
135 | + if(empty($eventslist)) { |
|
136 | + return 0; |
|
137 | + } |
|
131 | 138 | $isSourced=0; |
132 | 139 | $facts = $this->gedcomrecord->getFacts($eventslist); |
133 | 140 | foreach($facts as $fact){ |
@@ -137,8 +144,7 @@ discard block |
||
137 | 144 | if($tmpIsSourced != 0) { |
138 | 145 | if($isSourced==0) { |
139 | 146 | $isSourced = $tmpIsSourced; |
140 | - } |
|
141 | - else{ |
|
147 | + } else{ |
|
142 | 148 | $isSourced = max($isSourced, $tmpIsSourced); |
143 | 149 | } |
144 | 150 | } |
@@ -78,7 +78,9 @@ discard block |
||
78 | 78 | |
79 | 79 | $other_trees = array(); |
80 | 80 | foreach (Tree::getAll() as $tree) { |
81 | - if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
81 | + if($tree->getTreeId() != $wt_tree->getTreeId()) { |
|
82 | + $other_trees[] = $tree; |
|
83 | + } |
|
82 | 84 | } |
83 | 85 | $data->set('other_trees', $other_trees); |
84 | 86 | |
@@ -177,7 +179,9 @@ discard block |
||
177 | 179 | |
178 | 180 | // Generate an AJAX/JSON response for datatables to load a block of rows |
179 | 181 | $search = Filter::postArray('search'); |
180 | - if($search) $search = $search['value']; |
|
182 | + if($search) { |
|
183 | + $search = $search['value']; |
|
184 | + } |
|
181 | 185 | $start = Filter::postInteger('start'); |
182 | 186 | $length = Filter::postInteger('length'); |
183 | 187 | $order = Filter::postArray('order'); |
@@ -330,8 +334,7 @@ discard block |
||
330 | 334 | if($use_map) { |
331 | 335 | $options->setMap(new OutlineMap($map_file)); |
332 | 336 | $options->setMapLevel($map_top_level + 1); |
333 | - } |
|
334 | - else { |
|
337 | + } else { |
|
335 | 338 | $options->setMap(null); |
336 | 339 | } |
337 | 340 | } |
@@ -342,8 +345,7 @@ discard block |
||
342 | 345 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
343 | 346 | $ga = $res; |
344 | 347 | $success = true; |
345 | - } |
|
346 | - else { |
|
348 | + } else { |
|
347 | 349 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
348 | 350 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
349 | 351 | } |
@@ -361,8 +363,7 @@ discard block |
||
361 | 363 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
362 | 364 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
363 | 365 | $success = true; |
364 | - } |
|
365 | - else { |
|
366 | + } else { |
|
366 | 367 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
367 | 368 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
368 | 369 | } |
@@ -372,8 +373,7 @@ discard block |
||
372 | 373 | if(!$success) { |
373 | 374 | if($ga) { |
374 | 375 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
375 | - } |
|
376 | - else { |
|
376 | + } else { |
|
377 | 377 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
378 | 378 | } |
379 | 379 | } |
@@ -430,7 +430,9 @@ discard block |
||
430 | 430 | $data->set('map_list', $map_list); |
431 | 431 | |
432 | 432 | $gen_details = array(0 => I18N::translate('All')); |
433 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
433 | + for($i = 1; $i <= 10 ; $i++) { |
|
434 | + $gen_details[$i] = $i; |
|
435 | + } |
|
434 | 436 | $data->set('generation_details', $gen_details); |
435 | 437 | |
436 | 438 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |