Completed
Push — feature/code-analysis ( 05bab0...e964aa )
by Jonathan
02:58
created
src/Webtrees/Module/ModuleMenuItemInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
  */
16 16
 interface ModuleMenuItemInterface
17 17
 {
18
-    /**
19
-     * Returns a menu item for the module.
20
-     * 
21
-     * @param \Fisharebest\Webtrees\Tree|null $tree
22
-     * @param mixed $reference
23
-     */
24
-    public function getMenu(\Fisharebest\Webtrees\Tree $tree, $reference);
18
+	/**
19
+	 * Returns a menu item for the module.
20
+	 * 
21
+	 * @param \Fisharebest\Webtrees\Tree|null $tree
22
+	 * @param mixed $reference
23
+	 */
24
+	public function getMenu(\Fisharebest\Webtrees\Tree $tree, $reference);
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Model/ConfigurableTaskInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
  */
16 16
 interface ConfigurableTaskInterface {
17 17
     
18
-    /**
19
-     * Returns the HTML code to display the specific task configuration.
20
-     * 
21
-     * @return string HTML code
22
-     */
18
+	/**
19
+	 * Returns the HTML code to display the specific task configuration.
20
+	 * 
21
+	 * @return string HTML code
22
+	 */
23 23
 	function htmlConfigForm();
24 24
 	
25 25
 	/**
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Model/TaskProvider.php 3 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -20,32 +20,32 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class TaskProvider implements TaskProviderInterface {
22 22
     
23
-    /**
24
-     * Root path of thr folder containing the tasks
25
-     * @var string $root_path
26
-     */
27
-    protected $root_path;
23
+	/**
24
+	 * Root path of thr folder containing the tasks
25
+	 * @var string $root_path
26
+	 */
27
+	protected $root_path;
28 28
 	    
29
-    /**
30
-     * Constructor for the Task provider
31
-     * @param string $root_path
32
-     */
33
-    public function __construct($root_path) {
34
-        $this->root_path = $root_path;
29
+	/**
30
+	 * Constructor for the Task provider
31
+	 * @param string $root_path
32
+	 */
33
+	public function __construct($root_path) {
34
+		$this->root_path = $root_path;
35 35
 		$this->all_tasks = null;
36
-    }
36
+	}
37 37
 	
38
-    /**
39
-     * Load a task object from a file.
40
-     * 
41
-     * @param string $task_name Name of the task to load.
42
-     */
38
+	/**
39
+	 * Load a task object from a file.
40
+	 * 
41
+	 * @param string $task_name Name of the task to load.
42
+	 */
43 43
 	protected function loadTask($task_name) {
44 44
 		try {
45 45
 			if (file_exists($this->root_path . $task_name .'.php')) {
46 46
 				$task = include $this->root_path . $task_name .'.php';
47 47
 				if($task instanceof AbstractTask) {
48
-				    $task->setProvider($this);
48
+					$task->setProvider($this);
49 49
 					return $task;
50 50
 				}
51 51
 			}
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 		return null;
56 56
 	}
57 57
 	
58
-    /**
59
-     * Creates and returns a Task object from a data row.
60
-     * The row data is expected to be an array with the indexes:
61
-     *  - majat_name: task name
62
-     *  - majat_status: task status
63
-     *  - majat_last_run: last run time
64
-     *  - majat_last_result: last run result
65
-     *  - majat_frequency: run frequency
66
-     *  - majat_nb_occur: remaining running occurrences
67
-     *  - majat_running: is task running
68
-     *
69
-     * @param array $row
70
-     * @return AbstractTask|null
71
-     */
72
-    protected function loadTaskFromRow($row) {
73
-        $task = $this->loadTask($row['majat_name']);
58
+	/**
59
+	 * Creates and returns a Task object from a data row.
60
+	 * The row data is expected to be an array with the indexes:
61
+	 *  - majat_name: task name
62
+	 *  - majat_status: task status
63
+	 *  - majat_last_run: last run time
64
+	 *  - majat_last_result: last run result
65
+	 *  - majat_frequency: run frequency
66
+	 *  - majat_nb_occur: remaining running occurrences
67
+	 *  - majat_running: is task running
68
+	 *
69
+	 * @param array $row
70
+	 * @return AbstractTask|null
71
+	 */
72
+	protected function loadTaskFromRow($row) {
73
+		$task = $this->loadTask($row['majat_name']);
74 74
         
75 75
 		if($task) {
76 76
 			$task->setParameters(
@@ -85,99 +85,99 @@  discard block
 block discarded – undo
85 85
 			return $task;
86 86
 		}
87 87
 		else {
88
-		    $this->deleteTask($row['majat_name']);
88
+			$this->deleteTask($row['majat_name']);
89 89
 		}
90 90
 		return null;
91
-    }
91
+	}
92 92
     
93
-    /**
94
-     * {@inheritDoc}
95
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getTask()
96
-     */
97
-    public function getTask($task_name, $only_enabled = true) {
98
-        $args = array (
99
-            'task_name' => $task_name
100
-        );
93
+	/**
94
+	 * {@inheritDoc}
95
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getTask()
96
+	 */
97
+	public function getTask($task_name, $only_enabled = true) {
98
+		$args = array (
99
+			'task_name' => $task_name
100
+		);
101 101
     
102
-        $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' .
103
-            ' FROM `##maj_admintasks`' .
104
-            ' WHERE majat_name = :task_name';
105
-        if($only_enabled) {
106
-            $sql .= ' AND majat_status = :status';
107
-            $args['status'] = 'enabled';
108
-        }
102
+		$sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' .
103
+			' FROM `##maj_admintasks`' .
104
+			' WHERE majat_name = :task_name';
105
+		if($only_enabled) {
106
+			$sql .= ' AND majat_status = :status';
107
+			$args['status'] = 'enabled';
108
+		}
109 109
     
110
-        $task_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
110
+		$task_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
111 111
     
112
-        if($task_array) {
113
-            return $this->loadTaskFromRow($task_array);
114
-        }
112
+		if($task_array) {
113
+			return $this->loadTaskFromRow($task_array);
114
+		}
115 115
     
116
-        return null;
117
-    }
116
+		return null;
117
+	}
118 118
     
119 119
 	/**
120 120
 	 * {@inheritDoc}
121 121
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::setTaskStatus()
122 122
 	 */
123
-    public function setTaskStatus(AbstractTask $task, $status) {
124
-        Database::prepare(
125
-            'UPDATE `##maj_admintasks`'.
126
-            ' SET majat_status = :status'.
127
-            ' WHERE majat_name = :name'
128
-        )->execute(array(
129
-                'name' => $task->getName(),
123
+	public function setTaskStatus(AbstractTask $task, $status) {
124
+		Database::prepare(
125
+			'UPDATE `##maj_admintasks`'.
126
+			' SET majat_status = :status'.
127
+			' WHERE majat_name = :name'
128
+		)->execute(array(
129
+				'name' => $task->getName(),
130 130
 				'status' => $status ? 'enabled' : 'disabled'
131
-        ));
132
-    }
131
+		));
132
+	}
133 133
 	
134 134
    /**
135 135
     * {@inheritDoc}
136 136
     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::updateTask()
137 137
     */
138
-    public function updateTask(AbstractTask $task) {        
139
-        try{
140
-            Database::prepare(
141
-                'UPDATE `##maj_admintasks`'.
142
-                ' SET majat_status = :status,'.
143
-                ' majat_last_run = :last_run,'.
144
-                ' majat_last_result = :last_result,'.
145
-                ' majat_frequency = :frequency,'.
146
-                ' majat_nb_occur = :nb_occurrences,'.
147
-                ' majat_running = :is_running'.
148
-                ' WHERE majat_name = :name'
149
-                )->execute(array(
150
-                    'name' => $task->getName(),
151
-                    'status' => $task->isEnabled() ? 'enabled' : 'disabled',
152
-                    'last_run' => $task->getLastUpdated()->format('Y-m-d H:i:s'),
153
-                    'last_result' =>  $task->isLastRunSuccess() ? 1 : 0,
154
-                    'frequency' => $task->getFrequency(),
155
-                    'nb_occurrences' => $task->getRemainingOccurrences(),
156
-                    'is_running' => $task->isRunning() ? 1 : 0
157
-                ));
158
-            return true;
159
-        }
160
-        catch (\Exception $ex) {
161
-            Log::addErrorLog(sprintf('Error while updating the Admin Task %s. Exception: %s', $task->getName(), $ex->getMessage()));
162
-            return false;
163
-        }        
164
-    }
138
+	public function updateTask(AbstractTask $task) {        
139
+		try{
140
+			Database::prepare(
141
+				'UPDATE `##maj_admintasks`'.
142
+				' SET majat_status = :status,'.
143
+				' majat_last_run = :last_run,'.
144
+				' majat_last_result = :last_result,'.
145
+				' majat_frequency = :frequency,'.
146
+				' majat_nb_occur = :nb_occurrences,'.
147
+				' majat_running = :is_running'.
148
+				' WHERE majat_name = :name'
149
+				)->execute(array(
150
+					'name' => $task->getName(),
151
+					'status' => $task->isEnabled() ? 'enabled' : 'disabled',
152
+					'last_run' => $task->getLastUpdated()->format('Y-m-d H:i:s'),
153
+					'last_result' =>  $task->isLastRunSuccess() ? 1 : 0,
154
+					'frequency' => $task->getFrequency(),
155
+					'nb_occurrences' => $task->getRemainingOccurrences(),
156
+					'is_running' => $task->isRunning() ? 1 : 0
157
+				));
158
+			return true;
159
+		}
160
+		catch (\Exception $ex) {
161
+			Log::addErrorLog(sprintf('Error while updating the Admin Task %s. Exception: %s', $task->getName(), $ex->getMessage()));
162
+			return false;
163
+		}        
164
+	}
165 165
 	
166 166
 	/**
167 167
 	 * {@inheritDoc}
168 168
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getTasksCount()
169 169
 	 */
170
-    public function getTasksCount() {
171
-        return Database::prepare(
172
-            'SELECT COUNT(majat_name)' .
173
-            ' FROM `##maj_admintasks`'
174
-            )->execute()->fetchOne();
175
-    }
170
+	public function getTasksCount() {
171
+		return Database::prepare(
172
+			'SELECT COUNT(majat_name)' .
173
+			' FROM `##maj_admintasks`'
174
+			)->execute()->fetchOne();
175
+	}
176 176
 	
177
-    /**
178
-     * {@inheritDoc}
179
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getTasksToRun()
180
-     */
177
+	/**
178
+	 * {@inheritDoc}
179
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getTasksToRun()
180
+	 */
181 181
 	public function getTasksToRun($force = false, $task_name = null) 
182 182
 	{
183 183
 		$res = array();
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 		$data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
207 207
 		
208 208
 		foreach($data as $task_row) {
209
-            $task = $this->loadTaskFromRow($task_row);
209
+			$task = $this->loadTaskFromRow($task_row);
210 210
 			if($task)
211 211
 			{
212 212
 				$res[] = $task;
213 213
 			} 
214
-        }
214
+		}
215 215
 		
216 216
 		return $res;	
217 217
 	}
@@ -220,69 +220,69 @@  discard block
 block discarded – undo
220 220
 	 * {@inheritDoc}
221 221
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getFilteredTasksList()
222 222
 	 */
223
-    public function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null){
224
-        $res = array();
223
+	public function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null){
224
+		$res = array();
225 225
             
226
-        $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' .
227
-            ' FROM `##maj_admintasks`';
226
+		$sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' .
227
+			' FROM `##maj_admintasks`';
228 228
         
229
-        $args = array();
229
+		$args = array();
230 230
                 
231
-        if ($order_by) {
232
-            $sql .= ' ORDER BY ';
233
-            $i = 0;
234
-            foreach ($order_by as $key => $value) {
235
-                if ($i > 0) {
236
-                    $sql .= ',';
237
-                }
231
+		if ($order_by) {
232
+			$sql .= ' ORDER BY ';
233
+			$i = 0;
234
+			foreach ($order_by as $key => $value) {
235
+				if ($i > 0) {
236
+					$sql .= ',';
237
+				}
238 238
                 
239
-                switch ($value['dir']) {
240
-                    case 'asc':
241
-                        $sql .= $value['column'] . ' ASC ';
242
-                        break;
243
-                    case 'desc':
244
-                        $sql .= $value['column'] . ' DESC ';
245
-                        break;
246
-                }
247
-                $i++;
248
-            }
249
-        } else {
250
-            $sql .= ' ORDER BY majat_name ASC';
251
-        }
239
+				switch ($value['dir']) {
240
+					case 'asc':
241
+						$sql .= $value['column'] . ' ASC ';
242
+						break;
243
+					case 'desc':
244
+						$sql .= $value['column'] . ' DESC ';
245
+						break;
246
+				}
247
+				$i++;
248
+			}
249
+		} else {
250
+			$sql .= ' ORDER BY majat_name ASC';
251
+		}
252 252
         
253
-        if ($limit) {
254
-            $sql .= ' LIMIT :limit OFFSET :offset';
255
-            $args['limit']  = $limit;
256
-            $args['offset'] = $start;
257
-        }
253
+		if ($limit) {
254
+			$sql .= ' LIMIT :limit OFFSET :offset';
255
+			$args['limit']  = $limit;
256
+			$args['offset'] = $start;
257
+		}
258 258
             
259
-        $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
259
+		$data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
260 260
 
261
-        foreach($data as $ga) {
262
-            $task = $this->loadTaskFromRow($ga);
261
+		foreach($data as $ga) {
262
+			$task = $this->loadTaskFromRow($ga);
263 263
 			if($task && (empty($search) || ($search && strpos($task->getTitle(), $search) !== false)))
264 264
 			{
265 265
 				$res[] = $task;
266 266
 			}
267
-        }
267
+		}
268 268
 		
269
-        return $res;
270
-    }
269
+		return $res;
270
+	}
271 271
 	
272 272
 	
273
-    /**
274
-     * {inhericDoc}
275
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getInstalledTasks()
276
-     */
273
+	/**
274
+	 * {inhericDoc}
275
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getInstalledTasks()
276
+	 */
277 277
 	public function getInstalledTasks() {
278 278
 		$tasks=array();
279 279
 		$dir=opendir($this->root_path);
280 280
 		while (($file=readdir($dir))!==false){ 
281 281
 			try {
282
-			    if($file == '.' || $file == '..') continue;
282
+				if($file == '.' || $file == '..') continue;
283 283
 				$task = include $this->root_path . $file;
284 284
 				if($task ) {
285
-				    $task->setProvider($this);
285
+					$task->setProvider($this);
286 286
 					Database::prepare(
287 287
 						'INSERT IGNORE INTO `##maj_admintasks`'.
288 288
 						' (majat_name, majat_status, majat_frequency)'.
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
      */
43 43
 	protected function loadTask($task_name) {
44 44
 		try {
45
-			if (file_exists($this->root_path . $task_name .'.php')) {
46
-				$task = include $this->root_path . $task_name .'.php';
47
-				if($task instanceof AbstractTask) {
45
+			if (file_exists($this->root_path.$task_name.'.php')) {
46
+				$task = include $this->root_path.$task_name.'.php';
47
+				if ($task instanceof AbstractTask) {
48 48
 				    $task->setProvider($this);
49 49
 					return $task;
50 50
 				}
51 51
 			}
52 52
 		}
53
-		catch(\Exception $ex) { }
53
+		catch (\Exception $ex) { }
54 54
 		
55 55
 		return null;
56 56
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     protected function loadTaskFromRow($row) {
73 73
         $task = $this->loadTask($row['majat_name']);
74 74
         
75
-		if($task) {
75
+		if ($task) {
76 76
 			$task->setParameters(
77 77
 				$row['majat_status'] == 'enabled',
78 78
 				new \DateTime($row['majat_last_run']), 
@@ -95,21 +95,21 @@  discard block
 block discarded – undo
95 95
      * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getTask()
96 96
      */
97 97
     public function getTask($task_name, $only_enabled = true) {
98
-        $args = array (
98
+        $args = array(
99 99
             'task_name' => $task_name
100 100
         );
101 101
     
102
-        $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' .
103
-            ' FROM `##maj_admintasks`' .
102
+        $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running'.
103
+            ' FROM `##maj_admintasks`'.
104 104
             ' WHERE majat_name = :task_name';
105
-        if($only_enabled) {
105
+        if ($only_enabled) {
106 106
             $sql .= ' AND majat_status = :status';
107 107
             $args['status'] = 'enabled';
108 108
         }
109 109
     
110 110
         $task_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC);
111 111
     
112
-        if($task_array) {
112
+        if ($task_array) {
113 113
             return $this->loadTaskFromRow($task_array);
114 114
         }
115 115
     
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::updateTask()
137 137
     */
138 138
     public function updateTask(AbstractTask $task) {        
139
-        try{
139
+        try {
140 140
             Database::prepare(
141 141
                 'UPDATE `##maj_admintasks`'.
142 142
                 ' SET majat_status = :status,'.
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
     public function getTasksCount() {
171 171
         return Database::prepare(
172
-            'SELECT COUNT(majat_name)' .
172
+            'SELECT COUNT(majat_name)'.
173 173
             ' FROM `##maj_admintasks`'
174 174
             )->execute()->fetchOne();
175 175
     }
@@ -194,20 +194,20 @@  discard block
 block discarded – undo
194 194
 			'time_out' => AbstractTask::TASK_TIME_OUT		
195 195
 		);
196 196
 		
197
-		if(!$force) {
197
+		if (!$force) {
198 198
 			$sql .= ' AND (DATE_ADD(majat_last_run, INTERVAL majat_frequency MINUTE) <= NOW() OR majat_last_result = 0)';
199 199
 		}
200 200
 		
201
-		if($task_name) {
201
+		if ($task_name) {
202 202
 			$sql .= ' AND majat_name = :task_name';
203 203
 			$args['task_name'] = $task_name;
204 204
 		}
205 205
 		
206 206
 		$data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
207 207
 		
208
-		foreach($data as $task_row) {
208
+		foreach ($data as $task_row) {
209 209
             $task = $this->loadTaskFromRow($task_row);
210
-			if($task)
210
+			if ($task)
211 211
 			{
212 212
 				$res[] = $task;
213 213
 			} 
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 	 * {@inheritDoc}
221 221
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getFilteredTasksList()
222 222
 	 */
223
-    public function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null){
223
+    public function getFilteredTasksList($search = null, $order_by = null, $start = 0, $limit = null) {
224 224
         $res = array();
225 225
             
226
-        $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running' .
226
+        $sql = 'SELECT majat_name, majat_status, majat_last_run, majat_last_result, majat_frequency, majat_nb_occur, majat_running'.
227 227
             ' FROM `##maj_admintasks`';
228 228
         
229 229
         $args = array();
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
                 
239 239
                 switch ($value['dir']) {
240 240
                     case 'asc':
241
-                        $sql .= $value['column'] . ' ASC ';
241
+                        $sql .= $value['column'].' ASC ';
242 242
                         break;
243 243
                     case 'desc':
244
-                        $sql .= $value['column'] . ' DESC ';
244
+                        $sql .= $value['column'].' DESC ';
245 245
                         break;
246 246
                 }
247 247
                 $i++;
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
             
259 259
         $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC);
260 260
 
261
-        foreach($data as $ga) {
261
+        foreach ($data as $ga) {
262 262
             $task = $this->loadTaskFromRow($ga);
263
-			if($task && (empty($search) || ($search && strpos($task->getTitle(), $search) !== false)))
263
+			if ($task && (empty($search) || ($search && strpos($task->getTitle(), $search) !== false)))
264 264
 			{
265 265
 				$res[] = $task;
266 266
 			}
@@ -275,13 +275,13 @@  discard block
 block discarded – undo
275 275
      * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::getInstalledTasks()
276 276
      */
277 277
 	public function getInstalledTasks() {
278
-		$tasks=array();
279
-		$dir=opendir($this->root_path);
280
-		while (($file=readdir($dir))!==false){ 
278
+		$tasks = array();
279
+		$dir = opendir($this->root_path);
280
+		while (($file = readdir($dir)) !== false) { 
281 281
 			try {
282
-			    if($file == '.' || $file == '..') continue;
283
-				$task = include $this->root_path . $file;
284
-				if($task ) {
282
+			    if ($file == '.' || $file == '..') continue;
283
+				$task = include $this->root_path.$file;
284
+				if ($task) {
285 285
 				    $task->setProvider($this);
286 286
 					Database::prepare(
287 287
 						'INSERT IGNORE INTO `##maj_admintasks`'.
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 				}
301 301
 			}
302 302
 			catch (\Exception $ex) {
303
-				Log::addErrorLog('An error occured while trying to load the task in file ' . $file . '. Exception: ' . $ex->getMessage());
303
+				Log::addErrorLog('An error occured while trying to load the task in file '.$file.'. Exception: '.$ex->getMessage());
304 304
 			}
305 305
 		}
306 306
 		return $tasks;
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 	 * {inhericDoc}
312 312
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::deleteTask()
313 313
 	 */
314
-	public function deleteTask($task_name){
315
-		try{
314
+	public function deleteTask($task_name) {
315
+		try {
316 316
 			Database::beginTransaction();
317 317
 			
318 318
 			Database::prepare('DELETE FROM  `##maj_admintasks` WHERE majat_name= :task_name')
319 319
 				->execute(array('task_name' => $task_name));
320 320
 			Database::prepare('DELETE FROM  `##gedcom_setting` WHERE setting_name LIKE :setting_name')
321
-				->execute(array('setting_name' => 'MAJ_AT_' . $task_name .'%'));
321
+				->execute(array('setting_name' => 'MAJ_AT_'.$task_name.'%'));
322 322
 				
323 323
 			Database::commit();
324 324
 			
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 			
327 327
 			return true;
328 328
 		}
329
-		catch(\Exception $ex) {
329
+		catch (\Exception $ex) {
330 330
 			Database::rollback();
331 331
 		
332
-			Log::addErrorLog('An error occurred while deleting Admin Task '.$task_name.'. Exception: '. $ex->getMessage());
332
+			Log::addErrorLog('An error occurred while deleting Admin Task '.$task_name.'. Exception: '.$ex->getMessage());
333 333
 			return false;
334 334
 		}
335 335
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
 					return $task;
50 50
 				}
51 51
 			}
52
-		}
53
-		catch(\Exception $ex) { }
52
+		} catch(\Exception $ex) { }
54 53
 		
55 54
 		return null;
56 55
 	}
@@ -83,8 +82,7 @@  discard block
 block discarded – undo
83 82
 				);
84 83
         
85 84
 			return $task;
86
-		}
87
-		else {
85
+		} else {
88 86
 		    $this->deleteTask($row['majat_name']);
89 87
 		}
90 88
 		return null;
@@ -156,8 +154,7 @@  discard block
 block discarded – undo
156 154
                     'is_running' => $task->isRunning() ? 1 : 0
157 155
                 ));
158 156
             return true;
159
-        }
160
-        catch (\Exception $ex) {
157
+        } catch (\Exception $ex) {
161 158
             Log::addErrorLog(sprintf('Error while updating the Admin Task %s. Exception: %s', $task->getName(), $ex->getMessage()));
162 159
             return false;
163 160
         }        
@@ -279,7 +276,9 @@  discard block
 block discarded – undo
279 276
 		$dir=opendir($this->root_path);
280 277
 		while (($file=readdir($dir))!==false){ 
281 278
 			try {
282
-			    if($file == '.' || $file == '..') continue;
279
+			    if($file == '.' || $file == '..') {
280
+			    	continue;
281
+			    }
283 282
 				$task = include $this->root_path . $file;
284 283
 				if($task ) {
285 284
 				    $task->setProvider($this);
@@ -294,12 +293,10 @@  discard block
 block discarded – undo
294 293
 					));
295 294
 					
296 295
 					$tasks[] = $task;
297
-				}
298
-				else {
296
+				} else {
299 297
 					throw new \Exception;
300 298
 				}
301
-			}
302
-			catch (\Exception $ex) {
299
+			} catch (\Exception $ex) {
303 300
 				Log::addErrorLog('An error occured while trying to load the task in file ' . $file . '. Exception: ' . $ex->getMessage());
304 301
 			}
305 302
 		}
@@ -325,8 +322,7 @@  discard block
 block discarded – undo
325 322
 			Log::addConfigurationLog('Admin Task '.$task_name.' has been deleted from disk - deleting it from DB');
326 323
 			
327 324
 			return true;
328
-		}
329
-		catch(\Exception $ex) {
325
+		} catch(\Exception $ex) {
330 326
 			Database::rollback();
331 327
 		
332 328
 			Log::addErrorLog('An error occurred while deleting Admin Task '.$task_name.'. Exception: '. $ex->getMessage());
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Tasks/HealthCheckEmailTask.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -185,8 +185,7 @@  discard block
 block discarded – undo
185 185
 						I18N::translate('Error').Mail::EOL.
186 186
 						str_repeat('-', $nb_char_count_title)."\t".str_repeat('-', $nb_char_type)."\t".str_repeat('-', 20)."\t".str_repeat('-', strlen(I18N::translate('Error'))).Mail::EOL.
187 187
 						$tmp_message.Mail::EOL;
188
-				}
189
-				else{
188
+				} else{
190 189
 					$message .= I18N::translate('No errors', $nb_errors).Mail::EOL.Mail::EOL;
191 190
 				}
192 191
 				
@@ -251,8 +250,7 @@  discard block
 block discarded – undo
251 250
 				}
252 251
 			}
253 252
 			return true;
254
-		}
255
-		catch (\Exception $ex) {
253
+		} catch (\Exception $ex) {
256 254
 			Log::addErrorLog(sprintf('Error while updating the Admin Task "%s". Exception: %s', $this->getName(), $ex->getMessage()));
257 255
 			return false;
258 256
 		}
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class HealthCheckEmailTask extends AbstractTask implements ConfigurableTaskInterface {
31 31
     
32
-    /**
33
-     * {@inheritDoc}
34
-     * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle()
35
-     */
36
-    public function getTitle() {
32
+	/**
33
+	 * {@inheritDoc}
34
+	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle()
35
+	 */
36
+	public function getTitle() {
37 37
 		return I18N::translate('Healthcheck Email');
38 38
 	}
39 39
 	
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * {@inheritDoc}
42 42
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency()
43 43
 	 */
44
-    public function getDefaultFrequency() {
44
+	public function getDefaultFrequency() {
45 45
 		return 10080;  // = 1 week = 7 * 24 * 60 min
46 46
 	}
47 47
     
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * {@inheritDoc}
50 50
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::executeSteps()
51 51
 	 */
52
-    protected function executeSteps() {
52
+	protected function executeSteps() {
53 53
 	
54 54
 		$res = false;		
55 55
 		
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
 		$interval = max($this->frequency, $interval_sincelast);
64 64
 		$nbdays = ceil($interval / (24 * 60));
65 65
 				
66
-        // Check for updates
67
-        $latest_version_txt = Functions::fetchLatestVersion();
68
-        if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) {
69
-        	list($latest_version, , $download_url) = explode('|', $latest_version_txt);
70
-        } else {
71
-        	// Cannot determine the latest version
72
-        	list($latest_version, , $download_url) = explode('|', '||');
73
-        }
66
+		// Check for updates
67
+		$latest_version_txt = Functions::fetchLatestVersion();
68
+		if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) {
69
+			list($latest_version, , $download_url) = explode('|', $latest_version_txt);
70
+		} else {
71
+			// Cannot determine the latest version
72
+			list($latest_version, , $download_url) = explode('|', '||');
73
+		}
74 74
 		
75 75
 		// Users statistics
76 76
 		$warnusers = 0;
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 		$html = '
214 214
 			<div class="form-group">
215 215
     			<label class="control-label col-sm-3"> '.
216
-    				I18N::translate('Enable healthcheck emails for') .
217
-    			'</label>
216
+					I18N::translate('Enable healthcheck emails for') .
217
+				'</label>
218 218
     			<div class="col-sm-9">';
219 219
 
220 220
 		foreach(Tree::getAll() as $tree){
221 221
 			if(Auth::isManager($tree)){	
222
-			    $html .= '<div class="form-group row">
222
+				$html .= '<div class="form-group row">
223 223
 			        <span class="col-sm-3 control-label">' .
224
-			             $tree->getTitle() .
224
+						 $tree->getTitle() .
225 225
 					'</span>
226 226
 					 <div class="col-sm-2">';
227 227
 				$html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"');
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 		}
231 231
 		
232 232
 		$html .= '	<p class="small text-muted">'.
233
-    					I18N::translate('Enable the health check emails for each of the selected trees.') .
234
-    				'</p>
233
+						I18N::translate('Enable the health check emails for each of the selected trees.') .
234
+					'</p>
235 235
     			</div>
236 236
     		</div>';
237 237
 			
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency()
43 43
 	 */
44 44
     public function getDefaultFrequency() {
45
-		return 10080;  // = 1 week = 7 * 24 * 60 min
45
+		return 10080; // = 1 week = 7 * 24 * 60 min
46 46
 	}
47 47
     
48 48
 	/**
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 		
56 56
 		// Get the number of days to take into account, either last 7 days or since last check
57 57
 		$interval_sincelast = 0;
58
-		if($this->last_updated){
58
+		if ($this->last_updated) {
59 59
 			$tmpInt = $this->last_updated->diff(new \DateTime('now'), true);
60
-			$interval_sincelast = ( $tmpInt->days * 24  + $tmpInt->h ) * 60 + $tmpInt->i;
60
+			$interval_sincelast = ($tmpInt->days * 24 + $tmpInt->h) * 60 + $tmpInt->i;
61 61
 		}
62 62
 		
63 63
 		$interval = max($this->frequency, $interval_sincelast);
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
         // Check for updates
67 67
         $latest_version_txt = Functions::fetchLatestVersion();
68 68
         if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) {
69
-        	list($latest_version, , $download_url) = explode('|', $latest_version_txt);
69
+        	list($latest_version,, $download_url) = explode('|', $latest_version_txt);
70 70
         } else {
71 71
         	// Cannot determine the latest version
72
-        	list($latest_version, , $download_url) = explode('|', '||');
72
+        	list($latest_version,, $download_url) = explode('|', '||');
73 73
         }
74 74
 		
75 75
 		// Users statistics
76 76
 		$warnusers = 0;
77 77
 		$nverusers = 0;
78 78
 		$applusers = 0;
79
-		foreach(User::all() as $user) {
79
+		foreach (User::all() as $user) {
80 80
 			if (((date("U") - (int)$user->getPreference('reg_timestamp')) > 604800) && !$user->getPreference('verified')) {
81 81
 				$warnusers++;
82 82
 			}
@@ -90,20 +90,20 @@  discard block
 block discarded – undo
90 90
 		
91 91
 		// Tree specifics checks
92 92
 		$one_tree_done = false;
93
-		foreach(Tree::getAll() as $tree){
93
+		foreach (Tree::getAll() as $tree) {
94 94
 			$isTreeEnabled = $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED');
95
-			if((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))){
95
+			if ((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))) {
96 96
 				I18N::init($webmaster->getPreference('language'));
97 97
 				
98 98
 				$subject = I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->getTitle());
99 99
 				$message = 
100
-					I18N::translate('Health Check Report for the last %d days', $nbdays). Mail::EOL. Mail::EOL.
100
+					I18N::translate('Health Check Report for the last %d days', $nbdays).Mail::EOL.Mail::EOL.
101 101
 					I18N::translate('Tree %s', $tree->getTitle()).Mail::EOL.
102 102
 					'=========================================='.Mail::EOL.Mail::EOL;
103 103
 				
104 104
 				// News
105 105
 				$message_version = '';
106
-				if($latest_version && version_compare(WT_VERSION, $latest_version)<0){
106
+				if ($latest_version && version_compare(WT_VERSION, $latest_version) < 0) {
107 107
 					$message_version = I18N::translate('News').Mail::EOL.
108 108
 							'-------------'.Mail::EOL.
109 109
 							I18N::translate('A new version of *webtrees* is available: %s. Upgrade as soon as possible.', $latest_version).Mail::EOL.
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 						I18N::translate('Not verified by the user')."\t\t".$applusers.Mail::EOL.
120 120
 						I18N::translate('Not approved by an administrator')."\t".$nverusers.Mail::EOL.
121 121
 						Mail::EOL;
122
-				$message  .= $message_users;
122
+				$message .= $message_users;
123 123
 								
124 124
 				// Statistics tree:				
125 125
 				$stats = new Stats($tree);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 							' AND log_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)'.
160 160
 							' GROUP BY log_message, gedcom_id'.
161 161
 							' ORDER BY lastoccurred DESC';
162
-				$errors=Database::prepare($sql)->execute(array(
162
+				$errors = Database::prepare($sql)->execute(array(
163 163
 					'log_type' => Log::TYPE_ERROR, 
164 164
 					'gedcom_id' => $tree->getTreeId(), 
165 165
 					'nb_days' => $nbdays
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 					$tmp_message .= str_replace("\n", "\n\t\t\t\t\t\t", $error->log_message).Mail::EOL;
176 176
 					$nb_errors += $error->nblogs;
177 177
 				}
178
-				if($nb_errors > 0){
178
+				if ($nb_errors > 0) {
179 179
 					$message .= I18N::translate('Errors [%d]', $nb_errors).Mail::EOL.
180 180
 						'-------------'.Mail::EOL.
181 181
 						WT_BASE_URL.'admin_site_logs.php'.Mail::EOL.
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 						str_repeat('-', $nb_char_count_title)."\t".str_repeat('-', $nb_char_type)."\t".str_repeat('-', 20)."\t".str_repeat('-', strlen(I18N::translate('Error'))).Mail::EOL.
187 187
 						$tmp_message.Mail::EOL;
188 188
 				}
189
-				else{
189
+				else {
190 190
 					$message .= I18N::translate('No errors', $nb_errors).Mail::EOL.Mail::EOL;
191 191
 				}
192 192
 				
193 193
 				$tmpres = true;
194
-				if($webmaster->getPreference('contactmethod') !== 'messaging' 
194
+				if ($webmaster->getPreference('contactmethod') !== 'messaging' 
195 195
 						&& $webmaster->getPreference('contactmethod') !== 'none') {
196 196
 					$tmpres = Mail::systemMessage($tree, $webmaster, $subject, $message);
197 197
 				}		
@@ -213,24 +213,24 @@  discard block
 block discarded – undo
213 213
 		$html = '
214 214
 			<div class="form-group">
215 215
     			<label class="control-label col-sm-3"> '.
216
-    				I18N::translate('Enable healthcheck emails for') .
216
+    				I18N::translate('Enable healthcheck emails for').
217 217
     			'</label>
218 218
     			<div class="col-sm-9">';
219 219
 
220
-		foreach(Tree::getAll() as $tree){
221
-			if(Auth::isManager($tree)){	
220
+		foreach (Tree::getAll() as $tree) {
221
+			if (Auth::isManager($tree)) {	
222 222
 			    $html .= '<div class="form-group row">
223 223
 			        <span class="col-sm-3 control-label">' .
224
-			             $tree->getTitle() .
224
+			             $tree->getTitle().
225 225
 					'</span>
226 226
 					 <div class="col-sm-2">';
227
-				$html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"');
227
+				$html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"');
228 228
 				$html .= '</div></div>';
229 229
 			}
230 230
 		}
231 231
 		
232 232
 		$html .= '	<p class="small text-muted">'.
233
-    					I18N::translate('Enable the health check emails for each of the selected trees.') .
233
+    					I18N::translate('Enable the health check emails for each of the selected trees.').
234 234
     				'</p>
235 235
     			</div>
236 236
     		</div>';
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function saveConfig() {
246 246
 		try {
247
-			foreach(Tree::getAll() as $tree){		
248
-				if(Auth::isManager($tree)){
249
-					$tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), 0, 1);
247
+			foreach (Tree::getAll() as $tree) {		
248
+				if (Auth::isManager($tree)) {
249
+					$tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), 0, 1);
250 250
 					$tree->setPreference('MAJ_AT_'.$this->getName().'_ENABLED', $tree_enabled);
251 251
 				}
252 252
 			}
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/AdminConfigController.php 3 patches
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -187,7 +187,9 @@  discard block
 block discarded – undo
187 187
     
188 188
         // Generate an AJAX/JSON response for datatables to load a block of rows
189 189
         $search = Filter::postArray('search');
190
-        if($search) $search = $search['value'];
190
+        if($search) {
191
+        	$search = $search['value'];
192
+        }
191 193
         $start  = Filter::postInteger('start');
192 194
         $length = Filter::postInteger('length');
193 195
         $order  = Filter::postArray('order');
@@ -261,8 +263,7 @@  discard block
 block discarded – undo
261 263
     			    <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')">
262 264
     			         <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div>
263 265
     			    </button>';
264
-			}
265
-			else {
266
+			} else {
266 267
 			    $datum[9] = '';
267 268
 			}			    
268 269
 						
Please login to merge, or discard this patch.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -35,37 +35,37 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class AdminConfigController extends MvcController
37 37
 {    
38
-    /**
39
-     * Tasks Provider
40
-     * @var TaskProviderInterface $provider
41
-     */
42
-    protected $provider;    
38
+	/**
39
+	 * Tasks Provider
40
+	 * @var TaskProviderInterface $provider
41
+	 */
42
+	protected $provider;    
43 43
     
44
-    /**
45
-     * Constructor for Admin Config controller
46
-     * @param \Fisharebest\Webtrees\Module\AbstractModule $module
47
-     */
48
-    public function __construct(AbstractModule $module) {
49
-        parent::__construct($module);
44
+	/**
45
+	 * Constructor for Admin Config controller
46
+	 * @param \Fisharebest\Webtrees\Module\AbstractModule $module
47
+	 */
48
+	public function __construct(AbstractModule $module) {
49
+		parent::__construct($module);
50 50
         
51
-        $this->provider = $this->module->getProvider();
52
-    }    
51
+		$this->provider = $this->module->getProvider();
52
+	}    
53 53
     
54
-    /**
55
-     * Pages
56
-     */
54
+	/**
55
+	 * Pages
56
+	 */
57 57
         
58
-    /**
59
-     * AdminConfig@index
60
-     */
61
-    public function index() {
58
+	/**
59
+	 * AdminConfig@index
60
+	 */
61
+	public function index() {
62 62
         
63
-        $tree = Globals::getTree();
64
-        Theme::theme(new AdministrationTheme)->init($tree);
65
-        $controller = new PageController();
66
-        $controller
67
-            ->restrictAccess(Auth::isAdmin())
68
-            ->setPageTitle($this->module->getTitle());
63
+		$tree = Globals::getTree();
64
+		Theme::theme(new AdministrationTheme)->init($tree);
65
+		$controller = new PageController();
66
+		$controller
67
+			->restrictAccess(Auth::isAdmin())
68
+			->setPageTitle($this->module->getTitle());
69 69
 			
70 70
 		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
71 71
 		if(is_null($token)) {
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 			$this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token);
74 74
 		}
75 75
         
76
-        $data = new ViewBag();
77
-        $data->set('title', $controller->getPageTitle());
76
+		$data = new ViewBag();
77
+		$data->set('title', $controller->getPageTitle());
78 78
         
79
-        $table_id = 'table-admintasks-' . Uuid::uuid4();
80
-        $data->set('table_id', $table_id);
79
+		$table_id = 'table-admintasks-' . Uuid::uuid4();
80
+		$data->set('table_id', $table_id);
81 81
 		
82 82
 		$data->set('trigger_url_root', WT_BASE_URL.'module.php?mod='.$this->module->getName().'&mod_action=Task@trigger');
83 83
 		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 		$this->provider->getInstalledTasks();
91 91
 		
92 92
 		$controller
93
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
94
-            ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
95
-            ->addInlineJavascript('
93
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
94
+			->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
95
+			->addInlineJavascript('
96 96
                 //Datatable initialisation
97 97
 				jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
98 98
 				jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 				});
125 125
                 
126 126
                 ')
127
-                ->addInlineJavascript('					
127
+				->addInlineJavascript('					
128 128
 					function generate_force_token() {
129 129
 						jQuery("#bt_genforcetoken").attr("disabled", "disabled");
130 130
 						jQuery("#bt_tokentext").empty().html("<i class=\"fa fa-spinner fa-pulse fa-fw\"></i>");
@@ -172,54 +172,54 @@  discard block
 block discarded – undo
172 172
                     } 
173 173
                 ');
174 174
         
175
-        ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
176
-    }
175
+		ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
176
+	}
177 177
     
178
-    /**
179
-     * AdminConfig@jsonTasksList
180
-     */
181
-    public function jsonTasksList() {    
182
-        $controller = new JsonController();
183
-        $controller
184
-            ->restrictAccess(Auth::isAdmin());
178
+	/**
179
+	 * AdminConfig@jsonTasksList
180
+	 */
181
+	public function jsonTasksList() {    
182
+		$controller = new JsonController();
183
+		$controller
184
+			->restrictAccess(Auth::isAdmin());
185 185
     
186
-        // Generate an AJAX/JSON response for datatables to load a block of rows
187
-        $search = Filter::postArray('search');
188
-        if($search) $search = $search['value'];
189
-        $start  = Filter::postInteger('start');
190
-        $length = Filter::postInteger('length');
191
-        $order  = Filter::postArray('order');
186
+		// Generate an AJAX/JSON response for datatables to load a block of rows
187
+		$search = Filter::postArray('search');
188
+		if($search) $search = $search['value'];
189
+		$start  = Filter::postInteger('start');
190
+		$length = Filter::postInteger('length');
191
+		$order  = Filter::postArray('order');
192 192
     
193 193
 		$order_by_name = false;
194
-        foreach($order as $key => &$value) {
195
-            switch($value['column']) {
196
-                case 3:
194
+		foreach($order as $key => &$value) {
195
+			switch($value['column']) {
196
+				case 3:
197 197
 					$order_by_name = true;
198
-                    unset($order[$key]);
199
-                    break;
200
-                case 4;
198
+					unset($order[$key]);
199
+					break;
200
+				case 4;
201 201
 					$value['column'] = 'majat_last_run';
202 202
 					break;
203 203
 				case 4;
204 204
 					$value['column'] = 'majat_last_result';
205 205
 					break;
206
-                default:
207
-                    unset($order[$key]);
208
-            }
209
-        }
206
+				default:
207
+					unset($order[$key]);
208
+			}
209
+		}
210 210
     
211
-        $list = $this->provider->getFilteredTasksList($search, $order, $start, $length);
211
+		$list = $this->provider->getFilteredTasksList($search, $order, $start, $length);
212 212
 		if($order_by_name) {
213 213
 			usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); });
214 214
 		}
215
-        $recordsFiltered = count($list);
216
-        $recordsTotal = $this->provider->getTasksCount();
215
+		$recordsFiltered = count($list);
216
+		$recordsTotal = $this->provider->getTasksCount();
217 217
     
218
-        $data = array();
219
-        foreach($list as $task) {    
220
-            $datum = array();
218
+		$data = array();
219
+		foreach($list as $task) {    
220
+			$datum = array();
221 221
 			
222
-            $datum[0] = '
222
+			$datum[0] = '
223 223
                 <div class="btn-group">
224 224
                     <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
225 225
                         <i class="fa fa-pencil"></i><span class="caret"></span>
@@ -237,50 +237,50 @@  discard block
 block discarded – undo
237 237
                        </li>
238 238
                     </ul>
239 239
                 </div>';
240
-            $datum[1] = $task->getName();
241
-            $datum[2] = $task->isEnabled() ? 
240
+			$datum[1] = $task->getName();
241
+			$datum[2] = $task->isEnabled() ? 
242 242
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : 
243 243
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
244
-            $datum[3] = $task->getTitle();
245
-            $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s';
244
+			$datum[3] = $task->getTitle();
245
+			$date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s';
246 246
 			$datum[4] = $task->getLastUpdated()->format($date_format);
247
-            $datum[5] = $task->isLastRunSuccess() ? 
247
+			$datum[5] = $task->isLastRunSuccess() ? 
248 248
 				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : 
249 249
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
250
-            $dtF = new \DateTime('@0');
251
-            $dtT = new \DateTime('@' . ($task->getFrequency() * 60));            
252
-            $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m'));
250
+			$dtF = new \DateTime('@0');
251
+			$dtT = new \DateTime('@' . ($task->getFrequency() * 60));            
252
+			$datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m'));
253 253
 			$datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited');
254 254
 			$datum[8] = $task->isRunning() ? 
255 255
 				'<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : 
256 256
 				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>';
257 257
 			if($task->isEnabled() && !$task->isRunning()) {
258
-			    $datum[9] = '
258
+				$datum[9] = '
259 259
     			    <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')">
260 260
     			         <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div>
261 261
     			    </button>';
262 262
 			}
263 263
 			else {
264
-			    $datum[9] = '';
264
+				$datum[9] = '';
265 265
 			}			    
266 266
 						
267
-            $data[] = $datum;
268
-        }
267
+			$data[] = $datum;
268
+		}
269 269
     
270
-        $controller->pageHeader();
270
+		$controller->pageHeader();
271 271
     
272
-        $controller->encode(array(
273
-            'draw'            => Filter::getInteger('draw'),
274
-            'recordsTotal'    => $recordsTotal,
275
-            'recordsFiltered' => $recordsFiltered,
276
-            'data'            => $data
277
-        ));
272
+		$controller->encode(array(
273
+			'draw'            => Filter::getInteger('draw'),
274
+			'recordsTotal'    => $recordsTotal,
275
+			'recordsFiltered' => $recordsFiltered,
276
+			'data'            => $data
277
+		));
278 278
     
279
-    }
279
+	}
280 280
 		
281 281
 	/**
282 282
 	 * AdminConfig@generateToken
283
-     *
283
+	 *
284 284
 	 * Ajax call to generate a new token. Display the token, if generated.
285 285
 	 * Tokens call only be generated by a site administrator.
286 286
 	 *
Please login to merge, or discard this patch.
Spacing   +22 added lines, -25 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             ->setPageTitle($this->module->getTitle());
69 69
 			
70 70
 		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
71
-		if(is_null($token)) {
71
+		if (is_null($token)) {
72 72
 			$token = Functions::generateRandomToken();
73 73
 			$this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token);
74 74
 		}
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
         $data = new ViewBag();
77 77
         $data->set('title', $controller->getPageTitle());
78 78
         
79
-        $table_id = 'table-admintasks-' . Uuid::uuid4();
79
+        $table_id = 'table-admintasks-'.Uuid::uuid4();
80 80
         $data->set('table_id', $table_id);
81 81
 		
82 82
 		$data->set('trigger_url_root', WT_BASE_URL.'module.php?mod='.$this->module->getName().'&mod_action=Task@trigger');
83 83
 		$token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
84
-		if(is_null($token)) {
84
+		if (is_null($token)) {
85 85
 			$token = Functions::generateRandomToken();
86 86
 			$this->module->setSetting('MAJ_AT_FORCE_EXEC_TOKEN', $token);
87 87
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                     processing: true,
107 107
                     serverSide : true,
108 108
 					ajax : {
109
-						url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonTasksList&ged='. $tree->getNameUrl().'",
109
+						url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonTasksList&ged='.$tree->getNameUrl().'",
110 110
                         type : "POST"
111 111
 					},
112 112
                     columns: [
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
                             url: "module.php", 
144 144
                             type: "GET",
145 145
                             data: {
146
-                			    mod: "' . $this->module->getName() .'",
146
+                			    mod: "' . $this->module->getName().'",
147 147
                                 mod_action:  "Task@setStatus",
148 148
                 			    task: task,
149 149
                                 status: status
150 150
                             },
151 151
                             error: function(result, stat, error) {
152 152
                                 var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
153
-                                alert("' . I18N::translate('An error occured while editing this task:') . '" + err);
153
+                                alert("' . I18N::translate('An error occured while editing this task:').'" + err);
154 154
                             },
155 155
                             complete: function(result, stat) {
156 156
                                 adminTasksTable.ajax.reload(null, false);
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
     
186 186
         // Generate an AJAX/JSON response for datatables to load a block of rows
187 187
         $search = Filter::postArray('search');
188
-        if($search) $search = $search['value'];
188
+        if ($search) $search = $search['value'];
189 189
         $start  = Filter::postInteger('start');
190 190
         $length = Filter::postInteger('length');
191 191
         $order  = Filter::postArray('order');
192 192
     
193 193
 		$order_by_name = false;
194
-        foreach($order as $key => &$value) {
195
-            switch($value['column']) {
194
+        foreach ($order as $key => &$value) {
195
+            switch ($value['column']) {
196 196
                 case 3:
197 197
 					$order_by_name = true;
198 198
                     unset($order[$key]);
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
         }
210 210
     
211 211
         $list = $this->provider->getFilteredTasksList($search, $order, $start, $length);
212
-		if($order_by_name) {
212
+		if ($order_by_name) {
213 213
 			usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); });
214 214
 		}
215 215
         $recordsFiltered = count($list);
216 216
         $recordsTotal = $this->provider->getTasksCount();
217 217
     
218 218
         $data = array();
219
-        foreach($list as $task) {    
219
+        foreach ($list as $task) {    
220 220
             $datum = array();
221 221
 			
222 222
             $datum[0] = '
@@ -227,37 +227,34 @@  discard block
 block discarded – undo
227 227
                     <ul class="dropdown-menu" role="menu">
228 228
                        <li>
229 229
                             <a href="#" onclick="return set_admintask_status(\''. $task->getName().'\', '.($task->isEnabled() ? 'false' : 'true').');">
230
-                                <i class="fa fa-fw '.($task->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . '
230
+                                <i class="fa fa-fw '.($task->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).'
231 231
                             </a>
232 232
                        </li>
233 233
                         <li>
234
-                            <a href="module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='. $task->getName().'">
235
-                                <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . '
234
+                            <a href="module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='.$task->getName().'">
235
+                                <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').'
236 236
                             </a>
237 237
                        </li>
238 238
                     </ul>
239 239
                 </div>';
240 240
             $datum[1] = $task->getName();
241 241
             $datum[2] = $task->isEnabled() ? 
242
-				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : 
243
-				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
242
+				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>';
244 243
             $datum[3] = $task->getTitle();
245
-            $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s';
244
+            $date_format = str_replace('%', '', I18N::dateFormat()).' H:i:s';
246 245
 			$datum[4] = $task->getLastUpdated()->format($date_format);
247 246
             $datum[5] = $task->isLastRunSuccess() ? 
248
-				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : 
249
-				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
247
+				'<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>';
250 248
             $dtF = new \DateTime('@0');
251
-            $dtT = new \DateTime('@' . ($task->getFrequency() * 60));            
249
+            $dtT = new \DateTime('@'.($task->getFrequency() * 60));            
252 250
             $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m'));
253 251
 			$datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited');
254 252
 			$datum[8] = $task->isRunning() ? 
255
-				'<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : 
256
-				'<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>';
257
-			if($task->isEnabled() && !$task->isRunning()) {
253
+				'<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>';
254
+			if ($task->isEnabled() && !$task->isRunning()) {
258 255
 			    $datum[9] = '
259
-    			    <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')">
260
-    			         <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div>
256
+    			    <button id="bt_runtask_'. $task->getName().'" class="btn btn-primary" href="#" onclick="return run_admintask(\''.$task->getName().'\')">
257
+    			         <div id="bt_runtasktext_'. $task->getName().'"><i class="fa fa-cog fa-fw" ></i>'.I18N::translate('Run').'</div>
261 258
     			    </button>';
262 259
 			}
263 260
 			else {
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Views/TaskEditView.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 	 * {@inhericDoc}
27 27
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
28 28
 	 */
29
-    protected function renderContent() {
29
+	protected function renderContent() {
30 30
         
31
-        /** @var AbstractTask $task */
32
-        $task = $this->data->get('task');
33
-        ?>        
31
+		/** @var AbstractTask $task */
32
+		$task = $this->data->get('task');
33
+		?>        
34 34
         <ol class="breadcrumb small">
35 35
         	<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
36 36
 			<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     	</form>
123 123
 		
124 124
 		<?php        
125
-    }
125
+	}
126 126
     
127 127
 }
128 128
  
129 129
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
     			</div>
105 105
     		</div>
106 106
 			
107
-			<?php if($task instanceof ConfigurableTaskInterface) { ?>
107
+			<?php if ($task instanceof ConfigurableTaskInterface) { ?>
108 108
 			
109 109
 			<h3><?php echo I18N::translate('Options for “%s”', $task->getTitle()); ?></h3>
110 110
 			
Please login to merge, or discard this patch.
src/Webtrees/Module/AdminTasks/Views/AdminConfigView.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 	 * {@inhericDoc}
23 23
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
24 24
 	 */
25
-    protected function renderContent() {
25
+	protected function renderContent() {
26 26
         
27
-        $table_id = $this->data->get('table_id');
28
-        ?>        
27
+		$table_id = $this->data->get('table_id');
28
+		?>        
29 29
         <ol class="breadcrumb small">
30 30
         	<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
31 31
 			<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     	</table>
69 69
 		
70 70
 		<?php        
71
-    }
71
+	}
72 72
     
73 73
 }
74 74
  
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 			<?php echo I18N::translate('In order to do so, use the following URL, with the optional parameter <em>%s</em> if you only want to force the execution of one task: ', 'task'); ?>
41 41
 		</p>
42 42
 		<p>
43
-			<code><?php echo $this->data->get('trigger_url_root') .'&force=<span id="token_url">'. $this->data->get('trigger_token') .'</span>[&task='. I18N::translate('task_name').']'; ?></code>
43
+			<code><?php echo $this->data->get('trigger_url_root').'&force=<span id="token_url">'.$this->data->get('trigger_token').'</span>[&task='.I18N::translate('task_name').']'; ?></code>
44 44
 		</p>
45 45
 		<p>
46 46
 			<button id="bt_genforcetoken" class="bt bt-primary" onClick="generate_force_token();">
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Model/SosaCalculator.php 3 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -114,8 +114,12 @@
 block discarded – undo
114 114
         $this->flushTmpSosaTable();
115 115
         
116 116
         if($fam = $indi->getPrimaryChildFamily()) {
117
-            if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa);
118
-            if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1);
117
+            if($husb = $fam->getHusband()) {
118
+            	$this->addNode($husb, 2 * $sosa);
119
+            }
120
+            if($wife = $fam->getWife()) {
121
+            	$this->addNode($wife, 2 * $sosa + 1);
122
+            }
119 123
         }
120 124
     }
121 125
     
Please login to merge, or discard this patch.
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -19,116 +19,116 @@
 block discarded – undo
19 19
  */
20 20
 class SosaCalculator {
21 21
     
22
-    /**
23
-     * Maximium size for the temporary Sosa table
24
-     * @var int TMP_SOSA_TABLE_LIMIT
25
-     */
26
-    const TMP_SOSA_TABLE_LIMIT = 1000;
22
+	/**
23
+	 * Maximium size for the temporary Sosa table
24
+	 * @var int TMP_SOSA_TABLE_LIMIT
25
+	 */
26
+	const TMP_SOSA_TABLE_LIMIT = 1000;
27 27
     
28
-    /**
29
-     * Reference user
30
-     * @var Fisharebest\Webtrees\User $user
31
-     */
32
-    protected $user;
28
+	/**
29
+	 * Reference user
30
+	 * @var Fisharebest\Webtrees\User $user
31
+	 */
32
+	protected $user;
33 33
     
34
-    /**
35
-     * Reference tree
36
-     * @var Fisharebest\Webtrees\Tree $tree
37
-     */
38
-    protected $tree;
34
+	/**
35
+	 * Reference tree
36
+	 * @var Fisharebest\Webtrees\Tree $tree
37
+	 */
38
+	protected $tree;
39 39
     
40
-    /**
41
-     * Sosa Provider for the calculator
42
-     * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider
43
-     */
44
-    protected $sosa_provider;
40
+	/**
41
+	 * Sosa Provider for the calculator
42
+	 * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider
43
+	 */
44
+	protected $sosa_provider;
45 45
     
46
-    /**
47
-     * Temporary Sosa table, used during construction
48
-     * @var array $tmp_sosa_table
49
-     */
50
-    protected $tmp_sosa_table;
46
+	/**
47
+	 * Temporary Sosa table, used during construction
48
+	 * @var array $tmp_sosa_table
49
+	 */
50
+	protected $tmp_sosa_table;
51 51
     
52
-    /**
53
-     * Constructor for the Sosa Calculator
54
-     * @param Tree $tree
55
-     * @param User $user
56
-     */
57
-    public function __construct(Tree $tree, User $user) {        
58
-        $this->tree = $tree;
59
-        $this->user = $user;
52
+	/**
53
+	 * Constructor for the Sosa Calculator
54
+	 * @param Tree $tree
55
+	 * @param User $user
56
+	 */
57
+	public function __construct(Tree $tree, User $user) {        
58
+		$this->tree = $tree;
59
+		$this->user = $user;
60 60
         
61
-        $this->sosa_provider = new SosaProvider($this->tree, $this->user);;
62
-    }
61
+		$this->sosa_provider = new SosaProvider($this->tree, $this->user);;
62
+	}
63 63
     
64
-    /**
65
-     * Compute all Sosa ancestors from the user's root individual.
66
-     * @return bool Result of the computation
67
-     */
68
-    public function computeAll() {
69
-        $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');        
70
-        $indi = Individual::getInstance($root_id, $this->tree);
71
-        if($indi){
72
-            $this->sosa_provider->deleteAll();
73
-            $this->addNode($indi, 1);
74
-            $this->flushTmpSosaTable(true);
75
-            return true;
76
-        }     
77
-        return false;
78
-    }
64
+	/**
65
+	 * Compute all Sosa ancestors from the user's root individual.
66
+	 * @return bool Result of the computation
67
+	 */
68
+	public function computeAll() {
69
+		$root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');        
70
+		$indi = Individual::getInstance($root_id, $this->tree);
71
+		if($indi){
72
+			$this->sosa_provider->deleteAll();
73
+			$this->addNode($indi, 1);
74
+			$this->flushTmpSosaTable(true);
75
+			return true;
76
+		}     
77
+		return false;
78
+	}
79 79
     
80
-    /**
81
-     * Compute all Sosa Ancestors from a specified Individual
82
-     * @param Individual $indi
83
-     * @return bool Result of the computation
84
-     */
85
-    public function computeFromIndividual(Individual $indi) {
86
-        $dindi = new \MyArtJaub\Webtrees\Individual($indi);
87
-        $current_sosas = $dindi->getSosaNumbers();
88
-        foreach($current_sosas as $current_sosa => $gen) {
89
-            $this->sosa_provider->deleteAncestors($current_sosa);
90
-            $this->addNode($indi, $current_sosa);
91
-        }
92
-        $this->flushTmpSosaTable(true);
93
-        return true;
94
-    }
80
+	/**
81
+	 * Compute all Sosa Ancestors from a specified Individual
82
+	 * @param Individual $indi
83
+	 * @return bool Result of the computation
84
+	 */
85
+	public function computeFromIndividual(Individual $indi) {
86
+		$dindi = new \MyArtJaub\Webtrees\Individual($indi);
87
+		$current_sosas = $dindi->getSosaNumbers();
88
+		foreach($current_sosas as $current_sosa => $gen) {
89
+			$this->sosa_provider->deleteAncestors($current_sosa);
90
+			$this->addNode($indi, $current_sosa);
91
+		}
92
+		$this->flushTmpSosaTable(true);
93
+		return true;
94
+	}
95 95
     
96
-    /**
97
-     * Recursive method to add individual to the Sosa table, and flush it regularly
98
-     * @param Individual $indi Individual to add
99
-     * @param int $sosa Individual's sosa
100
-     */
101
-    protected function addNode(Individual $indi, $sosa) {                
102
-        $birth_year = $indi->getEstimatedBirthDate()->gregorianYear();
103
-        $death_year = $indi->getEstimatedDeathDate()->gregorianYear();
96
+	/**
97
+	 * Recursive method to add individual to the Sosa table, and flush it regularly
98
+	 * @param Individual $indi Individual to add
99
+	 * @param int $sosa Individual's sosa
100
+	 */
101
+	protected function addNode(Individual $indi, $sosa) {                
102
+		$birth_year = $indi->getEstimatedBirthDate()->gregorianYear();
103
+		$death_year = $indi->getEstimatedDeathDate()->gregorianYear();
104 104
         
105
-        $this->tmp_sosa_table[] = array(
106
-            'indi' => $indi->getXref(), 
107
-            'sosa' => $sosa, 
108
-            'birth_year' => $birth_year,
109
-            'death_year' => $death_year
110
-        );
105
+		$this->tmp_sosa_table[] = array(
106
+			'indi' => $indi->getXref(), 
107
+			'sosa' => $sosa, 
108
+			'birth_year' => $birth_year,
109
+			'death_year' => $death_year
110
+		);
111 111
         
112
-        $this->flushTmpSosaTable();
112
+		$this->flushTmpSosaTable();
113 113
         
114
-        if($fam = $indi->getPrimaryChildFamily()) {
115
-            if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa);
116
-            if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1);
117
-        }
118
-    }
114
+		if($fam = $indi->getPrimaryChildFamily()) {
115
+			if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa);
116
+			if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1);
117
+		}
118
+	}
119 119
     
120
-    /**
121
-     * Write sosas in the table, if the number of items is superior to the limit, or if forced.
122
-     *
123
-     * @param bool $force Should the flush be forced
124
-     */
125
-    protected function flushTmpSosaTable($force = false) {
126
-        if( count($this->tmp_sosa_table)> 0 && 
127
-            ($force ||  count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){            
128
-                $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table);
129
-                $this->tmp_sosa_table = array();
130
-        }
131
-    }
120
+	/**
121
+	 * Write sosas in the table, if the number of items is superior to the limit, or if forced.
122
+	 *
123
+	 * @param bool $force Should the flush be forced
124
+	 */
125
+	protected function flushTmpSosaTable($force = false) {
126
+		if( count($this->tmp_sosa_table)> 0 && 
127
+			($force ||  count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){            
128
+				$this->sosa_provider->insertOrUpdate($this->tmp_sosa_table);
129
+				$this->tmp_sosa_table = array();
130
+		}
131
+	}
132 132
                
133 133
 }
134 134
  
135 135
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $this->tree = $tree;
59 59
         $this->user = $user;
60 60
         
61
-        $this->sosa_provider = new SosaProvider($this->tree, $this->user);;
61
+        $this->sosa_provider = new SosaProvider($this->tree, $this->user); ;
62 62
     }
63 63
     
64 64
     /**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function computeAll() {
69 69
         $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');        
70 70
         $indi = Individual::getInstance($root_id, $this->tree);
71
-        if($indi){
71
+        if ($indi) {
72 72
             $this->sosa_provider->deleteAll();
73 73
             $this->addNode($indi, 1);
74 74
             $this->flushTmpSosaTable(true);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     public function computeFromIndividual(Individual $indi) {
86 86
         $dindi = new \MyArtJaub\Webtrees\Individual($indi);
87 87
         $current_sosas = $dindi->getSosaNumbers();
88
-        foreach($current_sosas as $current_sosa => $gen) {
88
+        foreach ($current_sosas as $current_sosa => $gen) {
89 89
             $this->sosa_provider->deleteAncestors($current_sosa);
90 90
             $this->addNode($indi, $current_sosa);
91 91
         }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
         
112 112
         $this->flushTmpSosaTable();
113 113
         
114
-        if($fam = $indi->getPrimaryChildFamily()) {
115
-            if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa);
116
-            if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1);
114
+        if ($fam = $indi->getPrimaryChildFamily()) {
115
+            if ($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa);
116
+            if ($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1);
117 117
         }
118 118
     }
119 119
     
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
      * @param bool $force Should the flush be forced
124 124
      */
125 125
     protected function flushTmpSosaTable($force = false) {
126
-        if( count($this->tmp_sosa_table)> 0 && 
127
-            ($force ||  count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){            
126
+        if (count($this->tmp_sosa_table) > 0 && 
127
+            ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)) {            
128 128
                 $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table);
129 129
                 $this->tmp_sosa_table = array();
130 130
         }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaListController.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -431,8 +431,7 @@  discard block
 block discarded – undo
431 431
                         ) {
432 432
                         $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex();
433 433
                     }
434
-                }
435
-                else {
434
+                } else {
436 435
                     $birth_dates[0]=new Date('');
437 436
                 }
438 437
                 if ($death_dates = $person->getAllDeathDates()) {
@@ -443,8 +442,7 @@  discard block
 block discarded – undo
443 442
                         ) {
444 443
                         $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
445 444
                     }
446
-                }
447
-                else {
445
+                } else {
448 446
                     $death_dates[0] = new Date('');
449 447
                 }
450 448
                 $age = Date::getAge($birth_dates[0], $death_dates[0], 0);
Please login to merge, or discard this patch.
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -37,67 +37,67 @@  discard block
 block discarded – undo
37 37
  */
38 38
 class SosaListController extends MvcController
39 39
 {
40
-    /**
41
-     * Sosa Provider for the controller
42
-     * @var SosaProvider $sosa_provider
43
-     */
44
-    protected $sosa_provider;
40
+	/**
41
+	 * Sosa Provider for the controller
42
+	 * @var SosaProvider $sosa_provider
43
+	 */
44
+	protected $sosa_provider;
45 45
     
46
-    /**
47
-     * Generation used for the controller
48
-     * @var int $generation
49
-     */
50
-    protected $generation;
46
+	/**
47
+	 * Generation used for the controller
48
+	 * @var int $generation
49
+	 */
50
+	protected $generation;
51 51
     
52
-    /**
53
-     * ViewBag to hold data for the controller
54
-     * @var ViewBag $view_bag
55
-     */
56
-    protected $view_bag;
52
+	/**
53
+	 * ViewBag to hold data for the controller
54
+	 * @var ViewBag $view_bag
55
+	 */
56
+	protected $view_bag;
57 57
     
58
-    /**
59
-     * {@inheritDoc}
60
-     * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module)
61
-     */
62
-    public function __construct(AbstractModule $module) {
63
-        parent::__construct($module);
58
+	/**
59
+	 * {@inheritDoc}
60
+	 * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module)
61
+	 */
62
+	public function __construct(AbstractModule $module) {
63
+		parent::__construct($module);
64 64
 
65
-        $this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user());
65
+		$this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user());
66 66
 
67
-        $this->generation = Filter::getInteger('gen');
67
+		$this->generation = Filter::getInteger('gen');
68 68
         
69
-        $this->view_bag = new ViewBag();
70
-        $this->view_bag->set('generation', $this->generation);
71
-        $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration());
72
-        $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0);
69
+		$this->view_bag = new ViewBag();
70
+		$this->view_bag->set('generation', $this->generation);
71
+		$this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration());
72
+		$this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0);
73 73
         
74
-    }
74
+	}
75 75
     
76 76
     
77
-    /**
78
-     * Pages
79
-     */
77
+	/**
78
+	 * Pages
79
+	 */
80 80
     
81
-    /**
82
-     * SosaList@index
83
-     */
84
-    public function index() {
85
-        $wt_tree = Globals::getTree();
86
-        $controller = new PageController();
87
-        $controller
88
-            ->setPageTitle(I18N::translate('Sosa Ancestors'));            
81
+	/**
82
+	 * SosaList@index
83
+	 */
84
+	public function index() {
85
+		$wt_tree = Globals::getTree();
86
+		$controller = new PageController();
87
+		$controller
88
+			->setPageTitle(I18N::translate('Sosa Ancestors'));            
89 89
 
90
-        $this->view_bag->set('title', $controller->getPageTitle());
90
+		$this->view_bag->set('title', $controller->getPageTitle());
91 91
         
92
-        if($this->view_bag->get('is_setup', false)) {
93
-            $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0);
94
-            $this->view_bag->set('url_module', $this->module->getName());
95
-            $this->view_bag->set('url_action', 'SosaList');
96
-            $this->view_bag->set('url_ged', $wt_tree->getNameUrl()); 
97
-            $this->view_bag->set('min_gen', 1);
92
+		if($this->view_bag->get('is_setup', false)) {
93
+			$this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0);
94
+			$this->view_bag->set('url_module', $this->module->getName());
95
+			$this->view_bag->set('url_action', 'SosaList');
96
+			$this->view_bag->set('url_ged', $wt_tree->getNameUrl()); 
97
+			$this->view_bag->set('min_gen', 1);
98 98
             
99
-            if($this->view_bag->get('has_sosa', false)) {            
100
-                $controller->addInlineJavascript('
99
+			if($this->view_bag->get('has_sosa', false)) {            
100
+				$controller->addInlineJavascript('
101 101
             		jQuery("#sosalist-tabs").tabs();
102 102
             		jQuery("#sosalist-tabs").css("visibility", "visible");
103 103
                 
@@ -151,43 +151,43 @@  discard block
 block discarded – undo
151 151
             		);
152 152
                 
153 153
             	');            
154
-            }
155
-        }
154
+			}
155
+		}
156 156
                 
157
-        ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render();   
158
-    }    
157
+		ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render();   
158
+	}    
159 159
     
160 160
 
161
-    /**
162
-     * SosaList@missing
163
-     */
164
-    public function missing() {
165
-        $wt_tree = Globals::getTree();
166
-        $controller = new PageController();
167
-        $controller
168
-        ->setPageTitle(I18N::translate('Missing Ancestors'));
161
+	/**
162
+	 * SosaList@missing
163
+	 */
164
+	public function missing() {
165
+		$wt_tree = Globals::getTree();
166
+		$controller = new PageController();
167
+		$controller
168
+		->setPageTitle(I18N::translate('Missing Ancestors'));
169 169
         
170
-        $this->view_bag->set('title', $controller->getPageTitle());
170
+		$this->view_bag->set('title', $controller->getPageTitle());
171 171
         
172
-        if($this->view_bag->get('is_setup', false)) {
173
-            $this->view_bag->set('url_module', $this->module->getName());
174
-            $this->view_bag->set('url_action', 'SosaList@missing');
175
-            $this->view_bag->set('url_ged', $wt_tree->getNameUrl());
176
-            $this->view_bag->set('min_gen', 2);
172
+		if($this->view_bag->get('is_setup', false)) {
173
+			$this->view_bag->set('url_module', $this->module->getName());
174
+			$this->view_bag->set('url_action', 'SosaList@missing');
175
+			$this->view_bag->set('url_ged', $wt_tree->getNameUrl());
176
+			$this->view_bag->set('min_gen', 2);
177 177
             
178
-            $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation);
179
-            $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0);
178
+			$missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation);
179
+			$this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0);
180 180
             
181
-            $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1));
182
-            $this->view_bag->set('perc_sosa', $perc_sosa);
181
+			$perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1));
182
+			$this->view_bag->set('perc_sosa', $perc_sosa);
183 183
             
