@@ -219,7 +219,7 @@ |
||
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Convert an array to Google Chart encoding |
222 | - * @param arrat $a Array to encode |
|
222 | + * @param integer[] $a Array to encode |
|
223 | 223 | * @return string |
224 | 224 | */ |
225 | 225 | private function arrayToExtendedEncoding($a) { |
@@ -25,218 +25,218 @@ |
||
25 | 25 | */ |
26 | 26 | class SosaStatsController extends MvcController |
27 | 27 | { |
28 | - /** |
|
29 | - * Sosa Provider for the controller |
|
30 | - * @var SosaProvider $sosa_provider |
|
31 | - */ |
|
32 | - protected $sosa_provider; |
|
28 | + /** |
|
29 | + * Sosa Provider for the controller |
|
30 | + * @var SosaProvider $sosa_provider |
|
31 | + */ |
|
32 | + protected $sosa_provider; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor for SosaStatsController |
|
36 | - * @param AbstractModule $module |
|
37 | - */ |
|
38 | - public function __construct(AbstractModule $module) { |
|
39 | - global $WT_TREE; |
|
34 | + /** |
|
35 | + * Constructor for SosaStatsController |
|
36 | + * @param AbstractModule $module |
|
37 | + */ |
|
38 | + public function __construct(AbstractModule $module) { |
|
39 | + global $WT_TREE; |
|
40 | 40 | |
41 | - parent::__construct($module); |
|
41 | + parent::__construct($module); |
|
42 | 42 | |
43 | - $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
44 | - } |
|
43 | + $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Pages |
|
48 | - */ |
|
46 | + /** |
|
47 | + * Pages |
|
48 | + */ |
|
49 | 49 | |
50 | - /** |
|
51 | - * SosaStats@index |
|
52 | - */ |
|
53 | - public function index() { |
|
54 | - global $WT_TREE; |
|
50 | + /** |
|
51 | + * SosaStats@index |
|
52 | + */ |
|
53 | + public function index() { |
|
54 | + global $WT_TREE; |
|
55 | 55 | |
56 | - $controller = new PageController(); |
|
57 | - $controller |
|
58 | - ->setPageTitle(I18N::translate('Sosa Statistics')) |
|
59 | - ->addInlineJavascript('$(".help_tooltip").tooltip();') |
|
60 | - ; |
|
56 | + $controller = new PageController(); |
|
57 | + $controller |
|
58 | + ->setPageTitle(I18N::translate('Sosa Statistics')) |
|
59 | + ->addInlineJavascript('$(".help_tooltip").tooltip();') |
|
60 | + ; |
|
61 | 61 | |
62 | - $view_bag = new ViewBag(); |
|
63 | - $view_bag->set('title', $controller->getPageTitle()); |
|
64 | - $view_bag->set('is_setup', false); |
|
62 | + $view_bag = new ViewBag(); |
|
63 | + $view_bag->set('title', $controller->getPageTitle()); |
|
64 | + $view_bag->set('is_setup', false); |
|
65 | 65 | |
66 | - if($this->sosa_provider->isSetup()) { |
|
67 | - $view_bag->set('is_setup', true); |
|
66 | + if($this->sosa_provider->isSetup()) { |
|
67 | + $view_bag->set('is_setup', true); |
|
68 | 68 | |
69 | - $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
|
69 | + $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
|
70 | 70 | |
71 | - $sosaCount = $this->sosa_provider->getSosaCount(); |
|
72 | - $diffSosaCount = $this->sosa_provider->getDifferentSosaCount(); |
|
71 | + $sosaCount = $this->sosa_provider->getSosaCount(); |
|
72 | + $diffSosaCount = $this->sosa_provider->getDifferentSosaCount(); |
|
73 | 73 | |
74 | - $general_stats = array( |
|
75 | - 'sosa_count' => $sosaCount, |
|
76 | - 'distinct_count' => $diffSosaCount, |
|
77 | - 'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()), |
|
78 | - 'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount), |
|
79 | - 'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime() |
|
80 | - ); |
|
81 | - $view_bag->set('general_stats', $general_stats); |
|
74 | + $general_stats = array( |
|
75 | + 'sosa_count' => $sosaCount, |
|
76 | + 'distinct_count' => $diffSosaCount, |
|
77 | + 'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()), |
|
78 | + 'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount), |
|
79 | + 'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime() |
|
80 | + ); |
|
81 | + $view_bag->set('general_stats', $general_stats); |
|
82 | 82 | |
83 | - $stats_gen = $this->sosa_provider->getStatisticsByGeneration(); |
|
84 | - $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$WT_TREE->getNameUrl().'&gen='); |
|
85 | - $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$WT_TREE->getNameUrl().'&gen='); |
|
83 | + $stats_gen = $this->sosa_provider->getStatisticsByGeneration(); |
|
84 | + $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$WT_TREE->getNameUrl().'&gen='); |
|
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; |
|
91 | - $gen_equiv=0; |
|
92 | - $generation_stats = array(); |
|
87 | + $gen_theoretical=1; |
|
88 | + $total_theoretical=0; |
|
89 | + $prev_diff=0; |
|
90 | + $prev_known=0.5; |
|
91 | + $gen_equiv=0; |
|
92 | + $generation_stats = array(); |
|
93 | 93 | |
94 | - foreach($stats_gen as $gen => $tab){ |
|
95 | - $genY1= I18N::translate('-'); |
|
96 | - $genY2= I18N::translate('-'); |
|
97 | - if($tab['firstBirth']>0) $genY1=$tab['firstBirth']; |
|
98 | - if($tab['lastBirth']>0) $genY2=$tab['lastBirth']; |
|
99 | - $total_theoretical += $gen_theoretical; |
|
100 | - $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
|
101 | - $gen_equiv += $perc_sosa_count_theor; |
|
102 | - $missing=2*$prev_known - $tab['sosaCount']; |
|
103 | - $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
94 | + foreach($stats_gen as $gen => $tab){ |
|
95 | + $genY1= I18N::translate('-'); |
|
96 | + $genY2= I18N::translate('-'); |
|
97 | + if($tab['firstBirth']>0) $genY1=$tab['firstBirth']; |
|
98 | + if($tab['lastBirth']>0) $genY2=$tab['lastBirth']; |
|
99 | + $total_theoretical += $gen_theoretical; |
|
100 | + $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
|
101 | + $gen_equiv += $perc_sosa_count_theor; |
|
102 | + $missing=2*$prev_known - $tab['sosaCount']; |
|
103 | + $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
104 | 104 | |
105 | - $generation_stats[$gen] = array( |
|
106 | - 'gen_min_birth' => $genY1, |
|
107 | - 'gen_max_birth' => $genY2, |
|
108 | - 'theoretical' => $gen_theoretical, |
|
109 | - 'known' => $tab['sosaCount'], |
|
110 | - 'perc_known' => $perc_sosa_count_theor, |
|
111 | - 'missing' => $missing, |
|
112 | - 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
113 | - 'total_known' => $tab['sosaTotalCount'], |
|
114 | - 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
|
115 | - 'different' => $gen_diff, |
|
116 | - 'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']), |
|
117 | - 'total_different' => $tab['diffSosaTotalCount'], |
|
118 | - 'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount']) |
|
119 | - ); |
|
105 | + $generation_stats[$gen] = array( |
|
106 | + 'gen_min_birth' => $genY1, |
|
107 | + 'gen_max_birth' => $genY2, |
|
108 | + 'theoretical' => $gen_theoretical, |
|
109 | + 'known' => $tab['sosaCount'], |
|
110 | + 'perc_known' => $perc_sosa_count_theor, |
|
111 | + 'missing' => $missing, |
|
112 | + 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
113 | + 'total_known' => $tab['sosaTotalCount'], |
|
114 | + 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
|
115 | + 'different' => $gen_diff, |
|
116 | + 'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']), |
|
117 | + 'total_different' => $tab['diffSosaTotalCount'], |
|
118 | + 'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount']) |
|
119 | + ); |
|
120 | 120 | |
121 | - $gen_theoretical = $gen_theoretical * 2; |
|
122 | - $prev_known=$tab['sosaCount']; |
|
123 | - $prev_diff=$tab['diffSosaTotalCount']; |
|
124 | - } |
|
121 | + $gen_theoretical = $gen_theoretical * 2; |
|
122 | + $prev_known=$tab['sosaCount']; |
|
123 | + $prev_diff=$tab['diffSosaTotalCount']; |
|
124 | + } |
|
125 | 125 | |
126 | - $view_bag->set('generation_stats', $generation_stats); |
|
127 | - $view_bag->set('equivalent_gen', $gen_equiv); |
|
126 | + $view_bag->set('generation_stats', $generation_stats); |
|
127 | + $view_bag->set('equivalent_gen', $gen_equiv); |
|
128 | 128 | |
129 | - $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2()); |
|
130 | - $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3()); |
|
129 | + $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2()); |
|
130 | + $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3()); |
|
131 | 131 | |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | - ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render(); |
|
135 | - } |
|
134 | + ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render(); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Returns HTML code for a graph showing the dispersion of ancestors across father & mother |
|
139 | - * @return string HTML code |
|
140 | - */ |
|
141 | - private function htmlAncestorDispersionG2() |
|
142 | - { |
|
143 | - $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
|
144 | - if(count($ancestorsDispGen2) == 0) return; |
|
137 | + /** |
|
138 | + * Returns HTML code for a graph showing the dispersion of ancestors across father & mother |
|
139 | + * @return string HTML code |
|
140 | + */ |
|
141 | + private function htmlAncestorDispersionG2() |
|
142 | + { |
|
143 | + $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
|
144 | + if(count($ancestorsDispGen2) == 0) return; |
|
145 | 145 | |
146 | - $size = '600x300'; |
|
146 | + $size = '600x300'; |
|
147 | 147 | |
148 | - $total = array_sum($ancestorsDispGen2); |
|
149 | - $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
150 | - $father = array ( |
|
151 | - 'color' => '84beff', |
|
152 | - 'count' => $father_count, |
|
153 | - 'perc' => Functions::safeDivision($father_count, $total), |
|
154 | - 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
|
155 | - ); |
|
156 | - $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
157 | - $mother = array ( |
|
158 | - 'color' => 'ffd1dc', |
|
159 | - 'count' => $mother_count, |
|
160 | - 'perc' => Functions::safeDivision($mother_count, $total), |
|
161 | - 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
|
162 | - ); |
|
163 | - $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
164 | - $shared = array ( |
|
165 | - 'color' => '777777', |
|
166 | - 'count' => $shared_count, |
|
167 | - 'perc' => Functions::safeDivision($shared_count, $total), |
|
168 | - 'name' => I18N::translate('Shared') |
|
169 | - ); |
|
148 | + $total = array_sum($ancestorsDispGen2); |
|
149 | + $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
150 | + $father = array ( |
|
151 | + 'color' => '84beff', |
|
152 | + 'count' => $father_count, |
|
153 | + 'perc' => Functions::safeDivision($father_count, $total), |
|
154 | + 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
|
155 | + ); |
|
156 | + $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
157 | + $mother = array ( |
|
158 | + 'color' => 'ffd1dc', |
|
159 | + 'count' => $mother_count, |
|
160 | + 'perc' => Functions::safeDivision($mother_count, $total), |
|
161 | + 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
|
162 | + ); |
|
163 | + $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
164 | + $shared = array ( |
|
165 | + 'color' => '777777', |
|
166 | + 'count' => $shared_count, |
|
167 | + 'perc' => Functions::safeDivision($shared_count, $total), |
|
168 | + 'name' => I18N::translate('Shared') |
|
169 | + ); |
|
170 | 170 | |
171 | - $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
|
172 | - $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
|
173 | - $chl = |
|
174 | - $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
175 | - $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
176 | - $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
177 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
178 | - } |
|
171 | + $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
|
172 | + $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
|
173 | + $chl = |
|
174 | + $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
175 | + $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
176 | + $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
177 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
178 | + } |
|
179 | 179 | |
180 | - /** |
|
181 | - * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents |
|
182 | - * @return string HTML code |
|
183 | - */ |
|
184 | - private function htmlAncestorDispersionG3() |
|
185 | - { |
|
186 | - $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); |
|
180 | + /** |
|
181 | + * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents |
|
182 | + * @return string HTML code |
|
183 | + */ |
|
184 | + private function htmlAncestorDispersionG3() |
|
185 | + { |
|
186 | + $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); |
|
187 | 187 | |
188 | - $size = '700x300'; |
|
188 | + $size = '700x300'; |
|
189 | 189 | |
190 | - $color_motmot = 'ffd1dc'; |
|
191 | - $color_motfat = 'b998a0'; |
|
192 | - $color_fatfat = '577292'; |
|
193 | - $color_fatmot = '84beff'; |
|
194 | - $color_shared = '777777'; |
|
190 | + $color_motmot = 'ffd1dc'; |
|
191 | + $color_motfat = 'b998a0'; |
|
192 | + $color_fatfat = '577292'; |
|
193 | + $color_fatmot = '84beff'; |
|
194 | + $color_shared = '777777'; |
|
195 | 195 | |
196 | - $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
197 | - $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
198 | - $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
|
199 | - $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
|
200 | - $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
201 | - $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
196 | + $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
197 | + $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
198 | + $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
|
199 | + $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
|
200 | + $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
201 | + $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
202 | 202 | |
203 | - $chd = $this->arrayToExtendedEncoding(array( |
|
204 | - 4095 * Functions::safeDivision($total_fatfat, $total), |
|
205 | - 4095 * Functions::safeDivision($total_fatmot, $total), |
|
206 | - 4095 * Functions::safeDivision($total_sha, $total), |
|
207 | - 4095 * Functions::safeDivision($total_motfat, $total), |
|
208 | - 4095 * Functions::safeDivision($total_motmot, $total) |
|
209 | - )); |
|
210 | - $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
|
211 | - $chl = |
|
212 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
213 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
214 | - I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
215 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
216 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
217 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
218 | - } |
|
203 | + $chd = $this->arrayToExtendedEncoding(array( |
|
204 | + 4095 * Functions::safeDivision($total_fatfat, $total), |
|
205 | + 4095 * Functions::safeDivision($total_fatmot, $total), |
|
206 | + 4095 * Functions::safeDivision($total_sha, $total), |
|
207 | + 4095 * Functions::safeDivision($total_motfat, $total), |
|
208 | + 4095 * Functions::safeDivision($total_motmot, $total) |
|
209 | + )); |
|
210 | + $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
|
211 | + $chl = |
|
212 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
213 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
214 | + I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
215 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
216 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
217 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * Convert an array to Google Chart encoding |
|
222 | - * @param arrat $a Array to encode |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - private function arrayToExtendedEncoding($a) { |
|
226 | - $xencoding = WT_GOOGLE_CHART_ENCODING; |
|
220 | + /** |
|
221 | + * Convert an array to Google Chart encoding |
|
222 | + * @param arrat $a Array to encode |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + private function arrayToExtendedEncoding($a) { |
|
226 | + $xencoding = WT_GOOGLE_CHART_ENCODING; |
|
227 | 227 | |
228 | - $encoding = ''; |
|
229 | - foreach ($a as $value) { |
|
230 | - if ($value < 0) { |
|
231 | - $value = 0; |
|
232 | - } |
|
233 | - $first = (int) ($value / 64); |
|
234 | - $second = $value % 64; |
|
235 | - $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
236 | - } |
|
228 | + $encoding = ''; |
|
229 | + foreach ($a as $value) { |
|
230 | + if ($value < 0) { |
|
231 | + $value = 0; |
|
232 | + } |
|
233 | + $first = (int) ($value / 64); |
|
234 | + $second = $value % 64; |
|
235 | + $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
236 | + } |
|
237 | 237 | |
238 | - return $encoding; |
|
239 | - } |
|
238 | + return $encoding; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | 242 | } |
243 | 243 | \ No newline at end of file |
@@ -18,35 +18,35 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class Dispatcher implements DispatcherInterface { |
20 | 20 | |
21 | - /** |
|
22 | - * @var Dispatcher $instance Singleton pattern instance |
|
23 | - */ |
|
24 | - private static $instance = null; |
|
21 | + /** |
|
22 | + * @var Dispatcher $instance Singleton pattern instance |
|
23 | + */ |
|
24 | + private static $instance = null; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Returns the *Dispatcher* instance of this class. |
|
28 | - * |
|
29 | - * @return Dispatcher The *Singleton* instance. |
|
30 | - */ |
|
31 | - public static function getInstance() |
|
32 | - { |
|
33 | - if (null === static::$instance) { |
|
34 | - static::$instance = new static(); |
|
35 | - } |
|
26 | + /** |
|
27 | + * Returns the *Dispatcher* instance of this class. |
|
28 | + * |
|
29 | + * @return Dispatcher The *Singleton* instance. |
|
30 | + */ |
|
31 | + public static function getInstance() |
|
32 | + { |
|
33 | + if (null === static::$instance) { |
|
34 | + static::$instance = new static(); |
|
35 | + } |
|
36 | 36 | |
37 | - return static::$instance; |
|
38 | - } |
|
37 | + return static::$instance; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | /** |
41 | - * Protected constructor. |
|
42 | - */ |
|
43 | - protected function __construct() {} |
|
41 | + * Protected constructor. |
|
42 | + */ |
|
43 | + protected function __construct() {} |
|
44 | 44 | |
45 | - /** |
|
46 | - * {@inheritdoc } |
|
47 | - * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle() |
|
48 | - */ |
|
49 | - public function handle(fw\Module\AbstractModule $module, $request) { |
|
45 | + /** |
|
46 | + * {@inheritdoc } |
|
47 | + * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle() |
|
48 | + */ |
|
49 | + public function handle(fw\Module\AbstractModule $module, $request) { |
|
50 | 50 | |
51 | 51 | $fq_modclass_name = get_class($module); |
52 | 52 | $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | |
67 | 67 | $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
68 | 68 | if(class_exists($ctrl_class) |
69 | - && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
|
69 | + && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
|
70 | 70 | && $ctrl = new $ctrl_class($module) ) { |
71 | 71 | if(method_exists($ctrl, $method)) { |
72 | - try { |
|
73 | - call_user_func_array(array($ctrl, $method), array()); |
|
74 | - } |
|
75 | - catch (MvcException $ex) { |
|
76 | - if(!headers_sent()) { |
|
77 | - http_response_code($ex->getHttpCode()); |
|
78 | - } |
|
79 | - echo $ex->getMessage(); |
|
80 | - } |
|
72 | + try { |
|
73 | + call_user_func_array(array($ctrl, $method), array()); |
|
74 | + } |
|
75 | + catch (MvcException $ex) { |
|
76 | + if(!headers_sent()) { |
|
77 | + http_response_code($ex->getHttpCode()); |
|
78 | + } |
|
79 | + echo $ex->getMessage(); |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | else { |
83 | 83 | throw new \Exception('The page requested does not exist'); |
@@ -86,27 +86,27 @@ discard block |
||
86 | 86 | else { |
87 | 87 | throw new \Exception('The page requested does not exist'); |
88 | 88 | } |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Private clone method to prevent cloning of the instance of the |
|
93 | - * *Dispatcher* instance. |
|
94 | - * |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - private function __clone() |
|
98 | - { |
|
99 | - } |
|
91 | + /** |
|
92 | + * Private clone method to prevent cloning of the instance of the |
|
93 | + * *Dispatcher* instance. |
|
94 | + * |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + private function __clone() |
|
98 | + { |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
103 | - * instance. |
|
104 | - * |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - private function __wakeup() |
|
108 | - { |
|
109 | - } |
|
101 | + /** |
|
102 | + * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
103 | + * instance. |
|
104 | + * |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + private function __wakeup() |
|
108 | + { |
|
109 | + } |
|
110 | 110 | |
111 | 111 | } |
112 | 112 |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | public function handle(fw\Module\AbstractModule $module, $request) { |
50 | 50 | |
51 | 51 | $fq_modclass_name = get_class($module); |
52 | - $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
|
52 | + $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\'; |
|
53 | 53 | |
54 | - $args = explode( '@', $request, 2); |
|
55 | - switch(count($args)) { |
|
54 | + $args = explode('@', $request, 2); |
|
55 | + switch (count($args)) { |
|
56 | 56 | case 1: |
57 | 57 | $ctrl_name = $args[0]; |
58 | 58 | $method = 'index'; |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | - $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
|
68 | - if(class_exists($ctrl_class) |
|
67 | + $ctrl_class = $ctrl_namespace.$ctrl_name.'Controller'; |
|
68 | + if (class_exists($ctrl_class) |
|
69 | 69 | && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
70 | - && $ctrl = new $ctrl_class($module) ) { |
|
71 | - if(method_exists($ctrl, $method)) { |
|
70 | + && $ctrl = new $ctrl_class($module)) { |
|
71 | + if (method_exists($ctrl, $method)) { |
|
72 | 72 | try { |
73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
74 | 74 | } |
75 | 75 | catch (MvcException $ex) { |
76 | - if(!headers_sent()) { |
|
76 | + if (!headers_sent()) { |
|
77 | 77 | http_response_code($ex->getHttpCode()); |
78 | 78 | } |
79 | 79 | echo $ex->getMessage(); |
@@ -71,19 +71,16 @@ |
||
71 | 71 | if(method_exists($ctrl, $method)) { |
72 | 72 | try { |
73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
74 | - } |
|
75 | - catch (MvcException $ex) { |
|
74 | + } catch (MvcException $ex) { |
|
76 | 75 | if(!headers_sent()) { |
77 | 76 | http_response_code($ex->getHttpCode()); |
78 | 77 | } |
79 | 78 | echo $ex->getMessage(); |
80 | 79 | } |
81 | - } |
|
82 | - else { |
|
80 | + } else { |
|
83 | 81 | throw new \Exception('The page requested does not exist'); |
84 | 82 | } |
85 | - } |
|
86 | - else { |
|
83 | + } else { |
|
87 | 84 | throw new \Exception('The page requested does not exist'); |
88 | 85 | } |
89 | 86 | } |
@@ -16,52 +16,52 @@ |
||
16 | 16 | */ |
17 | 17 | class MvcException extends \Exception { |
18 | 18 | |
19 | - /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
|
20 | - protected static $VALID_HTTP = array( |
|
21 | - 100, 101, |
|
22 | - 200, 201, 202, 203, 204, 205, 206, |
|
23 | - 300, 301, 302, 303, 304, 305, 306, 307, |
|
24 | - 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, |
|
25 | - 500, 501, 502, 503, 504, 505 |
|
26 | - ); |
|
19 | + /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
|
20 | + protected static $VALID_HTTP = array( |
|
21 | + 100, 101, |
|
22 | + 200, 201, 202, 203, 204, 205, 206, |
|
23 | + 300, 301, 302, 303, 304, 305, 306, 307, |
|
24 | + 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, |
|
25 | + 500, 501, 502, 503, 504, 505 |
|
26 | + ); |
|
27 | 27 | |
28 | - /** @var int $http_code */ |
|
29 | - protected $http_code; |
|
28 | + /** @var int $http_code */ |
|
29 | + protected $http_code; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor for MvcException |
|
33 | - * |
|
34 | - * @param int $http_code |
|
35 | - * @param string $message |
|
36 | - * @param int $code |
|
37 | - * @param \Throwable $previous |
|
38 | - */ |
|
39 | - public function __construct($http_code = 500, $message = "", $code = 0, \Throwable $previous = null) { |
|
40 | - parent::__construct($message, $code, $previous); |
|
31 | + /** |
|
32 | + * Constructor for MvcException |
|
33 | + * |
|
34 | + * @param int $http_code |
|
35 | + * @param string $message |
|
36 | + * @param int $code |
|
37 | + * @param \Throwable $previous |
|
38 | + */ |
|
39 | + public function __construct($http_code = 500, $message = "", $code = 0, \Throwable $previous = null) { |
|
40 | + parent::__construct($message, $code, $previous); |
|
41 | 41 | |
42 | - $this->http_code = in_array($http_code, self::$VALID_HTTP) ? $http_code : 500; |
|
43 | - } |
|
42 | + $this->http_code = in_array($http_code, self::$VALID_HTTP) ? $http_code : 500; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Get the HTTP code |
|
47 | - * |
|
48 | - * @return int |
|
49 | - */ |
|
50 | - public function getHttpCode() { |
|
51 | - return $this->http_code; |
|
52 | - } |
|
45 | + /** |
|
46 | + * Get the HTTP code |
|
47 | + * |
|
48 | + * @return int |
|
49 | + */ |
|
50 | + public function getHttpCode() { |
|
51 | + return $this->http_code; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Set the HTTP code |
|
56 | - * |
|
57 | - * @param int $http_code |
|
58 | - * @throws InvalidArgumentException Thrown if not valid Http code |
|
59 | - */ |
|
60 | - public function setHttpCode($http_code) { |
|
61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
62 | - throw new \InvalidArgumentException('Invalid HTTP code'); |
|
63 | - $this->http_code= $http_code; |
|
64 | - } |
|
54 | + /** |
|
55 | + * Set the HTTP code |
|
56 | + * |
|
57 | + * @param int $http_code |
|
58 | + * @throws InvalidArgumentException Thrown if not valid Http code |
|
59 | + */ |
|
60 | + public function setHttpCode($http_code) { |
|
61 | + if(!in_array($http_code, self::$VALID_HTTP)) |
|
62 | + throw new \InvalidArgumentException('Invalid HTTP code'); |
|
63 | + $this->http_code= $http_code; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
67 | 67 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | class MvcException extends \Exception { |
18 | 18 | |
19 | 19 | /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
20 | - protected static $VALID_HTTP = array( |
|
20 | + protected static $VALID_HTTP = array( |
|
21 | 21 | 100, 101, |
22 | 22 | 200, 201, 202, 203, 204, 205, 206, |
23 | 23 | 300, 301, 302, 303, 304, 305, 306, 307, |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @throws InvalidArgumentException Thrown if not valid Http code |
59 | 59 | */ |
60 | 60 | public function setHttpCode($http_code) { |
61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
61 | + if (!in_array($http_code, self::$VALID_HTTP)) |
|
62 | 62 | throw new \InvalidArgumentException('Invalid HTTP code'); |
63 | - $this->http_code= $http_code; |
|
63 | + $this->http_code = $http_code; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
@@ -58,8 +58,9 @@ |
||
58 | 58 | * @throws InvalidArgumentException Thrown if not valid Http code |
59 | 59 | */ |
60 | 60 | public function setHttpCode($http_code) { |
61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
62 | - throw new \InvalidArgumentException('Invalid HTTP code'); |
|
61 | + if(!in_array($http_code, self::$VALID_HTTP)) { |
|
62 | + throw new \InvalidArgumentException('Invalid HTTP code'); |
|
63 | + } |
|
63 | 64 | $this->http_code= $http_code; |
64 | 65 | } |
65 | 66 |
@@ -19,59 +19,59 @@ |
||
19 | 19 | * Hooks Module. |
20 | 20 | */ |
21 | 21 | class HooksModule extends AbstractModule implements ModuleConfigInterface, DependentInterface { |
22 | - // How to update the database schema for this module |
|
23 | - const SCHEMA_TARGET_VERSION = 1; |
|
24 | - const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
25 | - const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\Hooks\Schema'; |
|
22 | + // How to update the database schema for this module |
|
23 | + const SCHEMA_TARGET_VERSION = 1; |
|
24 | + const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
25 | + const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\Hooks\Schema'; |
|
26 | 26 | |
27 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
28 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
27 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
28 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
29 | 29 | |
30 | - /** |
|
31 | - * {@inhericDoc} |
|
32 | - */ |
|
33 | - public function getTitle() { |
|
34 | - return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
35 | - } |
|
30 | + /** |
|
31 | + * {@inhericDoc} |
|
32 | + */ |
|
33 | + public function getTitle() { |
|
34 | + return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * {@inhericDoc} |
|
39 | - */ |
|
40 | - public function getDescription() { |
|
41 | - return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
42 | - } |
|
37 | + /** |
|
38 | + * {@inhericDoc} |
|
39 | + */ |
|
40 | + public function getDescription() { |
|
41 | + return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * {@inhericDoc} |
|
46 | - */ |
|
47 | - public function modAction($mod_action) { |
|
48 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
44 | + /** |
|
45 | + * {@inhericDoc} |
|
46 | + */ |
|
47 | + public function modAction($mod_action) { |
|
48 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
49 | 49 | |
50 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
51 | - } |
|
50 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inhericDoc} |
|
55 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
56 | - */ |
|
57 | - public function getConfigLink() { |
|
58 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
53 | + /** |
|
54 | + * {@inhericDoc} |
|
55 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
56 | + */ |
|
57 | + public function getConfigLink() { |
|
58 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
59 | 59 | |
60 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
61 | - } |
|
60 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * {@inheritDoc} |
|
65 | - * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
66 | - */ |
|
67 | - public function validatePrerequisites() { |
|
68 | - try { |
|
69 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
70 | - return true; |
|
71 | - } |
|
72 | - catch (\Exception $ex) { } |
|
73 | - return false; |
|
74 | - } |
|
63 | + /** |
|
64 | + * {@inheritDoc} |
|
65 | + * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
66 | + */ |
|
67 | + public function validatePrerequisites() { |
|
68 | + try { |
|
69 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
70 | + return true; |
|
71 | + } |
|
72 | + catch (\Exception $ex) { } |
|
73 | + return false; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | 77 | } |
@@ -68,8 +68,7 @@ |
||
68 | 68 | try { |
69 | 69 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
70 | 70 | return true; |
71 | - } |
|
72 | - catch (\Exception $ex) { } |
|
71 | + } catch (\Exception $ex) { } |
|
73 | 72 | return false; |
74 | 73 | } |
75 | 74 |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | class WelcomeBlockController extends MvcController |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * Pages |
|
33 | - */ |
|
31 | + /** |
|
32 | + * Pages |
|
33 | + */ |
|
34 | 34 | |
35 | - /** |
|
36 | - * WelcomeBlock@index |
|
37 | - * |
|
38 | - * @param PageController $parent_controller |
|
39 | - * @param Tree $tree |
|
40 | - * @param string $block_id |
|
41 | - * @param string $template |
|
42 | - * @return $string |
|
43 | - */ |
|
44 | - public function index(PageController $parent_controller, Tree $tree, $block_id, $template) { |
|
45 | - $view_bag = new ViewBag(); |
|
35 | + /** |
|
36 | + * WelcomeBlock@index |
|
37 | + * |
|
38 | + * @param PageController $parent_controller |
|
39 | + * @param Tree $tree |
|
40 | + * @param string $block_id |
|
41 | + * @param string $template |
|
42 | + * @return $string |
|
43 | + */ |
|
44 | + public function index(PageController $parent_controller, Tree $tree, $block_id, $template) { |
|
45 | + $view_bag = new ViewBag(); |
|
46 | 46 | |
47 | - if($parent_controller && $tree) { |
|
47 | + if($parent_controller && $tree) { |
|
48 | 48 | |
49 | - $view_bag->set('tree', $tree); |
|
50 | - $view_bag->set('indi', $parent_controller->getSignificantIndividual()); |
|
49 | + $view_bag->set('tree', $tree); |
|
50 | + $view_bag->set('indi', $parent_controller->getSignificantIndividual()); |
|
51 | 51 | |
52 | - $id = $this->module->getName().$block_id; |
|
53 | - $class = $this->module->getName().'_block'; |
|
54 | - $parent_controller->addInlineJavascript(' |
|
52 | + $id = $this->module->getName().$block_id; |
|
53 | + $class = $this->module->getName().'_block'; |
|
54 | + $parent_controller->addInlineJavascript(' |
|
55 | 55 | jQuery("#maj-new_passwd").hide(); |
56 | 56 | jQuery("#maj-passwd_click").click(function() |
57 | 57 | { |
@@ -62,62 +62,62 @@ discard block |
||
62 | 62 | }); |
63 | 63 | '); |
64 | 64 | |
65 | - if (Auth::isAdmin()) { |
|
66 | - $title='<a class="icon-admin" title="'.I18N::translate('Configure').'" href="block_edit.php?block_id='.$block_id.'&ged=' . $tree->getNameHtml() . '&ctype=gedcom"></a>'; |
|
67 | - } else { |
|
68 | - $title=''; |
|
69 | - } |
|
70 | - $title .='<span dir="auto">'.$tree->getTitleHtml().'</span>'; |
|
65 | + if (Auth::isAdmin()) { |
|
66 | + $title='<a class="icon-admin" title="'.I18N::translate('Configure').'" href="block_edit.php?block_id='.$block_id.'&ged=' . $tree->getNameHtml() . '&ctype=gedcom"></a>'; |
|
67 | + } else { |
|
68 | + $title=''; |
|
69 | + } |
|
70 | + $title .='<span dir="auto">'.$tree->getTitleHtml().'</span>'; |
|
71 | 71 | |
72 | - $piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false); |
|
73 | - $view_bag->set('piwik_enabled', $piwik_enabled); |
|
74 | - if($piwik_enabled) { |
|
75 | - $parent_controller->addInlineJavascript( |
|
76 | - '$("#piwik_stats") |
|
72 | + $piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false); |
|
73 | + $view_bag->set('piwik_enabled', $piwik_enabled); |
|
74 | + if($piwik_enabled) { |
|
75 | + $parent_controller->addInlineJavascript( |
|
76 | + '$("#piwik_stats") |
|
77 | 77 | .load("module.php?mod='.$this->module->getName().'&mod_action=Piwik&block_id='.$block_id.'");' |
78 | - ); |
|
79 | - } |
|
78 | + ); |
|
79 | + } |
|
80 | 80 | |
81 | - $content = ViewFactory::make('WelcomeBlock', $this, new BaseController(), $view_bag)->getHtmlPartial(); |
|
81 | + $content = ViewFactory::make('WelcomeBlock', $this, new BaseController(), $view_bag)->getHtmlPartial(); |
|
82 | 82 | |
83 | - if ($template) { |
|
84 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
85 | - } else { |
|
86 | - return $content; |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
83 | + if ($template) { |
|
84 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
85 | + } else { |
|
86 | + return $content; |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * WelcomeBlock@config |
|
95 | - * |
|
96 | - * @param string $block_id |
|
97 | - */ |
|
98 | - public function config($block_id) { |
|
93 | + /** |
|
94 | + * WelcomeBlock@config |
|
95 | + * |
|
96 | + * @param string $block_id |
|
97 | + */ |
|
98 | + public function config($block_id) { |
|
99 | 99 | |
100 | - if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
101 | - $this->module->setBlockSetting($block_id, 'piwik_enabled', Filter::postBool('piwik_enabled')); |
|
102 | - $this->module->setBlockSetting($block_id, 'piwik_url', trim(Filter::postUrl('piwik_url'))); |
|
103 | - $this->module->setBlockSetting($block_id, 'piwik_siteid', trim(Filter::post('piwik_siteid'))); |
|
104 | - $this->module->setBlockSetting($block_id, 'piwik_token', trim(Filter::post('piwik_token'))); |
|
105 | - throw new MvcException(200); // Use this instead of exit |
|
106 | - } |
|
100 | + if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
101 | + $this->module->setBlockSetting($block_id, 'piwik_enabled', Filter::postBool('piwik_enabled')); |
|
102 | + $this->module->setBlockSetting($block_id, 'piwik_url', trim(Filter::postUrl('piwik_url'))); |
|
103 | + $this->module->setBlockSetting($block_id, 'piwik_siteid', trim(Filter::post('piwik_siteid'))); |
|
104 | + $this->module->setBlockSetting($block_id, 'piwik_token', trim(Filter::post('piwik_token'))); |
|
105 | + throw new MvcException(200); // Use this instead of exit |
|
106 | + } |
|
107 | 107 | |
108 | - $view_bag = new ViewBag(); |
|
108 | + $view_bag = new ViewBag(); |
|
109 | 109 | |
110 | - // Is Piwik Statistic Enabled ? |
|
111 | - $view_bag->set('piwik_enabled', $this->module->getBlockSetting($block_id, 'piwik_enabled', '0')); |
|
112 | - //Piwik Root Url |
|
113 | - $view_bag->set('piwik_url', $this->module->getBlockSetting($block_id, 'piwik_url', '')); |
|
114 | - // Piwik token |
|
115 | - $view_bag->set('piwik_token', $this->module->getBlockSetting($block_id, 'piwik_token', '')); |
|
116 | - // Piwik side id |
|
117 | - $view_bag->set('piwik_siteid', $this->module->getBlockSetting($block_id, 'piwik_siteid', '')); |
|
110 | + // Is Piwik Statistic Enabled ? |
|
111 | + $view_bag->set('piwik_enabled', $this->module->getBlockSetting($block_id, 'piwik_enabled', '0')); |
|
112 | + //Piwik Root Url |
|
113 | + $view_bag->set('piwik_url', $this->module->getBlockSetting($block_id, 'piwik_url', '')); |
|
114 | + // Piwik token |
|
115 | + $view_bag->set('piwik_token', $this->module->getBlockSetting($block_id, 'piwik_token', '')); |
|
116 | + // Piwik side id |
|
117 | + $view_bag->set('piwik_siteid', $this->module->getBlockSetting($block_id, 'piwik_siteid', '')); |
|
118 | 118 | |
119 | - ViewFactory::make('WelcomeBlockConfig', $this, new BaseController(), $view_bag)->renderPartial(); |
|
120 | - } |
|
119 | + ViewFactory::make('WelcomeBlockConfig', $this, new BaseController(), $view_bag)->renderPartial(); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | 123 |
@@ -24,88 +24,88 @@ |
||
24 | 24 | class GeoDispersionModule extends AbstractModule implements ModuleConfigInterface, DependentInterface { |
25 | 25 | |
26 | 26 | // How to update the database schema for this module |
27 | - const SCHEMA_TARGET_VERSION = 1; |
|
28 | - const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
29 | - const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\GeoDispersion\Schema'; |
|
27 | + const SCHEMA_TARGET_VERSION = 1; |
|
28 | + const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
29 | + const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\GeoDispersion\Schema'; |
|
30 | 30 | |
31 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
32 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
31 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
32 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
33 | 33 | |
34 | - /** |
|
35 | - * GeoDispersion analysis provider |
|
36 | - * @var \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider $provider |
|
37 | - */ |
|
38 | - protected $provider; |
|
34 | + /** |
|
35 | + * GeoDispersion analysis provider |
|
36 | + * @var \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider $provider |
|
37 | + */ |
|
38 | + protected $provider; |
|
39 | 39 | |
40 | - /** |
|
41 | - * {@inhericDoc} |
|
42 | - */ |
|
43 | - public function getTitle() { |
|
44 | - return /* I18N: Name of the “Hooks” module */ I18N::translate('Geographical Dispersion'); |
|
45 | - } |
|
40 | + /** |
|
41 | + * {@inhericDoc} |
|
42 | + */ |
|
43 | + public function getTitle() { |
|
44 | + return /* I18N: Name of the “Hooks” module */ I18N::translate('Geographical Dispersion'); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * {@inhericDoc} |
|
49 | - */ |
|
50 | - public function getDescription() { |
|
51 | - return /* I18N: Description of the “Hooks” module */ I18N::translate('Display the geographical dispersion of the root person’s Sosa ancestors.'); |
|
52 | - } |
|
47 | + /** |
|
48 | + * {@inhericDoc} |
|
49 | + */ |
|
50 | + public function getDescription() { |
|
51 | + return /* I18N: Description of the “Hooks” module */ I18N::translate('Display the geographical dispersion of the root person’s Sosa ancestors.'); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inhericDoc} |
|
56 | - */ |
|
57 | - public function modAction($mod_action) { |
|
58 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
54 | + /** |
|
55 | + * {@inhericDoc} |
|
56 | + */ |
|
57 | + public function modAction($mod_action) { |
|
58 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
59 | 59 | |
60 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
61 | - } |
|
60 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * {@inhericDoc} |
|
65 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
66 | - */ |
|
67 | - public function getConfigLink() { |
|
68 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
63 | + /** |
|
64 | + * {@inhericDoc} |
|
65 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
66 | + */ |
|
67 | + public function getConfigLink() { |
|
68 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
69 | 69 | |
70 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | - } |
|
70 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * {@inhericDoc} |
|
75 | - * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
76 | - */ |
|
77 | - public function validatePrerequisites() { |
|
78 | - try { |
|
79 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
73 | + /** |
|
74 | + * {@inhericDoc} |
|
75 | + * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
76 | + */ |
|
77 | + public function validatePrerequisites() { |
|
78 | + try { |
|
79 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
80 | 80 | |
81 | - return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME)); |
|
82 | - } |
|
83 | - catch (\Exception $ex) { } |
|
84 | - return false; |
|
85 | - } |
|
81 | + return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME)); |
|
82 | + } |
|
83 | + catch (\Exception $ex) { } |
|
84 | + return false; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Get the GeoAnalysis Provider (initialise it if not done yet). |
89 | 89 | * |
90 | 90 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider |
91 | 91 | */ |
92 | - public function getProvider() { |
|
93 | - global $WT_TREE; |
|
92 | + public function getProvider() { |
|
93 | + global $WT_TREE; |
|
94 | 94 | |
95 | - if(!$this->provider) { |
|
96 | - $this->provider = new GeoAnalysisProvider($WT_TREE); |
|
97 | - } |
|
98 | - return $this->provider; |
|
99 | - } |
|
95 | + if(!$this->provider) { |
|
96 | + $this->provider = new GeoAnalysisProvider($WT_TREE); |
|
97 | + } |
|
98 | + return $this->provider; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Set the GeoAnalysis Provider. |
103 | 103 | * |
104 | 104 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider |
105 | 105 | */ |
106 | - public function setProvider(GeoAnalysisProvider $provider) { |
|
107 | - $this->provider = $provider; |
|
108 | - } |
|
106 | + public function setProvider(GeoAnalysisProvider $provider) { |
|
107 | + $this->provider = $provider; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | 111 | } |
@@ -79,8 +79,7 @@ |
||
79 | 79 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
80 | 80 | |
81 | 81 | return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME)); |
82 | - } |
|
83 | - catch (\Exception $ex) { } |
|
82 | + } catch (\Exception $ex) { } |
|
84 | 83 | return false; |
85 | 84 | } |
86 | 85 |
@@ -18,40 +18,40 @@ |
||
18 | 18 | */ |
19 | 19 | class JsonController extends BaseController { |
20 | 20 | |
21 | - /** |
|
22 | - * {@inheritDoc} |
|
23 | - * @see \Fisharebest\Webtrees\Controller\BaseController::pageHeader() |
|
24 | - */ |
|
25 | - public function pageHeader() { |
|
26 | - header('Content-Type: application/json'); |
|
27 | - header('Cache-Control: no-cache, must-revalidate'); |
|
28 | - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
|
29 | - // We've displayed the header - display the footer automatically |
|
30 | - register_shutdown_function(array($this, 'pageFooter')); |
|
21 | + /** |
|
22 | + * {@inheritDoc} |
|
23 | + * @see \Fisharebest\Webtrees\Controller\BaseController::pageHeader() |
|
24 | + */ |
|
25 | + public function pageHeader() { |
|
26 | + header('Content-Type: application/json'); |
|
27 | + header('Cache-Control: no-cache, must-revalidate'); |
|
28 | + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
|
29 | + // We've displayed the header - display the footer automatically |
|
30 | + register_shutdown_function(array($this, 'pageFooter')); |
|
31 | 31 | |
32 | - return $this; |
|
33 | - } |
|
32 | + return $this; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritDoc} |
|
37 | - * @see \Fisharebest\Webtrees\Controller\BaseController::pageFooter() |
|
38 | - */ |
|
39 | - public function pageFooter() { |
|
40 | - return $this; |
|
41 | - } |
|
35 | + /** |
|
36 | + * {@inheritDoc} |
|
37 | + * @see \Fisharebest\Webtrees\Controller\BaseController::pageFooter() |
|
38 | + */ |
|
39 | + public function pageFooter() { |
|
40 | + return $this; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Restrict access. |
|
45 | - * |
|
46 | - * @param bool $condition |
|
47 | - * |
|
48 | - * @return $this |
|
49 | - */ |
|
50 | - public function restrictAccess($condition) { |
|
51 | - if ($condition !== true) { |
|
52 | - throw new MvcException(403); |
|
53 | - } |
|
43 | + /** |
|
44 | + * Restrict access. |
|
45 | + * |
|
46 | + * @param bool $condition |
|
47 | + * |
|
48 | + * @return $this |
|
49 | + */ |
|
50 | + public function restrictAccess($condition) { |
|
51 | + if ($condition !== true) { |
|
52 | + throw new MvcException(403); |
|
53 | + } |
|
54 | 54 | |
55 | - return $this; |
|
56 | - } |
|
55 | + return $this; |
|
56 | + } |
|
57 | 57 | } |