Completed
Push — master ( 95506d...0f93c5 )
by Jonathan
07:55
created
src/Webtrees/Module/AdminTasks/Views/AdminConfigView.php 1 patch
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.
src/Webtrees/Module/Sosa/SosaConfigController.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -29,66 +29,66 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class SosaConfigController extends MvcController
31 31
 {      
32
-    /**
33
-     * Check if the user can update the sosa ancestors list
34
-     * 
35
-     * @return bool
36
-     */
37
-    protected function canUpdate() {
38
-        global $WT_TREE;
32
+	/**
33
+	 * Check if the user can update the sosa ancestors list
34
+	 * 
35
+	 * @return bool
36
+	 */
37
+	protected function canUpdate() {
38
+		global $WT_TREE;
39 39
         
40
-        $user_id = Filter::postInteger('userid', -1) ?: Filter::getInteger('userid', -1);
41
-        return Auth::check() && 
42
-            ( 
43
-                $user_id == Auth::user()->getUserId() ||        // Allow update for yourself
44
-                ($user_id == -1 && Auth::isManager($WT_TREE))   // Allow a manager to update the default user
45
-             );
46
-    }
40
+		$user_id = Filter::postInteger('userid', -1) ?: Filter::getInteger('userid', -1);
41
+		return Auth::check() && 
42
+			( 
43
+				$user_id == Auth::user()->getUserId() ||        // Allow update for yourself
44
+				($user_id == -1 && Auth::isManager($WT_TREE))   // Allow a manager to update the default user
45
+			 );
46
+	}
47 47
     
48
-    /**
49
-     * Saves Sosa's user preferences (root individual for the user).
50
-     * 
51
-     * @param BaseController $controller
52
-     * @return bool True is saving successfull
53
-     */
54
-    protected function update(BaseController $controller) {
55
-        global $WT_TREE;          
56
-        if($this->canUpdate() && Filter::checkCsrf()) 
57
-        {            
58
-            $indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE);
59
-            $user = User::find(Filter::postInteger('userid', -1));
48
+	/**
49
+	 * Saves Sosa's user preferences (root individual for the user).
50
+	 * 
51
+	 * @param BaseController $controller
52
+	 * @return bool True is saving successfull
53
+	 */
54
+	protected function update(BaseController $controller) {
55
+		global $WT_TREE;          
56
+		if($this->canUpdate() && Filter::checkCsrf()) 
57
+		{            
58
+			$indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE);
59
+			$user = User::find(Filter::postInteger('userid', -1));
60 60
             
61
-            if($user  && $indi) {
62
-                $WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref());
63
-                $controller->addInlineJavascript('
61
+			if($user  && $indi) {
62
+				$WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref());
63
+				$controller->addInlineJavascript('
64 64
                     $( document ).ready(function() {
65 65
                         majComputeSosa('.$user->getUserId().');
66 66
                     });');
67
-                FlashMessages::addMessage(I18N::translate('The preferences have been updated.'));
68
-                return true;
69
-            }
70
-        }
71
-        FlashMessages::addMessage(I18N::translate('An error occurred while saving data...'), 'danger');
72
-        return false;
73
-    }
67
+				FlashMessages::addMessage(I18N::translate('The preferences have been updated.'));
68
+				return true;
69
+			}
70
+		}
71
+		FlashMessages::addMessage(I18N::translate('An error occurred while saving data...'), 'danger');
72
+		return false;
73
+	}
74 74
     
75
-    /**
76
-     * Pages
77
-     */
75
+	/**
76
+	 * Pages
77
+	 */
78 78
     
79
-    /**
80
-     * SosaConfig@index
81
-     */
82
-    public function index() {
83
-        global $WT_TREE;
79
+	/**
80
+	 * SosaConfig@index
81
+	 */
82
+	public function index() {
83
+		global $WT_TREE;
84 84
         
85
-        $controller = new PageController();
86
-        $controller
87
-        ->setPageTitle(I18N::translate('Sosa Configuration'))
88
-        ->restrictAccess(Auth::check())
89
-        ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
90
-        ->addInlineJavascript('autocomplete();')
91
-        ->addInlineJavascript('
85
+		$controller = new PageController();
86
+		$controller
87
+		->setPageTitle(I18N::translate('Sosa Configuration'))
88
+		->restrictAccess(Auth::check())
89
+		->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
90
+		->addInlineJavascript('autocomplete();')
91
+		->addInlineJavascript('
92 92
             $( document ).ready(function() {
93 93
                 $("#bt_sosa_compute").click(function() {
94 94
                     majComputeSosa($("#maj_sosa_input_userid, #maj-sosa-config-select option:selected").val());
@@ -105,83 +105,83 @@  discard block
 block discarded – undo
105 105
                   });
106 106
             }');
107 107
         
108
-        $action = Filter::post('action');
109
-        if($action === 'update') $this->update($controller);
108
+		$action = Filter::post('action');
109
+		if($action === 'update') $this->update($controller);
110 110
         
111
-        $view_bag = new ViewBag();
112
-        $view_bag->set('title', $controller->getPageTitle());
113
-        $view_bag->set('tree', $WT_TREE);
114
-        $view_bag->set('form_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaConfig&ged='.$WT_TREE->getNameUrl());
111
+		$view_bag = new ViewBag();
112
+		$view_bag->set('title', $controller->getPageTitle());
113
+		$view_bag->set('tree', $WT_TREE);
114
+		$view_bag->set('form_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaConfig&ged='.$WT_TREE->getNameUrl());
115 115
         
116
-        $users_root = array();
117
-        $users_js_array = 'var users_array = [];';
118
-        if(Auth::check()) {
119
-            $root_id = $WT_TREE->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID');
120
-            $users_root[] = array( 'user' => Auth::user(), 'rootid' => $root_id);
121
-            $users_js_array .=  'users_array["'.Auth::user()->getUserId().'"] = "' . $root_id . '";';
116
+		$users_root = array();
117
+		$users_js_array = 'var users_array = [];';
118
+		if(Auth::check()) {
119
+			$root_id = $WT_TREE->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID');
120
+			$users_root[] = array( 'user' => Auth::user(), 'rootid' => $root_id);
121
+			$users_js_array .=  'users_array["'.Auth::user()->getUserId().'"] = "' . $root_id . '";';
122 122
             
123
-            if(Auth::isManager($WT_TREE)) {
124
-                $default_user = User::find(-1);
125
-                $default_root_id = $WT_TREE->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID');
126
-                $users_root[] = array( 'user' => $default_user, 'rootid' => $default_root_id);
127
-                $users_js_array .=  'users_array["'.$default_user->getUserId().'"] = "' . $default_root_id . '";';
128
-            }
129
-        }
130
-        $view_bag->set('users_settings', $users_root);       
123
+			if(Auth::isManager($WT_TREE)) {
124
+				$default_user = User::find(-1);
125
+				$default_root_id = $WT_TREE->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID');
126
+				$users_root[] = array( 'user' => $default_user, 'rootid' => $default_root_id);
127
+				$users_js_array .=  'users_array["'.$default_user->getUserId().'"] = "' . $default_root_id . '";';
128
+			}
129
+		}
130
+		$view_bag->set('users_settings', $users_root);       
131 131
         
132
-        $controller->addInlineJavascript($users_js_array . '            
132
+		$controller->addInlineJavascript($users_js_array . '            
133 133
                 $("#maj-sosa-config-select").change(function() {
134 134
                     $("#rootid").val(users_array[this.value]);
135 135
                 });
136 136
              ');
137 137
         
138
-        ViewFactory::make('SosaConfig', $this, $controller, $view_bag)->render();   
139
-    }
138
+		ViewFactory::make('SosaConfig', $this, $controller, $view_bag)->render();   
139
+	}
140 140
     
141
-    /**
142
-     * SosaConfig@computeAll
143
-     */
144
-    public function computeAll() {
145
-        global $WT_TREE;
141
+	/**
142
+	 * SosaConfig@computeAll
143
+	 */
144
+	public function computeAll() {
145
+		global $WT_TREE;
146 146
         
147
-        $controller = new AjaxController();
148
-        $controller->restrictAccess($this->canUpdate());
147
+		$controller = new AjaxController();
148
+		$controller->restrictAccess($this->canUpdate());
149 149
         
150
-        $view_bag = new ViewBag();
151
-        $view_bag->set('is_success', false);
150
+		$view_bag = new ViewBag();
151
+		$view_bag->set('is_success', false);
152 152
         
153
-        $user = User::find(Filter::getInteger('userid', -1));
154
-        if($user) {
155
-            $calculator = new SosaCalculator($WT_TREE, $user);
156
-            if($calculator->computeAll()) $view_bag->set('is_success', true);
157
-        }
158
-        ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render();
159
-    }
153
+		$user = User::find(Filter::getInteger('userid', -1));
154
+		if($user) {
155
+			$calculator = new SosaCalculator($WT_TREE, $user);
156
+			if($calculator->computeAll()) $view_bag->set('is_success', true);
157
+		}
158
+		ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render();
159
+	}
160 160
     
161
-    /**
162
-     * SosaConfig@computePartial
163
-     */
164
-    public function computePartial() {
165
-        global $WT_TREE;
161
+	/**
162
+	 * SosaConfig@computePartial
163
+	 */
164
+	public function computePartial() {
165
+		global $WT_TREE;
166 166
     
167
-        $controller = new AjaxController();
168
-        $controller->restrictAccess($this->canUpdate());
167
+		$controller = new AjaxController();
168
+		$controller->restrictAccess($this->canUpdate());
169 169
     
170
-        $view_bag = new ViewBag();
171
-        $view_bag->set('is_success', false);
170
+		$view_bag = new ViewBag();
171
+		$view_bag->set('is_success', false);
172 172
     
173
-        $user = User::find(Filter::getInteger('userid', -1));
174
-        $indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE);
173
+		$user = User::find(Filter::getInteger('userid', -1));
174
+		$indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE);
175 175
         
176
-        if($user && $indi) {
177
-            $calculator = new SosaCalculator($WT_TREE, $user);
178
-            if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true);
179
-        }
180
-        else {
181
-            $view_bag->set('error', I18N::translate('Non existing individual'));
182
-        }
176
+		if($user && $indi) {
177
+			$calculator = new SosaCalculator($WT_TREE, $user);
178
+			if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true);
179
+		}
180
+		else {
181
+			$view_bag->set('error', I18N::translate('Non existing individual'));
182
+		}
183 183
             
184
-        ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render();
185
-    }
184
+		ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render();
185
+	}
186 186
     
187 187
 }
188 188
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Model/SosaCalculator.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -19,118 +19,118 @@
 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
-            $tmp_sosatable = array();
74
-            $this->addNode($indi, 1);
75
-            $this->flushTmpSosaTable(true);
76
-            return true;
77
-        }     
78
-        return false;
79
-    }
64
+	/**
65
+	 * Compute all Sosa ancestors from the user's root individual.
66
+	 * @return bool Result of the computation
67
+	 */
68
+	public function computeAll() {
69
+		$root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');        
70
+		$indi = Individual::getInstance($root_id, $this->tree);
71
+		if($indi){
72
+			$this->sosa_provider->deleteAll();
73
+			$tmp_sosatable = array();
74
+			$this->addNode($indi, 1);
75
+			$this->flushTmpSosaTable(true);
76
+			return true;
77
+		}     
78
+		return false;
79
+	}
80 80
     
81
-    /**
82
-     * Compute all Sosa Ancestors from a specified Individual
83
-     * @param Individual $indi
84
-     * @return bool Result of the computation
85
-     */
86
-    public function computeFromIndividual(Individual $indi) {
87
-        $tmp_sosatable = array();
88
-        $dindi = new \MyArtJaub\Webtrees\Individual($indi);
89
-        $current_sosas = $dindi->getSosaNumbers();
90
-        foreach($current_sosas as $current_sosa => $gen) {
91
-            $this->sosa_provider->deleteAncestors($current_sosa);
92
-            $this->addNode($indi, $current_sosa);
93
-        }
94
-        $this->flushTmpSosaTable(true);
95
-        return true;
96
-    }
81
+	/**
82
+	 * Compute all Sosa Ancestors from a specified Individual
83
+	 * @param Individual $indi
84
+	 * @return bool Result of the computation
85
+	 */
86
+	public function computeFromIndividual(Individual $indi) {
87
+		$tmp_sosatable = array();
88
+		$dindi = new \MyArtJaub\Webtrees\Individual($indi);
89
+		$current_sosas = $dindi->getSosaNumbers();
90
+		foreach($current_sosas as $current_sosa => $gen) {
91
+			$this->sosa_provider->deleteAncestors($current_sosa);
92
+			$this->addNode($indi, $current_sosa);
93
+		}
94
+		$this->flushTmpSosaTable(true);
95
+		return true;
96
+	}
97 97
     
