Completed
Push — master ( 94717f...b0ff97 )
by Jonathan
06:05
created
src/Webtrees/Module/Sosa/Views/SosaStatsView.php 1 patch
Spacing   +11 added lines, -11 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('Mean generation time'); ?></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>
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 				<tfoot>
125 125
 					<tr class="maj-row">
126 126
 						<td class="label" colspan="13">
127
-							<?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'),2)); ?>
127
+							<?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'), 2)); ?>
128 128
 						</td>
129 129
 					</tr>
130 130
 				</tfoot>
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
 			
134 134
 			<?php  
135 135
 			$top10_multi_ancestors = $this->data->get('top10multiancestors');
136
-			if(count($top10_multi_ancestors) > 0) { ?>
136
+			if (count($top10_multi_ancestors) > 0) { ?>
137 137
 			<h3><?= I18N::translate('Most duplicated root Sosa ancestors'); ?></h3>
138 138
 			<div class="maj-table">
139
-			<?php foreach($top10_multi_ancestors as $count => $indis) { ?>
139
+			<?php foreach ($top10_multi_ancestors as $count => $indis) { ?>
140 140
 			    <div class="maj-row">
141 141
 			    	<div class="label"><?= I18N::translate('%s times', I18N::number($count)); ?></div>
142 142
 			    	<div class="value"><?php 
143 143
 			    	echo implode(
144 144
 			    	    I18N::$list_separator, 
145 145
 			    	    array_map(function(Individual $indi) {
146
-			    	        return '<a href="'. $indi->getHtmlUrl(). '">'. $indi->getFullName() . '&nbsp;' . $indi->getSexImage() . '</a>';
146
+			    	        return '<a href="'.$indi->getHtmlUrl().'">'.$indi->getFullName().'&nbsp;'.$indi->getSexImage().'</a>';
147 147
 			    	    }, $indis)
148 148
 			    	);
149 149
 			    	?></div>
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 			
155 155
 			<h3><?php echo I18N::translate('Known Sosa ancestors\' family dispersion'); ?></h3>
156 156
 			<div class="center">
157
-				<?php echo $this->data->get('chart_img_g2') ?: '' ; ?>
158
-				<?php echo $this->data->get('chart_img_g3') ?: '' ; ?>				
157
+				<?php echo $this->data->get('chart_img_g2') ?: ''; ?>
158
+				<?php echo $this->data->get('chart_img_g3') ?: ''; ?>				
159 159
 				<!--  <canvas id="chart_ancestors_g2" width="300" height="300"></canvas>  -->
160 160
 			</div>
161 161
 			
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaStatsController.php 1 patch
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $view_bag->set('title', $controller->getPageTitle());
63 63
         $view_bag->set('is_setup', false);
64 64
         
65
-        if($this->sosa_provider->isSetup()) {
65
+        if ($this->sosa_provider->isSetup()) {
66 66
             $view_bag->set('is_setup', true);
67 67
             
68 68
             $view_bag->set('root_indi', $this->sosa_provider->getRootIndi());
@@ -83,23 +83,23 @@  discard block
 block discarded – undo
83 83
             $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen=');
84 84
             $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen=');
85 85
             
86
-            $gen_theoretical=1;
87
-            $total_theoretical=0;
88
-            $prev_diff=0;
89
-            $prev_known=0.5;
90
-            $gen_equiv=0;            
86
+            $gen_theoretical = 1;
87
+            $total_theoretical = 0;
88
+            $prev_diff = 0;
89
+            $prev_known = 0.5;
90
+            $gen_equiv = 0;            
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['firstBirth'];
97
-                if($tab['lastBirth']>0) $genY2=$tab['lastBirth'];
93
+            foreach ($stats_gen as $gen => $tab) {
94
+                $genY1 = I18N::translate('-');
95
+                $genY2 = I18N::translate('-');
96
+                if ($tab['firstBirth'] > 0) $genY1 = $tab['firstBirth'];
97
+                if ($tab['lastBirth'] > 0) $genY2 = $tab['lastBirth'];
98 98
                 $total_theoretical += $gen_theoretical;
99 99
                 $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical);
100 100
                 $gen_equiv += $perc_sosa_count_theor;
101
-                $missing=2*$prev_known - $tab['sosaCount'];
102
-                $gen_diff=$tab['diffSosaTotalCount']-$prev_diff;
101
+                $missing = 2 * $prev_known - $tab['sosaCount'];
102
+                $gen_diff = $tab['diffSosaTotalCount'] - $prev_diff;
103 103
                 
104 104
                 $generation_stats[$gen] = array(
105 105
                     'gen_min_birth' => $genY1,
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                     'known' => $tab['sosaCount'],
109 109
                     'perc_known' => $perc_sosa_count_theor,
110 110
                     'missing' => $missing,
111
-                    'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known),
111
+                    'perc_missing' => 1 - Functions::safeDivision($tab['sosaCount'], 2 * $prev_known),
112 112
                     'total_known' => $tab['sosaTotalCount'],
113 113
                     'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical),
114 114
                     'different' => $gen_diff,
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
                 );
119 119
                 
120 120
                 $gen_theoretical = $gen_theoretical * 2;
121
-                $prev_known=$tab['sosaCount'];
122
-                $prev_diff=$tab['diffSosaTotalCount'];
121
+                $prev_known = $tab['sosaCount'];
122
+                $prev_diff = $tab['diffSosaTotalCount'];
123 123
             }
124 124
             
125 125
             $view_bag->set('generation_stats', $generation_stats);
@@ -127,13 +127,12 @@  discard block
 block discarded – undo
127 127
             
128 128
             $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10);
129 129
             $top10ancestors = array();
130
-            if($top10multiancestors !== null && count($top10multiancestors)) {
131
-                foreach($top10multiancestors as $pid => $count) {
130
+            if ($top10multiancestors !== null && count($top10multiancestors)) {
131
+                foreach ($top10multiancestors as $pid => $count) {
132 132
                     $indi = Individual::getInstance($pid, $wt_tree);
133
-                    if($indi !== null && $indi->canShowName()) {
133
+                    if ($indi !== null && $indi->canShowName()) {
134 134
                         array_key_exists($count, $top10ancestors) ?
135
-                            $top10ancestors[$count][] = $indi:
136
-                            $top10ancestors[$count] = array($count => $indi);
135
+                            $top10ancestors[$count][] = $indi : $top10ancestors[$count] = array($count => $indi);
137 136
                     }
138 137
                 }
139 138
             }
@@ -154,27 +153,27 @@  discard block
 block discarded – undo
154 153
      private function htmlAncestorDispersionG2()
155 154
     {
156 155
         $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2);
157
-        if(count($ancestorsDispGen2) == 0) return;
156
+        if (count($ancestorsDispGen2) == 0) return;
158 157
         
159 158
         $size = '600x300';
160 159
         
161 160
         $total = array_sum($ancestorsDispGen2);
162 161
         $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
163
-        $father = array (
162
+        $father = array(
164 163
             'color' => '84beff', 
165 164
             'count' => $father_count, 
166 165
             'perc' => Functions::safeDivision($father_count, $total), 
167 166
             'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat')            
168 167
         );
169 168
         $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
170
-        $mother = array (
169
+        $mother = array(
171 170
             'color' => 'ffd1dc', 
172 171
             'count' => $mother_count, 
173 172
             'perc' => Functions::safeDivision($mother_count, $total),
174 173
             'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot')
175 174
         );
176 175
         $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
177
-        $shared = array (
176
+        $shared = array(
178 177
             'color' => '777777', 
179 178
             'count' => $shared_count, 
180 179
             'perc' => Functions::safeDivision($shared_count, $total),
@@ -184,10 +183,10 @@  discard block
 block discarded – undo
184 183
         $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc']));
185 184
         $chart_title = I18N::translate('Known Sosa ancestors\' dispersion');
186 185
         $chl = 
187
-             $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' .
188
-             $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' .
189
-             $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1);
190
-        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 . "\" />";
186
+             $father['name'].' - '.I18N::percentage($father['perc'], 1).'|'.
187
+             $shared['name'].' - '.I18N::percentage($shared['perc'], 1).'|'.
188
+             $mother['name'].' - '.I18N::percentage($mother['perc'], 1);
189
+        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."\" />";
191 190
     }
192 191
     
193 192
     /**
@@ -211,7 +210,7 @@  discard block
 block discarded – undo
211 210
         $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0;
212 211
         $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0;
213 212
         $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
214
-        $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha;
213
+        $total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha;
215 214
     
216 215
         $chd = $this->arrayToExtendedEncoding(array(
217 216
 	    4095 * Functions::safeDivision($total_fatfat, $total), 
@@ -222,12 +221,12 @@  discard block
 block discarded – undo
222 221
         ));
223 222
         $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3');
224 223
         $chl =
225
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' .
226
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' .
227
-            I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' .
228
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' .
229
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
230
-         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 . "\" />";
224
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat').' - '.I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1).'|'.
225
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot').' - '.I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1).'|'.
226
+            I18N::translate('Shared').' - '.I18N::percentage(Functions::safeDivision($total_sha, $total), 1).'|'.
227
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat').' - '.I18N::percentage(Functions::safeDivision($total_motfat, $total), 1).'|'.
228
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot').' - '.I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
229
+         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."\" />";
231 230
     }
232 231
 
233 232
     /**
@@ -243,9 +242,9 @@  discard block
 block discarded – undo
243 242
             if ($value < 0) {
244 243
                 $value = 0;
245 244
             }
246
-            $first  = (int) ($value / 64);
245
+            $first  = (int)($value / 64);
247 246
             $second = $value % 64;
248
-            $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second];
247
+            $encoding .= $xencoding[(int)$first].$xencoding[(int)$second];
249 248
         }
250 249
     
251 250
         return $encoding;
Please login to merge, or discard this patch.