Completed
Push — feature/code-analysis ( c314d5...820b23 )
by Jonathan
02:56
created
src/Webtrees/Hook/HookProviderInterface.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -16,51 +16,51 @@
 block discarded – undo
16 16
  */
17 17
 interface HookProviderInterface {
18 18
 
19
-    /**
20
-     * Return an instance of the hook linked to the specifed function / context
21
-     *
22
-     * @param string $hook_function
23
-     * @param string $hook_context
24
-     * @return Hook
25
-     */
26
-    public function get($hook_function, $hook_context = null);
19
+	/**
20
+	 * Return an instance of the hook linked to the specifed function / context
21
+	 *
22
+	 * @param string $hook_function
23
+	 * @param string $hook_context
24
+	 * @return Hook
25
+	 */
26
+	public function get($hook_function, $hook_context = null);
27 27
     
28
-    /**
29
-     * Return whether the Hook module is active and the table has been created.
30
-     *
31
-     * @uses \MyArtJaub\Webtrees\Module\ModuleManager to check if the module is operational
32
-     * @return bool True if module active and table created, false otherwise
33
-     */
34
-    public function isModuleOperational();
28
+	/**
29
+	 * Return whether the Hook module is active and the table has been created.
30
+	 *
31
+	 * @uses \MyArtJaub\Webtrees\Module\ModuleManager to check if the module is operational
32
+	 * @return bool True if module active and table created, false otherwise
33
+	 */
34
+	public function isModuleOperational();
35 35
     
36
-    /**
37
-     * Get the list of possible hooks in the list of modules files.
38
-     * A hook will be registered:
39
-     * 		- for all modules already registered in Webtrees
40
-     * 		- if the module implements HookSubscriberInterface
41
-     * 		- if the method exist within the module
42
-     *
43
-     * @return Array List of possible hooks, with the priority
44
-     */
45
-    public function getPossibleHooks();
36
+	/**
37
+	 * Get the list of possible hooks in the list of modules files.
38
+	 * A hook will be registered:
39
+	 * 		- for all modules already registered in Webtrees
40
+	 * 		- if the module implements HookSubscriberInterface
41
+	 * 		- if the method exist within the module
42
+	 *
43
+	 * @return Array List of possible hooks, with the priority
44
+	 */
45
+	public function getPossibleHooks();
46 46
     
47
-    /**
48
-     * Get the list of hooks intalled in webtrees, with their id, status and priority.
49
-     *
50
-     * @return array List of installed hooks
51
-     */
52
-    public function getRawInstalledHooks();
47
+	/**
48
+	 * Get the list of hooks intalled in webtrees, with their id, status and priority.
49
+	 *
50
+	 * @return array List of installed hooks
51
+	 */
52
+	public function getRawInstalledHooks();
53 53
     
54
-    /**
55
-     * Get the list of hooks intalled in webtrees, with their id, status and priority.
56
-     *
57
-     * @return Array List of installed hooks, with id, status and priority
58
-     */
59
-    public function getInstalledHooks();
54
+	/**
55
+	 * Get the list of hooks intalled in webtrees, with their id, status and priority.
56
+	 *
57
+	 * @return Array List of installed hooks, with id, status and priority
58
+	 */
59
+	public function getInstalledHooks();
60 60
     
61
-    /**
62
-     * Update the list of hooks, identifying missing ones and removed ones.
63
-     */
64
-    public function updateHooks();
61
+	/**
62
+	 * Update the list of hooks, identifying missing ones and removed ones.
63
+	 */
64
+	public function updateHooks();
65 65
     
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Controller/IndividualController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param \Fisharebest\Webtrees\Controller\IndividualController $ctrl_individual_in The Individual Controller to extend
34 34
 	 */
35
-	public function __construct(fw\Controller\IndividualController $ctrl_individual_in){
35
+	public function __construct(fw\Controller\IndividualController $ctrl_individual_in) {
36 36
 		$this->ctrl_individual = $ctrl_individual_in;
37 37
 		$this->dindi = new mw\Individual($this->ctrl_individual->getSignificantIndividual());
38 38
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * 
44 44
 	 * @uses \MyArtJaub\Webtrees\Hook\Hook
45 45
 	 */
46
-	public function printHeaderExtensions(){
46
+	public function printHeaderExtensions() {
47 47
 		$hook_extend_indi_header_left = new mw\Hook\Hook('hExtendIndiHeaderLeft');
48 48
 		$hook_extend_indi_header_right = new mw\Hook\Hook('hExtendIndiHeaderRight');
49 49
 		$hook_extend_indi_header_left = $hook_extend_indi_header_left->execute($this->ctrl_individual);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		echo '<div id="indi_perso_header">',
53 53
 			'<div id="indi_perso_header_left">';
54 54
 		foreach ($hook_extend_indi_header_left as $div) {
55
-			if(count($div)==2){
55
+			if (count($div) == 2) {
56 56
 				echo '<div id="', $div[0], '" class="indi_perso_header_left_div">',
57 57
 					$div[1], '</div>';
58 58
 			}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		echo '</div>',
61 61
 			'<div id="indi_perso_header_right">';
62 62
 		foreach ($hook_extend_indi_header_right as $div) {
63
-			if(count($div)==2){
63
+			if (count($div) == 2) {
64 64
 				echo '<div id="', $div[0], '" class="indi_perso_header_right_div">',
65 65
 					$div[1], '</div>';
66 66
 			}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @uses \MyArtJaub\Webtrees\Hook\Hook
77 77
 	 */
78
-	public function printHeaderExtraIcons(){
78
+	public function printHeaderExtraIcons() {
79 79
 		$hook_extend_indi_header_icons = new Hook('hExtendIndiHeaderIcons');
80 80
 		$hook_extend_indi_header_icons = $hook_extend_indi_header_icons->execute($this->ctrl_individual);
81 81
 		
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Schema/Migration0.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@
 block discarded – undo
24 24
 	 */
25 25
 	public function upgrade() {
26 26
 		Database::exec(
27
-		    'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('.
28
-		    ' majat_name 		    VARCHAR(32)                      NOT NULL,'.
29
-		    ' majat_status          ENUM(\'enabled\',\'disabled\') 	 NOT NULL DEFAULT \'disabled\','.
30
-		    ' majat_last_run 		DATETIME 					     NOT NULL DEFAULT \'2000-01-01 00:00:00\','.
31
-		    ' majat_last_result 	TINYINT(1)					     NOT NULL DEFAULT 1,'.		// 0 means error, 1 is success
32
-		    ' majat_frequency		INTEGER						     NOT NULL DEFAULT 10080,'.	// In min, Default every week
33
-		    ' majat_nb_occur	 	SMALLINT					     NOT NULL DEFAULT 0,'.
34
-		    ' majat_running 		TINYINT(1)					     NOT NULL DEFAULT 0,'.
35
-		    ' PRIMARY KEY (majat_name)'.
36
-		    ') COLLATE utf8_unicode_ci ENGINE=InnoDB'
27
+			'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('.
28
+			' majat_name 		    VARCHAR(32)                      NOT NULL,'.
29
+			' majat_status          ENUM(\'enabled\',\'disabled\') 	 NOT NULL DEFAULT \'disabled\','.
30
+			' majat_last_run 		DATETIME 					     NOT NULL DEFAULT \'2000-01-01 00:00:00\','.
31
+			' majat_last_result 	TINYINT(1)					     NOT NULL DEFAULT 1,'.		// 0 means error, 1 is success
32
+			' majat_frequency		INTEGER						     NOT NULL DEFAULT 10080,'.	// In min, Default every week
33
+			' majat_nb_occur	 	SMALLINT					     NOT NULL DEFAULT 0,'.
34
+			' majat_running 		TINYINT(1)					     NOT NULL DEFAULT 0,'.
35
+			' PRIMARY KEY (majat_name)'.
36
+			') COLLATE utf8_unicode_ci ENGINE=InnoDB'
37 37
 		);
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@
 block discarded – undo
28 28
 		    ' majat_name 		    VARCHAR(32)                      NOT NULL,'.
29 29
 		    ' majat_status          ENUM(\'enabled\',\'disabled\') 	 NOT NULL DEFAULT \'disabled\','.
30 30
 		    ' majat_last_run 		DATETIME 					     NOT NULL DEFAULT \'2000-01-01 00:00:00\','.
31
-		    ' majat_last_result 	TINYINT(1)					     NOT NULL DEFAULT 1,'.		// 0 means error, 1 is success
32
-		    ' majat_frequency		INTEGER						     NOT NULL DEFAULT 10080,'.	// In min, Default every week
31
+		    ' majat_last_result 	TINYINT(1)					     NOT NULL DEFAULT 1,'.// 0 means error, 1 is success
32
+		    ' majat_frequency		INTEGER						     NOT NULL DEFAULT 10080,'.// In min, Default every week
33 33
 		    ' majat_nb_occur	 	SMALLINT					     NOT NULL DEFAULT 0,'.
34 34
 		    ' majat_running 		TINYINT(1)					     NOT NULL DEFAULT 0,'.
35 35
 		    ' PRIMARY KEY (majat_name)'.
Please login to merge, or discard this patch.
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php 4 patches
Indentation   +327 added lines, -327 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,236 +217,236 @@  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>)
345
-     *      - hierarchy: an array of the place hierarchy (in reverse order of the gedcom)
346
-     *      
347
-     * @return array
348
-     */
349
-    public function getPlacesHierarchy() {
350
-        if(!$this->place_hierarchy) {
351
-            if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352
-                $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
-            }
354
-            else {
355
-                $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData());
356
-            }            
357
-        }
358
-        return $this->place_hierarchy;        
359
-    }
340
+	/**
341
+	 * Returns the infered place hierarchy, determined from the Gedcom data.
342
+	 * Depending on the data, it can be based on the Gedcom Header description, or from a place example.
343
+	 * This is returned as an associative array:
344
+	 *      - type:    describe the source of the data (<em>header<em> / <em>data</em>)
345
+	 *      - hierarchy: an array of the place hierarchy (in reverse order of the gedcom)
346
+	 *      
347
+	 * @return array
348
+	 */
349
+	public function getPlacesHierarchy() {
350
+		if(!$this->place_hierarchy) {
351
+			if($place_structure = $this->getPlacesHierarchyFromHeader()) {
352
+				$this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure);
353
+			}
354
+			else {
355
+				$this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData());
356
+			}            
357
+		}
358
+		return $this->place_hierarchy;        
359
+	}
360 360
     
361
-    /**
362
-     * Returns an array of the place hierarchy, as defined in the GEDCOM header.
363
-     * The places are reversed compared to normal GEDCOM structure.
364
-     * 
365
-     * @return array|null
366
-     */
367
-    protected function getPlacesHierarchyFromHeader() {
368
-        $head = GedcomRecord::getInstance('HEAD', $this->tree);
369
-        $head_place = $head->getFirstFact('PLAC');
370
-        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
371
-            return array_reverse(array_map('trim',explode(',', $head_place_value)));
372
-        }
373
-        return null;
374
-    }
361
+	/**
362
+	 * Returns an array of the place hierarchy, as defined in the GEDCOM header.
363
+	 * The places are reversed compared to normal GEDCOM structure.
364
+	 * 
365
+	 * @return array|null
366
+	 */
367
+	protected function getPlacesHierarchyFromHeader() {
368
+		$head = GedcomRecord::getInstance('HEAD', $this->tree);
369
+		$head_place = $head->getFirstFact('PLAC');
370
+		if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
371
+			return array_reverse(array_map('trim',explode(',', $head_place_value)));
372
+		}
373
+		return null;
374
+	}
375 375
     
376
-    /**
377
-     * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
378
-     * It will look for the longest hierarchy in the tree.
379
-     * The places are reversed compared to normal GEDCOM structure.
380
-     * 
381
-     * @return array
382
-     */
383
-    protected function getPlacesHierarchyFromData() {
384
-        $nb_levels = 0;
376
+	/**
377
+	 * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM.
378
+	 * It will look for the longest hierarchy in the tree.
379
+	 * The places are reversed compared to normal GEDCOM structure.
380
+	 * 
381
+	 * @return array
382
+	 */
383
+	protected function getPlacesHierarchyFromData() {
384
+		$nb_levels = 0;
385 385
         
386
-        //Select all '2 PLAC ' tags in the file and create array
387
-        $places_list=array();
388
-        $ged_data = Database::prepare(
389
-            'SELECT i_gedcom AS gedcom'.
390
-            ' FROM `##individuals`'.
391
-            ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
392
-            ' UNION ALL'.
393
-            'SELECT f_gedcom AS gedcom'.
394
-            ' FROM `##families`'.
395
-            ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
396
-        )->execute(array(
397
-            'gedcom' => '%\n2 PLAC %',
398
-            'gedcom_id' => $this->tree->getTreeId()            
399
-        ))->fetchOneColumn();
400
-        foreach ($ged_data as $ged_datum) {
401
-            $matches = null;
402
-            preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
403
-            foreach ($matches[1] as $match) {
404
-                $places_list[$match]=true;
405
-            }
406
-        }
386
+		//Select all '2 PLAC ' tags in the file and create array
387
+		$places_list=array();
388
+		$ged_data = Database::prepare(
389
+			'SELECT i_gedcom AS gedcom'.
390
+			' FROM `##individuals`'.
391
+			' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'.
392
+			' UNION ALL'.
393
+			'SELECT f_gedcom AS gedcom'.
394
+			' FROM `##families`'.
395
+			' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'
396
+		)->execute(array(
397
+			'gedcom' => '%\n2 PLAC %',
398
+			'gedcom_id' => $this->tree->getTreeId()            
399
+		))->fetchOneColumn();
400
+		foreach ($ged_data as $ged_datum) {
401
+			$matches = null;
402
+			preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
403
+			foreach ($matches[1] as $match) {
404
+				$places_list[$match]=true;
405
+			}
406
+		}
407 407
         
408
-        // Unique list of places
409
-        $places_list=array_keys($places_list);
408
+		// Unique list of places
409
+		$places_list=array_keys($places_list);
410 410
         
411
-        //sort the array, limit to unique values, and count them
412
-        usort($places_list, array('I18N', 'strcasecmp'));
411
+		//sort the array, limit to unique values, and count them
412
+		usort($places_list, array('I18N', 'strcasecmp'));
413 413
         
414
-        //calculate maximum no. of levels to display
415
-        $has_found_good_example = false;
416
-        foreach($places_list as $place){
417
-            $levels = explode(",", $place);
418
-            $parts = count($levels);
419
-            if ($parts >= $nb_levels){
420
-                $nb_levels = $parts;
421
-                if(!$has_found_good_example){
422
-                    $random_place = $place;
423
-                    if(min(array_map('strlen', $levels)) > 0){
424
-                        $has_found_good_example = true;
425
-                    }
426
-                }
427
-            }
428
-        }
414
+		//calculate maximum no. of levels to display
415
+		$has_found_good_example = false;
416
+		foreach($places_list as $place){
417
+			$levels = explode(",", $place);
418
+			$parts = count($levels);
419
+			if ($parts >= $nb_levels){
420
+				$nb_levels = $parts;
421
+				if(!$has_found_good_example){
422
+					$random_place = $place;
423
+					if(min(array_map('strlen', $levels)) > 0){
424
+						$has_found_good_example = true;
425
+					}
426
+				}
427
+			}
428
+		}
429 429
         
430
-        return array_reverse(array_map('trim',explode(',', $random_place)));
431
-    }
430
+		return array_reverse(array_map('trim',explode(',', $random_place)));
431
+	}
432 432
     
433
-    /**
434
-     * Returns the list of geodispersion maps available within the maps folder.
435
-     * 
436
-     * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
437
-     */
438
-    public function getOutlineMapsList() {
439
-        $res = array();
440
-        $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
441
-        if(is_dir($root_path)){
442
-            $dir = opendir($root_path);
443
-            while (($file=readdir($dir))!== false) {
444
-                if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
445
-                    $res[base64_encode($file)] = new OutlineMap($file, true);
446
-                }
447
-            }
448
-        }
449
-        return $res;
450
-    }
433
+	/**
434
+	 * Returns the list of geodispersion maps available within the maps folder.
435
+	 * 
436
+	 * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
437
+	 */
438
+	public function getOutlineMapsList() {
439
+		$res = array();
440
+		$root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
441
+		if(is_dir($root_path)){
442
+			$dir = opendir($root_path);
443
+			while (($file=readdir($dir))!== false) {
444
+				if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
445
+					$res[base64_encode($file)] = new OutlineMap($file, true);
446
+				}
447
+			}
448
+		}
449
+		return $res;
450
+	}
451 451
 }
452 452
  
453 453
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 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,8 +347,8 @@  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 354
             else {
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
     protected function getPlacesHierarchyFromHeader() {
368 368
         $head = GedcomRecord::getInstance('HEAD', $this->tree);
369 369
         $head_place = $head->getFirstFact('PLAC');
370
-        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
371
-            return array_reverse(array_map('trim',explode(',', $head_place_value)));
370
+        if ($head_place && $head_place_value = $head_place->getAttribute('FORM')) {
371
+            return array_reverse(array_map('trim', explode(',', $head_place_value)));
372 372
         }
373 373
         return null;
374 374
     }
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
         $nb_levels = 0;
385 385
         
386 386
         //Select all '2 PLAC ' tags in the file and create array
387
-        $places_list=array();
387
+        $places_list = array();
388 388
         $ged_data = Database::prepare(
389 389
             'SELECT i_gedcom AS gedcom'.
390 390
             ' FROM `##individuals`'.
@@ -401,33 +401,33 @@  discard block
 block discarded – undo
401 401
             $matches = null;
402 402
             preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches);
403 403
             foreach ($matches[1] as $match) {
404
-                $places_list[$match]=true;
404
+                $places_list[$match] = true;
405 405
             }
406 406
         }
407 407
         
408 408
         // Unique list of places
409
-        $places_list=array_keys($places_list);
409
+        $places_list = array_keys($places_list);
410 410
         
411 411
         //sort the array, limit to unique values, and count them
412 412
         usort($places_list, array('I18N', 'strcasecmp'));
413 413
         
414 414
         //calculate maximum no. of levels to display
415 415
         $has_found_good_example = false;
416
-        foreach($places_list as $place){
416
+        foreach ($places_list as $place) {
417 417
             $levels = explode(",", $place);
418 418
             $parts = count($levels);
419
-            if ($parts >= $nb_levels){
419
+            if ($parts >= $nb_levels) {
420 420
                 $nb_levels = $parts;
421
-                if(!$has_found_good_example){
421
+                if (!$has_found_good_example) {
422 422
                     $random_place = $place;
423
-                    if(min(array_map('strlen', $levels)) > 0){
423
+                    if (min(array_map('strlen', $levels)) > 0) {
424 424
                         $has_found_good_example = true;
425 425
                     }
426 426
                 }
427 427
             }
428 428
         }
429 429
         
430
-        return array_reverse(array_map('trim',explode(',', $random_place)));
430
+        return array_reverse(array_map('trim', explode(',', $random_place)));
431 431
     }
432 432
     
433 433
     /**
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
     public function getOutlineMapsList() {
439 439
         $res = array();
440 440
         $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/';
441
-        if(is_dir($root_path)){
441
+        if (is_dir($root_path)) {
442 442
             $dir = opendir($root_path);
443
-            while (($file=readdir($dir))!== false) {
443
+            while (($file = readdir($dir)) !== false) {
444 444
                 if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) {
445 445
                     $res[base64_encode($file)] = new OutlineMap($file, true);
446 446
                 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
     /**
90 90
      * Returns the number of geographical analysis (active and inactive). 
91 91
      * 
92
-     * @return int
92
+     * @return string|null
93 93
      */
94 94
     public function getGeoAnalysisCount() {
95 95
         return Database::prepare(
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 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,8 +348,7 @@  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
-            else {
351
+            } else {
355 352
                 $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData());
356 353
             }            
357 354
         }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Views/SosaStatsView.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 			<?php 
31 31
 			/** @var \Fisharebest\Webtrees\Individual $root_indi */
32 32
 			$root_indi = $this->data->get('root_indi');
33
-			if($root_indi !== null && $root_indi->canShowName()) { ?>
33
+			if ($root_indi !== null && $root_indi->canShowName()) { ?>
34 34
 			<h4 class="center"><?= I18N::translate('%s: %s', I18N::translate('Root individual'), $root_indi->getFullName()); ?><h4>
35 35
 			<?php } ?>
36 36
 			
37
-			<?php  if($this->data->get('is_setup')) {  
37
+			<?php  if ($this->data->get('is_setup')) {  
38 38
 			    $general_stats = $this->data->get('general_stats'); ?>
39 39
 			<h3><?php echo I18N::translate('General statistics'); ?></h3>
40 40
 			<div class="maj-table">
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 				</div>
57 57
 				<div class="maj-row">
58 58
 					<div class="label"><?php echo I18N::translate('Mean generation time'); ?></div>
59
-					<div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'],  I18N::number($general_stats['mean_gen_time'], 1)); ?></div>
59
+					<div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1)); ?></div>
60 60
 				</div>
61 61
 			</div>
62 62
 			
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 					</tr>
97 97
 				</thead>
98 98
 				<tbody>
99
-					<?php foreach($this->data->get('generation_stats') as $gen => $row) { ?>
99
+					<?php foreach ($this->data->get('generation_stats') as $gen => $row) { ?>
100 100
 					<tr class="maj-row">
101 101
 						<td class="label"><?php echo I18N::translate('<strong>G%d</strong>', $gen); ?></td>
102 102
 						<td class="label"><?php echo I18N::translate('%1$s <> %2$s', $row['gen_min_birth'], $row['gen_max_birth']); ?></td>
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 						<td class="value"><?php echo I18N::number($row['different']); ?></td>
111 111
 						<td class="value left percent_container">
112 112
 							<div class="percent_frame">
113
-								<div class="percent_cell" style="width:<?php echo 100*$row['perc_different'] ?>%;">
113
+								<div class="percent_cell" style="width:<?php echo 100 * $row['perc_different'] ?>%;">
114 114
 									&nbsp;<?php echo I18N::percentage($row['perc_different']); ?>&nbsp;
115 115
 								</div>
116 116
 							</div>
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 				<tfoot>
124 124
 					<tr class="maj-row">
125 125
 						<td class="label" colspan="13">
126
-							<?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'),2)); ?>
126
+							<?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'), 2)); ?>
127 127
 						</td>
128 128
 					</tr>
129 129
 				</tfoot>
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 			
133 133
 			<h3><?php echo I18N::translate('Known Sosa ancestors\' family dispersion'); ?></h3>
134 134
 			<div class="center">
135
-				<?php echo $this->data->get('chart_img_g2') ?: '' ; ?>
136
-				<?php echo $this->data->get('chart_img_g3') ?: '' ; ?>				
135
+				<?php echo $this->data->get('chart_img_g2') ?: ''; ?>
136
+				<?php echo $this->data->get('chart_img_g3') ?: ''; ?>				
137 137
 				<!--  <canvas id="chart_ancestors_g2" width="300" height="300"></canvas>  -->
138 138
 			</div>
139 139
 			
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	 * {@inhericDoc}
23 23
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
24 24
 	 */
25
-    protected function renderContent() {      
26
-        ?>                
25
+	protected function renderContent() {      
26
+		?>                
27 27
         <div id="maj-sosa-stats-page">
28 28
 			<h2><?php echo $this->data->get('title'); ?></h2>
29 29
 			
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 			<?php } ?>
36 36
 			
37 37
 			<?php  if($this->data->get('is_setup')) {  
38
-			    $general_stats = $this->data->get('general_stats'); ?>
38
+				$general_stats = $this->data->get('general_stats'); ?>
39 39
 			<h3><?php echo I18N::translate('General statistics'); ?></h3>
40 40
 			<div class="maj-table">
41 41
 				<div class="maj-row">
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 			<?php   } else { ?>
141 141
 			<div class="center warning"><?php echo I18N::translate('No Sosa root individual has been defined.'); ?></div>
142 142
 			<?php }     
143
-    }
143
+	}
144 144
     
145 145
 }
146 146
  
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Functions/Functions.php 3 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param string $text Text to display
40 40
 	 */
41
-	static public function promptAlert($text){
41
+	static public function promptAlert($text) {
42 42
 		echo '<script>';
43
-		echo 'alert("',fw\Filter::escapeHtml($text),'")';
43
+		echo 'alert("', fw\Filter::escapeHtml($text), '")';
44 44
 		echo '</script>';
45 45
 	}
46 46
 	
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return float Result of the safe division
54 54
 	 */
55 55
 	public static function safeDivision($num, $denom, $default = 0) {
56
-		if($denom && $denom!=0){
56
+		if ($denom && $denom != 0) {
57 57
 			return $num / $denom;
58 58
 		}
59 59
 		return $default;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param float $default Default value if denominator null or 0
68 68
 	 * @return float Percentage
69 69
 	 */
70
-	public static function getPercentage($num, $denom, $default = 0){
70
+	public static function getPercentage($num, $denom, $default = 0) {
71 71
 		return 100 * self::safeDivision($num, $denom, $default);
72 72
 	}
73 73
 	
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param int $target	The final max width/height
79 79
 	 * @return array array of ($width, $height). One of them must be $target
80 80
 	 */
81
-	static public function getResizedImageSize($file, $target=25){
82
-		list($width, $height, , ) = getimagesize($file);
81
+	static public function getResizedImageSize($file, $target = 25) {
82
+		list($width, $height,,) = getimagesize($file);
83 83
 		$max = max($width, $height);
84 84
 		$rapp = $target / $max;
85 85
 		$width = intval($rapp * $width);
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 	 * @param int $length Length of the token, default to 32
110 110
 	 * @return string Random token
111 111
 	 */
112
-	public static function generateRandomToken($length=32) {
112
+	public static function generateRandomToken($length = 32) {
113 113
 		$chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
114 114
 		$len_chars = count($chars);
115 115
 		$token = '';
116 116
 		
117 117
 		for ($i = 0; $i < $length; $i++)
118
-			$token .= $chars[ mt_rand(0, $len_chars - 1) ];
118
+			$token .= $chars[mt_rand(0, $len_chars - 1)];
119 119
 		
120 120
 		# Number of 32 char chunks
121
-		$chunks = ceil( strlen($token) / 32 );
121
+		$chunks = ceil(strlen($token) / 32);
122 122
 		$md5token = '';
123 123
 		
124 124
 		# Run each chunk through md5
125
-		for ( $i=1; $i<=$chunks; $i++ )
126
-			$md5token .= md5( substr($token, $i * 32 - 32, 32) );
125
+		for ($i = 1; $i <= $chunks; $i++)
126
+			$md5token .= md5(substr($token, $i * 32 - 32, 32));
127 127
 		
128 128
 			# Trim the token
129 129
 		return substr($md5token, 0, $length);		
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 	 * @param string $data Text to encrypt
146 146
 	 * @return string Encrypted and encoded text
147 147
 	 */
148
-	public static function encryptToSafeBase64($data){
149
-	    if(!self::isEncryptionCompatible())
148
+	public static function encryptToSafeBase64($data) {
149
+	    if (!self::isEncryptionCompatible())
150 150
 	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
151 151
 	    
152 152
 		$key = 'STANDARDKEYIFNOSERVER';
153
-		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
153
+		if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
154 154
 			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
155 155
 		$iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND);
156
-		$id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv);
156
+		$id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv);
157 157
 		$encrypted = base64_encode($iv.$id);
158 158
 		// +, / and = are not URL-compatible
159 159
 		$encrypted = str_replace('+', '-', $encrypted);
@@ -168,25 +168,25 @@  discard block
 block discarded – undo
168 168
 	 * @param string $encrypted Text to decrypt
169 169
 	 * @return string Decrypted text
170 170
 	 */
171
-	public static function decryptFromSafeBase64($encrypted){
172
-	    if(!self::isEncryptionCompatible())
171
+	public static function decryptFromSafeBase64($encrypted) {
172
+	    if (!self::isEncryptionCompatible())
173 173
 	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
174 174
 	    
175 175
 		$key = 'STANDARDKEYIFNOSERVER';
176
-		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
176
+		if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
177 177
 			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
178 178
 		$encrypted = str_replace('-', '+', $encrypted);
179 179
 		$encrypted = str_replace('_', '/', $encrypted);
180 180
 		$encrypted = str_replace('*', '=', $encrypted);
181 181
 		$encrypted = base64_decode($encrypted);
182
-		if(!$encrypted)
182
+		if (!$encrypted)
183 183
 			throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.');
184
-		if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) 
184
+		if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) 
185 185
 			throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.');
186 186
 		$iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE);
187 187
 		$encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE);
188 188
 		$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec);
189
-		return  preg_replace('~(?:\\000+)$~','',$decrypted);
189
+		return  preg_replace('~(?:\\000+)$~', '', $decrypted);
190 190
 	}
191 191
 	
192 192
 	/**
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	 * @param string $string Filesystem encoded string to encode
196 196
 	 * @return string UTF-8 encoded string
197 197
 	 */
198
-	public static function encodeFileSystemToUtf8($string){
198
+	public static function encodeFileSystemToUtf8($string) {
199 199
 		if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') {
200
-		    return iconv('cp1252', 'utf-8//IGNORE',$string);
200
+		    return iconv('cp1252', 'utf-8//IGNORE', $string);
201 201
 		}
202 202
 		return $string;
203 203
 	}
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 	 * @param string $string UTF-8 encoded string to encode
209 209
 	 * @return string Filesystem encoded string
210 210
 	 */
211
-	public static function encodeUtf8ToFileSystem($string){
211
+	public static function encodeUtf8ToFileSystem($string) {
212 212
 		if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') {
213
-			return iconv('utf-8', 'cp1252//IGNORE' ,  $string);
213
+			return iconv('utf-8', 'cp1252//IGNORE', $string);
214 214
 		}
215 215
 		return $string;
216 216
 	}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @return boolean True if path valid
224 224
 	 */
225 225
 	public static function isValidPath($filename, $acceptfolder = FALSE) {		
226
-		if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true;
226
+		if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true;
227 227
 		return false;
228 228
 	}
229 229
 	
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @return array Array of month short names
236 236
 	 */
237 237
 	public static function getCalendarShortMonths($calendarId = 0) {
238
-		if(!isset(self::$calendarShortMonths[$calendarId])) {
238
+		if (!isset(self::$calendarShortMonths[$calendarId])) {
239 239
 			$calendar_info = cal_info($calendarId);
240 240
 			self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths'];
241 241
 		}		
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param int $sosa Sosa number
249 249
 	 * @return number
250 250
 	 */
251
-	public static function getGeneration($sosa){
252
-		return(int)log($sosa, 2)+1;
251
+	public static function getGeneration($sosa) {
252
+		return(int)log($sosa, 2) + 1;
253 253
 	}
254 254
 	
255 255
 	
Please login to merge, or discard this patch.
Braces   +27 added lines, -17 removed lines patch added patch discarded remove patch
@@ -114,16 +114,18 @@  discard block
 block discarded – undo
114 114
 		$len_chars = count($chars);
115 115
 		$token = '';
116 116
 		
117
-		for ($i = 0; $i < $length; $i++)
118
-			$token .= $chars[ mt_rand(0, $len_chars - 1) ];
117
+		for ($i = 0; $i < $length; $i++) {
118
+					$token .= $chars[ mt_rand(0, $len_chars - 1) ];
119
+		}
119 120
 		
120 121
 		# Number of 32 char chunks
121 122
 		$chunks = ceil( strlen($token) / 32 );
122 123
 		$md5token = '';
123 124
 		
124 125
 		# Run each chunk through md5
125
-		for ( $i=1; $i<=$chunks; $i++ )
126
-			$md5token .= md5( substr($token, $i * 32 - 32, 32) );
126
+		for ( $i=1; $i<=$chunks; $i++ ) {
127
+					$md5token .= md5( substr($token, $i * 32 - 32, 32) );
128
+		}
127 129
 		
128 130
 			# Trim the token
129 131
 		return substr($md5token, 0, $length);		
@@ -146,12 +148,14 @@  discard block
 block discarded – undo
146 148
 	 * @return string Encrypted and encoded text
147 149
 	 */
148 150
 	public static function encryptToSafeBase64($data){
149
-	    if(!self::isEncryptionCompatible())
150
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
151
+	    if(!self::isEncryptionCompatible()) {
152
+	    	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
153
+	    }
151 154
 	    
152 155
 		$key = 'STANDARDKEYIFNOSERVER';
153
-		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
154
-			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
156
+		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) {
157
+					$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
158
+		}
155 159
 		$iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND);
156 160
 		$id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv);
157 161
 		$encrypted = base64_encode($iv.$id);
@@ -169,20 +173,24 @@  discard block
 block discarded – undo
169 173
 	 * @return string Decrypted text
170 174
 	 */
171 175
 	public static function decryptFromSafeBase64($encrypted){
172
-	    if(!self::isEncryptionCompatible())
173
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
176
+	    if(!self::isEncryptionCompatible()) {
177
+	    	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
178
+	    }
174 179
 	    
175 180
 		$key = 'STANDARDKEYIFNOSERVER';
176
-		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
177
-			$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
181
+		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) {
182
+					$key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE'));
183
+		}
178 184
 		$encrypted = str_replace('-', '+', $encrypted);
179 185
 		$encrypted = str_replace('_', '/', $encrypted);
180 186
 		$encrypted = str_replace('*', '=', $encrypted);
181 187
 		$encrypted = base64_decode($encrypted);
182
-		if(!$encrypted)
183
-			throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.');
184
-		if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) 
185
-			throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.');
188
+		if(!$encrypted) {
189
+					throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.');
190
+		}
191
+		if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) {
192
+					throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.');
193
+		}
186 194
 		$iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE);
187 195
 		$encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE);
188 196
 		$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec);
@@ -223,7 +231,9 @@  discard block
 block discarded – undo
223 231
 	 * @return boolean True if path valid
224 232
 	 */
225 233
 	public static function isValidPath($filename, $acceptfolder = FALSE) {		
226
-		if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true;
234
+		if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) {
235
+			return true;
236
+		}
227 237
 		return false;
228 238
 	}
229 239
 	
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return boolean
136 136
 	 */
137 137
 	public static function isEncryptionCompatible() {
138
-	    return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt');
138
+		return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt');
139 139
 	}
140 140
 	
141 141
 	/**	  
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @return string Encrypted and encoded text
147 147
 	 */
148 148
 	public static function encryptToSafeBase64($data){
149
-	    if(!self::isEncryptionCompatible())
150
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
149
+		if(!self::isEncryptionCompatible())
150
+			throw new \Exception('MCrypt PHP extension is required to use encryption.');
151 151
 	    
152 152
 		$key = 'STANDARDKEYIFNOSERVER';
153 153
 		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 * @return string Decrypted text
170 170
 	 */
171 171
 	public static function decryptFromSafeBase64($encrypted){
172
-	    if(!self::isEncryptionCompatible())
173
-	        throw new \Exception('MCrypt PHP extension is required to use encryption.');
172
+		if(!self::isEncryptionCompatible())
173
+			throw new \Exception('MCrypt PHP extension is required to use encryption.');
174 174
 	    
175 175
 		$key = 'STANDARDKEYIFNOSERVER';
176 176
 		if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE')))
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public static function encodeFileSystemToUtf8($string){
199 199
 		if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') {
200
-		    return iconv('cp1252', 'utf-8//IGNORE',$string);
200
+			return iconv('cp1252', 'utf-8//IGNORE',$string);
201 201
 		}
202 202
 		return $string;
203 203
 	}
@@ -262,20 +262,20 @@  discard block
 block discarded – undo
262 262
 	 * @return boolean|string Is supported?
263 263
 	 */
264 264
 	public static function isImageTypeSupported($reqtype) {
265
-	    $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
266
-	    $reqtype = strtolower($reqtype);
265
+		$supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png');
266
+		$reqtype = strtolower($reqtype);
267 267
 	
268
-	    if (empty($supportByGD[$reqtype])) {
269
-	        return false;
270
-	    }
268
+		if (empty($supportByGD[$reqtype])) {
269
+			return false;
270
+		}
271 271
 	
272
-	    $type = $supportByGD[$reqtype];
272
+		$type = $supportByGD[$reqtype];
273 273
 	
274
-	    if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) {
275
-	        return $type;
276
-	    }
274
+		if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) {
275
+			return $type;
276
+		}
277 277
 	
278
-	    return false;
278
+		return false;
279 279
 	}
280 280
 		
281 281
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaStatsController.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@
 block discarded – undo
219 219
 
220 220
     /**
221 221
      * Convert an array to Google Chart encoding
222
-     * @param arrat $a Array to encode
222
+     * @param integer[] $a Array to encode
223 223
      * @return string
224 224
      */
225 225
     private function arrayToExtendedEncoding($a) {
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -94,8 +94,12 @@  discard block
 block discarded – undo
94 94
             foreach($stats_gen as $gen => $tab){
95 95
                 $genY1= I18N::translate('-');
96 96
                 $genY2= I18N::translate('-');
97
-                if($tab['firstBirth']>0) $genY1=$tab['firstBirth'];
98
-                if($tab['lastBirth']>0) $genY2=$tab['lastBirth'];
97
+                if($tab['firstBirth']>0) {
98
+                	$genY1=$tab['firstBirth'];
99
+                }
100
+                if($tab['lastBirth']>0) {
101
+                	$genY2=$tab['lastBirth'];
102
+                }
99 103
                 $total_theoretical += $gen_theoretical;
100 104
                 $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical);
101 105
                 $gen_equiv += $perc_sosa_count_theor;
@@ -141,7 +145,9 @@  discard block
 block discarded – undo
141 145
      private function htmlAncestorDispersionG2()
142 146
     {
143 147
         $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2);
144
-        if(count($ancestorsDispGen2) == 0) return;
148
+        if(count($ancestorsDispGen2) == 0) {
149
+        	return;
150
+        }
145 151
         
146 152
         $size = '600x300';
147 153
         
Please login to merge, or discard this patch.
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -26,215 +26,215 @@
 block discarded – undo
26 26
  */
27 27
 class SosaStatsController extends MvcController
28 28
 {
29
-    /**
30
-     * Sosa Provider for the controller
31
-     * @var SosaProvider $sosa_provider
32
-     */
33
-    protected $sosa_provider;
29
+	/**
30
+	 * Sosa Provider for the controller
31
+	 * @var SosaProvider $sosa_provider
32
+	 */
33
+	protected $sosa_provider;
34 34
     
35
-    /**
36
-     * Constructor for SosaStatsController
37
-     * @param AbstractModule $module
38
-     */
39
-    public function __construct(AbstractModule $module) {
40
-        parent::__construct($module);
35
+	/**
36
+	 * Constructor for SosaStatsController
37
+	 * @param AbstractModule $module
38
+	 */
39
+	public function __construct(AbstractModule $module) {
40
+		parent::__construct($module);
41 41
         
42
-        $this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user());
43
-    }
42
+		$this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user());
43
+	}
44 44
     
45
-    /**
46
-     * Pages
47
-     */
45
+	/**
46
+	 * Pages
47
+	 */
48 48
     
49
-    /**
50
-     * SosaStats@index
51
-     */
52
-    public function index() {
53
-        $wt_tree = Globals::getTree();
54
-        $controller = new PageController();
55
-        $controller
56
-            ->setPageTitle(I18N::translate('Sosa Statistics'))
57
-            ->addInlineJavascript('$(".help_tooltip").tooltip();')
58
-        ;
49
+	/**
50
+	 * SosaStats@index
51
+	 */
52
+	public function index() {
53
+		$wt_tree = Globals::getTree();
54
+		$controller = new PageController();
55
+		$controller
56
+			->setPageTitle(I18N::translate('Sosa Statistics'))
57
+			->addInlineJavascript('$(".help_tooltip").tooltip();')
58
+		;
59 59
 
60
-        $view_bag = new ViewBag();
61
-        $view_bag->set('title', $controller->getPageTitle());
62
-        $view_bag->set('is_setup', false);
60
+		$view_bag = new ViewBag();
61
+		$view_bag->set('title', $controller->getPageTitle());
62
+		$view_bag->set('is_setup', false);
63 63
         
64
-        if($this->sosa_provider->isSetup()) {
65
-            $view_bag->set('is_setup', true);
64
+		if($this->sosa_provider->isSetup()) {
65
+			$view_bag->set('is_setup', true);
66 66
             
67
-            $view_bag->set('root_indi', $this->sosa_provider->getRootIndi());
67
+			$view_bag->set('root_indi', $this->sosa_provider->getRootIndi());
68 68
             
69
-            $sosaCount = $this->sosa_provider->getSosaCount();
70
-            $diffSosaCount = $this->sosa_provider->getDifferentSosaCount();
69
+			$sosaCount = $this->sosa_provider->getSosaCount();
70
+			$diffSosaCount = $this->sosa_provider->getDifferentSosaCount();
71 71
             
72
-            $general_stats = array(
73
-                'sosa_count' => $sosaCount,
74
-                'distinct_count' => $diffSosaCount,
75
-                'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()),
76
-                'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount),
77
-                'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime()
78
-            );
79
-            $view_bag->set('general_stats', $general_stats);
72
+			$general_stats = array(
73
+				'sosa_count' => $sosaCount,
74
+				'distinct_count' => $diffSosaCount,
75
+				'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()),
76
+				'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount),
77
+				'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime()
78
+			);
79
+			$view_bag->set('general_stats', $general_stats);
80 80
             
81
-            $stats_gen = $this->sosa_provider->getStatisticsByGeneration();
82
-            $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen=');
83
-            $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen=');
81
+			$stats_gen = $this->sosa_provider->getStatisticsByGeneration();
82
+			$view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen=');
83
+			$view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen=');
84 84
             
85
-            $gen_theoretical=1;
86
-            $total_theoretical=0;
87
-            $prev_diff=0;
88
-            $prev_known=0.5;
89
-            $gen_equiv=0;            
90
-            $generation_stats = array();
85
+			$gen_theoretical=1;
86
+			$total_theoretical=0;
87
+			$prev_diff=0;
88
+			$prev_known=0.5;
89
+			$gen_equiv=0;            
90
+			$generation_stats = array();
91 91
             
92
-            foreach($stats_gen as $gen => $tab){
93
-                $genY1= I18N::translate('-');
94
-                $genY2= I18N::translate('-');
95
-                if($tab['firstBirth']>0) $genY1=$tab['firstBirth'];
96
-                if($tab['lastBirth']>0) $genY2=$tab['lastBirth'];
97
-                $total_theoretical += $gen_theoretical;
98
-                $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical);
99
-                $gen_equiv += $perc_sosa_count_theor;
100
-                $missing=2*$prev_known - $tab['sosaCount'];
101
-                $gen_diff=$tab['diffSosaTotalCount']-$prev_diff;
92
+			foreach($stats_gen as $gen => $tab){
93
+				$genY1= I18N::translate('-');
94
+				$genY2= I18N::translate('-');
95
+				if($tab['firstBirth']>0) $genY1=$tab['firstBirth'];
96
+				if($tab['lastBirth']>0) $genY2=$tab['lastBirth'];
97
+				$total_theoretical += $gen_theoretical;
98
+				$perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical);
99
+				$gen_equiv += $perc_sosa_count_theor;
100
+				$missing=2*$prev_known - $tab['sosaCount'];
101
+				$gen_diff=$tab['diffSosaTotalCount']-$prev_diff;
102 102
                 
103
-                $generation_stats[$gen] = array(
104
-                    'gen_min_birth' => $genY1,
105
-                    'gen_max_birth' => $genY2,
106
-                    'theoretical' => $gen_theoretical,
107
-                    'known' => $tab['sosaCount'],
108
-                    'perc_known' => $perc_sosa_count_theor,
109
-                    'missing' => $missing,
110
-                    'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known),
111
-                    'total_known' => $tab['sosaTotalCount'],
112
-                    'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical),
113
-                    'different' => $gen_diff,
114
-                    'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']),
115
-                    'total_different' => $tab['diffSosaTotalCount'],
116
-                    'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount'])
117
-                );
103
+				$generation_stats[$gen] = array(
104
+					'gen_min_birth' => $genY1,
105
+					'gen_max_birth' => $genY2,
106
+					'theoretical' => $gen_theoretical,
107
+					'known' => $tab['sosaCount'],
108
+					'perc_known' => $perc_sosa_count_theor,
109
+					'missing' => $missing,
110
+					'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known),
111
+					'total_known' => $tab['sosaTotalCount'],
112
+					'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical),
113
+					'different' => $gen_diff,
114
+					'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']),
115
+					'total_different' => $tab['diffSosaTotalCount'],
116
+					'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount'])
117
+				);
118 118
                 