184
-            if($this->view_bag->get('has_missing', false)) {
185
-                $table_id = 'table-sosa-missing-' . Uuid::uuid4();
186
-                $this->view_bag->set('table_id', $table_id);
184
+			if($this->view_bag->get('has_missing', false)) {
185
+				$table_id = 'table-sosa-missing-' . Uuid::uuid4();
186
+				$this->view_bag->set('table_id', $table_id);
187 187
                 
188
-                $controller
189
-                ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
190
-                ->addInlineJavascript('
188
+				$controller
189
+				->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
190
+				->addInlineJavascript('
191 191
 				    jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
192 192
 				    jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
193 193
                     
@@ -239,76 +239,76 @@  discard block
 block discarded – undo
239 239
     				jQuery(".loading-image").css("display", "none");
240 240
     			');
241 241
                         
242
-                $unique_indis = array();
243
-                $sum_missing_different = 0;
244
-                $sum_missing_different_without_hidden = 0;
245
-                foreach($missing_list as $num => $missing_tab) {
246
-                    if(isset($unique_indis[$missing_tab['indi']])) {
247
-                        unset($missing_list[$num]);
248
-                        continue;
249
-                    }
250
-                    $sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
251
-                    $person = Individual::getInstance($missing_tab['indi'], $wt_tree);
252
-                    if (!$person || !$person->canShowName()) {
253
-                        unset($missing_list[$num]);
254
-                        continue;
255
-                    }  
256
-                    $sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
257
-                    $unique_indis[$person->getXref()] = true;
258
-                    $missing_tab['indi'] = $person;
259
-                    $missing_list[$num] = $missing_tab;
260
-                }
261
-                $this->view_bag->set('missing_list', $missing_list);
262
-                $this->view_bag->set('missing_diff_count', $sum_missing_different);
263
-                $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden);
264
-                $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2));
265
-                $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential);
266
-            }            
267
-        }
242
+				$unique_indis = array();
243
+				$sum_missing_different = 0;
244
+				$sum_missing_different_without_hidden = 0;
245
+				foreach($missing_list as $num => $missing_tab) {
246
+					if(isset($unique_indis[$missing_tab['indi']])) {
247
+						unset($missing_list[$num]);
248
+						continue;
249
+					}
250
+					$sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
251
+					$person = Individual::getInstance($missing_tab['indi'], $wt_tree);
252
+					if (!$person || !$person->canShowName()) {
253
+						unset($missing_list[$num]);
254
+						continue;
255
+					}  
256
+					$sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
257
+					$unique_indis[$person->getXref()] = true;
258
+					$missing_tab['indi'] = $person;
259
+					$missing_list[$num] = $missing_tab;
260
+				}
261
+				$this->view_bag->set('missing_list', $missing_list);
262
+				$this->view_bag->set('missing_diff_count', $sum_missing_different);
263
+				$this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden);
264
+				$perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2));
265
+				$this->view_bag->set('perc_sosa_potential', $perc_sosa_potential);
266
+			}            
267
+		}
268 268
         