98
-    /**
99
-     * Recursive method to add individual to the Sosa table, and flush it regularly
100
-     * @param Individual $indi Individual to add
101
-     * @param unknown $sosa Individual's sosa
102
-     */
103
-    protected function addNode(Individual $indi, $sosa) {                
104
-        $birth_year = $indi->getEstimatedBirthDate()->gregorianYear();
105
-        $death_year = $indi->getEstimatedDeathDate()->gregorianYear();
98
+	/**
99
+	 * Recursive method to add individual to the Sosa table, and flush it regularly
100
+	 * @param Individual $indi Individual to add
101
+	 * @param unknown $sosa Individual's sosa
102
+	 */
103
+	protected function addNode(Individual $indi, $sosa) {                
104
+		$birth_year = $indi->getEstimatedBirthDate()->gregorianYear();
105
+		$death_year = $indi->getEstimatedDeathDate()->gregorianYear();
106 106
         
107
-        $this->tmp_sosa_table[] = array(
108
-            'indi' => $indi->getXref(), 
109
-            'sosa' => $sosa, 
110
-            'birth_year' => $birth_year,
111
-            'death_year' => $death_year
112
-        );
107
+		$this->tmp_sosa_table[] = array(
108
+			'indi' => $indi->getXref(), 
109
+			'sosa' => $sosa, 
110
+			'birth_year' => $birth_year,
111
+			'death_year' => $death_year
112
+		);
113 113
         
114
-        $this->flushTmpSosaTable();
114
+		$this->flushTmpSosaTable();
115 115
         
116
-        if($fam = $indi->getPrimaryChildFamily()) {
117
-            if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa);
118
-            if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1);
119
-        }
120
-    }
116
+		if($fam = $indi->getPrimaryChildFamily()) {
117
+			if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa);
118
+			if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1);
119
+		}
120
+	}
121 121
     
122
-    /**
123
-     * Write sosas in the table, if the number of items is superior to the limit, or if forced.
124
-     *
125
-     * @param bool $force Should the flush be forced
126
-     */
127
-    protected function flushTmpSosaTable($force = false) {
128
-        if( count($this->tmp_sosa_table)> 0 && 
129
-            ($force ||  count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){            
130
-                $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table);
131
-                $this->tmp_sosa_table = array();
132
-        }
133
-    }
122
+	/**
123
+	 * Write sosas in the table, if the number of items is superior to the limit, or if forced.
124
+	 *
125
+	 * @param bool $force Should the flush be forced
126
+	 */
127
+	protected function flushTmpSosaTable($force = false) {
128
+		if( count($this->tmp_sosa_table)> 0 && 
129
+			($force ||  count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){            
130
+				$this->sosa_provider->insertOrUpdate($this->tmp_sosa_table);
131
+				$this->tmp_sosa_table = array();
132
+		}
133
+	}
134 134
                
135 135
 }
136 136
  
137 137
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Model/SosaProvider.php 1 patch
Indentation   +549 added lines, -549 removed lines patch added patch discarded remove patch
@@ -22,378 +22,378 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class SosaProvider {
24 24
     
25
-    /**
26
-     * Maximum number of generation the database is able to hold.
27
-     * @var int MAX_DB_GENERATIONS
28
-     */
29
-    const MAX_DB_GENERATIONS = 64;
30
-    
31
-    /**
32
-     * System's default user (ID -1 in the database
33
-     * @var User $default_user
34
-     */
35
-    protected static $default_user;
36
-    
37
-    /**
38
-     * Reference user
39
-     * @var User $user
40
-     */
41
-    protected $user;
42
-    
43
-    /**
44
-     * Reference tree
45
-     * @var Tree $tree
46
-     */
47
-    protected $tree;
48
-    
49
-    /**
50
-     * Cached list of Sosa Individuals by generation
51
-     * Format: key = generation, value = array ( sosa => Individual ID)
52
-     * @var array $sosa_list_by_gen
53
-     */
54
-    protected $sosa_list_by_gen;
55
-    
56
-    /**
57
-     * Cached list of Sosa Families by generation
58
-     * Format: key = generation, value = array ( sosa => Family ID)
59
-     * @var unknown $sosa_fam_list_by_gen
60
-     */
61
-    protected $sosa_fam_list_by_gen;
62
-    
63
-    /**
64
-     * Cached array of statistics by generation
65
-     * Format:  key = generation, 
66
-     *          value = array(
67
-     *              sosaCount, sosaTotalCount, diffSosaTotalCount, firstBirth, lastBirth, avgBirth
68
-     *           )
69
-     * @var array $statistics_tab
70
-     */
71
-    protected $statistics_tab;
72
-    
73
-    /**
74
-     * Has the provider's initialisation completed
75
-     * @var bool $is_setup
76
-     */
77
-    protected $is_setup;
78
-    
79
-    /**
80
-     * Constructor for Sosa Provider.
81
-     * A provider is defined in relation to a specific tree and reference user.
82
-     * 
83
-     * @param Tree $tree
84
-     * @param User $user
85
-     */
86
-    public function __construct(Tree $tree, User $user = null) {
87
-        if(self::$default_user === null) 
88
-            self::$default_user = User::find(-1);
25
+	/**
26
+	 * Maximum number of generation the database is able to hold.
27
+	 * @var int MAX_DB_GENERATIONS
28
+	 */
29
+	const MAX_DB_GENERATIONS = 64;
30
+    
31
+	/**
32
+	 * System's default user (ID -1 in the database
33
+	 * @var User $default_user
34
+	 */
35
+	protected static $default_user;
36
+    
37
+	/**
38
+	 * Reference user
39
+	 * @var User $user
40
+	 */
41
+	protected $user;
42
+    
43
+	/**
44
+	 * Reference tree
45
+	 * @var Tree $tree
46
+	 */
47
+	protected $tree;
48
+    
49
+	/**
50
+	 * Cached list of Sosa Individuals by generation
51
+	 * Format: key = generation, value = array ( sosa => Individual ID)
52
+	 * @var array $sosa_list_by_gen
53
+	 */
54
+	protected $sosa_list_by_gen;
55
+    
56
+	/**
57
+	 * Cached list of Sosa Families by generation
58
+	 * Format: key = generation, value = array ( sosa => Family ID)
59
+	 * @var unknown $sosa_fam_list_by_gen
60
+	 */
61
+	protected $sosa_fam_list_by_gen;
62
+    
63
+	/**
64
+	 * Cached array of statistics by generation
65
+	 * Format:  key = generation, 
66
+	 *          value = array(
67
+	 *              sosaCount, sosaTotalCount, diffSosaTotalCount, firstBirth, lastBirth, avgBirth
68
+	 *           )
69
+	 * @var array $statistics_tab
70
+	 */
71
+	protected $statistics_tab;
72
+    
73
+	/**
74
+	 * Has the provider's initialisation completed
75
+	 * @var bool $is_setup
76
+	 */
77
+	protected $is_setup;
78
+    
79
+	/**
80
+	 * Constructor for Sosa Provider.
81
+	 * A provider is defined in relation to a specific tree and reference user.
82
+	 * 
83
+	 * @param Tree $tree
84
+	 * @param User $user
85
+	 */
86
+	public function __construct(Tree $tree, User $user = null) {
87
+		if(self::$default_user === null) 
88
+			self::$default_user = User::find(-1);
89 89
         
90
-        $this->tree = $tree;
91
-        $this->user = $user;
92
-        $this->is_setup = true;
93
-        if($this->user === null) $this->user = Auth::user();
94
-        if(strlen($this->user->getUserId()) == 0) $this->user = self::$default_user;
90
+		$this->tree = $tree;
91
+		$this->user = $user;
92
+		$this->is_setup = true;
93
+		if($this->user === null) $this->user = Auth::user();
94
+		if(strlen($this->user->getUserId()) == 0) $this->user = self::$default_user;
95 95
         
96
-        // Check if the user, or the default user, has a root already setup;
97
-        if(!$this->getRootIndi()) {
98
-            if($this->user == self::$default_user) {  // If the default user is not setup
99
-                $this->is_setup = false;
100
-            }
101
-            else {
102
-                $this->user = self::$default_user;
103
-                $this->is_setup = $this->getRootIndi() === null;
104
-            }            
105
-        }
106
-    }
107
-    
108
-    /**
109
-     * Returns is the Provider has been successfully set up
110
-     * @return bool
111
-     */
112
-    public function isSetup() {
113
-        return $this->is_setup;
114
-    }
115
-    
116
-    /**
117
-     * Return the root individual for the reference tree and user.
118
-     * @return string Individual ID
119
-     */
120
-    public function getRootIndi() {
121
-        return $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
122
-    }
96
+		// Check if the user, or the default user, has a root already setup;
97
+		if(!$this->getRootIndi()) {
98
+			if($this->user == self::$default_user) {  // If the default user is not setup
99
+				$this->is_setup = false;
100
+			}
101
+			else {
102
+				$this->user = self::$default_user;
103
+				$this->is_setup = $this->getRootIndi() === null;
104
+			}            
105
+		}
106
+	}
107
+    
108
+	/**
109
+	 * Returns is the Provider has been successfully set up
110
+	 * @return bool
111
+	 */
112
+	public function isSetup() {
113
+		return $this->is_setup;
114
+	}
115
+    
116
+	/**
117
+	 * Return the root individual for the reference tree and user.
118
+	 * @return string Individual ID
119
+	 */
120
+	public function getRootIndi() {
121
+		return $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID');
122
+	}
123 123
        
124
-    /*****************
124
+	/*****************
125 125
      * DATA CRUD LAYER
126 126
      *****************/
127 127
     
128
-    /**
129
-     * Remove all Sosa entries related to the gedcom file and user
130
-     */
131
-    public function deleteAll() {
132
-        if(!$this->is_setup) return;
133
-        Database::prepare(
134
-            'DELETE FROM `##maj_sosa`'.
135
-            ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ')
136
-            ->execute(array(
137
-                'tree_id' => $this->tree->getTreeId(), 
138
-                'user_id' => $this->user->getUserId()                
139
-            ));
140
-    }
141
-    
142
-    /**
143
-     * Remove all ancestors of a sosa number
144
-     * 
145
-     * @param int $sosa
146
-     */
147
-    public function deleteAncestors($sosa) {
148
-        if(!$this->is_setup) return;
149
-        $gen = Functions::getGeneration($sosa);
150
-        Database::prepare(
151
-            'DELETE FROM `##maj_sosa`'.
152
-            ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' .
153
-            ' AND majs_gen >= :gen' .
154
-            ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa'
155
-        )->execute(array(
156
-            'tree_id' => $this->tree->getTreeId(), 
157
-            'user_id' => $this->user->getUserId(),
158
-            'gen' => $gen,
159
-            'sosa' => $sosa
160
-        ));
161
-    }    
162
-    
163
-    /**
164
-     * Insert (or update if already existing) a list of Sosa individuals
165
-     * @param array $sosa_records
166
-     */
167
-    public function insertOrUpdate($sosa_records) {
168
-        if(!$this->is_setup) return;
128
+	/**
129
+	 * Remove all Sosa entries related to the gedcom file and user
130
+	 */
131
+	public function deleteAll() {
132
+		if(!$this->is_setup) return;
133
+		Database::prepare(
134
+			'DELETE FROM `##maj_sosa`'.
135
+			' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ')
136
+			->execute(array(
137
+				'tree_id' => $this->tree->getTreeId(), 
138
+				'user_id' => $this->user->getUserId()                
139
+			));
140
+	}
141
+    
142
+	/**
143
+	 * Remove all ancestors of a sosa number
144
+	 * 
145
+	 * @param int $sosa
146
+	 */
147
+	public function deleteAncestors($sosa) {
148
+		if(!$this->is_setup) return;
149
+		$gen = Functions::getGeneration($sosa);
150
+		Database::prepare(
151
+			'DELETE FROM `##maj_sosa`'.
152
+			' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' .
153
+			' AND majs_gen >= :gen' .
154
+			' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa'
155
+		)->execute(array(
156
+			'tree_id' => $this->tree->getTreeId(), 
157
+			'user_id' => $this->user->getUserId(),
158
+			'gen' => $gen,
159
+			'sosa' => $sosa
160
+		));
161
+	}    
162
+    
163
+	/**
164
+	 * Insert (or update if already existing) a list of Sosa individuals
165
+	 * @param array $sosa_records
166
+	 */
167
+	public function insertOrUpdate($sosa_records) {
168
+		if(!$this->is_setup) return;
169 169
         
170
-        $treeid = $this->tree->getTreeId();
171
-        $userid = $this->user->getUserId();
172
-        $questionmarks_table = array();
173
-        $values_table = array();
170
+		$treeid = $this->tree->getTreeId();
171
+		$userid = $this->user->getUserId();
172
+		$questionmarks_table = array();
173
+		$values_table = array();
174 174
         
175
-        $i = 0;
176
-        foreach  ($sosa_records as $row) {
177
-            $gen = Functions::getGeneration($row['sosa']);
178
-            if($gen <= self::MAX_DB_GENERATIONS) {
179
-                $questionmarks_table[] = 
180
-                    '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')';
181
-                $values_table = array_merge(
182
-                    $values_table, 
183
-                    array(
184
-                        'tree_id'.$i => $treeid, 
185
-                        'user_id'.$i => $userid, 
186
-                        'sosa'.$i => $row['sosa'], 
187
-                        'indi_id'.$i => $row['indi'], 
188
-                        'gen'.$i => Functions::getGeneration($row['sosa']),
189
-                        'byear'.$i => $row['birth_year'],
190
-                        'dyear'.$i => $row['death_year']
191
-                    )
192
-                );
193
-            }
194
-            $i++;
195
-        }
175
+		$i = 0;
176
+		foreach  ($sosa_records as $row) {
177
+			$gen = Functions::getGeneration($row['sosa']);
178
+			if($gen <= self::MAX_DB_GENERATIONS) {
179
+				$questionmarks_table[] = 
180
+					'(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')';
181
+				$values_table = array_merge(
182
+					$values_table, 
183
+					array(
184
+						'tree_id'.$i => $treeid, 
185
+						'user_id'.$i => $userid, 
186
+						'sosa'.$i => $row['sosa'], 
187
+						'indi_id'.$i => $row['indi'], 
188
+						'gen'.$i => Functions::getGeneration($row['sosa']),
189
+						'byear'.$i => $row['birth_year'],
190
+						'dyear'.$i => $row['death_year']
191
+					)
192
+				);
193
+			}
194
+			$i++;
195
+		}
196 196
         
197
-        $sql = 'REPLACE INTO `##maj_sosa`' .
198
-            ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)' .
199
-            ' VALUES '. implode(',', $questionmarks_table);
200
-        Database::prepare($sql)->execute($values_table);
201
-    }
197
+		$sql = 'REPLACE INTO `##maj_sosa`' .
198
+			' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)' .
199
+			' VALUES '. implode(',', $questionmarks_table);
200
+		Database::prepare($sql)->execute($values_table);
201
+	}
202 202
     
