Passed
Branch feature/2.0 (2da243)
by Jonathan
05:05
created
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php 3 patches
Indentation   +329 added lines, -329 removed lines patch added patch discarded remove patch
@@ -21,130 +21,130 @@  discard block
 block discarded – undo
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
-        ->setUsingFlags($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
+		->setUsingFlags($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
 block discarded – undo
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,239 +217,239 @@  discard block
 block discarded – undo
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> / <em>none</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
-            elseif ($place_structure = $this->getPlacesHierarchyFromData()){
355
-                $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure);
356
-            }
357
-            else {
358
-                $this->place_hierarchy = array('type' => 'none', 'hierarchy' => null);
359
-            }
360
-        }
361
-        return $this->place_hierarchy;        
362
-    }
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> / <em>none</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
+			elseif ($place_structure = $this->getPlacesHierarchyFromData()){
355
+				$this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure);
356
+			}
357
+			else {
358
+				$this->place_hierarchy = array('type' => 'none', 'hierarchy' => null);
359
+			}
360
+		}
361
+		return $this->place_hierarchy;        
362
+	}
363 363
     
364
-    /**
365
-     * Returns an array of the place hierarchy, as defined in the GEDCOM header.
366
-     * The places are reversed compared to normal GEDCOM structure.
367
-     * 
368
-     * @return array|null
369
-     */
370
-    protected function getPlacesHierarchyFromHeader() {
371
-        $head = GedcomRecord::getInstance('HEAD', $this->tree);
372
-        $head_place = $head->getFirstFact('PLAC');
373
-        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
374
-            return array_reverse(array_map('trim',explode(',', $head_place_value)));
375
-        }
376
-        return null;
377
-    }
364
+	/**
365
+	 * Returns an array of the place hierarchy, as defined in the GEDCOM header.
366
+	 * The places are reversed compared to normal GEDCOM structure.
367
+	 * 
368
+	 * @return array|null
369
+	 */
370
+	protected function getPlacesHierarchyFromHeader() {
371
+		$head = GedcomRecord::getInstance('HEAD', $this->tree);
372
+		$head_place = $head->getFirstFact('PLAC');
373
+		if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
374
+			return array_reverse(array_map('trim',explode(',', $head_place_value)));
375
+		}
376
+		return null;
377
+	}
378 378
     
379
-    /**
380
-     * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
381
-     * It will look for the longest hierarchy in the tree.
382
-     * The places are reversed compared to normal GEDCOM structure.
383
-     * 
384
-     * @return array
385
-     */
386
-    protected function getPlacesHierarchyFromData() {
387
-        $nb_levels = 0;
379
+	/**
380
+	 * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
381
+	 * It will look for the longest hierarchy in the tree.
382
+	 * The places are reversed compared to normal GEDCOM structure.
383
+	 * 
384
+	 * @return array
385
+	 */
386
+	protected function getPlacesHierarchyFromData() {
387
+		$nb_levels = 0;
388 388
         
389
-        //Select all '2 PLAC ' tags in the file and create array
390
-        $places_list=array();
391
-        $ged_data = Database::prepare(
392
-            'SELECT i_gedcom AS gedcom'.
393
-            ' FROM `##individuals`'.
394
-            ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
395
-            ' UNION ALL'.
396
-            ' SELECT f_gedcom AS gedcom'.
397
-            ' FROM `##families`'.
398
-            ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
399
-        )->execute(array(
400
-            'gedcom' => '%2 PLAC %',
401
-            'gedcom_id' => $this->tree->getTreeId()
402
-        ))->fetchOneColumn();
403
-        foreach ($ged_data as $ged_datum) {
404
-            $matches = null;
405
-            preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
406
-            foreach ($matches[1] as $match) {
407
-                $places_list[$match]=true;
408
-            }
409
-        }
389
+		//Select all '2 PLAC ' tags in the file and create array
390
+		$places_list=array();
391
+		$ged_data = Database::prepare(
392
+			'SELECT i_gedcom AS gedcom'.
393
+			' FROM `##individuals`'.
394
+			' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
395
+			' UNION ALL'.
396
+			' SELECT f_gedcom AS gedcom'.
397
+			' FROM `##families`'.
398
+			' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
399
+		)->execute(array(
400
+			'gedcom' => '%2 PLAC %',
401
+			'gedcom_id' => $this->tree->getTreeId()
402
+		))->fetchOneColumn();
403
+		foreach ($ged_data as $ged_datum) {
404
+			$matches = null;
405
+			preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
406
+			foreach ($matches[1] as $match) {
407
+				$places_list[$match]=true;
408
+			}
409
+		}
410 410
         
411
-        // Get the places with higest numbers of levels
412
-        $places_with_high_level = array();
413
-        $max_level = 0;
411
+		// Get the places with higest numbers of levels
412
+		$places_with_high_level = array();
413
+		$max_level = 0;
414 414
         
415
-        foreach ($places_list as $place => $value) {
416
-            $levels = array_filter(array_map('trim', explode(",", $place)));
417
-            $parts = count($levels);
418
-            if($parts > $max_level) {
419
-                $max_level = $parts;
420
-                $places_with_high_level = array($place);
421
-            }
422
-            else if ($parts == $max_level) {
423
-                $places_with_high_level[] = $place;
424
-            }
425
-        }
415
+		foreach ($places_list as $place => $value) {
416
+			$levels = array_filter(array_map('trim', explode(",", $place)));
417
+			$parts = count($levels);
418
+			if($parts > $max_level) {
419
+				$max_level = $parts;
420
+				$places_with_high_level = array($place);
421
+			}
422
+			else if ($parts == $max_level) {
423
+				$places_with_high_level[] = $place;
424
+			}
425
+		}
426 426
         
427
-        // If empty array, then return null
428
-        if($max_level == 0) return null;
427
+		// If empty array, then return null
428
+		if($max_level == 0) return null;
429 429
                 
430
-        // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used
431
-        usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp'));        
432
-        return array_reverse(array_map('trim',explode(',', $places_with_high_level[0])));
430
+		// Else, return the first alphabetical element -- cannot return random to ensure always the same example if used
431
+		usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp'));        
432
+		return array_reverse(array_map('trim',explode(',', $places_with_high_level[0])));
433 433
         
434
-    }
434
+	}
435 435
     
436
-    /**
437
-     * Returns the list of geodispersion maps available within the maps folder.
438
-     * 
439
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
440
-     */
441
-    public function getOutlineMapsList() {
442
-        $res = array();
443
-        $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
444
-        if(is_dir($root_path)){
445
-            $dir = opendir($root_path);
446
-            while (($file=readdir($dir))!== false) {
447
-                if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
448
-                    $res[base64_encode($file)] = new OutlineMap($file, true);
449
-                }
450
-            }
451
-        }
452
-        return $res;
453
-    }
436
+	/**
437
+	 * Returns the list of geodispersion maps available within the maps folder.
438
+	 * 
439
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
440
+	 */
441
+	public function getOutlineMapsList() {
442
+		$res = array();
443
+		$root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
444
+		if(is_dir($root_path)){
445
+			$dir = opendir($root_path);
446
+			while (($file=readdir($dir))!== false) {
447
+				if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
448
+					$res[base64_encode($file)] = new OutlineMap($file, true);
449
+				}
450
+			}
451
+		}
452
+		return $res;
453
+	}
454 454
 }
455 455
  
456 456
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
         ->setUsingFlags($row['majgd_useflagsgen'] == 'yes')
66 66
         ->setMaxDetailsInGen($row['majgd_detailsgen']);
67 67
         