269
-        ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render();
270
-    }
269
+		ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render();
270
+	}
271 271
     
272
-    /**
273
-     * SosaList@sosalist
274
-     */
275
-    public function sosalist() {
272
+	/**
273
+	 * SosaList@sosalist
274
+	 */
275
+	public function sosalist() {
276 276
                 
277
-        $type = Filter::get('type', 'indi|fam', null);
277
+		$type = Filter::get('type', 'indi|fam', null);
278 278
         
279
-        $controller = new AjaxController();
280
-        $controller->restrictAccess($this->generation > 0 || !is_null($type));
279
+		$controller = new AjaxController();
280
+		$controller->restrictAccess($this->generation > 0 || !is_null($type));
281 281
         
282
-        switch ($type){
283
-            case 'indi':
284
-                $this->renderSosaListIndi($controller);
285
-                break;
286
-            case 'fam':
287
-                $this->renderFamSosaListIndi($controller);
288
-                break;
289
-            default:
290
-                break;
291
-        }
282
+		switch ($type){
283
+			case 'indi':
284
+				$this->renderSosaListIndi($controller);
285
+				break;
286
+			case 'fam':
287
+				$this->renderFamSosaListIndi($controller);
288
+				break;
289
+			default:
290
+				break;
291
+		}
292 292
 
293
-    }
293
+	}
294 294
     