119
-                $gen_theoretical = $gen_theoretical * 2;
120
-                $prev_known=$tab['sosaCount'];
121
-                $prev_diff=$tab['diffSosaTotalCount'];
122
-            }
119
+				$gen_theoretical = $gen_theoretical * 2;
120
+				$prev_known=$tab['sosaCount'];
121
+				$prev_diff=$tab['diffSosaTotalCount'];
122
+			}
123 123
             
124
-            $view_bag->set('generation_stats', $generation_stats);
125
-            $view_bag->set('equivalent_gen', $gen_equiv);
124
+			$view_bag->set('generation_stats', $generation_stats);
125
+			$view_bag->set('equivalent_gen', $gen_equiv);
126 126
                         
127
-            $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2());
128
-            $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3());
127
+			$view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2());
128
+			$view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3());
129 129
             
130
-        }
130
+		}
131 131
         
132
-        ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render();   
133
-    }
132
+		ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render();   
133
+	}
134 134
     
135
-    /**
136
-     * Returns HTML code for a graph showing the dispersion of ancestors across father & mother
137
-     * @return string HTML code
138
-     */
139
-     private function htmlAncestorDispersionG2()
140
-    {
141
-        $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2);
142
-        if(count($ancestorsDispGen2) == 0) return;
135
+	/**
136
+	 * Returns HTML code for a graph showing the dispersion of ancestors across father & mother
137
+	 * @return string HTML code
138
+	 */
139
+	 private function htmlAncestorDispersionG2()
140
+	{
141
+		$ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2);
142
+		if(count($ancestorsDispGen2) == 0) return;
143 143
         
