@@ -185,8 +185,7 @@ discard block |
||
| 185 | 185 | I18N::translate('Error').Mail::EOL. |
| 186 | 186 | str_repeat('-', $nb_char_count_title)."\t".str_repeat('-', $nb_char_type)."\t".str_repeat('-', 20)."\t".str_repeat('-', strlen(I18N::translate('Error'))).Mail::EOL. |
| 187 | 187 | $tmp_message.Mail::EOL; |
| 188 | - } |
|
| 189 | - else{ |
|
| 188 | + } else{ |
|
| 190 | 189 | $message .= I18N::translate('No errors', $nb_errors).Mail::EOL.Mail::EOL; |
| 191 | 190 | } |
| 192 | 191 | |
@@ -251,8 +250,7 @@ discard block |
||
| 251 | 250 | } |
| 252 | 251 | } |
| 253 | 252 | return true; |
| 254 | - } |
|
| 255 | - catch (\Exception $ex) { |
|
| 253 | + } catch (\Exception $ex) { |
|
| 256 | 254 | Log::addErrorLog(sprintf('Error while updating the Admin Task "%s". Exception: %s', $this->getName(), $ex->getMessage())); |
| 257 | 255 | return false; |
| 258 | 256 | } |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | class HealthCheckEmailTask extends AbstractTask implements ConfigurableTaskInterface { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * {@inheritDoc} |
|
| 34 | - * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle() |
|
| 35 | - */ |
|
| 36 | - public function getTitle() { |
|
| 32 | + /** |
|
| 33 | + * {@inheritDoc} |
|
| 34 | + * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getTitle() |
|
| 35 | + */ |
|
| 36 | + public function getTitle() { |
|
| 37 | 37 | return I18N::translate('Healthcheck Email'); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * {@inheritDoc} |
| 42 | 42 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency() |
| 43 | 43 | */ |
| 44 | - public function getDefaultFrequency() { |
|
| 44 | + public function getDefaultFrequency() { |
|
| 45 | 45 | return 10080; // = 1 week = 7 * 24 * 60 min |
| 46 | 46 | } |
| 47 | 47 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * {@inheritDoc} |
| 50 | 50 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::executeSteps() |
| 51 | 51 | */ |
| 52 | - protected function executeSteps() { |
|
| 52 | + protected function executeSteps() { |
|
| 53 | 53 | |
| 54 | 54 | $res = false; |
| 55 | 55 | |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | $interval = max($this->frequency, $interval_sincelast); |
| 64 | 64 | $nbdays = ceil($interval / (24 * 60)); |
| 65 | 65 | |
| 66 | - // Check for updates |
|
| 67 | - $latest_version_txt = Functions::fetchLatestVersion(); |
|
| 68 | - if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
| 69 | - list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
| 70 | - } else { |
|
| 71 | - // Cannot determine the latest version |
|
| 72 | - list($latest_version, , $download_url) = explode('|', '||'); |
|
| 73 | - } |
|
| 66 | + // Check for updates |
|
| 67 | + $latest_version_txt = Functions::fetchLatestVersion(); |
|
| 68 | + if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
|
| 69 | + list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
| 70 | + } else { |
|
| 71 | + // Cannot determine the latest version |
|
| 72 | + list($latest_version, , $download_url) = explode('|', '||'); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | // Users statistics |
| 76 | 76 | $warnusers = 0; |
@@ -213,15 +213,15 @@ discard block |
||
| 213 | 213 | $html = ' |
| 214 | 214 | <div class="form-group"> |
| 215 | 215 | <label class="control-label col-sm-3"> '. |
| 216 | - I18N::translate('Enable healthcheck emails for') . |
|
| 217 | - '</label> |
|
| 216 | + I18N::translate('Enable healthcheck emails for') . |
|
| 217 | + '</label> |
|
| 218 | 218 | <div class="col-sm-9">'; |
| 219 | 219 | |
| 220 | 220 | foreach(Tree::getAll() as $tree){ |
| 221 | 221 | if(Auth::isManager($tree)){ |
| 222 | - $html .= '<div class="form-group row"> |
|
| 222 | + $html .= '<div class="form-group row"> |
|
| 223 | 223 | <span class="col-sm-3 control-label">' . |
| 224 | - $tree->getTitle() . |
|
| 224 | + $tree->getTitle() . |
|
| 225 | 225 | '</span> |
| 226 | 226 | <div class="col-sm-2">'; |
| 227 | 227 | $html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | $html .= ' <p class="small text-muted">'. |
| 233 | - I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
| 234 | - '</p> |
|
| 233 | + I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
| 234 | + '</p> |
|
| 235 | 235 | </div> |
| 236 | 236 | </div>'; |
| 237 | 237 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::getDefaultFrequency() |
| 43 | 43 | */ |
| 44 | 44 | public function getDefaultFrequency() { |
| 45 | - return 10080; // = 1 week = 7 * 24 * 60 min |
|
| 45 | + return 10080; // = 1 week = 7 * 24 * 60 min |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | // Get the number of days to take into account, either last 7 days or since last check |
| 57 | 57 | $interval_sincelast = 0; |
| 58 | - if($this->last_updated){ |
|
| 58 | + if ($this->last_updated) { |
|
| 59 | 59 | $tmpInt = $this->last_updated->diff(new \DateTime('now'), true); |
| 60 | - $interval_sincelast = ( $tmpInt->days * 24 + $tmpInt->h ) * 60 + $tmpInt->i; |
|
| 60 | + $interval_sincelast = ($tmpInt->days * 24 + $tmpInt->h) * 60 + $tmpInt->i; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $interval = max($this->frequency, $interval_sincelast); |
@@ -66,17 +66,17 @@ discard block |
||
| 66 | 66 | // Check for updates |
| 67 | 67 | $latest_version_txt = Functions::fetchLatestVersion(); |
| 68 | 68 | if (preg_match('/^[0-9.]+\|[0-9.]+\|/', $latest_version_txt)) { |
| 69 | - list($latest_version, , $download_url) = explode('|', $latest_version_txt); |
|
| 69 | + list($latest_version,, $download_url) = explode('|', $latest_version_txt); |
|
| 70 | 70 | } else { |
| 71 | 71 | // Cannot determine the latest version |
| 72 | - list($latest_version, , $download_url) = explode('|', '||'); |
|
| 72 | + list($latest_version,, $download_url) = explode('|', '||'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Users statistics |
| 76 | 76 | $warnusers = 0; |
| 77 | 77 | $nverusers = 0; |
| 78 | 78 | $applusers = 0; |
| 79 | - foreach(User::all() as $user) { |
|
| 79 | + foreach (User::all() as $user) { |
|
| 80 | 80 | if (((date("U") - (int)$user->getPreference('reg_timestamp')) > 604800) && !$user->getPreference('verified')) { |
| 81 | 81 | $warnusers++; |
| 82 | 82 | } |
@@ -90,20 +90,20 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | // Tree specifics checks |
| 92 | 92 | $one_tree_done = false; |
| 93 | - foreach(Tree::getAll() as $tree){ |
|
| 93 | + foreach (Tree::getAll() as $tree) { |
|
| 94 | 94 | $isTreeEnabled = $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED'); |
| 95 | - if((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))){ |
|
| 95 | + if ((is_null($isTreeEnabled) || $isTreeEnabled) && $webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID'))) { |
|
| 96 | 96 | I18N::init($webmaster->getPreference('language')); |
| 97 | 97 | |
| 98 | 98 | $subject = I18N::translate('Health Check Report').' - '.I18N::translate('Tree %s', $tree->getTitle()); |
| 99 | 99 | $message = |
| 100 | - I18N::translate('Health Check Report for the last %d days', $nbdays). Mail::EOL. Mail::EOL. |
|
| 100 | + I18N::translate('Health Check Report for the last %d days', $nbdays).Mail::EOL.Mail::EOL. |
|
| 101 | 101 | I18N::translate('Tree %s', $tree->getTitle()).Mail::EOL. |
| 102 | 102 | '=========================================='.Mail::EOL.Mail::EOL; |
| 103 | 103 | |
| 104 | 104 | // News |
| 105 | 105 | $message_version = ''; |
| 106 | - if($latest_version && version_compare(WT_VERSION, $latest_version)<0){ |
|
| 106 | + if ($latest_version && version_compare(WT_VERSION, $latest_version) < 0) { |
|
| 107 | 107 | $message_version = I18N::translate('News').Mail::EOL. |
| 108 | 108 | '-------------'.Mail::EOL. |
| 109 | 109 | I18N::translate('A new version of *webtrees* is available: %s. Upgrade as soon as possible.', $latest_version).Mail::EOL. |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | I18N::translate('Not verified by the user')."\t\t".$applusers.Mail::EOL. |
| 120 | 120 | I18N::translate('Not approved by an administrator')."\t".$nverusers.Mail::EOL. |
| 121 | 121 | Mail::EOL; |
| 122 | - $message .= $message_users; |
|
| 122 | + $message .= $message_users; |
|
| 123 | 123 | |
| 124 | 124 | // Statistics tree: |
| 125 | 125 | $stats = new Stats($tree); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | ' AND log_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)'. |
| 160 | 160 | ' GROUP BY log_message, gedcom_id'. |
| 161 | 161 | ' ORDER BY lastoccurred DESC'; |
| 162 | - $errors=Database::prepare($sql)->execute(array( |
|
| 162 | + $errors = Database::prepare($sql)->execute(array( |
|
| 163 | 163 | 'log_type' => Log::TYPE_ERROR, |
| 164 | 164 | 'gedcom_id' => $tree->getTreeId(), |
| 165 | 165 | 'nb_days' => $nbdays |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $tmp_message .= str_replace("\n", "\n\t\t\t\t\t\t", $error->log_message).Mail::EOL; |
| 176 | 176 | $nb_errors += $error->nblogs; |
| 177 | 177 | } |
| 178 | - if($nb_errors > 0){ |
|
| 178 | + if ($nb_errors > 0) { |
|
| 179 | 179 | $message .= I18N::translate('Errors [%d]', $nb_errors).Mail::EOL. |
| 180 | 180 | '-------------'.Mail::EOL. |
| 181 | 181 | WT_BASE_URL.'admin_site_logs.php'.Mail::EOL. |
@@ -186,12 +186,12 @@ discard block |
||
| 186 | 186 | str_repeat('-', $nb_char_count_title)."\t".str_repeat('-', $nb_char_type)."\t".str_repeat('-', 20)."\t".str_repeat('-', strlen(I18N::translate('Error'))).Mail::EOL. |
| 187 | 187 | $tmp_message.Mail::EOL; |
| 188 | 188 | } |
| 189 | - else{ |
|
| 189 | + else { |
|
| 190 | 190 | $message .= I18N::translate('No errors', $nb_errors).Mail::EOL.Mail::EOL; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | $tmpres = true; |
| 194 | - if($webmaster->getPreference('contactmethod') !== 'messaging' |
|
| 194 | + if ($webmaster->getPreference('contactmethod') !== 'messaging' |
|
| 195 | 195 | && $webmaster->getPreference('contactmethod') !== 'none') { |
| 196 | 196 | $tmpres = Mail::systemMessage($tree, $webmaster, $subject, $message); |
| 197 | 197 | } |
@@ -213,24 +213,24 @@ discard block |
||
| 213 | 213 | $html = ' |
| 214 | 214 | <div class="form-group"> |
| 215 | 215 | <label class="control-label col-sm-3"> '. |
| 216 | - I18N::translate('Enable healthcheck emails for') . |
|
| 216 | + I18N::translate('Enable healthcheck emails for'). |
|
| 217 | 217 | '</label> |
| 218 | 218 | <div class="col-sm-9">'; |
| 219 | 219 | |
| 220 | - foreach(Tree::getAll() as $tree){ |
|
| 221 | - if(Auth::isManager($tree)){ |
|
| 220 | + foreach (Tree::getAll() as $tree) { |
|
| 221 | + if (Auth::isManager($tree)) { |
|
| 222 | 222 | $html .= '<div class="form-group row"> |
| 223 | 223 | <span class="col-sm-3 control-label">' . |
| 224 | - $tree->getTitle() . |
|
| 224 | + $tree->getTitle(). |
|
| 225 | 225 | '</span> |
| 226 | 226 | <div class="col-sm-2">'; |
| 227 | - $html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); |
|
| 227 | + $html .= FunctionsEdit::editFieldYesNo('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), $tree->getPreference('MAJ_AT_'.$this->getName().'_ENABLED', 1), 'class="radio-inline"'); |
|
| 228 | 228 | $html .= '</div></div>'; |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | $html .= ' <p class="small text-muted">'. |
| 233 | - I18N::translate('Enable the health check emails for each of the selected trees.') . |
|
| 233 | + I18N::translate('Enable the health check emails for each of the selected trees.'). |
|
| 234 | 234 | '</p> |
| 235 | 235 | </div> |
| 236 | 236 | </div>'; |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function saveConfig() { |
| 246 | 246 | try { |
| 247 | - foreach(Tree::getAll() as $tree){ |
|
| 248 | - if(Auth::isManager($tree)){ |
|
| 249 | - $tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), 0, 1); |
|
| 247 | + foreach (Tree::getAll() as $tree) { |
|
| 248 | + if (Auth::isManager($tree)) { |
|
| 249 | + $tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_'.$tree->getTreeId(), 0, 1); |
|
| 250 | 250 | $tree->setPreference('MAJ_AT_'.$this->getName().'_ENABLED', $tree_enabled); |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | ->setPageTitle($this->module->getTitle()); |
| 69 | 69 | |
| 70 | 70 | $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); |
| 71 | - if(is_null($token)) { |
|
| 71 | + if (is_null($token)) { |
|
| 72 | 72 | $token = Functions::generateRandomToken(); |
| 73 | 73 | $this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token); |
| 74 | 74 | } |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | $data = new ViewBag(); |
| 77 | 77 | $data->set('title', $controller->getPageTitle()); |
| 78 | 78 | |
| 79 | - $table_id = 'table-admintasks-' . Uuid::uuid4(); |
|
| 79 | + $table_id = 'table-admintasks-'.Uuid::uuid4(); |
|
| 80 | 80 | $data->set('table_id', $table_id); |
| 81 | 81 | |
| 82 | 82 | $data->set('trigger_url_root', WT_BASE_URL.'module.php?mod='.$this->module->getName().'&mod_action=Task@trigger'); |
| 83 | 83 | $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); |
| 84 | - if(is_null($token)) { |
|
| 84 | + if (is_null($token)) { |
|
| 85 | 85 | $token = Functions::generateRandomToken(); |
| 86 | 86 | $this->module->setSetting('MAJ_AT_FORCE_EXEC_TOKEN', $token); |
| 87 | 87 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | processing: true, |
| 107 | 107 | serverSide : true, |
| 108 | 108 | ajax : { |
| 109 | - url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonTasksList&ged='. $WT_TREE->getNameUrl().'", |
|
| 109 | + url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonTasksList&ged='.$WT_TREE->getNameUrl().'", |
|
| 110 | 110 | type : "POST" |
| 111 | 111 | }, |
| 112 | 112 | columns: [ |
@@ -143,14 +143,14 @@ discard block |
||
| 143 | 143 | url: "module.php", |
| 144 | 144 | type: "GET", |
| 145 | 145 | data: { |
| 146 | - mod: "' . $this->module->getName() .'", |
|
| 146 | + mod: "' . $this->module->getName().'", |
|
| 147 | 147 | mod_action: "Task@setStatus", |
| 148 | 148 | task: task, |
| 149 | 149 | status: status |
| 150 | 150 | }, |
| 151 | 151 | error: function(result, stat, error) { |
| 152 | 152 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
| 153 | - alert("' . I18N::translate('An error occured while editing this task:') . '" + err); |
|
| 153 | + alert("' . I18N::translate('An error occured while editing this task:').'" + err); |
|
| 154 | 154 | }, |
| 155 | 155 | complete: function(result, stat) { |
| 156 | 156 | adminTasksTable.ajax.reload(null, false); |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // Generate an AJAX/JSON response for datatables to load a block of rows |
| 189 | 189 | $search = Filter::postArray('search'); |
| 190 | - if($search) $search = $search['value']; |
|
| 190 | + if ($search) $search = $search['value']; |
|
| 191 | 191 | $start = Filter::postInteger('start'); |
| 192 | 192 | $length = Filter::postInteger('length'); |
| 193 | 193 | $order = Filter::postArray('order'); |
| 194 | 194 | |
| 195 | 195 | $order_by_name = false; |
| 196 | - foreach($order as $key => &$value) { |
|
| 197 | - switch($value['column']) { |
|
| 196 | + foreach ($order as $key => &$value) { |
|
| 197 | + switch ($value['column']) { |
|
| 198 | 198 | case 3: |
| 199 | 199 | $order_by_name = true; |
| 200 | 200 | unset($order[$key]); |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); |
| 214 | - if($order_by_name) { |
|
| 214 | + if ($order_by_name) { |
|
| 215 | 215 | usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); }); |
| 216 | 216 | } |
| 217 | 217 | $recordsFiltered = count($list); |
| 218 | 218 | $recordsTotal = $this->provider->getTasksCount(); |
| 219 | 219 | |
| 220 | 220 | $data = array(); |
| 221 | - foreach($list as $task) { |
|
| 221 | + foreach ($list as $task) { |
|
| 222 | 222 | $datum = array(); |
| 223 | 223 | |
| 224 | 224 | $datum[0] = ' |
@@ -229,37 +229,34 @@ discard block |
||
| 229 | 229 | <ul class="dropdown-menu" role="menu"> |
| 230 | 230 | <li> |
| 231 | 231 | <a href="#" onclick="return set_admintask_status(\''. $task->getName().'\', '.($task->isEnabled() ? 'false' : 'true').');"> |
| 232 | - <i class="fa fa-fw '.($task->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . ' |
|
| 232 | + <i class="fa fa-fw '.($task->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).' |
|
| 233 | 233 | </a> |
| 234 | 234 | </li> |
| 235 | 235 | <li> |
| 236 | - <a href="module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='. $task->getName().'"> |
|
| 237 | - <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . ' |
|
| 236 | + <a href="module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='.$task->getName().'"> |
|
| 237 | + <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').' |
|
| 238 | 238 | </a> |
| 239 | 239 | </li> |
| 240 | 240 | </ul> |
| 241 | 241 | </div>'; |
| 242 | 242 | $datum[1] = $task->getName(); |
| 243 | 243 | $datum[2] = $task->isEnabled() ? |
| 244 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
|
| 245 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
| 244 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
| 246 | 245 | $datum[3] = $task->getTitle(); |
| 247 | - $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; |
|
| 246 | + $date_format = str_replace('%', '', I18N::dateFormat()).' H:i:s'; |
|
| 248 | 247 | $datum[4] = $task->getLastUpdated()->format($date_format); |
| 249 | 248 | $datum[5] = $task->isLastRunSuccess() ? |
| 250 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
|
| 251 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
| 249 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
| 252 | 250 | $dtF = new \DateTime('@0'); |
| 253 | - $dtT = new \DateTime('@' . ($task->getFrequency() * 60)); |
|
| 251 | + $dtT = new \DateTime('@'.($task->getFrequency() * 60)); |
|
| 254 | 252 | $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); |
| 255 | 253 | $datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited'); |
| 256 | 254 | $datum[8] = $task->isRunning() ? |
| 257 | - '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : |
|
| 258 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>'; |
|
| 259 | - if($task->isEnabled() && !$task->isRunning()) { |
|
| 255 | + '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>'; |
|
| 256 | + if ($task->isEnabled() && !$task->isRunning()) { |
|
| 260 | 257 | $datum[9] = ' |
| 261 | - <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')"> |
|
| 262 | - <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> |
|
| 258 | + <button id="bt_runtask_'. $task->getName().'" class="btn btn-primary" href="#" onclick="return run_admintask(\''.$task->getName().'\')"> |
|
| 259 | + <div id="bt_runtasktext_'. $task->getName().'"><i class="fa fa-cog fa-fw" ></i>'.I18N::translate('Run').'</div> |
|
| 263 | 260 | </button>'; |
| 264 | 261 | } |
| 265 | 262 | else { |
@@ -187,7 +187,9 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // Generate an AJAX/JSON response for datatables to load a block of rows |
| 189 | 189 | $search = Filter::postArray('search'); |
| 190 | - if($search) $search = $search['value']; |
|
| 190 | + if($search) { |
|
| 191 | + $search = $search['value']; |
|
| 192 | + } |
|
| 191 | 193 | $start = Filter::postInteger('start'); |
| 192 | 194 | $length = Filter::postInteger('length'); |
| 193 | 195 | $order = Filter::postArray('order'); |
@@ -261,8 +263,7 @@ discard block |
||
| 261 | 263 | <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')"> |
| 262 | 264 | <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> |
| 263 | 265 | </button>'; |
| 264 | - } |
|
| 265 | - else { |
|
| 266 | + } else { |
|
| 266 | 267 | $datum[9] = ''; |
| 267 | 268 | } |
| 268 | 269 | |
@@ -34,37 +34,37 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | class AdminConfigController extends MvcController |
| 36 | 36 | { |
| 37 | - /** |
|
| 38 | - * Tasks Provider |
|
| 39 | - * @var TaskProviderInterface $provider |
|
| 40 | - */ |
|
| 41 | - protected $provider; |
|
| 37 | + /** |
|
| 38 | + * Tasks Provider |
|
| 39 | + * @var TaskProviderInterface $provider |
|
| 40 | + */ |
|
| 41 | + protected $provider; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Constructor for Admin Config controller |
|
| 45 | - * @param \Fisharebest\Webtrees\Module\AbstractModule $module |
|
| 46 | - */ |
|
| 47 | - public function __construct(AbstractModule $module) { |
|
| 48 | - parent::__construct($module); |
|
| 43 | + /** |
|
| 44 | + * Constructor for Admin Config controller |
|
| 45 | + * @param \Fisharebest\Webtrees\Module\AbstractModule $module |
|
| 46 | + */ |
|
| 47 | + public function __construct(AbstractModule $module) { |
|
| 48 | + parent::__construct($module); |
|
| 49 | 49 | |
| 50 | - $this->provider = $this->module->getProvider(); |
|
| 51 | - } |
|
| 50 | + $this->provider = $this->module->getProvider(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Pages |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * Pages |
|
| 55 | + */ |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * AdminConfig@index |
|
| 59 | - */ |
|
| 60 | - public function index() { |
|
| 61 | - global $WT_TREE; |
|
| 57 | + /** |
|
| 58 | + * AdminConfig@index |
|
| 59 | + */ |
|
| 60 | + public function index() { |
|
| 61 | + global $WT_TREE; |
|
| 62 | 62 | |
| 63 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 64 | - $controller = new PageController(); |
|
| 65 | - $controller |
|
| 66 | - ->restrictAccess(Auth::isAdmin()) |
|
| 67 | - ->setPageTitle($this->module->getTitle()); |
|
| 63 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 64 | + $controller = new PageController(); |
|
| 65 | + $controller |
|
| 66 | + ->restrictAccess(Auth::isAdmin()) |
|
| 67 | + ->setPageTitle($this->module->getTitle()); |
|
| 68 | 68 | |
| 69 | 69 | $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); |
| 70 | 70 | if(is_null($token)) { |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | $this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $data = new ViewBag(); |
|
| 76 | - $data->set('title', $controller->getPageTitle()); |
|
| 75 | + $data = new ViewBag(); |
|
| 76 | + $data->set('title', $controller->getPageTitle()); |
|
| 77 | 77 | |
| 78 | - $table_id = 'table-admintasks-' . Uuid::uuid4(); |
|
| 79 | - $data->set('table_id', $table_id); |
|
| 78 | + $table_id = 'table-admintasks-' . Uuid::uuid4(); |
|
| 79 | + $data->set('table_id', $table_id); |
|
| 80 | 80 | |
| 81 | 81 | $data->set('trigger_url_root', WT_BASE_URL.'module.php?mod='.$this->module->getName().'&mod_action=Task@trigger'); |
| 82 | 82 | $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $this->provider->getInstalledTasks(); |
| 90 | 90 | |
| 91 | 91 | $controller |
| 92 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 93 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
| 94 | - ->addInlineJavascript(' |
|
| 92 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 93 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
| 94 | + ->addInlineJavascript(' |
|
| 95 | 95 | //Datatable initialisation |
| 96 | 96 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
| 97 | 97 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | }); |
| 124 | 124 | |
| 125 | 125 | ') |
| 126 | - ->addInlineJavascript(' |
|
| 126 | + ->addInlineJavascript(' |
|
| 127 | 127 | function generate_force_token() { |
| 128 | 128 | jQuery("#bt_genforcetoken").attr("disabled", "disabled"); |
| 129 | 129 | jQuery("#bt_tokentext").empty().html("<i class=\"fa fa-spinner fa-pulse fa-fw\"></i>"); |
@@ -171,56 +171,56 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | '); |
| 173 | 173 | |
| 174 | - ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
| 175 | - } |
|
| 174 | + ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - /** |
|
| 178 | - * AdminConfig@jsonTasksList |
|
| 179 | - */ |
|
| 180 | - public function jsonTasksList() { |
|
| 181 | - global $WT_TREE; |
|
| 177 | + /** |
|
| 178 | + * AdminConfig@jsonTasksList |
|
| 179 | + */ |
|
| 180 | + public function jsonTasksList() { |
|
| 181 | + global $WT_TREE; |
|
| 182 | 182 | |
| 183 | - $controller = new JsonController(); |
|
| 184 | - $controller |
|
| 185 | - ->restrictAccess(Auth::isAdmin()); |
|
| 183 | + $controller = new JsonController(); |
|
| 184 | + $controller |
|
| 185 | + ->restrictAccess(Auth::isAdmin()); |
|
| 186 | 186 | |
| 187 | - // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 188 | - $search = Filter::postArray('search'); |
|
| 189 | - if($search) $search = $search['value']; |
|
| 190 | - $start = Filter::postInteger('start'); |
|
| 191 | - $length = Filter::postInteger('length'); |
|
| 192 | - $order = Filter::postArray('order'); |
|
| 187 | + // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 188 | + $search = Filter::postArray('search'); |
|
| 189 | + if($search) $search = $search['value']; |
|
| 190 | + $start = Filter::postInteger('start'); |
|
| 191 | + $length = Filter::postInteger('length'); |
|
| 192 | + $order = Filter::postArray('order'); |
|
| 193 | 193 | |
| 194 | 194 | $order_by_name = false; |
| 195 | - foreach($order as $key => &$value) { |
|
| 196 | - switch($value['column']) { |
|
| 197 | - case 3: |
|
| 195 | + foreach($order as $key => &$value) { |
|
| 196 | + switch($value['column']) { |
|
| 197 | + case 3: |
|
| 198 | 198 | $order_by_name = true; |
| 199 | - unset($order[$key]); |
|
| 200 | - break; |
|
| 201 | - case 4; |
|
| 199 | + unset($order[$key]); |
|
| 200 | + break; |
|
| 201 | + case 4; |
|
| 202 | 202 | $value['column'] = 'majat_last_run'; |
| 203 | 203 | break; |
| 204 | 204 | case 4; |
| 205 | 205 | $value['column'] = 'majat_last_result'; |
| 206 | 206 | break; |
| 207 | - default: |
|
| 208 | - unset($order[$key]); |
|
| 209 | - } |
|
| 210 | - } |
|
| 207 | + default: |
|
| 208 | + unset($order[$key]); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); |
|
| 212 | + $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); |
|
| 213 | 213 | if($order_by_name) { |
| 214 | 214 | usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); }); |
| 215 | 215 | } |
| 216 | - $recordsFiltered = count($list); |
|
| 217 | - $recordsTotal = $this->provider->getTasksCount(); |
|
| 216 | + $recordsFiltered = count($list); |
|
| 217 | + $recordsTotal = $this->provider->getTasksCount(); |
|
| 218 | 218 | |
| 219 | - $data = array(); |
|
| 220 | - foreach($list as $task) { |
|
| 221 | - $datum = array(); |
|
| 219 | + $data = array(); |
|
| 220 | + foreach($list as $task) { |
|
| 221 | + $datum = array(); |
|
| 222 | 222 | |
| 223 | - $datum[0] = ' |
|
| 223 | + $datum[0] = ' |
|
| 224 | 224 | <div class="btn-group"> |
| 225 | 225 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
| 226 | 226 | <i class="fa fa-pencil"></i><span class="caret"></span> |
@@ -238,50 +238,50 @@ discard block |
||
| 238 | 238 | </li> |
| 239 | 239 | </ul> |
| 240 | 240 | </div>'; |
| 241 | - $datum[1] = $task->getName(); |
|
| 242 | - $datum[2] = $task->isEnabled() ? |
|
| 241 | + $datum[1] = $task->getName(); |
|
| 242 | + $datum[2] = $task->isEnabled() ? |
|
| 243 | 243 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
| 244 | 244 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
| 245 | - $datum[3] = $task->getTitle(); |
|
| 246 | - $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; |
|
| 245 | + $datum[3] = $task->getTitle(); |
|
| 246 | + $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; |
|
| 247 | 247 | $datum[4] = $task->getLastUpdated()->format($date_format); |
| 248 | - $datum[5] = $task->isLastRunSuccess() ? |
|
| 248 | + $datum[5] = $task->isLastRunSuccess() ? |
|
| 249 | 249 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
| 250 | 250 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
| 251 | - $dtF = new \DateTime('@0'); |
|
| 252 | - $dtT = new \DateTime('@' . ($task->getFrequency() * 60)); |
|
| 253 | - $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); |
|
| 251 | + $dtF = new \DateTime('@0'); |
|
| 252 | + $dtT = new \DateTime('@' . ($task->getFrequency() * 60)); |
|
| 253 | + $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); |
|
| 254 | 254 | $datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited'); |
| 255 | 255 | $datum[8] = $task->isRunning() ? |
| 256 | 256 | '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : |
| 257 | 257 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>'; |
| 258 | 258 | if($task->isEnabled() && !$task->isRunning()) { |
| 259 | - $datum[9] = ' |
|
| 259 | + $datum[9] = ' |
|
| 260 | 260 | <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')"> |
| 261 | 261 | <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> |
| 262 | 262 | </button>'; |
| 263 | 263 | } |
| 264 | 264 | else { |
| 265 | - $datum[9] = ''; |
|
| 265 | + $datum[9] = ''; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - $data[] = $datum; |
|
| 269 | - } |
|
| 268 | + $data[] = $datum; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - $controller->pageHeader(); |
|
| 271 | + $controller->pageHeader(); |
|
| 272 | 272 | |
| 273 | - echo \Zend_Json::encode(array( |
|
| 274 | - 'draw' => Filter::getInteger('draw'), |
|
| 275 | - 'recordsTotal' => $recordsTotal, |
|
| 276 | - 'recordsFiltered' => $recordsFiltered, |
|
| 277 | - 'data' => $data |
|
| 278 | - )); |
|
| 273 | + echo \Zend_Json::encode(array( |
|
| 274 | + 'draw' => Filter::getInteger('draw'), |
|
| 275 | + 'recordsTotal' => $recordsTotal, |
|
| 276 | + 'recordsFiltered' => $recordsFiltered, |
|
| 277 | + 'data' => $data |
|
| 278 | + )); |
|
| 279 | 279 | |
| 280 | - } |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | 282 | /** |
| 283 | 283 | * AdminConfig@generateToken |
| 284 | - * |
|
| 284 | + * |
|
| 285 | 285 | * Ajax call to generate a new token. Display the token, if generated. |
| 286 | 286 | * Tokens call only be generated by a site administrator. |
| 287 | 287 | * |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * {@inhericDoc} |
| 27 | 27 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
| 28 | 28 | */ |
| 29 | - protected function renderContent() { |
|
| 29 | + protected function renderContent() { |
|
| 30 | 30 | |
| 31 | - /** @var AbstractTask $task */ |
|
| 32 | - $task = $this->data->get('task'); |
|
| 33 | - ?> |
|
| 31 | + /** @var AbstractTask $task */ |
|
| 32 | + $task = $this->data->get('task'); |
|
| 33 | + ?> |
|
| 34 | 34 | <ol class="breadcrumb small"> |
| 35 | 35 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
| 36 | 36 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | </form> |
| 123 | 123 | |
| 124 | 124 | <?php |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | \ No newline at end of file |
@@ -104,7 +104,7 @@ |
||
| 104 | 104 | </div> |
| 105 | 105 | </div> |
| 106 | 106 | |
| 107 | - <?php if($task instanceof ConfigurableTaskInterface) { ?> |
|
| 107 | + <?php if ($task instanceof ConfigurableTaskInterface) { ?> |
|
| 108 | 108 | |
| 109 | 109 | <h3><?php echo I18N::translate('Options for “%s”', $task->getTitle()); ?></h3> |
| 110 | 110 | |
@@ -22,10 +22,10 @@ discard block |
||
| 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 |
||
| 68 | 68 | </table> |
| 69 | 69 | |
| 70 | 70 | <?php |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | \ No newline at end of file |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | <?php echo I18N::translate('In order to do so, use the following URL, with the optional parameter <em>%s</em> if you only want to force the execution of one task: ', 'task'); ?> |
| 41 | 41 | </p> |
| 42 | 42 | <p> |
| 43 | - <code><?php echo $this->data->get('trigger_url_root') .'&force=<span id="token_url">'. $this->data->get('trigger_token') .'</span>[&task='. I18N::translate('task_name').']'; ?></code> |
|
| 43 | + <code><?php echo $this->data->get('trigger_url_root').'&force=<span id="token_url">'.$this->data->get('trigger_token').'</span>[&task='.I18N::translate('task_name').']'; ?></code> |
|
| 44 | 44 | </p> |
| 45 | 45 | <p> |
| 46 | 46 | <button id="bt_genforcetoken" class="bt bt-primary" onClick="generate_force_token();"> |
@@ -29,66 +29,66 @@ discard block |
||
| 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 |
||
| 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 |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $user_id = Filter::postInteger('userid', -1) ?: Filter::getInteger('userid', -1); |
| 41 | 41 | return Auth::check() && |
| 42 | 42 | ( |
| 43 | - $user_id == Auth::user()->getUserId() || // Allow update for yourself |
|
| 43 | + $user_id == Auth::user()->getUserId() || // Allow update for yourself |
|
| 44 | 44 | ($user_id == -1 && Auth::isManager($WT_TREE)) // Allow a manager to update the default user |
| 45 | 45 | ); |
| 46 | 46 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | protected function update(BaseController $controller) { |
| 55 | 55 | global $WT_TREE; |
| 56 | - if($this->canUpdate() && Filter::checkCsrf()) |
|
| 56 | + if ($this->canUpdate() && Filter::checkCsrf()) |
|
| 57 | 57 | { |
| 58 | 58 | $indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE); |
| 59 | 59 | $user = User::find(Filter::postInteger('userid', -1)); |
| 60 | 60 | |
| 61 | - if($user && $indi) { |
|
| 61 | + if ($user && $indi) { |
|
| 62 | 62 | $WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref()); |
| 63 | 63 | $controller->addInlineJavascript(' |
| 64 | 64 | $( document ).ready(function() { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | function majComputeSosa(user_id) { |
| 99 | 99 | jQuery("#bt_sosa_compute").prop( "disabled", true ); |
| 100 | - jQuery("#bt_sosa_computing").empty().html("<i class=\"icon-loading-small\"></i> '. I18N::translate('Computing...') .'"); |
|
| 100 | + jQuery("#bt_sosa_computing").empty().html("<i class=\"icon-loading-small\"></i> '. I18N::translate('Computing...').'"); |
|
| 101 | 101 | jQuery("#bt_sosa_computing").load( |
| 102 | 102 | "module.php?mod='.$this->module->getName().'&mod_action=SosaConfig@computeAll&ged='.$WT_TREE->getNameUrl().'&userid=" + user_id, |
| 103 | 103 | function() { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | }'); |
| 107 | 107 | |
| 108 | 108 | $action = Filter::post('action'); |
| 109 | - if($action === 'update') $this->update($controller); |
|
| 109 | + if ($action === 'update') $this->update($controller); |
|
| 110 | 110 | |
| 111 | 111 | $view_bag = new ViewBag(); |
| 112 | 112 | $view_bag->set('title', $controller->getPageTitle()); |
@@ -115,21 +115,21 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $users_root = array(); |
| 117 | 117 | $users_js_array = 'var users_array = [];'; |
| 118 | - if(Auth::check()) { |
|
| 118 | + if (Auth::check()) { |
|
| 119 | 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 . '";'; |
|
| 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)) { |
|
| 123 | + if (Auth::isManager($WT_TREE)) { |
|
| 124 | 124 | $default_user = User::find(-1); |
| 125 | 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 . '";'; |
|
| 126 | + $users_root[] = array('user' => $default_user, 'rootid' => $default_root_id); |
|
| 127 | + $users_js_array .= 'users_array["'.$default_user->getUserId().'"] = "'.$default_root_id.'";'; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 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 | }); |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | $view_bag->set('is_success', false); |
| 152 | 152 | |
| 153 | 153 | $user = User::find(Filter::getInteger('userid', -1)); |
| 154 | - if($user) { |
|
| 154 | + if ($user) { |
|
| 155 | 155 | $calculator = new SosaCalculator($WT_TREE, $user); |
| 156 | - if($calculator->computeAll()) $view_bag->set('is_success', true); |
|
| 156 | + if ($calculator->computeAll()) $view_bag->set('is_success', true); |
|
| 157 | 157 | } |
| 158 | 158 | ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
| 159 | 159 | } |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | $user = User::find(Filter::getInteger('userid', -1)); |
| 174 | 174 | $indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE); |
| 175 | 175 | |
| 176 | - if($user && $indi) { |
|
| 176 | + if ($user && $indi) { |
|
| 177 | 177 | $calculator = new SosaCalculator($WT_TREE, $user); |
| 178 | - if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
| 178 | + if ($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
| 179 | 179 | } |
| 180 | 180 | else { |
| 181 | 181 | $view_bag->set('error', I18N::translate('Non existing individual')); |
@@ -106,7 +106,9 @@ discard block |
||
| 106 | 106 | }'); |
| 107 | 107 | |
| 108 | 108 | $action = Filter::post('action'); |
| 109 | - if($action === 'update') $this->update($controller); |
|
| 109 | + if($action === 'update') { |
|
| 110 | + $this->update($controller); |
|
| 111 | + } |
|
| 110 | 112 | |
| 111 | 113 | $view_bag = new ViewBag(); |
| 112 | 114 | $view_bag->set('title', $controller->getPageTitle()); |
@@ -153,7 +155,9 @@ discard block |
||
| 153 | 155 | $user = User::find(Filter::getInteger('userid', -1)); |
| 154 | 156 | if($user) { |
| 155 | 157 | $calculator = new SosaCalculator($WT_TREE, $user); |
| 156 | - if($calculator->computeAll()) $view_bag->set('is_success', true); |
|
| 158 | + if($calculator->computeAll()) { |
|
| 159 | + $view_bag->set('is_success', true); |
|
| 160 | + } |
|
| 157 | 161 | } |
| 158 | 162 | ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
| 159 | 163 | } |
@@ -175,9 +179,10 @@ discard block |
||
| 175 | 179 | |
| 176 | 180 | if($user && $indi) { |
| 177 | 181 | $calculator = new SosaCalculator($WT_TREE, $user); |
| 178 | - if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
| 179 | - } |
|
| 180 | - else { |
|
| 182 | + if($calculator->computeFromIndividual($indi)) { |
|
| 183 | + $view_bag->set('is_success', true); |
|
| 184 | + } |
|
| 185 | + } else { |
|
| 181 | 186 | $view_bag->set('error', I18N::translate('Non existing individual')); |
| 182 | 187 | } |
| 183 | 188 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $this->tree = $tree; |
| 59 | 59 | $this->user = $user; |
| 60 | 60 | |
| 61 | - $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
| 61 | + $this->sosa_provider = new SosaProvider($this->tree, $this->user); ; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | public function computeAll() { |
| 69 | 69 | $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
| 70 | 70 | $indi = Individual::getInstance($root_id, $this->tree); |
| 71 | - if($indi){ |
|
| 71 | + if ($indi) { |
|
| 72 | 72 | $this->sosa_provider->deleteAll(); |
| 73 | 73 | $tmp_sosatable = array(); |
| 74 | 74 | $this->addNode($indi, 1); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $tmp_sosatable = array(); |
| 88 | 88 | $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
| 89 | 89 | $current_sosas = $dindi->getSosaNumbers(); |
| 90 | - foreach($current_sosas as $current_sosa => $gen) { |
|
| 90 | + foreach ($current_sosas as $current_sosa => $gen) { |
|
| 91 | 91 | $this->sosa_provider->deleteAncestors($current_sosa); |
| 92 | 92 | $this->addNode($indi, $current_sosa); |
| 93 | 93 | } |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | |
| 114 | 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); |
|
| 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 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @param bool $force Should the flush be forced |
| 126 | 126 | */ |
| 127 | 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)){ |
|
| 128 | + if (count($this->tmp_sosa_table) > 0 && |
|
| 129 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)) { |
|
| 130 | 130 | $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
| 131 | 131 | $this->tmp_sosa_table = array(); |
| 132 | 132 | } |
@@ -114,8 +114,12 @@ |
||
| 114 | 114 | $this->flushTmpSosaTable(); |
| 115 | 115 | |
| 116 | 116 | if($fam = $indi->getPrimaryChildFamily()) { |
| 117 | - if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
| 118 | - if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
| 117 | + if($husb = $fam->getHusband()) { |
|
| 118 | + $this->addNode($husb, 2 * $sosa); |
|
| 119 | + } |
|
| 120 | + if($wife = $fam->getWife()) { |
|
| 121 | + $this->addNode($wife, 2 * $sosa + 1); |
|
| 122 | + } |
|
| 119 | 123 | } |
| 120 | 124 | } |
| 121 | 125 | |
@@ -19,116 +19,116 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class SosaCalculator { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Maximium size for the temporary Sosa table |
|
| 24 | - * @var int TMP_SOSA_TABLE_LIMIT |
|
| 25 | - */ |
|
| 26 | - const TMP_SOSA_TABLE_LIMIT = 1000; |
|
| 22 | + /** |
|
| 23 | + * Maximium size for the temporary Sosa table |
|
| 24 | + * @var int TMP_SOSA_TABLE_LIMIT |
|
| 25 | + */ |
|
| 26 | + const TMP_SOSA_TABLE_LIMIT = 1000; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Reference user |
|
| 30 | - * @var Fisharebest\Webtrees\User $user |
|
| 31 | - */ |
|
| 32 | - protected $user; |
|
| 28 | + /** |
|
| 29 | + * Reference user |
|
| 30 | + * @var Fisharebest\Webtrees\User $user |
|
| 31 | + */ |
|
| 32 | + protected $user; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Reference tree |
|
| 36 | - * @var Fisharebest\Webtrees\Tree $tree |
|
| 37 | - */ |
|
| 38 | - protected $tree; |
|
| 34 | + /** |
|
| 35 | + * Reference tree |
|
| 36 | + * @var Fisharebest\Webtrees\Tree $tree |
|
| 37 | + */ |
|
| 38 | + protected $tree; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Sosa Provider for the calculator |
|
| 42 | - * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
| 43 | - */ |
|
| 44 | - protected $sosa_provider; |
|
| 40 | + /** |
|
| 41 | + * Sosa Provider for the calculator |
|
| 42 | + * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
| 43 | + */ |
|
| 44 | + protected $sosa_provider; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Temporary Sosa table, used during construction |
|
| 48 | - * @var array $tmp_sosa_table |
|
| 49 | - */ |
|
| 50 | - protected $tmp_sosa_table; |
|
| 46 | + /** |
|
| 47 | + * Temporary Sosa table, used during construction |
|
| 48 | + * @var array $tmp_sosa_table |
|
| 49 | + */ |
|
| 50 | + protected $tmp_sosa_table; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Constructor for the Sosa Calculator |
|
| 54 | - * @param Tree $tree |
|
| 55 | - * @param User $user |
|
| 56 | - */ |
|
| 57 | - public function __construct(Tree $tree, User $user) { |
|
| 58 | - $this->tree = $tree; |
|
| 59 | - $this->user = $user; |
|
| 52 | + /** |
|
| 53 | + * Constructor for the Sosa Calculator |
|
| 54 | + * @param Tree $tree |
|
| 55 | + * @param User $user |
|
| 56 | + */ |
|
| 57 | + public function __construct(Tree $tree, User $user) { |
|
| 58 | + $this->tree = $tree; |
|
| 59 | + $this->user = $user; |
|
| 60 | 60 | |
| 61 | - $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
| 62 | - } |
|
| 61 | + $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Compute all Sosa ancestors from the user's root individual. |
|
| 66 | - * @return bool Result of the computation |
|
| 67 | - */ |
|
| 68 | - public function computeAll() { |
|
| 69 | - $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
| 70 | - $indi = Individual::getInstance($root_id, $this->tree); |
|
| 71 | - if($indi){ |
|
| 72 | - $this->sosa_provider->deleteAll(); |
|
| 73 | - $this->addNode($indi, 1); |
|
| 74 | - $this->flushTmpSosaTable(true); |
|
| 75 | - return true; |
|
| 76 | - } |
|
| 77 | - return false; |
|
| 78 | - } |
|
| 64 | + /** |
|
| 65 | + * Compute all Sosa ancestors from the user's root individual. |
|
| 66 | + * @return bool Result of the computation |
|
| 67 | + */ |
|
| 68 | + public function computeAll() { |
|
| 69 | + $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
| 70 | + $indi = Individual::getInstance($root_id, $this->tree); |
|
| 71 | + if($indi){ |
|
| 72 | + $this->sosa_provider->deleteAll(); |
|
| 73 | + $this->addNode($indi, 1); |
|
| 74 | + $this->flushTmpSosaTable(true); |
|
| 75 | + return true; |
|
| 76 | + } |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Compute all Sosa Ancestors from a specified Individual |
|
| 82 | - * @param Individual $indi |
|
| 83 | - * @return bool Result of the computation |
|
| 84 | - */ |
|
| 85 | - public function computeFromIndividual(Individual $indi) { |
|
| 86 | - $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
| 87 | - $current_sosas = $dindi->getSosaNumbers(); |
|
| 88 | - foreach($current_sosas as $current_sosa => $gen) { |
|
| 89 | - $this->sosa_provider->deleteAncestors($current_sosa); |
|
| 90 | - $this->addNode($indi, $current_sosa); |
|
| 91 | - } |
|
| 92 | - $this->flushTmpSosaTable(true); |
|
| 93 | - return true; |
|
| 94 | - } |
|
| 80 | + /** |
|
| 81 | + * Compute all Sosa Ancestors from a specified Individual |
|
| 82 | + * @param Individual $indi |
|
| 83 | + * @return bool Result of the computation |
|
| 84 | + */ |
|
| 85 | + public function computeFromIndividual(Individual $indi) { |
|
| 86 | + $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
| 87 | + $current_sosas = $dindi->getSosaNumbers(); |
|
| 88 | + foreach($current_sosas as $current_sosa => $gen) { |
|
| 89 | + $this->sosa_provider->deleteAncestors($current_sosa); |
|
| 90 | + $this->addNode($indi, $current_sosa); |
|
| 91 | + } |
|
| 92 | + $this->flushTmpSosaTable(true); |
|
| 93 | + return true; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Recursive method to add individual to the Sosa table, and flush it regularly |
|
| 98 | - * @param Individual $indi Individual to add |
|
| 99 | - * @param int $sosa Individual's sosa |
|
| 100 | - */ |
|
| 101 | - protected function addNode(Individual $indi, $sosa) { |
|
| 102 | - $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
| 103 | - $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
| 96 | + /** |
|
| 97 | + * Recursive method to add individual to the Sosa table, and flush it regularly |
|
| 98 | + * @param Individual $indi Individual to add |
|
| 99 | + * @param int $sosa Individual's sosa |
|
| 100 | + */ |
|
| 101 | + protected function addNode(Individual $indi, $sosa) { |
|
| 102 | + $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
| 103 | + $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
| 104 | 104 | |
| 105 | - $this->tmp_sosa_table[] = array( |
|
| 106 | - 'indi' => $indi->getXref(), |
|
| 107 | - 'sosa' => $sosa, |
|
| 108 | - 'birth_year' => $birth_year, |
|
| 109 | - 'death_year' => $death_year |
|
| 110 | - ); |
|
| 105 | + $this->tmp_sosa_table[] = array( |
|
| 106 | + 'indi' => $indi->getXref(), |
|
| 107 | + 'sosa' => $sosa, |
|
| 108 | + 'birth_year' => $birth_year, |
|
| 109 | + 'death_year' => $death_year |
|
| 110 | + ); |
|
| 111 | 111 | |
| 112 | - $this->flushTmpSosaTable(); |
|
| 112 | + $this->flushTmpSosaTable(); |
|
| 113 | 113 | |
| 114 | - if($fam = $indi->getPrimaryChildFamily()) { |
|
| 115 | - if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
| 116 | - if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
| 117 | - } |
|
| 118 | - } |
|
| 114 | + if($fam = $indi->getPrimaryChildFamily()) { |
|
| 115 | + if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
| 116 | + if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
| 122 | - * |
|
| 123 | - * @param bool $force Should the flush be forced |
|
| 124 | - */ |
|
| 125 | - protected function flushTmpSosaTable($force = false) { |
|
| 126 | - if( count($this->tmp_sosa_table)> 0 && |
|
| 127 | - ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
| 128 | - $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
| 129 | - $this->tmp_sosa_table = array(); |
|
| 130 | - } |
|
| 131 | - } |
|
| 120 | + /** |
|
| 121 | + * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
| 122 | + * |
|
| 123 | + * @param bool $force Should the flush be forced |
|
| 124 | + */ |
|
| 125 | + protected function flushTmpSosaTable($force = false) { |
|
| 126 | + if( count($this->tmp_sosa_table)> 0 && |
|
| 127 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
| 128 | + $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
| 129 | + $this->tmp_sosa_table = array(); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | \ No newline at end of file |
@@ -431,8 +431,7 @@ discard block |
||
| 431 | 431 | ) { |
| 432 | 432 | $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
| 433 | 433 | } |
| 434 | - } |
|
| 435 | - else { |
|
| 434 | + } else { |
|
| 436 | 435 | $birth_dates[0]=new Date(''); |
| 437 | 436 | } |
| 438 | 437 | if ($death_dates = $person->getAllDeathDates()) { |
@@ -443,8 +442,7 @@ discard block |
||
| 443 | 442 | ) { |
| 444 | 443 | $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
| 445 | 444 | } |
| 446 | - } |
|
| 447 | - else { |
|
| 445 | + } else { |
|
| 448 | 446 | $death_dates[0] = new Date(''); |
| 449 | 447 | } |
| 450 | 448 | $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
@@ -36,70 +36,70 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class SosaListController extends MvcController |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * Sosa Provider for the controller |
|
| 41 | - * @var SosaProvider $sosa_provider |
|
| 42 | - */ |
|
| 43 | - protected $sosa_provider; |
|
| 39 | + /** |
|
| 40 | + * Sosa Provider for the controller |
|
| 41 | + * @var SosaProvider $sosa_provider |
|
| 42 | + */ |
|
| 43 | + protected $sosa_provider; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Generation used for the controller |
|
| 47 | - * @var int $generation |
|
| 48 | - */ |
|
| 49 | - protected $generation; |
|
| 45 | + /** |
|
| 46 | + * Generation used for the controller |
|
| 47 | + * @var int $generation |
|
| 48 | + */ |
|
| 49 | + protected $generation; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * ViewBag to hold data for the controller |
|
| 53 | - * @var ViewBag $view_bag |
|
| 54 | - */ |
|
| 55 | - protected $view_bag; |
|
| 51 | + /** |
|
| 52 | + * ViewBag to hold data for the controller |
|
| 53 | + * @var ViewBag $view_bag |
|
| 54 | + */ |
|
| 55 | + protected $view_bag; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * {@inheritDoc} |
|
| 59 | - * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module) |
|
| 60 | - */ |
|
| 61 | - public function __construct(AbstractModule $module) { |
|
| 62 | - global $WT_TREE; |
|
| 57 | + /** |
|
| 58 | + * {@inheritDoc} |
|
| 59 | + * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module) |
|
| 60 | + */ |
|
| 61 | + public function __construct(AbstractModule $module) { |
|
| 62 | + global $WT_TREE; |
|
| 63 | 63 | |
| 64 | - parent::__construct($module); |
|
| 64 | + parent::__construct($module); |
|
| 65 | 65 | |
| 66 | - $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
| 66 | + $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
| 67 | 67 | |
| 68 | - $this->generation = Filter::getInteger('gen'); |
|
| 68 | + $this->generation = Filter::getInteger('gen'); |
|
| 69 | 69 | |
| 70 | - $this->view_bag = new ViewBag(); |
|
| 71 | - $this->view_bag->set('generation', $this->generation); |
|
| 72 | - $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration()); |
|
| 73 | - $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0); |
|
| 70 | + $this->view_bag = new ViewBag(); |
|
| 71 | + $this->view_bag->set('generation', $this->generation); |
|
| 72 | + $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration()); |
|
| 73 | + $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0); |
|
| 74 | 74 | |
| 75 | - } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Pages |
|
| 80 | - */ |
|
| 78 | + /** |
|
| 79 | + * Pages |
|
| 80 | + */ |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * SosaList@index |
|
| 84 | - */ |
|
| 85 | - public function index() { |
|
| 86 | - global $WT_TREE; |
|
| 82 | + /** |
|
| 83 | + * SosaList@index |
|
| 84 | + */ |
|
| 85 | + public function index() { |
|
| 86 | + global $WT_TREE; |
|
| 87 | 87 | |
| 88 | - $controller = new PageController(); |
|
| 89 | - $controller |
|
| 90 | - ->setPageTitle(I18N::translate('Sosa Ancestors')); |
|
| 88 | + $controller = new PageController(); |
|
| 89 | + $controller |
|
| 90 | + ->setPageTitle(I18N::translate('Sosa Ancestors')); |
|
| 91 | 91 | |
| 92 | - $this->view_bag->set('title', $controller->getPageTitle()); |
|
| 92 | + $this->view_bag->set('title', $controller->getPageTitle()); |
|
| 93 | 93 | |
| 94 | - if($this->view_bag->get('is_setup', false)) { |
|
| 95 | - $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
|
| 96 | - $this->view_bag->set('url_module', $this->module->getName()); |
|
| 97 | - $this->view_bag->set('url_action', 'SosaList'); |
|
| 98 | - $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 99 | - $this->view_bag->set('min_gen', 1); |
|
| 94 | + if($this->view_bag->get('is_setup', false)) { |
|
| 95 | + $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
|
| 96 | + $this->view_bag->set('url_module', $this->module->getName()); |
|
| 97 | + $this->view_bag->set('url_action', 'SosaList'); |
|
| 98 | + $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 99 | + $this->view_bag->set('min_gen', 1); |
|
| 100 | 100 | |
| 101 | - if($this->view_bag->get('has_sosa', false)) { |
|
| 102 | - $controller->addInlineJavascript(' |
|
| 101 | + if($this->view_bag->get('has_sosa', false)) { |
|
| 102 | + $controller->addInlineJavascript(' |
|
| 103 | 103 | jQuery("#sosalist-tabs").tabs(); |
| 104 | 104 | jQuery("#sosalist-tabs").css("visibility", "visible"); |
| 105 | 105 | |
@@ -153,44 +153,44 @@ discard block |
||
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | 155 | '); |
| 156 | - } |
|
| 157 | - } |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render(); |
|
| 160 | - } |
|
| 159 | + ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * SosaList@missing |
|
| 165 | - */ |
|
| 166 | - public function missing() { |
|
| 167 | - global $WT_TREE; |
|
| 163 | + /** |
|
| 164 | + * SosaList@missing |
|
| 165 | + */ |
|
| 166 | + public function missing() { |
|
| 167 | + global $WT_TREE; |
|
| 168 | 168 | |
| 169 | - $controller = new PageController(); |
|
| 170 | - $controller |
|
| 171 | - ->setPageTitle(I18N::translate('Missing Ancestors')); |
|
| 169 | + $controller = new PageController(); |
|
| 170 | + $controller |
|
| 171 | + ->setPageTitle(I18N::translate('Missing Ancestors')); |
|
| 172 | 172 | |
| 173 | - $this->view_bag->set('title', $controller->getPageTitle()); |
|
| 173 | + $this->view_bag->set('title', $controller->getPageTitle()); |
|
| 174 | 174 | |
| 175 | - if($this->view_bag->get('is_setup', false)) { |
|
| 176 | - $this->view_bag->set('url_module', $this->module->getName()); |
|
| 177 | - $this->view_bag->set('url_action', 'SosaList@missing'); |
|
| 178 | - $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 179 | - $this->view_bag->set('min_gen', 2); |
|
| 175 | + if($this->view_bag->get('is_setup', false)) { |
|
| 176 | + $this->view_bag->set('url_module', $this->module->getName()); |
|
| 177 | + $this->view_bag->set('url_action', 'SosaList@missing'); |
|
| 178 | + $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 179 | + $this->view_bag->set('min_gen', 2); |
|
| 180 | 180 | |
| 181 | - $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
|
| 182 | - $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
|
| 181 | + $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
|
| 182 | + $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
|
| 183 | 183 | |
| 184 | - $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
| 185 | - $this->view_bag->set('perc_sosa', $perc_sosa); |
|
| 184 | + $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
| 185 | + $this->view_bag->set('perc_sosa', $perc_sosa); |
|
| 186 | 186 | |
| 187 | - if($this->view_bag->get('has_missing', false)) { |
|
| 188 | - $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
| 189 | - $this->view_bag->set('table_id', $table_id); |
|
| 187 | + if($this->view_bag->get('has_missing', false)) { |
|
| 188 | + $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
| 189 | + $this->view_bag->set('table_id', $table_id); |
|
| 190 | 190 | |
| 191 | - $controller |
|
| 192 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 193 | - ->addInlineJavascript(' |
|
| 191 | + $controller |
|
| 192 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 193 | + ->addInlineJavascript(' |
|
| 194 | 194 | /* Initialise datatables */ |
| 195 | 195 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
| 196 | 196 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -250,77 +250,77 @@ discard block |
||
| 250 | 250 | jQuery(".loading-image").css("display", "none"); |
| 251 | 251 | '); |
| 252 | 252 | |
| 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 | - } |
|
| 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,96 +396,96 @@ discard block |
||
| 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 | - FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
|
| 429 | - !isset($unique_indis[$person->getXref()]) |
|
| 430 | - ) { |
|
| 431 | - $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - else { |
|
| 435 | - $birth_dates[0]=new Date(''); |
|
| 436 | - } |
|
| 437 | - if ($death_dates = $person->getAllDeathDates()) { |
|
| 438 | - if ( |
|
| 439 | - FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
|
| 440 | - !isset($unique_indis[$person->getXref()]) |
|
| 441 | - ) { |
|
| 442 | - $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
| 443 | - } |
|
| 444 | - } |
|
| 445 | - else { |
|
| 446 | - $death_dates[0] = new Date(''); |
|
| 447 | - } |
|
| 448 | - $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
| 449 | - if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) { |
|
| 450 | - $deat_by_age[$age] .= $person->getSex(); |
|
| 451 | - } |
|
| 452 | - $listSosa[$sosa] = $person; |
|
| 453 | - $unique_indis[$person->getXref()] = true; |
|
| 454 | - } |
|
| 455 | - $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 | + FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
|
| 429 | + !isset($unique_indis[$person->getXref()]) |
|
| 430 | + ) { |
|
| 431 | + $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + else { |
|
| 435 | + $birth_dates[0]=new Date(''); |
|
| 436 | + } |
|
| 437 | + if ($death_dates = $person->getAllDeathDates()) { |
|
| 438 | + if ( |
|
| 439 | + FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
|
| 440 | + !isset($unique_indis[$person->getXref()]) |
|
| 441 | + ) { |
|
| 442 | + $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | + else { |
|
| 446 | + $death_dates[0] = new Date(''); |
|
| 447 | + } |
|
| 448 | + $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
| 449 | + if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) { |
|
| 450 | + $deat_by_age[$age] .= $person->getSex(); |
|
| 451 | + } |
|
| 452 | + $listSosa[$sosa] = $person; |
|
| 453 | + $unique_indis[$person->getXref()] = true; |
|
| 454 | + } |
|
| 455 | + $this->view_bag->set('sosa_list', $listSosa); |
|
| 456 | 456 | |
| 457 | - $this->view_bag->set('sosa_count', count($listSosa)); |
|
| 458 | - $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
| 459 | - $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
|
| 457 | + $this->view_bag->set('sosa_count', count($listSosa)); |
|
| 458 | + $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
| 459 | + $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
|
| 460 | 460 | |
| 461 | - $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
|
| 461 | + $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
|
| 462 | 462 | |
| 463 | - $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
| 464 | - $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death'))); |
|
| 465 | - $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year'))); |
|
| 466 | - } |
|
| 463 | + $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
| 464 | + $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death'))); |
|
| 465 | + $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year'))); |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render(); |
|
| 469 | - } |
|
| 468 | + ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render(); |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | - /** |
|
| 472 | - * Render the Ajax response for the sortable table of Sosa family |
|
| 473 | - * @param AjaxController $controller |
|
| 474 | - */ |
|
| 475 | - protected function renderFamSosaListIndi(AjaxController $controller) { |
|
| 476 | - global $WT_TREE; |
|
| 471 | + /** |
|
| 472 | + * Render the Ajax response for the sortable table of Sosa family |
|
| 473 | + * @param AjaxController $controller |
|
| 474 | + */ |
|
| 475 | + protected function renderFamSosaListIndi(AjaxController $controller) { |
|
| 476 | + global $WT_TREE; |
|
| 477 | 477 | |
| 478 | - $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
| 479 | - $this->view_bag->set('has_sosa', false); |
|
| 478 | + $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
| 479 | + $this->view_bag->set('has_sosa', false); |
|
| 480 | 480 | |
| 481 | - if(count($listFamSosa) > 0) { |
|
| 482 | - $this->view_bag->set('has_sosa', true); |
|
| 483 | - $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
| 484 | - $this->view_bag->set('table_id', $table_id); |
|
| 481 | + if(count($listFamSosa) > 0) { |
|
| 482 | + $this->view_bag->set('has_sosa', true); |
|
| 483 | + $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
| 484 | + $this->view_bag->set('table_id', $table_id); |
|
| 485 | 485 | |
| 486 | - $controller |
|
| 487 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 488 | - ->addInlineJavascript(' |
|
| 486 | + $controller |
|
| 487 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 488 | + ->addInlineJavascript(' |
|
| 489 | 489 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
| 490 | 490 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
| 491 | 491 | 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);}; |
@@ -561,67 +561,67 @@ discard block |
||
| 561 | 561 | jQuery("#btn-toggle-statistics-'.$table_id.'").click(); |
| 562 | 562 | '); |
| 563 | 563 | |
| 564 | - $stats = new Stats($WT_TREE); |
|
| 565 | - $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; |
|
| 564 | + $stats = new Stats($WT_TREE); |
|
| 565 | + $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; |
|
| 566 | 566 | |
| 567 | - //-- init chart data |
|
| 568 | - $marr_by_age = array(); |
|
| 569 | - for ($age=0; $age<=$max_age; $age++) { |
|
| 570 | - $marr_by_age[$age] = ''; |
|
| 571 | - } |
|
| 572 | - $birt_by_decade = array(); |
|
| 573 | - $marr_by_decade = array(); |
|
| 574 | - for ($year=1550; $year<2030; $year+=10) { |
|
| 575 | - $birt_by_decade[$year] = ''; |
|
| 576 | - $marr_by_decade[$year] = ''; |
|
| 577 | - } |
|
| 567 | + //-- init chart data |
|
| 568 | + $marr_by_age = array(); |
|
| 569 | + for ($age=0; $age<=$max_age; $age++) { |
|
| 570 | + $marr_by_age[$age] = ''; |
|
| 571 | + } |
|
| 572 | + $birt_by_decade = array(); |
|
| 573 | + $marr_by_decade = array(); |
|
| 574 | + for ($year=1550; $year<2030; $year+=10) { |
|
| 575 | + $birt_by_decade[$year] = ''; |
|
| 576 | + $marr_by_decade[$year] = ''; |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | - foreach($listFamSosa as $sosa => $fid) { |
|
| 580 | - $sfamily = Family::getInstance($fid, $WT_TREE); |
|
| 581 | - if(!$sfamily || !$sfamily->canShow()) { |
|
| 582 | - unset($sfamily[$sosa]); |
|
| 583 | - continue; |
|
| 584 | - } |
|
| 585 | - $mdate=$sfamily->getMarriageDate(); |
|
| 579 | + foreach($listFamSosa as $sosa => $fid) { |
|
| 580 | + $sfamily = Family::getInstance($fid, $WT_TREE); |
|
| 581 | + if(!$sfamily || !$sfamily->canShow()) { |
|
| 582 | + unset($sfamily[$sosa]); |
|
| 583 | + continue; |
|
| 584 | + } |
|
| 585 | + $mdate=$sfamily->getMarriageDate(); |
|
| 586 | 586 | |
| 587 | - if( ($husb = $sfamily->getHusband()) && |
|
| 588 | - ($hdate = $husb->getBirthDate()) && |
|
| 589 | - $hdate->isOK() && $mdate->isOK()) { |
|
| 590 | - if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
|
| 591 | - $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
| 592 | - } |
|
| 593 | - $hage = Date::getAge($hdate, $mdate, 0); |
|
| 594 | - if ($hage >= 0 && $hage <= $max_age) { |
|
| 595 | - $marr_by_age[$hage] .= $husb->getSex(); |
|
| 596 | - } |
|
| 597 | - } |
|
| 587 | + if( ($husb = $sfamily->getHusband()) && |
|
| 588 | + ($hdate = $husb->getBirthDate()) && |
|
| 589 | + $hdate->isOK() && $mdate->isOK()) { |
|
| 590 | + if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
|
| 591 | + $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
| 592 | + } |
|
| 593 | + $hage = Date::getAge($hdate, $mdate, 0); |
|
| 594 | + if ($hage >= 0 && $hage <= $max_age) { |
|
| 595 | + $marr_by_age[$hage] .= $husb->getSex(); |
|
| 596 | + } |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | - if(($wife = $sfamily->getWife()) && |
|
| 600 | - ($wdate=$wife->getBirthDate()) && |
|
| 601 | - $wdate->isOK() && $mdate->isOK()) { |
|
| 602 | - if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
|
| 603 | - $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
| 604 | - } |
|
| 605 | - $wage = Date::getAge($wdate, $mdate, 0); |
|
| 606 | - if ($wage >= 0 && $wage <= $max_age) { |
|
| 607 | - $marr_by_age[$wage] .= $wife->getSex(); |
|
| 608 | - } |
|
| 609 | - } |
|
| 599 | + if(($wife = $sfamily->getWife()) && |
|
| 600 | + ($wdate=$wife->getBirthDate()) && |
|
| 601 | + $wdate->isOK() && $mdate->isOK()) { |
|
| 602 | + if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
|
| 603 | + $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
| 604 | + } |
|
| 605 | + $wage = Date::getAge($wdate, $mdate, 0); |
|
| 606 | + if ($wage >= 0 && $wage <= $max_age) { |
|
| 607 | + $marr_by_age[$wage] .= $wife->getSex(); |
|
| 608 | + } |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | - if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
|
| 612 | - $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
| 613 | - } |
|
| 611 | + if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
|
| 612 | + $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - $listFamSosa[$sosa] = $sfamily; |
|
| 616 | - } |
|
| 617 | - $this->view_bag->set('sosa_list', $listFamSosa); |
|
| 615 | + $listFamSosa[$sosa] = $sfamily; |
|
| 616 | + } |
|
| 617 | + $this->view_bag->set('sosa_list', $listFamSosa); |
|
| 618 | 618 | |
| 619 | - $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
| 620 | - $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage'))); |
|
| 621 | - $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage'))); |
|
| 622 | - } |
|
| 619 | + $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
| 620 | + $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage'))); |
|
| 621 | + $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage'))); |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render(); |
|
| 625 | - } |
|
| 624 | + ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render(); |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | 627 | } |
| 628 | 628 | \ No newline at end of file |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $this->view_bag = new ViewBag(); |
| 71 | 71 | $this->view_bag->set('generation', $this->generation); |
| 72 | 72 | $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration()); |
| 73 | - $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0); |
|
| 73 | + $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0) > 0); |
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $this->view_bag->set('title', $controller->getPageTitle()); |
| 93 | 93 | |
| 94 | - if($this->view_bag->get('is_setup', false)) { |
|
| 94 | + if ($this->view_bag->get('is_setup', false)) { |
|
| 95 | 95 | $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
| 96 | 96 | $this->view_bag->set('url_module', $this->module->getName()); |
| 97 | 97 | $this->view_bag->set('url_action', 'SosaList'); |
| 98 | 98 | $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
| 99 | 99 | $this->view_bag->set('min_gen', 1); |
| 100 | 100 | |
| 101 | - if($this->view_bag->get('has_sosa', false)) { |
|
| 101 | + if ($this->view_bag->get('has_sosa', false)) { |
|
| 102 | 102 | $controller->addInlineJavascript(' |
| 103 | 103 | jQuery("#sosalist-tabs").tabs(); |
| 104 | 104 | jQuery("#sosalist-tabs").css("visibility", "visible"); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | "mod" : "'.$this->module->getName().'", |
| 110 | 110 | "mod_action": "SosaList@sosalist", |
| 111 | - "ged" : "' . $WT_TREE->getNameUrl(). '", |
|
| 111 | + "ged" : "' . $WT_TREE->getNameUrl().'", |
|
| 112 | 112 | "type" : "indi", |
| 113 | 113 | "gen" : "'.$this->generation.'" |
| 114 | 114 | }, |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | "mod" : "'.$this->module->getName().'", |
| 135 | 135 | "mod_action": "SosaList@sosalist", |
| 136 | - "ged" : "' . $WT_TREE->getNameUrl(). '", |
|
| 136 | + "ged" : "' . $WT_TREE->getNameUrl().'", |
|
| 137 | 137 | "type" : "fam", |
| 138 | 138 | "gen" : "'.$this->generation.'" |
| 139 | 139 | }, |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $this->view_bag->set('title', $controller->getPageTitle()); |
| 174 | 174 | |
| 175 | - if($this->view_bag->get('is_setup', false)) { |
|
| 175 | + if ($this->view_bag->get('is_setup', false)) { |
|
| 176 | 176 | $this->view_bag->set('url_module', $this->module->getName()); |
| 177 | 177 | $this->view_bag->set('url_action', 'SosaList@missing'); |
| 178 | 178 | $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
@@ -181,11 +181,11 @@ discard block |
||
| 181 | 181 | $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
| 182 | 182 | $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
| 183 | 183 | |
| 184 | - $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
| 184 | + $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation - 1)); |
|
| 185 | 185 | $this->view_bag->set('perc_sosa', $perc_sosa); |
| 186 | 186 | |
| 187 | - if($this->view_bag->get('has_missing', false)) { |
|
| 188 | - $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
| 187 | + if ($this->view_bag->get('has_missing', false)) { |
|
| 188 | + $table_id = 'table-sosa-missing-'.Uuid::uuid4(); |
|
| 189 | 189 | $this->view_bag->set('table_id', $table_id); |
| 190 | 190 | |
| 191 | 191 | $controller |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
| 199 | 199 | |
| 200 | 200 | jQuery("#'.$table_id.'").dataTable( { |
| 201 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
| 201 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
| 202 | 202 | '.I18N::datatablesI18N().', |
| 203 | 203 | jQueryUI: true, |
| 204 | 204 | autoWidth:false, |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | pagingType: "full_numbers" |
| 230 | 230 | }); |
| 231 | 231 | |
| 232 | - jQuery("#' . $table_id . '") |
|
| 232 | + jQuery("#' . $table_id.'") |
|
| 233 | 233 | /* Filter buttons in table header */ |
| 234 | 234 | .on("click", "button[data-filter-column]", function() { |
| 235 | 235 | var btn = jQuery(this); |
| 236 | 236 | // De-activate the other buttons in this button group |
| 237 | 237 | btn.siblings().removeClass("ui-state-active"); |
| 238 | 238 | // Apply (or clear) this filter |
| 239 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
| 239 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
| 240 | 240 | if (btn.hasClass("ui-state-active")) { |
| 241 | 241 | btn.removeClass("ui-state-active"); |
| 242 | 242 | col.search("").draw(); |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | $unique_indis = array(); |
| 254 | 254 | $sum_missing_different = 0; |
| 255 | 255 | $sum_missing_different_without_hidden = 0; |
| 256 | - foreach($missing_list as $num => $missing_tab) { |
|
| 257 | - if(isset($unique_indis[$missing_tab['indi']])) { |
|
| 256 | + foreach ($missing_list as $num => $missing_tab) { |
|
| 257 | + if (isset($unique_indis[$missing_tab['indi']])) { |
|
| 258 | 258 | unset($missing_list[$num]); |
| 259 | 259 | continue; |
| 260 | 260 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $this->view_bag->set('missing_list', $missing_list); |
| 273 | 273 | $this->view_bag->set('missing_diff_count', $sum_missing_different); |
| 274 | 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)); |
|
| 275 | + $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation - 2)); |
|
| 276 | 276 | $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $controller = new AjaxController(); |
| 291 | 291 | $controller->restrictAccess($this->generation > 0 || !is_null($type)); |
| 292 | 292 | |
| 293 | - switch ($type){ |
|
| 293 | + switch ($type) { |
|
| 294 | 294 | case 'indi': |
| 295 | 295 | $this->renderSosaListIndi($controller); |
| 296 | 296 | break; |
@@ -313,9 +313,9 @@ discard block |
||
| 313 | 313 | $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); |
| 314 | 314 | $this->view_bag->set('has_sosa', false); |
| 315 | 315 | |
| 316 | - if(count($listSosa) > 0) { |
|
| 316 | + if (count($listSosa) > 0) { |
|
| 317 | 317 | $this->view_bag->set('has_sosa', true); |
| 318 | - $table_id = 'table-sosa-indi-' . Uuid::uuid4(); |
|
| 318 | + $table_id = 'table-sosa-indi-'.Uuid::uuid4(); |
|
| 319 | 319 | $this->view_bag->set('table_id', $table_id); |
| 320 | 320 | |
| 321 | 321 | $controller |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
| 328 | 328 | |
| 329 | 329 | jQuery("#'.$table_id.'").dataTable( { |
| 330 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
| 331 | - ' . I18N::datatablesI18N() . ', |
|
| 330 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
| 331 | + ' . I18N::datatablesI18N().', |
|
| 332 | 332 | jQueryUI: true, |
| 333 | 333 | autoWidth: false, |
| 334 | 334 | processing: true, |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | pagingType: "full_numbers" |
| 365 | 365 | }); |
| 366 | 366 | |
| 367 | - jQuery("#' . $table_id . '") |
|
| 367 | + jQuery("#' . $table_id.'") |
|
| 368 | 368 | /* Hide/show parents */ |
| 369 | 369 | .on("click", ".btn-toggle-parents", function() { |
| 370 | 370 | jQuery(this).toggleClass("ui-state-active"); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | /* Hide/show statistics */ |
| 374 | 374 | .on("click", ".btn-toggle-statistics", function() { |
| 375 | 375 | jQuery(this).toggleClass("ui-state-active"); |
| 376 | - jQuery("#indi_list_table-charts_' . $table_id . '").slideToggle(); |
|
| 376 | + jQuery("#indi_list_table-charts_' . $table_id.'").slideToggle(); |
|
| 377 | 377 | }) |
| 378 | 378 | /* Filter buttons in table header */ |
| 379 | 379 | .on("click", "button[data-filter-column]", function() { |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | // De-activate the other buttons in this button group |
| 382 | 382 | btn.siblings().removeClass("ui-state-active"); |
| 383 | 383 | // Apply (or clear) this filter |
| 384 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
| 384 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
| 385 | 385 | if (btn.hasClass("ui-state-active")) { |
| 386 | 386 | btn.removeClass("ui-state-active"); |
| 387 | 387 | col.search("").draw(); |
@@ -416,30 +416,30 @@ discard block |
||
| 416 | 416 | $nb_displayed = 0; |
| 417 | 417 | |
| 418 | 418 | Individual::load($WT_TREE, $listSosa); |
| 419 | - foreach($listSosa as $sosa => $pid) { |
|
| 419 | + foreach ($listSosa as $sosa => $pid) { |
|
| 420 | 420 | $person = Individual::getInstance($pid, $WT_TREE); |
| 421 | 421 | if (!$person || !$person->canShowName()) { |
| 422 | 422 | unset($listSosa[$sosa]); |
| 423 | 423 | continue; |
| 424 | 424 | } |
| 425 | 425 | $nb_displayed++; |
| 426 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
| 426 | + if ($birth_dates = $person->getAllBirthDates()) { |
|
| 427 | 427 | if ( |
| 428 | 428 | FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
| 429 | 429 | !isset($unique_indis[$person->getXref()]) |
| 430 | 430 | ) { |
| 431 | - $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
| 431 | + $birt_by_decade[(int)($birth_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | else { |
| 435 | - $birth_dates[0]=new Date(''); |
|
| 435 | + $birth_dates[0] = new Date(''); |
|
| 436 | 436 | } |
| 437 | 437 | if ($death_dates = $person->getAllDeathDates()) { |
| 438 | 438 | if ( |
| 439 | 439 | FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
| 440 | 440 | !isset($unique_indis[$person->getXref()]) |
| 441 | 441 | ) { |
| 442 | - $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
| 442 | + $deat_by_decade[(int)($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | else { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $this->view_bag->set('sosa_list', $listSosa); |
| 456 | 456 | |
| 457 | 457 | $this->view_bag->set('sosa_count', count($listSosa)); |
| 458 | - $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
| 458 | + $this->view_bag->set('sosa_theo', pow(2, $this->generation - 1)); |
|
| 459 | 459 | $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
| 460 | 460 | |
| 461 | 461 | $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
@@ -475,12 +475,12 @@ discard block |
||
| 475 | 475 | protected function renderFamSosaListIndi(AjaxController $controller) { |
| 476 | 476 | global $WT_TREE; |
| 477 | 477 | |
| 478 | - $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
| 478 | + $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation); ; |
|
| 479 | 479 | $this->view_bag->set('has_sosa', false); |
| 480 | 480 | |
| 481 | - if(count($listFamSosa) > 0) { |
|
| 481 | + if (count($listFamSosa) > 0) { |
|
| 482 | 482 | $this->view_bag->set('has_sosa', true); |
| 483 | - $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
| 483 | + $table_id = 'table-sosa-fam-'.Uuid::uuid4(); |
|
| 484 | 484 | $this->view_bag->set('table_id', $table_id); |
| 485 | 485 | |
| 486 | 486 | $controller |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
| 493 | 493 | |
| 494 | 494 | jQuery("#'.$table_id.'").dataTable( { |
| 495 | - dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
| 495 | + dom: \'<"H"<"filtersH_' . $table_id.'"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
| 496 | 496 | '.I18N::datatablesI18N(array(16, 32, 64, 128, -1)).', |
| 497 | 497 | jQueryUI: true, |
| 498 | 498 | autoWidth: false, |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | pagingType: "full_numbers" |
| 530 | 530 | }); |
| 531 | 531 | |
| 532 | - jQuery("#' . $table_id . '") |
|
| 532 | + jQuery("#' . $table_id.'") |
|
| 533 | 533 | /* Hide/show parents */ |
| 534 | 534 | .on("click", ".btn-toggle-parents", function() { |
| 535 | 535 | jQuery(this).toggleClass("ui-state-active"); |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | /* Hide/show statistics */ |
| 539 | 539 | .on("click", ".btn-toggle-statistics", function() { |
| 540 | 540 | jQuery(this).toggleClass("ui-state-active"); |
| 541 | - jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle(); |
|
| 541 | + jQuery("#fam_list_table-charts_' . $table_id.'").slideToggle(); |
|
| 542 | 542 | }) |
| 543 | 543 | /* Filter buttons in table header */ |
| 544 | 544 | .on("click", "button[data-filter-column]", function() { |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | // De-activate the other buttons in this button group |
| 547 | 547 | btn.siblings().removeClass("ui-state-active"); |
| 548 | 548 | // Apply (or clear) this filter |
| 549 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
| 549 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
| 550 | 550 | if (btn.hasClass("ui-state-active")) { |
| 551 | 551 | btn.removeClass("ui-state-active"); |
| 552 | 552 | col.search("").draw(); |
@@ -566,29 +566,29 @@ discard block |
||
| 566 | 566 | |
| 567 | 567 | //-- init chart data |
| 568 | 568 | $marr_by_age = array(); |
| 569 | - for ($age=0; $age<=$max_age; $age++) { |
|
| 569 | + for ($age = 0; $age <= $max_age; $age++) { |
|
| 570 | 570 | $marr_by_age[$age] = ''; |
| 571 | 571 | } |
| 572 | 572 | $birt_by_decade = array(); |
| 573 | 573 | $marr_by_decade = array(); |
| 574 | - for ($year=1550; $year<2030; $year+=10) { |
|
| 574 | + for ($year = 1550; $year < 2030; $year += 10) { |
|
| 575 | 575 | $birt_by_decade[$year] = ''; |
| 576 | 576 | $marr_by_decade[$year] = ''; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - foreach($listFamSosa as $sosa => $fid) { |
|
| 579 | + foreach ($listFamSosa as $sosa => $fid) { |
|
| 580 | 580 | $sfamily = Family::getInstance($fid, $WT_TREE); |
| 581 | - if(!$sfamily || !$sfamily->canShow()) { |
|
| 581 | + if (!$sfamily || !$sfamily->canShow()) { |
|
| 582 | 582 | unset($sfamily[$sosa]); |
| 583 | 583 | continue; |
| 584 | 584 | } |
| 585 | - $mdate=$sfamily->getMarriageDate(); |
|
| 585 | + $mdate = $sfamily->getMarriageDate(); |
|
| 586 | 586 | |
| 587 | - if( ($husb = $sfamily->getHusband()) && |
|
| 587 | + if (($husb = $sfamily->getHusband()) && |
|
| 588 | 588 | ($hdate = $husb->getBirthDate()) && |
| 589 | 589 | $hdate->isOK() && $mdate->isOK()) { |
| 590 | 590 | if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
| 591 | - $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
| 591 | + $birt_by_decade[(int)($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
| 592 | 592 | } |
| 593 | 593 | $hage = Date::getAge($hdate, $mdate, 0); |
| 594 | 594 | if ($hage >= 0 && $hage <= $max_age) { |
@@ -596,11 +596,11 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - if(($wife = $sfamily->getWife()) && |
|
| 600 | - ($wdate=$wife->getBirthDate()) && |
|
| 599 | + if (($wife = $sfamily->getWife()) && |
|
| 600 | + ($wdate = $wife->getBirthDate()) && |
|
| 601 | 601 | $wdate->isOK() && $mdate->isOK()) { |
| 602 | 602 | if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
| 603 | - $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
| 603 | + $birt_by_decade[(int)($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
| 604 | 604 | } |
| 605 | 605 | $wage = Date::getAge($wdate, $mdate, 0); |
| 606 | 606 | if ($wage >= 0 && $wage <= $max_age) { |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
| 612 | - $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
| 612 | + $marr_by_decade[(int)($mdate->gregorianYear() / 10) * 10] .= $husb->getSex().$wife->getSex(); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | $listFamSosa[$sosa] = $sfamily; |
@@ -22,18 +22,18 @@ |
||
| 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 | } |
@@ -22,17 +22,17 @@ |
||
| 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' . |
|
| 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 | 36 | ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
| 37 | 37 | ); |
| 38 | 38 | } |
@@ -23,17 +23,17 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 117 | 117 | |
| 118 | 118 | <?php |
| 119 | 119 | } |
| 120 | - } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | \ No newline at end of file |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | <div id="maj-sosa-list-page" class="center"> |
| 29 | 29 | <h2><?php echo $this->data->get('title'); ?></h2> |
| 30 | 30 | |
| 31 | - <?php if($this->data->get('is_setup')) { |
|
| 31 | + <?php if ($this->data->get('is_setup')) { |
|
| 32 | 32 | $selectedgen = $this->data->get('generation'); |
| 33 | 33 | $this->renderSosaHeader(); |
| 34 | - if($this->data->get('has_sosa') ) { |
|
| 35 | - if($selectedgen > 0) { |
|
| 34 | + if ($this->data->get('has_sosa')) { |
|
| 35 | + if ($selectedgen > 0) { |
|
| 36 | 36 | ?> |
| 37 | 37 | <div id="sosalist-tabs"> |
| 38 | 38 | <ul> |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | ?> |
| 76 | 76 | |
| 77 | 77 | <form method="get" name="setgen" action="module.php"> |
| 78 | - <input type="hidden" name="mod" value="<?php echo $this->data->get('url_module');?>"> |
|
| 79 | - <input type="hidden" name="mod_action" value="<?php echo $this->data->get('url_action');?>"> |
|
| 80 | - <input type="hidden" name="ged" value="<?php echo $this->data->get('url_ged');?>"> |
|
| 78 | + <input type="hidden" name="mod" value="<?php echo $this->data->get('url_module'); ?>"> |
|
| 79 | + <input type="hidden" name="mod_action" value="<?php echo $this->data->get('url_action'); ?>"> |
|
| 80 | + <input type="hidden" name="ged" value="<?php echo $this->data->get('url_ged'); ?>"> |
|
| 81 | 81 | <div class="maj-table"> |
| 82 | 82 | <div class="maj-row"> |
| 83 | 83 | <div class="label"><?php echo I18N::translate('Choose generation') ?></div> |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | <div class="maj-row"> |
| 86 | 86 | <div class="value"> |
| 87 | 87 | <select name="gen"> |
| 88 | - <?php for($i=$this->data->get('min_gen'); $i <= $max_gen;$i++) {?> |
|
| 88 | + <?php for ($i = $this->data->get('min_gen'); $i <= $max_gen; $i++) {?> |
|
| 89 | 89 | <option value="<?php echo $i; ?>" |
| 90 | - <?php if($selectedgen && $selectedgen==$i) { ?> selected="true" <?php } ?> |
|
| 90 | + <?php if ($selectedgen && $selectedgen == $i) { ?> selected="true" <?php } ?> |
|
| 91 | 91 | ><?php echo I18N::translate('Generation %d', $i); ?> |
| 92 | 92 | </option> |
| 93 | 93 | <?php } ?> |
@@ -95,21 +95,21 @@ discard block |
||
| 95 | 95 | </div> |
| 96 | 96 | </div> |
| 97 | 97 | </div> |
| 98 | - <input type="submit" value="<?php echo I18N::translate('Show');?>" /> |
|
| 98 | + <input type="submit" value="<?php echo I18N::translate('Show'); ?>" /> |
|
| 99 | 99 | <br /> |
| 100 | 100 | </form> |
| 101 | - <?php if($selectedgen > 0) { ?> |
|
| 101 | + <?php if ($selectedgen > 0) { ?> |
|
| 102 | 102 | <h4> |
| 103 | - <?php if($selectedgen > $this->data->get('min_gen')) { ?> |
|
| 104 | - <a href="module.php?mod=<?php echo $this->data->get('url_module');?>&mod_action=<?php echo $this->data->get('url_action');?>&ged=<?php echo $this->data->get('url_ged');?>&gen=<?php echo $selectedgen-1; ?>"> |
|
| 103 | + <?php if ($selectedgen > $this->data->get('min_gen')) { ?> |
|
| 104 | + <a href="module.php?mod=<?php echo $this->data->get('url_module'); ?>&mod_action=<?php echo $this->data->get('url_action'); ?>&ged=<?php echo $this->data->get('url_ged'); ?>&gen=<?php echo $selectedgen - 1; ?>"> |
|
| 105 | 105 | <i class="icon-ldarrow" title="<?php echo I18N::translate('Previous generation'); ?>" ></i> |
| 106 | 106 | </a> |
| 107 | 107 | |
| 108 | 108 | <?php } ?> |
| 109 | 109 | <?php echo I18N::translate('Generation %d', $selectedgen); ?> |
| 110 | - <?php if($selectedgen < $max_gen) { ?> |
|
| 110 | + <?php if ($selectedgen < $max_gen) { ?> |
|
| 111 | 111 | |
| 112 | - <a href="module.php?mod=<?php echo $this->data->get('url_module');?>&mod_action=<?php echo $this->data->get('url_action');?>&ged=<?php echo $this->data->get('url_ged');?>&gen=<?php echo $selectedgen+1; ?>"> |
|
| 112 | + <a href="module.php?mod=<?php echo $this->data->get('url_module'); ?>&mod_action=<?php echo $this->data->get('url_action'); ?>&ged=<?php echo $this->data->get('url_ged'); ?>&gen=<?php echo $selectedgen + 1; ?>"> |
|
| 113 | 113 | <i class="icon-rdarrow" title="<?php echo I18N::translate('Next generation'); ?>" ></i> |
| 114 | 114 | </a> |
| 115 | 115 | <?php } ?> |