@@ -21,130 +21,130 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class GeoAnalysisProvider { |
23 | 23 | |
24 | - /** |
|
25 | - * Reference tree |
|
26 | - * @var Tree $tree |
|
27 | - */ |
|
28 | - protected $tree; |
|
24 | + /** |
|
25 | + * Reference tree |
|
26 | + * @var Tree $tree |
|
27 | + */ |
|
28 | + protected $tree; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Cached hierarchy of places in the Gedcom file. |
|
32 | - * |
|
33 | - * @var (array|null) $place_hierarchy |
|
34 | - */ |
|
35 | - protected $place_hierarchy; |
|
30 | + /** |
|
31 | + * Cached hierarchy of places in the Gedcom file. |
|
32 | + * |
|
33 | + * @var (array|null) $place_hierarchy |
|
34 | + */ |
|
35 | + protected $place_hierarchy; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for GeoAnalysis Provider. |
|
39 | - * A provider is defined in relation to a specific tree. |
|
40 | - * |
|
41 | - * @param Tree $tree |
|
42 | - */ |
|
43 | - public function __construct(Tree $tree) { |
|
44 | - $this->tree = $tree; |
|
45 | - $this->place_hierarchy = null; |
|
46 | - } |
|
37 | + /** |
|
38 | + * Constructor for GeoAnalysis Provider. |
|
39 | + * A provider is defined in relation to a specific tree. |
|
40 | + * |
|
41 | + * @param Tree $tree |
|
42 | + */ |
|
43 | + public function __construct(Tree $tree) { |
|
44 | + $this->tree = $tree; |
|
45 | + $this->place_hierarchy = null; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Creates and returns a GeoAnalysis object from a data row. |
|
50 | - * The row data is expected to be an array with the indexes: |
|
51 | - * - majgd_id: geodispersion analysis ID |
|
52 | - * - majgd_descr: geodispersion analysis description/title |
|
53 | - * - majgd_sublevel: Analysis level |
|
54 | - * - majgd_useflagsgen: Use flags in places display |
|
55 | - * - majgd_detailsgen: Number of top places |
|
56 | - * - majgd_map: file name of the map |
|
57 | - * - majgd_toplevel: parent level for the map |
|
58 | - * |
|
59 | - * @param array $row |
|
60 | - * @return GeoAnalysis |
|
61 | - */ |
|
62 | - protected function loadGeoAnalysisFromRow($row) { |
|
63 | - $options = new GeoDisplayOptions(); |
|
64 | - $options |
|
65 | - ->setIsUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | - ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
48 | + /** |
|
49 | + * Creates and returns a GeoAnalysis object from a data row. |
|
50 | + * The row data is expected to be an array with the indexes: |
|
51 | + * - majgd_id: geodispersion analysis ID |
|
52 | + * - majgd_descr: geodispersion analysis description/title |
|
53 | + * - majgd_sublevel: Analysis level |
|
54 | + * - majgd_useflagsgen: Use flags in places display |
|
55 | + * - majgd_detailsgen: Number of top places |
|
56 | + * - majgd_map: file name of the map |
|
57 | + * - majgd_toplevel: parent level for the map |
|
58 | + * |
|
59 | + * @param array $row |
|
60 | + * @return GeoAnalysis |
|
61 | + */ |
|
62 | + protected function loadGeoAnalysisFromRow($row) { |
|
63 | + $options = new GeoDisplayOptions(); |
|
64 | + $options |
|
65 | + ->setIsUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | + ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
67 | 67 | |
68 | - if($row['majgd_map']) { |
|
69 | - $options |
|
70 | - ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | - ->setMapLevel($row['majgd_toplevel']); |
|
72 | - } |
|
68 | + if($row['majgd_map']) { |
|
69 | + $options |
|
70 | + ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | + ->setMapLevel($row['majgd_toplevel']); |
|
72 | + } |
|
73 | 73 | |
74 | - $enabled = true; |
|
75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | - $enabled = false; |
|
77 | - } |
|
74 | + $enabled = true; |
|
75 | + if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | + $enabled = false; |
|
77 | + } |
|
78 | 78 | |
79 | - return new GeoAnalysis( |
|
80 | - $this->tree, |
|
81 | - $row['majgd_id'], |
|
82 | - $row['majgd_descr'], |
|
83 | - $row['majgd_sublevel'], |
|
84 | - $options, |
|
85 | - $enabled |
|
86 | - ); |
|
87 | - } |
|
79 | + return new GeoAnalysis( |
|
80 | + $this->tree, |
|
81 | + $row['majgd_id'], |
|
82 | + $row['majgd_descr'], |
|
83 | + $row['majgd_sublevel'], |
|
84 | + $options, |
|
85 | + $enabled |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Returns the number of geographical analysis (active and inactive). |
|
91 | - * |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function getGeoAnalysisCount() { |
|
95 | - return Database::prepare( |
|
96 | - 'SELECT COUNT(majgd_id)' . |
|
97 | - ' FROM `##maj_geodispersion`' . |
|
98 | - ' WHERE majgd_file = :gedcom_id' |
|
99 | - )->execute(array( |
|
100 | - 'gedcom_id' => $this->tree->getTreeId() |
|
101 | - ))->fetchOne(); |
|
102 | - } |
|
89 | + /** |
|
90 | + * Returns the number of geographical analysis (active and inactive). |
|
91 | + * |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function getGeoAnalysisCount() { |
|
95 | + return Database::prepare( |
|
96 | + 'SELECT COUNT(majgd_id)' . |
|
97 | + ' FROM `##maj_geodispersion`' . |
|
98 | + ' WHERE majgd_file = :gedcom_id' |
|
99 | + )->execute(array( |
|
100 | + 'gedcom_id' => $this->tree->getTreeId() |
|
101 | + ))->fetchOne(); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Get a geographical analysis by its ID. |
|
106 | - * The function can only search for only enabled analysis, or all. |
|
107 | - * |
|
108 | - * @param int $id geodispersion analysis ID |
|
109 | - * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | - */ |
|
112 | - public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | - $args = array ( |
|
114 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | - 'ga_id' => $id |
|
116 | - ); |
|
104 | + /** |
|
105 | + * Get a geographical analysis by its ID. |
|
106 | + * The function can only search for only enabled analysis, or all. |
|
107 | + * |
|
108 | + * @param int $id geodispersion analysis ID |
|
109 | + * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | + */ |
|
112 | + public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | + $args = array ( |
|
114 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | + 'ga_id' => $id |
|
116 | + ); |
|
117 | 117 | |
118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | - ' FROM `##maj_geodispersion`' . |
|
120 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | - if($only_enabled) { |
|
122 | - $sql .= ' AND majgd_status = :status'; |
|
123 | - $args['status'] = 'enabled'; |
|
124 | - } |
|
125 | - $sql .= ' ORDER BY majgd_descr'; |
|
118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | + ' FROM `##maj_geodispersion`' . |
|
120 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | + if($only_enabled) { |
|
122 | + $sql .= ' AND majgd_status = :status'; |
|
123 | + $args['status'] = 'enabled'; |
|
124 | + } |
|
125 | + $sql .= ' ORDER BY majgd_descr'; |
|
126 | 126 | |
127 | - $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
127 | + $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
128 | 128 | |
129 | - if($ga_array) { |
|
130 | - return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | - } |
|
129 | + if($ga_array) { |
|
130 | + return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | + } |
|
132 | 132 | |
133 | - return null; |
|
134 | - } |
|
133 | + return null; |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | - * When successful, eturns the newly created GeoAnalysis object. |
|
139 | - * |
|
140 | - * @param string $description geodispersion analysis title |
|
141 | - * @param int $analysis_level Analysis level |
|
142 | - * @param string $map_file Filename of the map |
|
143 | - * @param int $map_top_level Parent level of the map |
|
144 | - * @param bool $use_flags Use flag in the place display |
|
145 | - * @param int $gen_details Number of top places to display |
|
146 | - * @return GeoAnalysis |
|
147 | - */ |
|
136 | + /** |
|
137 | + * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | + * When successful, eturns the newly created GeoAnalysis object. |
|
139 | + * |
|
140 | + * @param string $description geodispersion analysis title |
|
141 | + * @param int $analysis_level Analysis level |
|
142 | + * @param string $map_file Filename of the map |
|
143 | + * @param int $map_top_level Parent level of the map |
|
144 | + * @param bool $use_flags Use flag in the place display |
|
145 | + * @param int $gen_details Number of top places to display |
|
146 | + * @return GeoAnalysis |
|
147 | + */ |
|
148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
149 | 149 | try{ |
150 | 150 | Database::beginTransaction(); |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
175 | 175 | } |
176 | 176 | return $ga; |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | - * When successful, returns the updated GeoAnalysis object |
|
182 | - * |
|
183 | - * @param GeoAnalysis $ga |
|
184 | - * @return GeoAnalysis |
|
185 | - */ |
|
186 | - public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | - try { |
|
179 | + /** |
|
180 | + * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | + * When successful, returns the updated GeoAnalysis object |
|
182 | + * |
|
183 | + * @param GeoAnalysis $ga |
|
184 | + * @return GeoAnalysis |
|
185 | + */ |
|
186 | + public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | + try { |
|
188 | 188 | Database::beginTransaction(); |
189 | 189 | |
190 | 190 | Database::prepare( |
@@ -217,238 +217,238 @@ discard block |
||
217 | 217 | $ga = null; |
218 | 218 | } |
219 | 219 | return $ga; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Set the status of a specific analysis. |
|
224 | - * The status can be enabled (true), or disabled (false). |
|
225 | - * |
|
226 | - * @param GeoAnalysis $ga |
|
227 | - * @param bool $status |
|
228 | - */ |
|
229 | - public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | - Database::prepare( |
|
231 | - 'UPDATE `##maj_geodispersion`'. |
|
232 | - ' SET majgd_status = :status'. |
|
233 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | - )->execute(array( |
|
235 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | - 'status' => $status ? 'enabled' : 'disabled', |
|
237 | - 'ga_id' => $ga->getId() |
|
238 | - )); |
|
239 | - } |
|
222 | + /** |
|
223 | + * Set the status of a specific analysis. |
|
224 | + * The status can be enabled (true), or disabled (false). |
|
225 | + * |
|
226 | + * @param GeoAnalysis $ga |
|
227 | + * @param bool $status |
|
228 | + */ |
|
229 | + public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | + Database::prepare( |
|
231 | + 'UPDATE `##maj_geodispersion`'. |
|
232 | + ' SET majgd_status = :status'. |
|
233 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | + )->execute(array( |
|
235 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | + 'status' => $status ? 'enabled' : 'disabled', |
|
237 | + 'ga_id' => $ga->getId() |
|
238 | + )); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Delete a geodispersion analysis from the database. |
|
243 | - * |
|
244 | - * @param GeoAnalysis $ga |
|
245 | - */ |
|
246 | - public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | - Database::prepare( |
|
248 | - 'DELETE FROM `##maj_geodispersion`'. |
|
249 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | - )->execute(array( |
|
251 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | - 'ga_id' => $ga->getId() |
|
253 | - )); |
|
254 | - } |
|
241 | + /** |
|
242 | + * Delete a geodispersion analysis from the database. |
|
243 | + * |
|
244 | + * @param GeoAnalysis $ga |
|
245 | + */ |
|
246 | + public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | + Database::prepare( |
|
248 | + 'DELETE FROM `##maj_geodispersion`'. |
|
249 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | + )->execute(array( |
|
251 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | + 'ga_id' => $ga->getId() |
|
253 | + )); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | - * |
|
259 | - * @return array List of enabled maps |
|
260 | - */ |
|
261 | - public function getGeoAnalysisList(){ |
|
262 | - $res = array(); |
|
256 | + /** |
|
257 | + * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | + * |
|
259 | + * @return array List of enabled maps |
|
260 | + */ |
|
261 | + public function getGeoAnalysisList(){ |
|
262 | + $res = array(); |
|
263 | 263 | |
264 | - $list = Database::prepare( |
|
265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | - ' FROM `##maj_geodispersion`' . |
|
267 | - ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | - ' ORDER BY majgd_descr' |
|
269 | - )->execute(array( |
|
270 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | - 'status' => 'enabled' |
|
272 | - ))->fetchAll(\PDO::FETCH_ASSOC); |
|
264 | + $list = Database::prepare( |
|
265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | + ' FROM `##maj_geodispersion`' . |
|
267 | + ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | + ' ORDER BY majgd_descr' |
|
269 | + )->execute(array( |
|
270 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | + 'status' => 'enabled' |
|
272 | + ))->fetchAll(\PDO::FETCH_ASSOC); |
|
273 | 273 | |
274 | - foreach($list as $ga) { |
|
275 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | - } |
|
274 | + foreach($list as $ga) { |
|
275 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | + } |
|
277 | 277 | |
278 | - return $res; |
|
279 | - } |
|
278 | + return $res; |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Return the list of geodispersion analysis matching specified criterias. |
|
283 | - * |
|
284 | - * @param string $search Search criteria in analysis description |
|
285 | - * @param array $order_by Columns to order by |
|
286 | - * @param int $start Offset to start with (for pagination) |
|
287 | - * @param int|null $limit Max number of items to return (for pagination) |
|
288 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | - */ |
|
290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | - $res = array(); |
|
281 | + /** |
|
282 | + * Return the list of geodispersion analysis matching specified criterias. |
|
283 | + * |
|
284 | + * @param string $search Search criteria in analysis description |
|
285 | + * @param array $order_by Columns to order by |
|
286 | + * @param int $start Offset to start with (for pagination) |
|
287 | + * @param int|null $limit Max number of items to return (for pagination) |
|
288 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | + */ |
|
290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | + $res = array(); |
|
292 | 292 | |
293 | - $sql = |
|
294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | - ' FROM `##maj_geodispersion`' . |
|
296 | - ' WHERE majgd_file = :gedcom_id'; |
|
293 | + $sql = |
|
294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | + ' FROM `##maj_geodispersion`' . |
|
296 | + ' WHERE majgd_file = :gedcom_id'; |
|
297 | 297 | |
298 | - $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
298 | + $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
299 | 299 | |
300 | - if($search) { |
|
301 | - $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | - $args['search'] = $search; |
|
303 | - } |
|
300 | + if($search) { |
|
301 | + $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | + $args['search'] = $search; |
|
303 | + } |
|
304 | 304 | |
305 | - if ($order_by) { |
|
306 | - $sql .= ' ORDER BY '; |
|
307 | - foreach ($order_by as $key => $value) { |
|
308 | - if ($key > 0) { |
|
309 | - $sql .= ','; |
|
310 | - } |
|
305 | + if ($order_by) { |
|
306 | + $sql .= ' ORDER BY '; |
|
307 | + foreach ($order_by as $key => $value) { |
|
308 | + if ($key > 0) { |
|
309 | + $sql .= ','; |
|
310 | + } |
|
311 | 311 | |
312 | - switch ($value['dir']) { |
|
313 | - case 'asc': |
|
314 | - $sql .= $value['column'] . ' ASC '; |
|
315 | - break; |
|
316 | - case 'desc': |
|
317 | - $sql .= $value['column'] . ' DESC '; |
|
318 | - break; |
|
319 | - } |
|
320 | - } |
|
321 | - } else { |
|
322 | - $sql = " ORDER BY majgd_descr ASC"; |
|
323 | - } |
|
312 | + switch ($value['dir']) { |
|
313 | + case 'asc': |
|
314 | + $sql .= $value['column'] . ' ASC '; |
|
315 | + break; |
|
316 | + case 'desc': |
|
317 | + $sql .= $value['column'] . ' DESC '; |
|
318 | + break; |
|
319 | + } |
|
320 | + } |
|
321 | + } else { |
|
322 | + $sql = " ORDER BY majgd_descr ASC"; |
|
323 | + } |
|
324 | 324 | |
325 | - if ($limit) { |
|
326 | - $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | - $args['limit'] = $limit; |
|
328 | - $args['offset'] = $start; |
|
329 | - } |
|
325 | + if ($limit) { |
|
326 | + $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | + $args['limit'] = $limit; |
|
328 | + $args['offset'] = $start; |
|
329 | + } |
|
330 | 330 | |
331 | - $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
331 | + $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
332 | 332 | |
333 | - foreach($data as $ga) { |
|
334 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | - } |
|
333 | + foreach($data as $ga) { |
|
334 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | + } |
|
336 | 336 | |
337 | - return $res; |
|
338 | - } |
|
337 | + return $res; |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | - * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | - * This is returned as an associative array: |
|
344 | - * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | - * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | - * |
|
347 | - * @return array |
|
348 | - */ |
|
349 | - public function getPlacesHierarchy() { |
|
350 | - if(!$this->place_hierarchy) { |
|
351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | - $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | - } |
|
354 | - else { |
|
355 | - $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | - } |
|
357 | - } |
|
358 | - return $this->place_hierarchy; |
|
359 | - } |
|
340 | + /** |
|
341 | + * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | + * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | + * This is returned as an associative array: |
|
344 | + * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
345 | + * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | + * |
|
347 | + * @return array |
|
348 | + */ |
|
349 | + public function getPlacesHierarchy() { |
|
350 | + if(!$this->place_hierarchy) { |
|
351 | + if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | + $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | + } |
|
354 | + else { |
|
355 | + $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
356 | + } |
|
357 | + } |
|
358 | + return $this->place_hierarchy; |
|
359 | + } |
|
360 | 360 | |
361 | - /** |
|
362 | - * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | - * The places are reversed compared to normal GEDCOM structure. |
|
364 | - * |
|
365 | - * @return array|null |
|
366 | - */ |
|
367 | - protected function getPlacesHierarchyFromHeader() { |
|
368 | - $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | - $head_place = $head->getFirstFact('PLAC'); |
|
370 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | - } |
|
373 | - return null; |
|
374 | - } |
|
361 | + /** |
|
362 | + * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
363 | + * The places are reversed compared to normal GEDCOM structure. |
|
364 | + * |
|
365 | + * @return array|null |
|
366 | + */ |
|
367 | + protected function getPlacesHierarchyFromHeader() { |
|
368 | + $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
369 | + $head_place = $head->getFirstFact('PLAC'); |
|
370 | + if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
371 | + return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
372 | + } |
|
373 | + return null; |
|
374 | + } |
|
375 | 375 | |
376 | - /** |
|
377 | - * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | - * It will look for the longest hierarchy in the tree. |
|
379 | - * The places are reversed compared to normal GEDCOM structure. |
|
380 | - * |
|
381 | - * @return array |
|
382 | - */ |
|
383 | - protected function getPlacesHierarchyFromData() { |
|
384 | - $random_place = null; |
|
385 | - $nb_levels = 0; |
|
376 | + /** |
|
377 | + * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
378 | + * It will look for the longest hierarchy in the tree. |
|
379 | + * The places are reversed compared to normal GEDCOM structure. |
|
380 | + * |
|
381 | + * @return array |
|
382 | + */ |
|
383 | + protected function getPlacesHierarchyFromData() { |
|
384 | + $random_place = null; |
|
385 | + $nb_levels = 0; |
|
386 | 386 | |
387 | - //Select all '2 PLAC ' tags in the file and create array |
|
388 | - $places_list=array(); |
|
389 | - $ged_data = Database::prepare( |
|
390 | - 'SELECT i_gedcom AS gedcom'. |
|
391 | - ' FROM `##individuals`'. |
|
392 | - ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
393 | - ' UNION ALL'. |
|
394 | - 'SELECT f_gedcom AS gedcom'. |
|
395 | - ' FROM `##families`'. |
|
396 | - ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
397 | - )->execute(array( |
|
398 | - 'gedcom' => '%\n2 PLAC %', |
|
399 | - 'gedcom_id' => $this->tree->getTreeId() |
|
400 | - ))->fetchOneColumn(); |
|
401 | - foreach ($ged_data as $ged_datum) { |
|
402 | - preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | - foreach ($matches[1] as $match) { |
|
404 | - $places_list[$match]=true; |
|
405 | - } |
|
406 | - } |
|
387 | + //Select all '2 PLAC ' tags in the file and create array |
|
388 | + $places_list=array(); |
|
389 | + $ged_data = Database::prepare( |
|
390 | + 'SELECT i_gedcom AS gedcom'. |
|
391 | + ' FROM `##individuals`'. |
|
392 | + ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
393 | + ' UNION ALL'. |
|
394 | + 'SELECT f_gedcom AS gedcom'. |
|
395 | + ' FROM `##families`'. |
|
396 | + ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
397 | + )->execute(array( |
|
398 | + 'gedcom' => '%\n2 PLAC %', |
|
399 | + 'gedcom_id' => $this->tree->getTreeId() |
|
400 | + ))->fetchOneColumn(); |
|
401 | + foreach ($ged_data as $ged_datum) { |
|
402 | + preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
403 | + foreach ($matches[1] as $match) { |
|
404 | + $places_list[$match]=true; |
|
405 | + } |
|
406 | + } |
|
407 | 407 | |
408 | - // Unique list of places |
|
409 | - $places_list=array_keys($places_list); |
|
408 | + // Unique list of places |
|
409 | + $places_list=array_keys($places_list); |
|
410 | 410 | |
411 | - //sort the array, limit to unique values, and count them |
|
412 | - $places_parts=array(); |
|
413 | - usort($places_list, array('I18N', 'strcasecmp')); |
|
414 | - $nb_places = count($places_list); |
|
411 | + //sort the array, limit to unique values, and count them |
|
412 | + $places_parts=array(); |
|
413 | + usort($places_list, array('I18N', 'strcasecmp')); |
|
414 | + $nb_places = count($places_list); |
|
415 | 415 | |
416 | - //calculate maximum no. of levels to display |
|
417 | - $has_found_good_example = false; |
|
418 | - foreach($places_list as $place){ |
|
419 | - $levels = explode(",", $place); |
|
420 | - $parts = count($levels); |
|
421 | - if ($parts >= $nb_levels){ |
|
422 | - $nb_levels = $parts; |
|
423 | - if(!$has_found_good_example){ |
|
424 | - $random_place = $$place; |
|
425 | - if(min(array_map('strlen', $levels)) > 0){ |
|
426 | - $has_found_good_example = true; |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - } |
|
416 | + //calculate maximum no. of levels to display |
|
417 | + $has_found_good_example = false; |
|
418 | + foreach($places_list as $place){ |
|
419 | + $levels = explode(",", $place); |
|
420 | + $parts = count($levels); |
|
421 | + if ($parts >= $nb_levels){ |
|
422 | + $nb_levels = $parts; |
|
423 | + if(!$has_found_good_example){ |
|
424 | + $random_place = $$place; |
|
425 | + if(min(array_map('strlen', $levels)) > 0){ |
|
426 | + $has_found_good_example = true; |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + } |
|
431 | 431 | |
432 | - return array_reverse(array_map('trim',explode(',', $randomPlace))); |
|
433 | - } |
|
432 | + return array_reverse(array_map('trim',explode(',', $randomPlace))); |
|
433 | + } |
|
434 | 434 | |
435 | - /** |
|
436 | - * Returns the list of geodispersion maps available within the maps folder. |
|
437 | - * |
|
438 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
439 | - */ |
|
440 | - public function getOutlineMapsList() { |
|
441 | - $res = array(); |
|
442 | - $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
443 | - if(is_dir($root_path)){ |
|
444 | - $dir = opendir($root_path); |
|
445 | - while (($file=readdir($dir))!== false) { |
|
446 | - if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
447 | - $res[base64_encode($file)] = new OutlineMap($file, true); |
|
448 | - } |
|
449 | - } |
|
450 | - } |
|
451 | - return $res; |
|
452 | - } |
|
435 | + /** |
|
436 | + * Returns the list of geodispersion maps available within the maps folder. |
|
437 | + * |
|
438 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
439 | + */ |
|
440 | + public function getOutlineMapsList() { |
|
441 | + $res = array(); |
|
442 | + $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
443 | + if(is_dir($root_path)){ |
|
444 | + $dir = opendir($root_path); |
|
445 | + while (($file=readdir($dir))!== false) { |
|
446 | + if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
447 | + $res[base64_encode($file)] = new OutlineMap($file, true); |
|
448 | + } |
|
449 | + } |
|
450 | + } |
|
451 | + return $res; |
|
452 | + } |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | \ No newline at end of file |
@@ -25,64 +25,64 @@ discard block |
||
25 | 25 | * Geo Analysis ID |
26 | 26 | * @var int $id |
27 | 27 | */ |
28 | - protected $id; |
|
28 | + protected $id; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Geo Analysis Title |
32 | 32 | * @var string $title |
33 | 33 | */ |
34 | - protected $title; |
|
34 | + protected $title; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Level of the Gedcom hierarchy for the analysis |
38 | 38 | * @var int $analysis_level |
39 | 39 | */ |
40 | - protected $analysis_level; |
|
40 | + protected $analysis_level; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Display options |
|
44 | - * @var GeoDisplayOptions $options |
|
45 | - */ |
|
46 | - protected $options; |
|
42 | + /** |
|
43 | + * Display options |
|
44 | + * @var GeoDisplayOptions $options |
|
45 | + */ |
|
46 | + protected $options; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Reference tree |
|
50 | - * @var Tree $tree |
|
51 | - */ |
|
52 | - protected $tree; |
|
48 | + /** |
|
49 | + * Reference tree |
|
50 | + * @var Tree $tree |
|
51 | + */ |
|
52 | + protected $tree; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Is the analysis enabled |
|
56 | - * @var bool $enabled |
|
57 | - */ |
|
58 | - protected $enabled; |
|
54 | + /** |
|
55 | + * Is the analysis enabled |
|
56 | + * @var bool $enabled |
|
57 | + */ |
|
58 | + protected $enabled; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Constructor for GeoAnalysis. |
|
62 | - * |
|
63 | - * @param Tree $tree Reference tree |
|
60 | + /** |
|
61 | + * Constructor for GeoAnalysis. |
|
62 | + * |
|
63 | + * @param Tree $tree Reference tree |
|
64 | 64 | * @param int $id GeoAnalysis ID |
65 | 65 | * @param string $title GeoAnalysis title |
66 | 66 | * @param int $analysis_level Analysis level |
67 | 67 | * @param (GeoDisplayOptions|null) $options Display options |
68 | 68 | * @param bool $enabled Is analysis enabled |
69 | - */ |
|
70 | - public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
71 | - $this->tree = $tree; |
|
72 | - $this->id = $id; |
|
73 | - $this->title = $title; |
|
74 | - $this->analysis_level = $analysis_level; |
|
75 | - $this->options = $options; |
|
76 | - $this->enabled = $enabled; |
|
77 | - } |
|
69 | + */ |
|
70 | + public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
71 | + $this->tree = $tree; |
|
72 | + $this->id = $id; |
|
73 | + $this->title = $title; |
|
74 | + $this->analysis_level = $analysis_level; |
|
75 | + $this->options = $options; |
|
76 | + $this->enabled = $enabled; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Get the analysis title |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function getTitle() { |
|
84 | - return $this->title; |
|
85 | - } |
|
83 | + public function getTitle() { |
|
84 | + return $this->title; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Set the analysis title |
@@ -90,53 +90,53 @@ discard block |
||
90 | 90 | * @param string $title |
91 | 91 | * @return self Enable method-chaining |
92 | 92 | */ |
93 | - public function setTitle($title) { |
|
94 | - $this->title = $title; |
|
95 | - return $this; |
|
96 | - } |
|
93 | + public function setTitle($title) { |
|
94 | + $this->title = $title; |
|
95 | + return $this; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Get the analysis ID |
100 | 100 | * @return int |
101 | 101 | */ |
102 | - public function getId() { |
|
103 | - return $this->id; |
|
104 | - } |
|
102 | + public function getId() { |
|
103 | + return $this->id; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Get the analysis status (enabled/disabled) |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - public function isEnabled() { |
|
111 | - return $this->enabled; |
|
112 | - } |
|
110 | + public function isEnabled() { |
|
111 | + return $this->enabled; |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Get analysis options |
|
116 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
117 | - */ |
|
118 | - public function getOptions() { |
|
119 | - return $this->options; |
|
120 | - } |
|
114 | + /** |
|
115 | + * Get analysis options |
|
116 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
117 | + */ |
|
118 | + public function getOptions() { |
|
119 | + return $this->options; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | /** |
123 | - * Set analysis options |
|
123 | + * Set analysis options |
|
124 | 124 | * |
125 | - * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
125 | + * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
126 | 126 | * @return self Enable method-chaining |
127 | - */ |
|
128 | - public function setOptions(GeoDisplayOptions $options) { |
|
129 | - $this->options = $options; |
|
130 | - return $this; |
|
131 | - } |
|
127 | + */ |
|
128 | + public function setOptions(GeoDisplayOptions $options) { |
|
129 | + $this->options = $options; |
|
130 | + return $this; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Get analysis level |
135 | 135 | * @return int |
136 | 136 | */ |
137 | - public function getAnalysisLevel() { |
|
138 | - return $this->analysis_level; |
|
139 | - } |
|
137 | + public function getAnalysisLevel() { |
|
138 | + return $this->analysis_level; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Get analysis level |
@@ -144,19 +144,19 @@ discard block |
||
144 | 144 | * @param int $analysis_level |
145 | 145 | * @return self Enable method-chaining |
146 | 146 | */ |
147 | - public function setAnalysisLevel($analysis_level) { |
|
148 | - $this->analysis_level = $analysis_level; |
|
149 | - return $this; |
|
150 | - } |
|
147 | + public function setAnalysisLevel($analysis_level) { |
|
148 | + $this->analysis_level = $analysis_level; |
|
149 | + return $this; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Check whether the analysis has a linked map |
154 | 154 | * |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function hasMap() { |
|
158 | - return $this->options && $this->options->getMap(); |
|
159 | - } |
|
157 | + public function hasMap() { |
|
158 | + return $this->options && $this->options->getMap(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Get the URL for the GeoAnalysis. |
@@ -164,117 +164,117 @@ discard block |
||
164 | 164 | * @return string |
165 | 165 | */ |
166 | 166 | public function getHtmlUrl() { |
167 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
168 | - } |
|
167 | + return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Return the dispersion analysis tables. |
|
172 | - * Two arrays are returned : |
|
173 | - * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
174 | - * - knownsum : Number of known places |
|
175 | - * - unknown : Number of unknown places |
|
176 | - * - max : Maximum count of ancestors within a place |
|
177 | - * - other : Other places (not in the top level area) |
|
178 | - * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
179 | - * - sum : Number of known places |
|
180 | - * - unknown : Number of unknown places |
|
181 | - * - other : Other places (not in the top level area) |
|
182 | - * |
|
183 | - * @param array $sosalist List of all sosas |
|
184 | - * @return array Array of the general and generations table |
|
185 | - */ |
|
186 | - public function getAnalysisResults($sosalist) { |
|
187 | - $placesDispGeneral = null; |
|
188 | - $placesDispGenerations = null; |
|
170 | + /** |
|
171 | + * Return the dispersion analysis tables. |
|
172 | + * Two arrays are returned : |
|
173 | + * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
174 | + * - knownsum : Number of known places |
|
175 | + * - unknown : Number of unknown places |
|
176 | + * - max : Maximum count of ancestors within a place |
|
177 | + * - other : Other places (not in the top level area) |
|
178 | + * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
179 | + * - sum : Number of known places |
|
180 | + * - unknown : Number of unknown places |
|
181 | + * - other : Other places (not in the top level area) |
|
182 | + * |
|
183 | + * @param array $sosalist List of all sosas |
|
184 | + * @return array Array of the general and generations table |
|
185 | + */ |
|
186 | + public function getAnalysisResults($sosalist) { |
|
187 | + $placesDispGeneral = null; |
|
188 | + $placesDispGenerations = null; |
|
189 | 189 | |
190 | - if($sosalist && count($sosalist) > 0) { |
|
191 | - $placesDispGeneral['knownsum'] = 0; |
|
192 | - $placesDispGeneral['unknown'] = 0; |
|
193 | - $placesDispGeneral['max'] = 0; |
|
194 | - $placesDispGeneral['places'] = array(); |
|
195 | - foreach($sosalist as $sosaid => $gens) { |
|
196 | - $sosa = Individual::getIntance($sosaid, $this->tree); |
|
197 | - $place =$sosa->getSignificantPlace(); |
|
198 | - $genstab = explode(',', $gens); |
|
199 | - $isUnknown=true; |
|
200 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | - if(count($levels)>= $this->analysis_level){ |
|
203 | - $toplevelvalues = array(); |
|
204 | - if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
206 | - } |
|
207 | - if(!$this->hasMap() |
|
208 | - || is_null($this->options->getMapLevel()) |
|
209 | - || $this->options->getMap()->getTopLevelName() == '*' |
|
210 | - || ( |
|
211 | - $this->options->getMapLevel() <= $this->analysis_level |
|
212 | - && $this->options->getMapLevel() > 0 |
|
213 | - && count($levels) >= $this->options->getMapLevel() |
|
214 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
215 | - ) |
|
216 | - ) { |
|
217 | - $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
218 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
219 | - $placesDispGeneral['places'][$placest] += 1; |
|
220 | - } |
|
221 | - else { |
|
222 | - $placesDispGeneral['places'][$placest] = 1; |
|
223 | - } |
|
224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
226 | - foreach($genstab as $gen) { |
|
227 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | - $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
229 | - } |
|
230 | - else { |
|
231 | - $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
232 | - } |
|
233 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | - $placesDispGenerations[$gen]['sum'] += 1; |
|
235 | - } |
|
236 | - else { |
|
237 | - $placesDispGenerations[$gen]['sum'] = 1; |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
241 | - else{ |
|
242 | - if(isset($placesDispGeneral['other'])) { |
|
243 | - $placesDispGeneral['other'] += 1; |
|
244 | - } |
|
245 | - else { |
|
246 | - $placesDispGeneral['other'] = 1; |
|
247 | - } |
|
248 | - foreach($genstab as $gen) { |
|
249 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | - $placesDispGenerations[$gen]['other'] += 1; |
|
251 | - } |
|
252 | - else { |
|
253 | - $placesDispGenerations[$gen]['other'] = 1; |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
257 | - $placesDispGeneral['knownsum'] += 1; |
|
258 | - $isUnknown = false; |
|
259 | - } |
|
260 | - } |
|
261 | - if($isUnknown){ |
|
262 | - $placesDispGeneral['unknown'] += 1; |
|
263 | - foreach($genstab as $gen) { |
|
264 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | - $placesDispGenerations[$gen]['unknown'] += 1; |
|
266 | - } |
|
267 | - else { |
|
268 | - $placesDispGenerations[$gen]['unknown'] = 1; |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - } |
|
190 | + if($sosalist && count($sosalist) > 0) { |
|
191 | + $placesDispGeneral['knownsum'] = 0; |
|
192 | + $placesDispGeneral['unknown'] = 0; |
|
193 | + $placesDispGeneral['max'] = 0; |
|
194 | + $placesDispGeneral['places'] = array(); |
|
195 | + foreach($sosalist as $sosaid => $gens) { |
|
196 | + $sosa = Individual::getIntance($sosaid, $this->tree); |
|
197 | + $place =$sosa->getSignificantPlace(); |
|
198 | + $genstab = explode(',', $gens); |
|
199 | + $isUnknown=true; |
|
200 | + if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
201 | + $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
202 | + if(count($levels)>= $this->analysis_level){ |
|
203 | + $toplevelvalues = array(); |
|
204 | + if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
205 | + $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
206 | + } |
|
207 | + if(!$this->hasMap() |
|
208 | + || is_null($this->options->getMapLevel()) |
|
209 | + || $this->options->getMap()->getTopLevelName() == '*' |
|
210 | + || ( |
|
211 | + $this->options->getMapLevel() <= $this->analysis_level |
|
212 | + && $this->options->getMapLevel() > 0 |
|
213 | + && count($levels) >= $this->options->getMapLevel() |
|
214 | + && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
215 | + ) |
|
216 | + ) { |
|
217 | + $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
218 | + if(isset($placesDispGeneral['places'][$placest])) { |
|
219 | + $placesDispGeneral['places'][$placest] += 1; |
|
220 | + } |
|
221 | + else { |
|
222 | + $placesDispGeneral['places'][$placest] = 1; |
|
223 | + } |
|
224 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
225 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
226 | + foreach($genstab as $gen) { |
|
227 | + if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | + $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
229 | + } |
|
230 | + else { |
|
231 | + $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
232 | + } |
|
233 | + if(isset($placesDispGenerations[$gen]['sum'])) { |
|
234 | + $placesDispGenerations[$gen]['sum'] += 1; |
|
235 | + } |
|
236 | + else { |
|
237 | + $placesDispGenerations[$gen]['sum'] = 1; |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | + else{ |
|
242 | + if(isset($placesDispGeneral['other'])) { |
|
243 | + $placesDispGeneral['other'] += 1; |
|
244 | + } |
|
245 | + else { |
|
246 | + $placesDispGeneral['other'] = 1; |
|
247 | + } |
|
248 | + foreach($genstab as $gen) { |
|
249 | + if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | + $placesDispGenerations[$gen]['other'] += 1; |
|
251 | + } |
|
252 | + else { |
|
253 | + $placesDispGenerations[$gen]['other'] = 1; |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | + $placesDispGeneral['knownsum'] += 1; |
|
258 | + $isUnknown = false; |
|
259 | + } |
|
260 | + } |
|
261 | + if($isUnknown){ |
|
262 | + $placesDispGeneral['unknown'] += 1; |
|
263 | + foreach($genstab as $gen) { |
|
264 | + if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | + $placesDispGenerations[$gen]['unknown'] += 1; |
|
266 | + } |
|
267 | + else { |
|
268 | + $placesDispGenerations[$gen]['unknown'] = 1; |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + } |
|
273 | 273 | |
274 | - } |
|
274 | + } |
|
275 | 275 | |
276 | - return array($placesDispGeneral, $placesDispGenerations); |
|
277 | - } |
|
276 | + return array($placesDispGeneral, $placesDispGenerations); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | |
280 | 280 | } |
@@ -21,175 +21,175 @@ |
||
21 | 21 | * Name of the file containing the description of the map. |
22 | 22 | * @var string $filename |
23 | 23 | */ |
24 | - protected $filename; |
|
24 | + protected $filename; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Indicates whether the description has been loaded from the file. |
28 | 28 | * @var bool $is_loaded |
29 | 29 | */ |
30 | - protected $is_loaded; |
|
30 | + protected $is_loaded; |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Description/title of the map. |
34 | 34 | * @var string $description |
35 | 35 | */ |
36 | - protected $description; |
|
36 | + protected $description; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Name(s) of the parent level(s) of the map. |
40 | 40 | * @var string $is_loaded |
41 | 41 | */ |
42 | - protected $top_level_name; |
|
42 | + protected $top_level_name; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Map canvas |
|
46 | - * @var OutlineMapCanvas $canvas |
|
47 | - */ |
|
48 | - protected $canvas; |
|
44 | + /** |
|
45 | + * Map canvas |
|
46 | + * @var OutlineMapCanvas $canvas |
|
47 | + */ |
|
48 | + protected $canvas; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Map subdivisions |
|
52 | - * @var array $subdivisions |
|
53 | - */ |
|
54 | - protected $subdivisions; |
|
50 | + /** |
|
51 | + * Map subdivisions |
|
52 | + * @var array $subdivisions |
|
53 | + */ |
|
54 | + protected $subdivisions; |
|
55 | 55 | |
56 | - /** |
|
57 | - * Places mappings |
|
58 | - * @var array $subdivisions |
|
59 | - */ |
|
60 | - protected $mappings; |
|
56 | + /** |
|
57 | + * Places mappings |
|
58 | + * @var array $subdivisions |
|
59 | + */ |
|
60 | + protected $mappings; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Constructor for GeoAnalysisMap. |
|
64 | - * |
|
65 | - * @param string $filename Outline map file name |
|
66 | - * @param bool $load Should the map be loaded immediately |
|
67 | - */ |
|
68 | - public function __construct($filename, $load = false) { |
|
69 | - $this->filename = $filename; |
|
70 | - $this->is_loaded = false; |
|
71 | - $this->subdivisions = array(); |
|
72 | - $this->mappings = array(); |
|
73 | - if($load) $this->load(); |
|
74 | - } |
|
62 | + /** |
|
63 | + * Constructor for GeoAnalysisMap. |
|
64 | + * |
|
65 | + * @param string $filename Outline map file name |
|
66 | + * @param bool $load Should the map be loaded immediately |
|
67 | + */ |
|
68 | + public function __construct($filename, $load = false) { |
|
69 | + $this->filename = $filename; |
|
70 | + $this->is_loaded = false; |
|
71 | + $this->subdivisions = array(); |
|
72 | + $this->mappings = array(); |
|
73 | + if($load) $this->load(); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Load the map settings contained within its XML representation |
|
78 | - * |
|
79 | - * XML structure : |
|
80 | - * - displayName : Display name of the map |
|
81 | - * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
82 | - * - canvas : all settings related to the map canvas. |
|
83 | - * - width : canvas width, in px |
|
84 | - * - height : canvas height, in px |
|
85 | - * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
86 | - * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
87 | - * - bgcolor : map background color, RGB hexadecimal |
|
88 | - * - bgstroke : map stroke color, RGB hexadecimal |
|
89 | - * - defaultcolor : default color of places, RGB hexadecimal |
|
90 | - * - defaultstroke : default stroke color, RGB hexadecimal |
|
91 | - * - subdvisions : for each subdivision : |
|
76 | + /** |
|
77 | + * Load the map settings contained within its XML representation |
|
78 | + * |
|
79 | + * XML structure : |
|
80 | + * - displayName : Display name of the map |
|
81 | + * - topLevel : Values of the top level subdivisions (separated by commas, if multiple) |
|
82 | + * - canvas : all settings related to the map canvas. |
|
83 | + * - width : canvas width, in px |
|
84 | + * - height : canvas height, in px |
|
85 | + * - maxcolor : color to identify places with ancestors, RGB hexadecimal |
|
86 | + * - hovercolor : same as previous, color when mouse is hovering the place, RGB hexadecimal |
|
87 | + * - bgcolor : map background color, RGB hexadecimal |
|
88 | + * - bgstroke : map stroke color, RGB hexadecimal |
|
89 | + * - defaultcolor : default color of places, RGB hexadecimal |
|
90 | + * - defaultstroke : default stroke color, RGB hexadecimal |
|
91 | + * - subdvisions : for each subdivision : |
|
92 | 92 | * - id : Subdivision id, must be compatible with PHP variable constraints, and unique |
93 | - * - name: Display name for the place |
|
93 | + * - name: Display name for the place |
|
94 | 94 | * - parent: if any, describe to which parent level the place if belonging to |
95 | - * - <em>Element value<em> : SVG description of the subdvision shape |
|
95 | + * - <em>Element value<em> : SVG description of the subdvision shape |
|
96 | 96 | * - mapping : for each subdivision : |
97 | 97 | * - name : Name of the place to map |
98 | - * - mapto: Name of the place to map to |
|
98 | + * - mapto: Name of the place to map to |
|
99 | 99 | * |
100 | - */ |
|
101 | - protected function load() { |
|
102 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | - $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
104 | - if($xml){ |
|
105 | - $this->description = trim($xml->displayName); |
|
106 | - $this->top_level_name = trim($xml->topLevel); |
|
107 | - $this->canvas = new OutlineMapCanvas( |
|
108 | - trim($xml->canvas->width), |
|
109 | - trim($xml->canvas->height), |
|
110 | - trim($xml->canvas->maxcolor), |
|
111 | - trim($xml->canvas->hovercolor), |
|
112 | - trim($xml->canvas->bgcolor), |
|
113 | - trim($xml->canvas->bgstroke), |
|
114 | - trim($xml->canvas->defaultcolor), |
|
115 | - trim($xml->canvas->defaultstroke) |
|
116 | - ); |
|
117 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | - $attributes = $subdivision->attributes(); |
|
119 | - $key = trim($attributes['name']); |
|
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | - $this->subdivisions[$key] = array( |
|
122 | - 'id' => trim($attributes['id']), |
|
123 | - 'displayname' => trim($attributes['name']), |
|
124 | - 'coord' => trim($subdivision[0]) |
|
125 | - ); |
|
126 | - } |
|
127 | - if(isset($xml->mappings)) { |
|
128 | - foreach($xml->mappings->children() as $mappings){ |
|
129 | - $attributes = $mappings->attributes(); |
|
130 | - $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
|
131 | - } |
|
132 | - } |
|
133 | - $this->is_loaded = true; |
|
134 | - return; |
|
135 | - } |
|
136 | - } |
|
137 | - throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
138 | - } |
|
100 | + */ |
|
101 | + protected function load() { |
|
102 | + if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | + $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
|
104 | + if($xml){ |
|
105 | + $this->description = trim($xml->displayName); |
|
106 | + $this->top_level_name = trim($xml->topLevel); |
|
107 | + $this->canvas = new OutlineMapCanvas( |
|
108 | + trim($xml->canvas->width), |
|
109 | + trim($xml->canvas->height), |
|
110 | + trim($xml->canvas->maxcolor), |
|
111 | + trim($xml->canvas->hovercolor), |
|
112 | + trim($xml->canvas->bgcolor), |
|
113 | + trim($xml->canvas->bgstroke), |
|
114 | + trim($xml->canvas->defaultcolor), |
|
115 | + trim($xml->canvas->defaultstroke) |
|
116 | + ); |
|
117 | + foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | + $attributes = $subdivision->attributes(); |
|
119 | + $key = trim($attributes['name']); |
|
120 | + if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | + $this->subdivisions[$key] = array( |
|
122 | + 'id' => trim($attributes['id']), |
|
123 | + 'displayname' => trim($attributes['name']), |
|
124 | + 'coord' => trim($subdivision[0]) |
|
125 | + ); |
|
126 | + } |
|
127 | + if(isset($xml->mappings)) { |
|
128 | + foreach($xml->mappings->children() as $mappings){ |
|
129 | + $attributes = $mappings->attributes(); |
|
130 | + $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
|
131 | + } |
|
132 | + } |
|
133 | + $this->is_loaded = true; |
|
134 | + return; |
|
135 | + } |
|
136 | + } |
|
137 | + throw new \Exception('The Outline Map could not be loaded from XML.'); |
|
138 | + } |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Get the map file name. |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function getFileName() { |
|
145 | - if(!$this->is_loaded) $this->load(); |
|
146 | - return $this->filename; |
|
147 | - } |
|
144 | + public function getFileName() { |
|
145 | + if(!$this->is_loaded) $this->load(); |
|
146 | + return $this->filename; |
|
147 | + } |
|
148 | 148 | |
149 | 149 | /** |
150 | 150 | * Get the map file name. |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function getDescription() { |
|
154 | - if(!$this->is_loaded) $this->load(); |
|
155 | - return $this->description; |
|
156 | - } |
|
153 | + public function getDescription() { |
|
154 | + if(!$this->is_loaded) $this->load(); |
|
155 | + return $this->description; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Get the name of the map parent level. |
160 | 160 | * @return string |
161 | 161 | */ |
162 | - public function getTopLevelName() { |
|
163 | - if(!$this->is_loaded) $this->load(); |
|
164 | - return $this->top_level_name; |
|
165 | - } |
|
162 | + public function getTopLevelName() { |
|
163 | + if(!$this->is_loaded) $this->load(); |
|
164 | + return $this->top_level_name; |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * Get the Outline Map canvas. |
|
169 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
170 | - */ |
|
171 | - public function getCanvas() { |
|
172 | - if(!$this->is_loaded) $this->load(); |
|
173 | - return $this->canvas; |
|
174 | - } |
|
167 | + /** |
|
168 | + * Get the Outline Map canvas. |
|
169 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
|
170 | + */ |
|
171 | + public function getCanvas() { |
|
172 | + if(!$this->is_loaded) $this->load(); |
|
173 | + return $this->canvas; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | /** |
177 | - * Get the subdivisions of the map. |
|
178 | - * @return array |
|
179 | - */ |
|
180 | - public function getSubdivisions() { |
|
181 | - if(!$this->is_loaded) $this->load(); |
|
182 | - return $this->subdivisions; |
|
183 | - } |
|
177 | + * Get the subdivisions of the map. |
|
178 | + * @return array |
|
179 | + */ |
|
180 | + public function getSubdivisions() { |
|
181 | + if(!$this->is_loaded) $this->load(); |
|
182 | + return $this->subdivisions; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | /** |
186 | - * Get the places mappings of the map. |
|
187 | - * @return array |
|
188 | - */ |
|
189 | - public function getPlacesMappings() { |
|
190 | - if(!$this->is_loaded) $this->load(); |
|
191 | - return $this->mappings; |
|
192 | - } |
|
186 | + * Get the places mappings of the map. |
|
187 | + * @return array |
|
188 | + */ |
|
189 | + public function getPlacesMappings() { |
|
190 | + if(!$this->is_loaded) $this->load(); |
|
191 | + return $this->mappings; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | 196 | \ No newline at end of file |
@@ -24,18 +24,18 @@ |
||
24 | 24 | */ |
25 | 25 | public function upgrade() { |
26 | 26 | Database::exec( |
27 | - 'CREATE TABLE IF NOT EXISTS `##maj_geodispersion` ('. |
|
28 | - ' majgd_id INTEGER AUTO_INCREMENT NOT NULL,'. |
|
29 | - ' majgd_file INTEGER NOT NULL,'. |
|
30 | - ' majgd_descr VARCHAR(70) NOT NULL,'. |
|
31 | - ' majgd_sublevel TINYINT NOT NULL,'. |
|
32 | - ' majgd_map VARCHAR(70) NULL,'. |
|
33 | - ' majgd_toplevel TINYINT NULL,'. |
|
34 | - ' majgd_status ENUM(\'enabled\', \'disabled\') NOT NULL DEFAULT \'enabled\','. |
|
35 | - ' majgd_useflagsgen ENUM(\'yes\', \'no\') NOT NULL DEFAULT \'no\','. |
|
36 | - ' majgd_detailsgen TINYINT NOT NULL DEFAULT 0,'. |
|
37 | - ' PRIMARY KEY (majgd_id)'. |
|
38 | - ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
27 | + 'CREATE TABLE IF NOT EXISTS `##maj_geodispersion` ('. |
|
28 | + ' majgd_id INTEGER AUTO_INCREMENT NOT NULL,'. |
|
29 | + ' majgd_file INTEGER NOT NULL,'. |
|
30 | + ' majgd_descr VARCHAR(70) NOT NULL,'. |
|
31 | + ' majgd_sublevel TINYINT NOT NULL,'. |
|
32 | + ' majgd_map VARCHAR(70) NULL,'. |
|
33 | + ' majgd_toplevel TINYINT NULL,'. |
|
34 | + ' majgd_status ENUM(\'enabled\', \'disabled\') NOT NULL DEFAULT \'enabled\','. |
|
35 | + ' majgd_useflagsgen ENUM(\'yes\', \'no\') NOT NULL DEFAULT \'no\','. |
|
36 | + ' majgd_detailsgen TINYINT NOT NULL DEFAULT 0,'. |
|
37 | + ' PRIMARY KEY (majgd_id)'. |
|
38 | + ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * {@inhericDoc} |
26 | 26 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
27 | 27 | */ |
28 | - protected function renderContent() { |
|
28 | + protected function renderContent() { |
|
29 | 29 | |
30 | - /** @var GeoAnalysis $ga */ |
|
31 | - $ga = $this->data->get('geo_analysis'); |
|
32 | - $is_new = is_null($ga); |
|
30 | + /** @var GeoAnalysis $ga */ |
|
31 | + $ga = $this->data->get('geo_analysis'); |
|
32 | + $is_new = is_null($ga); |
|
33 | 33 | |
34 | - $places_hierarchy = $this->data->get('places_hierarchy'); |
|
35 | - ?> |
|
34 | + $places_hierarchy = $this->data->get('places_hierarchy'); |
|
35 | + ?> |
|
36 | 36 | <ol class="breadcrumb small"> |
37 | 37 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
38 | 38 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | </form> |
156 | 156 | |
157 | 157 | <?php |
158 | - } |
|
158 | + } |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | |
162 | 162 | \ No newline at end of file |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | * {@inhericDoc} |
25 | 25 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
26 | 26 | */ |
27 | - protected function renderContent() { |
|
28 | - ?> |
|
27 | + protected function renderContent() { |
|
28 | + ?> |
|
29 | 29 | <div id="maj-geodisp-list-page" class="center"> |
30 | 30 | <h2><?php echo $this->data->get('title'); ?></h2> |
31 | 31 | |
32 | 32 | <?php |
33 | 33 | if($this->data->get('has_analysis', false)) { |
34 | - /** @var GeoAnalysis $ga */ |
|
35 | - $ga = $this->data->get('geoanalysis'); |
|
36 | - ?> |
|
34 | + /** @var GeoAnalysis $ga */ |
|
35 | + $ga = $this->data->get('geoanalysis'); |
|
36 | + ?> |
|
37 | 37 | |
38 | 38 | <div id="geodispersion-panel"> |
39 | 39 | <h3><?php echo $ga->getTitle() ?></h3> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | </div> |
67 | 67 | |
68 | 68 | <?php |
69 | - } |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
73 | 73 | \ No newline at end of file |
@@ -26,90 +26,90 @@ discard block |
||
26 | 26 | * {@inhericDoc} |
27 | 27 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
28 | 28 | */ |
29 | - protected function renderContent() { |
|
29 | + protected function renderContent() { |
|
30 | 30 | |
31 | - $max_details_gen = $this->data->get('max_details_gen'); |
|
32 | - $use_flags = $this->data->get('use_flags'); |
|
33 | - $analysis_level = $this->data->get('analysis_level'); |
|
34 | - $results_by_gen = $this->data->get('results_by_generations'); |
|
35 | - $display_all_places = $this->data->get('display_all_places', true); |
|
31 | + $max_details_gen = $this->data->get('max_details_gen'); |
|
32 | + $use_flags = $this->data->get('use_flags'); |
|
33 | + $analysis_level = $this->data->get('analysis_level'); |
|
34 | + $results_by_gen = $this->data->get('results_by_generations'); |
|
35 | + $display_all_places = $this->data->get('display_all_places', true); |
|
36 | 36 | |
37 | - $html = |
|
38 | - '<div id="geodispersion_gen"> |
|
37 | + $html = |
|
38 | + '<div id="geodispersion_gen"> |
|
39 | 39 | <table id="geodispersion_gentable" class="center">'; |
40 | 40 | |
41 | - foreach($results_by_gen as $gen => $genData){ |
|
42 | - $html .= |
|
43 | - '<tr> |
|
41 | + foreach($results_by_gen as $gen => $genData){ |
|
42 | + $html .= |
|
43 | + '<tr> |
|
44 | 44 | <td class="descriptionbox">' . |
45 | - I18N::translate("Generation %s", I18N::number($gen)). |
|
46 | - ($display_all_places ? '<br />' : ' '). |
|
47 | - I18N::translate('(%s)', I18N::percentage(Functions::safeDivision($genData['sum'] + $genData['other'], $genData['sum'] + $genData['other'] + $genData['unknown']),1)) . |
|
48 | - '</td> |
|
45 | + I18N::translate("Generation %s", I18N::number($gen)). |
|
46 | + ($display_all_places ? '<br />' : ' '). |
|
47 | + I18N::translate('(%s)', I18N::percentage(Functions::safeDivision($genData['sum'] + $genData['other'], $genData['sum'] + $genData['other'] + $genData['unknown']),1)) . |
|
48 | + '</td> |
|
49 | 49 | <td class="optionbox left">'. |
50 | - ($display_all_places ? |
|
51 | - $this->htmlGenerationAllPlacesRow($genData, $analysis_level) : |
|
52 | - $this->htmlGenerationTopPlacesRow($genData, $analysis_level) |
|
53 | - ) . |
|
54 | - '</ditdv> |
|
50 | + ($display_all_places ? |
|
51 | + $this->htmlGenerationAllPlacesRow($genData, $analysis_level) : |
|
52 | + $this->htmlGenerationTopPlacesRow($genData, $analysis_level) |
|
53 | + ) . |
|
54 | + '</ditdv> |
|
55 | 55 | </tr>'; |
56 | - } |
|
56 | + } |
|
57 | 57 | |
58 | - $html.= |
|
59 | - '</table> |
|
58 | + $html.= |
|
59 | + '</table> |
|
60 | 60 | <div class="left"> |
61 | 61 | <strong>' . I18N::translate('Interpretation help:') . '</strong> |
62 | 62 | <br />'. |
63 | - I18N::translate('<strong>Generation X (yy %%)</strong>: The percentage indicates the number of found places compared to the total number of ancestors in this generation.') . |
|
64 | - '<br />'; |
|
65 | - if(!is_null($max_details_gen) && $max_details_gen == 0){ |
|
66 | - $html .= I18N::translate('<strong><em>Place</em> or <em>Flag</em> aa (bb %%)</strong>: The first number indicates the total number of ancestors born in this place, the percentage relates this count to the total number of found places. No percentage means it is less than 10%%.').'<br />'; |
|
67 | - $html .= I18N::translate('If any, the darker area indicates the number of unknown places within the generation or places outside the analysed area, and its percentage compared to the number of ancestors. No percentage means it is less than 10%%.'); |
|
68 | - } |
|
69 | - else{ |
|
70 | - $html .= I18N::translate('<strong><em>Place</em> [aa - bb %%]</strong>: The first number indicates the total number of ancestors born in this place, the percentage compares this count to the total number of found places.').'<br />'; |
|
71 | - $html .= I18N::translate('Only the %d more frequent places for each generation are displayed.', $max_details_gen); |
|
72 | - } |
|
73 | - $html.= |
|
74 | - '</div> |
|
63 | + I18N::translate('<strong>Generation X (yy %%)</strong>: The percentage indicates the number of found places compared to the total number of ancestors in this generation.') . |
|
64 | + '<br />'; |
|
65 | + if(!is_null($max_details_gen) && $max_details_gen == 0){ |
|
66 | + $html .= I18N::translate('<strong><em>Place</em> or <em>Flag</em> aa (bb %%)</strong>: The first number indicates the total number of ancestors born in this place, the percentage relates this count to the total number of found places. No percentage means it is less than 10%%.').'<br />'; |
|
67 | + $html .= I18N::translate('If any, the darker area indicates the number of unknown places within the generation or places outside the analysed area, and its percentage compared to the number of ancestors. No percentage means it is less than 10%%.'); |
|
68 | + } |
|
69 | + else{ |
|
70 | + $html .= I18N::translate('<strong><em>Place</em> [aa - bb %%]</strong>: The first number indicates the total number of ancestors born in this place, the percentage compares this count to the total number of found places.').'<br />'; |
|
71 | + $html .= I18N::translate('Only the %d more frequent places for each generation are displayed.', $max_details_gen); |
|
72 | + } |
|
73 | + $html.= |
|
74 | + '</div> |
|
75 | 75 | </div>'; |
76 | 76 | |
77 | - return $html; |
|
78 | - } |
|
77 | + return $html; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Return the HTML code to display a row with all places found in a generation. |
|
83 | - * |
|
84 | - * @param array $data Data array |
|
85 | - * @param int $analysis_level Level of subdivision of analysis |
|
86 | - * @return string HTML code for all places row |
|
87 | - */ |
|
88 | - protected function htmlGenerationAllPlacesRow($data, $analysis_level) { |
|
89 | - $html = |
|
90 | - '<table class="geodispersion_bigrow"> |
|
81 | + /** |
|
82 | + * Return the HTML code to display a row with all places found in a generation. |
|
83 | + * |
|
84 | + * @param array $data Data array |
|
85 | + * @param int $analysis_level Level of subdivision of analysis |
|
86 | + * @return string HTML code for all places row |
|
87 | + */ |
|
88 | + protected function htmlGenerationAllPlacesRow($data, $analysis_level) { |
|
89 | + $html = |
|
90 | + '<table class="geodispersion_bigrow"> |
|
91 | 91 | <tr>'; |
92 | 92 | |
93 | - $sum_gen = $data['sum']; |
|
94 | - $unknownother = $data['unknown'] + $data['other']; |
|
95 | - foreach($data['places'] as $placename=> $dataplace){ |
|
96 | - $levels = array_map('trim',explode(',', $placename)); |
|
97 | - $content = ''; |
|
98 | - if(isset($dataplace['flag'])){ |
|
99 | - $content .= '<td class="geodispersion_flag">'. FunctionsPrint::htmlPlaceIcon($dataplace['place'], $dataplace['flag']) .'</td><td>'; |
|
100 | - } |
|
101 | - else{ |
|
102 | - $content .= '<td><span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span><br/>'; |
|
103 | - } |
|
104 | - $count = $dataplace['count']; |
|
105 | - $content .= I18N::number($count); |
|
106 | - $perc = Functions::safeDivision($count, $sum_gen + $unknownother); |
|
107 | - $perc2= Functions::safeDivision($count, $sum_gen); |
|
108 | - if($perc2>=0.1) |
|
109 | - $content.= '<br/><span class="small">('.I18N::percentage($perc2, 1).')</span>'; |
|
110 | - $content .= '</td>'; |
|
93 | + $sum_gen = $data['sum']; |
|
94 | + $unknownother = $data['unknown'] + $data['other']; |
|
95 | + foreach($data['places'] as $placename=> $dataplace){ |
|
96 | + $levels = array_map('trim',explode(',', $placename)); |
|
97 | + $content = ''; |
|
98 | + if(isset($dataplace['flag'])){ |
|
99 | + $content .= '<td class="geodispersion_flag">'. FunctionsPrint::htmlPlaceIcon($dataplace['place'], $dataplace['flag']) .'</td><td>'; |
|
100 | + } |
|
101 | + else{ |
|
102 | + $content .= '<td><span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span><br/>'; |
|
103 | + } |
|
104 | + $count = $dataplace['count']; |
|
105 | + $content .= I18N::number($count); |
|
106 | + $perc = Functions::safeDivision($count, $sum_gen + $unknownother); |
|
107 | + $perc2= Functions::safeDivision($count, $sum_gen); |
|
108 | + if($perc2>=0.1) |
|
109 | + $content.= '<br/><span class="small">('.I18N::percentage($perc2, 1).')</span>'; |
|
110 | + $content .= '</td>'; |
|
111 | 111 | |
112 | - $html .= ' |
|
112 | + $html .= ' |
|
113 | 113 | <td class="geodispersion_rowitem" width="'.max(round(100*$perc, 0),1).'%"> |
114 | 114 | <table> |
115 | 115 | <tr> |
@@ -121,46 +121,46 @@ discard block |
||
121 | 121 | </tr> |
122 | 122 | </table> |
123 | 123 | </td>'; |
124 | - } |
|
124 | + } |
|
125 | 125 | |
126 | - if($unknownother>0){ |
|
127 | - $perc= Functions::safeDivision($unknownother, $sum_gen + $unknownother); |
|
128 | - $html .='<td class="geodispersion_unknownitem left" >'.I18N::number($unknownother); |
|
129 | - if($perc>=0.1) $html.= '<br/><span class="small">('.I18N::percentage($perc, 1).')</span>'; |
|
130 | - $html .='</td>'; |
|
131 | - } |
|
126 | + if($unknownother>0){ |
|
127 | + $perc= Functions::safeDivision($unknownother, $sum_gen + $unknownother); |
|
128 | + $html .='<td class="geodispersion_unknownitem left" >'.I18N::number($unknownother); |
|
129 | + if($perc>=0.1) $html.= '<br/><span class="small">('.I18N::percentage($perc, 1).')</span>'; |
|
130 | + $html .='</td>'; |
|
131 | + } |
|
132 | 132 | |
133 | - $html .= |
|
134 | - '</tr> |
|
133 | + $html .= |
|
134 | + '</tr> |
|
135 | 135 | </table>'; |
136 | - return $html; |
|
137 | - } |
|
136 | + return $html; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Returns the HTML code fo display a row of the Top Places found for a generation. |
141 | 141 | * |
142 | 142 | * @param array $data Data array |
143 | - * @param int $analysis_level Level of subdivision of analysis |
|
143 | + * @param int $analysis_level Level of subdivision of analysis |
|
144 | 144 | * @return string HTML code for Top Places row |
145 | 145 | */ |
146 | - protected function htmlGenerationTopPlacesRow($data, $analysis_level) { |
|
147 | - $tmp_places = array(); |
|
148 | - $sum_gen = $data['sum']; |
|
149 | - $other = $data['other']; |
|
146 | + protected function htmlGenerationTopPlacesRow($data, $analysis_level) { |
|
147 | + $tmp_places = array(); |
|
148 | + $sum_gen = $data['sum']; |
|
149 | + $other = $data['other']; |
|
150 | 150 | |
151 | - foreach($data['places'] as $placename => $count) { |
|
152 | - if($placename != 'other'){ |
|
153 | - $levels = array_map('trim',explode(',', $placename)); |
|
154 | - $placename = '<span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span>'; |
|
155 | - } |
|
156 | - else{ |
|
157 | - $placename = I18N::translate('Other places'); |
|
158 | - } |
|
159 | - $tmp_places[] = I18N::translate('<strong>%s</strong> [%d - %s]', $placename, $count, I18N::percentage(Functions::safeDivision($count, $sum_gen + $other), 1)); |
|
160 | - } |
|
151 | + foreach($data['places'] as $placename => $count) { |
|
152 | + if($placename != 'other'){ |
|
153 | + $levels = array_map('trim',explode(',', $placename)); |
|
154 | + $placename = '<span title="'.implode(I18N::$list_separator, array_reverse($levels)).'">'.$levels[$analysis_level-1].'</span>'; |
|
155 | + } |
|
156 | + else{ |
|
157 | + $placename = I18N::translate('Other places'); |
|
158 | + } |
|
159 | + $tmp_places[] = I18N::translate('<strong>%s</strong> [%d - %s]', $placename, $count, I18N::percentage(Functions::safeDivision($count, $sum_gen + $other), 1)); |
|
160 | + } |
|
161 | 161 | |
162 | - return implode(I18N::$list_separator, $tmp_places); |
|
163 | - } |
|
162 | + return implode(I18N::$list_separator, $tmp_places); |
|
163 | + } |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | 167 | \ No newline at end of file |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | * {@inheritDoc} |
26 | 26 | * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisTabGeneralView::htmlAnalysisData() |
27 | 27 | */ |
28 | - protected function htmlAnalysisData() { |
|
28 | + protected function htmlAnalysisData() { |
|
29 | 29 | |
30 | - /** @var OutlineMap $map */ |
|
31 | - $map = $this->data->get('map'); |
|
32 | - $canvas = $map->getCanvas(); |
|
33 | - $subdvisions_results = $this->data->get('results_by_subdivisions'); |
|
30 | + /** @var OutlineMap $map */ |
|
31 | + $map = $this->data->get('map'); |
|
32 | + $canvas = $map->getCanvas(); |
|
33 | + $subdvisions_results = $this->data->get('results_by_subdivisions'); |
|
34 | 34 | |
35 | - $nb_found = $this->data->get('stats_gen_nb_found'); |
|
36 | - $nb_other = $this->data->get('stats_gen_nb_other'); |
|
35 | + $nb_found = $this->data->get('stats_gen_nb_found'); |
|
36 | + $nb_other = $this->data->get('stats_gen_nb_other'); |
|
37 | 37 | |
38 | - $html = '<script> |
|
38 | + $html = '<script> |
|
39 | 39 | var tip = null; |
40 | 40 | var tipText = ""; |
41 | 41 | var over = false; |
@@ -82,29 +82,29 @@ discard block |
||
82 | 82 | var map = {}; |
83 | 83 | '; |
84 | 84 | |
85 | - foreach($subdvisions_results as $name => $location){ |
|
86 | - $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
87 | - if(isset($location['transparency'])) { |
|
88 | - $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
|
89 | - if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
90 | - $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
|
91 | - $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
92 | - $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
93 | - $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
94 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
95 | - '});'. |
|
96 | - 'map.area'.$location['id'].'.mouseout(function () {'. |
|
97 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
|
98 | - '});'; |
|
99 | - } |
|
100 | - } |
|
101 | - $html .= '}); |
|
85 | + foreach($subdvisions_results as $name => $location){ |
|
86 | + $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
87 | + if(isset($location['transparency'])) { |
|
88 | + $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
|
89 | + if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
90 | + $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
|
91 | + $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
92 | + $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
93 | + $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
94 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
95 | + '});'. |
|
96 | + 'map.area'.$location['id'].'.mouseout(function () {'. |
|
97 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
|
98 | + '});'; |
|
99 | + } |
|
100 | + } |
|
101 | + $html .= '}); |
|
102 | 102 | </script> |
103 | 103 | |
104 | 104 | <div id="geodispersion_map"></div> |
105 | 105 | <div id="geodispersion_tip"></div>'; |
106 | 106 | |
107 | - return $html; |
|
108 | - } |
|
107 | + return $html; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
111 | 111 | \ No newline at end of file |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | * {@inhericDoc} |
24 | 24 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
25 | 25 | */ |
26 | - protected function renderContent() { |
|
26 | + protected function renderContent() { |
|
27 | 27 | |
28 | - /** @var Tree $tree */ |
|
29 | - $tree = $this->data->get('tree'); |
|
30 | - $root_url = $this->data->get('root_url'); |
|
31 | - $other_trees = $this->data->get('other_trees'); |
|
32 | - $table_id = $this->data->get('table_id'); |
|
33 | - ?> |
|
28 | + /** @var Tree $tree */ |
|
29 | + $tree = $this->data->get('tree'); |
|
30 | + $root_url = $this->data->get('root_url'); |
|
31 | + $other_trees = $this->data->get('other_trees'); |
|
32 | + $table_id = $this->data->get('table_id'); |
|
33 | + ?> |
|
34 | 34 | <ol class="breadcrumb small"> |
35 | 35 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
36 | 36 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -63,23 +63,23 @@ discard block |
||
63 | 63 | <p> |
64 | 64 | <?php $places_hierarchy = $this->data->get('places_hierarchy'); |
65 | 65 | if($places_hierarchy) { |
66 | - switch ($places_hierarchy['type']) { |
|
67 | - case 'header': |
|
68 | - echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: '); |
|
69 | - break; |
|
70 | - case 'data': |
|
71 | - echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.'). |
|
72 | - '<br/>'. |
|
73 | - I18N::translate('Here is an example of your place data: '); |
|
74 | - break; |
|
75 | - default: |
|
76 | - break; |
|
77 | - } |
|
78 | - $str_hierarchy = array(); |
|
79 | - foreach($places_hierarchy['hierarchy'] as $key => $level) { |
|
80 | - $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level); |
|
81 | - } |
|
82 | - echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>'; |
|
66 | + switch ($places_hierarchy['type']) { |
|
67 | + case 'header': |
|
68 | + echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: '); |
|
69 | + break; |
|
70 | + case 'data': |
|
71 | + echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.'). |
|
72 | + '<br/>'. |
|
73 | + I18N::translate('Here is an example of your place data: '); |
|
74 | + break; |
|
75 | + default: |
|
76 | + break; |
|
77 | + } |
|
78 | + $str_hierarchy = array(); |
|
79 | + foreach($places_hierarchy['hierarchy'] as $key => $level) { |
|
80 | + $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level); |
|
81 | + } |
|
82 | + echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>'; |
|
83 | 83 | } |
84 | 84 | ?> |
85 | 85 | </p> |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | </a> |
110 | 110 | |
111 | 111 | <?php |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | 116 | \ No newline at end of file |