203
-    /****************
203
+	/****************
204 204
      * SIMPLE QUERIES
205 205
      ****************/
206 206
     
207
-    /**
208
-     * Returns the list of Sosa numbers to which an individual is related.
209
-     * Format: key = sosa number, value = generation for the Sosa number
210
-     * 
211
-     * @param Individual $indi
212
-     * @return array Array of sosa numbers
213
-     */
214
-    public function getSosaNumbers(Individual $indi) {
215
-        if(!$this->is_setup) return array();
216
-        return Database::prepare(
217
-                'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'.
218
-                ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id'
219
-            )->execute(array(
220
-                'indi_id' => $indi->getXref(), 
221
-                'tree_id' => $this->tree->getTreeId(), 
222
-                'user_id' => $this->user->getUserId()
223
-            ))->fetchAssoc();
224
-    }
225
-    
226
-    /**
227
-     * Get the last generation of Sosa ancestors
228
-     *
229
-     * @return number Last generation if found, 1 otherwise
230
-     */
231
-    public function getLastGeneration() {
232
-        if(!$this->is_setup) return;
233
-        return Database::prepare(
234
-                'SELECT MAX(majs_gen) FROM `##maj_sosa`'.
235
-                ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'
236
-            )->execute(array(
237
-                'tree_id' => $this->tree->getTreeId(), 
238
-                'user_id' => $this->user->getUserId()                
239
-            ))->fetchOne() ?: 1;
240
-    }
241
-    
242
-    /*************
207
+	/**
208
+	 * Returns the list of Sosa numbers to which an individual is related.
209
+	 * Format: key = sosa number, value = generation for the Sosa number
210
+	 * 
211
+	 * @param Individual $indi
212
+	 * @return array Array of sosa numbers
213
+	 */
214
+	public function getSosaNumbers(Individual $indi) {
215
+		if(!$this->is_setup) return array();
216
+		return Database::prepare(
217
+				'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'.
218
+				' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id'
219
+			)->execute(array(
220
+				'indi_id' => $indi->getXref(), 
221
+				'tree_id' => $this->tree->getTreeId(), 
222
+				'user_id' => $this->user->getUserId()
223
+			))->fetchAssoc();
224
+	}
225
+    
226
+	/**
227
+	 * Get the last generation of Sosa ancestors
228
+	 *
229
+	 * @return number Last generation if found, 1 otherwise
230
+	 */
231
+	public function getLastGeneration() {
232
+		if(!$this->is_setup) return;
233
+		return Database::prepare(
234
+				'SELECT MAX(majs_gen) FROM `##maj_sosa`'.
235
+				' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'
236
+			)->execute(array(
237
+				'tree_id' => $this->tree->getTreeId(), 
238
+				'user_id' => $this->user->getUserId()                
239
+			))->fetchOne() ?: 1;
240
+	}
241
+    
242
+	/*************
243 243
      * SOSA LISTS
244 244
      *************/
245 245
     