295
-    /**
296
-     * Render the Ajax response for the sortable table of Sosa individuals
297
-     * @param AjaxController $controller
298
-     */
299
-    protected function renderSosaListIndi(AjaxController $controller) {
300
-        $wt_tree = Globals::getTree();
301
-        $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); 
302
-        $this->view_bag->set('has_sosa', false);
295
+	/**
296
+	 * Render the Ajax response for the sortable table of Sosa individuals
297
+	 * @param AjaxController $controller
298
+	 */
299
+	protected function renderSosaListIndi(AjaxController $controller) {
300
+		$wt_tree = Globals::getTree();
301
+		$listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); 
302
+		$this->view_bag->set('has_sosa', false);
303 303
         
304
-        if(count($listSosa) > 0) {
305
-            $this->view_bag->set('has_sosa', true);
306
-            $table_id = 'table-sosa-indi-' . Uuid::uuid4();
307
-            $this->view_bag->set('table_id', $table_id);
304
+		if(count($listSosa) > 0) {
305
+			$this->view_bag->set('has_sosa', true);
306
+			$table_id = 'table-sosa-indi-' . Uuid::uuid4();
307
+			$this->view_bag->set('table_id', $table_id);
308 308
                      
309
-            $controller
310
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
311
-            ->addInlineJavascript('
309
+			$controller
310
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
311
+			->addInlineJavascript('
312 312
                 jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
313 313
                 jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
314 314
                 
@@ -375,95 +375,95 @@  discard block
 block discarded – undo
375 375
 				jQuery("#btn-toggle-statistics-'.$table_id.'").click();
376 376
            ');
377 377
             
378
-            $stats = new Stats($wt_tree);         
378
+			$stats = new Stats($wt_tree);         
379 379
             
380
-            // Bad data can cause "longest life" to be huge, blowing memory limits
381
-            $max_age = min($wt_tree->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1;
382
-            // Inititialise chart data
383
-            $deat_by_age = array();
384
-            for ($age = 0; $age <= $max_age; $age++) {
385
-                $deat_by_age[$age] = '';
386
-            }
387
-            $birt_by_decade = array();
388
-            $deat_by_decade = array();
389
-            for ($year = 1550; $year < 2030; $year += 10) {
390
-                $birt_by_decade[$year] = '';
391
-                $deat_by_decade[$year] = '';
392
-            }
380
+			// Bad data can cause "longest life" to be huge, blowing memory limits
381
+			$max_age = min($wt_tree->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1;
382
+			// Inititialise chart data
383
+			$deat_by_age = array();
384
+			for ($age = 0; $age <= $max_age; $age++) {
385
+				$deat_by_age[$age] = '';
386
+			}
387
+			$birt_by_decade = array();
388
+			$deat_by_decade = array();
389
+			for ($year = 1550; $year < 2030; $year += 10) {
390
+				$birt_by_decade[$year] = '';
391
+				$deat_by_decade[$year] = '';
392
+			}
393 393
             
394
-            $unique_indis = array(); // Don't double-count indis with multiple names.
395
-            $nb_displayed = 0;
394
+			$unique_indis = array(); // Don't double-count indis with multiple names.
395
+			$nb_displayed = 0;
396 396
             
397
-            Individual::load($wt_tree, $listSosa);
398
-            foreach($listSosa as $sosa => $pid) {
399
-                $person = Individual::getInstance($pid, $wt_tree);
400
-                if (!$person || !$person->canShowName()) {
401
-                    unset($listSosa[$sosa]);
402
-                    continue;
403
-                }
404
-                $nb_displayed++;
405
-                if ($birth_dates=$person->getAllBirthDates()) {
406
-                    if (
407
-                        FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) &&
408
-                        !isset($unique_indis[$person->getXref()])
409
-                        ) {
410
-                        $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex();
411
-                    }
412
-                }
413
-                else {
414
-                    $birth_dates[0]=new Date('');
415
-                }
416
-                if ($death_dates = $person->getAllDeathDates()) {
417
-                    if (
418
-                        FunctionsPrint::isDateWithinChartsRange($death_dates[0]) &&
419
-                        !isset($unique_indis[$person->getXref()])
420
-                        ) {
421
-                        $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
422
-                    }
423
-                }
424
-                else {
425
-                    $death_dates[0] = new Date('');
426
-                }
427
-                $age = Date::getAge($birth_dates[0], $death_dates[0], 0);
428
-                if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) {
429
-                    $deat_by_age[$age] .= $person->getSex();
430
-                }
431
-                $listSosa[$sosa] = $person;
432
-                $unique_indis[$person->getXref()] = true;
433
-            }
434
-            $this->view_bag->set('sosa_list', $listSosa);   
397
+			Individual::load($wt_tree, $listSosa);
398
+			foreach($listSosa as $sosa => $pid) {
399
+				$person = Individual::getInstance($pid, $wt_tree);
400
+				if (!$person || !$person->canShowName()) {
401
+					unset($listSosa[$sosa]);
402
+					continue;
403
+				}
404
+				$nb_displayed++;
405
+				if ($birth_dates=$person->getAllBirthDates()) {
406
+					if (
407
+						FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) &&
408
+						!isset($unique_indis[$person->getXref()])
409
+						) {
410
+						$birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex();
411
+					}
412
+				}
413
+				else {
414
+					$birth_dates[0]=new Date('');
415
+				}
416
+				if ($death_dates = $person->getAllDeathDates()) {
417
+					if (
418
+						FunctionsPrint::isDateWithinChartsRange($death_dates[0]) &&
419
+						!isset($unique_indis[$person->getXref()])
420
+						) {
421
+						$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
422
+					}
423
+				}
424
+				else {
425
+					$death_dates[0] = new Date('');
426
+				}
427
+				$age = Date::getAge($birth_dates[0], $death_dates[0], 0);
428
+				if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) {
429
+					$deat_by_age[$age] .= $person->getSex();
430
+				}
431
+				$listSosa[$sosa] = $person;
432
+				$unique_indis[$person->getXref()] = true;
433
+			}
434
+			$this->view_bag->set('sosa_list', $listSosa);   
435 435
             
436
-            $this->view_bag->set('sosa_count', count($listSosa));
437
-            $this->view_bag->set('sosa_theo', pow(2, $this->generation-1));
438
-            $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo')));
436
+			$this->view_bag->set('sosa_count', count($listSosa));
437
+			$this->view_bag->set('sosa_theo', pow(2, $this->generation-1));
438
+			$this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo')));
439 439
             
440
-            $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed);
440
+			$this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed);
441 441
             