144
-        $size = '600x300';
144
+		$size = '600x300';
145 145
         
146
-        $total = array_sum($ancestorsDispGen2);
147
-        $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
148
-        $father = array (
149
-            'color' => '84beff', 
150
-            'count' => $father_count, 
151
-            'perc' => Functions::safeDivision($father_count, $total), 
152
-            'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat')            
153
-        );
154
-        $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
155
-        $mother = array (
156
-            'color' => 'ffd1dc', 
157
-            'count' => $mother_count, 
158
-            'perc' => Functions::safeDivision($mother_count, $total),
159
-            'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot')
160
-        );
161
-        $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
162
-        $shared = array (
163
-            'color' => '777777', 
164
-            'count' => $shared_count, 
165
-            'perc' => Functions::safeDivision($shared_count, $total),
166
-            'name' => I18N::translate('Shared')
167
-        );
146
+		$total = array_sum($ancestorsDispGen2);
147
+		$father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
148
+		$father = array (
149
+			'color' => '84beff', 
150
+			'count' => $father_count, 
151
+			'perc' => Functions::safeDivision($father_count, $total), 
152
+			'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat')            
153
+		);
154
+		$mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
155
+		$mother = array (
156
+			'color' => 'ffd1dc', 
157
+			'count' => $mother_count, 
158
+			'perc' => Functions::safeDivision($mother_count, $total),
159
+			'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot')
160
+		);
161
+		$shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
162
+		$shared = array (
163
+			'color' => '777777', 
164
+			'count' => $shared_count, 
165
+			'perc' => Functions::safeDivision($shared_count, $total),
166
+			'name' => I18N::translate('Shared')
167
+		);
168 168
         
