Passed
Push — master ( b2ca54...1f995c )
by Jonathan
04:01
created
src/Webtrees/Module/PatronymicLineage/Views/LineageView.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
         /** @var \Fisharebest\Webtrees\Tree $tree */
37 37
         $tree = $this->data->get('tree');
38 38
         
39
-        echo '<h2 class="center">', $this->data->get('title') , '</h2>';
39
+        echo '<h2 class="center">', $this->data->get('title'), '</h2>';
40 40
         echo '<p class="center alpha_index">', implode(' | ', $this->getInitialLettersList()), '</p>';
41 41
          
42
-        if($this->data->get('issurnames', false)) {
42
+        if ($this->data->get('issurnames', false)) {
43 43
             $surns = $this->data->get('surnameslist', array());
44
-            $extra_params = array ('mod' => Constants::MODULE_MAJ_PATROLIN_NAME, 'mod_action' => 'Lineage');
44
+            $extra_params = array('mod' => Constants::MODULE_MAJ_PATROLIN_NAME, 'mod_action' => 'Lineage');
45 45
             // Show the surname list
46 46
             switch ($tree->getPreference('SURNAME_LIST_STYLE')) {
47 47
                 case 'style1':
@@ -59,16 +59,16 @@  discard block
 block discarded – undo
59 59
         else if ($this->data->get('islineages', false)) {
60 60
             //Link to indilist
61 61
             echo '<p class="center"><strong>'.
62
-                '<a href="indilist.php?ged=' . $tree->getNameUrl() . '&surname=' . rawurlencode($this->data->get('surname')) .'">'. 
62
+                '<a href="indilist.php?ged='.$tree->getNameUrl().'&surname='.rawurlencode($this->data->get('surname')).'">'. 
63 63
                 I18N::translate('Go to the list of individuals with surname %s', $this->data->get('legend')).
64 64
                 '</a></strong></p>';
65 65
             
66 66
             $lineages = $this->data->get('lineages', null);
67 67
             $nb_lineages = is_null($lineages) ? 0 : count($lineages);
68
-            if($nb_lineages == 0) {
68
+            if ($nb_lineages == 0) {
69 69
             	echo '<p class="center"><span class="warning">',
70 70
             		I18N::translate('No individuals with surname %s has been found. Please try another name.',
71
-            			'<span dir="auto">' . $this->data->get('legend') . '</span>'),
71
+            			'<span dir="auto">'.$this->data->get('legend').'</span>'),
72 72
             			'</span></p>';
73 73
             } else { 
74 74
             	
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
             	
80 80
             	echo '<div class="list_value_wrap">';            	
81 81
             	
82
-            	foreach($lineages as $i => $lineage) {
82
+            	foreach ($lineages as $i => $lineage) {
83 83
             		$this->printRootLineage($lineage);
84
-            		if($i < $nb_lineages - 1) echo '<hr />';
84
+            		if ($i < $nb_lineages - 1) echo '<hr />';
85 85
             	}
86 86
             	
87 87
             	echo '</div>';
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $list = array();
105 105
         /** @var \Fisharebest\Webtrees\Tree $tree */
106 106
         $tree = $this->data->get('tree');
107
-		$script_base_url = WT_SCRIPT_NAME . '?mod=' . \MyArtJaub\Webtrees\Constants::MODULE_MAJ_PATROLIN_NAME . '&mod_action=Lineage';
107
+		$script_base_url = WT_SCRIPT_NAME.'?mod='.\MyArtJaub\Webtrees\Constants::MODULE_MAJ_PATROLIN_NAME.'&mod_action=Lineage';
108 108
 		
109 109
         foreach (QueryName::surnameAlpha($tree, false, false) as $letter => $count) {
110 110
             switch ($letter) {
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
             }
121 121
             if ($count) {
122 122
                 if ($letter == $this->data->get('alpha')) {
123
-                    $list[] = '<a href="' . $script_base_url . '&alpha=' . rawurlencode($letter) . '&amp;ged=' . $tree->getNameUrl() . '" class="warning" title="' . I18N::number($count) . '">' . $html . '</a>';
123
+                    $list[] = '<a href="'.$script_base_url.'&alpha='.rawurlencode($letter).'&amp;ged='.$tree->getNameUrl().'" class="warning" title="'.I18N::number($count).'">'.$html.'</a>';
124 124
                 } else {
125
-                    $list[] = '<a href="' . $script_base_url . '&alpha=' . rawurlencode($letter) . '&amp;ged=' . $tree->getNameUrl() . '" title="' . I18N::number($count) . '">' . $html . '</a>';
125
+                    $list[] = '<a href="'.$script_base_url.'&alpha='.rawurlencode($letter).'&amp;ged='.$tree->getNameUrl().'" title="'.I18N::number($count).'">'.$html.'</a>';
126 126
                 }
127 127
             } else {
128 128
                 $list[] = $html;
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
         // Search spiders don't get the "show all" option as the other links give them everything.
133 133
         if (!Auth::isSearchEngine()) {
134 134
             if ($this->data->get('show_all') === 'yes') {
135
-                $list[] = '<span class="warning">' . I18N::translate('All') . '</span>';
135
+                $list[] = '<span class="warning">'.I18N::translate('All').'</span>';
136 136
             } else {
137
-                $list[] = '<a href="' . $script_base_url . '&show_all=yes' . '&amp;ged=' . $tree->getNameUrl() . '">' . I18N::translate('All') . '</a>';
137
+                $list[] = '<a href="'.$script_base_url.'&show_all=yes'.'&amp;ged='.$tree->getNameUrl().'">'.I18N::translate('All').'</a>';
138 138
             }
139 139
         }
140 140
     
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
      */
148 148
     private function printRootLineage(LineageRootNode $node) {    	
149 149
     	print '<div class="patrolin_tree">';
150
-    	if($node->getIndividual() === null) {
150
+    	if ($node->getIndividual() === null) {
151 151
     		$fam_nodes = $node->getFamiliesNodes();
152
-    		foreach($fam_nodes as $fam){
153
-    			foreach($fam_nodes[$fam] as $child_node) {
154
-    				if($child_node) {
152
+    		foreach ($fam_nodes as $fam) {
153
+    			foreach ($fam_nodes[$fam] as $child_node) {
154
+    				if ($child_node) {
155 155
     					$this->printLineage($child_node);
156 156
     				}
157 157
     			}
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     	echo '</div>';
164 164
     	
165 165
     	$places = $node->getPlaces();
166
-    	if($places && count($places)>0){
166
+    	if ($places && count($places) > 0) {
167 167
     		echo '<div class="patrolin_places">';
168 168
     		echo \MyArtJaub\Webtrees\Functions\FunctionsPrint::htmlPlacesCloud($places, false, $this->data->get('tree'));
169 169
     		echo '</div>';
@@ -178,34 +178,34 @@  discard block
 block discarded – undo
178 178
     	
179 179
     	echo '<ul>';
180 180
     	$fam_nodes = $node->getFamiliesNodes();
181
-    	if(count($fam_nodes) > 0) {
181
+    	if (count($fam_nodes) > 0) {
182 182
     		$is_first_family = true;
183
-    		foreach($fam_nodes as $fam) {
183
+    		foreach ($fam_nodes as $fam) {
184 184
     			$node_indi = $node->getIndividual();
185 185
     			echo '<li>';
186
-    			if($is_first_family){
186
+    			if ($is_first_family) {
187 187
     				echo FunctionsPrint::htmlIndividualForList($node_indi);
188 188
     			}
189
-				else{
189
+				else {
190 190
 					echo FunctionsPrint::htmlIndividualForList($node_indi, false);
191 191
 				}
192 192
 				//Get individual's spouse
193 193
 				$dfam = new Family($fam);
194
-				$spouse=$dfam->getSpouseById($node_indi);
194
+				$spouse = $dfam->getSpouseById($node_indi);
195 195
 				//Print the spouse if relevant
196
-				if($spouse){
196
+				if ($spouse) {
197 197
 					$marrdate = I18N::translate('yes');
198 198
 					$marryear = '';
199 199
 					echo '&nbsp;<a href="'.$fam->getHtmlUrl().'">';
200
-					if ($fam->getMarriageYear()){
200
+					if ($fam->getMarriageYear()) {
201 201
 						$marrdate = strip_tags($fam->getMarriageDate()->Display());
202 202
 						$marryear = $fam->getMarriageYear();
203 203
 					}
204 204
 					echo '<span class="details1" title="'.$marrdate.'"><i class="icon-rings"></i>'.$marryear.'</span></a>&nbsp;';
205 205
 					echo FunctionsPrint::htmlIndividualForList($spouse);
206 206
 				}
207
-    			foreach($fam_nodes[$fam] as $child_node) {
208
-    				if($child_node) {
207
+    			foreach ($fam_nodes[$fam] as $child_node) {
208
+    				if ($child_node) {
209 209
     					$this->printLineage($child_node);
210 210
     				}
211 211
     				else {
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
     	else {
219 219
     		echo '<li>';
220 220
     		echo \MyArtJaub\Webtrees\Functions\FunctionsPrint::htmlIndividualForList($node->getIndividual());
221
-    		if($node->hasFollowUpSurname()) {
222
-    			$url_base = WT_SCRIPT_NAME . '?mod=' . \MyArtJaub\Webtrees\Constants::MODULE_MAJ_PATROLIN_NAME . '&mod_action=Lineage';
221
+    		if ($node->hasFollowUpSurname()) {
222
+    			$url_base = WT_SCRIPT_NAME.'?mod='.\MyArtJaub\Webtrees\Constants::MODULE_MAJ_PATROLIN_NAME.'&mod_action=Lineage';
223 223
     			echo '&nbsp;'.
224
-    				'<a href="' . $url_base . '&surname=' . rawurlencode($node->getFollowUpSurname()) . '&amp;ged=' . $this->data->get('tree')->getNameUrl() . '">'.
224
+    				'<a href="'.$url_base.'&surname='.rawurlencode($node->getFollowUpSurname()).'&amp;ged='.$this->data->get('tree')->getNameUrl().'">'.
225 225
     				'('.I18N::translate('Go to %s lineages', $node->getFollowUpSurname()).')'.
226 226
     				'</a>';
227 227
     		}
Please login to merge, or discard this patch.
src/Webtrees/ImageBuilder.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	*
70 70
 	* @param Media|null $media Reference media object
71 71
 	*/
72
-	public function __construct(Media $media = null){
72
+	public function __construct(Media $media = null) {
73 73
 	    $this->media = $media;
74 74
 	    $this->use_ttf = function_exists('imagettftext');
75 75
 	    $this->expire_offset = 3600 * 24;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return ImageBuilder
96 96
 	 */
97 97
 	public function setExpireOffset($expireOffset) {
98
-	    if($expireOffset) $this->expire_offset = $expireOffset;
98
+	    if ($expireOffset) $this->expire_offset = $expireOffset;
99 99
 	    return $this;
100 100
 	}
101 101
 	
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return ImageBuilder
116 116
 	 */
117 117
 	public function setShowWatermark($show_watermark) {
118
-	    if(!is_null($show_watermark)) $this->show_watermark = $show_watermark;
118
+	    if (!is_null($show_watermark)) $this->show_watermark = $show_watermark;
119 119
 	    return $this;
120 120
 	}
121 121
 	
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @return ImageBuilder
127 127
 	 */
128 128
 	public function setFontMaxSize($font_max_size) {
129
-	    if($font_max_size) $this->font_max_size = $font_max_size;
129
+	    if ($font_max_size) $this->font_max_size = $font_max_size;
130 130
 	    return $this;
131 131
 	}
132 132
 	
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @return ImageBuilder
138 138
 	 */
139 139
 	public function setFontColor($font_color) {
140
-	    if($font_color) $this->font_color = $font_color;
140
+	    if ($font_color) $this->font_color = $font_color;
141 141
 	    return $this;
142 142
 	}
143 143
 	
@@ -148,32 +148,32 @@  discard block
 block discarded – undo
148 148
 	 * @return ImageBuilder
149 149
 	 */
150 150
 	public function setAsAttachment($is_attachement) {
151
-	    if(is_bool($is_attachement)) $this->as_attachment = $is_attachement;
151
+	    if (is_bool($is_attachement)) $this->as_attachment = $is_attachement;
152 152
 	    return $this;
153 153
 	}
154 154
 	
155 155
 	/**
156 156
 	 * Render the image to the output.
157 157
 	 */
158
-	public function render(){
158
+	public function render() {
159 159
 	    
160 160
 	    if (!$this->media || !$this->media->canShow()) {
161
-	        Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.'));
161
+	        Log::addMediaLog('Image Builder error: >'.I18N::translate('Missing or private media object.'));
162 162
 	        $this->renderError();
163 163
 	    }
164 164
 	    
165 165
 	    $serverFilename = $this->media->getServerFilename();
166 166
 	    
167 167
 	    if (!file_exists($serverFilename)) {
168
-	        Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
168
+	        Log::addMediaLog('Image Builder error: >'.I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<');
169 169
 	        $this->renderError();
170 170
 	    }
171 171
 	    
172 172
 	    $mimetype = $this->media->mimeType();
173 173
 	    $imgsize = $this->media->getImageAttributes();
174 174
 	    $filetime = $this->media->getFiletime();
175
-	    $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';	    
176
-	    $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT';
175
+	    $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime).' GMT';	    
176
+	    $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()).' GMT';
177 177
 	    
178 178
 	    $type = Functions::isImageTypeSupported($imgsize['ext']);
179 179
 	    $usewatermark = false;
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 	    }
206 206
 	    
207 207
 	    // add caching headers.  allow browser to cache file, but not proxy
208
-	    header('Last-Modified: ' . $filetimeHeader);
209
-	    header('ETag: "' . $etag . '"');
210
-	    header('Expires: ' . $expireHeader);
211
-	    header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate');
208
+	    header('Last-Modified: '.$filetimeHeader);
209
+	    header('ETag: "'.$etag.'"');
210
+	    header('Expires: '.$expireHeader);
211
+	    header('Cache-Control: max-age='.$this->getExpireOffset().', s-maxage=0, proxy-revalidate');
212 212
 	    
213 213
 	    // if this file is already in the user’s cache, don’t resend it
214 214
 	    // first check if the if_modified_since param matches
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 
224 224
 	    // send headers for the image
225 225
 	    $disposition = $this->as_attachment ? 'attachment' : 'inline';
226
-	    header('Content-Type: ' . $mimetype);
227
-	    header('Content-Disposition: ' . $disposition . '; filename="' . addslashes(basename($this->media->getFilename())) . '"');
226
+	    header('Content-Type: '.$mimetype);
227
+	    header('Content-Disposition: '.$disposition.'; filename="'.addslashes(basename($this->media->getFilename())).'"');
228 228
 	     
229 229
 	    if ($usewatermark) {
230 230
 	        // generate the watermarked image
231
-	        $imCreateFunc = 'imagecreatefrom' . $type;
232
-	        $imSendFunc   = 'image' . $type;
231
+	        $imCreateFunc = 'imagecreatefrom'.$type;
232
+	        $imSendFunc   = 'image'.$type;
233 233
 	    
234 234
 	        if (function_exists($imCreateFunc) && function_exists($imSendFunc)) {
235 235
 	            $im = $imCreateFunc($serverFilename);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	            return;
243 243
 	        } else {
244 244
 	            // this image is defective.  log it
245
-	            Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage());
245
+	            Log::addMediaLog('Image Builder error: >'.I18N::translate('This media file is broken and cannot be watermarked.').'< in file >'.$serverFilename.'< memory used: '.memory_get_usage());
246 246
 	        }
247 247
 	    }
248 248
 	    
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	    $filesize = filesize($serverFilename);
251 251
 	    
252 252
 	    // set content-length header, send file
253
-	    header('Content-Length: ' . $filesize);
253
+	    header('Content-Length: '.$filesize);
254 254
 	    
255 255
 	    // Some servers disable fpassthru() and readfile()
256 256
 	    if (function_exists('readfile')) {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     	$bgc    = imagecolorallocate($im, 255, 255, 255); /* set background color */
281 281
     	imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */
282 282
     
283
-    	$this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left');
283
+    	$this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, 'top', 'left');
284 284
     
285 285
     	http_response_code(404);
286 286
     	header('Content-Type: image/png');
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	protected function applyWatermark($im) {
299 299
 	    
300 300
 	    // text to watermark with	    
301
-	    if(method_exists($this->media, 'getWatermarkText')) {
301
+	    if (method_exists($this->media, 'getWatermarkText')) {
302 302
 	       $word1_text = $this->media->getWatermarkText();
303 303
 	    }
304 304
 	    else {
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	        $word1_text, 
311 311
 	        $this->font_max_size,
312 312
 	        $this->font_color,
313
-	        WT_ROOT . Config::FONT_DEJAVU_SANS_TTF,
313
+	        WT_ROOT.Config::FONT_DEJAVU_SANS_TTF,
314 314
 	        'top', 
315 315
 	        'left'
316 316
 	     );
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * @param string $hexstr
430 430
 	 * @return int[]
431 431
 	 */
432
-	protected function hexrgb ($hexstr)
432
+	protected function hexrgb($hexstr)
433 433
 	{
434 434
 	    $int = hexdec($hexstr);
435 435
 	
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
      */
472 472
     function imageTtfTextErrorHandler($errno, $errstr) {
473 473
         // log the error
474
-        Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<');
474
+        Log::addErrorLog('Image Builder error: >'.$errno.'/'.$errstr.'< while processing file >'.$this->media->getServerFilename().'<');
475 475
     
476 476
         // change value of useTTF to false so the fallback watermarking can be used.
477 477
         $this->use_ttf = false;
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Schema/Migration1.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@
 block discarded – undo
22 22
 	public function upgrade() {
23 23
 
24 24
 		Database::exec(
25
-		    'ALTER TABLE `##maj_sosa`' . 
26
-		    ' ADD COLUMN majs_birth_year_est SMALLINT NULL AFTER majs_birth_year,' .
25
+		    'ALTER TABLE `##maj_sosa`'. 
26
+		    ' ADD COLUMN majs_birth_year_est SMALLINT NULL AFTER majs_birth_year,'.
27 27
 		    ' ADD COLUMN majs_death_year_est SMALLINT NULL AFTER majs_death_year'
28 28
 		);
29 29
 		
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaStatsController.php 1 patch
Spacing   +40 added lines, -41 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $view_bag->set('title', $controller->getPageTitle());
64 64
         $view_bag->set('is_setup', false);
65 65
         
66
-        if($this->sosa_provider->isSetup()) {
66
+        if ($this->sosa_provider->isSetup()) {
67 67
             $view_bag->set('is_setup', true);
68 68
             
69 69
             $view_bag->set('root_indi', $this->sosa_provider->getRootIndi());
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
             $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen=');
85 85
             $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen=');
86 86
             
87
-            $gen_theoretical=1;
88
-            $total_theoretical=0;
89
-            $prev_diff=0;
90
-            $prev_known=0.5;
87
+            $gen_theoretical = 1;
88
+            $total_theoretical = 0;
89
+            $prev_diff = 0;
90
+            $prev_known = 0.5;
91 91
             $generation_stats = array();
92 92
             
93
-            foreach($stats_gen as $gen => $tab){
94
-                $genY1= I18N::translate('-');
95
-                $genY2= I18N::translate('-');
96
-                if($tab['firstBirth']>0) $genY1=$tab['firstEstimatedBirth'];
97
-                if($tab['lastBirth']>0) $genY2=$tab['lastEstimatedBirth'];
93
+            foreach ($stats_gen as $gen => $tab) {
94
+                $genY1 = I18N::translate('-');
95
+                $genY2 = I18N::translate('-');
96
+                if ($tab['firstBirth'] > 0) $genY1 = $tab['firstEstimatedBirth'];
97
+                if ($tab['lastBirth'] > 0) $genY2 = $tab['lastEstimatedBirth'];
98 98
                 $total_theoretical += $gen_theoretical;
99 99
                 $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical);
100
-                $missing=2*$prev_known - $tab['sosaCount'];
101
-                $gen_diff=$tab['diffSosaTotalCount']-$prev_diff;
100
+                $missing = 2 * $prev_known - $tab['sosaCount'];
101
+                $gen_diff = $tab['diffSosaTotalCount'] - $prev_diff;
102 102
                 
103 103
                 $generation_stats[$gen] = array(
104 104
                     'gen_min_birth' => $genY1,
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     'known' => $tab['sosaCount'],
108 108
                     'perc_known' => $perc_sosa_count_theor,
109 109
                     'missing' => $missing,
110
-                    'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known),
110
+                    'perc_missing' => 1 - Functions::safeDivision($tab['sosaCount'], 2 * $prev_known),
111 111
                     'total_known' => $tab['sosaTotalCount'],
112 112
                     'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical),
113 113
                     'different' => $gen_diff,
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
                 );
118 118
                 
119 119
                 $gen_theoretical = $gen_theoretical * 2;
120
-                $prev_known=$tab['sosaCount'];
121
-                $prev_diff=$tab['diffSosaTotalCount'];
120
+                $prev_known = $tab['sosaCount'];
121
+                $prev_diff = $tab['diffSosaTotalCount'];
122 122
             }
123 123
             
124 124
             $view_bag->set('generation_stats', $generation_stats);
@@ -149,13 +149,12 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10);
151 151
         $top10ancestors = array();
152
-        if($top10multiancestors !== null && count($top10multiancestors)) {
153
-            foreach($top10multiancestors as $pid => $count) {
152
+        if ($top10multiancestors !== null && count($top10multiancestors)) {
153
+            foreach ($top10multiancestors as $pid => $count) {
154 154
                 $indi = Individual::getInstance($pid, $this->sosa_provider->getTree());
155
-                if($indi !== null && $indi->canShowName()) {
155
+                if ($indi !== null && $indi->canShowName()) {
156 156
                     array_key_exists($count, $top10ancestors) ?
157
-                        $top10ancestors[$count][] = $indi:
158
-                        $top10ancestors[$count] = array($count => $indi);
157
+                        $top10ancestors[$count][] = $indi : $top10ancestors[$count] = array($count => $indi);
159 158
                 }
160 159
             }
161 160
         }
@@ -169,27 +168,27 @@  discard block
 block discarded – undo
169 168
      private function htmlAncestorDispersionG2()
170 169
     {
171 170
         $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2);
172
-        if(count($ancestorsDispGen2) == 0) return;
171
+        if (count($ancestorsDispGen2) == 0) return;
173 172
         
174 173
         $size = '600x300';
175 174
         
176 175
         $total = array_sum($ancestorsDispGen2);
177 176
         $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
178
-        $father = array (
177
+        $father = array(
179 178
             'color' => '84beff', 
180 179
             'count' => $father_count, 
181 180
             'perc' => Functions::safeDivision($father_count, $total), 
182 181
             'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat')            
183 182
         );
184 183
         $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
185
-        $mother = array (
184
+        $mother = array(
186 185
             'color' => 'ffd1dc', 
187 186
             'count' => $mother_count, 
188 187
             'perc' => Functions::safeDivision($mother_count, $total),
189 188
             'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot')
190 189
         );
191 190
         $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
192
-        $shared = array (
191
+        $shared = array(
193 192
             'color' => '777777', 
194 193
             'count' => $shared_count, 
195 194
             'perc' => Functions::safeDivision($shared_count, $total),
@@ -199,10 +198,10 @@  discard block
 block discarded – undo
199 198
         $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc']));
200 199
         $chart_title = I18N::translate('Known Sosa ancestors\' dispersion');
201 200
         $chl = 
202
-             $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' .
203
-             $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' .
204
-             $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1);
205
-        return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
201
+             $father['name'].' - '.I18N::percentage($father['perc'], 1).'|'.
202
+             $shared['name'].' - '.I18N::percentage($shared['perc'], 1).'|'.
203
+             $mother['name'].' - '.I18N::percentage($mother['perc'], 1);
204
+        return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />";
206 205
     }
207 206
     
208 207
     /**
@@ -226,7 +225,7 @@  discard block
 block discarded – undo
226 225
         $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0;
227 226
         $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0;
228 227
         $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
229
-        $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha;
228
+        $total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha;
230 229
     
231 230
         $chd = $this->arrayToExtendedEncoding(array(
232 231
 	    4095 * Functions::safeDivision($total_fatfat, $total), 
@@ -237,12 +236,12 @@  discard block
 block discarded – undo
237 236
         ));
238 237
         $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3');
239 238
         $chl =
240
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' .
241
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' .
242
-            I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' .
243
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' .
244
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
245
-         return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
239
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat').' - '.I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1).'|'.
240
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot').' - '.I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1).'|'.
241
+            I18N::translate('Shared').' - '.I18N::percentage(Functions::safeDivision($total_sha, $total), 1).'|'.
242
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat').' - '.I18N::percentage(Functions::safeDivision($total_motfat, $total), 1).'|'.
243
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot').' - '.I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
244
+         return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />";
246 245
     }    
247 246
     
248 247
     /**
@@ -251,15 +250,15 @@  discard block
 block discarded – undo
251 250
      */
252 251
     private function htmlAncestorGenDepthG3() {
253 252
         $ancestorsGenDepth3 = $this->sosa_provider->getGenerationDepthStatsAtGen(3);
254
-        if(count($ancestorsGenDepth3) == 0) return;
253
+        if (count($ancestorsGenDepth3) == 0) return;
255 254
         
256 255
         $ancestors = array();
257 256
         $chd_mean = array();
258 257
         $chd_error_low = array();
259 258
         $chd_error_high = array();
260
-        foreach($ancestorsGenDepth3 as $sosa => $genDepthStat) {
259
+        foreach ($ancestorsGenDepth3 as $sosa => $genDepthStat) {
261 260
             $ancestor = Individual::getInstance($genDepthStat['root_ancestor_id'], $this->sosa_provider->getTree());
262
-            if($ancestor !== null && $ancestor->canShowName()) {
261
+            if ($ancestor !== null && $ancestor->canShowName()) {
263 262
                 $tmp = $ancestor->getAllNames();
264 263
                 $ancestors[] = Filter::escapeUrl($tmp[$ancestor->getPrimaryName()]['fullNN']);
265 264
             }
@@ -272,7 +271,7 @@  discard block
 block discarded – undo
272 271
         }
273 272
         
274 273
         $maxChd = ceil(max($chd_error_high));
275
-        $chd = implode(',', $chd_mean) . '|' . implode(',', $chd_error_low) . '|' . implode(',', $chd_error_high);
274
+        $chd = implode(',', $chd_mean).'|'.implode(',', $chd_error_low).'|'.implode(',', $chd_error_high);
276 275
         $chxl = implode('|', array_reverse($ancestors));
277 276
         $chbh = 30;
278 277
         $chs = count($ancestors) * $chbh + 50;
@@ -294,9 +293,9 @@  discard block
 block discarded – undo
294 293
             if ($value < 0) {
295 294
                 $value = 0;
296 295
             }
297
-            $first  = (int) ($value / 64);
296
+            $first  = (int)($value / 64);
298 297
             $second = $value % 64;
299
-            $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second];
298
+            $encoding .= $xencoding[(int)$first].$xencoding[(int)$second];
300 299
         }
301 300
     
302 301
         return $encoding;
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Views/SosaStatsView.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 			<?php 
32 32
 			/** @var \Fisharebest\Webtrees\Individual $root_indi */
33 33
 			$root_indi = $this->data->get('root_indi');
34
-			if($root_indi !== null && $root_indi->canShowName()) { ?>
34
+			if ($root_indi !== null && $root_indi->canShowName()) { ?>
35 35
 			<h4 class="center"><?= I18N::translate('%s: %s', I18N::translate('Root individual'), $root_indi->getFullName()); ?><h4>
36 36
 			<?php } ?>
37 37
 			
38
-			<?php  if($this->data->get('is_setup')) {  
38
+			<?php  if ($this->data->get('is_setup')) {  
39 39
 			    $general_stats = $this->data->get('general_stats'); ?>
40 40
 			<h3><?php echo I18N::translate('General statistics'); ?></h3>
41 41
 			<div class="maj-table">
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 				</div>
58 58
 				<div class="maj-row">
59 59
 					<div class="label"><?php echo I18N::translate('Generation mean duration'); ?></div>
60
-					<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
+					<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>
61 61
 				</div>
62 62
 			</div>
63 63
 			
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 					</tr>
98 98
 				</thead>
99 99
 				<tbody>
100
-					<?php foreach($this->data->get('generation_stats') as $gen => $row) { ?>
100
+					<?php foreach ($this->data->get('generation_stats') as $gen => $row) { ?>
101 101
 					<tr class="maj-row">
102 102
 						<td class="label"><?php echo I18N::translate('<strong>G%d</strong>', $gen); ?></td>
103 103
 						<td class="label"><?php echo I18N::translate('%1$s <> %2$s', $row['gen_min_birth'], $row['gen_max_birth']); ?></td>
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 						<td class="value"><?php echo I18N::number($row['different']); ?></td>
112 112
 						<td class="value left percent_container">
113 113
 							<div class="percent_frame">
114
-								<div class="percent_cell" style="width:<?php echo 100*$row['perc_different'] ?>%;">
114
+								<div class="percent_cell" style="width:<?php echo 100 * $row['perc_different'] ?>%;">
115 115
 									&nbsp;<?php echo I18N::percentage($row['perc_different']); ?>&nbsp;
116 116
 								</div>
117 117
 							</div>
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 							             I18N::translate('%s generation'),
132 132
 							             I18N::translate('%s generations'),
133 133
 							             $this->data->get('mean_gen_depth'),
134
-							             I18N::number($this->data->get('mean_gen_depth'),2)
134
+							             I18N::number($this->data->get('mean_gen_depth'), 2)
135 135
 							         )
136 136
 							    ).
137
-								' &mdash; ' . 
137
+								' &mdash; '. 
138 138
 								I18N::translate(
139 139
 								    'Standard deviation: %s',
140 140
 								    I18N::plural(
141 141
 								        I18N::translate('%s generation'), 
142 142
 								        I18N::translate('%s generations'), 
143 143
 								        $this->data->get('stddev_gen_depth'), 
144
-								        I18N::number($this->data->get('stddev_gen_depth'),2)
144
+								        I18N::number($this->data->get('stddev_gen_depth'), 2)
145 145
 								    )
146 146
 								);
147 147
 							?>
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 			
154 154
 			<?php  
155 155
 			$top10_multi_ancestors = $this->data->get('top10multiancestors');
156
-			if(count($top10_multi_ancestors) > 0) { ?>
156
+			if (count($top10_multi_ancestors) > 0) { ?>
157 157
 			<h3><?= I18N::translate('Most duplicated root Sosa ancestors'); ?></h3>
158 158
 			<div class="maj-table">
159
-			<?php foreach($top10_multi_ancestors as $count => $indis) { ?>
159
+			<?php foreach ($top10_multi_ancestors as $count => $indis) { ?>
160 160
 			    <div class="maj-row">
161 161
 			    	<div class="label"><?= I18N::translate('%s times', I18N::number($count)); ?></div>
162 162
 			    	<div class="value"><?php 
163 163
 			    	echo implode(
164 164
 			    	    I18N::$list_separator, 
165 165
 			    	    array_map(function(Individual $indi) {
166
-			    	        return '<a href="'. $indi->getHtmlUrl(). '">'. $indi->getFullName() . '&nbsp;' . $indi->getSexImage() . '</a>';
166
+			    	        return '<a href="'.$indi->getHtmlUrl().'">'.$indi->getFullName().'&nbsp;'.$indi->getSexImage().'</a>';
167 167
 			    	    }, $indis)
168 168
 			    	);
169 169
 			    	?></div>
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 			
175 175
 			<h3><?php echo I18N::translate('Known Sosa ancestors\' family dispersion'); ?></h3>
176 176
 			<div class="center">
177
-				<?php echo $this->data->get('chart_img_g2') ?: '' ; ?>
178
-				<?php echo $this->data->get('chart_img_g3') ?: '' ; ?>
177
+				<?php echo $this->data->get('chart_img_g2') ?: ''; ?>
178
+				<?php echo $this->data->get('chart_img_g3') ?: ''; ?>
179 179
 				<!--  <canvas id="chart_ancestors_g2" width="300" height="300"></canvas>  -->
180 180
 			</div>
181 181
 			
182 182
 			<h3><?php echo I18N::translate('Mean generation depth by grandparents'); ?></h3>
183 183
 			<div class="center">
184
-				<?php echo $this->data->get('chart_img_gendepth3') ?: '' ; ?>
184
+				<?php echo $this->data->get('chart_img_gendepth3') ?: ''; ?>
185 185
 			</div>
186 186
 			
187 187
 			<?php   } else { ?>
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Model/SosaProvider.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
      * @param User $user
85 85
      */
86 86
     public function __construct(Tree $tree, User $user = null) {
87
-        if(self::$default_user === null) 
87
+        if (self::$default_user === null) 
88 88
             self::$default_user = User::find(-1);
89 89
         
90 90
         $this->tree = $tree;
91 91
         $this->user = $user;
92 92
         $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;
93
+        if ($this->user === null) $this->user = Auth::user();
94
+        if (strlen($this->user->getUserId()) == 0) $this->user = self::$default_user;
95 95
         
96 96
         // Check if the user, or the default user, has a root already setup;
97
-        if(empty($this->getRootIndiId())) {
98
-            if($this->user == self::$default_user) {  // If the default user is not setup
97
+        if (empty($this->getRootIndiId())) {
98
+            if ($this->user == self::$default_user) {  // If the default user is not setup
99 99
                 $this->is_setup = false;
100 100
             }
101 101
             else {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function getRootIndi() {
147 147
         $root_indi_id = $this->getRootIndiId();
148
-        if(!empty($root_indi_id)) {
148
+        if (!empty($root_indi_id)) {
149 149
             return Individual::getInstance($root_indi_id, $this->tree);
150 150
         }
151 151
         return null;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * Remove all Sosa entries related to the gedcom file and user
160 160
      */
161 161
     public function deleteAll() {
162
-        if(!$this->is_setup) return;
162
+        if (!$this->is_setup) return;
163 163
         Database::prepare(
164 164
             'DELETE FROM `##maj_sosa`'.
165 165
             ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ')
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
      * @param int $sosa
176 176
      */
177 177
     public function deleteAncestors($sosa) {
178
-        if(!$this->is_setup) return;
178
+        if (!$this->is_setup) return;
179 179
         $gen = Functions::getGeneration($sosa);
180 180
         Database::prepare(
181 181
             'DELETE FROM `##maj_sosa`'.
182
-            ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' .
183
-            ' AND majs_gen >= :gen' .
182
+            ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id'.
183
+            ' AND majs_gen >= :gen'.
184 184
             ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa'
185 185
         )->execute(array(
186 186
             'tree_id' => $this->tree->getTreeId(), 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      * @param array $sosa_records
196 196
      */
197 197
     public function insertOrUpdate($sosa_records) {
198
-        if(!$this->is_setup) return;
198
+        if (!$this->is_setup) return;
199 199
         
200 200
         $treeid = $this->tree->getTreeId();
201 201
         $userid = $this->user->getUserId();
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
         $values_table = array();
204 204
         
205 205
         $i = 0;
206
-        foreach  ($sosa_records as $row) {
206
+        foreach ($sosa_records as $row) {
207 207
             $gen = Functions::getGeneration($row['sosa']);
208
-            if($gen <= self::MAX_DB_GENERATIONS) {
208
+            if ($gen <= self::MAX_DB_GENERATIONS) {
209 209
                 $questionmarks_table[] = 
210 210
                     '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :byearest'.$i.', :dyear'.$i.', :dyearest'.$i.')';
211 211
                 $values_table = array_merge(
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
             $i++;
227 227
         }
228 228
         
229
-        $sql = 'REPLACE INTO `##maj_sosa`' .
230
-            ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)' .
231
-            ' VALUES '. implode(',', $questionmarks_table);
229
+        $sql = 'REPLACE INTO `##maj_sosa`'.
230
+            ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)'.
231
+            ' VALUES '.implode(',', $questionmarks_table);
232 232
         Database::prepare($sql)->execute($values_table);
233 233
     }
234 234
     
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @return array Array of sosa numbers
245 245
      */
246 246
     public function getSosaNumbers(Individual $indi) {
247
-        if(!$this->is_setup) return array();
247
+        if (!$this->is_setup) return array();
248 248
         return Database::prepare(
249 249
                 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'.
250 250
                 ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id'
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
      * @return number Last generation if found, 1 otherwise
262 262
      */
263 263
     public function getLastGeneration() {
264
-        if(!$this->is_setup) return;
264
+        if (!$this->is_setup) return;
265 265
         return Database::prepare(
266 266
                 'SELECT MAX(majs_gen) FROM `##maj_sosa`'.
267 267
                 ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
      *
281 281
      * @return array Associative array of Sosa ancestors, with their generation, comma separated
282 282
      */
283
-    public function getAllSosaWithGenerations(){
284
-        if(!$this->is_setup) return array();
283
+    public function getAllSosaWithGenerations() {
284
+        if (!$this->is_setup) return array();
285 285
         return Database::prepare(
286
-            'SELECT majs_i_id AS indi,' .
287
-            ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' .
288
-            ' FROM `##maj_sosa`' .
289
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' .
286
+            'SELECT majs_i_id AS indi,'.
287
+            ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations'.
288
+            ' FROM `##maj_sosa`'.
289
+            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
290 290
             ' GROUP BY majs_i_id'
291 291
         )->execute(array(
292 292
             'tree_id' => $this->tree->getTreeId(),
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
      * @param number $gen Generation
301 301
      * @return array Array of Sosa individuals
302 302
      */
303
-    public function getSosaListAtGeneration($gen){
304
-        if(!$this->is_setup) return array();
305
-        if(!$this->sosa_list_by_gen)
303
+    public function getSosaListAtGeneration($gen) {
304
+        if (!$this->is_setup) return array();
305
+        if (!$this->sosa_list_by_gen)
306 306
             $this->sosa_list_by_gen = array();
307 307
         
308
-        if($gen){
309
-            if(!isset($this->sosa_list_by_gen[$gen])){
308
+        if ($gen) {
309
+            if (!isset($this->sosa_list_by_gen[$gen])) {
310 310
                 $this->sosa_list_by_gen[$gen] = Database::prepare(
311 311
                     'SELECT majs_sosa AS sosa, majs_i_id AS indi'.
312 312
                     ' FROM `##maj_sosa`'.
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
      * @param number $gen Generation
332 332
      * @return array Array of Sosa families
333 333
      */
334
-    public function getFamilySosaListAtGeneration($gen){
335
-        if(!$this->is_setup) return array();
336
-        if(!$this->sosa_fam_list_by_gen)
334
+    public function getFamilySosaListAtGeneration($gen) {
335
+        if (!$this->is_setup) return array();
336
+        if (!$this->sosa_fam_list_by_gen)
337 337
             $this->sosa_fam_list_by_gen = array();
338 338
         
339
-        if($gen){
340
-            if(!isset($this->sosa_fam_list_by_gen[$gen])){
339
+        if ($gen) {
340
+            if (!isset($this->sosa_fam_list_by_gen[$gen])) {
341 341
                 $this->sosa_fam_list_by_gen[$gen] = Database::prepare(
342 342
                     'SELECT s1.majs_sosa AS sosa, f_id AS fam'.
343 343
                     ' FROM `##families`'.
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
      * @param number $gen Generation
368 368
      * @return array Array of Sosa individuals
369 369
      */
370
-    public function getMissingSosaListAtGeneration($gen){
371
-        if(!$this->is_setup) return array();    
372
-        if($gen){
370
+    public function getMissingSosaListAtGeneration($gen) {
371
+        if (!$this->is_setup) return array();    
372
+        if ($gen) {
373 373
             return $this->sosa_list_by_gen[$gen] = Database::prepare(
374 374
                 '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'.
375 375
                 ' FROM `##maj_sosa` schild'.
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
      * @return array Statistics array
409 409
      */
410 410
     public function getStatisticsByGeneration() {
411
-        if(!$this->is_setup) return array();
412
-        if(!$this->statistics_tab) {
411
+        if (!$this->is_setup) return array();
412
+        if (!$this->statistics_tab) {
413 413
             $this->statistics_tab = array();
414
-            if($maxGeneration = $this->getLastGeneration()) {
414
+            if ($maxGeneration = $this->getLastGeneration()) {
415 415
                 for ($gen = 1; $gen <= $maxGeneration; $gen++) {
416 416
                     $birthStats = $this->getStatsBirthYearInGeneration($gen);
417 417
                     $this->statistics_tab[$gen] = array(
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 	 * @return int
437 437
 	 */
438 438
 	public function getTotalIndividuals() {
439
-	    if(!$this->is_setup) return 0;
439
+	    if (!$this->is_setup) return 0;
440 440
 	    return Database::prepare(
441
-	        'SELECT COUNT(*) FROM `##individuals`' .
441
+	        'SELECT COUNT(*) FROM `##individuals`'.
442 442
 	        ' WHERE i_file = :tree_id')
443 443
 	        ->execute(array('tree_id' => $this->tree->getTreeId()))
444 444
 	        ->fetchOne() ?: 0;
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
      *
450 450
      * @return number Number of Sosas
451 451
      */
452
-    public function getSosaCount(){
453
-        if(!$this->is_setup) return 0;
452
+    public function getSosaCount() {
453
+        if (!$this->is_setup) return 0;
454 454
         return Database::prepare(
455
-            'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' .
455
+            'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'.
456 456
             ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id')
457 457
             ->execute(array(
458 458
                 'tree_id' => $this->tree->getTreeId(), 
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
      * @param number $gen Generation
467 467
      * @return number Number of Sosas in generation
468 468
      */
469
-    public function getSosaCountAtGeneration($gen){
470
-        if(!$this->is_setup) return 0;
469
+    public function getSosaCountAtGeneration($gen) {
470
+        if (!$this->is_setup) return 0;
471 471
         return Database::prepare(
472
-            'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' .
472
+            'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'.
473 473
             ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
474 474
             ' AND majs_gen= :gen')
475 475
         ->execute(array(
@@ -485,10 +485,10 @@  discard block
 block discarded – undo
485 485
      * @param number $gen Generation
486 486
      * @return number Total number of Sosas up to generation
487 487
      */
488
-    public function getSosaCountUpToGeneration($gen){
489
-        if(!$this->is_setup) return 0;
488
+    public function getSosaCountUpToGeneration($gen) {
489
+        if (!$this->is_setup) return 0;
490 490
         return Database::prepare(
491
-            'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' .
491
+            'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'.
492 492
             ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
493 493
             ' AND majs_gen <= :gen')
494 494
         ->execute(array(
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
      *
504 504
      * @return number Total number of distinct individual
505 505
      */
506
-    public function getDifferentSosaCount(){
507
-        if(!$this->is_setup) return 0;
506
+    public function getDifferentSosaCount() {
507
+        if (!$this->is_setup) return 0;
508 508
         return Database::prepare(
509
-            'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' .
509
+            'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'.
510 510
             ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id')
511 511
         ->execute(array(
512 512
                 'tree_id' => $this->tree->getTreeId(), 
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
      * @param number $gen Generation
521 521
      * @return number Number of distinct Sosa individuals up to generation
522 522
      */
523
-    public function getDifferentSosaCountUpToGeneration($gen){
524
-        if(!$this->is_setup) return 0;
523
+    public function getDifferentSosaCountUpToGeneration($gen) {
524
+        if (!$this->is_setup) return 0;
525 525
         return Database::prepare(
526
-            'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' .
526
+            'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'.
527 527
             ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
528 528
             ' AND majs_gen <= :gen')
529 529
         ->execute(array(
@@ -545,8 +545,8 @@  discard block
 block discarded – undo
545 545
      * @param number $gen Generation
546 546
      * @return array Birth statistics array
547 547
      */
548
-    public function getStatsBirthYearInGeneration($gen){
549
-        if(!$this->is_setup) return array('first' => 0, 'first_est' => 0, 'avg' => 0, 'last' => 0, 'last_est' => 0);
548
+    public function getStatsBirthYearInGeneration($gen) {
549
+        if (!$this->is_setup) return array('first' => 0, 'first_est' => 0, 'avg' => 0, 'last' => 0, 'last_est' => 0);
550 550
         return Database::prepare(
551 551
             'SELECT'.
552 552
             ' MIN(majs_birth_year) AS first, MIN(majs_birth_year_est) AS first_est,'.
@@ -567,25 +567,25 @@  discard block
 block discarded – undo
567 567
      *
568 568
      * @return number|NULL Mean generation time
569 569
      */
570
-    public function getMeanGenerationTime(){
571
-        if(!$this->is_setup) return;
572
-        if(!$this->statistics_tab){
570
+    public function getMeanGenerationTime() {
571
+        if (!$this->is_setup) return;
572
+        if (!$this->statistics_tab) {
573 573
             $this->getStatisticsByGeneration();
574 574
         }
575 575
         //Linear regression on x=generation and y=birthdate
576
-        $sum_xy = $sum_x = $sum_y= $sum_x2 = $n = 0;
577
-        foreach($this->statistics_tab as $gen=>$stats){
578
-            if(!is_null($stats['avgBirth'])) {
576
+        $sum_xy = $sum_x = $sum_y = $sum_x2 = $n = 0;
577
+        foreach ($this->statistics_tab as $gen=>$stats) {
578
+            if (!is_null($stats['avgBirth'])) {
579 579
                 $n++;
580
-                $sum_xy+=$gen*$stats['avgBirth'];
581
-                $sum_x+=$gen;
582
-                $sum_y+=$stats['avgBirth'];
583
-                $sum_x2+=$gen*$gen;
580
+                $sum_xy += $gen * $stats['avgBirth'];
581
+                $sum_x += $gen;
582
+                $sum_y += $stats['avgBirth'];
583
+                $sum_x2 += $gen * $gen;
584 584
             }
585 585
         }
586
-        $denom=($n*$sum_x2)-($sum_x*$sum_x);
587
-        if($denom!=0){
588
-            return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom);
586
+        $denom = ($n * $sum_x2) - ($sum_x * $sum_x);
587
+        if ($denom != 0) {
588
+            return -(($n * $sum_xy) - ($sum_x * $sum_y)) / ($denom);
589 589
         }
590 590
         return null;
591 591
     }
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
      * @return array
610 610
      */
611 611
     public function getGenerationDepthStatsAtGen($gen) {
612
-        if(!$this->is_setup) return array();
612
+        if (!$this->is_setup) return array();
613 613
         $gen_depth_stats_raw = Database::prepare(
614 614
             'SELECT stats_by_gen.root_ancestor AS root_ancestor_sosa,'.
615 615
             '   sosa_list.majs_i_id as root_ancestor_id,'.
@@ -684,14 +684,14 @@  discard block
 block discarded – undo
684 684
      * @return array
685 685
      */
686 686
     public function getAncestorDispersionForGen($gen) {
687
-        if(!$this->is_setup || $gen > 11) return array();  // Going further than 11 gen will be out of range in the query
687
+        if (!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query
688 688
         return Database::prepare(
689 689
             'SELECT branches, count(i_id)'.
690 690
             ' FROM ('.
691 691
             '   SELECT i_id,'.
692 692
             '       CASE'.
693 693
             '           WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'.
694
-            '           ELSE -1'.   // We put all ancestors shared between some branches in the same bucket
694
+            '           ELSE -1'.// We put all ancestors shared between some branches in the same bucket
695 695
             '       END branches'.
696 696
             '   FROM ('.
697 697
             '       SELECT DISTINCT majs_i_id i_id,'.
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
      * @return array 
725 725
      */
726 726
     public function getTopMultiSosaAncestorsNoTies($limit) {
727
-        if(!$this->is_setup) return array();
727
+        if (!$this->is_setup) return array();
728 728
         return Database::prepare(
729 729
             'SELECT sosa_i_id, sosa_count FROM ('.
730 730
             '   SELECT'.
@@ -737,20 +737,20 @@  discard block
 block discarded – undo
737 737
             '           COUNT(sosa.majs_sosa) sosa_count,'.
738 738
             '           MIN(sosa.majs_sosa) sosa_min'.
739 739
             '       FROM ##maj_sosa AS sosa'.
740
-            '       LEFT JOIN ##maj_sosa AS sosa_fat ON sosa_fat.majs_sosa = 2 * sosa.majs_sosa'.   // Link to sosa's father
740
+            '       LEFT JOIN ##maj_sosa AS sosa_fat ON sosa_fat.majs_sosa = 2 * sosa.majs_sosa'.// Link to sosa's father
741 741
             '           AND sosa.majs_gedcom_id = sosa_fat.majs_gedcom_id'.
742 742
             '           AND sosa.majs_user_id = sosa_fat.majs_user_id'.
743
-            '       LEFT JOIN ##maj_sosa AS sosa_mot on sosa_mot.majs_sosa = (2 * sosa.majs_sosa + 1)'.  // Link to sosa's mother
743
+            '       LEFT JOIN ##maj_sosa AS sosa_mot on sosa_mot.majs_sosa = (2 * sosa.majs_sosa + 1)'.// Link to sosa's mother
744 744
             '           AND sosa.majs_gedcom_id = sosa_fat.majs_gedcom_id'.
745 745
             '           AND sosa.majs_user_id = sosa_fat.majs_user_id'.
746 746
             '       WHERE sosa.majs_gedcom_id = :tree_id'.
747 747
             '       AND sosa.majs_user_id = :user_id'.
748
-            '       AND sosa_fat.majs_sosa IS NULL'.    // We keep only root individuals, i.e. those with no father or mother
748
+            '       AND sosa_fat.majs_sosa IS NULL'.// We keep only root individuals, i.e. those with no father or mother
749 749
             '       AND sosa_mot.majs_sosa IS NULL'. 
750 750
             '       GROUP BY sosa.majs_i_id'.
751
-            '       HAVING COUNT(sosa.majs_sosa) > 1'.   // Limit to the duplicate sosas.
751
+            '       HAVING COUNT(sosa.majs_sosa) > 1'.// Limit to the duplicate sosas.
752 752
             '       ORDER BY COUNT(sosa.majs_sosa) DESC'.
753
-            '       LIMIT ' . ($limit + 1) . // We want to select one more than required
753
+            '       LIMIT '.($limit + 1).// We want to select one more than required
754 754
             '   ) AS top_sosa,'.
755 755
             '   (SELECT @prev_count := 0, @keep := 0) x'.
756 756
             '   ORDER BY top_sosa.sosa_count ASC'.
Please login to merge, or discard this patch.