@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return string HTML code of the inserted flag |
80 | 80 | */ |
81 | 81 | public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
82 | - return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
82 | + return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return boolean |
356 | 356 | */ |
357 | 357 | public static function isDateWithinChartsRange(Date $date) { |
358 | - return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030; |
|
358 | + return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | if(!$this->gedcomrecord->canShow($access_level)) return false; |
93 | 93 | if($access_level === null ) |
94 | - $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
94 | + $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
|
95 | 95 | |
96 | 96 | if (isset($global_facts['SOUR'])) { |
97 | 97 | return $global_facts['SOUR'] >= $access_level; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return int Level of sources |
130 | 130 | */ |
131 | 131 | public function isFactSourced($eventslist){ |
132 | - if(empty($eventslist)) return 0; |
|
132 | + if(empty($eventslist)) return 0; |
|
133 | 133 | $isSourced=0; |
134 | 134 | $facts = $this->gedcomrecord->getFacts($eventslist); |
135 | 135 | foreach($facts as $fact){ |
@@ -35,47 +35,47 @@ discard block |
||
35 | 35 | */ |
36 | 36 | class GeoAnalysisController extends MvcController |
37 | 37 | { |
38 | - /** |
|
39 | - * GeoAnalysis Provider |
|
40 | - * @var GeoAnalysisProvider $provider |
|
41 | - */ |
|
42 | - protected $provider; |
|
38 | + /** |
|
39 | + * GeoAnalysis Provider |
|
40 | + * @var GeoAnalysisProvider $provider |
|
41 | + */ |
|
42 | + protected $provider; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor for GeoAnalysis controller |
|
46 | - * @param AbstractModule $module |
|
47 | - */ |
|
48 | - public function __construct(AbstractModule $module) { |
|
49 | - parent::__construct($module); |
|
44 | + /** |
|
45 | + * Constructor for GeoAnalysis controller |
|
46 | + * @param AbstractModule $module |
|
47 | + */ |
|
48 | + public function __construct(AbstractModule $module) { |
|
49 | + parent::__construct($module); |
|
50 | 50 | |
51 | - $this->provider = $this->module->getProvider(); |
|
52 | - } |
|
51 | + $this->provider = $this->module->getProvider(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Pages |
|
56 | - */ |
|
54 | + /** |
|
55 | + * Pages |
|
56 | + */ |
|
57 | 57 | |
58 | - /** |
|
59 | - * GeoAnalysis@index |
|
60 | - */ |
|
61 | - public function index() { |
|
58 | + /** |
|
59 | + * GeoAnalysis@index |
|
60 | + */ |
|
61 | + public function index() { |
|
62 | 62 | |
63 | - $controller = new PageController(); |
|
64 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
63 | + $controller = new PageController(); |
|
64 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
65 | 65 | |
66 | - $data = new ViewBag(); |
|
67 | - $data->set('title', $controller->getPageTitle()); |
|
68 | - $data->set('has_analysis', false); |
|
66 | + $data = new ViewBag(); |
|
67 | + $data->set('title', $controller->getPageTitle()); |
|
68 | + $data->set('has_analysis', false); |
|
69 | 69 | |
70 | - $ga_id = Filter::getInteger('ga_id'); |
|
70 | + $ga_id = Filter::getInteger('ga_id'); |
|
71 | 71 | |
72 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
73 | - $data->set('has_analysis', true); |
|
74 | - $data->set('geoanalysis', $ga); |
|
72 | + if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
73 | + $data->set('has_analysis', true); |
|
74 | + $data->set('geoanalysis', $ga); |
|
75 | 75 | |
76 | - $controller |
|
77 | - ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
78 | - ->addInlineJavascript(' |
|
76 | + $controller |
|
77 | + ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
78 | + ->addInlineJavascript(' |
|
79 | 79 | jQuery("#geodispersion-tabs").tabs(); |
80 | 80 | jQuery("#geodispersion-tabs").css("visibility", "visible"); |
81 | 81 | |
@@ -96,133 +96,133 @@ discard block |
||
96 | 96 | "json" |
97 | 97 | ); |
98 | 98 | '); |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | - ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
102 | - } |
|
101 | + ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * GeoAnalysis@listAll |
|
106 | - */ |
|
107 | - public function listAll() { |
|
104 | + /** |
|
105 | + * GeoAnalysis@listAll |
|
106 | + */ |
|
107 | + public function listAll() { |
|
108 | 108 | |
109 | - $controller = new PageController(); |
|
110 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
109 | + $controller = new PageController(); |
|
110 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
111 | 111 | |
112 | - $data = new ViewBag(); |
|
113 | - $data->set('title', $controller->getPageTitle()); |
|
114 | - $data->set('has_list', false); |
|
112 | + $data = new ViewBag(); |
|
113 | + $data->set('title', $controller->getPageTitle()); |
|
114 | + $data->set('has_list', false); |
|
115 | 115 | |
116 | - $ga_list = $this->provider->getGeoAnalysisList(); |
|
117 | - if(count($ga_list) > 0 ) { |
|
118 | - $data->set('has_list', true); |
|
119 | - $data->set('geoanalysislist', $ga_list); |
|
120 | - } |
|
116 | + $ga_list = $this->provider->getGeoAnalysisList(); |
|
117 | + if(count($ga_list) > 0 ) { |
|
118 | + $data->set('has_list', true); |
|
119 | + $data->set('geoanalysislist', $ga_list); |
|
120 | + } |
|
121 | 121 | |
122 | - ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
123 | - } |
|
122 | + ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
123 | + } |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * GeoAnalysis@setStatus |
127 | 127 | */ |
128 | - public function setStatus() { |
|
129 | - global $WT_TREE; |
|
128 | + public function setStatus() { |
|
129 | + global $WT_TREE; |
|
130 | 130 | |
131 | - $controller = new JsonController(); |
|
131 | + $controller = new JsonController(); |
|
132 | 132 | |
133 | - $ga_id = Filter::getInteger('ga_id'); |
|
134 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
133 | + $ga_id = Filter::getInteger('ga_id'); |
|
134 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
135 | 135 | |
136 | - $controller->restrictAccess( |
|
137 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
138 | - && Auth::isManager($WT_TREE) |
|
139 | - && $ga !== null |
|
140 | - ); |
|
136 | + $controller->restrictAccess( |
|
137 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
138 | + && Auth::isManager($WT_TREE) |
|
139 | + && $ga !== null |
|
140 | + ); |
|
141 | 141 | |
142 | - $status = Filter::getBool('status'); |
|
143 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
144 | - try{ |
|
145 | - $this->provider->setGeoAnalysisStatus($ga, $status); |
|
146 | - $res['status'] = $status; |
|
142 | + $status = Filter::getBool('status'); |
|
143 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
144 | + try{ |
|
145 | + $this->provider->setGeoAnalysisStatus($ga, $status); |
|
146 | + $res['status'] = $status; |
|
147 | 147 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
148 | - } |
|
149 | - catch (\Exception $ex) { |
|
150 | - $res['error'] = $ex->getMessage(); |
|
148 | + } |
|
149 | + catch (\Exception $ex) { |
|
150 | + $res['error'] = $ex->getMessage(); |
|
151 | 151 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
152 | - } |
|
152 | + } |
|
153 | 153 | |
154 | - $controller->pageHeader(); |
|
155 | - if($res['error']) http_response_code(500); |
|
154 | + $controller->pageHeader(); |
|
155 | + if($res['error']) http_response_code(500); |
|
156 | 156 | |
157 | - echo \Zend_Json::encode($res); |
|
158 | - } |
|
157 | + echo \Zend_Json::encode($res); |
|
158 | + } |
|
159 | 159 | |
160 | 160 | /** |
161 | - * GeoAnalysis@delete |
|
162 | - */ |
|
163 | - public function delete() { |
|
164 | - global $WT_TREE; |
|
161 | + * GeoAnalysis@delete |
|
162 | + */ |
|
163 | + public function delete() { |
|
164 | + global $WT_TREE; |
|
165 | 165 | |
166 | - $controller = new JsonController(); |
|
166 | + $controller = new JsonController(); |
|
167 | 167 | |
168 | - $ga_id = Filter::getInteger('ga_id'); |
|
169 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
168 | + $ga_id = Filter::getInteger('ga_id'); |
|
169 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
170 | 170 | |
171 | - $controller->restrictAccess( |
|
172 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
173 | - && Auth::isManager($WT_TREE) |
|
174 | - && $ga |
|
175 | - ); |
|
171 | + $controller->restrictAccess( |
|
172 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
173 | + && Auth::isManager($WT_TREE) |
|
174 | + && $ga |
|
175 | + ); |
|
176 | 176 | |
177 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
178 | - try{ |
|
179 | - $this->provider->deleteGeoAnalysis($ga); |
|
177 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
178 | + try{ |
|
179 | + $this->provider->deleteGeoAnalysis($ga); |
|
180 | 180 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
181 | - } |
|
182 | - catch (\Exception $ex) { |
|
183 | - $res['error'] = $ex->getMessage(); |
|
181 | + } |
|
182 | + catch (\Exception $ex) { |
|
183 | + $res['error'] = $ex->getMessage(); |
|
184 | 184 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - $controller->pageHeader(); |
|
188 | - if($res['error']) http_response_code(500); |
|
187 | + $controller->pageHeader(); |
|
188 | + if($res['error']) http_response_code(500); |
|
189 | 189 | |
190 | - echo \Zend_Json::encode($res); |
|
191 | - } |
|
190 | + echo \Zend_Json::encode($res); |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * GeoAnalysis@dataTabs |
|
195 | - */ |
|
196 | - public function dataTabs() { |
|
197 | - global $WT_TREE; |
|
193 | + /** |
|
194 | + * GeoAnalysis@dataTabs |
|
195 | + */ |
|
196 | + public function dataTabs() { |
|
197 | + global $WT_TREE; |
|
198 | 198 | |
199 | - $controller = new JsonController(); |
|
199 | + $controller = new JsonController(); |
|
200 | 200 | |
201 | - $ga_id = Filter::getInteger('ga_id'); |
|
202 | - $ga = $this->provider->getGeoAnalysis($ga_id); |
|
203 | - $sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
201 | + $ga_id = Filter::getInteger('ga_id'); |
|
202 | + $ga = $this->provider->getGeoAnalysis($ga_id); |
|
203 | + $sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
204 | 204 | |
205 | - $controller |
|
206 | - ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
207 | - ->pageHeader(); |
|
205 | + $controller |
|
206 | + ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
207 | + ->pageHeader(); |
|
208 | 208 | |
209 | - $jsonArray = array(); |
|
209 | + $jsonArray = array(); |
|
210 | 210 | |
211 | - list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
211 | + list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
212 | 212 | |
213 | - $flags = array(); |
|
214 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
215 | - $mapProvider = new GoogleMapsProvider(); |
|
216 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
217 | - $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); |
|
218 | - } |
|
219 | - } |
|
213 | + $flags = array(); |
|
214 | + if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
215 | + $mapProvider = new GoogleMapsProvider(); |
|
216 | + foreach($placesDispGeneral['places'] as $place => $count) { |
|
217 | + $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
222 | - $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
221 | + $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
222 | + $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
223 | 223 | |
224 | - echo \Zend_Json::encode($jsonArray); |
|
225 | - } |
|
224 | + echo \Zend_Json::encode($jsonArray); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | /** |
228 | 228 | * Returns HTML code for the GeoAnalysis general tab (can be either a map or a table). |
@@ -232,70 +232,70 @@ discard block |
||
232 | 232 | * @param (null|array) $flags Array of flags |
233 | 233 | * @return string HTML code for the general tab |
234 | 234 | */ |
235 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
236 | - global $WT_TREE; |
|
235 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
236 | + global $WT_TREE; |
|
237 | 237 | |
238 | - if(!empty($placesGeneralResults)){ |
|
239 | - $data = new ViewBag(); |
|
238 | + if(!empty($placesGeneralResults)){ |
|
239 | + $data = new ViewBag(); |
|
240 | 240 | |
241 | - $nb_found = $placesGeneralResults['knownsum']; |
|
242 | - $nb_other = 0; |
|
243 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
244 | - $nb_unknown = $placesGeneralResults['unknown']; |
|
241 | + $nb_found = $placesGeneralResults['knownsum']; |
|
242 | + $nb_other = 0; |
|
243 | + if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
244 | + $nb_unknown = $placesGeneralResults['unknown']; |
|
245 | 245 | |
246 | - $data->set('stats_gen_nb_found', $nb_found); |
|
247 | - $data->set('stats_gen_nb_other', $nb_other); |
|
248 | - $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
246 | + $data->set('stats_gen_nb_found', $nb_found); |
|
247 | + $data->set('stats_gen_nb_other', $nb_other); |
|
248 | + $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
249 | 249 | |
250 | - $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
250 | + $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
251 | 251 | |
252 | - if($ga->hasMap()) { |
|
253 | - $max = $placesGeneralResults['max']; |
|
254 | - $map = $ga->getOptions()->getMap(); |
|
255 | - $results_by_subdivs = $map->getSubdivisions(); |
|
256 | - $places_mappings = $map->getPlacesMappings(); |
|
257 | - foreach ($placesGeneralResults['places'] as $location => $count) { |
|
258 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
259 | - $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
260 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
261 | - $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
262 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
263 | - } |
|
264 | - else { |
|
265 | - $levelref = $levelvalues[0]; |
|
266 | - } |
|
267 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
268 | - if(isset($results_by_subdivs[$levelref])) { |
|
269 | - $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
270 | - $count_subd += $count; |
|
271 | - $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
272 | - $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
273 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
274 | - $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE); |
|
275 | - $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
276 | - } |
|
277 | - } |
|
278 | - } |
|
252 | + if($ga->hasMap()) { |
|
253 | + $max = $placesGeneralResults['max']; |
|
254 | + $map = $ga->getOptions()->getMap(); |
|
255 | + $results_by_subdivs = $map->getSubdivisions(); |
|
256 | + $places_mappings = $map->getPlacesMappings(); |
|
257 | + foreach ($placesGeneralResults['places'] as $location => $count) { |
|
258 | + $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
259 | + $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
260 | + if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
261 | + $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
262 | + if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
263 | + } |
|
264 | + else { |
|
265 | + $levelref = $levelvalues[0]; |
|
266 | + } |
|
267 | + if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
268 | + if(isset($results_by_subdivs[$levelref])) { |
|
269 | + $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
270 | + $count_subd += $count; |
|
271 | + $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
272 | + $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
273 | + if($ga->getOptions()->isUsingFlags() && $flags) { |
|
274 | + $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE); |
|
275 | + $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
276 | + } |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | - $data->set('map', $ga->getOptions()->getMap()); |
|
281 | - $data->set('results_by_subdivisions', $results_by_subdivs); |
|
280 | + $data->set('map', $ga->getOptions()->getMap()); |
|
281 | + $data->set('results_by_subdivisions', $results_by_subdivs); |
|
282 | 282 | |
283 | - $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
284 | - } |
|
285 | - else { |
|
286 | - $results = $placesGeneralResults['places']; |
|
287 | - arsort($results); |
|
288 | - $data->set('results', $results); |
|
289 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
283 | + $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
284 | + } |
|
285 | + else { |
|
286 | + $results = $placesGeneralResults['places']; |
|
287 | + arsort($results); |
|
288 | + $data->set('results', $results); |
|
289 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
290 | 290 | |
291 | - $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
292 | - } |
|
293 | - } |
|
294 | - else { |
|
295 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
296 | - } |
|
297 | - return $html; |
|
298 | - } |
|
291 | + $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
292 | + } |
|
293 | + } |
|
294 | + else { |
|
295 | + $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
296 | + } |
|
297 | + return $html; |
|
298 | + } |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Returns HTML code for the GeoAnalysis generations tab. |
@@ -305,68 +305,68 @@ discard block |
||
305 | 305 | * @param (null|array) $flags Array of flags |
306 | 306 | * @return string HTML code for the generations tab |
307 | 307 | */ |
308 | - protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
309 | - global $WT_TREE; |
|
308 | + protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
309 | + global $WT_TREE; |
|
310 | 310 | |
311 | - if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
312 | - $data = new ViewBag(); |
|
311 | + if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
312 | + $data = new ViewBag(); |
|
313 | 313 | |
314 | - ksort($placesGenerationsResults); |
|
314 | + ksort($placesGenerationsResults); |
|
315 | 315 | |
316 | - $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
317 | - $data->set('max_details_gen', $detailslevel); |
|
318 | - $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
319 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
320 | - $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
321 | - $data->set('display_all_places', $display_all_places); |
|
316 | + $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
317 | + $data->set('max_details_gen', $detailslevel); |
|
318 | + $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
319 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
320 | + $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
321 | + $data->set('display_all_places', $display_all_places); |
|
322 | 322 | |
323 | - $results_by_gen = array(); |
|
324 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
325 | - $sum = 0; |
|
326 | - $other = 0; |
|
327 | - $unknown = 0; |
|
328 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
329 | - if(isset($genData['other'])) $other = $genData['other']; |
|
330 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
323 | + $results_by_gen = array(); |
|
324 | + foreach($placesGenerationsResults as $gen => $genData){ |
|
325 | + $sum = 0; |
|
326 | + $other = 0; |
|
327 | + $unknown = 0; |
|
328 | + if(isset($genData['sum'])) $sum = $genData['sum']; |
|
329 | + if(isset($genData['other'])) $other = $genData['other']; |
|
330 | + if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
331 | 331 | |
332 | - if($sum > 0) { |
|
333 | - $results_by_gen[$gen]['sum'] = $sum; |
|
334 | - $results_by_gen[$gen]['other'] = $other; |
|
335 | - $results_by_gen[$gen]['unknown'] = $unknown; |
|
336 | - $results_by_gen[$gen]['places'] = array(); |
|
337 | - arsort($genData['places']); |
|
332 | + if($sum > 0) { |
|
333 | + $results_by_gen[$gen]['sum'] = $sum; |
|
334 | + $results_by_gen[$gen]['other'] = $other; |
|
335 | + $results_by_gen[$gen]['unknown'] = $unknown; |
|
336 | + $results_by_gen[$gen]['places'] = array(); |
|
337 | + arsort($genData['places']); |
|
338 | 338 | |
339 | - if($display_all_places){ |
|
340 | - foreach($genData['places'] as $placename=> $count){ |
|
341 | - $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
339 | + if($display_all_places){ |
|
340 | + foreach($genData['places'] as $placename=> $count){ |
|
341 | + $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
342 | 342 | |
343 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
344 | - $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE); |
|
345 | - $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
346 | - } |
|
347 | - } |
|
348 | - } |
|
349 | - else { |
|
350 | - $tmp = $genData['places']; |
|
351 | - if($other > 0) { |
|
352 | - $tmp = array_slice($tmp, 0, 5, true); |
|
353 | - $tmp['other'] = $other; |
|
354 | - arsort($tmp); |
|
355 | - } |
|
356 | - $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
357 | - } |
|
358 | - } |
|
359 | - } |
|
343 | + if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
344 | + $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE); |
|
345 | + $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
346 | + } |
|
347 | + } |
|
348 | + } |
|
349 | + else { |
|
350 | + $tmp = $genData['places']; |
|
351 | + if($other > 0) { |
|
352 | + $tmp = array_slice($tmp, 0, 5, true); |
|
353 | + $tmp['other'] = $other; |
|
354 | + arsort($tmp); |
|
355 | + } |
|
356 | + $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
357 | + } |
|
358 | + } |
|
359 | + } |
|
360 | 360 | |
361 | - $data->set('results_by_generations', $results_by_gen); |
|
361 | + $data->set('results_by_generations', $results_by_gen); |
|
362 | 362 | |
363 | - $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
363 | + $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
364 | 364 | |
365 | - } |
|
366 | - else { |
|
367 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
368 | - } |
|
369 | - return $html; |
|
370 | - } |
|
365 | + } |
|
366 | + else { |
|
367 | + $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
368 | + } |
|
369 | + return $html; |
|
370 | + } |
|
371 | 371 | |
372 | 372 | } |
373 | 373 | \ No newline at end of file |
@@ -32,158 +32,158 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class CertificateController extends MvcController |
34 | 34 | { |
35 | - /** |
|
36 | - * Certificate Provider |
|
37 | - * @var CertificateProviderInterface $provider |
|
38 | - */ |
|
39 | - protected $provider; |
|
35 | + /** |
|
36 | + * Certificate Provider |
|
37 | + * @var CertificateProviderInterface $provider |
|
38 | + */ |
|
39 | + protected $provider; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor for Certificate controller |
|
43 | - * @param AbstractModule $module |
|
44 | - */ |
|
45 | - public function __construct(AbstractModule $module) { |
|
46 | - parent::__construct($module); |
|
47 | - |
|
48 | - $this->provider = $this->module->getProvider(); |
|
49 | - } |
|
41 | + /** |
|
42 | + * Constructor for Certificate controller |
|
43 | + * @param AbstractModule $module |
|
44 | + */ |
|
45 | + public function __construct(AbstractModule $module) { |
|
46 | + parent::__construct($module); |
|
47 | + |
|
48 | + $this->provider = $this->module->getProvider(); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Pages |
|
54 | - */ |
|
55 | - |
|
56 | - /** |
|
57 | - * Certificate@index |
|
58 | - */ |
|
59 | - public function index() { |
|
60 | - global $WT_TREE; |
|
61 | - |
|
62 | - $controller = new PageController(); |
|
63 | - $controller |
|
64 | - ->setPageTitle(I18N::translate('Certificate')) |
|
65 | - ->restrictAccess( |
|
66 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
67 | - ); |
|
68 | - |
|
69 | - $cid = Filter::get('cid'); |
|
70 | - |
|
71 | - $certificate = null; |
|
72 | - if(!empty($cid) && strlen($cid) > 22){ |
|
73 | - $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
74 | - } |
|
75 | - |
|
76 | - $data = new ViewBag(); |
|
77 | - $data->set('title', $controller->getPageTitle()); |
|
78 | - |
|
79 | - $data->set('has_certif', false); |
|
80 | - if($certificate) { |
|
81 | - $controller->restrictAccess($certificate->canShow()); |
|
82 | - $data->set('title', $certificate->getTitle()); |
|
83 | - $data->set('has_certif', true); |
|
84 | - $data->set('certificate', $certificate); |
|
52 | + /** |
|
53 | + * Pages |
|
54 | + */ |
|
55 | + |
|
56 | + /** |
|
57 | + * Certificate@index |
|
58 | + */ |
|
59 | + public function index() { |
|
60 | + global $WT_TREE; |
|
61 | + |
|
62 | + $controller = new PageController(); |
|
63 | + $controller |
|
64 | + ->setPageTitle(I18N::translate('Certificate')) |
|
65 | + ->restrictAccess( |
|
66 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
67 | + ); |
|
68 | + |
|
69 | + $cid = Filter::get('cid'); |
|
70 | + |
|
71 | + $certificate = null; |
|
72 | + if(!empty($cid) && strlen($cid) > 22){ |
|
73 | + $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
74 | + } |
|
75 | + |
|
76 | + $data = new ViewBag(); |
|
77 | + $data->set('title', $controller->getPageTitle()); |
|
78 | + |
|
79 | + $data->set('has_certif', false); |
|
80 | + if($certificate) { |
|
81 | + $controller->restrictAccess($certificate->canShow()); |
|
82 | + $data->set('title', $certificate->getTitle()); |
|
83 | + $data->set('has_certif', true); |
|
84 | + $data->set('certificate', $certificate); |
|
85 | 85 | |
86 | - $data->set( |
|
87 | - 'url_certif_city', |
|
88 | - 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
89 | - '&mod_action=Certificate@listAll' . |
|
90 | - '&ged=' . $WT_TREE->getNameUrl() . |
|
91 | - '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
92 | - ); |
|
86 | + $data->set( |
|
87 | + 'url_certif_city', |
|
88 | + 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
89 | + '&mod_action=Certificate@listAll' . |
|
90 | + '&ged=' . $WT_TREE->getNameUrl() . |
|
91 | + '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
92 | + ); |
|
93 | 93 | |
94 | - $controller->addInlineJavascript(' |
|
94 | + $controller->addInlineJavascript(' |
|
95 | 95 | jQuery("#certificate-tabs").tabs(); |
96 | 96 | jQuery("#certificate-tabs").css("visibility", "visible"); |
97 | 97 | '); |
98 | 98 | |
99 | - $data->set('has_linked_indis', false); |
|
100 | - $data->set('has_linked_fams', false); |
|
99 | + $data->set('has_linked_indis', false); |
|
100 | + $data->set('has_linked_fams', false); |
|
101 | 101 | |
102 | - $linked_indis = $certificate->linkedIndividuals(); |
|
103 | - $linked_fams = $certificate->linkedFamilies(); |
|
102 | + $linked_indis = $certificate->linkedIndividuals(); |
|
103 | + $linked_fams = $certificate->linkedFamilies(); |
|
104 | 104 | |
105 | - if($linked_indis && count($linked_indis) > 0) { |
|
106 | - $data->set('has_linked_indis', true); |
|
107 | - $data->set('linked_indis', $linked_indis); |
|
108 | - } |
|
105 | + if($linked_indis && count($linked_indis) > 0) { |
|
106 | + $data->set('has_linked_indis', true); |
|
107 | + $data->set('linked_indis', $linked_indis); |
|
108 | + } |
|
109 | 109 | |
110 | - if(!empty($linked_fams)) { |
|
111 | - $data->set('has_linked_fams', true); |
|
112 | - $data->set('linked_fams', $linked_fams); |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
117 | - } |
|
110 | + if(!empty($linked_fams)) { |
|
111 | + $data->set('has_linked_fams', true); |
|
112 | + $data->set('linked_fams', $linked_fams); |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Certificate@image |
|
121 | - */ |
|
122 | - public function image() { |
|
123 | - global $WT_TREE; |
|
119 | + /** |
|
120 | + * Certificate@image |
|
121 | + */ |
|
122 | + public function image() { |
|
123 | + global $WT_TREE; |
|
124 | 124 | |
125 | - $cid = Filter::get('cid'); |
|
126 | - $certificate = null; |
|
127 | - if(!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
125 | + $cid = Filter::get('cid'); |
|
126 | + $certificate = null; |
|
127 | + if(!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
128 | 128 | |
129 | - $imageBuilder = new ImageBuilder($certificate); |
|
129 | + $imageBuilder = new ImageBuilder($certificate); |
|
130 | 130 | |
131 | - if (!empty(Filter::get('cb'))) { |
|
132 | - $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
133 | - } |
|
131 | + if (!empty(Filter::get('cb'))) { |
|
132 | + $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
133 | + } |
|
134 | 134 | |
135 | - $imageBuilder |
|
136 | - ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
137 | - ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
138 | - ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
139 | - ; |
|
135 | + $imageBuilder |
|
136 | + ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
137 | + ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
138 | + ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
139 | + ; |
|
140 | 140 | |
141 | - $imageBuilder->render(); |
|
141 | + $imageBuilder->render(); |
|
142 | 142 | |
143 | - } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Certificate@listAll |
|
147 | - */ |
|
148 | - public function listAll() { |
|
149 | - global $WT_TREE; |
|
150 | - |
|
151 | - $controller = new PageController(); |
|
152 | - $controller |
|
153 | - ->setPageTitle(I18N::translate('Certificates')) |
|
154 | - ->restrictAccess( |
|
155 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
156 | - ); |
|
157 | - |
|
158 | - $city = Filter::get('city'); |
|
159 | - |
|
160 | - if(!empty($city) && strlen($city) > 22){ |
|
161 | - $city = Functions::decryptFromSafeBase64($city); |
|
162 | - $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
163 | - } |
|
164 | - |
|
165 | - $data = new ViewBag(); |
|
166 | - $data->set('title', $controller->getPageTitle()); |
|
167 | - $data->set('url_module', $this->module->getName()); |
|
168 | - $data->set('url_action', 'Certificate@listAll'); |
|
169 | - $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
170 | - |
|
171 | - $data->set('cities', $this->provider->getCitiesList()); |
|
172 | - $data->set('selected_city', $city); |
|
173 | - |
|
174 | - $data->set('has_list', false); |
|
175 | - if(!empty($city)) { |
|
176 | - $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
145 | + /** |
|
146 | + * Certificate@listAll |
|
147 | + */ |
|
148 | + public function listAll() { |
|
149 | + global $WT_TREE; |
|
150 | + |
|
151 | + $controller = new PageController(); |
|
152 | + $controller |
|
153 | + ->setPageTitle(I18N::translate('Certificates')) |
|
154 | + ->restrictAccess( |
|
155 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
156 | + ); |
|
157 | + |
|
158 | + $city = Filter::get('city'); |
|
159 | + |
|
160 | + if(!empty($city) && strlen($city) > 22){ |
|
161 | + $city = Functions::decryptFromSafeBase64($city); |
|
162 | + $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
163 | + } |
|
164 | + |
|
165 | + $data = new ViewBag(); |
|
166 | + $data->set('title', $controller->getPageTitle()); |
|
167 | + $data->set('url_module', $this->module->getName()); |
|
168 | + $data->set('url_action', 'Certificate@listAll'); |
|
169 | + $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
170 | + |
|
171 | + $data->set('cities', $this->provider->getCitiesList()); |
|
172 | + $data->set('selected_city', $city); |
|
173 | + |
|
174 | + $data->set('has_list', false); |
|
175 | + if(!empty($city)) { |
|
176 | + $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
177 | 177 | |
178 | - $certif_list = $this->provider->getCertificatesList($city); |
|
179 | - if(!empty($certif_list)) { |
|
180 | - $data->set('has_list', true); |
|
181 | - $data->set('table_id', $table_id); |
|
182 | - $data->set('certificate_list', $certif_list); |
|
178 | + $certif_list = $this->provider->getCertificatesList($city); |
|
179 | + if(!empty($certif_list)) { |
|
180 | + $data->set('has_list', true); |
|
181 | + $data->set('table_id', $table_id); |
|
182 | + $data->set('certificate_list', $certif_list); |
|
183 | 183 | |
184 | - $controller |
|
185 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
186 | - ->addInlineJavascript(' |
|
184 | + $controller |
|
185 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
186 | + ->addInlineJavascript(' |
|
187 | 187 | /* Initialise datatables */ |
188 | 188 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
189 | 189 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -210,29 +210,29 @@ discard block |
||
210 | 210 | jQuery(".certificate-list").css("visibility", "visible"); |
211 | 211 | jQuery(".loading-image").css("display", "none"); |
212 | 212 | '); |
213 | - } |
|
214 | - } |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
216 | + ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
217 | 217 | |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * Certificate@autocomplete |
|
222 | - */ |
|
223 | - public function autocomplete() { |
|
224 | - global $WT_TREE; |
|
220 | + /** |
|
221 | + * Certificate@autocomplete |
|
222 | + */ |
|
223 | + public function autocomplete() { |
|
224 | + global $WT_TREE; |
|
225 | 225 | |
226 | - $controller = new JsonController(); |
|
226 | + $controller = new JsonController(); |
|
227 | 227 | |
228 | - $city = Filter::get('city'); |
|
229 | - $contains = Filter::get('term'); |
|
228 | + $city = Filter::get('city'); |
|
229 | + $contains = Filter::get('term'); |
|
230 | 230 | |
231 | - $controller |
|
232 | - ->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains)) |
|
233 | - ->pageHeader(); |
|
231 | + $controller |
|
232 | + ->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains)) |
|
233 | + ->pageHeader(); |
|
234 | 234 | |
235 | - $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
236 | - echo \Zend_Json::encode($listCert); |
|
237 | - } |
|
235 | + $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
236 | + echo \Zend_Json::encode($listCert); |
|
237 | + } |
|
238 | 238 | } |
239 | 239 | \ No newline at end of file |
@@ -19,118 +19,118 @@ |
||
19 | 19 | */ |
20 | 20 | class SosaCalculator { |
21 | 21 | |
22 | - /** |
|
23 | - * Maximium size for the temporary Sosa table |
|
24 | - * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | - */ |
|
26 | - const TMP_SOSA_TABLE_LIMIT = 1000; |
|
22 | + /** |
|
23 | + * Maximium size for the temporary Sosa table |
|
24 | + * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | + */ |
|
26 | + const TMP_SOSA_TABLE_LIMIT = 1000; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reference user |
|
30 | - * @var Fisharebest\Webtrees\User $user |
|
31 | - */ |
|
32 | - protected $user; |
|
28 | + /** |
|
29 | + * Reference user |
|
30 | + * @var Fisharebest\Webtrees\User $user |
|
31 | + */ |
|
32 | + protected $user; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Reference tree |
|
36 | - * @var Fisharebest\Webtrees\Tree $tree |
|
37 | - */ |
|
38 | - protected $tree; |
|
34 | + /** |
|
35 | + * Reference tree |
|
36 | + * @var Fisharebest\Webtrees\Tree $tree |
|
37 | + */ |
|
38 | + protected $tree; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Sosa Provider for the calculator |
|
42 | - * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | - */ |
|
44 | - protected $sosa_provider; |
|
40 | + /** |
|
41 | + * Sosa Provider for the calculator |
|
42 | + * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | + */ |
|
44 | + protected $sosa_provider; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Temporary Sosa table, used during construction |
|
48 | - * @var array $tmp_sosa_table |
|
49 | - */ |
|
50 | - protected $tmp_sosa_table; |
|
46 | + /** |
|
47 | + * Temporary Sosa table, used during construction |
|
48 | + * @var array $tmp_sosa_table |
|
49 | + */ |
|
50 | + protected $tmp_sosa_table; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Constructor for the Sosa Calculator |
|
54 | - * @param Tree $tree |
|
55 | - * @param User $user |
|
56 | - */ |
|
57 | - public function __construct(Tree $tree, User $user) { |
|
58 | - $this->tree = $tree; |
|
59 | - $this->user = $user; |
|
52 | + /** |
|
53 | + * Constructor for the Sosa Calculator |
|
54 | + * @param Tree $tree |
|
55 | + * @param User $user |
|
56 | + */ |
|
57 | + public function __construct(Tree $tree, User $user) { |
|
58 | + $this->tree = $tree; |
|
59 | + $this->user = $user; |
|
60 | 60 | |
61 | - $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | - } |
|
61 | + $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Compute all Sosa ancestors from the user's root individual. |
|
66 | - * @return bool Result of the computation |
|
67 | - */ |
|
68 | - public function computeAll() { |
|
69 | - $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | - $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | - if($indi){ |
|
72 | - $this->sosa_provider->deleteAll(); |
|
73 | - $tmp_sosatable = array(); |
|
74 | - $this->addNode($indi, 1); |
|
75 | - $this->flushTmpSosaTable(true); |
|
76 | - return true; |
|
77 | - } |
|
78 | - return false; |
|
79 | - } |
|
64 | + /** |
|
65 | + * Compute all Sosa ancestors from the user's root individual. |
|
66 | + * @return bool Result of the computation |
|
67 | + */ |
|
68 | + public function computeAll() { |
|
69 | + $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | + $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | + if($indi){ |
|
72 | + $this->sosa_provider->deleteAll(); |
|
73 | + $tmp_sosatable = array(); |
|
74 | + $this->addNode($indi, 1); |
|
75 | + $this->flushTmpSosaTable(true); |
|
76 | + return true; |
|
77 | + } |
|
78 | + return false; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Compute all Sosa Ancestors from a specified Individual |
|
83 | - * @param Individual $indi |
|
84 | - * @return bool Result of the computation |
|
85 | - */ |
|
86 | - public function computeFromIndividual(Individual $indi) { |
|
87 | - $tmp_sosatable = array(); |
|
88 | - $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
89 | - $current_sosas = $dindi->getSosaNumbers(); |
|
90 | - foreach($current_sosas as $current_sosa => $gen) { |
|
91 | - $this->sosa_provider->deleteAncestors($current_sosa); |
|
92 | - $this->addNode($indi, $current_sosa); |
|
93 | - } |
|
94 | - $this->flushTmpSosaTable(true); |
|
95 | - return true; |
|
96 | - } |
|
81 | + /** |
|
82 | + * Compute all Sosa Ancestors from a specified Individual |
|
83 | + * @param Individual $indi |
|
84 | + * @return bool Result of the computation |
|
85 | + */ |
|
86 | + public function computeFromIndividual(Individual $indi) { |
|
87 | + $tmp_sosatable = array(); |
|
88 | + $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
89 | + $current_sosas = $dindi->getSosaNumbers(); |
|
90 | + foreach($current_sosas as $current_sosa => $gen) { |
|
91 | + $this->sosa_provider->deleteAncestors($current_sosa); |
|
92 | + $this->addNode($indi, $current_sosa); |
|
93 | + } |
|
94 | + $this->flushTmpSosaTable(true); |
|
95 | + return true; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Recursive method to add individual to the Sosa table, and flush it regularly |
|
100 | - * @param Individual $indi Individual to add |
|
101 | - * @param int $sosa Individual's sosa |
|
102 | - */ |
|
103 | - protected function addNode(Individual $indi, $sosa) { |
|
104 | - $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
105 | - $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
98 | + /** |
|
99 | + * Recursive method to add individual to the Sosa table, and flush it regularly |
|
100 | + * @param Individual $indi Individual to add |
|
101 | + * @param int $sosa Individual's sosa |
|
102 | + */ |
|
103 | + protected function addNode(Individual $indi, $sosa) { |
|
104 | + $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
105 | + $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
106 | 106 | |
107 | - $this->tmp_sosa_table[] = array( |
|
108 | - 'indi' => $indi->getXref(), |
|
109 | - 'sosa' => $sosa, |
|
110 | - 'birth_year' => $birth_year, |
|
111 | - 'death_year' => $death_year |
|
112 | - ); |
|
107 | + $this->tmp_sosa_table[] = array( |
|
108 | + 'indi' => $indi->getXref(), |
|
109 | + 'sosa' => $sosa, |
|
110 | + 'birth_year' => $birth_year, |
|
111 | + 'death_year' => $death_year |
|
112 | + ); |
|
113 | 113 | |
114 | - $this->flushTmpSosaTable(); |
|
114 | + $this->flushTmpSosaTable(); |
|
115 | 115 | |
116 | - if($fam = $indi->getPrimaryChildFamily()) { |
|
117 | - if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
118 | - if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
119 | - } |
|
120 | - } |
|
116 | + if($fam = $indi->getPrimaryChildFamily()) { |
|
117 | + if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
118 | + if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
119 | + } |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
124 | - * |
|
125 | - * @param bool $force Should the flush be forced |
|
126 | - */ |
|
127 | - protected function flushTmpSosaTable($force = false) { |
|
128 | - if( count($this->tmp_sosa_table)> 0 && |
|
129 | - ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
130 | - $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
131 | - $this->tmp_sosa_table = array(); |
|
132 | - } |
|
133 | - } |
|
122 | + /** |
|
123 | + * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
124 | + * |
|
125 | + * @param bool $force Should the flush be forced |
|
126 | + */ |
|
127 | + protected function flushTmpSosaTable($force = false) { |
|
128 | + if( count($this->tmp_sosa_table)> 0 && |
|
129 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
130 | + $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
131 | + $this->tmp_sosa_table = array(); |
|
132 | + } |
|
133 | + } |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | 137 | \ No newline at end of file |
@@ -36,70 +36,70 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class SosaListController extends MvcController |
38 | 38 | { |
39 | - /** |
|
40 | - * Sosa Provider for the controller |
|
41 | - * @var SosaProvider $sosa_provider |
|
42 | - */ |
|
43 | - protected $sosa_provider; |
|
39 | + /** |
|
40 | + * Sosa Provider for the controller |
|
41 | + * @var SosaProvider $sosa_provider |
|
42 | + */ |
|
43 | + protected $sosa_provider; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Generation used for the controller |
|
47 | - * @var int $generation |
|
48 | - */ |
|
49 | - protected $generation; |
|
45 | + /** |
|
46 | + * Generation used for the controller |
|
47 | + * @var int $generation |
|
48 | + */ |
|
49 | + protected $generation; |
|
50 | 50 | |
51 | - /** |
|
52 | - * ViewBag to hold data for the controller |
|
53 | - * @var ViewBag $view_bag |
|
54 | - */ |
|
55 | - protected $view_bag; |
|
51 | + /** |
|
52 | + * ViewBag to hold data for the controller |
|
53 | + * @var ViewBag $view_bag |
|
54 | + */ |
|
55 | + protected $view_bag; |
|
56 | 56 | |
57 | - /** |
|
58 | - * {@inheritDoc} |
|
59 | - * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module) |
|
60 | - */ |
|
61 | - public function __construct(AbstractModule $module) { |
|
62 | - global $WT_TREE; |
|
57 | + /** |
|
58 | + * {@inheritDoc} |
|
59 | + * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module) |
|
60 | + */ |
|
61 | + public function __construct(AbstractModule $module) { |
|
62 | + global $WT_TREE; |
|
63 | 63 | |
64 | - parent::__construct($module); |
|
64 | + parent::__construct($module); |
|
65 | 65 | |
66 | - $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
66 | + $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
67 | 67 | |
68 | - $this->generation = Filter::getInteger('gen'); |
|
68 | + $this->generation = Filter::getInteger('gen'); |
|
69 | 69 | |
70 | - $this->view_bag = new ViewBag(); |
|
71 | - $this->view_bag->set('generation', $this->generation); |
|
72 | - $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration()); |
|
73 | - $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0); |
|
70 | + $this->view_bag = new ViewBag(); |
|
71 | + $this->view_bag->set('generation', $this->generation); |
|
72 | + $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration()); |
|
73 | + $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0); |
|
74 | 74 | |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * Pages |
|
80 | - */ |
|
78 | + /** |
|
79 | + * Pages |
|
80 | + */ |
|
81 | 81 | |
82 | - /** |
|
83 | - * SosaList@index |
|
84 | - */ |
|
85 | - public function index() { |
|
86 | - global $WT_TREE; |
|
82 | + /** |
|
83 | + * SosaList@index |
|
84 | + */ |
|
85 | + public function index() { |
|
86 | + global $WT_TREE; |
|
87 | 87 | |
88 | - $controller = new PageController(); |
|
89 | - $controller |
|
90 | - ->setPageTitle(I18N::translate('Sosa Ancestors')); |
|
88 | + $controller = new PageController(); |
|
89 | + $controller |
|
90 | + ->setPageTitle(I18N::translate('Sosa Ancestors')); |
|
91 | 91 | |
92 | - $this->view_bag->set('title', $controller->getPageTitle()); |
|
92 | + $this->view_bag->set('title', $controller->getPageTitle()); |
|
93 | 93 | |
94 | - if($this->view_bag->get('is_setup', false)) { |
|
95 | - $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
|
96 | - $this->view_bag->set('url_module', $this->module->getName()); |
|
97 | - $this->view_bag->set('url_action', 'SosaList'); |
|
98 | - $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
99 | - $this->view_bag->set('min_gen', 1); |
|
94 | + if($this->view_bag->get('is_setup', false)) { |
|
95 | + $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
|
96 | + $this->view_bag->set('url_module', $this->module->getName()); |
|
97 | + $this->view_bag->set('url_action', 'SosaList'); |
|
98 | + $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
99 | + $this->view_bag->set('min_gen', 1); |
|
100 | 100 | |
101 | - if($this->view_bag->get('has_sosa', false)) { |
|
102 | - $controller->addInlineJavascript(' |
|
101 | + if($this->view_bag->get('has_sosa', false)) { |
|
102 | + $controller->addInlineJavascript(' |
|
103 | 103 | jQuery("#sosalist-tabs").tabs(); |
104 | 104 | jQuery("#sosalist-tabs").css("visibility", "visible"); |
105 | 105 | |
@@ -153,44 +153,44 @@ discard block |
||
153 | 153 | ); |
154 | 154 | |
155 | 155 | '); |
156 | - } |
|
157 | - } |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render(); |
|
160 | - } |
|
159 | + ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render(); |
|
160 | + } |
|
161 | 161 | |
162 | 162 | |
163 | - /** |
|
164 | - * SosaList@missing |
|
165 | - */ |
|
166 | - public function missing() { |
|
167 | - global $WT_TREE; |
|
163 | + /** |
|
164 | + * SosaList@missing |
|
165 | + */ |
|
166 | + public function missing() { |
|
167 | + global $WT_TREE; |
|
168 | 168 | |
169 | - $controller = new PageController(); |
|
170 | - $controller |
|
171 | - ->setPageTitle(I18N::translate('Missing Ancestors')); |
|
169 | + $controller = new PageController(); |
|
170 | + $controller |
|
171 | + ->setPageTitle(I18N::translate('Missing Ancestors')); |
|
172 | 172 | |
173 | - $this->view_bag->set('title', $controller->getPageTitle()); |
|
173 | + $this->view_bag->set('title', $controller->getPageTitle()); |
|
174 | 174 | |
175 | - if($this->view_bag->get('is_setup', false)) { |
|
176 | - $this->view_bag->set('url_module', $this->module->getName()); |
|
177 | - $this->view_bag->set('url_action', 'SosaList@missing'); |
|
178 | - $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
179 | - $this->view_bag->set('min_gen', 2); |
|
175 | + if($this->view_bag->get('is_setup', false)) { |
|
176 | + $this->view_bag->set('url_module', $this->module->getName()); |
|
177 | + $this->view_bag->set('url_action', 'SosaList@missing'); |
|
178 | + $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
179 | + $this->view_bag->set('min_gen', 2); |
|
180 | 180 | |
181 | - $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
|
182 | - $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
|
181 | + $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
|
182 | + $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
|
183 | 183 | |
184 | - $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
185 | - $this->view_bag->set('perc_sosa', $perc_sosa); |
|
184 | + $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
185 | + $this->view_bag->set('perc_sosa', $perc_sosa); |
|
186 | 186 | |
187 | - if($this->view_bag->get('has_missing', false)) { |
|
188 | - $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
189 | - $this->view_bag->set('table_id', $table_id); |
|
187 | + if($this->view_bag->get('has_missing', false)) { |
|
188 | + $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
189 | + $this->view_bag->set('table_id', $table_id); |
|
190 | 190 | |
191 | - $controller |
|
192 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
193 | - ->addInlineJavascript(' |
|
191 | + $controller |
|
192 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
193 | + ->addInlineJavascript(' |
|
194 | 194 | /* Initialise datatables */ |
195 | 195 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
196 | 196 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -250,77 +250,77 @@ discard block |
||
250 | 250 | jQuery(".loading-image").css("display", "none"); |
251 | 251 | '); |
252 | 252 | |
253 | - $unique_indis = array(); |
|
254 | - $sum_missing_different = 0; |
|
255 | - $sum_missing_different_without_hidden = 0; |
|
256 | - foreach($missing_list as $num => $missing_tab) { |
|
257 | - if(isset($unique_indis[$missing_tab['indi']])) { |
|
258 | - unset($missing_list[$num]); |
|
259 | - continue; |
|
260 | - } |
|
261 | - $sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
262 | - $person = Individual::getInstance($missing_tab['indi'], $WT_TREE); |
|
263 | - if (!$person || !$person->canShowName()) { |
|
264 | - unset($missing_list[$num]); |
|
265 | - continue; |
|
266 | - } |
|
267 | - $sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
268 | - $unique_indis[$person->getXref()] = true; |
|
269 | - $missing_tab['indi'] = $person; |
|
270 | - $missing_list[$num] = $missing_tab; |
|
271 | - } |
|
272 | - $this->view_bag->set('missing_list', $missing_list); |
|
273 | - $this->view_bag->set('missing_diff_count', $sum_missing_different); |
|
274 | - $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden); |
|
275 | - $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2)); |
|
276 | - $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential); |
|
277 | - } |
|
278 | - } |
|
253 | + $unique_indis = array(); |
|
254 | + $sum_missing_different = 0; |
|
255 | + $sum_missing_different_without_hidden = 0; |
|
256 | + foreach($missing_list as $num => $missing_tab) { |
|
257 | + if(isset($unique_indis[$missing_tab['indi']])) { |
|
258 | + unset($missing_list[$num]); |
|
259 | + continue; |
|
260 | + } |
|
261 | + $sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
262 | + $person = Individual::getInstance($missing_tab['indi'], $WT_TREE); |
|
263 | + if (!$person || !$person->canShowName()) { |
|
264 | + unset($missing_list[$num]); |
|
265 | + continue; |
|
266 | + } |
|
267 | + $sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
268 | + $unique_indis[$person->getXref()] = true; |
|
269 | + $missing_tab['indi'] = $person; |
|
270 | + $missing_list[$num] = $missing_tab; |
|
271 | + } |
|
272 | + $this->view_bag->set('missing_list', $missing_list); |
|
273 | + $this->view_bag->set('missing_diff_count', $sum_missing_different); |
|
274 | + $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden); |
|
275 | + $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2)); |
|
276 | + $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential); |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | - ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render(); |
|
281 | - } |
|
280 | + ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render(); |
|
281 | + } |
|
282 | 282 | |
283 | - /** |
|
284 | - * SosaList@sosalist |
|
285 | - */ |
|
286 | - public function sosalist() { |
|
283 | + /** |
|
284 | + * SosaList@sosalist |
|
285 | + */ |
|
286 | + public function sosalist() { |
|
287 | 287 | |
288 | - $type = Filter::get('type', 'indi|fam', null); |
|
288 | + $type = Filter::get('type', 'indi|fam', null); |
|
289 | 289 | |
290 | - $controller = new AjaxController(); |
|
291 | - $controller->restrictAccess($this->generation > 0 || !is_null($type)); |
|
290 | + $controller = new AjaxController(); |
|
291 | + $controller->restrictAccess($this->generation > 0 || !is_null($type)); |
|
292 | 292 | |
293 | - switch ($type){ |
|
294 | - case 'indi': |
|
295 | - $this->renderSosaListIndi($controller); |
|
296 | - break; |
|
297 | - case 'fam': |
|
298 | - $this->renderFamSosaListIndi($controller); |
|
299 | - break; |
|
300 | - default: |
|
301 | - break; |
|
302 | - } |
|
293 | + switch ($type){ |
|
294 | + case 'indi': |
|
295 | + $this->renderSosaListIndi($controller); |
|
296 | + break; |
|
297 | + case 'fam': |
|
298 | + $this->renderFamSosaListIndi($controller); |
|
299 | + break; |
|
300 | + default: |
|
301 | + break; |
|
302 | + } |
|
303 | 303 | |
304 | - } |
|
304 | + } |
|
305 | 305 | |
306 | - /** |
|
307 | - * Render the Ajax response for the sortable table of Sosa individuals |
|
308 | - * @param AjaxController $controller |
|
309 | - */ |
|
310 | - protected function renderSosaListIndi(AjaxController $controller) { |
|
311 | - global $WT_TREE; |
|
306 | + /** |
|
307 | + * Render the Ajax response for the sortable table of Sosa individuals |
|
308 | + * @param AjaxController $controller |
|
309 | + */ |
|
310 | + protected function renderSosaListIndi(AjaxController $controller) { |
|
311 | + global $WT_TREE; |
|
312 | 312 | |
313 | - $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); |
|
314 | - $this->view_bag->set('has_sosa', false); |
|
313 | + $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); |
|
314 | + $this->view_bag->set('has_sosa', false); |
|
315 | 315 | |
316 | - if(count($listSosa) > 0) { |
|
317 | - $this->view_bag->set('has_sosa', true); |
|
318 | - $table_id = 'table-sosa-indi-' . Uuid::uuid4(); |
|
319 | - $this->view_bag->set('table_id', $table_id); |
|
316 | + if(count($listSosa) > 0) { |
|
317 | + $this->view_bag->set('has_sosa', true); |
|
318 | + $table_id = 'table-sosa-indi-' . Uuid::uuid4(); |
|
319 | + $this->view_bag->set('table_id', $table_id); |
|
320 | 320 | |
321 | - $controller |
|
322 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
323 | - ->addInlineJavascript(' |
|
321 | + $controller |
|
322 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
323 | + ->addInlineJavascript(' |
|
324 | 324 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
325 | 325 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
326 | 326 | jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);}; |
@@ -396,96 +396,96 @@ discard block |
||
396 | 396 | jQuery("#btn-toggle-statistics-'.$table_id.'").click(); |
397 | 397 | '); |
398 | 398 | |
399 | - $stats = new Stats($WT_TREE); |
|
399 | + $stats = new Stats($WT_TREE); |
|
400 | 400 | |
401 | - // Bad data can cause "longest life" to be huge, blowing memory limits |
|
402 | - $max_age = min($WT_TREE->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1; |
|
403 | - // Inititialise chart data |
|
404 | - $deat_by_age = array(); |
|
405 | - for ($age = 0; $age <= $max_age; $age++) { |
|
406 | - $deat_by_age[$age] = ''; |
|
407 | - } |
|
408 | - $birt_by_decade = array(); |
|
409 | - $deat_by_decade = array(); |
|
410 | - for ($year = 1550; $year < 2030; $year += 10) { |
|
411 | - $birt_by_decade[$year] = ''; |
|
412 | - $deat_by_decade[$year] = ''; |
|
413 | - } |
|
401 | + // Bad data can cause "longest life" to be huge, blowing memory limits |
|
402 | + $max_age = min($WT_TREE->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1; |
|
403 | + // Inititialise chart data |
|
404 | + $deat_by_age = array(); |
|
405 | + for ($age = 0; $age <= $max_age; $age++) { |
|
406 | + $deat_by_age[$age] = ''; |
|
407 | + } |
|
408 | + $birt_by_decade = array(); |
|
409 | + $deat_by_decade = array(); |
|
410 | + for ($year = 1550; $year < 2030; $year += 10) { |
|
411 | + $birt_by_decade[$year] = ''; |
|
412 | + $deat_by_decade[$year] = ''; |
|
413 | + } |
|
414 | 414 | |
415 | - $unique_indis = array(); // Don't double-count indis with multiple names. |
|
416 | - $nb_displayed = 0; |
|
415 | + $unique_indis = array(); // Don't double-count indis with multiple names. |
|
416 | + $nb_displayed = 0; |
|
417 | 417 | |
418 | - Individual::load($WT_TREE, $listSosa); |
|
419 | - foreach($listSosa as $sosa => $pid) { |
|
420 | - $person = Individual::getInstance($pid, $WT_TREE); |
|
421 | - if (!$person || !$person->canShowName()) { |
|
422 | - unset($listSosa[$sosa]); |
|
423 | - continue; |
|
424 | - } |
|
425 | - $nb_displayed++; |
|
426 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
427 | - if ( |
|
428 | - FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
|
429 | - !isset($unique_indis[$person->getXref()]) |
|
430 | - ) { |
|
431 | - $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
432 | - } |
|
433 | - } |
|
434 | - else { |
|
435 | - $birth_dates[0]=new Date(''); |
|
436 | - } |
|
437 | - if ($death_dates = $person->getAllDeathDates()) { |
|
438 | - if ( |
|
439 | - FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
|
440 | - !isset($unique_indis[$person->getXref()]) |
|
441 | - ) { |
|
442 | - $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
443 | - } |
|
444 | - } |
|
445 | - else { |
|
446 | - $death_dates[0] = new Date(''); |
|
447 | - } |
|
448 | - $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
449 | - if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) { |
|
450 | - $deat_by_age[$age] .= $person->getSex(); |
|
451 | - } |
|
452 | - $listSosa[$sosa] = $person; |
|
453 | - $unique_indis[$person->getXref()] = true; |
|
454 | - } |
|
455 | - $this->view_bag->set('sosa_list', $listSosa); |
|
418 | + Individual::load($WT_TREE, $listSosa); |
|
419 | + foreach($listSosa as $sosa => $pid) { |
|
420 | + $person = Individual::getInstance($pid, $WT_TREE); |
|
421 | + if (!$person || !$person->canShowName()) { |
|
422 | + unset($listSosa[$sosa]); |
|
423 | + continue; |
|
424 | + } |
|
425 | + $nb_displayed++; |
|
426 | + if ($birth_dates=$person->getAllBirthDates()) { |
|
427 | + if ( |
|
428 | + FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
|
429 | + !isset($unique_indis[$person->getXref()]) |
|
430 | + ) { |
|
431 | + $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
432 | + } |
|
433 | + } |
|
434 | + else { |
|
435 | + $birth_dates[0]=new Date(''); |
|
436 | + } |
|
437 | + if ($death_dates = $person->getAllDeathDates()) { |
|
438 | + if ( |
|
439 | + FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
|
440 | + !isset($unique_indis[$person->getXref()]) |
|
441 | + ) { |
|
442 | + $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
443 | + } |
|
444 | + } |
|
445 | + else { |
|
446 | + $death_dates[0] = new Date(''); |
|
447 | + } |
|
448 | + $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
449 | + if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) { |
|
450 | + $deat_by_age[$age] .= $person->getSex(); |
|
451 | + } |
|
452 | + $listSosa[$sosa] = $person; |
|
453 | + $unique_indis[$person->getXref()] = true; |
|
454 | + } |
|
455 | + $this->view_bag->set('sosa_list', $listSosa); |
|
456 | 456 | |
457 | - $this->view_bag->set('sosa_count', count($listSosa)); |
|
458 | - $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
459 | - $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
|
457 | + $this->view_bag->set('sosa_count', count($listSosa)); |
|
458 | + $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
459 | + $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
|
460 | 460 | |
461 | - $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
|
461 | + $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
|
462 | 462 | |
463 | - $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
464 | - $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death'))); |
|
465 | - $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year'))); |
|
466 | - } |
|
463 | + $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
464 | + $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death'))); |
|
465 | + $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year'))); |
|
466 | + } |
|
467 | 467 | |
468 | - ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render(); |
|
469 | - } |
|
468 | + ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render(); |
|
469 | + } |
|
470 | 470 | |
471 | - /** |
|
472 | - * Render the Ajax response for the sortable table of Sosa family |
|
473 | - * @param AjaxController $controller |
|
474 | - */ |
|
475 | - protected function renderFamSosaListIndi(AjaxController $controller) { |
|
476 | - global $WT_TREE; |
|
471 | + /** |
|
472 | + * Render the Ajax response for the sortable table of Sosa family |
|
473 | + * @param AjaxController $controller |
|
474 | + */ |
|
475 | + protected function renderFamSosaListIndi(AjaxController $controller) { |
|
476 | + global $WT_TREE; |
|
477 | 477 | |
478 | - $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
479 | - $this->view_bag->set('has_sosa', false); |
|
478 | + $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
479 | + $this->view_bag->set('has_sosa', false); |
|
480 | 480 | |
481 | - if(count($listFamSosa) > 0) { |
|
482 | - $this->view_bag->set('has_sosa', true); |
|
483 | - $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
484 | - $this->view_bag->set('table_id', $table_id); |
|
481 | + if(count($listFamSosa) > 0) { |
|
482 | + $this->view_bag->set('has_sosa', true); |
|
483 | + $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
484 | + $this->view_bag->set('table_id', $table_id); |
|
485 | 485 | |
486 | - $controller |
|
487 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
488 | - ->addInlineJavascript(' |
|
486 | + $controller |
|
487 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
488 | + ->addInlineJavascript(' |
|
489 | 489 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
490 | 490 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
491 | 491 | jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);}; |
@@ -561,67 +561,67 @@ discard block |
||
561 | 561 | jQuery("#btn-toggle-statistics-'.$table_id.'").click(); |
562 | 562 | '); |
563 | 563 | |
564 | - $stats = new Stats($WT_TREE); |
|
565 | - $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; |
|
564 | + $stats = new Stats($WT_TREE); |
|
565 | + $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; |
|
566 | 566 | |
567 | - //-- init chart data |
|
568 | - $marr_by_age = array(); |
|
569 | - for ($age=0; $age<=$max_age; $age++) { |
|
570 | - $marr_by_age[$age] = ''; |
|
571 | - } |
|
572 | - $birt_by_decade = array(); |
|
573 | - $marr_by_decade = array(); |
|
574 | - for ($year=1550; $year<2030; $year+=10) { |
|
575 | - $birt_by_decade[$year] = ''; |
|
576 | - $marr_by_decade[$year] = ''; |
|
577 | - } |
|
567 | + //-- init chart data |
|
568 | + $marr_by_age = array(); |
|
569 | + for ($age=0; $age<=$max_age; $age++) { |
|
570 | + $marr_by_age[$age] = ''; |
|
571 | + } |
|
572 | + $birt_by_decade = array(); |
|
573 | + $marr_by_decade = array(); |
|
574 | + for ($year=1550; $year<2030; $year+=10) { |
|
575 | + $birt_by_decade[$year] = ''; |
|
576 | + $marr_by_decade[$year] = ''; |
|
577 | + } |
|
578 | 578 | |
579 | - foreach($listFamSosa as $sosa => $fid) { |
|
580 | - $sfamily = Family::getInstance($fid, $WT_TREE); |
|
581 | - if(!$sfamily || !$sfamily->canShow()) { |
|
582 | - unset($sfamily[$sosa]); |
|
583 | - continue; |
|
584 | - } |
|
585 | - $mdate=$sfamily->getMarriageDate(); |
|
579 | + foreach($listFamSosa as $sosa => $fid) { |
|
580 | + $sfamily = Family::getInstance($fid, $WT_TREE); |
|
581 | + if(!$sfamily || !$sfamily->canShow()) { |
|
582 | + unset($sfamily[$sosa]); |
|
583 | + continue; |
|
584 | + } |
|
585 | + $mdate=$sfamily->getMarriageDate(); |
|
586 | 586 | |
587 | - if( ($husb = $sfamily->getHusband()) && |
|
588 | - ($hdate = $husb->getBirthDate()) && |
|
589 | - $hdate->isOK() && $mdate->isOK()) { |
|
590 | - if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
|
591 | - $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
592 | - } |
|
593 | - $hage = Date::getAge($hdate, $mdate, 0); |
|
594 | - if ($hage >= 0 && $hage <= $max_age) { |
|
595 | - $marr_by_age[$hage] .= $husb->getSex(); |
|
596 | - } |
|
597 | - } |
|
587 | + if( ($husb = $sfamily->getHusband()) && |
|
588 | + ($hdate = $husb->getBirthDate()) && |
|
589 | + $hdate->isOK() && $mdate->isOK()) { |
|
590 | + if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
|
591 | + $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
592 | + } |
|
593 | + $hage = Date::getAge($hdate, $mdate, 0); |
|
594 | + if ($hage >= 0 && $hage <= $max_age) { |
|
595 | + $marr_by_age[$hage] .= $husb->getSex(); |
|
596 | + } |
|
597 | + } |
|
598 | 598 | |
599 | - if(($wife = $sfamily->getWife()) && |
|
600 | - ($wdate=$wife->getBirthDate()) && |
|
601 | - $wdate->isOK() && $mdate->isOK()) { |
|
602 | - if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
|
603 | - $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
604 | - } |
|
605 | - $wage = Date::getAge($wdate, $mdate, 0); |
|
606 | - if ($wage >= 0 && $wage <= $max_age) { |
|
607 | - $marr_by_age[$wage] .= $wife->getSex(); |
|
608 | - } |
|
609 | - } |
|
599 | + if(($wife = $sfamily->getWife()) && |
|
600 | + ($wdate=$wife->getBirthDate()) && |
|
601 | + $wdate->isOK() && $mdate->isOK()) { |
|
602 | + if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
|
603 | + $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
604 | + } |
|
605 | + $wage = Date::getAge($wdate, $mdate, 0); |
|
606 | + if ($wage >= 0 && $wage <= $max_age) { |
|
607 | + $marr_by_age[$wage] .= $wife->getSex(); |
|
608 | + } |
|
609 | + } |
|
610 | 610 | |
611 | - if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
|
612 | - $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
613 | - } |
|
611 | + if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
|
612 | + $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
613 | + } |
|
614 | 614 | |
615 | - $listFamSosa[$sosa] = $sfamily; |
|
616 | - } |
|
617 | - $this->view_bag->set('sosa_list', $listFamSosa); |
|
615 | + $listFamSosa[$sosa] = $sfamily; |
|
616 | + } |
|
617 | + $this->view_bag->set('sosa_list', $listFamSosa); |
|
618 | 618 | |
619 | - $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
620 | - $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage'))); |
|
621 | - $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage'))); |
|
622 | - } |
|
619 | + $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
620 | + $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage'))); |
|
621 | + $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage'))); |
|
622 | + } |
|
623 | 623 | |
624 | - ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render(); |
|
625 | - } |
|
624 | + ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render(); |
|
625 | + } |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | \ No newline at end of file |
@@ -18,97 +18,97 @@ |
||
18 | 18 | /** |
19 | 19 | * @var array $data Container for data |
20 | 20 | */ |
21 | - protected $data = array(); |
|
21 | + protected $data = array(); |
|
22 | 22 | |
23 | - /** |
|
24 | - * Constructor for ViewBag |
|
25 | - * @param array $data_in |
|
26 | - */ |
|
27 | - public function __construct(array $data_in = array()) { |
|
28 | - $this->data = $data_in; |
|
29 | - } |
|
23 | + /** |
|
24 | + * Constructor for ViewBag |
|
25 | + * @param array $data_in |
|
26 | + */ |
|
27 | + public function __construct(array $data_in = array()) { |
|
28 | + $this->data = $data_in; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Get the keys present in the view bag. |
|
33 | - * |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function keys() |
|
37 | - { |
|
38 | - return array_keys($this->data); |
|
39 | - } |
|
31 | + /** |
|
32 | + * Get the keys present in the view bag. |
|
33 | + * |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function keys() |
|
37 | + { |
|
38 | + return array_keys($this->data); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get all the data from the bag for a given key. |
|
43 | - * |
|
44 | - * @param string $key |
|
45 | - * @param string $format |
|
46 | - * @return unknown |
|
47 | - */ |
|
48 | - public function get($key, $default = null) |
|
49 | - { |
|
50 | - if (array_key_exists($key, $this->data)) { |
|
51 | - return $this->data[$key]; |
|
52 | - } |
|
53 | - return $default; |
|
54 | - } |
|
41 | + /** |
|
42 | + * Get all the data from the bag for a given key. |
|
43 | + * |
|
44 | + * @param string $key |
|
45 | + * @param string $format |
|
46 | + * @return unknown |
|
47 | + */ |
|
48 | + public function get($key, $default = null) |
|
49 | + { |
|
50 | + if (array_key_exists($key, $this->data)) { |
|
51 | + return $this->data[$key]; |
|
52 | + } |
|
53 | + return $default; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Magic getter. |
|
58 | - * Returns the value associated with the key. |
|
59 | - * |
|
60 | - * @param string $key |
|
61 | - * @return unknown |
|
62 | - */ |
|
63 | - public function __get($key) { |
|
64 | - return $this->get($key, null); |
|
65 | - } |
|
56 | + /** |
|
57 | + * Magic getter. |
|
58 | + * Returns the value associated with the key. |
|
59 | + * |
|
60 | + * @param string $key |
|
61 | + * @return unknown |
|
62 | + */ |
|
63 | + public function __get($key) { |
|
64 | + return $this->get($key, null); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Set the value for the specified key. |
|
69 | - * Can define whether to override an existing value; |
|
70 | - * |
|
71 | - * @param string $key |
|
72 | - * @param mixed $value |
|
73 | - * @param bool $override |
|
74 | - */ |
|
75 | - public function set($key, $value, $override = true) { |
|
76 | - if(is_null($key)) return; |
|
77 | - if(!$override && array_key_exists($key, $this->data)) return; |
|
78 | - $this->data[$key] = $value; |
|
79 | - } |
|
67 | + /** |
|
68 | + * Set the value for the specified key. |
|
69 | + * Can define whether to override an existing value; |
|
70 | + * |
|
71 | + * @param string $key |
|
72 | + * @param mixed $value |
|
73 | + * @param bool $override |
|
74 | + */ |
|
75 | + public function set($key, $value, $override = true) { |
|
76 | + if(is_null($key)) return; |
|
77 | + if(!$override && array_key_exists($key, $this->data)) return; |
|
78 | + $this->data[$key] = $value; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Magic setter. |
|
83 | - * Set the value for the specified key. |
|
84 | - * |
|
85 | - * @param string $key |
|
86 | - * @param mixed $value |
|
87 | - */ |
|
88 | - public function __set($key, $value) { |
|
89 | - $this->set($key, $value); |
|
90 | - } |
|
81 | + /** |
|
82 | + * Magic setter. |
|
83 | + * Set the value for the specified key. |
|
84 | + * |
|
85 | + * @param string $key |
|
86 | + * @param mixed $value |
|
87 | + */ |
|
88 | + public function __set($key, $value) { |
|
89 | + $this->set($key, $value); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Magic isset |
|
94 | - * Checks whether the ViewBag contains the specified key |
|
95 | - * |
|
96 | - * @param string $key |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function __isset($key) { |
|
100 | - return isset($this->data[$key]); |
|
101 | - } |
|
92 | + /** |
|
93 | + * Magic isset |
|
94 | + * Checks whether the ViewBag contains the specified key |
|
95 | + * |
|
96 | + * @param string $key |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function __isset($key) { |
|
100 | + return isset($this->data[$key]); |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Magic unset |
|
105 | - * Unset the specified key from the ViewBag |
|
106 | - * |
|
107 | - * @param string $key |
|
108 | - */ |
|
109 | - public function __unset($key) { |
|
110 | - unset($this->data[$key]);; |
|
111 | - } |
|
103 | + /** |
|
104 | + * Magic unset |
|
105 | + * Unset the specified key from the ViewBag |
|
106 | + * |
|
107 | + * @param string $key |
|
108 | + */ |
|
109 | + public function __unset($key) { |
|
110 | + unset($this->data[$key]);; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | 115 | \ No newline at end of file |