246
-    /**
247
-     * Return the list of all sosas, with the generations it belongs to
248
-     *
249
-     * @param int $ged_id ID of the gedcom file
250
-     * @return array Associative array of Sosa ancestors, with their generation, comma separated
251
-     */
252
-    public function getAllSosaWithGenerations(){
253
-        if(!$this->is_setup) return array();
254
-        return Database::prepare(
255
-            'SELECT majs_i_id AS indi,' .
256
-            ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' .
257
-            ' FROM `##maj_sosa`' .
258
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' .
259
-            ' GROUP BY majs_i_id'
260
-        )->execute(array(
261
-            'tree_id' => $this->tree->getTreeId(),
262
-            'user_id' => $this->user->getUserId()
263
-        ))->fetchAssoc();
264
-    }
265
-    
266
-    /**
267
-     * Get an associative array of Sosa individuals in generation G. Keys are Sosa numbers, values individuals.
268
-     *
269
-     * @param number $gen Generation
270
-     * @return array Array of Sosa individuals
271
-     */
272
-    public function getSosaListAtGeneration($gen){
273
-        if(!$this->is_setup) return array();
274
-        if(!$this->sosa_list_by_gen)
275
-            $this->sosa_list_by_gen = array();
246
+	/**
247
+	 * Return the list of all sosas, with the generations it belongs to
248
+	 *
249
+	 * @param int $ged_id ID of the gedcom file
250
+	 * @return array Associative array of Sosa ancestors, with their generation, comma separated
251
+	 */
252
+	public function getAllSosaWithGenerations(){
253
+		if(!$this->is_setup) return array();
254
+		return Database::prepare(
255
+			'SELECT majs_i_id AS indi,' .
256
+			' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' .
257
+			' FROM `##maj_sosa`' .
258
+			' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' .
259
+			' GROUP BY majs_i_id'
260
+		)->execute(array(
261
+			'tree_id' => $this->tree->getTreeId(),
262
+			'user_id' => $this->user->getUserId()
263
+		))->fetchAssoc();
264
+	}
265
+    
266
+	/**
267
+	 * Get an associative array of Sosa individuals in generation G. Keys are Sosa numbers, values individuals.
268
+	 *
269
+	 * @param number $gen Generation
270
+	 * @return array Array of Sosa individuals
271
+	 */
272
+	public function getSosaListAtGeneration($gen){
273
+		if(!$this->is_setup) return array();
274
+		if(!$this->sosa_list_by_gen)
275
+			$this->sosa_list_by_gen = array();
276 276
         
277
-        if($gen){
278
-            if(!isset($this->sosa_list_by_gen[$gen])){
279
-                $this->sosa_list_by_gen[$gen] = Database::prepare(
280
-                    'SELECT majs_sosa AS sosa, majs_i_id AS indi'.
281
-                    ' FROM `##maj_sosa`'.
282
-                    ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
283
-                    ' AND majs_gen = :gen'.
284
-                    ' ORDER BY majs_sosa ASC')
285
-                ->execute(array(
286
-                    'tree_id' => $this->tree->getTreeId(),
287
-                    'user_id' => $this->user->getUserId(),
288
-                    'gen' => $gen
289
-                ))
290
-                ->fetchAssoc();
291
-            }
292
-            return $this->sosa_list_by_gen[$gen];
293
-        }
294
-        return array();
295
-    }
296
-    
297
-    /**
298
-     * Get an associative array of Sosa families in generation G. Keys are Sosa numbers for the husband, values families.
299
-     *
300
-     * @param number $gen Generation
301
-     * @return array Array of Sosa families
302
-     */
303
-    public function getFamilySosaListAtGeneration($gen){
304
-        if(!$this->is_setup) return array();
305
-        if(!$this->sosa_fam_list_by_gen)
306
-            $this->sosa_fam_list_by_gen = array();
277
+		if($gen){
278
+			if(!isset($this->sosa_list_by_gen[$gen])){
279
+				$this->sosa_list_by_gen[$gen] = Database::prepare(
280
+					'SELECT majs_sosa AS sosa, majs_i_id AS indi'.
281
+					' FROM `##maj_sosa`'.
282
+					' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
283
+					' AND majs_gen = :gen'.
284
+					' ORDER BY majs_sosa ASC')
285
+				->execute(array(
286
+					'tree_id' => $this->tree->getTreeId(),
287
+					'user_id' => $this->user->getUserId(),
288
+					'gen' => $gen
289
+				))
290
+				->fetchAssoc();
291
+			}
292
+			return $this->sosa_list_by_gen[$gen];
293
+		}
294
+		return array();
295
+	}
296
+    
297
+	/**
298
+	 * Get an associative array of Sosa families in generation G. Keys are Sosa numbers for the husband, values families.
299
+	 *
300
+	 * @param number $gen Generation
301
+	 * @return array Array of Sosa families
302
+	 */
303
+	public function getFamilySosaListAtGeneration($gen){
304
+		if(!$this->is_setup) return array();
305
+		if(!$this->sosa_fam_list_by_gen)
306
+			$this->sosa_fam_list_by_gen = array();
307 307
         
308
-        if($gen){
309
-            if(!isset($this->sosa_fam_list_by_gen[$gen])){
310
-                $this->sosa_fam_list_by_gen[$gen] = Database::prepare(
311
-                    'SELECT s1.majs_sosa AS sosa, f_id AS fam'.
312
-                    ' FROM `##families`'.
313
-                    ' INNER JOIN `##maj_sosa` AS s1 ON (`##families`.f_husb = s1.majs_i_id AND `##families`.f_file = s1.majs_gedcom_id)'.
314
-                    ' INNER JOIN `##maj_sosa` AS s2 ON (`##families`.f_wife = s2.majs_i_id AND `##families`.f_file = s2.majs_gedcom_id)'.
315
-                    ' WHERE s1.majs_sosa + 1 = s2.majs_sosa'.
316
-                    ' AND s1.majs_gedcom_id= :tree_id AND s1.majs_user_id=:user_id'.
317
-                    ' AND s2.majs_gedcom_id= :tree_id AND s2.majs_user_id=:user_id'.
318
-                    ' AND s1.majs_gen = :gen'.
319
-                    ' ORDER BY s1.majs_sosa ASC'
320
-                    )
321
-                    ->execute(array(
322
-                        'tree_id' => $this->tree->getTreeId(),
323
-                        'user_id' => $this->user->getUserId(),
324
-                        'gen' => $gen
325
-                    ))
326
-                    ->fetchAssoc();
327
-            }
328
-            return $this->sosa_fam_list_by_gen[$gen];
329
-        }
330
-        return array();
331
-    }
332
-    
333
-    /**
334
-     * Get an associative array of Sosa individuals in generation G who are missing parents. Keys are Sosa numbers, values individuals.
335
-     *
336
-     * @param number $gen Generation
337
-     * @return array Array of Sosa individuals
338
-     */
339
-    public function getMissingSosaListAtGeneration($gen){
340
-        if(!$this->is_setup) return array();    
341
-        if($gen){
342
-            return $this->sosa_list_by_gen[$gen] = Database::prepare(
343
-                'SELECT schild.majs_sosa sosa, schild.majs_i_id indi, sfat.majs_sosa IS NOT NULL has_father, smot.majs_sosa IS NOT NULL has_mother'.
344
-                ' FROM `##maj_sosa` schild'.
345
-                ' LEFT JOIN `##maj_sosa` sfat ON ((schild.majs_sosa * 2) = sfat.majs_sosa AND schild.majs_gedcom_id = sfat.majs_gedcom_id AND schild.majs_user_id = sfat.majs_user_id)'.
346
-                ' LEFT JOIN `##maj_sosa` smot ON ((schild.majs_sosa * 2 + 1) = smot.majs_sosa AND schild.majs_gedcom_id = smot.majs_gedcom_id AND schild.majs_user_id = smot.majs_user_id)'.
347
-                ' WHERE schild.majs_gedcom_id = :tree_id AND schild.majs_user_id = :user_id'.
348
-                ' AND schild.majs_gen = :gen'.
349
-                ' AND (sfat.majs_sosa IS NULL OR smot.majs_sosa IS NULL)'.
350
-                ' ORDER BY schild.majs_sosa ASC')
351
-                ->execute(array(
352
-                    'tree_id' => $this->tree->getTreeId(),
353
-                    'user_id' => $this->user->getUserId(),
354
-                    'gen' => $gen - 1
355
-                ))->fetchAll(\PDO::FETCH_ASSOC);
356
-        }
357
-        return array();
358
-    }
359
-    
360
-    
361
-    
362
-    /*************
308
+		if($gen){
309
+			if(!isset($this->sosa_fam_list_by_gen[$gen])){
310
+				$this->sosa_fam_list_by_gen[$gen] = Database::prepare(
311
+					'SELECT s1.majs_sosa AS sosa, f_id AS fam'.
312
+					' FROM `##families`'.
313
+					' INNER JOIN `##maj_sosa` AS s1 ON (`##families`.f_husb = s1.majs_i_id AND `##families`.f_file = s1.majs_gedcom_id)'.
314
+					' INNER JOIN `##maj_sosa` AS s2 ON (`##families`.f_wife = s2.majs_i_id AND `##families`.f_file = s2.majs_gedcom_id)'.
315
+					' WHERE s1.majs_sosa + 1 = s2.majs_sosa'.
316
+					' AND s1.majs_gedcom_id= :tree_id AND s1.majs_user_id=:user_id'.
317
+					' AND s2.majs_gedcom_id= :tree_id AND s2.majs_user_id=:user_id'.
318
+					' AND s1.majs_gen = :gen'.
319
+					' ORDER BY s1.majs_sosa ASC'
320
+					)
321
+					->execute(array(
322
+						'tree_id' => $this->tree->getTreeId(),
323
+						'user_id' => $this->user->getUserId(),
324
+						'gen' => $gen
325
+					))
326
+					->fetchAssoc();
327
+			}
328
+			return $this->sosa_fam_list_by_gen[$gen];
329
+		}
330
+		return array();
331
+	}
332
+    
333
+	/**
334
+	 * Get an associative array of Sosa individuals in generation G who are missing parents. Keys are Sosa numbers, values individuals.
335
+	 *
336
+	 * @param number $gen Generation
337
+	 * @return array Array of Sosa individuals
338
+	 */
339
+	public function getMissingSosaListAtGeneration($gen){
340
+		if(!$this->is_setup) return array();    
341
+		if($gen){
342
+			return $this->sosa_list_by_gen[$gen] = Database::prepare(
343
+				'SELECT schild.majs_sosa sosa, schild.majs_i_id indi, sfat.majs_sosa IS NOT NULL has_father, smot.majs_sosa IS NOT NULL has_mother'.
344
+				' FROM `##maj_sosa` schild'.
345
+				' LEFT JOIN `##maj_sosa` sfat ON ((schild.majs_sosa * 2) = sfat.majs_sosa AND schild.majs_gedcom_id = sfat.majs_gedcom_id AND schild.majs_user_id = sfat.majs_user_id)'.
346
+				' LEFT JOIN `##maj_sosa` smot ON ((schild.majs_sosa * 2 + 1) = smot.majs_sosa AND schild.majs_gedcom_id = smot.majs_gedcom_id AND schild.majs_user_id = smot.majs_user_id)'.
347
+				' WHERE schild.majs_gedcom_id = :tree_id AND schild.majs_user_id = :user_id'.
348
+				' AND schild.majs_gen = :gen'.
349
+				' AND (sfat.majs_sosa IS NULL OR smot.majs_sosa IS NULL)'.
350
+				' ORDER BY schild.majs_sosa ASC')
351
+				->execute(array(
352
+					'tree_id' => $this->tree->getTreeId(),
353
+					'user_id' => $this->user->getUserId(),
354
+					'gen' => $gen - 1
355
+				))->fetchAll(\PDO::FETCH_ASSOC);
356
+		}
357
+		return array();
358
+	}
359
+    
360
+    
361
+    
362
+	/*************
363 363
      * STATISTICS
364 364
      *************/
365
-    /**
366
-     * Get the statistic array detailed by generation.
367
-     * Statistics for each generation are:
368
-     * 	- The number of Sosa in generation
369
-     * 	- The number of Sosa up to generation
370
-     *  - The number of distinct Sosa up to generation
371
-     *  - The year of the first birth in generation
372
-     *  - The year of the last birth in generation
373
-     *  - The average year of birth in generation
374
-     *
375
-     * @return array Statistics array
376
-     */
377
-    public function getStatisticsByGeneration() {
378
-        if(!$this->is_setup) return array();
379
-        if(!$this->statistics_tab) {
380
-            $this->statistics_tab = array();
381
-            if($maxGeneration = $this->getLastGeneration()) {
382
-                for ($gen = 1; $gen <= $maxGeneration; $gen++) {
383
-                    $birthStats = $this->getStatsBirthYearInGeneration($gen);
384
-                    $this->statistics_tab[$gen] = array(
385
-                        'sosaCount'				=>	$this->getSosaCountAtGeneration($gen),
386
-                        'sosaTotalCount'		=>	$this->getSosaCountUpToGeneration($gen),
387
-                        'diffSosaTotalCount'	=>	$this->getDifferentSosaCountUpToGeneration($gen),
388
-                        'firstBirth'			=>	$birthStats['first'],
389
-                        'lastBirth'				=>	$birthStats['last'],
390
-                        'avgBirth'				=>	$birthStats['avg']
391
-                    );
392
-                }
393
-            }
394
-        }
395
-        return $this->statistics_tab;        
396
-    }
365
+	/**
366
+	 * Get the statistic array detailed by generation.
367
+	 * Statistics for each generation are:
368
+	 * 	- The number of Sosa in generation
369
+	 * 	- The number of Sosa up to generation
370
+	 *  - The number of distinct Sosa up to generation
371
+	 *  - The year of the first birth in generation
372
+	 *  - The year of the last birth in generation
373
+	 *  - The average year of birth in generation
374
+	 *
375
+	 * @return array Statistics array
376
+	 */
377
+	public function getStatisticsByGeneration() {
378
+		if(!$this->is_setup) return array();
379
+		if(!$this->statistics_tab) {
380
+			$this->statistics_tab = array();
381
+			if($maxGeneration = $this->getLastGeneration()) {
382
+				for ($gen = 1; $gen <= $maxGeneration; $gen++) {
383
+					$birthStats = $this->getStatsBirthYearInGeneration($gen);
384
+					$this->statistics_tab[$gen] = array(
385
+						'sosaCount'				=>	$this->getSosaCountAtGeneration($gen),
386
+						'sosaTotalCount'		=>	$this->getSosaCountUpToGeneration($gen),
387
+						'diffSosaTotalCount'	=>	$this->getDifferentSosaCountUpToGeneration($gen),
388
+						'firstBirth'			=>	$birthStats['first'],
389
+						'lastBirth'				=>	$birthStats['last'],
390
+						'avgBirth'				=>	$birthStats['avg']
391
+					);
392
+				}
393
+			}
394
+		}
395
+		return $this->statistics_tab;        
396
+	}
397 397
     
398 398
 	/**
399 399
 	 * How many individuals exist in the tree.
@@ -401,205 +401,205 @@  discard block
 block discarded – undo
401 401
 	 * @return int
402 402
 	 */
403 403
 	public function getTotalIndividuals() {
404
-	    if(!$this->is_setup) return 0;
405
-	    return Database::prepare(
406
-	        'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' .
407
-	        ' WHERE i_file = :tree_id')
408
-	        ->execute(array('tree_id' => $this->tree->getTreeId()))
409
-	        ->fetchOne() ?: 0;
404
+		if(!$this->is_setup) return 0;
405
+		return Database::prepare(
406
+			'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' .
407
+			' WHERE i_file = :tree_id')
408
+			->execute(array('tree_id' => $this->tree->getTreeId()))
409
+			->fetchOne() ?: 0;
410 410
 	}
411 411
     
412
-    /**
413
-     * Get the total Sosa count for all generations
414
-     *
415
-     * @return number Number of Sosas
416
-     */
417
-    public function getSosaCount(){
418
-        if(!$this->is_setup) return 0;
419
-        return Database::prepare(
420
-            'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' .
421
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id')
422
-            ->execute(array(
423
-                'tree_id' => $this->tree->getTreeId(), 
424
-                'user_id' => $this->user->getUserId() 
425
-            ))->fetchOne() ?: 0;
426
-    }
427
-    
428
-    /**
429
-     * Get the number of Sosa in a specific generation.
430
-     *
431
-     * @param number $gen Generation
432
-     * @return number Number of Sosas in generation
433
-     */
434
-    public function getSosaCountAtGeneration($gen){
435
-        if(!$this->is_setup) return 0;
436
-        return Database::prepare(
437
-            'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' .
438
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
439
-            ' AND majs_gen= :gen')
440
-        ->execute(array(
441
-                'tree_id' => $this->tree->getTreeId(), 
442
-                'user_id' => $this->user->getUserId(),
443
-                'gen' => $gen            
444
-        ))->fetchOne() ?: 0;
445
-    }
446
-    
447
-    /**
448
-     * Get the total number of Sosa up to a specific generation.
449
-     *
450
-     * @param number $gen Generation
451
-     * @return number Total number of Sosas up to generation
452
-     */
453
-    public function getSosaCountUpToGeneration($gen){
454
-        if(!$this->is_setup) return 0;
455
-        return Database::prepare(
456
-            'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' .
457
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
458
-            ' AND majs_gen <= :gen')
459
-        ->execute(array(
460
-                'tree_id' => $this->tree->getTreeId(), 
461
-                'user_id' => $this->user->getUserId(),
462
-                'gen' => $gen 
463
-        ))->fetchOne() ?: 0;
464
-    }
465
-    
466
-    /**
467
-     * Get the total number of distinct Sosa individual for all generations.
468
-     *
469
-     * @return number Total number of distinct individual
470
-     */
471
-    public function getDifferentSosaCount(){
472
-        if(!$this->is_setup) return 0;
473
-        return Database::prepare(
474
-            'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' .
475
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id')
476
-        ->execute(array(
477
-                'tree_id' => $this->tree->getTreeId(), 
478
-                'user_id' => $this->user->getUserId()
479
-        ))->fetchOne() ?: 0;
480
-    }
481
-    
482
-    /**
483
-     * Get the number of distinct Sosa individual up to a specific generation.
484
-     *
485
-     * @param number $gen Generation
486
-     * @return number Number of distinct Sosa individuals up to generation
487
-     */
488
-    public function getDifferentSosaCountUpToGeneration($gen){
489
-        if(!$this->is_setup) return 0;
490
-        return Database::prepare(
491
-            'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' .
492
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
493
-            ' AND majs_gen <= :gen')
494
-        ->execute(array(
495
-                'tree_id' => $this->tree->getTreeId(), 
496
-                'user_id' => $this->user->getUserId(),
497
-                'gen' => $gen 
498
-        ))->fetchOne() ?: 0;
499
-    }
500
-    
501
-    /**
502
-     * Get an array of birth statistics for a specific generation
503
-     * Statistics are :
504
-     * 	- first : First birth year in generation
505
-     *  - last : Last birth year in generation
506
-     *  - avg : Average birth year
507
-     *
508
-     * @param number $gen Generation
509
-     * @return array Birth statistics array
510
-     */
511
-    public function getStatsBirthYearInGeneration($gen){
512
-        if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0);
513
-        return Database::prepare(
514
-            'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'.
515
-            ' FROM `##maj_sosa`' .
516
-            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
517
-            ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year')
518
-            ->execute(array(
519
-                'tree_id' => $this->tree->getTreeId(), 
520
-                'user_id' => $this->user->getUserId(),
521
-                'gen' => $gen,
522
-                'birth_year' => 0))
523
-            ->fetchOneRow(\PDO::FETCH_ASSOC) ?: array('first' => 0, 'avg' => 0, 'last' => 0);
524
-    }
525
-    
526
-    /**
527
-     * Get the mean generation time, based on a linear regression of birth years and generations
528
-     *
529
-     * @return number|NULL Mean generation time
530
-     */
531
-    public function getMeanGenerationTime(){
532
-        if(!$this->is_setup) return;
533
-        if(!$this->statistics_tab){
534
-            $this->getStatisticsByGeneration();
535
-        }
536
-        //Linear regression on x=generation and y=birthdate
537
-        $sum_xy = 0;
538
-        $sum_x=0;
539
-        $sum_y=0;
540
-        $sum_x2=0;
541
-        $n=count($this->statistics_tab);
542
-        foreach($this->statistics_tab as $gen=>$stats){
543
-            $sum_xy+=$gen*$stats['avgBirth'];
544
-            $sum_x+=$gen;
545
-            $sum_y+=$stats['avgBirth'];
546
-            $sum_x2+=$gen*$gen;
547
-        }
548
-        $denom=($n*$sum_x2)-($sum_x*$sum_x);
549
-        if($denom!=0){
550
-            return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom);
551
-        }
552
-        return null;
553
-    }
554
-    
555
-    /**
556
-     * Return a computed array of statistics about the dispersion of ancestors across the ancestors
557
-     * at a specified generation.
558
-     * This statistics cannot be used for generations above 11, as it would cause a out of range in MySQL
559
-     * 
560
-     * Format: 
561
-     *  - key : a base-2 representation of the ancestor at generation G for which exclusive ancestors have been found,
562
-     *          -1 is used for shared ancestors
563
-     *          For instance base2(0100) = base10(4) represent the maternal grand father
564
-     *  - values: number of ancestors exclusively in the ancestors of the ancestor in key
565
-     *  
566
-     *  For instance a result at generation 3 could be :
567
-     *      array (   -1        =>  12      -> 12 ancestors are shared by the grand-parents
568
-     *                base10(1) =>  32      -> 32 ancestors are exclusive to the paternal grand-father
569
-     *                base10(2) =>  25      -> 25 ancestors are exclusive to the paternal grand-mother
570
-     *                base10(4) =>  12      -> 12 ancestors are exclusive to the maternal grand-father
571
-     *                base10(8) =>  30      -> 30 ancestors are exclusive to the maternal grand-mother
572
-     *            )
573
-     *  
574
-     * @param int $gen Reference generation
575
-     * @return array
576
-     */
577
-    public function getAncestorDispersionForGen($gen) {
578
-        if(!$this->is_setup || $gen > 11) return array();  // Going further than 11 gen will be out of range in the query
579
-        return Database::prepare(
580
-            'SELECT branches, count(i_id)'.
581
-            ' FROM ('.
582
-            '   SELECT i_id,'.
583
-            '       CASE'.
584
-            '           WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'.
585
-            '           ELSE -1'.   // We put all ancestors shared between some branches in the same bucket
586
-            '       END branches'.
587
-            '   FROM ('.
588
-            '       SELECT DISTINCT majs_i_id i_id,'.
589
-            '           POW(2, FLOOR(majs_sosa / POW(2, (majs_gen - :gen))) - POW(2, :gen -1)) branch'.
590
-            '       FROM `##maj_sosa`'.
591
-            '       WHERE majs_gedcom_id = :tree_id AND majs_user_id = :user_id'.
592
-            '           AND majs_gen >= :gen'.
593
-            '   ) indistat'.
594
-            '   GROUP BY i_id'.
595
-            ') grouped'.
596
-            ' GROUP BY branches')
597
-            ->execute(array(
598
-                'tree_id' => $this->tree->getTreeId(), 
599
-                'user_id' => $this->user->getUserId(),
600
-                'gen' => $gen
601
-            ))->fetchAssoc() ?: array();
602
-    }
412
+	/**
413
+	 * Get the total Sosa count for all generations
414
+	 *
415
+	 * @return number Number of Sosas
416
+	 */
417
+	public function getSosaCount(){
418
+		if(!$this->is_setup) return 0;
419
+		return Database::prepare(
420
+			'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' .
421
+			' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id')
422
+			->execute(array(
423
+				'tree_id' => $this->tree->getTreeId(), 
424
+				'user_id' => $this->user->getUserId() 
425
+			))->fetchOne() ?: 0;
426
+	}
427
+    
428
+	/**
429
+	 * Get the number of Sosa in a specific generation.
430
+	 *
431
+	 * @param number $gen Generation
432
+	 * @return number Number of Sosas in generation
433
+	 */
434
+	public function getSosaCountAtGeneration($gen){
435
+		if(!$this->is_setup) return 0;
436
+		return Database::prepare(
437
+			'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' .
438
+			' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
439
+			' AND majs_gen= :gen')
440
+		->execute(array(
441
+				'tree_id' => $this->tree->getTreeId(), 
442
+				'user_id' => $this->user->getUserId(),
443
+				'gen' => $gen            
444
+		))->fetchOne() ?: 0;
445
+	}
446
+    
447
+	/**
448
+	 * Get the total number of Sosa up to a specific generation.
449
+	 *
450
+	 * @param number $gen Generation
451
+	 * @return number Total number of Sosas up to generation
452
+	 */
453
+	public function getSosaCountUpToGeneration($gen){
454
+		if(!$this->is_setup) return 0;
455
+		return Database::prepare(
456
+			'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' .
457
+			' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
458
+			' AND majs_gen <= :gen')
459
+		->execute(array(
460
+				'tree_id' => $this->tree->getTreeId(), 
461
+				'user_id' => $this->user->getUserId(),
462
+				'gen' => $gen 
463
+		))->fetchOne() ?: 0;
464
+	}
465
+    
466
+	/**
467
+	 * Get the total number of distinct Sosa individual for all generations.
468
+	 *
469
+	 * @return number Total number of distinct individual
470
+	 */
471
+	public function getDifferentSosaCount(){
472
+		if(!$this->is_setup) return 0;
473
+		return Database::prepare(
474
+			'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' .
475
+			' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id')
476
+		->execute(array(
477
+				'tree_id' => $this->tree->getTreeId(), 
478
+				'user_id' => $this->user->getUserId()
479
+		))->fetchOne() ?: 0;
480
+	}
481
+    
482
+	/**
483
+	 * Get the number of distinct Sosa individual up to a specific generation.
484
+	 *
485
+	 * @param number $gen Generation
486
+	 * @return number Number of distinct Sosa individuals up to generation
487
+	 */
488
+	public function getDifferentSosaCountUpToGeneration($gen){
489
+		if(!$this->is_setup) return 0;
490
+		return Database::prepare(
491
+			'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' .
492
+			' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
493
+			' AND majs_gen <= :gen')
494
+		->execute(array(
495
+				'tree_id' => $this->tree->getTreeId(), 
496
+				'user_id' => $this->user->getUserId(),
497
+				'gen' => $gen 
498
+		))->fetchOne() ?: 0;
499
+	}
500
+    
501
+	/**
502
+	 * Get an array of birth statistics for a specific generation
503
+	 * Statistics are :
504
+	 * 	- first : First birth year in generation
505
+	 *  - last : Last birth year in generation
506
+	 *  - avg : Average birth year
507
+	 *
508
+	 * @param number $gen Generation
509
+	 * @return array Birth statistics array
510
+	 */
511
+	public function getStatsBirthYearInGeneration($gen){
512
+		if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0);
513
+		return Database::prepare(
514
+			'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'.
515
+			' FROM `##maj_sosa`' .
516
+			' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'.
517
+			' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year')
518
+			->execute(array(
519
+				'tree_id' => $this->tree->getTreeId(), 
520
+				'user_id' => $this->user->getUserId(),
521
+				'gen' => $gen,
522
+				'birth_year' => 0))
523
+			->fetchOneRow(\PDO::FETCH_ASSOC) ?: array('first' => 0, 'avg' => 0, 'last' => 0);
524
+	}
525
+    
526
+	/**
527
+	 * Get the mean generation time, based on a linear regression of birth years and generations
528
+	 *
529
+	 * @return number|NULL Mean generation time
530
+	 */
531
+	public function getMeanGenerationTime(){
532
+		if(!$this->is_setup) return;
533
+		if(!$this->statistics_tab){
534
+			$this->getStatisticsByGeneration();
535
+		}
536
+		//Linear regression on x=generation and y=birthdate
537
+		$sum_xy = 0;
538
+		$sum_x=0;
539
+		$sum_y=0;
540
+		$sum_x2=0;
541
+		$n=count($this->statistics_tab);
542
+		foreach($this->statistics_tab as $gen=>$stats){
543
+			$sum_xy+=$gen*$stats['avgBirth'];
544
+			$sum_x+=$gen;
545
+			$sum_y+=$stats['avgBirth'];
546
+			$sum_x2+=$gen*$gen;
547
+		}
548
+		$denom=($n*$sum_x2)-($sum_x*$sum_x);
549
+		if($denom!=0){
550
+			return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom);
551
+		}
552
+		return null;
553
+	}
554
+    
555
+	/**
556
+	 * Return a computed array of statistics about the dispersion of ancestors across the ancestors
557
+	 * at a specified generation.
558
+	 * This statistics cannot be used for generations above 11, as it would cause a out of range in MySQL
559
+	 * 
560
+	 * Format: 
561
+	 *  - key : a base-2 representation of the ancestor at generation G for which exclusive ancestors have been found,
562
+	 *          -1 is used for shared ancestors
563
+	 *          For instance base2(0100) = base10(4) represent the maternal grand father
564
+	 *  - values: number of ancestors exclusively in the ancestors of the ancestor in key
565
+	 *  
566
+	 *  For instance a result at generation 3 could be :
567
+	 *      array (   -1        =>  12      -> 12 ancestors are shared by the grand-parents
568
+	 *                base10(1) =>  32      -> 32 ancestors are exclusive to the paternal grand-father
569
+	 *                base10(2) =>  25      -> 25 ancestors are exclusive to the paternal grand-mother
570
+	 *                base10(4) =>  12      -> 12 ancestors are exclusive to the maternal grand-father
571
+	 *                base10(8) =>  30      -> 30 ancestors are exclusive to the maternal grand-mother
572
+	 *            )
573
+	 *  
574
+	 * @param int $gen Reference generation
575
+	 * @return array
576
+	 */
577
+	public function getAncestorDispersionForGen($gen) {
578
+		if(!$this->is_setup || $gen > 11) return array();  // Going further than 11 gen will be out of range in the query
579
+		return Database::prepare(
580
+			'SELECT branches, count(i_id)'.
581
+			' FROM ('.
582
+			'   SELECT i_id,'.
583
+			'       CASE'.
584
+			'           WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'.
585
+			'           ELSE -1'.   // We put all ancestors shared between some branches in the same bucket
586
+			'       END branches'.
587
+			'   FROM ('.
588
+			'       SELECT DISTINCT majs_i_id i_id,'.
589
+			'           POW(2, FLOOR(majs_sosa / POW(2, (majs_gen - :gen))) - POW(2, :gen -1)) branch'.
590
+			'       FROM `##maj_sosa`'.
591
+			'       WHERE majs_gedcom_id = :tree_id AND majs_user_id = :user_id'.
592
+			'           AND majs_gen >= :gen'.
593
+			'   ) indistat'.
594
+			'   GROUP BY i_id'.
595
+			') grouped'.
596
+			' GROUP BY branches')
597
+			->execute(array(
598
+				'tree_id' => $this->tree->getTreeId(), 
599
+				'user_id' => $this->user->getUserId(),
600
+				'gen' => $gen
601
+			))->fetchAssoc() ?: array();
602
+	}
603 603
     