169
-        $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc']));
170
-        $chart_title = I18N::translate('Known Sosa ancestors\' dispersion');
171
-        $chl = 
172
-             $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' .
173
-             $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' .
174
-             $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1);
175
-        return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
176
-    }
169
+		$chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc']));
170
+		$chart_title = I18N::translate('Known Sosa ancestors\' dispersion');
171
+		$chl = 
172
+			 $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' .
173
+			 $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' .
174
+			 $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1);
175
+		return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
176
+	}
177 177
     
178
-    /**
179
-     * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents
180
-     * @return string HTML code
181
-     */
182
-    private function htmlAncestorDispersionG3()
183
-    {
184
-        $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3);
178
+	/**
179
+	 * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents
180
+	 * @return string HTML code
181
+	 */
182
+	private function htmlAncestorDispersionG3()
183
+	{
184
+		$ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3);
185 185
         
186
-        $size = '700x300';
186
+		$size = '700x300';
187 187
         
188
-        $color_motmot = 'ffd1dc';
189
-        $color_motfat = 'b998a0';
190
-        $color_fatfat = '577292';
191
-        $color_fatmot = '84beff';
192
-        $color_shared = '777777';
188
+		$color_motmot = 'ffd1dc';
189
+		$color_motfat = 'b998a0';
190
+		$color_fatfat = '577292';
191
+		$color_fatmot = '84beff';
192
+		$color_shared = '777777';
193 193
     