442
-            $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
443
-            $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death')));
444
-            $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year')));
445
-        }
442
+			$this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
443
+			$this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death')));
444
+			$this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year')));
445
+		}
446 446
         
447
-        ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render();        
448
-    }
447
+		ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render();        
448
+	}
449 449
     
450
-    /**
451
-     * Render the Ajax response for the sortable table of Sosa family
452
-     * @param AjaxController $controller
453
-     */
454
-    protected function renderFamSosaListIndi(AjaxController $controller) {
455
-        $wt_tree = Globals::getTree();
456
-        $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);;
457
-        $this->view_bag->set('has_sosa', false);
450
+	/**
451
+	 * Render the Ajax response for the sortable table of Sosa family
452
+	 * @param AjaxController $controller
453
+	 */
454
+	protected function renderFamSosaListIndi(AjaxController $controller) {
455
+		$wt_tree = Globals::getTree();
456
+		$listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);;
457
+		$this->view_bag->set('has_sosa', false);
458 458
         
459
-        if(count($listFamSosa) > 0) {
460
-            $this->view_bag->set('has_sosa', true);
461
-            $table_id = 'table-sosa-fam-' . Uuid::uuid4();
462
-            $this->view_bag->set('table_id', $table_id);
459
+		if(count($listFamSosa) > 0) {
460
+			$this->view_bag->set('has_sosa', true);
461
+			$table_id = 'table-sosa-fam-' . Uuid::uuid4();
462
+			$this->view_bag->set('table_id', $table_id);
463 463
              
464
-            $controller
465
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
466
-            ->addInlineJavascript('
464
+			$controller
465
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
466
+			->addInlineJavascript('
467 467
 				jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
468 468
 				jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
469 469
                 
@@ -527,67 +527,67 @@  discard block
 block discarded – undo
527 527
 				jQuery("#btn-toggle-statistics-'.$table_id.'").click();
528 528
            ');
529 529
         
530
-            $stats = new Stats($wt_tree);        
531
-            $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1;
530
+			$stats = new Stats($wt_tree);        
531
+			$max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1;
532 532
             
533
-            //-- init chart data
534
-    		$marr_by_age = array();
535
-    		for ($age=0; $age<=$max_age; $age++) {
536
-    			$marr_by_age[$age] = '';
537
-    		}
538
-    		$birt_by_decade = array();
539
-    		$marr_by_decade = array();
540
-    		for ($year=1550; $year<2030; $year+=10) {
541
-    			$birt_by_decade[$year] = '';
542
-    			$marr_by_decade[$year] = '';
543
-    		}
533
+			//-- init chart data
534
+			$marr_by_age = array();
535
+			for ($age=0; $age<=$max_age; $age++) {
536
+				$marr_by_age[$age] = '';
537
+			}
538
+			$birt_by_decade = array();
539
+			$marr_by_decade = array();
540
+			for ($year=1550; $year<2030; $year+=10) {
541
+				$birt_by_decade[$year] = '';
542
+				$marr_by_decade[$year] = '';
543
+			}
544 544
     		
545
-            foreach($listFamSosa as $sosa => $fid) {
546
-                $sfamily = Family::getInstance($fid, $wt_tree);
547
-                if(!$sfamily || !$sfamily->canShow()) {
548
-                    unset($listFamSosa[$sosa]);
549
-                    continue;
550
-                }
551
-                $mdate=$sfamily->getMarriageDate();
545
+			foreach($listFamSosa as $sosa => $fid) {
546
+				$sfamily = Family::getInstance($fid, $wt_tree);
547
+				if(!$sfamily || !$sfamily->canShow()) {
548
+					unset($listFamSosa[$sosa]);
549
+					continue;
550
+				}
551
+				$mdate=$sfamily->getMarriageDate();
552 552
                 
553
-                if( ($husb = $sfamily->getHusband()) && 
554
-                    ($hdate = $husb->getBirthDate()) && 
555
-                    $hdate->isOK() && $mdate->isOK()) {
556
-                    if (FunctionsPrint::isDateWithinChartsRange($hdate)) {
557
-                        $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
558
-                    }
559
-                    $hage = Date::getAge($hdate, $mdate, 0);
560
-                    if ($hage >= 0 && $hage <= $max_age) {
561
-                        $marr_by_age[$hage] .= $husb->getSex();
562
-                    }
563
-                }
553
+				if( ($husb = $sfamily->getHusband()) && 
554
+					($hdate = $husb->getBirthDate()) && 
555
+					$hdate->isOK() && $mdate->isOK()) {
556
+					if (FunctionsPrint::isDateWithinChartsRange($hdate)) {
557
+						$birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
558
+					}
559
+					$hage = Date::getAge($hdate, $mdate, 0);
560
+					if ($hage >= 0 && $hage <= $max_age) {
561
+						$marr_by_age[$hage] .= $husb->getSex();
562
+					}
563
+				}
564 564
                 
565
-                if(($wife = $sfamily->getWife()) &&
566
-                    ($wdate=$wife->getBirthDate()) &&
567
-                    $wdate->isOK() && $mdate->isOK()) {
568
-                    if (FunctionsPrint::isDateWithinChartsRange($wdate)) {
569
-                        $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
570
-                    }
571
-                    $wage = Date::getAge($wdate, $mdate, 0);
572
-                    if ($wage >= 0 && $wage <= $max_age) {
573
-                        $marr_by_age[$wage] .= $wife->getSex();
574
-                    }
575
-                }                
565
+				if(($wife = $sfamily->getWife()) &&
566
+					($wdate=$wife->getBirthDate()) &&
567
+					$wdate->isOK() && $mdate->isOK()) {
568
+					if (FunctionsPrint::isDateWithinChartsRange($wdate)) {
569
+						$birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
570
+					}
571
+					$wage = Date::getAge($wdate, $mdate, 0);
572
+					if ($wage >= 0 && $wage <= $max_age) {
573
+						$marr_by_age[$wage] .= $wife->getSex();
574
+					}
575
+				}                
576 576
 
577
-                if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) {
578
-                    $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
579
-                }
577
+				if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) {
578
+					$marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
579
+				}
580 580
                 
581
-                $listFamSosa[$sosa] = $sfamily;
582
-            }
583
-            $this->view_bag->set('sosa_list', $listFamSosa);
581
+				$listFamSosa[$sosa] = $sfamily;
582
+			}
583
+			$this->view_bag->set('sosa_list', $listFamSosa);
584 584
         
585
-            $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
586
-            $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')));
587
-            $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')));
588
-        }
585
+			$this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
586
+			$this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')));
587
+			$this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')));
588
+		}
589 589
         