604 604
                
605 605
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaListController.php 1 patch
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -35,70 +35,70 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class SosaListController extends MvcController
37 37
 {
38
-    /**
39
-     * Sosa Provider for the controller
40
-     * @var SosaProvider $sosa_provider
41
-     */
42
-    protected $sosa_provider;
38
+	/**
39
+	 * Sosa Provider for the controller
40
+	 * @var SosaProvider $sosa_provider
41
+	 */
42
+	protected $sosa_provider;
43 43
     
44
-    /**
45
-     * Generation used for the controller
46
-     * @var int $generation
47
-     */
48
-    protected $generation;
44
+	/**
45
+	 * Generation used for the controller
46
+	 * @var int $generation
47
+	 */
48
+	protected $generation;
49 49
     
50
-    /**
51
-     * ViewBag to hold data for the controller
52
-     * @var ViewBag $view_bag
53
-     */
54
-    protected $view_bag;
50
+	/**
51
+	 * ViewBag to hold data for the controller
52
+	 * @var ViewBag $view_bag
53
+	 */
54
+	protected $view_bag;
55 55
     
56
-    /**
57
-     * {@inheritDoc}
58
-     * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module)
59
-     */
60
-    public function __construct(AbstractModule $module) {
61
-        global $WT_TREE;
56
+	/**
57
+	 * {@inheritDoc}
58
+	 * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module)
59
+	 */
60
+	public function __construct(AbstractModule $module) {
61
+		global $WT_TREE;
62 62
         
63
-        parent::__construct($module);
63
+		parent::__construct($module);
64 64
 
65
-        $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user());
65
+		$this->sosa_provider = new SosaProvider($WT_TREE, 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
-        global $WT_TREE;
81
+	/**
82
+	 * SosaList@index
83
+	 */
84
+	public function index() {
85
+		global $WT_TREE;
86 86
         
87
-        $controller = new PageController();
88
-        $controller
89
-            ->setPageTitle(I18N::translate('Sosa Ancestors'));            
87
+		$controller = new PageController();
88
+		$controller
89
+			->setPageTitle(I18N::translate('Sosa Ancestors'));            
90 90
 
91
-        $this->view_bag->set('title', $controller->getPageTitle());
91
+		$this->view_bag->set('title', $controller->getPageTitle());
92 92
         
93
-        if($this->view_bag->get('is_setup', false)) {
94
-            $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0);
95
-            $this->view_bag->set('url_module', $this->module->getName());
96
-            $this->view_bag->set('url_action', 'SosaList');
97
-            $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); 
98
-            $this->view_bag->set('min_gen', 1);
93
+		if($this->view_bag->get('is_setup', false)) {
94
+			$this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0);
95
+			$this->view_bag->set('url_module', $this->module->getName());
96
+			$this->view_bag->set('url_action', 'SosaList');
97
+			$this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); 
98
+			$this->view_bag->set('min_gen', 1);
99 99
             
100
-            if($this->view_bag->get('has_sosa', false)) {            
101
-                $controller->addInlineJavascript('
100
+			if($this->view_bag->get('has_sosa', false)) {            
101
+				$controller->addInlineJavascript('
102 102
             		jQuery("#sosalist-tabs").tabs();
103 103
             		jQuery("#sosalist-tabs").css("visibility", "visible");
104 104
                 
@@ -152,44 +152,44 @@  discard block
 block discarded – undo
152 152
             		);
153 153
                 
154 154
             	');            
155
-            }
156
-        }
155
+			}
156
+		}
157 157
                 
158
-        ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render();   
159
-    }    
158
+		ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render();   
159
+	}    
160 160
     