194
-        $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
195
-        $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
196
-        $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0;
197
-        $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0;
198
-        $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
199
-        $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha;
194
+		$total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
195
+		$total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
196
+		$total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0;
197
+		$total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0;
198
+		$total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
199
+		$total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha;
200 200
     
201
-        $chd = $this->arrayToExtendedEncoding(array(
202
-	    4095 * Functions::safeDivision($total_fatfat, $total), 
203
-            4095 * Functions::safeDivision($total_fatmot, $total),
204
-            4095 * Functions::safeDivision($total_sha, $total), 
205
-            4095 * Functions::safeDivision($total_motfat, $total),
206
-            4095 * Functions::safeDivision($total_motmot, $total)          
207
-        ));
208
-        $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3');
209
-        $chl =
210
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' .
211
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' .
212
-            I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' .
213
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' .
214
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
215
-         return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
216
-    }
201
+		$chd = $this->arrayToExtendedEncoding(array(
202
+		4095 * Functions::safeDivision($total_fatfat, $total), 
203
+			4095 * Functions::safeDivision($total_fatmot, $total),
204
+			4095 * Functions::safeDivision($total_sha, $total), 
205
+			4095 * Functions::safeDivision($total_motfat, $total),
206
+			4095 * Functions::safeDivision($total_motmot, $total)          
207
+		));
208
+		$chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3');
209
+		$chl =
210
+			\Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' .
211
+			\Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' .
212
+			I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' .
213
+			\Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' .
214
+			\Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
215
+		 return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
216
+	}
217 217
 