590
-        ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render();
591
-    }
590
+		ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render();
591
+	}
592 592
     
593 593
 }
594 594
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $this->view_bag = new ViewBag();
70 70
         $this->view_bag->set('generation', $this->generation);
71 71
         $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration());
72
-        $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0);
72
+        $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0) > 0);
73 73
         
74 74
     }
75 75
     
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 
90 90
         $this->view_bag->set('title', $controller->getPageTitle());
91 91
         
92
-        if($this->view_bag->get('is_setup', false)) {
92
+        if ($this->view_bag->get('is_setup', false)) {
93 93
             $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0);
94 94
             $this->view_bag->set('url_module', $this->module->getName());
95 95
             $this->view_bag->set('url_action', 'SosaList');
96 96
             $this->view_bag->set('url_ged', $wt_tree->getNameUrl()); 
97 97
             $this->view_bag->set('min_gen', 1);
98 98
             
99
-            if($this->view_bag->get('has_sosa', false)) {            
99
+            if ($this->view_bag->get('has_sosa', false)) {            
100 100
                 $controller->addInlineJavascript('
101 101
             		jQuery("#sosalist-tabs").tabs();
102 102
             		jQuery("#sosalist-tabs").css("visibility", "visible");
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             			{
107 107
                             "mod" : "'.$this->module->getName().'",
108 108
                             "mod_action": "SosaList@sosalist",
109
-                            "ged" : "' . $wt_tree->getNameUrl(). '",
109
+                            "ged" : "' . $wt_tree->getNameUrl().'",
110 110
                             "type" : "indi",
111 111
                             "gen" : "'.$this->generation.'"
112 112
                         },
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                         {
132 132
                             "mod" : "'.$this->module->getName().'",
133 133
                             "mod_action": "SosaList@sosalist",
134
-                            "ged" : "' . $wt_tree->getNameUrl(). '",
134
+                            "ged" : "' . $wt_tree->getNameUrl().'",
135 135
                             "type" : "fam",
136 136
                             "gen" : "'.$this->generation.'"
137 137
                         },
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         
170 170
         $this->view_bag->set('title', $controller->getPageTitle());
171 171
         
172
-        if($this->view_bag->get('is_setup', false)) {
172
+        if ($this->view_bag->get('is_setup', false)) {
173 173
             $this->view_bag->set('url_module', $this->module->getName());
174 174
             $this->view_bag->set('url_action', 'SosaList@missing');
175 175
             $this->view_bag->set('url_ged', $wt_tree->getNameUrl());
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
             $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation);
179 179
             $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0);
180 180
             
181
-            $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1));
181
+            $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation - 1));
182 182
             $this->view_bag->set('perc_sosa', $perc_sosa);