161 161
 
162
-    /**
163
-     * SosaList@missing
164
-     */
165
-    public function missing() {
166
-        global $WT_TREE;
162
+	/**
163
+	 * SosaList@missing
164
+	 */
165
+	public function missing() {
166
+		global $WT_TREE;
167 167
         
168
-        $controller = new PageController();
169
-        $controller
170
-        ->setPageTitle(I18N::translate('Missing Ancestors'));
168
+		$controller = new PageController();
169
+		$controller
170
+		->setPageTitle(I18N::translate('Missing Ancestors'));
171 171
         
172
-        $this->view_bag->set('title', $controller->getPageTitle());
172
+		$this->view_bag->set('title', $controller->getPageTitle());
173 173
         
174
-        if($this->view_bag->get('is_setup', false)) {
175
-            $this->view_bag->set('url_module', $this->module->getName());
176
-            $this->view_bag->set('url_action', 'SosaList@missing');
177
-            $this->view_bag->set('url_ged', $WT_TREE->getNameUrl());
178
-            $this->view_bag->set('min_gen', 2);
174
+		if($this->view_bag->get('is_setup', false)) {
175
+			$this->view_bag->set('url_module', $this->module->getName());
176
+			$this->view_bag->set('url_action', 'SosaList@missing');
177
+			$this->view_bag->set('url_ged', $WT_TREE->getNameUrl());
178
+			$this->view_bag->set('min_gen', 2);
179 179
             
180
-            $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation);
181
-            $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0);
180
+			$missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation);
181
+			$this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0);
182 182
             
183
-            $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1));
184
-            $this->view_bag->set('perc_sosa', $perc_sosa);
183
+			$perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1));
184
+			$this->view_bag->set('perc_sosa', $perc_sosa);
185 185
             
186
-            if($this->view_bag->get('has_missing', false)) {
187
-                $table_id = 'table-sosa-missing-' . Uuid::uuid4();
188
-                $this->view_bag->set('table_id', $table_id);
186
+			if($this->view_bag->get('has_missing', false)) {
187
+				$table_id = 'table-sosa-missing-' . Uuid::uuid4();
188
+				$this->view_bag->set('table_id', $table_id);
189 189
                 
190
-                $controller
191
-                ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
192
-                ->addInlineJavascript('
190
+				$controller
191
+				->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
192
+				->addInlineJavascript('
193 193
     				/* Initialise datatables */
194 194
     				jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
195 195
     				jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
@@ -249,78 +249,78 @@  discard block
 block discarded – undo
249 249
     				jQuery(".loading-image").css("display", "none");
250 250
     			');
251 251
                                     
252
-                $nb_displayed = 0;
253
-                $unique_indis = array();
254
-                $sum_missing_different = 0;
255
-                $sum_missing_different_without_hidden = 0;
256
-                foreach($missing_list as $num => $missing_tab) {
257
-                    if(isset($unique_indis[$missing_tab['indi']])) {
258
-                        unset($missing_list[$num]);
259
-                        continue;
260
-                    }
261
-                    $sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
262
-                    $person = Individual::getInstance($missing_tab['indi'], $WT_TREE);
263
-                    if (!$person || !$person->canShowName()) {
264
-                        unset($missing_list[$num]);
265
-                        continue;
266
-                    }  
267
-                    $sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
268
-                    $unique_indis[$person->getXref()] = true;
269
-                    $missing_tab['indi'] = $person;
270
-                    $missing_list[$num] = $missing_tab;
271
-                }
272
-                $this->view_bag->set('missing_list', $missing_list);
273
-                $this->view_bag->set('missing_diff_count', $sum_missing_different);
274
-                $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden);
275
-                $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2));
276
-                $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential);
277
-            }            
278
-        }
252
+				$nb_displayed = 0;
253
+				$unique_indis = array();
254
+				$sum_missing_different = 0;
255
+				$sum_missing_different_without_hidden = 0;
256
+				foreach($missing_list as $num => $missing_tab) {
257
+					if(isset($unique_indis[$missing_tab['indi']])) {
258
+						unset($missing_list[$num]);
259
+						continue;
260
+					}
261
+					$sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
262
+					$person = Individual::getInstance($missing_tab['indi'], $WT_TREE);
263
+					if (!$person || !$person->canShowName()) {
264
+						unset($missing_list[$num]);
265
+						continue;
266
+					}  
267
+					$sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother'];
268
+					$unique_indis[$person->getXref()] = true;
269
+					$missing_tab['indi'] = $person;
270
+					$missing_list[$num] = $missing_tab;
271
+				}
272
+				$this->view_bag->set('missing_list', $missing_list);
273
+				$this->view_bag->set('missing_diff_count', $sum_missing_different);
274
+				$this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden);
275
+				$perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2));
276
+				$this->view_bag->set('perc_sosa_potential', $perc_sosa_potential);
277
+			}            
278
+		}
279 279
         
280
-        ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render();
281
-    }
280
+		ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render();
281
+	}
282 282
     
283
-    /**
284
-     * SosaList@sosalist
285
-     */
286
-    public function sosalist() {
283
+	/**
284
+	 * SosaList@sosalist
285
+	 */
286
+	public function sosalist() {
287 287
                 
288
-        $type = Filter::get('type', 'indi|fam', null);
288
+		$type = Filter::get('type', 'indi|fam', null);
289 289
         
290
-        $controller = new AjaxController();
291
-        $controller->restrictAccess($this->generation > 0 || !is_null($type));
290
+		$controller = new AjaxController();
291
+		$controller->restrictAccess($this->generation > 0 || !is_null($type));
292 292
         
293
-        switch ($type){
294
-            case 'indi':
295
-                $this->renderSosaListIndi($controller);
296
-                break;
297
-            case 'fam':
298
-                $this->renderFamSosaListIndi($controller);
299
-                break;
300
-            default:
301
-                break;
302
-        }
293
+		switch ($type){
294
+			case 'indi':
295
+				$this->renderSosaListIndi($controller);
296
+				break;
297
+			case 'fam':
298
+				$this->renderFamSosaListIndi($controller);
299
+				break;
300
+			default:
301
+				break;
302
+		}
303 303
 
304
-    }
304
+	}
305 305
     
306
-    /**
307
-     * Render the Ajax response for the sortable table of Sosa individuals
308
-     * @param AjaxController $controller
309
-     */
310
-    protected function renderSosaListIndi(AjaxController $controller) {
311
-        global $WT_TREE;
306
+	/**
307
+	 * Render the Ajax response for the sortable table of Sosa individuals
308
+	 * @param AjaxController $controller
309
+	 */
310
+	protected function renderSosaListIndi(AjaxController $controller) {
311
+		global $WT_TREE;
312 312
         
313
-        $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); 
314
-        $this->view_bag->set('has_sosa', false);
313
+		$listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); 
314
+		$this->view_bag->set('has_sosa', false);
315 315
         
316
-        if(count($listSosa) > 0) {
317
-            $this->view_bag->set('has_sosa', true);
318
-            $table_id = 'table-sosa-indi-' . Uuid::uuid4();
319
-            $this->view_bag->set('table_id', $table_id);
316
+		if(count($listSosa) > 0) {
317
+			$this->view_bag->set('has_sosa', true);
318
+			$table_id = 'table-sosa-indi-' . Uuid::uuid4();
319
+			$this->view_bag->set('table_id', $table_id);
320 320
                      
321
-            $controller
322
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
323
-            ->addInlineJavascript('
321
+			$controller
322
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
323
+			->addInlineJavascript('
324 324
                 jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
325 325
 				jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
326 326
 				jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);};
@@ -396,98 +396,98 @@  discard block
 block discarded – undo
396 396
 				jQuery("#btn-toggle-statistics-'.$table_id.'").click();
397 397
            ');
398 398
             
399
-            $stats = new Stats($WT_TREE);         
399
+			$stats = new Stats($WT_TREE);         
400 400
             
401
-            // Bad data can cause "longest life" to be huge, blowing memory limits
402
-            $max_age = min($WT_TREE->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1;
403
-            // Inititialise chart data
404
-            $deat_by_age = array();
405
-            for ($age = 0; $age <= $max_age; $age++) {
406
-                $deat_by_age[$age] = '';
407
-            }
408
-            $birt_by_decade = array();
409
-            $deat_by_decade = array();
410
-            for ($year = 1550; $year < 2030; $year += 10) {
411
-                $birt_by_decade[$year] = '';
412
-                $deat_by_decade[$year] = '';
413
-            }
401
+			// Bad data can cause "longest life" to be huge, blowing memory limits
402
+			$max_age = min($WT_TREE->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1;
403
+			// Inititialise chart data
404
+			$deat_by_age = array();
405
+			for ($age = 0; $age <= $max_age; $age++) {
406
+				$deat_by_age[$age] = '';
407
+			}
408
+			$birt_by_decade = array();
409
+			$deat_by_decade = array();
410
+			for ($year = 1550; $year < 2030; $year += 10) {
411
+				$birt_by_decade[$year] = '';
412
+				$deat_by_decade[$year] = '';
413
+			}
414 414
             
415
-            $unique_indis = array(); // Don't double-count indis with multiple names.
416
-            $nb_displayed = 0;
415
+			$unique_indis = array(); // Don't double-count indis with multiple names.
416
+			$nb_displayed = 0;
417 417
             
418
-            Individual::load($WT_TREE, $listSosa);
419
-            foreach($listSosa as $sosa => $pid) {
420
-                $person = Individual::getInstance($pid, $WT_TREE);
421
-                if (!$person || !$person->canShowName()) {
422
-                    unset($listSosa[$sosa]);
423
-                    continue;
424
-                }
425
-                $nb_displayed++;
426
-                if ($birth_dates=$person->getAllBirthDates()) {
427
-                    if (
428
-                        $birth_dates[0]->gregorianYear()>=1550 && 
429
-                        $birth_dates[0]->gregorianYear()<2030 && 
430
-                        !isset($unique_indis[$person->getXref()])
431
-                        ) {
432
-                        $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex();
433
-                    }
434
-                }
435
-                else {
436
-                    $birth_dates[0]=new Date('');
437
-                }
438
-                if ($death_dates = $person->getAllDeathDates()) {
439
-                    if (
440
-                        $death_dates[0]->gregorianYear() >= 1550 && 
441
-                        $death_dates[0]->gregorianYear() < 2030 && 
442
-                        !isset($unique_indis[$person->getXref()])
443
-                        ) {
444
-                        $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
445
-                    }
446
-                }
447
-                else {
448
-                    $death_dates[0] = new Date('');
449
-                }
450
-                $age = Date::getAge($birth_dates[0], $death_dates[0], 0);
451
-                if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) {
452
-                    $deat_by_age[$age] .= $person->getSex();
453
-                }
454
-                $listSosa[$sosa] = $person;
455
-                $unique_indis[$person->getXref()] = true;
456
-            }
457
-            $this->view_bag->set('sosa_list', $listSosa);   
418
+			Individual::load($WT_TREE, $listSosa);
419
+			foreach($listSosa as $sosa => $pid) {
420
+				$person = Individual::getInstance($pid, $WT_TREE);
421
+				if (!$person || !$person->canShowName()) {
422
+					unset($listSosa[$sosa]);
423
+					continue;
424
+				}
425
+				$nb_displayed++;
426
+				if ($birth_dates=$person->getAllBirthDates()) {
427
+					if (
428
+						$birth_dates[0]->gregorianYear()>=1550 && 
429
+						$birth_dates[0]->gregorianYear()<2030 && 
430
+						!isset($unique_indis[$person->getXref()])
431
+						) {
432
+						$birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex();
433
+					}
434
+				}
435
+				else {
436
+					$birth_dates[0]=new Date('');
437
+				}
438
+				if ($death_dates = $person->getAllDeathDates()) {
439
+					if (
440
+						$death_dates[0]->gregorianYear() >= 1550 && 
441
+						$death_dates[0]->gregorianYear() < 2030 && 
442
+						!isset($unique_indis[$person->getXref()])
443
+						) {
444
+						$deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
445
+					}
446
+				}
447
+				else {
448
+					$death_dates[0] = new Date('');
449
+				}
450
+				$age = Date::getAge($birth_dates[0], $death_dates[0], 0);
451
+				if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) {
452
+					$deat_by_age[$age] .= $person->getSex();
453
+				}
454
+				$listSosa[$sosa] = $person;
455
+				$unique_indis[$person->getXref()] = true;
456
+			}
457
+			$this->view_bag->set('sosa_list', $listSosa);   
458 458
             
459
-            $this->view_bag->set('sosa_count', count($listSosa));
460
-            $this->view_bag->set('sosa_theo', pow(2, $this->generation-1));
461
-            $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo')));
459
+			$this->view_bag->set('sosa_count', count($listSosa));
460
+			$this->view_bag->set('sosa_theo', pow(2, $this->generation-1));
461
+			$this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo')));
462 462
             
463
-            $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed);
463
+			$this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed);
464 464
             