218
-    /**
219
-     * Convert an array to Google Chart encoding
220
-     * @param arrat $a Array to encode
221
-     * @return string
222
-     */
223
-    private function arrayToExtendedEncoding($a) {
224
-        $xencoding = WT_GOOGLE_CHART_ENCODING;
218
+	/**
219
+	 * Convert an array to Google Chart encoding
220
+	 * @param arrat $a Array to encode
221
+	 * @return string
222
+	 */
223
+	private function arrayToExtendedEncoding($a) {
224
+		$xencoding = WT_GOOGLE_CHART_ENCODING;
225 225
     
226
-        $encoding = '';
227
-        foreach ($a as $value) {
228
-            if ($value < 0) {
229
-                $value = 0;
230
-            }
231
-            $first  = (int) ($value / 64);
232
-            $second = $value % 64;
233
-            $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second];
234
-        }
226
+		$encoding = '';
227
+		foreach ($a as $value) {
228
+			if ($value < 0) {
229
+				$value = 0;
230
+			}
231
+			$first  = (int) ($value / 64);
232
+			$second = $value % 64;
233
+			$encoding .= $xencoding[(int) $first] . $xencoding[(int) $second];
234
+		}
235 235
     
236
-        return $encoding;
237
-    }
236
+		return $encoding;
237
+	}
238 238
     