183 183
             
184
-            if($this->view_bag->get('has_missing', false)) {
185
-                $table_id = 'table-sosa-missing-' . Uuid::uuid4();
184
+            if ($this->view_bag->get('has_missing', false)) {
185
+                $table_id = 'table-sosa-missing-'.Uuid::uuid4();
186 186
                 $this->view_bag->set('table_id', $table_id);
187 187
                 
188 188
                 $controller
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 				    jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
193 193
                     
194 194
     				jQuery("#'.$table_id.'").dataTable( {
195
-                        dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
195
+                        dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\',
196 196
     					'.I18N::datatablesI18N().',
197 197
     					jQueryUI: true,
198 198
     					autoWidth:false,
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
     					pagingType: "full_numbers"
219 219
     			   });
220 220
     			
221
-    				jQuery("#' . $table_id . '")
221
+    				jQuery("#' . $table_id.'")
222 222
     				/* Filter buttons in table header */
223 223
     				.on("click", "button[data-filter-column]", function() {
224 224
     					var btn = jQuery(this);
225 225
     					// De-activate the other buttons in this button group
226 226
     					btn.siblings().removeClass("ui-state-active");
227 227
     					// Apply (or clear) this filter
228
-    					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
228
+    					var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column"));
229 229
     					if (btn.hasClass("ui-state-active")) {
230 230
     						btn.removeClass("ui-state-active");
231 231
     						col.search("").draw();
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
                 $unique_indis = array();
243 243
                 $sum_missing_different = 0;
244 244
                 $sum_missing_different_without_hidden = 0;
245
-                foreach($missing_list as $num => $missing_tab) {
246
-                    if(isset($unique_indis[$missing_tab['indi']])) {
245
+                foreach ($missing_list as $num => $missing_tab) {
246
+                    if (isset($unique_indis[$missing_tab['indi']])) {
247 247
                         unset($missing_list[$num]);
248 248
                         continue;
249 249
                     }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 $this->view_bag->set('missing_list', $missing_list);
262 262
                 $this->view_bag->set('missing_diff_count', $sum_missing_different);
263 263
                 $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden);
264
-                $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2));
264
+                $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation - 2));
265 265
                 $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential);
266 266
             }            
267 267
         }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         $controller = new AjaxController();