465
-            $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
466
-            $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death')));
467
-            $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year')));
468
-        }
465
+			$this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
466
+			$this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death')));
467
+			$this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year')));
468
+		}
469 469
         
470
-        ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render();        
471
-    }
470
+		ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render();        
471
+	}
472 472
     
473
-    /**
474
-     * Render the Ajax response for the sortable table of Sosa family
475
-     * @param AjaxController $controller
476
-     */
477
-    protected function renderFamSosaListIndi(AjaxController $controller) {
478
-        global $WT_TREE;
473
+	/**
474
+	 * Render the Ajax response for the sortable table of Sosa family
475
+	 * @param AjaxController $controller
476
+	 */
477
+	protected function renderFamSosaListIndi(AjaxController $controller) {
478
+		global $WT_TREE;
479 479
         
480
-        $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);;
481
-        $this->view_bag->set('has_sosa', false);
480
+		$listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);;
481
+		$this->view_bag->set('has_sosa', false);
482 482
         
483
-        if(count($listFamSosa) > 0) {
484
-            $this->view_bag->set('has_sosa', true);
485
-            $table_id = 'table-sosa-fam-' . Uuid::uuid4();
486
-            $this->view_bag->set('table_id', $table_id);
483
+		if(count($listFamSosa) > 0) {
484
+			$this->view_bag->set('has_sosa', true);
485
+			$table_id = 'table-sosa-fam-' . Uuid::uuid4();
486
+			$this->view_bag->set('table_id', $table_id);
487 487
              
488
-            $controller
489
-            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
490
-            ->addInlineJavascript('
488
+			$controller
489
+			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
490
+			->addInlineJavascript('
491 491
                 jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
492 492
 				jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
493 493
 				jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);};
@@ -563,68 +563,68 @@  discard block
 block discarded – undo
563 563
 				jQuery("#btn-toggle-statistics-'.$table_id.'").click();
564 564
            ');
565 565
         
566
-            $stats = new Stats($WT_TREE);        
567
-            $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1;
566
+			$stats = new Stats($WT_TREE);        
567
+			$max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1;
568 568
             
569
-            //-- init chart data
570
-    		$marr_by_age = array();
571
-    		for ($age=0; $age<=$max_age; $age++) {
572
-    			$marr_by_age[$age] = '';
573
-    		}
574
-    		$birt_by_decade = array();
575
-    		$marr_by_decade = array();
576
-    		for ($year=1550; $year<2030; $year+=10) {
577
-    			$birt_by_decade[$year] = '';
578
-    			$marr_by_decade[$year] = '';
579
-    		}
569
+			//-- init chart data
570
+			$marr_by_age = array();
571
+			for ($age=0; $age<=$max_age; $age++) {
572
+				$marr_by_age[$age] = '';
573
+			}
574
+			$birt_by_decade = array();
575
+			$marr_by_decade = array();
576
+			for ($year=1550; $year<2030; $year+=10) {
577
+				$birt_by_decade[$year] = '';
578
+				$marr_by_decade[$year] = '';
579
+			}
580 580
     		
581
-            foreach($listFamSosa as $sosa => $fid) {
582
-                $sfamily = Family::getInstance($fid, $WT_TREE);
583
-                if(!$sfamily || !$sfamily->canShow()) {
584
-                    unset($sfamily[$sosa]);
585
-                    continue;
586
-                }
587
-                $mdate=$sfamily->getMarriageDate();
581
+			foreach($listFamSosa as $sosa => $fid) {
582
+				$sfamily = Family::getInstance($fid, $WT_TREE);
583
+				if(!$sfamily || !$sfamily->canShow()) {
584
+					unset($sfamily[$sosa]);
585
+					continue;
586
+				}
587
+				$mdate=$sfamily->getMarriageDate();
588 588
                 
589
-                if( ($husb = $sfamily->getHusband()) && 
590
-                    ($hdate = $husb->getBirthDate()) && 
591
-                    $hdate->isOK() && $mdate->isOK()) {
592
-                    if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) {
593
-                        $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
594
-                    }
595
-                    $hage = Date::getAge($hdate, $mdate, 0);
596
-                    if ($hage >= 0 && $hage <= $max_age) {
597
-                        $marr_by_age[$hage] .= $husb->getSex();
598
-                    }
599
-                }
589
+				if( ($husb = $sfamily->getHusband()) && 
590
+					($hdate = $husb->getBirthDate()) && 
591
+					$hdate->isOK() && $mdate->isOK()) {
592
+					if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) {
593
+						$birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
594
+					}
595
+					$hage = Date::getAge($hdate, $mdate, 0);
596
+					if ($hage >= 0 && $hage <= $max_age) {
597
+						$marr_by_age[$hage] .= $husb->getSex();
598
+					}
599
+				}
600 600
                 
601
-                if(($wife = $sfamily->getWife()) &&
602
-                    ($wdate=$wife->getBirthDate()) &&
603
-                    $wdate->isOK() && $mdate->isOK()) {
604
-                    if ($wdate->gregorianYear() >= 1550 && $wdate->gregorianYear() < 2030) {
605
-                        $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
606
-                    }
607
-                    $wage = Date::getAge($wdate, $mdate, 0);
608
-                    if ($wage >= 0 && $wage <= $max_age) {
609
-                        $marr_by_age[$wage] .= $wife->getSex();
610
-                    }
611
-                }                
601
+				if(($wife = $sfamily->getWife()) &&
602
+					($wdate=$wife->getBirthDate()) &&
603
+					$wdate->isOK() && $mdate->isOK()) {
604
+					if ($wdate->gregorianYear() >= 1550 && $wdate->gregorianYear() < 2030) {
605
+						$birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
606
+					}
607
+					$wage = Date::getAge($wdate, $mdate, 0);
608
+					if ($wage >= 0 && $wage <= $max_age) {
609
+						$marr_by_age[$wage] .= $wife->getSex();
610
+					}
611
+				}                
612 612
 
613
-                if ($mdate->isOK() && $mdate->gregorianYear() >= 1550 && $mdate->gregorianYear() < 2030 && $husb && $wife) {
614
-                    $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
615
-                }
613
+				if ($mdate->isOK() && $mdate->gregorianYear() >= 1550 && $mdate->gregorianYear() < 2030 && $husb && $wife) {
614
+					$marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
615
+				}
616 616
                 
617
-                $listFamSosa[$sosa] = $sfamily;
618
-            }
619
-            $this->view_bag->set('sosa_list', $listFamSosa);
617
+				$listFamSosa[$sosa] = $sfamily;
618
+			}
619
+			$this->view_bag->set('sosa_list', $listFamSosa);
620 620
         
621
-            $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
622
-            $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')));
623
-            $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')));
624
-        }
621
+			$this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
622
+			$this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')));
623
+			$this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')));
624
+		}
625 625
         
626
-        ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render();
627
-    }
626
+		ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render();
627
+	}
628 628
     
629 629
     
630 630
 }
631 631
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Schema/Migration0.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,18 +22,18 @@
 block discarded – undo
22 22
 	public function upgrade() {
23 23
 
24 24
 		Database::exec(
25
-		    'CREATE TABLE IF NOT EXISTS `##maj_sosa` (' .
26
-	        ' majs_gedcom_id      INTEGER 	        NOT NULL,' .
27
-		    ' majs_user_id        INTEGER           NOT NULL DEFAULT -1,' . 
28
-		    ' majs_sosa           BIGINT UNSIGNED 	NOT NULL,' . // Allow to calculate sosa on 64 generations
29
-            ' majs_i_id           VARCHAR(20)	    NOT NULL,' .	
30
-            ' majs_gen            TINYINT			NULL,' .
31
-            ' majs_birth_year	  SMALLINT			NULL,' .
32
-            ' majs_death_year	  SMALLINT			NULL,' .
33
-            ' PRIMARY KEY (majs_gedcom_id, majs_user_id, majs_sosa),' .
34
-		    ' FOREIGN KEY `##gedcom_id_fk1` (majs_gedcom_id) REFERENCES `##gedcom` (gedcom_id) ON DELETE CASCADE,' .
35
-		    ' FOREIGN KEY `##user_id_fk1` (majs_user_id) REFERENCES `##user` (user_id) ON DELETE CASCADE' .			
36
-		    ') COLLATE utf8_unicode_ci ENGINE=InnoDB'
25
+			'CREATE TABLE IF NOT EXISTS `##maj_sosa` (' .
26
+			' majs_gedcom_id      INTEGER 	        NOT NULL,' .
27
+			' majs_user_id        INTEGER           NOT NULL DEFAULT -1,' . 
28
+			' majs_sosa           BIGINT UNSIGNED 	NOT NULL,' . // Allow to calculate sosa on 64 generations
29
+			' majs_i_id           VARCHAR(20)	    NOT NULL,' .	
30
+			' majs_gen            TINYINT			NULL,' .
31
+			' majs_birth_year	  SMALLINT			NULL,' .
32
+			' majs_death_year	  SMALLINT			NULL,' .
33
+			' PRIMARY KEY (majs_gedcom_id, majs_user_id, majs_sosa),' .
34
+			' FOREIGN KEY `##gedcom_id_fk1` (majs_gedcom_id) REFERENCES `##gedcom` (gedcom_id) ON DELETE CASCADE,' .
35
+			' FOREIGN KEY `##user_id_fk1` (majs_user_id) REFERENCES `##user` (user_id) ON DELETE CASCADE' .			
36
+			') COLLATE utf8_unicode_ci ENGINE=InnoDB'
37 37
 		);
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Views/SosaListView.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
 	 * {@inhericDoc}
24 24
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
25 25
 	 */
26
-    protected function renderContent() {      
27
-        ?>                
26
+	protected function renderContent() {      
27
+		?>                
28 28
         <div id="maj-sosa-list-page" class="center">
29 29
 			<h2><?php echo $this->data->get('title'); ?></h2>
30 30
 			
31 31
 			<?php  if($this->data->get('is_setup')) { 
32
-			    $selectedgen = $this->data->get('generation');
33
-			    $this->renderSosaHeader();
34
-			    if($this->data->get('has_sosa') ) {
35
-			         if($selectedgen > 0) {
36
-			        ?>
32
+				$selectedgen = $this->data->get('generation');
33
+				$this->renderSosaHeader();
34
+				if($this->data->get('has_sosa') ) {
35
+					 if($selectedgen > 0) {
36
+					?>
37 37
 			<div id="sosalist-tabs">
38 38
 				<ul>
39 39
 					<li><a href="#sosalist-indi"><?php echo I18N::translate('Individuals'); ?></a></li>
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			<?php        } else { ?>
54 54
 			<p class="warning"><?php echo I18N::translate('No ancestor has been found for generation %d', $selectedgen); ?></p>
55 55
 			<?php    }
56
-			    }
56
+				}
57 57
 			} else { ?>
58 58
 			<p class="warning"><?php echo I18N::translate('The list could not be displayed. Reasons might be:'); ?><br/>
59 59
 				<ul>
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 			<?php } ?>
65 65
 		</div> 
66 66
 		<?php 
67
-    }
67
+	}
68 68
     
69
-    /**
70
-     * Render the common header to Sosa Lists, made of the generation selector, and the generation navigator
71
-     */
72
-    protected function renderSosaHeader() {
73
-        $selectedgen = $this->data->get('generation');
74
-        $max_gen = $this->data->get('max_gen');
75
-        ?>
69
+	/**
70
+	 * Render the common header to Sosa Lists, made of the generation selector, and the generation navigator
71
+	 */
72
+	protected function renderSosaHeader() {
73
+		$selectedgen = $this->data->get('generation');
74
+		$max_gen = $this->data->get('max_gen');
75
+		?>
76 76
         
77 77
     	<form method="get" name="setgen" action="module.php">
78 78
 			<input type="hidden" name="mod" value="<?php echo $this->data->get('url_module');?>">
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		
118 118
 		<?php 
119 119
 		}
120
-    }       
120
+	}       
121 121
     
122 122
 }
123 123
  