68
-        if($row['majgd_map']) {
68
+        if ($row['majgd_map']) {
69 69
             $options
70 70
             ->setMap(new OutlineMap($row['majgd_map']))
71 71
             ->setMapLevel($row['majgd_toplevel']);
72 72
         }
73 73
         
74 74
         $enabled = true;
75
-        if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
75
+        if (isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') {
76 76
             $enabled = false;
77 77
         }
78 78
         
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getGeoAnalysisCount() {
95 95
         return Database::prepare(
96
-            'SELECT COUNT(majgd_id)' .
97
-            ' FROM `##maj_geodispersion`' .
96
+            'SELECT COUNT(majgd_id)'.
97
+            ' FROM `##maj_geodispersion`'.
98 98
             ' WHERE majgd_file = :gedcom_id'
99 99
             )->execute(array(
100 100
                 'gedcom_id' => $this->tree->getTreeId()
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
      * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL
111 111
      */
112 112
     public function getGeoAnalysis($id, $only_enabled = true) {
113
-        $args = array (
113
+        $args = array(
114 114
             'gedcom_id' => $this->tree->getTreeId(),
115 115
             'ga_id' => $id
116 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`' .
118
+        $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'.
119
+            ' FROM `##maj_geodispersion`'.
120 120
             ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id';
121
-        if($only_enabled) {
121
+        if ($only_enabled) {
122 122
             $sql .= ' AND majgd_status = :status';
123 123
             $args['status'] = 'enabled';
124 124
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         
127 127
         $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
128 128
         
129
-        if($ga_array) {
129
+        if ($ga_array) {
130 130
             return $this->loadGeoAnalysisFromRow($ga_array);
131 131
         }
132 132
         
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * @return GeoAnalysis
147 147
      */
148 148
 	public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) {
149
-		try{
149
+		try {
150 150
 			Database::beginTransaction();
151 151
 		
152 152
 			Database::prepare(
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 			
169 169
 			Database::commit();
170 170
 		}
171
-		catch(\Exception $ex) {
171
+		catch (\Exception $ex) {
172 172
 			Database::rollback();
173 173
 			$ga = null;
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());
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 			
212 212
 			 Database::commit();
213 213
 		}
214
-		catch(\Exception $ex) {		    
214
+		catch (\Exception $ex) {		    
215 215
 			Database::rollback();
216
-			Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage());
216
+			Log::addErrorLog('The Geo Analysis ID “'.$ga->getId().'” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage());
217 217
 			$ga = null;
218 218
 		}
219 219
 		return $ga;
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
      *
259 259
      * @return array List of enabled maps
260 260
      */
261
-    public function getGeoAnalysisList(){
261
+    public function getGeoAnalysisList() {
262 262
         $res = array();
263 263
         
264 264
         $list = Database::prepare(
265
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' .
266
-            ' FROM `##maj_geodispersion`' .
265
+            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen'.
266
+            ' FROM `##maj_geodispersion`'.
267 267
             ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'.
268 268
             ' ORDER BY majgd_descr'
269 269
         )->execute(array(
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             'status' => 'enabled'
272 272
         ))->fetchAll(\PDO::FETCH_ASSOC);
273 273
         
274
-        foreach($list as $ga) {
274
+        foreach ($list as $ga) {
275 275
            $res[] = $this->loadGeoAnalysisFromRow($ga);
276 276
         }
277 277
         
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
      * @param int|null $limit Max number of items to return (for pagination)
288 288
      * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
289 289
      */
290
-    public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){
290
+    public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null) {
291 291
         $res = array();
292 292
             
293 293
         $sql = 
294
-            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' .
295
-            ' FROM `##maj_geodispersion`' .
294
+            'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'.
295
+            ' FROM `##maj_geodispersion`'.
296 296
             ' WHERE majgd_file = :gedcom_id';
297 297
         
298 298
         $args = array('gedcom_id'=> $this->tree->getTreeId());
299 299
         
300
-        if($search) {
300
+        if ($search) {
301 301
             $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')';
302 302
             $args['search'] = $search;
303 303
         }
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
                 
312 312
                 switch ($value['dir']) {
313 313
                     case 'asc':
314
-                        $sql .= $value['column'] . ' ASC ';
314
+                        $sql .= $value['column'].' ASC ';
315 315
                         break;
316 316
                     case 'desc':
317
-                        $sql .= $value['column'] . ' DESC ';
317
+                        $sql .= $value['column'].' DESC ';
318 318
                         break;
319 319
                 }
320 320
             }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             
331 331
         $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
332 332
 
333
-        foreach($data as $ga) {
333
+        foreach ($data as $ga) {
334 334
             $res[] = $this->loadGeoAnalysisFromRow($ga);
335 335
         }
336 336
         
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
      * @return array
348 348
      */
349 349
     public function getPlacesHierarchy() {
350
-        if(!$this->place_hierarchy) {
351
-            if($place_structure = $this->getPlacesHierarchyFromHeader()) {
350
+        if (!$this->place_hierarchy) {
351
+            if ($place_structure = $this->getPlacesHierarchyFromHeader()) {
352 352
                 $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353 353
             }
354
-            elseif ($place_structure = $this->getPlacesHierarchyFromData()){
354
+            elseif ($place_structure = $this->getPlacesHierarchyFromData()) {
355 355
                 $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure);
356 356
             }
357 357
             else {
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
     protected function getPlacesHierarchyFromHeader() {
371 371
         $head = GedcomRecord::getInstance('HEAD', $this->tree);
372 372
         $head_place = $head->getFirstFact('PLAC');
373
-        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
374
-            return array_reverse(array_map('trim',explode(',', $head_place_value)));
373
+        if ($head_place && $head_place_value = $head_place->getAttribute('FORM')) {
374
+            return array_reverse(array_map('trim', explode(',', $head_place_value)));
375 375
         }
376 376
         return null;
377 377
     }
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         $nb_levels = 0;
388 388
         
389 389
         //Select all '2 PLAC ' tags in the file and create array
390
-        $places_list=array();
390
+        $places_list = array();
391 391
         $ged_data = Database::prepare(
392 392
             'SELECT i_gedcom AS gedcom'.
393 393
             ' FROM `##individuals`'.
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
             $matches = null;
405 405
             preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
406 406
             foreach ($matches[1] as $match) {
407
-                $places_list[$match]=true;
407
+                $places_list[$match] = true;
408 408
             }
409 409
         }
410 410
         
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
         foreach ($places_list as $place => $value) {
416 416
             $levels = array_filter(array_map('trim', explode(",", $place)));
417 417
             $parts = count($levels);
418
-            if($parts > $max_level) {
418
+            if ($parts > $max_level) {
419 419
                 $max_level = $parts;
420 420
                 $places_with_high_level = array($place);
421 421
             }
@@ -425,11 +425,11 @@  discard block
 block discarded – undo
425 425
         }
426 426
         
427 427
         // If empty array, then return null
428
-        if($max_level == 0) return null;
428
+        if ($max_level == 0) return null;
429 429
                 
430 430
         // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used
431 431
         usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp'));        
432
-        return array_reverse(array_map('trim',explode(',', $places_with_high_level[0])));
432
+        return array_reverse(array_map('trim', explode(',', $places_with_high_level[0])));
433 433
         
434 434
     }
435 435
     
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
     public function getOutlineMapsList() {
442 442
         $res = array();
443 443
         $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
444
-        if(is_dir($root_path)){
444
+        if (is_dir($root_path)) {
445 445
             $dir = opendir($root_path);
446
-            while (($file=readdir($dir))!== false) {
446
+            while (($file = readdir($dir)) !== false) {
447 447
                 if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
448 448
                     $res[base64_encode($file)] = new OutlineMap($file, true);
449 449
                 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -11 removed lines patch added patch discarded remove patch
@@ -167,8 +167,7 @@  discard block
 block discarded – undo
167 167
 			$ga = $this->getGeoAnalysis($id, false);
168 168
 			
169 169
 			Database::commit();
170
-		}
171
-		catch(\Exception $ex) {
170
+		} catch(\Exception $ex) {
172 171
 			Database::rollback();
173 172
 			$ga = null;
174 173
 			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());
@@ -210,8 +209,7 @@  discard block
 block discarded – undo
210 209
 			$ga = $this->getGeoAnalysis($ga->getId(), false);
211 210
 			
212 211
 			 Database::commit();
213
-		}
214
-		catch(\Exception $ex) {		    
212
+		} catch(\Exception $ex) {		    
215 213
 			Database::rollback();
216 214
 			Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage());
217 215
 			$ga = null;
@@ -350,11 +348,9 @@  discard block
 block discarded – undo
350 348
         if(!$this->place_hierarchy) {
351 349
             if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352 350
                 $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
-            }
354
-            elseif ($place_structure = $this->getPlacesHierarchyFromData()){
351
+            } elseif ($place_structure = $this->getPlacesHierarchyFromData()){
355 352
                 $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure);
356
-            }
357
-            else {
353
+            } else {
358 354
                 $this->place_hierarchy = array('type' => 'none', 'hierarchy' => null);
359 355
             }
360 356
         }
@@ -418,14 +414,15 @@  discard block
 block discarded – undo
418 414
             if($parts > $max_level) {
419 415
                 $max_level = $parts;
420 416
                 $places_with_high_level = array($place);
421
-            }
422
-            else if ($parts == $max_level) {
417
+            } else if ($parts == $max_level) {
423 418
                 $places_with_high_level[] = $place;
424 419
             }
425 420
         }
426 421
         
427 422
         // If empty array, then return null
428
-        if($max_level == 0) return null;
423
+        if($max_level == 0) {
424
+        	return null;
425
+        }
429 426
                 
430 427
         // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used
431 428
         usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp'));        
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/Views/AdminConfigView.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
63 63
 		<p>
64 64
 		<?php $places_hierarchy = $this->data->get('places_hierarchy'); 
65 65
 		if($places_hierarchy && $places_hierarchy['type'] != 'none') {
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
 block discarded – undo
109 109
         </a>
110 110
 		
111 111
 		<?php        
112
-    }
112
+	}
113 113
     
114 114
 }
115 115
  
116 116
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 		
42 42
 		<h2>
43 43
 			<?php echo $tree->getTitleHtml(); ?>
44
-			<?php if(count($other_trees) > 0) {?>
44
+			<?php if (count($other_trees) > 0) {?>
45 45
 			<div class="btn-group">
46 46
 				<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
47 47
 					<?php echo I18N::translate('Change tree'); ?>
48 48
 					<span class="caret"></span>
49 49
 				</button>
50
-				<?php foreach($other_trees as $other_tree) { ?>
50
+				<?php foreach ($other_trees as $other_tree) { ?>
51 51
 				<ul class="dropdown-menu" role="menu">
52 52
 					<li>
53
-						<a href="<?php echo $root_url . '&ged=' . $other_tree->getNameUrl(); ?>">
53
+						<a href="<?php echo $root_url.'&ged='.$other_tree->getNameUrl(); ?>">
54 54
 							<i class="fa fa-fw fa-tree"></i>&nbsp;<?php echo $other_tree->getTitleHtml(); ?>
55 55
 						</a>
56 56
 					</li>
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		
63 63
 		<p>
64 64
 		<?php $places_hierarchy = $this->data->get('places_hierarchy'); 
65
-		if($places_hierarchy && $places_hierarchy['type'] != 'none') {
65
+		if ($places_hierarchy && $places_hierarchy['type'] != 'none') {
66 66
 		    switch ($places_hierarchy['type']) {
67 67
 		        case 'header':
68 68
 		            echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: ');
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 		            break;
77 77
 		    }
78 78
 		    $str_hierarchy = array();
79
-		    foreach($places_hierarchy['hierarchy'] as $key => $level) {
79
+		    foreach ($places_hierarchy['hierarchy'] as $key => $level) {
80 80
 		        $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level);
81 81
 		    }
82
-		    echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>';
82
+		    echo '<strong>'.implode(I18N::$list_separator, $str_hierarchy).'</strong>';
83 83
 		}
84 84
 		?>
85 85
 		</p>
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     		</tbody>
104 104
     	</table>
105 105
     	
106
-        <a type="button" class="btn btn-primary" href="<?php echo $root_url . '@add&ged=' . $tree->getNameUrl(); ?>" title="<?php echo I18N::translate('Add'); ?>">
106
+        <a type="button" class="btn btn-primary" href="<?php echo $root_url.'@add&ged='.$tree->getNameUrl(); ?>" title="<?php echo I18N::translate('Add'); ?>">
107 107
         	<i class="fa fa-plus"></i>
108 108
         	<?php echo I18N::translate('Add'); ?>
109 109
         </a>
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/AdminConfigController.php 3 patches
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -36,58 +36,58 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class AdminConfigController extends MvcController
38 38
 {    
39
-    /**
40
-     * GeoAnalysis Provider
41
-     * @var GeoAnalysisProvider $provider
42
-     */
43
-    protected $provider;    
39
+	/**
40
+	 * GeoAnalysis Provider
41
+	 * @var GeoAnalysisProvider $provider
42
+	 */
43
+	protected $provider;    
44 44
     
45
-    /**
46
-     * Constructor for Admin Config controller
47
-     * @param AbstractModule $module
48
-     */
49
-    public function __construct(AbstractModule $module) {
50
-        parent::__construct($module);
45
+	/**
46
+	 * Constructor for Admin Config controller
47
+	 * @param AbstractModule $module
48
+	 */
49
+	public function __construct(AbstractModule $module) {
50
+		parent::__construct($module);
51 51
         
52
-        $this->provider = $this->module->getProvider();
53
-    }    
52
+		$this->provider = $this->module->getProvider();
53
+	}    
54 54
     
55
-    /**
56
-     * Pages
57
-     */
55
+	/**
56
+	 * Pages
57
+	 */
58 58
         
59
-    /**
60
-     * AdminConfig@index
61
-     */
62
-    public function index() {
63
-        $wt_tree = Globals::getTree();
64
-        Theme::theme(new AdministrationTheme)->init($wt_tree);
65
-        $controller = new PageController();
66
-        $controller
67
-            ->restrictAccess(Auth::isManager($wt_tree))
68
-            ->setPageTitle($this->module->getTitle());
59
+	/**
60
+	 * AdminConfig@index
61
+	 */
62
+	public function index() {
63
+		$wt_tree = Globals::getTree();
64
+		Theme::theme(new AdministrationTheme)->init($wt_tree);
65
+		$controller = new PageController();
66
+		$controller
67
+			->restrictAccess(Auth::isManager($wt_tree))
68
+			->setPageTitle($this->module->getTitle());
69 69
         
70
-        $data = new ViewBag();
71
-        $data->set('title', $controller->getPageTitle());
72
-        $data->set('tree', $wt_tree);
70
+		$data = new ViewBag();
71
+		$data->set('title', $controller->getPageTitle());
72
+		$data->set('tree', $wt_tree);
73 73
         
74
-        $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
74
+		$data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
75 75
                 
76
-        $table_id = 'table-geoanalysis-' . Uuid::uuid4();
77
-        $data->set('table_id', $table_id);
76
+		$table_id = 'table-geoanalysis-' . Uuid::uuid4();
77
+		$data->set('table_id', $table_id);
78 78
         
79
-        $other_trees = array();
80
-        foreach (Tree::getAll() as $tree) {
81
-            if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
82
-        }      
83
-        $data->set('other_trees', $other_trees);
79
+		$other_trees = array();
80
+		foreach (Tree::getAll() as $tree) {
81
+			if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
82
+		}      
83
+		$data->set('other_trees', $other_trees);
84 84
         
85
-        $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
85
+		$data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
86 86
         
87
-        $controller
88
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
89
-            ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
90
-            ->addInlineJavascript('
87
+		$controller
88
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
89
+			->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
90
+			->addInlineJavascript('
91 91
 				jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
92 92
 				jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
93 93
                 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 				});
120 120
                 
121 121
                 ')
122
-                ->addInlineJavascript('				
122
+				->addInlineJavascript('				
123 123
                     function set_geoanalysis_status(ga_id, status, gedcom) {
124 124
                 		jQuery.ajax({
125 125
                             url: "module.php", 
@@ -163,54 +163,54 @@  discard block
 block discarded – undo
163 163
                 ');
164 164
         
165 165
         
166
-        ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
167
-    }
166
+		ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
167
+	}
168 168
 
169
-    /**
170
-     * AdminConfig@jsonGeoAnalysisList
171
-     */
172
-    public function jsonGeoAnalysisList() {
173
-        $wt_tree = Globals::getTree();
174
-        $controller = new JsonController();
175
-        $controller
176
-            ->restrictAccess(Auth::isManager($wt_tree));
169
+	/**
170
+	 * AdminConfig@jsonGeoAnalysisList
171
+	 */
172
+	public function jsonGeoAnalysisList() {
173
+		$wt_tree = Globals::getTree();
174
+		$controller = new JsonController();
175
+		$controller
176
+			->restrictAccess(Auth::isManager($wt_tree));
177 177
         
178
-        // Generate an AJAX/JSON response for datatables to load a block of rows
179
-        $search = Filter::postArray('search');
180
-        if($search) $search = $search['value'];
181
-        $start  = Filter::postInteger('start');
182
-        $length = Filter::postInteger('length');
183
-        $order  = Filter::postArray('order');
178
+		// Generate an AJAX/JSON response for datatables to load a block of rows
179
+		$search = Filter::postArray('search');
180
+		if($search) $search = $search['value'];
181
+		$start  = Filter::postInteger('start');
182
+		$length = Filter::postInteger('length');
183
+		$order  = Filter::postArray('order');
184 184
         
185
-        foreach($order as $key => &$value) {
186
-            switch($value['column']) {
187
-                case 3:
188
-                    $value['column'] = 'majgd_descr';
189
-                    break;
190
-                case 5;
191
-                    $value['column'] = 'majgd_sublevel';
192
-                    break;
193
-                default:
194
-                    unset($order[$key]);
195
-            }
196
-        }
185
+		foreach($order as $key => &$value) {
186
+			switch($value['column']) {
187
+				case 3:
188
+					$value['column'] = 'majgd_descr';
189
+					break;
190
+				case 5;
191
+					$value['column'] = 'majgd_sublevel';
192
+					break;
193
+				default:
194
+					unset($order[$key]);
195
+			}
196
+		}
197 197
         
198
-        /** @var GeoAnalysisProvider $provider */
199
-        $provider = $this->module->getProvider();
198
+		/** @var GeoAnalysisProvider $provider */
199
+		$provider = $this->module->getProvider();
200 200
         
201
-        $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length);
202
-        $recordsFiltered = count($list);
203
-        $recordsTotal = $this->provider->getGeoAnalysisCount();
201
+		$list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length);
202
+		$recordsFiltered = count($list);
203
+		$recordsTotal = $this->provider->getGeoAnalysisCount();
204 204
         
205
-        $data = array();
206
-        $place_hierarchy = $this->provider->getPlacesHierarchy();
207
-        foreach($list as $ga) {
208
-            /** @var GeoAnalysis $ga */
205
+		$data = array();
206
+		$place_hierarchy = $this->provider->getPlacesHierarchy();
207
+		foreach($list as $ga) {
208
+			/** @var GeoAnalysis $ga */
209 209
             
210
-            $datum = array();
211
-            $options= $ga->getOptions();
210
+			$datum = array();
211
+			$options= $ga->getOptions();
212 212
             
213
-            $datum[0] = '
213
+			$datum[0] = '
214 214
                 <div class="btn-group">
215 215
                     <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
216 216
                         <i class="fa fa-pencil"></i><span class="caret"></span>
@@ -234,116 +234,116 @@  discard block
 block discarded – undo
234 234
                        </li>
235 235
                     </ul>
236 236
                 </div>';
237
-		    $datum[1] = $ga->getId();
238
-		    $datum[2] = $ga->isEnabled() ? 
237
+			$datum[1] = $ga->getId();
238
+			$datum[2] = $ga->isEnabled() ? 
239 239
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : 
240 240
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
241
-		    $datum[3] = $ga->getTitle();
242
-		    $analysis_level = $ga->getAnalysisLevel();
243
-		    if($place_hierarchy['type'] == 'header') {
244
-		        $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
245
-		    } elseif ($place_hierarchy['type'] == 'data') {
246
-		        $datum[4] = $analysis_level . ' (' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
247
-		    } else {
248
-		        $datum[4] = $analysis_level;
249
-		    }
250
-		    $datum[5] = $ga->getAnalysisLevel();
251
-		    $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
252
-		    $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
253
-		    if($ga->hasMap()) {
254
-		        if($options->getMap()->isLoaded()) {
255
-    		        $datum[6] = $options->getMap()->getDescription();
256
-    		        $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
257
-    		        $top_level = $options->getMapLevel();
258
-    		        if($place_hierarchy['type'] == 'header') {
259
-    		            $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
260
-    		        } elseif ($place_hierarchy['type'] == 'data') {
261
-    		            $datum[7] .= $top_level . ' (' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
262
-    		        } else {
263
-    		            $datum[7] .= $top_level;
264
-    		        }
265
-    		        $datum[7] .= '</span>';
266
-		        }
267
-		        else {
268
-		            $datum[6] = I18N::translate('Error when loading map.');
269
-		        }
270
-		    }
271
-		    $datum[8] = $options->isUsingFlags() ? 
241
+			$datum[3] = $ga->getTitle();
242
+			$analysis_level = $ga->getAnalysisLevel();
243
+			if($place_hierarchy['type'] == 'header') {
244
+				$datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
245
+			} elseif ($place_hierarchy['type'] == 'data') {
246
+				$datum[4] = $analysis_level . ' (' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
247
+			} else {
248
+				$datum[4] = $analysis_level;
249
+			}
250
+			$datum[5] = $ga->getAnalysisLevel();
251
+			$datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
252
+			$datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
253
+			if($ga->hasMap()) {
254
+				if($options->getMap()->isLoaded()) {
255
+					$datum[6] = $options->getMap()->getDescription();
256
+					$datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
257
+					$top_level = $options->getMapLevel();
258
+					if($place_hierarchy['type'] == 'header') {
259
+						$datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
260
+					} elseif ($place_hierarchy['type'] == 'data') {
261
+						$datum[7] .= $top_level . ' (' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
262
+					} else {
263
+						$datum[7] .= $top_level;
264
+					}
265
+					$datum[7] .= '</span>';
266
+				}
267
+				else {
268
+					$datum[6] = I18N::translate('Error when loading map.');
269
+				}
270
+			}
271
+			$datum[8] = $options->isUsingFlags() ? 
272 272
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : 
273 273
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
274
-		    $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
274
+			$datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
275 275
 		    
276
-		    $data[] = $datum;
277
-        }
276
+			$data[] = $datum;
277
+		}
278 278
         
279
-        $controller->pageHeader();
279
+		$controller->pageHeader();
280 280
         
281
-        $controller->encode(array(
282
-            'draw'            => Filter::getInteger('draw'),
283
-            'recordsTotal'    => $recordsTotal,
284
-            'recordsFiltered' => $recordsFiltered,
285
-            'data'            => $data
286
-        ));
281
+		$controller->encode(array(
282
+			'draw'            => Filter::getInteger('draw'),
283
+			'recordsTotal'    => $recordsTotal,
284
+			'recordsFiltered' => $recordsFiltered,
285
+			'data'            => $data
286
+		));
287 287
         
288
-    }
288
+	}
289 289
 
290
-    /**
291
-     * AdminConfig@edit
292
-     */
293
-    public function edit() {
294
-        $ga_id = Filter::getInteger('ga_id');
295
-        $ga = $this->provider->getGeoAnalysis($ga_id, false);
290
+	/**
291
+	 * AdminConfig@edit
292
+	 */
293
+	public function edit() {
294
+		$ga_id = Filter::getInteger('ga_id');
295
+		$ga = $this->provider->getGeoAnalysis($ga_id, false);
296 296
         
297
-        $this->renderEdit($ga);
298
-    }
297
+		$this->renderEdit($ga);
298
+	}
299 299
     
300
-    /**
301
-     * AdminConfig@add
302
-     */
303
-    public function add() {
304
-        $this->renderEdit(null);
305
-    }
300
+	/**
301
+	 * AdminConfig@add
302
+	 */
303
+	public function add() {
304
+		$this->renderEdit(null);
305
+	}
306 306
     
307
-    /**
308
-     * AdminConfig@save
309
-     */
310
-    public function save() {
311
-        $wt_tree = Globals::getTree();
312
-        $tmp_contrl = new PageController();
313
-        $tmp_contrl->restrictAccess(
314
-            Auth::isManager($wt_tree) 
315
-            && Filter::checkCsrf()
316
-         );
307
+	/**
308
+	 * AdminConfig@save
309
+	 */
310
+	public function save() {
311
+		$wt_tree = Globals::getTree();
312
+		$tmp_contrl = new PageController();
313
+		$tmp_contrl->restrictAccess(
314
+			Auth::isManager($wt_tree) 
315
+			&& Filter::checkCsrf()
316
+		 );
317 317
         
318
-        $ga_id          = Filter::postInteger('ga_id');
319
-        $description    = Filter::post('description');
320
-        $analysislevel  = Filter::postInteger('analysislevel');
321
-        $use_map        = Filter::postBool('use_map');
322
-        if($use_map) {
323
-            $map_file   = base64_decode(Filter::post('map_file'));
324
-            $map_top_level   = Filter::postInteger('map_top_level');
325
-        }
326
-        $use_flags      = Filter::postBool('use_flags');
327
-        $gen_details    = Filter::postInteger('gen_details');
318
+		$ga_id          = Filter::postInteger('ga_id');
319
+		$description    = Filter::post('description');
320
+		$analysislevel  = Filter::postInteger('analysislevel');
321
+		$use_map        = Filter::postBool('use_map');
322
+		if($use_map) {
323
+			$map_file   = base64_decode(Filter::post('map_file'));
324
+			$map_top_level   = Filter::postInteger('map_top_level');
325
+		}
326
+		$use_flags      = Filter::postBool('use_flags');
327
+		$gen_details    = Filter::postInteger('gen_details');
328 328
         
329
-        $success = false; 
330
-        if($ga_id) {
331
-            $ga = $this->provider->getGeoAnalysis($ga_id, false);
332
-            if($ga) {
333
-                $ga->setTitle($description);
334
-                $ga->setAnalysisLevel($analysislevel + 1);
335
-                $options = $ga->getOptions();
336
-                if($options) {
337
-                    $options->setUsingFlags($use_flags);
338
-                    $options->setMaxDetailsInGen($gen_details);
339
-                    if($use_map) {
340
-                        $options->setMap(new OutlineMap($map_file));
341
-                        $options->setMapLevel($map_top_level + 1);
342
-                    }
343
-                    else {
344
-                        $options->setMap(null);
345
-                    }
346
-                }
329
+		$success = false; 
330
+		if($ga_id) {
331
+			$ga = $this->provider->getGeoAnalysis($ga_id, false);
332
+			if($ga) {
333
+				$ga->setTitle($description);
334
+				$ga->setAnalysisLevel($analysislevel + 1);
335
+				$options = $ga->getOptions();
336
+				if($options) {
337
+					$options->setUsingFlags($use_flags);
338
+					$options->setMaxDetailsInGen($gen_details);
339
+					if($use_map) {
340
+						$options->setMap(new OutlineMap($map_file));
341
+						$options->setMapLevel($map_top_level + 1);
342
+					}
343
+					else {
344
+						$options->setMap(null);
345
+					}
346
+				}
347 347
 				
348 348
 				$res = $this->provider->updateGeoAnalysis($ga);
349 349
 				if($res) {
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 					FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger');
357 357
 					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.');
358 358
 				}
359
-            }
360
-        } else {
359
+			}
360
+		} else {
361 361
 			$ga = $this->provider->createGeoAnalysis(
362 362
 				$description,
363 363
 				$analysislevel + 1,
@@ -375,33 +375,33 @@  discard block
 block discarded – undo
375 375
 				FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger');
376 376
 				Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.');
377 377
 			}
378
-        }
378
+		}
379 379
         
380
-        $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl();
381
-        if(!$success) {			
382
-            if($ga) {
383
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl();
384
-            }
385
-            else {
386
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl();
387
-            }
388
-        }        
389
-        header('Location: ' . WT_BASE_URL . $redirection_url);
380
+		$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl();
381
+		if(!$success) {			
382
+			if($ga) {
383
+				$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl();
384
+			}
385
+			else {
386
+				$redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl();
387
+			}
388
+		}        
389
+		header('Location: ' . WT_BASE_URL . $redirection_url);
390 390
         
391
-    }
391
+	}
392 392
      
393 393
 	/**
394 394
 	 * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one.
395 395
 	 * 
396 396
 	 * @param (GeoAnalysis!null) $ga GeoAnalysis to edit
397 397
 	 */
398
-    protected function renderEdit(GeoAnalysis $ga = null) {
399
-        $wt_tree = Globals::getTree();
400
-        Theme::theme(new AdministrationTheme)->init($wt_tree);
401
-        $controller = new PageController();        
402
-        $controller
403
-            ->restrictAccess(Auth::isManager($wt_tree))
404
-            ->addInlineJavascript('
398
+	protected function renderEdit(GeoAnalysis $ga = null) {
399
+		$wt_tree = Globals::getTree();
400
+		Theme::theme(new AdministrationTheme)->init($wt_tree);
401
+		$controller = new PageController();        
402
+		$controller
403
+			->restrictAccess(Auth::isManager($wt_tree))
404
+			->addInlineJavascript('
405 405
                 function toggleMapOptions() {
406 406
                     if($("input:radio[name=\'use_map\']:checked").val() == 1) {
407 407
                         $("#map_options").show();
@@ -415,34 +415,34 @@  discard block
 block discarded – undo
415 415
                 toggleMapOptions();
416 416
             ');
417 417
         
418
-        $data = new ViewBag();
419
-        if($ga) {
420
-            $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
421
-            $data->set('geo_analysis', $ga);
422
-        } else {
423
-            $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
424
-        }
418
+		$data = new ViewBag();
419
+		if($ga) {
420
+			$controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
421
+			$data->set('geo_analysis', $ga);
422
+		} else {
423
+			$controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
424
+		}
425 425
         
426
-        $data->set('title', $controller->getPageTitle());
427
-        $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl());
428
-        $data->set('module_title', $this->module->getTitle());
429
-        $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl());
430
-        $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
426
+		$data->set('title', $controller->getPageTitle());
427
+		$data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl());
428
+		$data->set('module_title', $this->module->getTitle());
429
+		$data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl());
430
+		$data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
431 431
     
432
-        $map_list = array_map(
433
-            function(OutlineMap $map) {
434
-                return $map->getDescription();
435
-            },
436
-            $this->provider->getOutlineMapsList()
437
-            );
438
-        asort($map_list);
439
-        $data->set('map_list', $map_list);
432
+		$map_list = array_map(
433
+			function(OutlineMap $map) {
434
+				return $map->getDescription();
435
+			},
436
+			$this->provider->getOutlineMapsList()
437
+			);
438
+		asort($map_list);
439
+		$data->set('map_list', $map_list);
440 440
     
441
-        $gen_details = array(0 => I18N::translate('All'));
442
-        for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
443
-        $data->set('generation_details', $gen_details);
441
+		$gen_details = array(0 => I18N::translate('All'));
442
+		for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
443
+		$data->set('generation_details', $gen_details);
444 444
     
445
-        ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
446
-    }
445
+		ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
446
+	}
447 447
     
448 448
 }
449 449
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +44 added lines, -46 removed lines patch added patch discarded remove patch
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
         $data->set('title', $controller->getPageTitle());
72 72
         $data->set('tree', $wt_tree);
73 73
         
74
-        $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
74
+        $data->set('root_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig');
75 75
                 
76
-        $table_id = 'table-geoanalysis-' . Uuid::uuid4();
76
+        $table_id = 'table-geoanalysis-'.Uuid::uuid4();
77 77
         $data->set('table_id', $table_id);
78 78
         
79 79
         $other_trees = array();
80 80
         foreach (Tree::getAll() as $tree) {
81
-            if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
81
+            if ($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
82 82
         }      
83 83
         $data->set('other_trees', $other_trees);
84 84
         
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
                     processing: true,
102 102
                     serverSide : true,
103 103
 					ajax : {
104
-						url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='. $wt_tree->getNameUrl().'",
104
+						url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='.$wt_tree->getNameUrl().'",
105 105
                         type : "POST"
106 106
 					},
107 107
                     columns: [
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                             url: "module.php", 
126 126
                             type: "GET",
127 127
                             data: {
128
-                			    mod: "' . $this->module->getName() .'",
128
+                			    mod: "' . $this->module->getName().'",
129 129
                                 mod_action:  "GeoAnalysis@setStatus",
130 130
                 			    ga_id: ga_id,
131 131
                 			    ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom,
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                             },
134 134
                             error: function(result, stat, error) {
135 135
                                 var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
136
-                                alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err);
136
+                                alert("' . I18N::translate('An error occured while editing this analysis:').'" + err);
137 137
                             },
138 138
                             complete: function(result, stat) {
139 139
                                 geoAnalysisTable.ajax.reload(null, false);
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
                             url: "module.php", 
147 147
                             type: "GET",
148 148
                             data: {
149
-                			    mod: "' . $this->module->getName() .'",
149
+                			    mod: "' . $this->module->getName().'",
150 150
                                 mod_action:  "GeoAnalysis@delete",
151 151
                 			    ga_id: ga_id,
152 152
                 			    ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom
153 153
                             },
154 154
                             error: function(result, stat, error) {
155 155
                                 var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
156
-                                alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err);
156
+                                alert("' . I18N::translate('An error occured while deleting this analysis:').'" + err);
157 157
                             },
158 158
                             complete: function(result, stat) {
159 159
                                 geoAnalysisTable.ajax.reload(null, false);
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
         
178 178
         // Generate an AJAX/JSON response for datatables to load a block of rows
179 179
         $search = Filter::postArray('search');
180
-        if($search) $search = $search['value'];
180
+        if ($search) $search = $search['value'];
181 181
         $start  = Filter::postInteger('start');
182 182
         $length = Filter::postInteger('length');
183 183
         $order  = Filter::postArray('order');
184 184
         
185
-        foreach($order as $key => &$value) {
186
-            switch($value['column']) {
185
+        foreach ($order as $key => &$value) {
186
+            switch ($value['column']) {
187 187
                 case 3:
188 188
                     $value['column'] = 'majgd_descr';
189 189
                     break;
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
         
205 205
         $data = array();
206 206
         $place_hierarchy = $this->provider->getPlacesHierarchy();
207
-        foreach($list as $ga) {
207
+        foreach ($list as $ga) {
208 208
             /** @var GeoAnalysis $ga */
209 209
             
210 210
             $datum = array();
211
-            $options= $ga->getOptions();
211
+            $options = $ga->getOptions();
212 212
             
213 213
             $datum[0] = '
214 214
                 <div class="btn-group">
@@ -218,47 +218,46 @@  discard block
 block discarded – undo
218 218
                     <ul class="dropdown-menu" role="menu">
219 219
                        <li>
220 220
                             <a href="#" onclick="return set_geoanalysis_status('. $ga->getId().', '.($ga->isEnabled() ? 'false' : 'true').', \''.Filter::escapeJs($wt_tree->getName()).'\');">
221
-                                <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . '
221
+                                <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).'
222 222
                             </a>
223 223
                        </li>
224 224
                         <li>
225 225
                             <a href="module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getName().'">
226
-                                <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . '
226
+                                <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').'
227 227
                             </a>
228 228
                        </li>
229 229
                        <li class="divider" />
230 230
                        <li>
231 231
                             <a href="#" onclick="return delete_geoanalysis('. $ga->getId().', \''.Filter::escapeJs($wt_tree->getName()).'\');">
232
-                                <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete') . '
232
+                                <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete').'
233 233
                             </a>
234 234
                        </li>
235 235
                     </ul>
236 236
                 </div>';
237 237
 		    $datum[1] = $ga->getId();
238 238
 		    $datum[2] = $ga->isEnabled() ? 
239
-				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : 
240
-				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
239
+				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
241 240
 		    $datum[3] = $ga->getTitle();
242 241
 		    $analysis_level = $ga->getAnalysisLevel();
243
-		    if($place_hierarchy['type'] == 'header') {
242
+		    if ($place_hierarchy['type'] == 'header') {
244 243
 		        $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
245 244
 		    } elseif ($place_hierarchy['type'] == 'data') {
246
-		        $datum[4] = $analysis_level . ' (' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
245
+		        $datum[4] = $analysis_level.' ('.$place_hierarchy['hierarchy'][$analysis_level - 1].')';
247 246
 		    } else {
248 247
 		        $datum[4] = $analysis_level;
249 248
 		    }
250 249
 		    $datum[5] = $ga->getAnalysisLevel();
251 250
 		    $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
252 251
 		    $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>';
253
-		    if($ga->hasMap()) {
254
-		        if($options->getMap()->isLoaded()) {
252
+		    if ($ga->hasMap()) {
253
+		        if ($options->getMap()->isLoaded()) {
255 254
     		        $datum[6] = $options->getMap()->getDescription();
256
-    		        $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
255
+    		        $datum[7] = '<span data-toggle="tooltip" title="'.$options->getMap()->getTopLevelName().'" />';
257 256
     		        $top_level = $options->getMapLevel();
258
-    		        if($place_hierarchy['type'] == 'header') {
257
+    		        if ($place_hierarchy['type'] == 'header') {
259 258
     		            $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
260 259
     		        } elseif ($place_hierarchy['type'] == 'data') {
261
-    		            $datum[7] .= $top_level . ' (' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
260
+    		            $datum[7] .= $top_level.' ('.$place_hierarchy['hierarchy'][$top_level - 1].')';
262 261
     		        } else {
263 262
     		            $datum[7] .= $top_level;
264 263
     		        }
@@ -269,8 +268,7 @@  discard block
 block discarded – undo
269 268
 		        }
270 269
 		    }
271 270
 		    $datum[8] = $options->isUsingFlags() ? 
272
-				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : 
273
-				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
271
+				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
274 272
 		    $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
275 273
 		    
276 274
 		    $data[] = $datum;
@@ -319,24 +317,24 @@  discard block
 block discarded – undo
319 317
         $description    = Filter::post('description');
320 318
         $analysislevel  = Filter::postInteger('analysislevel');
321 319
         $use_map        = Filter::postBool('use_map');
322
-        if($use_map) {
320
+        if ($use_map) {
323 321
             $map_file   = base64_decode(Filter::post('map_file'));
324
-            $map_top_level   = Filter::postInteger('map_top_level');
322
+            $map_top_level = Filter::postInteger('map_top_level');
325 323
         }
326 324
         $use_flags      = Filter::postBool('use_flags');
327 325
         $gen_details    = Filter::postInteger('gen_details');
328 326
         
329 327
         $success = false; 
330
-        if($ga_id) {
328
+        if ($ga_id) {
331 329
             $ga = $this->provider->getGeoAnalysis($ga_id, false);
332
-            if($ga) {
330
+            if ($ga) {
333 331
                 $ga->setTitle($description);
334 332
                 $ga->setAnalysisLevel($analysislevel + 1);
335 333
                 $options = $ga->getOptions();
336
-                if($options) {
334
+                if ($options) {
337 335
                     $options->setUsingFlags($use_flags);
338 336
                     $options->setMaxDetailsInGen($gen_details);
339
-                    if($use_map) {
337
+                    if ($use_map) {
340 338
                         $options->setMap(new OutlineMap($map_file));
341 339
                         $options->setMapLevel($map_top_level + 1);
342 340
                     }
@@ -346,7 +344,7 @@  discard block
 block discarded – undo
346 344
                 }
347 345
 				
348 346
 				$res = $this->provider->updateGeoAnalysis($ga);
349
-				if($res) {
347
+				if ($res) {
350 348
 					FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully updated', $res->getTitle()), 'success');
351 349
 					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.');
352 350
 					$ga = $res;
@@ -354,7 +352,7 @@  discard block
 block discarded – undo
354 352
 				}
355 353
 				else {
356 354
 					FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger');
357
-					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.');
355
+					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” could not be updated. See error log.');
358 356
 				}
359 357
             }
360 358
         } else {
@@ -366,7 +364,7 @@  discard block
 block discarded – undo
366 364
 				$use_flags,
367 365
 				$gen_details
368 366
 			);
369
-			if($ga) {
367
+			if ($ga) {
370 368
 				FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success');
371 369
 				Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.');
372 370
 				$success = true;
@@ -377,16 +375,16 @@  discard block
 block discarded – undo
377 375
 			}
378 376
         }
379 377
         
380
-        $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl();
381
-        if(!$success) {			
382
-            if($ga) {
383
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl();
378
+        $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl();
379
+        if (!$success) {			
380
+            if ($ga) {
381
+                $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getNameUrl();
384 382
             }
385 383
             else {
386
-                $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl();
384
+                $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@add&ged='.$wt_tree->getNameUrl();
387 385
             }
388 386
         }        
389
-        header('Location: ' . WT_BASE_URL . $redirection_url);
387
+        header('Location: '.WT_BASE_URL.$redirection_url);
390 388
         
391 389
     }
392 390
      
@@ -416,7 +414,7 @@  discard block
 block discarded – undo
416 414
             ');
417 415
         
418 416
         $data = new ViewBag();
419
-        if($ga) {
417
+        if ($ga) {
420 418
             $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
421 419
             $data->set('geo_analysis', $ga);
422 420
         } else {
@@ -424,9 +422,9 @@  discard block
 block discarded – undo
424 422
         }
425 423
         
426 424
         $data->set('title', $controller->getPageTitle());
427
-        $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl());
425
+        $data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl());
428 426
         $data->set('module_title', $this->module->getTitle());
429
-        $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl());
427
+        $data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@save&ged='.$wt_tree->getNameUrl());
430 428
         $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
431 429
     
432 430
         $map_list = array_map(
@@ -439,7 +437,7 @@  discard block
 block discarded – undo
439 437
         $data->set('map_list', $map_list);
440 438
     
441 439
         $gen_details = array(0 => I18N::translate('All'));
442
-        for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
440
+        for ($i = 1; $i <= 10; $i++) $gen_details[$i] = $i;
443 441
         $data->set('generation_details', $gen_details);
444 442
     
445 443
         ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
Please login to merge, or discard this patch.
Braces   +14 added lines, -13 removed lines patch added patch discarded remove patch
@@ -78,7 +78,9 @@  discard block
 block discarded – undo
78 78
         
79 79
         $other_trees = array();
80 80
         foreach (Tree::getAll() as $tree) {
81
-            if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
81
+            if($tree->getTreeId() != $wt_tree->getTreeId()) {
82
+            	$other_trees[] = $tree;
83
+            }
82 84
         }      
83 85
         $data->set('other_trees', $other_trees);
84 86
         
@@ -177,7 +179,9 @@  discard block
 block discarded – undo
177 179
         
178 180
         // Generate an AJAX/JSON response for datatables to load a block of rows
179 181
         $search = Filter::postArray('search');
180
-        if($search) $search = $search['value'];
182
+        if($search) {
183
+        	$search = $search['value'];
184
+        }
181 185
         $start  = Filter::postInteger('start');
182 186
         $length = Filter::postInteger('length');
183 187
         $order  = Filter::postArray('order');
@@ -263,8 +267,7 @@  discard block
 block discarded – undo
263 267
     		            $datum[7] .= $top_level;
264 268
     		        }
265 269
     		        $datum[7] .= '</span>';
266
-		        }
267
-		        else {
270
+		        } else {
268 271
 		            $datum[6] = I18N::translate('Error when loading map.');
269 272
 		        }
270 273
 		    }
@@ -339,8 +342,7 @@  discard block
 block discarded – undo
339 342
                     if($use_map) {
340 343
                         $options->setMap(new OutlineMap($map_file));
341 344
                         $options->setMapLevel($map_top_level + 1);
342
-                    }
343
-                    else {
345
+                    } else {
344 346
                         $options->setMap(null);
345 347
                     }
346 348
                 }
@@ -351,8 +353,7 @@  discard block
 block discarded – undo
351 353
 					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.');
352 354
 					$ga = $res;
353 355
 					$success = true;
354
-				}
355
-				else {
356
+				} else {
356 357
 					FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger');
357 358
 					Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.');
358 359
 				}
@@ -370,8 +371,7 @@  discard block
 block discarded – undo
370 371
 				FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success');
371 372
 				Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.');
372 373
 				$success = true;
373
-			}
374
-			else {
374
+			} else {
375 375
 				FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger');
376 376
 				Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.');
377 377
 			}
@@ -381,8 +381,7 @@  discard block
 block discarded – undo
381 381
         if(!$success) {			
382 382
             if($ga) {
383 383
                 $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl();
384
-            }
385
-            else {
384
+            } else {
386 385
                 $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl();
387 386
             }
388 387
         }        
@@ -439,7 +438,9 @@  discard block
 block discarded – undo
439 438
         $data->set('map_list', $map_list);
440 439
     
441 440
         $gen_details = array(0 => I18N::translate('All'));
442
-        for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i;
441
+        for($i = 1; $i <= 10 ; $i++) {
442
+        	$gen_details[$i] = $i;
443
+        }
443 444
         $data->set('generation_details', $gen_details);
444 445
     
445 446
         ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Http/RequestHandlers/SurnamesList.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,71 +30,71 @@
 block discarded – undo
30 30
  */
31 31
 class SurnamesList implements RequestHandlerInterface
32 32
 {
33
-    use ViewResponseTrait;
33
+	use ViewResponseTrait;
34 34
 
35
-    /**
36
-     * @var PatronymicLineageModule $module
37
-     */
38
-    private $module;
35
+	/**
36
+	 * @var PatronymicLineageModule $module
37
+	 */
38
+	private $module;
39 39
     
40
-    /**
41
-     * @var IndividualListService $indilist_service
42
-     */
43
-    private $indilist_service;
40
+	/**
41
+	 * @var IndividualListService $indilist_service
42
+	 */
43
+	private $indilist_service;
44 44
     
45
-    /**
46
-     * Constructor for SurnamesList Request Handler
47
-     *
48
-     * @param ModuleService $module_service
49
-     * @param IndividualListService $indilist_service
50
-     */
51
-    public function __construct(ModuleService $module_service, IndividualListService $indilist_service)
52
-    {
53
-        $this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
54
-        $this->indilist_service = $indilist_service;
55
-    }
45
+	/**
46
+	 * Constructor for SurnamesList Request Handler
47
+	 *
48
+	 * @param ModuleService $module_service
49
+	 * @param IndividualListService $indilist_service
50
+	 */
51
+	public function __construct(ModuleService $module_service, IndividualListService $indilist_service)
52
+	{
53
+		$this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
54
+		$this->indilist_service = $indilist_service;
55
+	}
56 56
     
57
-    /**
58
-     * {@inheritDoc}
59
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
60
-     */
61
-    public function handle(ServerRequestInterface $request): ResponseInterface
62
-    {
63
-        if ($this->module === null) {
64
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
65
-        }
57
+	/**
58
+	 * {@inheritDoc}
59
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
60
+	 */
61
+	public function handle(ServerRequestInterface $request): ResponseInterface
62
+	{
63
+		if ($this->module === null) {
64
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
65
+		}
66 66
         
67
-        $tree = $request->getAttribute('tree');
68
-        assert($tree instanceof Tree);
67
+		$tree = $request->getAttribute('tree');
68
+		assert($tree instanceof Tree);
69 69
         
70
-        $initial = $request->getAttribute('alpha');
71
-        $initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale()))
72
-            ->reject(function ($count, $initial) {
70
+		$initial = $request->getAttribute('alpha');
71
+		$initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale()))
72
+			->reject(function ($count, $initial) {
73 73
 
74
-                return $initial === '@' || $initial === ',';
75
-            });
74
+				return $initial === '@' || $initial === ',';
75
+			});
76 76
             
77
-        $show_all = $request->getQueryParams()['show_all'] ?? 'no';
77
+		$show_all = $request->getQueryParams()['show_all'] ?? 'no';
78 78
         
79
-        if ($show_all === 'yes') {
80
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All');
81
-            $surnames = $this->indilist_service->surnames('', '', false, false, I18N::locale());
82
-        } elseif ($initial !== null && mb_strlen($initial) == 1) {
83
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . $initial;
84
-            $surnames = $this->indilist_service->surnames('', $initial, false, false, I18N::locale());
85
-        } else {
86
-            $title =  I18N::translate('Patronymic Lineages');
87
-            $surnames = [];
88
-        }
79
+		if ($show_all === 'yes') {
80
+			$title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All');
81
+			$surnames = $this->indilist_service->surnames('', '', false, false, I18N::locale());
82
+		} elseif ($initial !== null && mb_strlen($initial) == 1) {
83
+			$title = I18N::translate('Patronymic Lineages') . ' — ' . $initial;
84
+			$surnames = $this->indilist_service->surnames('', $initial, false, false, I18N::locale());
85
+		} else {
86
+			$title =  I18N::translate('Patronymic Lineages');
87
+			$surnames = [];
88
+		}
89 89
         
90
-        return $this->viewResponse($this->module->name() . '::surnames-page', [
91
-            'title'         =>  $title,
92
-            'module'        =>  $this->module,
93
-            'tree'          =>  $tree,
94
-            'initials_list' =>  $initials_list,
95
-            'initial'       =>  $initial,
96
-            'show_all'      =>  $show_all,
97
-            'surnames'      =>  $surnames
98
-        ]);
99
-    }
90
+		return $this->viewResponse($this->module->name() . '::surnames-page', [
91
+			'title'         =>  $title,
92
+			'module'        =>  $this->module,
93
+			'tree'          =>  $tree,
94
+			'initials_list' =>  $initials_list,
95
+			'initial'       =>  $initial,
96
+			'show_all'      =>  $show_all,
97
+			'surnames'      =>  $surnames
98
+		]);
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         
70 70
         $initial = $request->getAttribute('alpha');
71 71
         $initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale()))
72
-            ->reject(function ($count, $initial) {
72
+            ->reject(function($count, $initial) {
73 73
 
74 74
                 return $initial === '@' || $initial === ',';
75 75
             });
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
         $show_all = $request->getQueryParams()['show_all'] ?? 'no';
78 78
         
79 79
         if ($show_all === 'yes') {
80
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . I18N::translate('All');
80
+            $title = I18N::translate('Patronymic Lineages').' — '.I18N::translate('All');
81 81
             $surnames = $this->indilist_service->surnames('', '', false, false, I18N::locale());
82 82
         } elseif ($initial !== null && mb_strlen($initial) == 1) {
83
-            $title = I18N::translate('Patronymic Lineages') . ' — ' . $initial;
83
+            $title = I18N::translate('Patronymic Lineages').' — '.$initial;
84 84
             $surnames = $this->indilist_service->surnames('', $initial, false, false, I18N::locale());
85 85
         } else {
86
-            $title =  I18N::translate('Patronymic Lineages');
86
+            $title = I18N::translate('Patronymic Lineages');
87 87
             $surnames = [];
88 88
         }
89 89
         
90
-        return $this->viewResponse($this->module->name() . '::surnames-page', [
90
+        return $this->viewResponse($this->module->name().'::surnames-page', [
91 91
             'title'         =>  $title,
92 92
             'module'        =>  $this->module,
93 93
             'tree'          =>  $tree,
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Http/RequestHandlers/LineagesPage.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,16 +72,16 @@
 block discarded – undo
72 72
         
73 73
         $initial = mb_substr($surname, 0, 1);
74 74
         $initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale()))
75
-            ->reject(function ($count, $initial) {
75
+            ->reject(function($count, $initial) {
76 76
 
77 77
                 return $initial === '@' || $initial === ',';
78 78
             });
79 79
             
80
-        $title = I18N::translate('Patronymic Lineages') . ' — ' . $surname;
80
+        $title = I18N::translate('Patronymic Lineages').' — '.$surname;
81 81
         
82 82
         $lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages();
83 83
         
84
-        return $this->viewResponse($this->module->name() . '::lineages-page', [
84
+        return $this->viewResponse($this->module->name().'::lineages-page', [
85 85
             'title'         =>  $title,
86 86
             'module'        =>  $this->module,
87 87
             'tree'          =>  $tree,
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -31,66 +31,66 @@
 block discarded – undo
31 31
  */
32 32
 class LineagesPage implements RequestHandlerInterface
33 33
 {
34
-    use ViewResponseTrait;
34
+	use ViewResponseTrait;
35 35
 
36
-    /**
37
-     * @var PatronymicLineageModule $module
38
-     */
39
-    private $module;
36
+	/**
37
+	 * @var PatronymicLineageModule $module
38
+	 */
39
+	private $module;
40 40
     
41
-    /**
42
-     * @var IndividualListService $indilist_service
43
-     */
44
-    private $indilist_service;
41
+	/**
42
+	 * @var IndividualListService $indilist_service
43
+	 */
44
+	private $indilist_service;
45 45
     
46
-    /**
47
-     * Constructor for LineagesPage Request handler
48
-     *
49
-     * @param ModuleService $module_service
50
-     * @param IndividualListService $indilist_service
51
-     */
52
-    public function __construct(ModuleService $module_service, IndividualListService $indilist_service)
53
-    {
54
-            $this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
55
-        $this->indilist_service = $indilist_service;
56
-    }
46
+	/**
47
+	 * Constructor for LineagesPage Request handler
48
+	 *
49
+	 * @param ModuleService $module_service
50
+	 * @param IndividualListService $indilist_service
51
+	 */
52
+	public function __construct(ModuleService $module_service, IndividualListService $indilist_service)
53
+	{
54
+			$this->module = $module_service->findByInterface(PatronymicLineageModule::class)->first();
55
+		$this->indilist_service = $indilist_service;
56
+	}
57 57
     
58
-    /**
59
-     * {@inheritDoc}
60
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
61
-     */
62
-    public function handle(ServerRequestInterface $request): ResponseInterface
63
-    {
64
-        if ($this->module === null) {
65
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
66
-        }
58
+	/**
59
+	 * {@inheritDoc}
60
+	 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
61
+	 */
62
+	public function handle(ServerRequestInterface $request): ResponseInterface
63
+	{
64
+		if ($this->module === null) {
65
+			throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
66
+		}
67 67
         
68
-        $tree = $request->getAttribute('tree');
69
-        assert($tree instanceof Tree);
68
+		$tree = $request->getAttribute('tree');
69
+		assert($tree instanceof Tree);
70 70
         
71
-        $surname = $request->getAttribute('surname');
71
+		$surname = $request->getAttribute('surname');
72 72
         
73
-        $initial = mb_substr($surname, 0, 1);
74
-        $initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale()))
75
-            ->reject(function ($count, $initial) {
73
+		$initial = mb_substr($surname, 0, 1);
74
+		$initials_list = collect($this->indilist_service->surnameAlpha(false, false, I18N::locale()))
75
+			->reject(function ($count, $initial) {
76 76
 
77
-                return $initial === '@' || $initial === ',';
78
-            });
77
+				return $initial === '@' || $initial === ',';
78
+			});
79 79
             
80
-        $title = I18N::translate('Patronymic Lineages') . ' — ' . $surname;
80
+		$title = I18N::translate('Patronymic Lineages') . ' — ' . $surname;
81 81
         
82
-        $lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages();
82
+		$lineages = app()->make(LineageBuilder::class, ['surname' => $surname])->buildLineages();
83 83
         
84
-        return $this->viewResponse($this->module->name() . '::lineages-page', [
85
-            'title'         =>  $title,
86
-            'module'        =>  $this->module,
87
-            'tree'          =>  $tree,
88
-            'initials_list' =>  $initials_list,
89
-            'initial'       =>  $initial,
90
-            'show_all'      =>  'no',
91
-            'surname'       =>  $surname,
92
-            'lineages'      =>  $lineages,
93
-            'nb_lineages'   =>  $lineages !== null ? $lineages->count() : 0
94
-        ]);
95
-    }
84
+		return $this->viewResponse($this->module->name() . '::lineages-page', [
85
+			'title'         =>  $title,
86
+			'module'        =>  $this->module,
87
+			'tree'          =>  $tree,
88
+			'initials_list' =>  $initials_list,
89
+			'initial'       =>  $initial,
90
+			'show_all'      =>  'no',
91
+			'surname'       =>  $surname,
92
+			'lineages'      =>  $lineages,
93
+			'nb_lineages'   =>  $lineages !== null ? $lineages->count() : 0
94
+		]);
95
+	}
96 96
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/PatronymicLineageModule.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -33,86 +33,86 @@
 block discarded – undo
33 33
  */
34 34
 class PatronymicLineageModule extends AbstractModuleMaj implements ModuleListInterface, ModuleGlobalInterface
35 35
 {
36
-    use ModuleListTrait;
37
-    use ModuleGlobalTrait;
36
+	use ModuleListTrait;
37
+	use ModuleGlobalTrait;
38 38
 
39
-     /**
40
-     * {@inheritDoc}
41
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
42
-     */
43
-    public function title(): string
44
-    {
45
-        return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages');
46
-    }
39
+	 /**
40
+	  * {@inheritDoc}
41
+	  * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
42
+	  */
43
+	public function title(): string
44
+	{
45
+		return /* I18N: Name of the “Patronymic lineage” module */ I18N::translate('Patronymic Lineages');
46
+	}
47 47
     
48
-    /**
49
-     * {@inheritDoc}
50
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
51
-     */
52
-    public function description(): string
53
-    {
54
-        //phpcs:ignore Generic.Files.LineLength.TooLong
55
-        return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.');
56
-    }
48
+	/**
49
+	 * {@inheritDoc}
50
+	 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
51
+	 */
52
+	public function description(): string
53
+	{
54
+		//phpcs:ignore Generic.Files.LineLength.TooLong
55
+		return /* I18N: Description of the “Patronymic lineage” module */ I18N::translate('Display lineages of people holding the same surname.');
56
+	}
57 57
     
58
-    /**
59
-     * {@inheritDoc}
60
-     * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes()
61
-     */
62
-    public function loadRoutes(Map $router): void
63
-    {
64
-        $router->attach('', '', static function (Map $router) {
58
+	/**
59
+	 * {@inheritDoc}
60
+	 * @see \MyArtJaub\Webtrees\Module\AbstractModuleMaj::loadRoutes()
61
+	 */
62
+	public function loadRoutes(Map $router): void
63
+	{
64
+		$router->attach('', '', static function (Map $router) {
65 65
 
66
-            $router->attach('', '/module-maj/lineages', static function (Map $router) {
66
+			$router->attach('', '/module-maj/lineages', static function (Map $router) {
67 67
 
68
-                $router->attach('', '/Page', static function (Map $router) {
68
+				$router->attach('', '/Page', static function (Map $router) {
69 69
 
70
-                    $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
71
-                    $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
72
-                });
73
-            });
74
-        });
75
-    }
70
+					$router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
71
+					$router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
72
+				});
73
+			});
74
+		});
75
+	}
76 76
     
77
-    /**
78
-     * {@inheritDoc}
79
-     * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl()
80
-     */
81
-    public function listUrl(Tree $tree, array $parameters = []): string
82
-    {
83
-        $surname = $parameters['surname'] ?? '';
77
+	/**
78
+	 * {@inheritDoc}
79
+	 * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listUrl()
80
+	 */
81
+	public function listUrl(Tree $tree, array $parameters = []): string
82
+	{
83
+		$surname = $parameters['surname'] ?? '';
84 84
         
85
-        $xref = app(ServerRequestInterface::class)->getAttribute('xref', '');
86
-        if ($xref !== '' && $individual = Factory::individual()->make($xref, $tree)) {
87
-            $surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname'];
88
-        }
85
+		$xref = app(ServerRequestInterface::class)->getAttribute('xref', '');
86
+		if ($xref !== '' && $individual = Factory::individual()->make($xref, $tree)) {
87
+			$surname = $individual->getAllNames()[$individual->getPrimaryName()]['surname'];
88
+		}
89 89
         
90
-        if ($surname !== '') {
91
-            return route(LineagesPage::class, [
92
-                'tree'      =>  $tree->name(),
93
-                'surname'   =>  $surname
94
-            ] + $parameters);
95
-        }
96
-        return route(SurnamesList::class, [
97
-            'tree'  =>  $tree->name()
98
-        ] + $parameters);
99
-    }
90
+		if ($surname !== '') {
91
+			return route(LineagesPage::class, [
92
+				'tree'      =>  $tree->name(),
93
+				'surname'   =>  $surname
94
+			] + $parameters);
95
+		}
96
+		return route(SurnamesList::class, [
97
+			'tree'  =>  $tree->name()
98
+		] + $parameters);
99
+	}
100 100
     
101
-    /**
102
-     * {@inheritDoc}
103
-     * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass()
104
-     */
105
-    public function listMenuClass(): string
106
-    {
107
-        return 'menu-maj-patrolineage';
108
-    }
101
+	/**
102
+	 * {@inheritDoc}
103
+	 * @see \Fisharebest\Webtrees\Module\ModuleListInterface::listMenuClass()
104
+	 */
105
+	public function listMenuClass(): string
106
+	{
107
+		return 'menu-maj-patrolineage';
108
+	}
109 109
     
110
-    /**
111
-     * {@inheritDoc}
112
-     * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
113
-     */
114
-    public function headContent(): string
115
-    {
116
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
117
-    }
110
+	/**
111
+	 * {@inheritDoc}
112
+	 * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent()
113
+	 */
114
+	public function headContent(): string
115
+	{
116
+		return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function loadRoutes(Map $router): void
63 63
     {
64
-        $router->attach('', '', static function (Map $router) {
64
+        $router->attach('', '', static function(Map $router) {
65 65
 
66
-            $router->attach('', '/module-maj/lineages', static function (Map $router) {
66
+            $router->attach('', '/module-maj/lineages', static function(Map $router) {
67 67
 
68
-                $router->attach('', '/Page', static function (Map $router) {
68
+                $router->attach('', '/Page', static function(Map $router) {
69 69
 
70 70
                     $router->get(SurnamesList::class, '/{tree}/list{/alpha}', SurnamesList::class);
71 71
                     $router->get(LineagesPage::class, '/{tree}/lineage/{surname}', LineagesPage::class);
@@ -113,6 +113,6 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function headContent(): string
115 115
     {
116
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
116
+        return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">';
117 117
     }
118 118
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageRootNode.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -24,68 +24,68 @@
 block discarded – undo
24 24
 class LineageRootNode extends LineageNode
25 25
 {
26 26
     
27
-    /**
28
-     * @var Collection $places Places for the lineage node
29
-     */
30
-    private $places;
27
+	/**
28
+	 * @var Collection $places Places for the lineage node
29
+	 */
30
+	private $places;
31 31
    
32
-    /**
33
-     * @var int $nb_children Number of node childs
34
-     */
35
-    private $nb_children;
32
+	/**
33
+	 * @var int $nb_children Number of node childs
34
+	 */
35
+	private $nb_children;
36 36
   
37
-    /**
38
-     * Constructor for LineageRootNode
39
-     *
40
-     * @param Individual|null $node_indi
41
-     */
42
-    public function __construct(?Individual $node_indi = null)
43
-    {
44
-        parent::__construct($node_indi, $this);
45
-        $this->places = new Collection();
46
-        $this->nb_children = 0;
47
-    }
37
+	/**
38
+	 * Constructor for LineageRootNode
39
+	 *
40
+	 * @param Individual|null $node_indi
41
+	 */
42
+	public function __construct(?Individual $node_indi = null)
43
+	{
44
+		parent::__construct($node_indi, $this);
45
+		$this->places = new Collection();
46
+		$this->nb_children = 0;
47
+	}
48 48
    
49
-    /**
50
-     * Adds a place to the list of lineage's place
51
-     *
52
-     * @param Place $place
53
-     */
54
-    public function addPlace(Place $place): void
55
-    {
56
-        $place_name = $place->gedcomName();
57
-        if (mb_strlen($place_name) > 0) {
58
-            $this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
-        }
60
-    }
49
+	/**
50
+	 * Adds a place to the list of lineage's place
51
+	 *
52
+	 * @param Place $place
53
+	 */
54
+	public function addPlace(Place $place): void
55
+	{
56
+		$place_name = $place->gedcomName();
57
+		if (mb_strlen($place_name) > 0) {
58
+			$this->places->put($place_name, $this->places->get($place_name, 0) + 1);
59
+		}
60
+	}
61 61
     
62
-    /**
63
-     * Returns the number of child nodes.
64
-     * This number is more to be used as indication rather than an accurate one.
65
-     *
66
-     * @return int
67
-     */
68
-    public function numberChildNodes(): int
69
-    {
70
-        return $this->nb_children;
71
-    }
62
+	/**
63
+	 * Returns the number of child nodes.
64
+	 * This number is more to be used as indication rather than an accurate one.
65
+	 *
66
+	 * @return int
67
+	 */
68
+	public function numberChildNodes(): int
69
+	{
70
+		return $this->nb_children;
71
+	}
72 72
    
73
-    /**
74
-     * Increments the number of child nodes by one
75
-     *
76
-     */
77
-    public function incrementChildNodes(): void
78
-    {
79
-        $this->nb_children++;
80
-    }
73
+	/**
74
+	 * Increments the number of child nodes by one
75
+	 *
76
+	 */
77
+	public function incrementChildNodes(): void
78
+	{
79
+		$this->nb_children++;
80
+	}
81 81
    
82
-    /**
83
-     * Returns the list of place for the lineage
84
-     *
85
-     * @return Collection
86
-     */
87
-    public function places(): Collection
88
-    {
89
-        return $this->places;
90
-    }
82
+	/**
83
+	 * Returns the list of place for the lineage
84
+	 *
85
+	 * @return Collection
86
+	 */
87
+	public function places(): Collection
88
+	{
89
+		return $this->places;
90
+	}
91 91
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageNode.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function addFamily(Family $fams): object
69 69
     {
70 70
         if (!$this->linked_fams->has($fams->xref())) {
71
-            $this->linked_fams->put($fams->xref(), (object) [
71
+            $this->linked_fams->put($fams->xref(), (object)[
72 72
                 'family'   =>  $fams,
73 73
                 'children' =>  new Collection()
74 74
             ]);
@@ -135,6 +135,6 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function hasFollowUpSurname(): bool
137 137
     {
138
-        return mb_strlen($this->followUpSurname()) > 0 ;
138
+        return mb_strlen($this->followUpSurname()) > 0;
139 139
     }
140 140
 }
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -25,117 +25,117 @@
 block discarded – undo
25 25
 class LineageNode
26 26
 {
27 27
   
28
-    /**
29
-     * @var Collection $linked_fams Spouse families linked to the node
30
-     */
31
-    private $linked_fams;
28
+	/**
29
+	 * @var Collection $linked_fams Spouse families linked to the node
30
+	 */
31
+	private $linked_fams;
32 32
   
33
-    /**
34
-     * @var ?Individual $node_indi Reference individual for the node
35
-     */
36
-    private $node_indi;
33
+	/**
34
+	 * @var ?Individual $node_indi Reference individual for the node
35
+	 */
36
+	private $node_indi;
37 37
    
38
-    /**
39
-     * @var LineageRootNode $root_node Root node of the lineage
40
-     */
41
-    private $root_node;
38
+	/**
39
+	 * @var LineageRootNode $root_node Root node of the lineage
40
+	 */
41
+	private $root_node;
42 42
    
43
-    /**
44
-     * @var ?string $alt_surname Linked surname, used to link to another lineage
45
-     */
46
-    private $alt_surname;
43
+	/**
44
+	 * @var ?string $alt_surname Linked surname, used to link to another lineage
45
+	 */
46
+	private $alt_surname;
47 47
  
48
-    /**
49
-     * Constructor for Lineage node
50
-     *
51
-     * @param Individual $node_indi Main individual
52
-     * @param LineageRootNode $root_node Node of the lineage root
53
-     * @param null|string $alt_surname Follow-up surname
54
-     */
55
-    public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
56
-    {
57
-        $this->node_indi = $node_indi;
58
-        $this->root_node = $root_node;
59
-        $this->alt_surname = $alt_surname;
60
-        $this->linked_fams = new Collection();
61
-    }
48
+	/**
49
+	 * Constructor for Lineage node
50
+	 *
51
+	 * @param Individual $node_indi Main individual
52
+	 * @param LineageRootNode $root_node Node of the lineage root
53
+	 * @param null|string $alt_surname Follow-up surname
54
+	 */
55
+	public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null)
56
+	{
57
+		$this->node_indi = $node_indi;
58
+		$this->root_node = $root_node;
59
+		$this->alt_surname = $alt_surname;
60
+		$this->linked_fams = new Collection();
61
+	}
62 62
   
63
-    /**
64
-     * Add a spouse family to the node
65
-     *
66
-     * @param Family $fams
67
-     * @return stdClass
68
-     */
69
-    public function addFamily(Family $fams): object
70
-    {
71
-        if (!$this->linked_fams->has($fams->xref())) {
72
-            $this->linked_fams->put($fams->xref(), (object) [
73
-                'family'   =>  $fams,
74
-                'children' =>  new Collection()
75
-            ]);
76
-        }
77
-        return $this->linked_fams->get($fams->xref());
78
-    }
63
+	/**
64
+	 * Add a spouse family to the node
65
+	 *
66
+	 * @param Family $fams
67
+	 * @return stdClass
68
+	 */
69
+	public function addFamily(Family $fams): object
70
+	{
71
+		if (!$this->linked_fams->has($fams->xref())) {
72
+			$this->linked_fams->put($fams->xref(), (object) [
73
+				'family'   =>  $fams,
74
+				'children' =>  new Collection()
75
+			]);
76
+		}
77
+		return $this->linked_fams->get($fams->xref());
78
+	}
79 79
     
80
-    /**
81
-     * Add a child LineageNode to the node
82
-     *
83
-     * @param Family $fams
84
-     * @param LineageNode $child
85
-     */
86
-    public function addChild(Family $fams, LineageNode $child = null): void
87
-    {
88
-        $this->addFamily($fams)->children->push($child);
89
-        $this->root_node->incrementChildNodes();
90
-    }
80
+	/**
81
+	 * Add a child LineageNode to the node
82
+	 *
83
+	 * @param Family $fams
84
+	 * @param LineageNode $child
85
+	 */
86
+	public function addChild(Family $fams, LineageNode $child = null): void
87
+	{
88
+		$this->addFamily($fams)->children->push($child);
89
+		$this->root_node->incrementChildNodes();
90
+	}
91 91
    
92
-    /**
93
-     * Returns the node individual
94
-     *
95
-     * @return Individual|NULL
96
-     */
97
-    public function individual(): ?Individual
98
-    {
99
-        return $this->node_indi;
100
-    }
92
+	/**
93
+	 * Returns the node individual
94
+	 *
95
+	 * @return Individual|NULL
96
+	 */
97
+	public function individual(): ?Individual
98
+	{
99
+		return $this->node_indi;
100
+	}
101 101
    
102
-    /**
103
-     * Returns the lineage root node individual
104
-     *
105
-     * @return LineageRootNode
106
-     */
107
-    public function rootNode(): LineageRootNode
108
-    {
109
-        return $this->root_node;
110
-    }
102
+	/**
103
+	 * Returns the lineage root node individual
104
+	 *
105
+	 * @return LineageRootNode
106
+	 */
107
+	public function rootNode(): LineageRootNode
108
+	{
109
+		return $this->root_node;
110
+	}
111 111
     
112
-    /**
113
-     * Returns the spouse families linked to the node
114
-     *
115
-     * @return Collection
116
-     */
117
-    public function families(): Collection
118
-    {
119
-        return $this->linked_fams;
120
-    }
112
+	/**
113
+	 * Returns the spouse families linked to the node
114
+	 *
115
+	 * @return Collection
116
+	 */
117
+	public function families(): Collection
118
+	{
119
+		return $this->linked_fams;
120
+	}
121 121
   
122
-    /**
123
-     * Returns the follow-up surname
124
-     *
125
-     * @return string
126
-     */
127
-    public function followUpSurname(): string
128
-    {
129
-        return $this->alt_surname ?? '';
130
-    }
122
+	/**
123
+	 * Returns the follow-up surname
124
+	 *
125
+	 * @return string
126
+	 */
127
+	public function followUpSurname(): string
128
+	{
129
+		return $this->alt_surname ?? '';
130
+	}
131 131
     
132
-    /**
133
-     * Indicates whether the node has a follow up surname
134
-     *
135
-     * @return boolean
136
-     */
137
-    public function hasFollowUpSurname(): bool
138
-    {
139
-        return mb_strlen($this->followUpSurname()) > 0 ;
140
-    }
132
+	/**
133
+	 * Indicates whether the node has a follow up surname
134
+	 *
135
+	 * @return boolean
136
+	 */
137
+	public function hasFollowUpSurname(): bool
138
+	{
139
+		return mb_strlen($this->followUpSurname()) > 0 ;
140
+	}
141 141
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/PatronymicLineage/Model/LineageBuilder.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -29,212 +29,212 @@
 block discarded – undo
29 29
 class LineageBuilder
30 30
 {
31 31
     
32
-    /**
33
-     * @var string $surname Reference surname
34
-     */
35
-    private $surname;
32
+	/**
33
+	 * @var string $surname Reference surname
34
+	 */
35
+	private $surname;
36 36
     
37
-    /**
38
-     * @var Tree $tree Reference tree
39
-     */
40
-    private $tree;
37
+	/**
38
+	 * @var Tree $tree Reference tree
39
+	 */
40
+	private $tree;
41 41
    
42
-    /**
43
-     * @var IndividualListService $indilist_service
44
-     */
45
-    private $indilist_service;
42
+	/**
43
+	 * @var IndividualListService $indilist_service
44
+	 */
45
+	private $indilist_service;
46 46
     
47
-    /**
48
-     * @var Collection $used_indis Individuals already processed
49
-     */
50
-    private $used_indis;
47
+	/**
48
+	 * @var Collection $used_indis Individuals already processed
49
+	 */
50
+	private $used_indis;
51 51
  
52
-    /**
53
-     * Constructor for Lineage Builder
54
-     *
55
-     * @param string $surname Reference surname
56
-     * @param Tree $tree Gedcom tree
57
-     */
58
-    public function __construct($surname, Tree $tree, IndividualListService $indilist_service)
59
-    {
60
-        $this->surname = $surname;
61
-        $this->tree = $tree;
62
-        $this->indilist_service = $indilist_service;
63
-        $this->used_indis = new Collection();
64
-    }
52
+	/**
53
+	 * Constructor for Lineage Builder
54
+	 *
55
+	 * @param string $surname Reference surname
56
+	 * @param Tree $tree Gedcom tree
57
+	 */
58
+	public function __construct($surname, Tree $tree, IndividualListService $indilist_service)
59
+	{
60
+		$this->surname = $surname;
61
+		$this->tree = $tree;
62
+		$this->indilist_service = $indilist_service;
63
+		$this->used_indis = new Collection();
64
+	}
65 65
   
66
-    /**
67
-     * Build all patronymic lineages for the reference surname.
68
-     *
69
-     * @return Collection|NULL List of root patronymic lineages
70
-     */
71
-    public function buildLineages(): ?Collection
72
-    {
73
-        $indis = $this->indilist_service->individuals($this->surname, '', '', false, false, I18N::locale());
74
-        //Warning - the IndividualListService returns a clone of individuals objects. Cannot be used for object equality
75
-        if (count($indis) == 0) {
76
-            return null;
77
-        }
66
+	/**
67
+	 * Build all patronymic lineages for the reference surname.
68
+	 *
69
+	 * @return Collection|NULL List of root patronymic lineages
70
+	 */
71
+	public function buildLineages(): ?Collection
72
+	{
73
+		$indis = $this->indilist_service->individuals($this->surname, '', '', false, false, I18N::locale());
74
+		//Warning - the IndividualListService returns a clone of individuals objects. Cannot be used for object equality
75
+		if (count($indis) == 0) {
76
+			return null;
77
+		}
78 78
       
79
-        $root_lineages = new Collection();
79
+		$root_lineages = new Collection();
80 80
         
81
-        foreach ($indis as $indi) {
82
-            /** @var Individual $indi */
83
-            if (!$this->used_indis->get($indi->xref(), false)) {
84
-                $indi_first = $this->getLineageRootIndividual($indi);
85
-                if ($indi_first !== null) {
86
-                    // The root lineage needs to be recreated from the Factory, to retrieve the proper object
87
-                    $indi_first = Factory::individual()->make($indi_first->xref(), $this->tree);
88
-                }
89
-                if ($indi_first === null) {
90
-                    continue;
91
-                }
92
-                $this->used_indis->put($indi_first->xref(), true);
93
-                if ($indi_first->canShow()) {
94
-                    //Check if the root individual has brothers and sisters, without parents
95
-                    $indi_first_child_family = $indi_first->childFamilies()->first();
96
-                    if ($indi_first_child_family !== null) {
97
-                                $root_node = new LineageRootNode(null);
98
-                                $root_node->addFamily($indi_first_child_family);
99
-                    } else {
100
-                        $root_node = new LineageRootNode($indi_first);
101
-                    }
102
-                    $root_node = $this->buildLineage($root_node);
103
-                    if ($root_node !== null) {
104
-                        $root_lineages->add($root_node);
105
-                    }
106
-                }
107
-            }
108
-        }
81
+		foreach ($indis as $indi) {
82
+			/** @var Individual $indi */
83
+			if (!$this->used_indis->get($indi->xref(), false)) {
84
+				$indi_first = $this->getLineageRootIndividual($indi);
85
+				if ($indi_first !== null) {
86
+					// The root lineage needs to be recreated from the Factory, to retrieve the proper object
87
+					$indi_first = Factory::individual()->make($indi_first->xref(), $this->tree);
88
+				}
89
+				if ($indi_first === null) {
90
+					continue;
91
+				}
92
+				$this->used_indis->put($indi_first->xref(), true);
93
+				if ($indi_first->canShow()) {
94
+					//Check if the root individual has brothers and sisters, without parents
95
+					$indi_first_child_family = $indi_first->childFamilies()->first();
96
+					if ($indi_first_child_family !== null) {
97
+								$root_node = new LineageRootNode(null);
98
+								$root_node->addFamily($indi_first_child_family);
99
+					} else {
100
+						$root_node = new LineageRootNode($indi_first);
101
+					}
102
+					$root_node = $this->buildLineage($root_node);
103
+					if ($root_node !== null) {
104
+						$root_lineages->add($root_node);
105
+					}
106
+				}
107
+			}
108
+		}
109 109
       
110
-        return $root_lineages->sort(function (LineageRootNode $a, LineageRootNode $b) {
110
+		return $root_lineages->sort(function (LineageRootNode $a, LineageRootNode $b) {
111 111
 
112
-            if ($a->numberChildNodes() == $b->numberChildNodes()) {
113
-                return 0;
114
-            }
115
-            return ($a->numberChildNodes() > $b->numberChildNodes()) ? -1 : 1;
116
-        });
117
-    }
112
+			if ($a->numberChildNodes() == $b->numberChildNodes()) {
113
+				return 0;
114
+			}
115
+			return ($a->numberChildNodes() > $b->numberChildNodes()) ? -1 : 1;
116
+		});
117
+	}
118 118
  
119
-    /**
120
-     * Retrieve the root individual, from any individual, by recursion.
121
-     * The Root individual is the individual without a father, or without a mother holding the same name.
122
-     *
123
-     * @param Individual $indi
124
-     * @return Individual|NULL Root individual
125
-     */
126
-    private function getLineageRootIndividual(Individual $indi): ?Individual
127
-    {
128
-        $child_families = $indi->childFamilies();
129
-        if ($this->used_indis->get($indi->xref(), false)) {
130
-            return null;
131
-        }
119
+	/**
120
+	 * Retrieve the root individual, from any individual, by recursion.
121
+	 * The Root individual is the individual without a father, or without a mother holding the same name.
122
+	 *
123
+	 * @param Individual $indi
124
+	 * @return Individual|NULL Root individual
125
+	 */
126
+	private function getLineageRootIndividual(Individual $indi): ?Individual
127
+	{
128
+		$child_families = $indi->childFamilies();
129
+		if ($this->used_indis->get($indi->xref(), false)) {
130
+			return null;
131
+		}
132 132
         
133
-        foreach ($child_families as $child_family) {
134
-            /** @var Family $child_family */
135
-            $child_family->husband();
136
-            if ($husb = $child_family->husband()) {
137
-                if ($husb->isPendingAddition() && $husb->privatizeGedcom(Auth::PRIV_HIDE) == '') {
138
-                    return $indi;
139
-                }
140
-                return $this->getLineageRootIndividual($husb);
141
-            } elseif ($wife = $child_family->wife()) {
142
-                if (!($wife->isPendingAddition() && $wife->privatizeGedcom(Auth::PRIV_HIDE) == '')) {
143
-                    $indi_surname = $indi->getAllNames()[$indi->getPrimaryName()]['surname'];
144
-                    $wife_surname = $wife->getAllNames()[$wife->getPrimaryName()]['surname'];
145
-                    if (
146
-                        $indi->canShowName()
147
-                        && $wife->canShowName()
148
-                        && I18N::strcasecmp($indi_surname, $wife_surname) == 0
149
-                    ) {
150
-                            return $this->getLineageRootIndividual($wife);
151
-                    }
152
-                }
153
-                return $indi;
154
-            }
155
-        }
156
-        return $indi;
157
-    }
133
+		foreach ($child_families as $child_family) {
134
+			/** @var Family $child_family */
135
+			$child_family->husband();
136
+			if ($husb = $child_family->husband()) {
137
+				if ($husb->isPendingAddition() && $husb->privatizeGedcom(Auth::PRIV_HIDE) == '') {
138
+					return $indi;
139
+				}
140
+				return $this->getLineageRootIndividual($husb);
141
+			} elseif ($wife = $child_family->wife()) {
142
+				if (!($wife->isPendingAddition() && $wife->privatizeGedcom(Auth::PRIV_HIDE) == '')) {
143
+					$indi_surname = $indi->getAllNames()[$indi->getPrimaryName()]['surname'];
144
+					$wife_surname = $wife->getAllNames()[$wife->getPrimaryName()]['surname'];
145
+					if (
146
+						$indi->canShowName()
147
+						&& $wife->canShowName()
148
+						&& I18N::strcasecmp($indi_surname, $wife_surname) == 0
149
+					) {
150
+							return $this->getLineageRootIndividual($wife);
151
+					}
152
+				}
153
+				return $indi;
154
+			}
155
+		}
156
+		return $indi;
157
+	}
158 158
     
159
-    /**
160
-     * Computes descendent Lineage from a node.
161
-     * Uses recursion to build the lineage tree
162
-     *
163
-     * @param LineageNode $node
164
-     * @return LineageNode Computed lineage
165
-     */
166
-    private function buildLineage(LineageNode $node): LineageNode
167
-    {
168
-        $indi_surname = '';
159
+	/**
160
+	 * Computes descendent Lineage from a node.
161
+	 * Uses recursion to build the lineage tree
162
+	 *
163
+	 * @param LineageNode $node
164
+	 * @return LineageNode Computed lineage
165
+	 */
166
+	private function buildLineage(LineageNode $node): LineageNode
167
+	{
168
+		$indi_surname = '';
169 169
         
170
-        $indi_node = $node->individual();
171
-        if ($indi_node !== null) {
172
-            if ($node->families()->count() == 0) {
173
-                foreach ($indi_node->spouseFamilies() as $spouse_family) {
174
-                    $node->addFamily($spouse_family);
175
-                }
176
-            }
170
+		$indi_node = $node->individual();
171
+		if ($indi_node !== null) {
172
+			if ($node->families()->count() == 0) {
173
+				foreach ($indi_node->spouseFamilies() as $spouse_family) {
174
+					$node->addFamily($spouse_family);
175
+				}
176
+			}
177 177
           
178
-            $indi_surname = $indi_node->getAllNames()[$indi_node->getPrimaryName()]['surname'] ?? '';
179
-            $node->rootNode()->addPlace($indi_node->getBirthPlace());
178
+			$indi_surname = $indi_node->getAllNames()[$indi_node->getPrimaryName()]['surname'] ?? '';
179
+			$node->rootNode()->addPlace($indi_node->getBirthPlace());
180 180
                
181
-            //Tag the individual as used
182
-            $this->used_indis->put($indi_node->xref(), true);
183
-        }
181
+			//Tag the individual as used
182
+			$this->used_indis->put($indi_node->xref(), true);
183
+		}
184 184
       
185
-        foreach ($node->families() as $family_node) {
186
-            /** @var Family $spouse_family */
187
-            $spouse_family = $family_node->family;
188
-            $spouse_surname = '';
189
-            $spouse = null;
190
-            if ($indi_node !== null && ($spouse = $spouse_family->spouse($indi_node)) && $spouse->canShowName()) {
191
-                $spouse_surname = $spouse->getAllNames()[$spouse->getPrimaryName()]['surname'] ?? '';
192
-            }
185
+		foreach ($node->families() as $family_node) {
186
+			/** @var Family $spouse_family */
187
+			$spouse_family = $family_node->family;
188
+			$spouse_surname = '';
189
+			$spouse = null;
190
+			if ($indi_node !== null && ($spouse = $spouse_family->spouse($indi_node)) && $spouse->canShowName()) {
191
+				$spouse_surname = $spouse->getAllNames()[$spouse->getPrimaryName()]['surname'] ?? '';
192
+			}
193 193
            
194
-            $nb_children = $nb_natural = 0;
194
+			$nb_children = $nb_natural = 0;
195 195
            
196
-            foreach ($spouse_family->children() as $child) {
197
-                if (!($child->isPendingAddition() && $child->privatizeGedcom(Auth::PRIV_HIDE) == '')) {
198
-                    $child_surname = $child->getAllNames()[$child->getPrimaryName()]['surname'] ?? '';
196
+			foreach ($spouse_family->children() as $child) {
197
+				if (!($child->isPendingAddition() && $child->privatizeGedcom(Auth::PRIV_HIDE) == '')) {
198
+					$child_surname = $child->getAllNames()[$child->getPrimaryName()]['surname'] ?? '';
199 199
                     
200
-                    $nb_children++;
201
-                    if ($indi_node !== null && $indi_node->sex() == 'F') { //If the root individual is the mother
202
-                        //Print only lineages of children with the same surname as their mother
203
-                        //(supposing they are natural children)
204
-                        if (!$spouse || ($spouse_surname && I18N::strcasecmp($child_surname, $spouse_surname) != 0)) {
205
-                            if (I18N::strcasecmp($child_surname, $indi_surname) == 0) {
206
-                                $nb_natural++;
207
-                                $node_child = new LineageNode($child, $node->rootNode());
208
-                                $node_child = $this->buildLineage($node_child);
209
-                                $node->addChild($spouse_family, $node_child);
210
-                            }
211
-                        }
212
-                    } else { //If the root individual is the father
213
-                        $nb_natural++;
214
-                        //Print if the children does not bear the same name as his mother
215
-                        //(and different from his father)
216
-                        if (
217
-                            mb_strlen($child_surname) == 0 ||
218
-                            mb_strlen($indi_surname) == 0 || mb_strlen($spouse_surname) == 0 ||
219
-                            I18N::strcasecmp($child_surname, $indi_surname) == 0 ||
220
-                            I18N::strcasecmp($child_surname, $spouse_surname) != 0
221
-                        ) {
222
-                            $node_child = new LineageNode($child, $node->rootNode());
223
-                            $node_child = $this->buildLineage($node_child);
224
-                        } else {
225
-                            $node_child = new LineageNode($child, $node->rootNode(), $child_surname);
226
-                        }
227
-                        $node->addChild($spouse_family, $node_child);
228
-                    }
229
-                }
230
-            }
200
+					$nb_children++;
201
+					if ($indi_node !== null && $indi_node->sex() == 'F') { //If the root individual is the mother
202
+						//Print only lineages of children with the same surname as their mother
203
+						//(supposing they are natural children)
204
+						if (!$spouse || ($spouse_surname && I18N::strcasecmp($child_surname, $spouse_surname) != 0)) {
205
+							if (I18N::strcasecmp($child_surname, $indi_surname) == 0) {
206
+								$nb_natural++;
207
+								$node_child = new LineageNode($child, $node->rootNode());
208
+								$node_child = $this->buildLineage($node_child);
209
+								$node->addChild($spouse_family, $node_child);
210
+							}
211
+						}
212
+					} else { //If the root individual is the father
213
+						$nb_natural++;
214
+						//Print if the children does not bear the same name as his mother
215
+						//(and different from his father)
216
+						if (
217
+							mb_strlen($child_surname) == 0 ||
218
+							mb_strlen($indi_surname) == 0 || mb_strlen($spouse_surname) == 0 ||
219
+							I18N::strcasecmp($child_surname, $indi_surname) == 0 ||
220
+							I18N::strcasecmp($child_surname, $spouse_surname) != 0
221
+						) {
222
+							$node_child = new LineageNode($child, $node->rootNode());
223
+							$node_child = $this->buildLineage($node_child);
224
+						} else {
225
+							$node_child = new LineageNode($child, $node->rootNode(), $child_surname);
226
+						}
227
+						$node->addChild($spouse_family, $node_child);
228
+					}
229
+				}
230
+			}
231 231
             
232
-            //Do not print other children
233
-            if (($nb_children - $nb_natural) > 0) {
234
-                $node->addChild($spouse_family, null);
235
-            }
236
-        }
232
+			//Do not print other children
233
+			if (($nb_children - $nb_natural) > 0) {
234
+				$node->addChild($spouse_family, null);
235
+			}
236
+		}
237 237
        
238
-        return $node;
239
-    }
238
+		return $node;
239
+	}
240 240
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
             }
108 108
         }
109 109
       
110
-        return $root_lineages->sort(function (LineageRootNode $a, LineageRootNode $b) {
110
+        return $root_lineages->sort(function(LineageRootNode $a, LineageRootNode $b) {
111 111
 
112 112
             if ($a->numberChildNodes() == $b->numberChildNodes()) {
113 113
                 return 0;
Please login to merge, or discard this patch.