280 280
         $controller->restrictAccess($this->generation > 0 || !is_null($type));
281 281
         
282
-        switch ($type){
282
+        switch ($type) {
283 283
             case 'indi':
284 284
                 $this->renderSosaListIndi($controller);
285 285
                 break;
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
         $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); 
302 302
         $this->view_bag->set('has_sosa', false);
303 303
         
304
-        if(count($listSosa) > 0) {
304
+        if (count($listSosa) > 0) {
305 305
             $this->view_bag->set('has_sosa', true);
306
-            $table_id = 'table-sosa-indi-' . Uuid::uuid4();
306
+            $table_id = 'table-sosa-indi-'.Uuid::uuid4();
307 307
             $this->view_bag->set('table_id', $table_id);
308 308
                      
309 309
             $controller
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
                 jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
314 314
                 
315 315
                 jQuery("#'.$table_id.'").dataTable( {
316
-					dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
317
-					' . I18N::datatablesI18N() . ',
316
+					dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\',
317
+					' . I18N::datatablesI18N().',
318 318
 					jQueryUI: true,
319 319
 					autoWidth: false,
320 320
 					processing: true,
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 					pagingType: "full_numbers"
344 344
 			   });
345 345
             
346
-				jQuery("#' . $table_id . '")
346
+				jQuery("#' . $table_id.'")
347 347
 				/* Hide/show parents */
348 348
 				.on("click", ".btn-toggle-parents", function() {
349 349
 					jQuery(this).toggleClass("ui-state-active");
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				/* Hide/show statistics */
353 353
 				.on("click", ".btn-toggle-statistics", function() {
354 354
 					jQuery(this).toggleClass("ui-state-active");
355
-					jQuery("#indi_list_table-charts_' . $table_id . '").slideToggle();
355
+					jQuery("#indi_list_table-charts_' . $table_id.'").slideToggle();
356 356
 				})
357 357
 				/* Filter buttons in table header */
358 358
 				.on("click", "button[data-filter-column]", function() {
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 					// De-activate the other buttons in this button group
361 361
 					btn.siblings().removeClass("ui-state-active");
362 362
 					// Apply (or clear) this filter
363
-					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
363
+					var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column"));
364 364
 					if (btn.hasClass("ui-state-active")) {
365 365
 						btn.removeClass("ui-state-active");
366 366
 						col.search("").draw();
@@ -395,30 +395,30 @@  discard block
 block discarded – undo
395 395
             $nb_displayed = 0;
396 396
             
397 397
             Individual::load($wt_tree, $listSosa);
398
-            foreach($listSosa as $sosa => $pid) {
398
+            foreach ($listSosa as $sosa => $pid) {
399 399
                 $person = Individual::getInstance($pid, $wt_tree);
400 400
                 if (!$person || !$person->canShowName()) {
401 401
                     unset($listSosa[$sosa]);
402 402
                     continue;
403 403
                 }
404 404
                 $nb_displayed++;
405
-                if ($birth_dates=$person->getAllBirthDates()) {
405
+                if ($birth_dates = $person->getAllBirthDates()) {
406 406
                     if (
407 407
                         FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) &&
408 408
                         !isset($unique_indis[$person->getXref()])
409 409
                         ) {
410
-                        $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex();
410
+                        $birt_by_decade[(int)($birth_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
411 411
                     }
412 412
                 }
413 413
                 else {
414
-                    $birth_dates[0]=new Date('');
414
+                    $birth_dates[0] = new Date('');
415 415
                 }
416 416
                 if ($death_dates = $person->getAllDeathDates()) {
417 417
                     if (
418 418
                         FunctionsPrint::isDateWithinChartsRange($death_dates[0]) &&
419 419
                         !isset($unique_indis[$person->getXref()])
420 420
                         ) {
421
-                        $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
421
+                        $deat_by_decade[(int)($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
422 422
                     }
423 423
                 }
424 424
                 else {
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
             $this->view_bag->set('sosa_list', $listSosa);   
435 435
             
436 436
             $this->view_bag->set('sosa_count', count($listSosa));
437
-            $this->view_bag->set('sosa_theo', pow(2, $this->generation-1));
437
+            $this->view_bag->set('sosa_theo', pow(2, $this->generation - 1));
438 438
             $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo')));
439 439
             
440 440
             $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed);
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
      */
454 454
     protected function renderFamSosaListIndi(AjaxController $controller) {
455 455
         $wt_tree = Globals::getTree();
456
-        $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);;
456
+        $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation); ;
457 457
         $this->view_bag->set('has_sosa', false);
458 458
         
459
-        if(count($listFamSosa) > 0) {
459
+        if (count($listFamSosa) > 0) {
460 460
             $this->view_bag->set('has_sosa', true);
461
-            $table_id = 'table-sosa-fam-' . Uuid::uuid4();
461
+            $table_id = 'table-sosa-fam-'.Uuid::uuid4();
462 462
             $this->view_bag->set('table_id', $table_id);
463 463
              
464 464
             $controller
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
469 469
                 
470 470
                 jQuery("#'.$table_id.'").dataTable( {
471
-					dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
471
+					dom: \'<"H"<"filtersH_' . $table_id.'"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\',
472 472
                     '.I18N::datatablesI18N(array(16, 32, 64, 128, -1)).',
473 473
 					jQueryUI: true,
474 474
 					autoWidth: false,
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 					pagingType: "full_numbers"
496 496
 			   });
497 497
 					
498
-				jQuery("#' . $table_id . '")
498
+				jQuery("#' . $table_id.'")
499 499
 				/* Hide/show parents */
500 500
 				.on("click", ".btn-toggle-parents", function() {
501 501
 					jQuery(this).toggleClass("ui-state-active");
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 				/* Hide/show statistics */
505 505
 				.on("click",  ".btn-toggle-statistics", function() {
506 506
 					jQuery(this).toggleClass("ui-state-active");
507
-					jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle();
507
+					jQuery("#fam_list_table-charts_' . $table_id.'").slideToggle();
508 508
 				})
509 509
 				/* Filter buttons in table header */
510 510
 				.on("click", "button[data-filter-column]", function() {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 					// De-activate the other buttons in this button group
513 513
 					btn.siblings().removeClass("ui-state-active");
514 514
 					// Apply (or clear) this filter
515
-					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
515
+					var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column"));
516 516
 					if (btn.hasClass("ui-state-active")) {
517 517
 						btn.removeClass("ui-state-active");
518 518
 						col.search("").draw();
@@ -532,29 +532,29 @@  discard block
 block discarded – undo
532 532
             
533 533
             //-- init chart data
534 534
     		$marr_by_age = array();
535
-    		for ($age=0; $age<=$max_age; $age++) {
535
+    		for ($age = 0; $age <= $max_age; $age++) {
536 536
     			$marr_by_age[$age] = '';
537 537
     		}
538 538
     		$birt_by_decade = array();
539 539
     		$marr_by_decade = array();
540
-    		for ($year=1550; $year<2030; $year+=10) {
540
+    		for ($year = 1550; $year < 2030; $year += 10) {
541 541
     			$birt_by_decade[$year] = '';
542 542
     			$marr_by_decade[$year] = '';
543 543
     		}
544 544
     		
545
-            foreach($listFamSosa as $sosa => $fid) {
545
+            foreach ($listFamSosa as $sosa => $fid) {
546 546
                 $sfamily = Family::getInstance($fid, $wt_tree);
547
-                if(!$sfamily || !$sfamily->canShow()) {
547
+                if (!$sfamily || !$sfamily->canShow()) {
548 548
                     unset($listFamSosa[$sosa]);
549 549
                     continue;
550 550
                 }
551
-                $mdate=$sfamily->getMarriageDate();
551
+                $mdate = $sfamily->getMarriageDate();
552 552
                 
553
-                if( ($husb = $sfamily->getHusband()) && 
553
+                if (($husb = $sfamily->getHusband()) && 
554 554
                     ($hdate = $husb->getBirthDate()) && 
555 555
                     $hdate->isOK() && $mdate->isOK()) {
556 556
                     if (FunctionsPrint::isDateWithinChartsRange($hdate)) {
557
-                        $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
557
+                        $birt_by_decade[(int)($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
558 558
                     }
559 559
                     $hage = Date::getAge($hdate, $mdate, 0);
560 560
                     if ($hage >= 0 && $hage <= $max_age) {
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
                     }
563 563
                 }
564 564
                 
565
-                if(($wife = $sfamily->getWife()) &&
566
-                    ($wdate=$wife->getBirthDate()) &&
565
+                if (($wife = $sfamily->getWife()) &&
566
+                    ($wdate = $wife->getBirthDate()) &&
567 567
                     $wdate->isOK() && $mdate->isOK()) {
568 568
                     if (FunctionsPrint::isDateWithinChartsRange($wdate)) {
569
-                        $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
569
+                        $birt_by_decade[(int)($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
570 570
                     }
571 571
                     $wage = Date::getAge($wdate, $mdate, 0);
572 572
                     if ($wage >= 0 && $wage <= $max_age) {
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                 }                
576 576
 
577 577
                 if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) {
578
-                    $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
578
+                    $marr_by_decade[(int)($mdate->gregorianYear() / 10) * 10] .= $husb->getSex().$wife->getSex();
579 579
                 }
580 580
                 
581 581
                 $listFamSosa[$sosa] = $sfamily;
Please login to merge, or discard this patch.