124 124
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Views/SosaConfigView.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	 * {@inhericDoc}
26 26
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
27 27
 	 */
28
-    protected function renderContent() {
28
+	protected function renderContent() {
29 29
         
30
-        ?>        
30
+		?>        
31 31
         
32 32
         <div id="maj-sosa-config-page">
33 33
 			<h2><?php echo $this->data->get('title'); ?></h2>
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
         			</div>
48 48
         			<div class="value">
49 49
         				<?php 
50
-        				    $users = $this->data->get('users_settings');
51
-        				    if(count($users) == 1) {
52
-        				?>
50
+							$users = $this->data->get('users_settings');
51
+							if(count($users) == 1) {
52
+						?>
53 53
         					<label>
54 54
         						<input id="maj_sosa_input_userid" type="hidden" name="userid" value="<?php echo $users[0]['user']->getUserId(); ?>" />
55 55
         						<?php echo $users[0]['user']->getRealNameHtml() ?>
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
         				<?php  } else if(count($users) > 1) { ?>
58 58
         					<select id='maj-sosa-config-select' name="userid">
59 59
         					<?php 
60
-        					$root_indi = $users[0]['rootid'];
61
-        					foreach ($this->data->get('users_settings') as $user) { ?>
60
+							$root_indi = $users[0]['rootid'];
61
+							foreach ($this->data->get('users_settings') as $user) { ?>
62 62
         						<option value="<?php echo $user['user']->getUserId(); ?>"><?php echo $user['user']->getRealNameHtml() ?></option>
63 63
         					<?php  } ?>
64 64
         					</select>
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 			</form>	
82 82
 		
83 83
 		<?php        
84
-    }
84
+	}
85 85
     
86 86
 }
87 87
  
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Views/SosaListIndiView.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 	 * {@inhericDoc}
32 32
 	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
33 33
 	 */
34
-    protected function renderContent() { 
34
+	protected function renderContent() { 
35 35
         
36
-        if($this->data->get('has_sosa', false)) {
37
-            $table_id = $this->data->get('table_id');            
38
-        ?>   
36
+		if($this->data->get('has_sosa', false)) {
37
+			$table_id = $this->data->get('table_id');            
38
+		?>   
39 39
         
40 40
         <div id="sosa-indi-list" class="sosa-list">
41 41
         	<table id="<?php echo $table_id;?>">
@@ -186,42 +186,42 @@  discard block
 block discarded – undo
186 186
 			<tbody>
187 187
 			
188 188
 			<?php foreach($this->data->get('sosa_list') as $sosa => $person) {
189
-			    /** @var \Fisharebest\Webtrees\Individual $person */
190
-			    if ($person->isPendingAddtion()) {
191
-			        $class = ' class="new"';
192
-			    } elseif ($person->isPendingDeletion()) {
193
-			        $class = ' class="old"';
194
-			    } else {
195
-			        $class = '';
196
-			    }
197
-			    $dperson = new \MyArtJaub\Webtrees\Individual($person);
198
-			    ?>			
189
+				/** @var \Fisharebest\Webtrees\Individual $person */
190
+				if ($person->isPendingAddtion()) {
191
+					$class = ' class="new"';
192
+				} elseif ($person->isPendingDeletion()) {
193
+					$class = ' class="old"';
194
+				} else {
195
+					$class = '';
196
+				}
197
+				$dperson = new \MyArtJaub\Webtrees\Individual($person);
198
+				?>			
199 199
         		<tr <?php echo $class?>>
200 200
         			<td class="transparent"><?php echo $sosa; ?></td>
201 201
         			<td class="transparent"><?php echo $person->getXref(); ?></td>
202 202
         			<td colspan="2">
203 203
         			<?php foreach ($person->getAllNames() as $num=>$name) {
204
-        				if ($name['type']=='NAME') {
205
-        					$title='';
206
-        				} else {
207
-        					$title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"';
208
-        				}
209
-        				if ($num==$person->getPrimaryName()) {
210
-        					$class=' class="name2"';
211
-        					$sex_image=$person->getSexImage();
212
-        					list($surn, $givn)=explode(',', $name['sort']);
213
-        				} else {
214
-        					$class='';
215
-        					$sex_image='';
216
-        				} ?>
204
+						if ($name['type']=='NAME') {
205
+							$title='';
206
+						} else {
207
+							$title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"';
208
+						}
209
+						if ($num==$person->getPrimaryName()) {
210
+							$class=' class="name2"';
211
+							$sex_image=$person->getSexImage();
212
+							list($surn, $givn)=explode(',', $name['sort']);
213
+						} else {
214
+							$class='';
215
+							$sex_image='';
216
+						} ?>
217 217
         				<a <?php echo $title.' '.$class; ?> href="<?php echo $person->getHtmlUrl(); ?>">
218 218
         					<?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?>
219 219
         				</a>
220 220
         				<?php echo $sex_image.FunctionsPrint::formatSosaNumbers($dperson->getSosaNumbers(), 1, 'smaller'); ?>
221 221
         				<br/>
222 222
             		<?php }
223
-            		echo $person->getPrimaryParentsNames('parents details1', 'none');
224
-            		?>
223
+					echo $person->getPrimaryParentsNames('parents details1', 'none');
224
+					?>
225 225
             		</td>
226 226
             		<td style="display:none;"></td>
227 227
             		<td>
@@ -232,34 +232,34 @@  discard block
 block discarded – undo
232 232
             		</td>
233 233
             		<td>
234 234
             		<?php 
235
-            		if ($birth_dates=$person->getAllBirthDates()) {
236
-			            foreach ($birth_dates as $num=>$birth_date) {
237
-    					   if ($num) { ?><br/><?php } ?>
235
+					if ($birth_dates=$person->getAllBirthDates()) {
236
+						foreach ($birth_dates as $num=>$birth_date) {
237
+						   if ($num) { ?><br/><?php } ?>
238 238
     						<?php  echo $birth_date->display(true);
239
-			            }
240
-            		} else {
241
-            		    $birth_date=$person->getEstimatedBirthDate();
242
-            		    if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) {
243
-            		        $birth_date->display(true);
244
-            		    } else {
245
-            		        echo '&nbsp;';
246
-            		    }
247
-            		    $birth_dates[0] = new Date('');
248
-            		}
249
-            		?>
239
+						}
240
+					} else {
241
+						$birth_date=$person->getEstimatedBirthDate();
242
+						if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) {
243
+							$birth_date->display(true);
244
+						} else {
245
+							echo '&nbsp;';
246
+						}
247
+						$birth_dates[0] = new Date('');
248
+					}
249
+					?>
250 250
             		</td>
251 251
             		<td><?php echo $birth_date->julianDay();?></td>
252 252
         			<td>
253 253
         			<?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) {
254
-				        $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree());
255
-        				if ($n) { ?><br><?php } ?>
254
+						$tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree());
255
+						if ($n) { ?><br><?php } ?>
256 256
         				<a href="'<?php echo $tmp->getURL(); ?>" title="<?php echo strip_tags($tmp->getFullName()); ?>">
257 257
         					<?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?>
258 258
         				</a>
259 259
         			<?php } ?>
260 260
         			</td>
261 261
         			<?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) {
262
-				        $isBSourced = $dperson->isBirthSourced(); ?>
262
+						$isBSourced = $dperson->isBirthSourced(); ?>
263 263
 				   	<td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium'); ?></td>
264 264
 					<td><?php echo $isBSourced; ?></td>
265 265
 					<?php } else { ?>
@@ -269,36 +269,36 @@  discard block
 block discarded – undo
269 269
 					<td>
270 270
 					<?php 
271 271
 					if ($death_dates = $person->getAllDeathDates()) {
272
-				        foreach ($death_dates as $num => $death_date) {
273
-					       if ($num) { ?><br/><?php } ?>
272
+						foreach ($death_dates as $num => $death_date) {
273
+						   if ($num) { ?><br/><?php } ?>
274 274
 					 		<?php echo $death_date->display(true); 
275
-				        }
276
-			         } else {
277
-				        $death_date = $person->getEstimatedDeathDate();
278
-				        if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES') && $death_date->minimumJulianDay() < WT_CLIENT_JD) {
279
-					       echo $death_date->display(true);
280
-        				} elseif ($person->isDead()) {
281
-        					echo I18N::translate('yes');
282
-        				} else {
283
-        					echo '&nbsp;';
284
-        				}
285
-                        $death_dates[0] = new Date('');
286
-			         } ?>
275
+						}
276
+					 } else {
277
+						$death_date = $person->getEstimatedDeathDate();
278
+						if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES') && $death_date->minimumJulianDay() < WT_CLIENT_JD) {
279
+						   echo $death_date->display(true);
280
+						} elseif ($person->isDead()) {
281
+							echo I18N::translate('yes');
282
+						} else {
283
+							echo '&nbsp;';
284
+						}
285
+						$death_dates[0] = new Date('');
286
+					 } ?>
287 287
 			         </td>
288 288
 			         <td><?php echo $death_date->julianDay(); ?></td>
289 289
 			         <td><?php echo Date::getAge($birth_dates[0], $death_dates[0], 2); ?></td>
290 290
 			         <td><?php echo Date::getAge($birth_dates[0], $death_dates[0], 1); ?></td>
291 291
 			         <td>
292 292
         			 <?php foreach ($person->getAllDeathPlaces() as $n => $death_place) {
293
-        				$tmp = new Place($death_place, $person->getTree());
294
-        				if ($n) { ?><br><?php } ?>
293
+						$tmp = new Place($death_place, $person->getTree());
294
+						if ($n) { ?><br><?php } ?>
295 295
         				<a href="'<?php echo $tmp->getURL(); ?>" title="<?php echo strip_tags($tmp->getFullName()); ?>">
296 296
         					<?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?>
297 297
         				</a>
298 298
         			<?php } ?>
299 299
         			</td>
300 300
         			<?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) {
301
-				        $isDSourced = $dperson->isDeathSourced(); ?>
301
+						$isDSourced = $dperson->isDeathSourced(); ?>
302 302
 				   	<td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isDSourced, 'DEAT', 1, 'medium'); ?></td>
303 303
 					<td><?php echo $isDSourced; ?></td>
304 304
 					<?php } else { ?>
@@ -308,29 +308,29 @@  discard block
 block discarded – undo
308 308
 					<td><?php  echo $person->getSex(); ?></td>
309 309
 					<td>
310 310
 					<?php if (!$person->canShow() || Date::compare($birth_date, new Date(date('Y') - 100)) > 0) {
311
-					    echo 'Y100';
312
-        			} else {
313
-        				echo 'YES';
314
-        			} ?>
311
+						echo 'Y100';
312
+					} else {
313
+						echo 'YES';
314
+					} ?>
315 315
         			</td>
316 316
         			<td>
317 317
         			<?php if (Date::compare($death_dates[0], new Date(date('Y') - 100)) > 0) {
318
-				        echo 'Y100';
319
-        			} elseif ($death_dates[0]->minimumJulianDay() || $person->isDead()) {
320
-				        echo 'YES';
321
-        			} else {
322
-				        echo 'N';
323
-			         } ?>
318
+						echo 'Y100';
319
+					} elseif ($death_dates[0]->minimumJulianDay() || $person->isDead()) {
320
+						echo 'YES';
321
+					} else {
322
+						echo 'N';
323
+					 } ?>
324 324
 			         </td>
325 325
 			         <td>
326 326
 					<?php if (!$person->getChildFamilies()) {
327
-					    echo 'R';
327
+						echo 'R';
328 328
 					}  // roots
329 329
 					elseif (!$person->isDead() && $person->getNumberOfChildren() < 1) {
330
-            			echo 'L';
330
+						echo 'L';
331 331
 					} // leaves
332 332
 					else {
333
-					    echo '&nbsp;';
333
+						echo '&nbsp;';
334 334
 					} ?>
335 335
 					</td>
336 336
 				</tr>
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 					<th class="ui-state-default" colspan="22">
342 342
 						<div class="center">
343 343
 							<?php echo I18N::translate('Number of Sosa ancestors: %1$s known / %2$s theoretical (%3$s)',
344
-							    I18N::number($this->data->get('sosa_count')),
345
-							    I18N::number($this->data->get('sosa_theo')), 
346
-							    I18N::percentage($this->data->get('sosa_ratio'),2)
347
-							    ); ?>
344
+								I18N::number($this->data->get('sosa_count')),
345
+								I18N::number($this->data->get('sosa_theo')), 
346
+								I18N::percentage($this->data->get('sosa_ratio'),2)
347
+								); ?>
348 348
 							<?php if($this->data->get('sosa_hidden') > 0) {
349
-							    echo '['. I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))).']';
349
+								echo '['. I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))).']';
350 350
 							} ?>
351 351
 						</div>
352 352
 					</th>
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 				</div>
381 381
 			</div>
382 382
 		<?php 
383
-        }
384
-    }
383
+		}
384
+	}
385 385
     
386 386
 }
387 387
  
388 388
\ No newline at end of file
Please login to merge, or discard this patch.