239 239
     
240 240
 }
241 241
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $view_bag->set('title', $controller->getPageTitle());
62 62
         $view_bag->set('is_setup', false);
63 63
         
64
-        if($this->sosa_provider->isSetup()) {
64
+        if ($this->sosa_provider->isSetup()) {
65 65
             $view_bag->set('is_setup', true);
66 66
             
67 67
             $view_bag->set('root_indi', $this->sosa_provider->getRootIndi());
@@ -82,23 +82,23 @@  discard block
 block discarded – undo
82 82
             $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen=');
83 83
             $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen=');
84 84
             
85
-            $gen_theoretical=1;
86
-            $total_theoretical=0;
87
-            $prev_diff=0;
88
-            $prev_known=0.5;
89
-            $gen_equiv=0;            
85
+            $gen_theoretical = 1;
86
+            $total_theoretical = 0;
87
+            $prev_diff = 0;
88
+            $prev_known = 0.5;
89
+            $gen_equiv = 0;            
90 90
             $generation_stats = array();
91 91
             
92
-            foreach($stats_gen as $gen => $tab){
93
-                $genY1= I18N::translate('-');
94
-                $genY2= I18N::translate('-');
95
-                if($tab['firstBirth']>0) $genY1=$tab['firstBirth'];
96
-                if($tab['lastBirth']>0) $genY2=$tab['lastBirth'];
92
+            foreach ($stats_gen as $gen => $tab) {
93
+                $genY1 = I18N::translate('-');
94
+                $genY2 = I18N::translate('-');
95
+                if ($tab['firstBirth'] > 0) $genY1 = $tab['firstBirth'];
96
+                if ($tab['lastBirth'] > 0) $genY2 = $tab['lastBirth'];
97 97
                 $total_theoretical += $gen_theoretical;
98 98
                 $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical);
99 99
                 $gen_equiv += $perc_sosa_count_theor;
100
-                $missing=2*$prev_known - $tab['sosaCount'];
101
-                $gen_diff=$tab['diffSosaTotalCount']-$prev_diff;
100
+                $missing = 2 * $prev_known - $tab['sosaCount'];
101
+                $gen_diff = $tab['diffSosaTotalCount'] - $prev_diff;
102 102
                 
103 103
                 $generation_stats[$gen] = array(
104 104
                     'gen_min_birth' => $genY1,
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     'known' => $tab['sosaCount'],
108 108
                     'perc_known' => $perc_sosa_count_theor,
109 109
                     'missing' => $missing,
110
-                    'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known),
110
+                    'perc_missing' => 1 - Functions::safeDivision($tab['sosaCount'], 2 * $prev_known),
111 111
                     'total_known' => $tab['sosaTotalCount'],
112 112
                     'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical),
113 113
                     'different' => $gen_diff,
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
                 );
118 118
                 
119 119
                 $gen_theoretical = $gen_theoretical * 2;
120
-                $prev_known=$tab['sosaCount'];
121
-                $prev_diff=$tab['diffSosaTotalCount'];
120
+                $prev_known = $tab['sosaCount'];
121
+                $prev_diff = $tab['diffSosaTotalCount'];
122 122
             }
123 123
             
124 124
             $view_bag->set('generation_stats', $generation_stats);
@@ -139,27 +139,27 @@  discard block
 block discarded – undo
139 139
      private function htmlAncestorDispersionG2()
140 140
     {
141 141
         $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2);
142
-        if(count($ancestorsDispGen2) == 0) return;
142
+        if (count($ancestorsDispGen2) == 0) return;
143 143
         
144 144
         $size = '600x300';
145 145
         
146 146
         $total = array_sum($ancestorsDispGen2);
147 147
         $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
148
-        $father = array (
148
+        $father = array(
149 149
             'color' => '84beff', 
150 150
             'count' => $father_count, 
151 151
             'perc' => Functions::safeDivision($father_count, $total), 
152 152
             'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat')            
153 153
         );
154 154
         $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
155
-        $mother = array (
155
+        $mother = array(
156 156
             'color' => 'ffd1dc', 
157 157
             'count' => $mother_count, 
158 158
             'perc' => Functions::safeDivision($mother_count, $total),
159 159
             'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot')
160 160
         );
161 161
         $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
162
-        $shared = array (
162
+        $shared = array(
163 163
             'color' => '777777', 
164 164
             'count' => $shared_count, 
165 165
             'perc' => Functions::safeDivision($shared_count, $total),
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
         $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc']));
170 170
         $chart_title = I18N::translate('Known Sosa ancestors\' dispersion');
171 171
         $chl = 
172
-             $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' .
173
-             $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' .
174
-             $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1);
175
-        return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
172
+             $father['name'].' - '.I18N::percentage($father['perc'], 1).'|'.
173
+             $shared['name'].' - '.I18N::percentage($shared['perc'], 1).'|'.
174
+             $mother['name'].' - '.I18N::percentage($mother['perc'], 1);
175
+        return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />";
176 176
     }
177 177
     
178 178
     /**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0;
197 197
         $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0;
198 198
         $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
199
-        $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha;
199
+        $total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha;
200 200
     
201 201
         $chd = $this->arrayToExtendedEncoding(array(
202 202
 	    4095 * Functions::safeDivision($total_fatfat, $total), 
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
         ));
208 208
         $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3');
209 209
         $chl =
210
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' .
211
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' .
212
-            I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' .
213
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' .
214
-            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
215
-         return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
210
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat').' - '.I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1).'|'.
211
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot').' - '.I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1).'|'.
212
+            I18N::translate('Shared').' - '.I18N::percentage(Functions::safeDivision($total_sha, $total), 1).'|'.
213
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat').' - '.I18N::percentage(Functions::safeDivision($total_motfat, $total), 1).'|'.
214
+            \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot').' - '.I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
215
+         return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />";
216 216
     }
217 217
 
218 218
     /**
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
             if ($value < 0) {
229 229
                 $value = 0;
230 230
             }
231
-            $first  = (int) ($value / 64);
231
+            $first  = (int)($value / 64);
232 232
             $second = $value % 64;
233
-            $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second];
233
+            $encoding .= $xencoding[(int)$first].$xencoding[(int)$second];
234 234
         }
235 235
     
236 236
         return $encoding;
Please login to merge, or discard this patch.
src/Webtrees/Mvc/Dispatcher.php 3 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -18,35 +18,35 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Dispatcher implements DispatcherInterface {
20 20
     
21
-    /**
22
-     * @var Dispatcher $instance Singleton pattern instance
23
-     */
24
-    private static $instance = null;
21
+	/**
22
+	 * @var Dispatcher $instance Singleton pattern instance
23
+	 */
24
+	private static $instance = null;
25 25
     
26
-    /**
27
-     * Returns the *Dispatcher* instance of this class.
28
-     *
29
-     * @return Dispatcher The *Singleton* instance.
30
-     */
31
-    public static function getInstance()
32
-    {
33
-        if (null === static::$instance) {
34
-            static::$instance = new static();
35
-        }
26
+	/**
27
+	 * Returns the *Dispatcher* instance of this class.
28
+	 *
29
+	 * @return Dispatcher The *Singleton* instance.
30
+	 */
31
+	public static function getInstance()
32
+	{
33
+		if (null === static::$instance) {
34
+			static::$instance = new static();
35
+		}
36 36
     
37
-        return static::$instance;
38
-    }    
37
+		return static::$instance;
38
+	}    
39 39
     
40 40
 	/**
41
-     * Protected constructor.
42
-     */
43
-    protected function __construct() {}
41
+	 * Protected constructor.
42
+	 */
43
+	protected function __construct() {}
44 44
     
45
-    /**
46
-     * {@inheritdoc }
47
-     * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle()
48
-     */
49
-    public function handle(fw\Module\AbstractModule $module, $request) {
45
+	/**
46
+	 * {@inheritdoc }
47
+	 * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle()
48
+	 */
49
+	public function handle(fw\Module\AbstractModule $module, $request) {
50 50
 		
51 51
 		$fq_modclass_name = get_class($module);
52 52
 		$ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\';
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 		
67 67
 		$ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller';
68 68
 		if(class_exists($ctrl_class) 
69
-		    && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController')
69
+			&& is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController')
70 70
 			&& $ctrl = new $ctrl_class($module) ) {
71 71
 			if(method_exists($ctrl, $method)) {
72
-			    try {
73
-			        call_user_func_array(array($ctrl, $method), array());
74
-			    }
75
-			    catch (MvcException $ex) {
76
-			        if(!headers_sent()) {
77
-			            http_response_code($ex->getHttpCode());
78
-			        }
79
-			        echo $ex->getMessage();			        
80
-			    }
72
+				try {
73
+					call_user_func_array(array($ctrl, $method), array());
74
+				}
75
+				catch (MvcException $ex) {
76
+					if(!headers_sent()) {
77
+						http_response_code($ex->getHttpCode());
78
+					}
79
+					echo $ex->getMessage();			        
80
+				}
81 81
 			}
82 82
 			 else {
83 83
 				 throw new \Exception('The page requested does not exist');
@@ -86,27 +86,27 @@  discard block
 block discarded – undo
86 86
 		 else {
87 87
 			 throw new \Exception('The page requested does not exist');
88 88
 		 }
89
-    }
89
+	}
90 90
 
91
-    /**
92
-     * Private clone method to prevent cloning of the instance of the
93
-     * *Dispatcher* instance.
94
-     *
95
-     * @return void
96
-     */
97
-    private function __clone()
98
-    {
99
-    }
91
+	/**
92
+	 * Private clone method to prevent cloning of the instance of the
93
+	 * *Dispatcher* instance.
94
+	 *
95
+	 * @return void
96
+	 */
97
+	private function __clone()
98
+	{
99
+	}
100 100
     
101
-    /**
102
-     * Private unserialize method to prevent unserializing of the *Dispatcher*
103
-     * instance.
104
-     *
105
-     * @return void
106
-     */
107
-    private function __wakeup()
108
-    {
109
-    }
101
+	/**
102
+	 * Private unserialize method to prevent unserializing of the *Dispatcher*
103
+	 * instance.
104
+	 *
105
+	 * @return void
106
+	 */
107
+	private function __wakeup()
108
+	{
109
+	}
110 110
     
111 111
 }
112 112
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     public function handle(fw\Module\AbstractModule $module, $request) {
50 50
 		
51 51
 		$fq_modclass_name = get_class($module);
52
-		$ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\';
52
+		$ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\';
53 53
 		
54
-		$args = explode( '@', $request, 2);
55
-		switch(count($args)) {
54
+		$args = explode('@', $request, 2);
55
+		switch (count($args)) {
56 56
 			case 1:
57 57
 				$ctrl_name = $args[0];
58 58
 				$method = 'index';
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
 				break;
65 65
 		}
66 66
 		
67
-		$ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller';
68
-		if(class_exists($ctrl_class) 
67
+		$ctrl_class = $ctrl_namespace.$ctrl_name.'Controller';
68
+		if (class_exists($ctrl_class) 
69 69
 		    && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController')
70
-			&& $ctrl = new $ctrl_class($module) ) {
71
-			if(method_exists($ctrl, $method)) {
70
+			&& $ctrl = new $ctrl_class($module)) {
71
+			if (method_exists($ctrl, $method)) {
72 72
 			    try {
73 73
 			        call_user_func_array(array($ctrl, $method), array());
74 74
 			    }
75 75
 			    catch (MvcException $ex) {
76
-			        if(!headers_sent()) {
76
+			        if (!headers_sent()) {
77 77
 			            http_response_code($ex->getHttpCode());
78 78
 			        }
79 79
 			        echo $ex->getMessage();			        
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -71,19 +71,16 @@
 block discarded – undo
71 71
 			if(method_exists($ctrl, $method)) {
72 72
 			    try {
73 73
 			        call_user_func_array(array($ctrl, $method), array());
74
-			    }
75
-			    catch (MvcException $ex) {
74
+			    } catch (MvcException $ex) {
76 75
 			        if(!headers_sent()) {
77 76
 			            http_response_code($ex->getHttpCode());
78 77
 			        }
79 78
 			        echo $ex->getMessage();			        
80 79
 			    }
81
-			}
82
-			 else {
80
+			} else {
83 81
 				 throw new \Exception('The page requested does not exist');
84 82
 			 }
85
-		 }
86
-		 else {
83
+		 } else {
87 84
 			 throw new \Exception('The page requested does not exist');
88 85
 		 }
89 86
     }
Please login to merge, or discard this patch.
src/Webtrees/Mvc/MvcException.php 3 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -16,52 +16,52 @@
 block discarded – undo
16 16
  */
17 17
 class MvcException extends \Exception {
18 18
 
19
-    /** @var int[] $VALID_HTTP List of valid HTTP codes */
20
-    protected static $VALID_HTTP =  array(
21
-        100, 101,
22
-        200, 201, 202, 203, 204, 205, 206,
23
-        300, 301, 302, 303, 304, 305, 306, 307,
24
-        400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417,
25
-        500, 501, 502, 503, 504, 505
26
-    );
19
+	/** @var int[] $VALID_HTTP List of valid HTTP codes */
20
+	protected static $VALID_HTTP =  array(
21
+		100, 101,
22
+		200, 201, 202, 203, 204, 205, 206,
23
+		300, 301, 302, 303, 304, 305, 306, 307,
24
+		400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417,
25
+		500, 501, 502, 503, 504, 505
26
+	);
27 27
     
28
-    /** @var int $http_code */
29
-    protected $http_code;
28
+	/** @var int $http_code */
29
+	protected $http_code;
30 30
     
31
-    /**
32
-     * Constructor for MvcException
33
-     * 
34
-     * @param int $http_code
35
-     * @param string $message
36
-     * @param int $code
37
-     * @param \Throwable $previous
38
-     */
39
-    public function __construct($http_code = 500, $message = "", $code = 0, \Throwable $previous = null) {
40
-        parent::__construct($message, $code, $previous);   
31
+	/**
32
+	 * Constructor for MvcException
33
+	 * 
34
+	 * @param int $http_code
35
+	 * @param string $message
36
+	 * @param int $code
37
+	 * @param \Throwable $previous
38
+	 */
39
+	public function __construct($http_code = 500, $message = "", $code = 0, \Throwable $previous = null) {
40
+		parent::__construct($message, $code, $previous);   
41 41
                 
42
-        $this->http_code = in_array($http_code, self::$VALID_HTTP) ? $http_code : 500;
43
-    }
42
+		$this->http_code = in_array($http_code, self::$VALID_HTTP) ? $http_code : 500;
43
+	}
44 44
     
45
-    /**
46
-     * Get the HTTP code
47
-     * 
48
-     * @return int
49
-     */
50
-    public function getHttpCode() {
51
-        return $this->http_code;
52
-    }
45
+	/**
46
+	 * Get the HTTP code
47
+	 * 
48
+	 * @return int
49
+	 */
50
+	public function getHttpCode() {
51
+		return $this->http_code;
52
+	}
53 53
     
54
-    /**
55
-     * Set the HTTP code
56
-     * 
57
-     * @param int $http_code
58
-     * @throws InvalidArgumentException Thrown if not valid Http code
59
-     */
60
-    public function setHttpCode($http_code) {
61
-        if(!in_array($http_code, self::$VALID_HTTP))
62
-            throw new \InvalidArgumentException('Invalid HTTP code');
63
-        $this->http_code= $http_code;
64
-    }   
54
+	/**
55
+	 * Set the HTTP code
56
+	 * 
57
+	 * @param int $http_code
58
+	 * @throws InvalidArgumentException Thrown if not valid Http code
59
+	 */
60
+	public function setHttpCode($http_code) {
61
+		if(!in_array($http_code, self::$VALID_HTTP))
62
+			throw new \InvalidArgumentException('Invalid HTTP code');
63
+		$this->http_code= $http_code;
64
+	}   
65 65
 
66 66
 }
67 67
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 class MvcException extends \Exception {
18 18
 
19 19
     /** @var int[] $VALID_HTTP List of valid HTTP codes */
20
-    protected static $VALID_HTTP =  array(
20
+    protected static $VALID_HTTP = array(
21 21
         100, 101,
22 22
         200, 201, 202, 203, 204, 205, 206,
23 23
         300, 301, 302, 303, 304, 305, 306, 307,
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
      * @throws InvalidArgumentException Thrown if not valid Http code
59 59
      */
60 60
     public function setHttpCode($http_code) {
61
-        if(!in_array($http_code, self::$VALID_HTTP))
61
+        if (!in_array($http_code, self::$VALID_HTTP))
62 62
             throw new \InvalidArgumentException('Invalid HTTP code');
63
-        $this->http_code= $http_code;
63
+        $this->http_code = $http_code;
64 64
     }   
65 65
 
66 66
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@
 block discarded – undo
58 58
      * @throws InvalidArgumentException Thrown if not valid Http code
59 59
      */
60 60
     public function setHttpCode($http_code) {
61
-        if(!in_array($http_code, self::$VALID_HTTP))
62
-            throw new \InvalidArgumentException('Invalid HTTP code');
61
+        if(!in_array($http_code, self::$VALID_HTTP)) {
62
+                    throw new \InvalidArgumentException('Invalid HTTP code');
63
+        }
63 64
         $this->http_code= $http_code;
64 65
     }   
65 66
 
Please login to merge, or discard this patch.