@@ -115,7 +115,9 @@ discard block |
||
115 | 115 | $sid=null; |
116 | 116 | |
117 | 117 | if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($wt_tree)){ |
118 | - if (!$srec || strlen($srec) == 0) return $html; |
|
118 | + if (!$srec || strlen($srec) == 0) { |
|
119 | + return $html; |
|
120 | + } |
|
119 | 121 | |
120 | 122 | $certificate = null; |
121 | 123 | $subrecords = explode("\n", $srec); |
@@ -129,11 +131,14 @@ discard block |
||
129 | 131 | $subrecords[$i] = trim($subrecords[$i]); |
130 | 132 | $tag = substr($subrecords[$i], 2, 4); |
131 | 133 | $text = substr($subrecords[$i], 7); |
132 | - if($tag == '_ACT') $certificate= new Certificate($text, $wt_tree, $this->getProvider()); |
|
134 | + if($tag == '_ACT') { |
|
135 | + $certificate= new Certificate($text, $wt_tree, $this->getProvider()); |
|
136 | + } |
|
133 | 137 | } |
134 | 138 | |
135 | - if($certificate && $certificate->canShow()) |
|
136 | - $html = $this->getDisplay_ACT($certificate, $sid); |
|
139 | + if($certificate && $certificate->canShow()) { |
|
140 | + $html = $this->getDisplay_ACT($certificate, $sid); |
|
141 | + } |
|
137 | 142 | |
138 | 143 | } |
139 | 144 | return $html; |
@@ -161,7 +166,9 @@ discard block |
||
161 | 166 | $html = ''; |
162 | 167 | switch($tag){ |
163 | 168 | case '_ACT': |
164 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
169 | + if($context == 'SOUR') { |
|
170 | + $html = $this->getDisplay_ACT($value, $contextid); |
|
171 | + } |
|
165 | 172 | break; |
166 | 173 | } |
167 | 174 | return $html; |
@@ -189,7 +196,9 @@ discard block |
||
189 | 196 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
190 | 197 | foreach ($tabCities as $cities){ |
191 | 198 | $selectedCity=''; |
192 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
199 | + if($certificate && $cities== $certificate->getCity()) { |
|
200 | + $selectedCity='selected="true"'; |
|
201 | + } |
|
193 | 202 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
194 | 203 | } |
195 | 204 | $html .= '</select>'; |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | $array_hook = explode('#', $ihook); |
48 | 48 | //Update status |
49 | 49 | $new_status= Filter::postBool('status-' . $params['id']); |
50 | - if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
50 | + if(in_array($array_hook[0], $module_names)) { |
|
51 | + $new_status = false; |
|
52 | + } |
|
51 | 53 | $previous_status = $params['status']; |
52 | 54 | if ($new_status !== null) { |
53 | 55 | $new_status= $new_status ? 'enabled' : 'disabled'; |
@@ -92,7 +94,9 @@ discard block |
||
92 | 94 | HookProvider::getInstance()->updateHooks(); |
93 | 95 | |
94 | 96 | $action = Filter::post('action'); |
95 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
97 | + if($action == 'update' && Filter::checkCsrf()) { |
|
98 | + $this->update(); |
|
99 | + } |
|
96 | 100 | |
97 | 101 | Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
98 | 102 | $ctrl = new PageController(); |
@@ -160,7 +160,9 @@ discard block |
||
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 |
||
174 | 176 | $html .= ' <span><small><em>'.$dindi->formatFirstMajorFact(WT_EVENTS_BIRT, 10).'</em></small></span>'; |
175 | 177 | $html .= ' <span><small><em>'.$dindi->formatFirstMajorFact(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; |
@@ -193,8 +194,7 @@ discard block |
||
193 | 194 | $date = $fact->getDate(); |
194 | 195 | if($date->isOK()){ |
195 | 196 | $html.=' '.$date->Display($anchor && !Globals::isSearchSpider(), '%Y'); |
196 | - } |
|
197 | - else{ |
|
197 | + } else{ |
|
198 | 198 | // 1 DEAT Y with no DATE => print YES |
199 | 199 | // 1 BIRT 2 SOUR @S1@ => print YES |
200 | 200 | // 1 DEAT N is not allowed |
@@ -218,7 +218,9 @@ discard block |
||
218 | 218 | public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
219 | 219 | $html=''; |
220 | 220 | |
221 | - if ($fact === null) return $html; |
|
221 | + if ($fact === null) { |
|
222 | + return $html; |
|
223 | + } |
|
222 | 224 | $place = $fact->getPlace(); |
223 | 225 | if($place){ |
224 | 226 | $dplace = new Place($place); |
@@ -336,7 +338,9 @@ discard block |
||
336 | 338 | default: |
337 | 339 | break; |
338 | 340 | } |
339 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
341 | + if($image && $title) { |
|
342 | + $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
343 | + } |
|
340 | 344 | break; |
341 | 345 | default: |
342 | 346 | break; |
@@ -108,16 +108,18 @@ discard block |
||
108 | 108 | $len_chars = count($chars); |
109 | 109 | $token = ''; |
110 | 110 | |
111 | - for ($i = 0; $i < $length; $i++) |
|
112 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
111 | + for ($i = 0; $i < $length; $i++) { |
|
112 | + $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
113 | + } |
|
113 | 114 | |
114 | 115 | # Number of 32 char chunks |
115 | 116 | $chunks = ceil( strlen($token) / 32 ); |
116 | 117 | $md5token = ''; |
117 | 118 | |
118 | 119 | # Run each chunk through md5 |
119 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
120 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
120 | + for ( $i=1; $i<=$chunks; $i++ ) { |
|
121 | + $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
122 | + } |
|
121 | 123 | |
122 | 124 | # Trim the token |
123 | 125 | return substr($md5token, 0, $length); |
@@ -130,8 +132,9 @@ discard block |
||
130 | 132 | */ |
131 | 133 | protected static function getBase64EncryptionKey() { |
132 | 134 | $key = 'STANDARDKEYIFNOSERVER'; |
133 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
134 | - $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
135 | + if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) { |
|
136 | + $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
137 | + } |
|
135 | 138 | |
136 | 139 | return $key; |
137 | 140 | } |
@@ -168,11 +171,13 @@ discard block |
||
168 | 171 | $encrypted = str_replace('_', '/', $encrypted); |
169 | 172 | $encrypted = str_replace('*', '=', $encrypted); |
170 | 173 | $encrypted = base64_decode($encrypted); |
171 | - if($encrypted === false) |
|
172 | - throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
174 | + if($encrypted === false) { |
|
175 | + throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
176 | + } |
|
173 | 177 | |
174 | - if (mb_strlen($encrypted, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) |
|
175 | - throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
178 | + if (mb_strlen($encrypted, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) { |
|
179 | + throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
180 | + } |
|
176 | 181 | |
177 | 182 | $nonce = mb_substr($encrypted, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit'); |
178 | 183 | $ciphertext = mb_substr($encrypted, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit'); |
@@ -222,7 +227,9 @@ discard block |
||
222 | 227 | * @return boolean True if path valid |
223 | 228 | */ |
224 | 229 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
225 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
230 | + if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) { |
|
231 | + return true; |
|
232 | + } |
|
226 | 233 | return false; |
227 | 234 | } |
228 | 235 |
@@ -71,7 +71,9 @@ discard block |
||
71 | 71 | $this->is_loaded = false; |
72 | 72 | $this->subdivisions = array(); |
73 | 73 | $this->mappings = array(); |
74 | - if($load) $this->load(); |
|
74 | + if($load) { |
|
75 | + $this->load(); |
|
76 | + } |
|
75 | 77 | } |
76 | 78 | |
77 | 79 | /** |
@@ -118,7 +120,9 @@ discard block |
||
118 | 120 | foreach($xml->subdivisions->children() as $subdivision){ |
119 | 121 | $attributes = $subdivision->attributes(); |
120 | 122 | $key = I18N::strtolower(trim($attributes['name'])); |
121 | - if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
123 | + if(isset($attributes['parent'])) { |
|
124 | + $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
125 | + } |
|
122 | 126 | $this->subdivisions[$key] = array( |
123 | 127 | 'id' => trim($attributes['id']), |
124 | 128 | 'displayname' => trim($attributes['name']), |
@@ -145,9 +149,10 @@ discard block |
||
145 | 149 | */ |
146 | 150 | public function isLoaded() { |
147 | 151 | try{ |
148 | - if(!$this->is_loaded) $this->load(); |
|
149 | - } |
|
150 | - catch (\Exception $ex) { } |
|
152 | + if(!$this->is_loaded) { |
|
153 | + $this->load(); |
|
154 | + } |
|
155 | + } catch (\Exception $ex) { } |
|
151 | 156 | return $this->is_loaded; |
152 | 157 | } |
153 | 158 | |
@@ -164,7 +169,9 @@ discard block |
||
164 | 169 | * @return string |
165 | 170 | */ |
166 | 171 | public function getDescription() { |
167 | - if(!$this->is_loaded) $this->load(); |
|
172 | + if(!$this->is_loaded) { |
|
173 | + $this->load(); |
|
174 | + } |
|
168 | 175 | return $this->description; |
169 | 176 | } |
170 | 177 | |
@@ -173,7 +180,9 @@ discard block |
||
173 | 180 | * @return string |
174 | 181 | */ |
175 | 182 | public function getTopLevelName() { |
176 | - if(!$this->is_loaded) $this->load(); |
|
183 | + if(!$this->is_loaded) { |
|
184 | + $this->load(); |
|
185 | + } |
|
177 | 186 | return $this->top_level_name; |
178 | 187 | } |
179 | 188 | |
@@ -182,7 +191,9 @@ discard block |
||
182 | 191 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
183 | 192 | */ |
184 | 193 | public function getCanvas() { |
185 | - if(!$this->is_loaded) $this->load(); |
|
194 | + if(!$this->is_loaded) { |
|
195 | + $this->load(); |
|
196 | + } |
|
186 | 197 | return $this->canvas; |
187 | 198 | } |
188 | 199 | |
@@ -191,7 +202,9 @@ discard block |
||
191 | 202 | * @return array |
192 | 203 | */ |
193 | 204 | public function getSubdivisions() { |
194 | - if(!$this->is_loaded) $this->load(); |
|
205 | + if(!$this->is_loaded) { |
|
206 | + $this->load(); |
|
207 | + } |
|
195 | 208 | return $this->subdivisions; |
196 | 209 | } |
197 | 210 | |
@@ -200,7 +213,9 @@ discard block |
||
200 | 213 | * @return array |
201 | 214 | */ |
202 | 215 | public function getPlacesMappings() { |
203 | - if(!$this->is_loaded) $this->load(); |
|
216 | + if(!$this->is_loaded) { |
|
217 | + $this->load(); |
|
218 | + } |
|
204 | 219 | return $this->mappings; |
205 | 220 | } |
206 | 221 |
@@ -144,14 +144,15 @@ discard block |
||
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | 146 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
147 | - } |
|
148 | - catch (\Exception $ex) { |
|
147 | + } catch (\Exception $ex) { |
|
149 | 148 | $res['error'] = $ex->getMessage(); |
150 | 149 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
151 | 150 | } |
152 | 151 | |
153 | 152 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
153 | + if($res['error']) { |
|
154 | + http_response_code(500); |
|
155 | + } |
|
155 | 156 | |
156 | 157 | $controller->encode($res); |
157 | 158 | } |
@@ -175,14 +176,15 @@ discard block |
||
175 | 176 | try{ |
176 | 177 | $this->provider->deleteGeoAnalysis($ga); |
177 | 178 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | - } |
|
179 | - catch (\Exception $ex) { |
|
179 | + } catch (\Exception $ex) { |
|
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | 181 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
182 | 182 | } |
183 | 183 | |
184 | 184 | $controller->pageHeader(); |
185 | - if($res['error']) http_response_code(500); |
|
185 | + if($res['error']) { |
|
186 | + http_response_code(500); |
|
187 | + } |
|
186 | 188 | |
187 | 189 | $controller->encode($res); |
188 | 190 | } |
@@ -234,7 +236,9 @@ discard block |
||
234 | 236 | |
235 | 237 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 238 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
239 | + if(isset($placesGeneralResults['other'])) { |
|
240 | + $nb_other =$placesGeneralResults['other']; |
|
241 | + } |
|
238 | 242 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 243 | |
240 | 244 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -255,12 +259,13 @@ discard block |
||
255 | 259 | if($level_map >= 0 && $level_map < count($levelvalues)) { |
256 | 260 | $levelref = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]); |
257 | 261 | if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
258 | - } |
|
259 | - else { |
|
262 | + } else { |
|
260 | 263 | $levelref = $levelvalues[0]; |
261 | 264 | } |
262 | 265 | $levelref = I18N::strtolower($levelref); |
263 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
266 | + if(isset($places_mappings[$levelref])) { |
|
267 | + $levelref = $places_mappings[$levelref]; |
|
268 | + } |
|
264 | 269 | if(isset($results_by_subdivs[$levelref])) { |
265 | 270 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
266 | 271 | $count_subd += $count; |
@@ -278,8 +283,7 @@ discard block |
||
278 | 283 | } |
279 | 284 | |
280 | 285 | $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
281 | - } |
|
282 | - else { |
|
286 | + } else { |
|
283 | 287 | $results = $placesGeneralResults['places']; |
284 | 288 | arsort($results); |
285 | 289 | $data->set('results', $results); |
@@ -287,8 +291,7 @@ discard block |
||
287 | 291 | |
288 | 292 | $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
289 | 293 | } |
290 | - } |
|
291 | - else { |
|
294 | + } else { |
|
292 | 295 | $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
293 | 296 | } |
294 | 297 | return $html; |
@@ -320,9 +323,15 @@ discard block |
||
320 | 323 | $sum = 0; |
321 | 324 | $other = 0; |
322 | 325 | $unknown = 0; |
323 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | - if(isset($genData['other'])) $other = $genData['other']; |
|
325 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
326 | + if(isset($genData['sum'])) { |
|
327 | + $sum = $genData['sum']; |
|
328 | + } |
|
329 | + if(isset($genData['other'])) { |
|
330 | + $other = $genData['other']; |
|
331 | + } |
|
332 | + if(isset($genData['unknown'])) { |
|
333 | + $unknown = $genData['unknown']; |
|
334 | + } |
|
326 | 335 | |
327 | 336 | if($sum > 0) { |
328 | 337 | $results_by_gen[$gen]['sum'] = $sum; |
@@ -340,8 +349,7 @@ discard block |
||
340 | 349 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
341 | 350 | } |
342 | 351 | } |
343 | - } |
|
344 | - else { |
|
352 | + } else { |
|
345 | 353 | $tmp = $genData['places']; |
346 | 354 | if($other > 0) { |
347 | 355 | $tmp = array_slice($tmp, 0, 5, true); |
@@ -357,8 +365,7 @@ discard block |
||
357 | 365 | |
358 | 366 | $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
359 | 367 | |
360 | - } |
|
361 | - else { |
|
368 | + } else { |
|
362 | 369 | $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
363 | 370 | } |
364 | 371 | return $html; |
@@ -95,7 +95,9 @@ discard block |
||
95 | 95 | * @return ImageBuilder |
96 | 96 | */ |
97 | 97 | public function setExpireOffset($expireOffset) { |
98 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
98 | + if($expireOffset) { |
|
99 | + $this->expire_offset = $expireOffset; |
|
100 | + } |
|
99 | 101 | return $this; |
100 | 102 | } |
101 | 103 | |
@@ -115,7 +117,9 @@ discard block |
||
115 | 117 | * @return ImageBuilder |
116 | 118 | */ |
117 | 119 | public function setShowWatermark($show_watermark) { |
118 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
120 | + if(!is_null($show_watermark)) { |
|
121 | + $this->show_watermark = $show_watermark; |
|
122 | + } |
|
119 | 123 | return $this; |
120 | 124 | } |
121 | 125 | |
@@ -126,7 +130,9 @@ discard block |
||
126 | 130 | * @return ImageBuilder |
127 | 131 | */ |
128 | 132 | public function setFontMaxSize($font_max_size) { |
129 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
133 | + if($font_max_size) { |
|
134 | + $this->font_max_size = $font_max_size; |
|
135 | + } |
|
130 | 136 | return $this; |
131 | 137 | } |
132 | 138 | |
@@ -137,7 +143,9 @@ discard block |
||
137 | 143 | * @return ImageBuilder |
138 | 144 | */ |
139 | 145 | public function setFontColor($font_color) { |
140 | - if($font_color) $this->font_color = $font_color; |
|
146 | + if($font_color) { |
|
147 | + $this->font_color = $font_color; |
|
148 | + } |
|
141 | 149 | return $this; |
142 | 150 | } |
143 | 151 | |
@@ -148,7 +156,9 @@ discard block |
||
148 | 156 | * @return ImageBuilder |
149 | 157 | */ |
150 | 158 | public function setAsAttachment($is_attachement) { |
151 | - if(is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
159 | + if(is_bool($is_attachement)) { |
|
160 | + $this->as_attachment = $is_attachement; |
|
161 | + } |
|
152 | 162 | return $this; |
153 | 163 | } |
154 | 164 | |
@@ -300,8 +310,7 @@ discard block |
||
300 | 310 | // text to watermark with |
301 | 311 | if(method_exists($this->media, 'getWatermarkText')) { |
302 | 312 | $word1_text = $this->media->getWatermarkText(); |
303 | - } |
|
304 | - else { |
|
313 | + } else { |
|
305 | 314 | $word1_text = $this->media->getTitle(); |
306 | 315 | } |
307 | 316 |
@@ -84,21 +84,25 @@ discard block |
||
84 | 84 | * @param User $user |
85 | 85 | */ |
86 | 86 | public function __construct(Tree $tree, User $user = null) { |
87 | - if(self::$default_user === null) |
|
88 | - self::$default_user = User::find(-1); |
|
87 | + if(self::$default_user === null) { |
|
88 | + self::$default_user = User::find(-1); |
|
89 | + } |
|
89 | 90 | |
90 | 91 | $this->tree = $tree; |
91 | 92 | $this->user = $user; |
92 | 93 | $this->is_setup = true; |
93 | - if($this->user === null) $this->user = Auth::user(); |
|
94 | - if(strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
94 | + if($this->user === null) { |
|
95 | + $this->user = Auth::user(); |
|
96 | + } |
|
97 | + if(strlen($this->user->getUserId()) == 0) { |
|
98 | + $this->user = self::$default_user; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | // Check if the user, or the default user, has a root already setup; |
97 | 102 | if(empty($this->getRootIndiId())) { |
98 | 103 | if($this->user == self::$default_user) { // If the default user is not setup |
99 | 104 | $this->is_setup = false; |
100 | - } |
|
101 | - else { |
|
105 | + } else { |
|
102 | 106 | $this->user = self::$default_user; |
103 | 107 | $this->is_setup = $this->getRootIndiId() === null; |
104 | 108 | } |
@@ -159,7 +163,9 @@ discard block |
||
159 | 163 | * Remove all Sosa entries related to the gedcom file and user |
160 | 164 | */ |
161 | 165 | public function deleteAll() { |
162 | - if(!$this->is_setup) return; |
|
166 | + if(!$this->is_setup) { |
|
167 | + return; |
|
168 | + } |
|
163 | 169 | Database::prepare( |
164 | 170 | 'DELETE FROM `##maj_sosa`'. |
165 | 171 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -175,7 +181,9 @@ discard block |
||
175 | 181 | * @param int $sosa |
176 | 182 | */ |
177 | 183 | public function deleteAncestors($sosa) { |
178 | - if(!$this->is_setup) return; |
|
184 | + if(!$this->is_setup) { |
|
185 | + return; |
|
186 | + } |
|
179 | 187 | $gen = Functions::getGeneration($sosa); |
180 | 188 | Database::prepare( |
181 | 189 | 'DELETE FROM `##maj_sosa`'. |
@@ -195,7 +203,9 @@ discard block |
||
195 | 203 | * @param array $sosa_records |
196 | 204 | */ |
197 | 205 | public function insertOrUpdate($sosa_records) { |
198 | - if(!$this->is_setup) return; |
|
206 | + if(!$this->is_setup) { |
|
207 | + return; |
|
208 | + } |
|
199 | 209 | |
200 | 210 | $treeid = $this->tree->getTreeId(); |
201 | 211 | $userid = $this->user->getUserId(); |
@@ -244,7 +254,9 @@ discard block |
||
244 | 254 | * @return array Array of sosa numbers |
245 | 255 | */ |
246 | 256 | public function getSosaNumbers(Individual $indi) { |
247 | - if(!$this->is_setup) return array(); |
|
257 | + if(!$this->is_setup) { |
|
258 | + return array(); |
|
259 | + } |
|
248 | 260 | return Database::prepare( |
249 | 261 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
250 | 262 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -261,7 +273,9 @@ discard block |
||
261 | 273 | * @return number Last generation if found, 1 otherwise |
262 | 274 | */ |
263 | 275 | public function getLastGeneration() { |
264 | - if(!$this->is_setup) return; |
|
276 | + if(!$this->is_setup) { |
|
277 | + return; |
|
278 | + } |
|
265 | 279 | return Database::prepare( |
266 | 280 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
267 | 281 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -281,7 +295,9 @@ discard block |
||
281 | 295 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
282 | 296 | */ |
283 | 297 | public function getAllSosaWithGenerations(){ |
284 | - if(!$this->is_setup) return array(); |
|
298 | + if(!$this->is_setup) { |
|
299 | + return array(); |
|
300 | + } |
|
285 | 301 | return Database::prepare( |
286 | 302 | 'SELECT majs_i_id AS indi,' . |
287 | 303 | ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
@@ -301,9 +317,12 @@ discard block |
||
301 | 317 | * @return array Array of Sosa individuals |
302 | 318 | */ |
303 | 319 | public function getSosaListAtGeneration($gen){ |
304 | - if(!$this->is_setup) return array(); |
|
305 | - if(!$this->sosa_list_by_gen) |
|
306 | - $this->sosa_list_by_gen = array(); |
|
320 | + if(!$this->is_setup) { |
|
321 | + return array(); |
|
322 | + } |
|
323 | + if(!$this->sosa_list_by_gen) { |
|
324 | + $this->sosa_list_by_gen = array(); |
|
325 | + } |
|
307 | 326 | |
308 | 327 | if($gen){ |
309 | 328 | if(!isset($this->sosa_list_by_gen[$gen])){ |
@@ -332,9 +351,12 @@ discard block |
||
332 | 351 | * @return array Array of Sosa families |
333 | 352 | */ |
334 | 353 | public function getFamilySosaListAtGeneration($gen){ |
335 | - if(!$this->is_setup) return array(); |
|
336 | - if(!$this->sosa_fam_list_by_gen) |
|
337 | - $this->sosa_fam_list_by_gen = array(); |
|
354 | + if(!$this->is_setup) { |
|
355 | + return array(); |
|
356 | + } |
|
357 | + if(!$this->sosa_fam_list_by_gen) { |
|
358 | + $this->sosa_fam_list_by_gen = array(); |
|
359 | + } |
|
338 | 360 | |
339 | 361 | if($gen){ |
340 | 362 | if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
@@ -368,7 +390,9 @@ discard block |
||
368 | 390 | * @return array Array of Sosa individuals |
369 | 391 | */ |
370 | 392 | public function getMissingSosaListAtGeneration($gen){ |
371 | - if(!$this->is_setup) return array(); |
|
393 | + if(!$this->is_setup) { |
|
394 | + return array(); |
|
395 | + } |
|
372 | 396 | if($gen){ |
373 | 397 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
374 | 398 | 'SELECT schild.majs_sosa sosa, schild.majs_i_id indi, sfat.majs_sosa IS NOT NULL has_father, smot.majs_sosa IS NOT NULL has_mother'. |
@@ -408,7 +432,9 @@ discard block |
||
408 | 432 | * @return array Statistics array |
409 | 433 | */ |
410 | 434 | public function getStatisticsByGeneration() { |
411 | - if(!$this->is_setup) return array(); |
|
435 | + if(!$this->is_setup) { |
|
436 | + return array(); |
|
437 | + } |
|
412 | 438 | if(!$this->statistics_tab) { |
413 | 439 | $this->statistics_tab = array(); |
414 | 440 | if($maxGeneration = $this->getLastGeneration()) { |
@@ -436,7 +462,9 @@ discard block |
||
436 | 462 | * @return int |
437 | 463 | */ |
438 | 464 | public function getTotalIndividuals() { |
439 | - if(!$this->is_setup) return 0; |
|
465 | + if(!$this->is_setup) { |
|
466 | + return 0; |
|
467 | + } |
|
440 | 468 | return Database::prepare( |
441 | 469 | 'SELECT COUNT(*) FROM `##individuals`' . |
442 | 470 | ' WHERE i_file = :tree_id') |
@@ -450,7 +478,9 @@ discard block |
||
450 | 478 | * @return number Number of Sosas |
451 | 479 | */ |
452 | 480 | public function getSosaCount(){ |
453 | - if(!$this->is_setup) return 0; |
|
481 | + if(!$this->is_setup) { |
|
482 | + return 0; |
|
483 | + } |
|
454 | 484 | return Database::prepare( |
455 | 485 | 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
456 | 486 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -467,7 +497,9 @@ discard block |
||
467 | 497 | * @return number Number of Sosas in generation |
468 | 498 | */ |
469 | 499 | public function getSosaCountAtGeneration($gen){ |
470 | - if(!$this->is_setup) return 0; |
|
500 | + if(!$this->is_setup) { |
|
501 | + return 0; |
|
502 | + } |
|
471 | 503 | return Database::prepare( |
472 | 504 | 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
473 | 505 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -486,7 +518,9 @@ discard block |
||
486 | 518 | * @return number Total number of Sosas up to generation |
487 | 519 | */ |
488 | 520 | public function getSosaCountUpToGeneration($gen){ |
489 | - if(!$this->is_setup) return 0; |
|
521 | + if(!$this->is_setup) { |
|
522 | + return 0; |
|
523 | + } |
|
490 | 524 | return Database::prepare( |
491 | 525 | 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
492 | 526 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -504,7 +538,9 @@ discard block |
||
504 | 538 | * @return number Total number of distinct individual |
505 | 539 | */ |
506 | 540 | public function getDifferentSosaCount(){ |
507 | - if(!$this->is_setup) return 0; |
|
541 | + if(!$this->is_setup) { |
|
542 | + return 0; |
|
543 | + } |
|
508 | 544 | return Database::prepare( |
509 | 545 | 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
510 | 546 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -521,7 +557,9 @@ discard block |
||
521 | 557 | * @return number Number of distinct Sosa individuals up to generation |
522 | 558 | */ |
523 | 559 | public function getDifferentSosaCountUpToGeneration($gen){ |
524 | - if(!$this->is_setup) return 0; |
|
560 | + if(!$this->is_setup) { |
|
561 | + return 0; |
|
562 | + } |
|
525 | 563 | return Database::prepare( |
526 | 564 | 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
527 | 565 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -546,7 +584,9 @@ discard block |
||
546 | 584 | * @return array Birth statistics array |
547 | 585 | */ |
548 | 586 | public function getStatsBirthYearInGeneration($gen){ |
549 | - if(!$this->is_setup) return array('first' => 0, 'first_est' => 0, 'avg' => 0, 'last' => 0, 'last_est' => 0); |
|
587 | + if(!$this->is_setup) { |
|
588 | + return array('first' => 0, 'first_est' => 0, 'avg' => 0, 'last' => 0, 'last_est' => 0); |
|
589 | + } |
|
550 | 590 | return Database::prepare( |
551 | 591 | 'SELECT'. |
552 | 592 | ' MIN(majs_birth_year) AS first, MIN(majs_birth_year_est) AS first_est,'. |
@@ -568,7 +608,9 @@ discard block |
||
568 | 608 | * @return number|NULL Mean generation time |
569 | 609 | */ |
570 | 610 | public function getMeanGenerationTime(){ |
571 | - if(!$this->is_setup) return; |
|
611 | + if(!$this->is_setup) { |
|
612 | + return; |
|
613 | + } |
|
572 | 614 | if(!$this->statistics_tab){ |
573 | 615 | $this->getStatisticsByGeneration(); |
574 | 616 | } |
@@ -610,7 +652,9 @@ discard block |
||
610 | 652 | * @return array |
611 | 653 | */ |
612 | 654 | public function getGenerationDepthStatsAtGen($gen) { |
613 | - if(!$this->is_setup) return array(); |
|
655 | + if(!$this->is_setup) { |
|
656 | + return array(); |
|
657 | + } |
|
614 | 658 | $gen_depth_stats_raw = Database::prepare( |
615 | 659 | 'SELECT stats_by_gen.root_ancestor AS root_ancestor_sosa,'. |
616 | 660 | ' sosa_list.majs_i_id as root_ancestor_id,'. |
@@ -685,7 +729,10 @@ discard block |
||
685 | 729 | * @return array |
686 | 730 | */ |
687 | 731 | public function getAncestorDispersionForGen($gen) { |
688 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
732 | + if(!$this->is_setup || $gen > 11) { |
|
733 | + return array(); |
|
734 | + } |
|
735 | + // Going further than 11 gen will be out of range in the query |
|
689 | 736 | return Database::prepare( |
690 | 737 | 'SELECT branches, count(i_id)'. |
691 | 738 | ' FROM ('. |
@@ -725,7 +772,9 @@ discard block |
||
725 | 772 | * @return array |
726 | 773 | */ |
727 | 774 | public function getTopMultiSosaAncestorsNoTies($limit) { |
728 | - if(!$this->is_setup) return array(); |
|
775 | + if(!$this->is_setup) { |
|
776 | + return array(); |
|
777 | + } |
|
729 | 778 | return Database::prepare( |
730 | 779 | 'SELECT sosa_i_id, sosa_count FROM ('. |
731 | 780 | ' SELECT'. |
@@ -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,11 +348,9 @@ 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 | - elseif ($place_structure = $this->getPlacesHierarchyFromData()){ |
|
351 | + } elseif ($place_structure = $this->getPlacesHierarchyFromData()){ |
|
355 | 352 | $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure); |
356 | - } |
|
357 | - else { |
|
353 | + } else { |
|
358 | 354 | $this->place_hierarchy = array('type' => 'none', 'hierarchy' => null); |
359 | 355 | } |
360 | 356 | } |
@@ -418,14 +414,15 @@ discard block |
||
418 | 414 | if($parts > $max_level) { |
419 | 415 | $max_level = $parts; |
420 | 416 | $places_with_high_level = array($place); |
421 | - } |
|
422 | - else if ($parts == $max_level) { |
|
417 | + } else if ($parts == $max_level) { |
|
423 | 418 | $places_with_high_level[] = $place; |
424 | 419 | } |
425 | 420 | } |
426 | 421 | |
427 | 422 | // If empty array, then return null |
428 | - if($max_level == 0) return null; |
|
423 | + if($max_level == 0) { |
|
424 | + return null; |
|
425 | + } |
|
429 | 426 | |
430 | 427 | // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used |
431 | 428 | usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp')); |