@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $ajax = Filter::getBool('ajax'); |
35 | 35 | |
36 | 36 | if (!$ajax) { |
37 | - $controller = new PageController; |
|
38 | - $controller |
|
39 | - ->restrictAccess(Module::isActiveChart($WT_TREE, 'statistics_chart')) |
|
40 | - ->setPageTitle(I18N::translate('Statistics')) |
|
41 | - ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) |
|
42 | - ->addInlineJavascript(' |
|
37 | + $controller = new PageController; |
|
38 | + $controller |
|
39 | + ->restrictAccess(Module::isActiveChart($WT_TREE, 'statistics_chart')) |
|
40 | + ->setPageTitle(I18N::translate('Statistics')) |
|
41 | + ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) |
|
42 | + ->addInlineJavascript(' |
|
43 | 43 | jQuery("#statistics_chart").css("visibility", "visible"); |
44 | 44 | jQuery("#statistics_chart").tabs({ |
45 | 45 | load: function() { |
@@ -60,33 +60,33 @@ discard block |
||
60 | 60 | } |
61 | 61 | }); |
62 | 62 | ') |
63 | - ->pageHeader(); |
|
63 | + ->pageHeader(); |
|
64 | 64 | |
65 | - echo '<div id="statistics-page"><h2>', I18N::translate('Statistics'), '</h2>', |
|
66 | - '<div id="statistics_chart">', |
|
67 | - '<ul>', |
|
68 | - '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=0">', |
|
69 | - '<span id="stats-indi">', I18N::translate('Individuals'), '</span></a></li>', |
|
70 | - '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=1">', |
|
71 | - '<span id="stats-fam">', I18N::translate('Families'), '</span></a></li>', |
|
72 | - '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=2">', |
|
73 | - '<span id="stats-other">', I18N::translate('Others'), '</span></a></li>', |
|
74 | - '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=3">', |
|
75 | - '<span id="stats-own">', I18N::translate('Own charts'), '</span></a></li>', |
|
76 | - '</ul>', |
|
77 | - '<div id="loading-indicator" style="margin:auto;width:100%;"></div>', |
|
78 | - '</div>', // statistics_chart |
|
79 | - '</div>', // statistics-page |
|
80 | - '<br><br>'; |
|
65 | + echo '<div id="statistics-page"><h2>', I18N::translate('Statistics'), '</h2>', |
|
66 | + '<div id="statistics_chart">', |
|
67 | + '<ul>', |
|
68 | + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=0">', |
|
69 | + '<span id="stats-indi">', I18N::translate('Individuals'), '</span></a></li>', |
|
70 | + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=1">', |
|
71 | + '<span id="stats-fam">', I18N::translate('Families'), '</span></a></li>', |
|
72 | + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=2">', |
|
73 | + '<span id="stats-other">', I18N::translate('Others'), '</span></a></li>', |
|
74 | + '<li><a href="statistics.php?ged=', $WT_TREE->getNameUrl(), '&ajax=1&tab=3">', |
|
75 | + '<span id="stats-own">', I18N::translate('Own charts'), '</span></a></li>', |
|
76 | + '</ul>', |
|
77 | + '<div id="loading-indicator" style="margin:auto;width:100%;"></div>', |
|
78 | + '</div>', // statistics_chart |
|
79 | + '</div>', // statistics-page |
|
80 | + '<br><br>'; |
|
81 | 81 | } else { |
82 | - $controller = new AjaxController; |
|
83 | - $controller |
|
84 | - ->pageHeader() |
|
85 | - ->addInlineJavascript('autocomplete();') |
|
86 | - ->addInlineJavascript('jQuery("#loading-indicator").removeClass("loading-image");'); |
|
87 | - $stats = new Stats($WT_TREE); |
|
88 | - if ($tab == 0) { |
|
89 | - echo '<fieldset> |
|
82 | + $controller = new AjaxController; |
|
83 | + $controller |
|
84 | + ->pageHeader() |
|
85 | + ->addInlineJavascript('autocomplete();') |
|
86 | + ->addInlineJavascript('jQuery("#loading-indicator").removeClass("loading-image");'); |
|
87 | + $stats = new Stats($WT_TREE); |
|
88 | + if ($tab == 0) { |
|
89 | + echo '<fieldset> |
|
90 | 90 | <legend>', I18N::translate('Total individuals: %s', $stats->totalIndividuals()), '</legend> |
91 | 91 | <table class="facts_table"> |
92 | 92 | <tr> |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | </tr> |
173 | 173 | </table> |
174 | 174 | <br>'; |
175 | - if (Auth::check()) { |
|
176 | - echo '<b>', I18N::translate('Oldest living individuals'), '</b> |
|
175 | + if (Auth::check()) { |
|
176 | + echo '<b>', I18N::translate('Oldest living individuals'), '</b> |
|
177 | 177 | <table class="facts_table"> |
178 | 178 | <tr> |
179 | 179 | <td class="facts_label">', I18N::translate('Males'), '</td> |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | </tr> |
186 | 186 | </table> |
187 | 187 | <br>'; |
188 | - } |
|
189 | - echo '<b>', I18N::translate('Names'), '</b> |
|
188 | + } |
|
189 | + echo '<b>', I18N::translate('Names'), '</b> |
|
190 | 190 | <table class="facts_table"> |
191 | 191 | <tr> |
192 | 192 | <td class="facts_label">', I18N::translate('Total surnames'), '</td> |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | </tr> |
207 | 207 | </table> |
208 | 208 | </fieldset>'; |
209 | - } elseif ($tab == 1) { |
|
210 | - echo '<fieldset> |
|
209 | + } elseif ($tab == 1) { |
|
210 | + echo '<fieldset> |
|
211 | 211 | <legend>', I18N::translate('Total families: %s', $stats->totalFamilies()), '</legend> |
212 | 212 | <b>', I18N::translate('Events'), '</b> |
213 | 213 | <table class="facts_table"> |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | </tr> |
345 | 345 | </table> |
346 | 346 | </fieldset>'; |
347 | - } elseif ($tab == 2) { |
|
348 | - echo ' |
|
347 | + } elseif ($tab == 2) { |
|
348 | + echo ' |
|
349 | 349 | <fieldset> |
350 | 350 | <legend>', I18N::translate('Records'), ': ', $stats->totalRecords(), '</legend> |
351 | 351 | <table class="facts_table"> |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | </tr> |
429 | 429 | </table> |
430 | 430 | </fieldset>'; |
431 | - } elseif ($tab == 3) { |
|
432 | - ?> |
|
431 | + } elseif ($tab == 3) { |
|
432 | + ?> |
|
433 | 433 | <script> |
434 | 434 | function statusHide(sel) { |
435 | 435 | var box = document.getElementById(sel); |
@@ -769,5 +769,5 @@ discard block |
||
769 | 769 | </div> |
770 | 770 | </fieldset> |
771 | 771 | <?php |
772 | - } |
|
772 | + } |
|
773 | 773 | } |
@@ -32,222 +32,222 @@ |
||
32 | 32 | header('Content-type: text/html; charset=UTF-8'); |
33 | 33 | |
34 | 34 | if (!Filter::checkCsrf()) { |
35 | - http_response_code(406); |
|
35 | + http_response_code(406); |
|
36 | 36 | |
37 | - return; |
|
37 | + return; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | switch (Filter::post('action')) { |
41 | 41 | case 'accept-changes': |
42 | - // Accept all the pending changes for a record |
|
43 | - $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
44 | - if ($record && Auth::isModerator($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
45 | - if ($record->isPendingDeletion()) { |
|
46 | - FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
47 | - I18N::translate('“%s” has been deleted.', $record->getFullName())); |
|
48 | - } else { |
|
49 | - FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
50 | - I18N::translate('The changes to “%s” have been accepted.', $record->getFullName())); |
|
51 | - } |
|
52 | - FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId()); |
|
53 | - } else { |
|
54 | - http_response_code(406); |
|
55 | - } |
|
56 | - break; |
|
42 | + // Accept all the pending changes for a record |
|
43 | + $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
44 | + if ($record && Auth::isModerator($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
45 | + if ($record->isPendingDeletion()) { |
|
46 | + FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
47 | + I18N::translate('“%s” has been deleted.', $record->getFullName())); |
|
48 | + } else { |
|
49 | + FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
50 | + I18N::translate('The changes to “%s” have been accepted.', $record->getFullName())); |
|
51 | + } |
|
52 | + FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId()); |
|
53 | + } else { |
|
54 | + http_response_code(406); |
|
55 | + } |
|
56 | + break; |
|
57 | 57 | |
58 | 58 | case 'copy-fact': |
59 | - // Copy a fact to the clipboard |
|
60 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
61 | - $fact_id = Filter::post('fact_id'); |
|
62 | - |
|
63 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
64 | - |
|
65 | - if ($record && $record->canEdit()) { |
|
66 | - foreach ($record->getFacts() as $fact) { |
|
67 | - if ($fact->getFactId() == $fact_id) { |
|
68 | - switch ($fact->getTag()) { |
|
69 | - case 'NOTE': |
|
70 | - case 'SOUR': |
|
71 | - case 'OBJE': |
|
72 | - $type = 'all'; // paste this anywhere |
|
73 | - break; |
|
74 | - default: |
|
75 | - $type = $record::RECORD_TYPE; // paste only to the same record type |
|
76 | - break; |
|
77 | - } |
|
78 | - $clipboard = Session::get('clipboard'); |
|
79 | - if (!is_array($clipboard)) { |
|
80 | - $clipboard = array(); |
|
81 | - } |
|
82 | - $clipboard[$fact_id] = array( |
|
83 | - 'type' => $type, |
|
84 | - 'factrec' => $fact->getGedcom(), |
|
85 | - 'fact' => $fact->getTag(), |
|
86 | - ); |
|
87 | - // The clipboard only holds 10 facts |
|
88 | - while (count($clipboard) > 10) { |
|
89 | - array_shift($clipboard); |
|
90 | - } |
|
91 | - Session::put('clipboard', $clipboard); |
|
92 | - FlashMessages::addMessage(I18N::translate('The record has been copied to the clipboard.')); |
|
93 | - break 2; |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - break; |
|
59 | + // Copy a fact to the clipboard |
|
60 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
61 | + $fact_id = Filter::post('fact_id'); |
|
62 | + |
|
63 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
64 | + |
|
65 | + if ($record && $record->canEdit()) { |
|
66 | + foreach ($record->getFacts() as $fact) { |
|
67 | + if ($fact->getFactId() == $fact_id) { |
|
68 | + switch ($fact->getTag()) { |
|
69 | + case 'NOTE': |
|
70 | + case 'SOUR': |
|
71 | + case 'OBJE': |
|
72 | + $type = 'all'; // paste this anywhere |
|
73 | + break; |
|
74 | + default: |
|
75 | + $type = $record::RECORD_TYPE; // paste only to the same record type |
|
76 | + break; |
|
77 | + } |
|
78 | + $clipboard = Session::get('clipboard'); |
|
79 | + if (!is_array($clipboard)) { |
|
80 | + $clipboard = array(); |
|
81 | + } |
|
82 | + $clipboard[$fact_id] = array( |
|
83 | + 'type' => $type, |
|
84 | + 'factrec' => $fact->getGedcom(), |
|
85 | + 'fact' => $fact->getTag(), |
|
86 | + ); |
|
87 | + // The clipboard only holds 10 facts |
|
88 | + while (count($clipboard) > 10) { |
|
89 | + array_shift($clipboard); |
|
90 | + } |
|
91 | + Session::put('clipboard', $clipboard); |
|
92 | + FlashMessages::addMessage(I18N::translate('The record has been copied to the clipboard.')); |
|
93 | + break 2; |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + break; |
|
98 | 98 | |
99 | 99 | case 'paste-fact': |
100 | - // Paste a fact from the clipboard |
|
101 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
102 | - $fact_id = Filter::post('fact_id'); |
|
103 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
104 | - $clipboard = Session::get('clipboard'); |
|
100 | + // Paste a fact from the clipboard |
|
101 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
102 | + $fact_id = Filter::post('fact_id'); |
|
103 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
104 | + $clipboard = Session::get('clipboard'); |
|
105 | 105 | |
106 | - if ($record && $record->canEdit() && isset($clipboard[$fact_id])) { |
|
107 | - $record->createFact($clipboard[$fact_id]['factrec'], true); |
|
108 | - } |
|
109 | - break; |
|
106 | + if ($record && $record->canEdit() && isset($clipboard[$fact_id])) { |
|
107 | + $record->createFact($clipboard[$fact_id]['factrec'], true); |
|
108 | + } |
|
109 | + break; |
|
110 | 110 | |
111 | 111 | case 'delete-fact': |
112 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
113 | - $fact_id = Filter::post('fact_id'); |
|
114 | - |
|
115 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
116 | - if ($record && $record->canShow() && $record->canEdit()) { |
|
117 | - foreach ($record->getFacts() as $fact) { |
|
118 | - if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) { |
|
119 | - $record->deleteFact($fact_id, true); |
|
120 | - break 2; |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - // Can’t find the record/fact, or don’t have permission to delete it. |
|
126 | - http_response_code(406); |
|
127 | - break; |
|
112 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
113 | + $fact_id = Filter::post('fact_id'); |
|
114 | + |
|
115 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
116 | + if ($record && $record->canShow() && $record->canEdit()) { |
|
117 | + foreach ($record->getFacts() as $fact) { |
|
118 | + if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) { |
|
119 | + $record->deleteFact($fact_id, true); |
|
120 | + break 2; |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + // Can’t find the record/fact, or don’t have permission to delete it. |
|
126 | + http_response_code(406); |
|
127 | + break; |
|
128 | 128 | |
129 | 129 | case 'delete-record': |
130 | - $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
131 | - if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
132 | - // Delete links to this record |
|
133 | - foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) { |
|
134 | - $linker = GedcomRecord::getInstance($xref, $WT_TREE); |
|
135 | - $old_gedcom = $linker->getGedcom(); |
|
136 | - $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref()); |
|
137 | - // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the |
|
138 | - // record itself) may have already been deleted. |
|
139 | - if ($old_gedcom !== $new_gedcom) { |
|
140 | - // If we have removed a link from a family to an individual, and it has only one member |
|
141 | - if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) { |
|
142 | - // Delete the family |
|
143 | - $family = GedcomRecord::getInstance($xref, $WT_TREE); |
|
144 | - FlashMessages::addMessage(/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */ I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName())); |
|
145 | - $family->deleteRecord(); |
|
146 | - // Delete any remaining link to this family |
|
147 | - if ($match) { |
|
148 | - $relict = GedcomRecord::getInstance($match[2][0], $WT_TREE); |
|
149 | - $new_gedcom = $relict->getGedcom(); |
|
150 | - $new_gedcom = FunctionsEdit::removeLinks($new_gedcom, $linker->getXref()); |
|
151 | - $relict->updateRecord($new_gedcom, false); |
|
152 | - FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $relict->getFullName(), $family->getFullName())); |
|
153 | - } |
|
154 | - } else { |
|
155 | - // Remove links from $linker to $record |
|
156 | - FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $linker->getFullName(), $record->getFullName())); |
|
157 | - $linker->updateRecord($new_gedcom, false); |
|
158 | - } |
|
159 | - } |
|
160 | - } |
|
161 | - // Delete the record itself |
|
162 | - $record->deleteRecord(); |
|
163 | - } else { |
|
164 | - http_response_code(406); |
|
165 | - } |
|
166 | - break; |
|
130 | + $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
131 | + if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
132 | + // Delete links to this record |
|
133 | + foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) { |
|
134 | + $linker = GedcomRecord::getInstance($xref, $WT_TREE); |
|
135 | + $old_gedcom = $linker->getGedcom(); |
|
136 | + $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref()); |
|
137 | + // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the |
|
138 | + // record itself) may have already been deleted. |
|
139 | + if ($old_gedcom !== $new_gedcom) { |
|
140 | + // If we have removed a link from a family to an individual, and it has only one member |
|
141 | + if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) { |
|
142 | + // Delete the family |
|
143 | + $family = GedcomRecord::getInstance($xref, $WT_TREE); |
|
144 | + FlashMessages::addMessage(/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */ I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName())); |
|
145 | + $family->deleteRecord(); |
|
146 | + // Delete any remaining link to this family |
|
147 | + if ($match) { |
|
148 | + $relict = GedcomRecord::getInstance($match[2][0], $WT_TREE); |
|
149 | + $new_gedcom = $relict->getGedcom(); |
|
150 | + $new_gedcom = FunctionsEdit::removeLinks($new_gedcom, $linker->getXref()); |
|
151 | + $relict->updateRecord($new_gedcom, false); |
|
152 | + FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $relict->getFullName(), $family->getFullName())); |
|
153 | + } |
|
154 | + } else { |
|
155 | + // Remove links from $linker to $record |
|
156 | + FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $linker->getFullName(), $record->getFullName())); |
|
157 | + $linker->updateRecord($new_gedcom, false); |
|
158 | + } |
|
159 | + } |
|
160 | + } |
|
161 | + // Delete the record itself |
|
162 | + $record->deleteRecord(); |
|
163 | + } else { |
|
164 | + http_response_code(406); |
|
165 | + } |
|
166 | + break; |
|
167 | 167 | |
168 | 168 | case 'delete-user': |
169 | - $user = User::find(Filter::postInteger('user_id')); |
|
169 | + $user = User::find(Filter::postInteger('user_id')); |
|
170 | 170 | |
171 | - if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
172 | - Log::addAuthenticationLog('Deleted user: ' . $user->getUserName()); |
|
173 | - $user->delete(); |
|
174 | - } |
|
175 | - break; |
|
171 | + if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
172 | + Log::addAuthenticationLog('Deleted user: ' . $user->getUserName()); |
|
173 | + $user->delete(); |
|
174 | + } |
|
175 | + break; |
|
176 | 176 | |
177 | 177 | case 'language': |
178 | - // Change the current language |
|
179 | - $language = Filter::post('language'); |
|
180 | - try { |
|
181 | - I18N::init($language); |
|
182 | - Session::put('locale', $language); |
|
183 | - // Remember our selection |
|
184 | - Auth::user()->setPreference('language', $language); |
|
185 | - } catch (\Exception $ex) { |
|
186 | - // Request for a non-existant language. |
|
187 | - http_response_code(406); |
|
188 | - } |
|
189 | - break; |
|
178 | + // Change the current language |
|
179 | + $language = Filter::post('language'); |
|
180 | + try { |
|
181 | + I18N::init($language); |
|
182 | + Session::put('locale', $language); |
|
183 | + // Remember our selection |
|
184 | + Auth::user()->setPreference('language', $language); |
|
185 | + } catch (\Exception $ex) { |
|
186 | + // Request for a non-existant language. |
|
187 | + http_response_code(406); |
|
188 | + } |
|
189 | + break; |
|
190 | 190 | |
191 | 191 | case 'masquerade': |
192 | - $user = User::find(Filter::postInteger('user_id')); |
|
192 | + $user = User::find(Filter::postInteger('user_id')); |
|
193 | 193 | |
194 | - if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
195 | - Log::addAuthenticationLog('Masquerade as user: ' . $user->getUserName()); |
|
196 | - Auth::login($user); |
|
197 | - Session::put('masquerade', '1'); |
|
198 | - } else { |
|
199 | - http_response_code(406); |
|
200 | - } |
|
201 | - break; |
|
194 | + if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
195 | + Log::addAuthenticationLog('Masquerade as user: ' . $user->getUserName()); |
|
196 | + Auth::login($user); |
|
197 | + Session::put('masquerade', '1'); |
|
198 | + } else { |
|
199 | + http_response_code(406); |
|
200 | + } |
|
201 | + break; |
|
202 | 202 | |
203 | 203 | case 'unlink-media': |
204 | - // Remove links from an individual and their spouse-family records to a media object. |
|
205 | - // Used by the "unlink" option on the album (lightbox) tab. |
|
206 | - $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE); |
|
207 | - $target = Filter::post('target', WT_REGEX_XREF); |
|
208 | - if ($source && $source->canShow() && $source->canEdit() && $target) { |
|
209 | - // Consider the individual and their spouse-family records |
|
210 | - $sources = $source->getSpouseFamilies(); |
|
211 | - $sources[] = $source; |
|
212 | - foreach ($sources as $source) { |
|
213 | - foreach ($source->getFacts() as $fact) { |
|
214 | - if (!$fact->isPendingDeletion()) { |
|
215 | - if ($fact->getValue() == '@' . $target . '@') { |
|
216 | - // Level 1 links |
|
217 | - $source->deleteFact($fact->getFactId(), true); |
|
218 | - } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) { |
|
219 | - // Level 2-3 links |
|
220 | - $source->updateFact($fact->getFactId(), preg_replace(array('/\n2 OBJE @' . $target . '@(\n[3-9].*)*/', '/\n3 OBJE @' . $target . '@(\n[4-9].*)*/'), '', $fact->getGedcom()), true); |
|
221 | - } |
|
222 | - } |
|
223 | - } |
|
224 | - } |
|
225 | - } else { |
|
226 | - http_response_code(406); |
|
227 | - } |
|
228 | - break; |
|
204 | + // Remove links from an individual and their spouse-family records to a media object. |
|
205 | + // Used by the "unlink" option on the album (lightbox) tab. |
|
206 | + $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE); |
|
207 | + $target = Filter::post('target', WT_REGEX_XREF); |
|
208 | + if ($source && $source->canShow() && $source->canEdit() && $target) { |
|
209 | + // Consider the individual and their spouse-family records |
|
210 | + $sources = $source->getSpouseFamilies(); |
|
211 | + $sources[] = $source; |
|
212 | + foreach ($sources as $source) { |
|
213 | + foreach ($source->getFacts() as $fact) { |
|
214 | + if (!$fact->isPendingDeletion()) { |
|
215 | + if ($fact->getValue() == '@' . $target . '@') { |
|
216 | + // Level 1 links |
|
217 | + $source->deleteFact($fact->getFactId(), true); |
|
218 | + } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) { |
|
219 | + // Level 2-3 links |
|
220 | + $source->updateFact($fact->getFactId(), preg_replace(array('/\n2 OBJE @' . $target . '@(\n[3-9].*)*/', '/\n3 OBJE @' . $target . '@(\n[4-9].*)*/'), '', $fact->getGedcom()), true); |
|
221 | + } |
|
222 | + } |
|
223 | + } |
|
224 | + } |
|
225 | + } else { |
|
226 | + http_response_code(406); |
|
227 | + } |
|
228 | + break; |
|
229 | 229 | |
230 | 230 | case 'reject-changes': |
231 | - // Reject all the pending changes for a record |
|
232 | - $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
233 | - if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) { |
|
234 | - FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been rejected.', $record->getFullName())); |
|
235 | - FunctionsImport::rejectAllChanges($record); |
|
236 | - } else { |
|
237 | - http_response_code(406); |
|
238 | - } |
|
239 | - break; |
|
231 | + // Reject all the pending changes for a record |
|
232 | + $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
233 | + if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) { |
|
234 | + FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been rejected.', $record->getFullName())); |
|
235 | + FunctionsImport::rejectAllChanges($record); |
|
236 | + } else { |
|
237 | + http_response_code(406); |
|
238 | + } |
|
239 | + break; |
|
240 | 240 | |
241 | 241 | case 'theme': |
242 | - // Change the current theme |
|
243 | - $theme = Filter::post('theme'); |
|
244 | - if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) { |
|
245 | - Session::put('theme_id', $theme); |
|
246 | - // Remember our selection |
|
247 | - Auth::user()->setPreference('theme', $theme); |
|
248 | - } else { |
|
249 | - // Request for a non-existant theme. |
|
250 | - http_response_code(406); |
|
251 | - } |
|
252 | - break; |
|
242 | + // Change the current theme |
|
243 | + $theme = Filter::post('theme'); |
|
244 | + if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) { |
|
245 | + Session::put('theme_id', $theme); |
|
246 | + // Remember our selection |
|
247 | + Auth::user()->setPreference('theme', $theme); |
|
248 | + } else { |
|
249 | + // Request for a non-existant theme. |
|
250 | + http_response_code(406); |
|
251 | + } |
|
252 | + break; |
|
253 | 253 | } |
@@ -66,14 +66,14 @@ |
||
66 | 66 | foreach ($record->getFacts() as $fact) { |
67 | 67 | if ($fact->getFactId() == $fact_id) { |
68 | 68 | switch ($fact->getTag()) { |
69 | - case 'NOTE': |
|
70 | - case 'SOUR': |
|
71 | - case 'OBJE': |
|
72 | - $type = 'all'; // paste this anywhere |
|
73 | - break; |
|
74 | - default: |
|
75 | - $type = $record::RECORD_TYPE; // paste only to the same record type |
|
76 | - break; |
|
69 | + case 'NOTE': |
|
70 | + case 'SOUR': |
|
71 | + case 'OBJE': |
|
72 | + $type = 'all'; // paste this anywhere |
|
73 | + break; |
|
74 | + default: |
|
75 | + $type = $record::RECORD_TYPE; // paste only to the same record type |
|
76 | + break; |
|
77 | 77 | } |
78 | 78 | $clipboard = Session::get('clipboard'); |
79 | 79 | if (!is_array($clipboard)) { |
@@ -37,50 +37,50 @@ discard block |
||
37 | 37 | * @return int |
38 | 38 | */ |
39 | 39 | function month_of_birth($z_axis, array $z_boundaries, Stats $stats) { |
40 | - $total = 0; |
|
40 | + $total = 0; |
|
41 | 41 | |
42 | - if ($z_axis === 300) { |
|
43 | - $num = $stats->statsBirthQuery(false); |
|
44 | - foreach ($num as $values) { |
|
45 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
46 | - if ($month === $values['d_month']) { |
|
47 | - fill_y_data(0, $key, $values['total']); |
|
48 | - $total += $values['total']; |
|
49 | - } |
|
50 | - } |
|
51 | - } |
|
52 | - } elseif ($z_axis === 301) { |
|
53 | - $num = $stats->statsBirthQuery(false, true); |
|
54 | - foreach ($num as $values) { |
|
55 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
56 | - if ($month === $values['d_month']) { |
|
57 | - if ($values['i_sex'] === 'M') { |
|
58 | - fill_y_data(0, $key, $values['total']); |
|
59 | - $total += $values['total']; |
|
60 | - } elseif ($values['i_sex'] === 'F') { |
|
61 | - fill_y_data(1, $key, $values['total']); |
|
62 | - $total += $values['total']; |
|
63 | - } |
|
64 | - } |
|
65 | - } |
|
66 | - } |
|
67 | - } else { |
|
68 | - $zstart = 0; |
|
69 | - foreach ($z_boundaries as $boundary) { |
|
70 | - $num = $stats->statsBirthQuery(false, false, $zstart, $boundary); |
|
71 | - foreach ($num as $values) { |
|
72 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
73 | - if ($month === $values['d_month']) { |
|
74 | - fill_y_data($boundary, $key, $values['total']); |
|
75 | - $total += $values['total']; |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
79 | - $zstart = $boundary + 1; |
|
80 | - } |
|
81 | - } |
|
42 | + if ($z_axis === 300) { |
|
43 | + $num = $stats->statsBirthQuery(false); |
|
44 | + foreach ($num as $values) { |
|
45 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
46 | + if ($month === $values['d_month']) { |
|
47 | + fill_y_data(0, $key, $values['total']); |
|
48 | + $total += $values['total']; |
|
49 | + } |
|
50 | + } |
|
51 | + } |
|
52 | + } elseif ($z_axis === 301) { |
|
53 | + $num = $stats->statsBirthQuery(false, true); |
|
54 | + foreach ($num as $values) { |
|
55 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
56 | + if ($month === $values['d_month']) { |
|
57 | + if ($values['i_sex'] === 'M') { |
|
58 | + fill_y_data(0, $key, $values['total']); |
|
59 | + $total += $values['total']; |
|
60 | + } elseif ($values['i_sex'] === 'F') { |
|
61 | + fill_y_data(1, $key, $values['total']); |
|
62 | + $total += $values['total']; |
|
63 | + } |
|
64 | + } |
|
65 | + } |
|
66 | + } |
|
67 | + } else { |
|
68 | + $zstart = 0; |
|
69 | + foreach ($z_boundaries as $boundary) { |
|
70 | + $num = $stats->statsBirthQuery(false, false, $zstart, $boundary); |
|
71 | + foreach ($num as $values) { |
|
72 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
73 | + if ($month === $values['d_month']) { |
|
74 | + fill_y_data($boundary, $key, $values['total']); |
|
75 | + $total += $values['total']; |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | + $zstart = $boundary + 1; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - return $total; |
|
83 | + return $total; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -93,50 +93,50 @@ discard block |
||
93 | 93 | * @return int |
94 | 94 | */ |
95 | 95 | function month_of_birth_of_first_child($z_axis, array $z_boundaries, Stats $stats) { |
96 | - $total = 0; |
|
96 | + $total = 0; |
|
97 | 97 | |
98 | - if ($z_axis === 300) { |
|
99 | - $num = $stats->monthFirstChildQuery(false); |
|
100 | - foreach ($num as $values) { |
|
101 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
102 | - if ($month === $values['d_month']) { |
|
103 | - fill_y_data(0, $key, $values['total']); |
|
104 | - $total += $values['total']; |
|
105 | - } |
|
106 | - } |
|
107 | - } |
|
108 | - } elseif ($z_axis === 301) { |
|
109 | - $num = $stats->monthFirstChildQuery(false, true); |
|
110 | - foreach ($num as $values) { |
|
111 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
112 | - if ($month === $values['d_month']) { |
|
113 | - if ($values['i_sex'] === 'M') { |
|
114 | - fill_y_data(0, $key, $values['total']); |
|
115 | - $total += $values['total']; |
|
116 | - } elseif ($values['i_sex'] === 'F') { |
|
117 | - fill_y_data(1, $key, $values['total']); |
|
118 | - $total += $values['total']; |
|
119 | - } |
|
120 | - } |
|
121 | - } |
|
122 | - } |
|
123 | - } else { |
|
124 | - $zstart = 0; |
|
125 | - foreach ($z_boundaries as $boundary) { |
|
126 | - $num = $stats->monthFirstChildQuery(false, false, $zstart, $boundary); |
|
127 | - foreach ($num as $values) { |
|
128 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
129 | - if ($month === $values['d_month']) { |
|
130 | - fill_y_data($boundary, $key, $values['total']); |
|
131 | - $total += $values['total']; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - $zstart = $boundary + 1; |
|
136 | - } |
|
137 | - } |
|
98 | + if ($z_axis === 300) { |
|
99 | + $num = $stats->monthFirstChildQuery(false); |
|
100 | + foreach ($num as $values) { |
|
101 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
102 | + if ($month === $values['d_month']) { |
|
103 | + fill_y_data(0, $key, $values['total']); |
|
104 | + $total += $values['total']; |
|
105 | + } |
|
106 | + } |
|
107 | + } |
|
108 | + } elseif ($z_axis === 301) { |
|
109 | + $num = $stats->monthFirstChildQuery(false, true); |
|
110 | + foreach ($num as $values) { |
|
111 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
112 | + if ($month === $values['d_month']) { |
|
113 | + if ($values['i_sex'] === 'M') { |
|
114 | + fill_y_data(0, $key, $values['total']); |
|
115 | + $total += $values['total']; |
|
116 | + } elseif ($values['i_sex'] === 'F') { |
|
117 | + fill_y_data(1, $key, $values['total']); |
|
118 | + $total += $values['total']; |
|
119 | + } |
|
120 | + } |
|
121 | + } |
|
122 | + } |
|
123 | + } else { |
|
124 | + $zstart = 0; |
|
125 | + foreach ($z_boundaries as $boundary) { |
|
126 | + $num = $stats->monthFirstChildQuery(false, false, $zstart, $boundary); |
|
127 | + foreach ($num as $values) { |
|
128 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
129 | + if ($month === $values['d_month']) { |
|
130 | + fill_y_data($boundary, $key, $values['total']); |
|
131 | + $total += $values['total']; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + $zstart = $boundary + 1; |
|
136 | + } |
|
137 | + } |
|
138 | 138 | |
139 | - return $total; |
|
139 | + return $total; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -149,50 +149,50 @@ discard block |
||
149 | 149 | * @return int |
150 | 150 | */ |
151 | 151 | function month_of_death($z_axis, array $z_boundaries, Stats $stats) { |
152 | - $total = 0; |
|
152 | + $total = 0; |
|
153 | 153 | |
154 | - if ($z_axis === 300) { |
|
155 | - $num = $stats->statsDeathQuery(false); |
|
156 | - foreach ($num as $values) { |
|
157 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
158 | - if ($month === $values['d_month']) { |
|
159 | - fill_y_data(0, $key, $values['total']); |
|
160 | - $total += $values['total']; |
|
161 | - } |
|
162 | - } |
|
163 | - } |
|
164 | - } elseif ($z_axis === 301) { |
|
165 | - $num = $stats->statsDeathQuery(false, true); |
|
166 | - foreach ($num as $values) { |
|
167 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
168 | - if ($month === $values['d_month']) { |
|
169 | - if ($values['i_sex'] === 'M') { |
|
170 | - fill_y_data(0, $key, $values['total']); |
|
171 | - $total += $values['total']; |
|
172 | - } elseif ($values['i_sex'] === 'F') { |
|
173 | - fill_y_data(1, $key, $values['total']); |
|
174 | - $total += $values['total']; |
|
175 | - } |
|
176 | - } |
|
177 | - } |
|
178 | - } |
|
179 | - } else { |
|
180 | - $zstart = 0; |
|
181 | - foreach ($z_boundaries as $boundary) { |
|
182 | - $num = $stats->statsDeathQuery(false, false, $zstart, $boundary); |
|
183 | - foreach ($num as $values) { |
|
184 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
185 | - if ($month === $values['d_month']) { |
|
186 | - fill_y_data($boundary, $key, $values['total']); |
|
187 | - $total += $values['total']; |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
191 | - $zstart = $boundary + 1; |
|
192 | - } |
|
193 | - } |
|
154 | + if ($z_axis === 300) { |
|
155 | + $num = $stats->statsDeathQuery(false); |
|
156 | + foreach ($num as $values) { |
|
157 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
158 | + if ($month === $values['d_month']) { |
|
159 | + fill_y_data(0, $key, $values['total']); |
|
160 | + $total += $values['total']; |
|
161 | + } |
|
162 | + } |
|
163 | + } |
|
164 | + } elseif ($z_axis === 301) { |
|
165 | + $num = $stats->statsDeathQuery(false, true); |
|
166 | + foreach ($num as $values) { |
|
167 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
168 | + if ($month === $values['d_month']) { |
|
169 | + if ($values['i_sex'] === 'M') { |
|
170 | + fill_y_data(0, $key, $values['total']); |
|
171 | + $total += $values['total']; |
|
172 | + } elseif ($values['i_sex'] === 'F') { |
|
173 | + fill_y_data(1, $key, $values['total']); |
|
174 | + $total += $values['total']; |
|
175 | + } |
|
176 | + } |
|
177 | + } |
|
178 | + } |
|
179 | + } else { |
|
180 | + $zstart = 0; |
|
181 | + foreach ($z_boundaries as $boundary) { |
|
182 | + $num = $stats->statsDeathQuery(false, false, $zstart, $boundary); |
|
183 | + foreach ($num as $values) { |
|
184 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
185 | + if ($month === $values['d_month']) { |
|
186 | + fill_y_data($boundary, $key, $values['total']); |
|
187 | + $total += $values['total']; |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | + $zstart = $boundary + 1; |
|
192 | + } |
|
193 | + } |
|
194 | 194 | |
195 | - return $total; |
|
195 | + return $total; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -205,35 +205,35 @@ discard block |
||
205 | 205 | * @return int |
206 | 206 | */ |
207 | 207 | function month_of_marriage($z_axis, array $z_boundaries, Stats $stats) { |
208 | - $total = 0; |
|
208 | + $total = 0; |
|
209 | 209 | |
210 | - if ($z_axis === 300) { |
|
211 | - $num = $stats->statsMarrQuery(false, false); |
|
212 | - foreach ($num as $values) { |
|
213 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
214 | - if ($month === $values['d_month']) { |
|
215 | - fill_y_data(0, $key, $values['total']); |
|
216 | - $total += $values['total']; |
|
217 | - } |
|
218 | - } |
|
219 | - } |
|
220 | - } else { |
|
221 | - $zstart = 0; |
|
222 | - foreach ($z_boundaries as $boundary) { |
|
223 | - $num = $stats->statsMarrQuery(false, false, $zstart, $boundary); |
|
224 | - foreach ($num as $values) { |
|
225 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
226 | - if ($month === $values['d_month']) { |
|
227 | - fill_y_data($boundary, $key, $values['total']); |
|
228 | - $total += $values['total']; |
|
229 | - } |
|
230 | - } |
|
231 | - } |
|
232 | - $zstart = $boundary + 1; |
|
233 | - } |
|
234 | - } |
|
210 | + if ($z_axis === 300) { |
|
211 | + $num = $stats->statsMarrQuery(false, false); |
|
212 | + foreach ($num as $values) { |
|
213 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
214 | + if ($month === $values['d_month']) { |
|
215 | + fill_y_data(0, $key, $values['total']); |
|
216 | + $total += $values['total']; |
|
217 | + } |
|
218 | + } |
|
219 | + } |
|
220 | + } else { |
|
221 | + $zstart = 0; |
|
222 | + foreach ($z_boundaries as $boundary) { |
|
223 | + $num = $stats->statsMarrQuery(false, false, $zstart, $boundary); |
|
224 | + foreach ($num as $values) { |
|
225 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
226 | + if ($month === $values['d_month']) { |
|
227 | + fill_y_data($boundary, $key, $values['total']); |
|
228 | + $total += $values['total']; |
|
229 | + } |
|
230 | + } |
|
231 | + } |
|
232 | + $zstart = $boundary + 1; |
|
233 | + } |
|
234 | + } |
|
235 | 235 | |
236 | - return $total; |
|
236 | + return $total; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -246,47 +246,47 @@ discard block |
||
246 | 246 | * @return int |
247 | 247 | */ |
248 | 248 | function month_of_first_marriage($z_axis, array $z_boundaries, Stats $stats) { |
249 | - $total = 0; |
|
249 | + $total = 0; |
|
250 | 250 | |
251 | - if ($z_axis === 300) { |
|
252 | - $num = $stats->statsMarrQuery(false, true); |
|
253 | - $indi = array(); |
|
254 | - $fam = array(); |
|
255 | - foreach ($num as $values) { |
|
256 | - if (!in_array($values['indi'], $indi) && !in_array($values['fams'], $fam)) { |
|
257 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
258 | - if ($month === $values['month']) { |
|
259 | - fill_y_data(0, $key, 1); |
|
260 | - $total++; |
|
261 | - } |
|
262 | - } |
|
263 | - $indi[] = $values['indi']; |
|
264 | - $fam[] = $values['fams']; |
|
265 | - } |
|
266 | - } |
|
267 | - } else { |
|
268 | - $zstart = 0; |
|
269 | - $indi = array(); |
|
270 | - $fam = array(); |
|
271 | - foreach ($z_boundaries as $boundary) { |
|
272 | - $num = $stats->statsMarrQuery(false, true, $zstart, $boundary); |
|
273 | - foreach ($num as $values) { |
|
274 | - if (!in_array($values['indi'], $indi) && !in_array($values['fams'], $fam)) { |
|
275 | - foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
276 | - if ($month === $values['month']) { |
|
277 | - fill_y_data($boundary, $key, 1); |
|
278 | - $total++; |
|
279 | - } |
|
280 | - } |
|
281 | - $indi[] = $values['indi']; |
|
282 | - $fam[] = $values['fams']; |
|
283 | - } |
|
284 | - } |
|
285 | - $zstart = $boundary + 1; |
|
286 | - } |
|
287 | - } |
|
251 | + if ($z_axis === 300) { |
|
252 | + $num = $stats->statsMarrQuery(false, true); |
|
253 | + $indi = array(); |
|
254 | + $fam = array(); |
|
255 | + foreach ($num as $values) { |
|
256 | + if (!in_array($values['indi'], $indi) && !in_array($values['fams'], $fam)) { |
|
257 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
258 | + if ($month === $values['month']) { |
|
259 | + fill_y_data(0, $key, 1); |
|
260 | + $total++; |
|
261 | + } |
|
262 | + } |
|
263 | + $indi[] = $values['indi']; |
|
264 | + $fam[] = $values['fams']; |
|
265 | + } |
|
266 | + } |
|
267 | + } else { |
|
268 | + $zstart = 0; |
|
269 | + $indi = array(); |
|
270 | + $fam = array(); |
|
271 | + foreach ($z_boundaries as $boundary) { |
|
272 | + $num = $stats->statsMarrQuery(false, true, $zstart, $boundary); |
|
273 | + foreach ($num as $values) { |
|
274 | + if (!in_array($values['indi'], $indi) && !in_array($values['fams'], $fam)) { |
|
275 | + foreach (array('JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') as $key => $month) { |
|
276 | + if ($month === $values['month']) { |
|
277 | + fill_y_data($boundary, $key, 1); |
|
278 | + $total++; |
|
279 | + } |
|
280 | + } |
|
281 | + $indi[] = $values['indi']; |
|
282 | + $fam[] = $values['fams']; |
|
283 | + } |
|
284 | + } |
|
285 | + $zstart = $boundary + 1; |
|
286 | + } |
|
287 | + } |
|
288 | 288 | |
289 | - return $total; |
|
289 | + return $total; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -299,46 +299,46 @@ discard block |
||
299 | 299 | * @return int |
300 | 300 | */ |
301 | 301 | function lifespan_by_birth_year($z_axis, array $z_boundaries, Stats $stats) { |
302 | - $total = 0; |
|
302 | + $total = 0; |
|
303 | 303 | |
304 | - if ($z_axis === 300) { |
|
305 | - $num = $stats->statsAgeQuery(false, 'BIRT'); |
|
306 | - foreach ($num as $values) { |
|
307 | - foreach ($values as $age_value) { |
|
308 | - fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
309 | - $total++; |
|
310 | - } |
|
311 | - } |
|
312 | - } elseif ($z_axis === 301) { |
|
313 | - $num = $stats->statsAgeQuery(false, 'BIRT', 'M'); |
|
314 | - foreach ($num as $values) { |
|
315 | - foreach ($values as $age_value) { |
|
316 | - fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
317 | - $total++; |
|
318 | - } |
|
319 | - } |
|
320 | - $num = $stats->statsAgeQuery(false, 'BIRT', 'F'); |
|
321 | - foreach ($num as $values) { |
|
322 | - foreach ($values as $age_value) { |
|
323 | - fill_y_data(1, (int) ($age_value / 365.25), 1); |
|
324 | - $total++; |
|
325 | - } |
|
326 | - } |
|
327 | - } else { |
|
328 | - $zstart = 0; |
|
329 | - foreach ($z_boundaries as $boundary) { |
|
330 | - $num = $stats->statsAgeQuery(false, 'BIRT', 'BOTH', $zstart, $boundary); |
|
331 | - foreach ($num as $values) { |
|
332 | - foreach ($values as $age_value) { |
|
333 | - fill_y_data($boundary, (int) ($age_value / 365.25), 1); |
|
334 | - $total++; |
|
335 | - } |
|
336 | - } |
|
337 | - $zstart = $boundary + 1; |
|
338 | - } |
|
339 | - } |
|
304 | + if ($z_axis === 300) { |
|
305 | + $num = $stats->statsAgeQuery(false, 'BIRT'); |
|
306 | + foreach ($num as $values) { |
|
307 | + foreach ($values as $age_value) { |
|
308 | + fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
309 | + $total++; |
|
310 | + } |
|
311 | + } |
|
312 | + } elseif ($z_axis === 301) { |
|
313 | + $num = $stats->statsAgeQuery(false, 'BIRT', 'M'); |
|
314 | + foreach ($num as $values) { |
|
315 | + foreach ($values as $age_value) { |
|
316 | + fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
317 | + $total++; |
|
318 | + } |
|
319 | + } |
|
320 | + $num = $stats->statsAgeQuery(false, 'BIRT', 'F'); |
|
321 | + foreach ($num as $values) { |
|
322 | + foreach ($values as $age_value) { |
|
323 | + fill_y_data(1, (int) ($age_value / 365.25), 1); |
|
324 | + $total++; |
|
325 | + } |
|
326 | + } |
|
327 | + } else { |
|
328 | + $zstart = 0; |
|
329 | + foreach ($z_boundaries as $boundary) { |
|
330 | + $num = $stats->statsAgeQuery(false, 'BIRT', 'BOTH', $zstart, $boundary); |
|
331 | + foreach ($num as $values) { |
|
332 | + foreach ($values as $age_value) { |
|
333 | + fill_y_data($boundary, (int) ($age_value / 365.25), 1); |
|
334 | + $total++; |
|
335 | + } |
|
336 | + } |
|
337 | + $zstart = $boundary + 1; |
|
338 | + } |
|
339 | + } |
|
340 | 340 | |
341 | - return $total; |
|
341 | + return $total; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -351,46 +351,46 @@ discard block |
||
351 | 351 | * @return int |
352 | 352 | */ |
353 | 353 | function lifespan_by_death_year($z_axis, array $z_boundaries, Stats $stats) { |
354 | - $total = 0; |
|
354 | + $total = 0; |
|
355 | 355 | |
356 | - if ($z_axis === 300) { |
|
357 | - $num = $stats->statsAgeQuery(false, 'DEAT'); |
|
358 | - foreach ($num as $values) { |
|
359 | - foreach ($values as $age_value) { |
|
360 | - fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
361 | - $total++; |
|
362 | - } |
|
363 | - } |
|
364 | - } elseif ($z_axis === 301) { |
|
365 | - $num = $stats->statsAgeQuery(false, 'DEAT', 'M'); |
|
366 | - foreach ($num as $values) { |
|
367 | - foreach ($values as $age_value) { |
|
368 | - fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
369 | - $total++; |
|
370 | - } |
|
371 | - } |
|
372 | - $num = $stats->statsAgeQuery(false, 'DEAT', 'F'); |
|
373 | - foreach ($num as $values) { |
|
374 | - foreach ($values as $age_value) { |
|
375 | - fill_y_data(1, (int) ($age_value / 365.25), 1); |
|
376 | - $total++; |
|
377 | - } |
|
378 | - } |
|
379 | - } else { |
|
380 | - $zstart = 0; |
|
381 | - foreach ($z_boundaries as $boundary) { |
|
382 | - $num = $stats->statsAgeQuery(false, 'DEAT', 'BOTH', $zstart, $boundary); |
|
383 | - foreach ($num as $values) { |
|
384 | - foreach ($values as $age_value) { |
|
385 | - fill_y_data($boundary, (int) ($age_value / 365.25), 1); |
|
386 | - $total++; |
|
387 | - } |
|
388 | - } |
|
389 | - $zstart = $boundary + 1; |
|
390 | - } |
|
391 | - } |
|
356 | + if ($z_axis === 300) { |
|
357 | + $num = $stats->statsAgeQuery(false, 'DEAT'); |
|
358 | + foreach ($num as $values) { |
|
359 | + foreach ($values as $age_value) { |
|
360 | + fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
361 | + $total++; |
|
362 | + } |
|
363 | + } |
|
364 | + } elseif ($z_axis === 301) { |
|
365 | + $num = $stats->statsAgeQuery(false, 'DEAT', 'M'); |
|
366 | + foreach ($num as $values) { |
|
367 | + foreach ($values as $age_value) { |
|
368 | + fill_y_data(0, (int) ($age_value / 365.25), 1); |
|
369 | + $total++; |
|
370 | + } |
|
371 | + } |
|
372 | + $num = $stats->statsAgeQuery(false, 'DEAT', 'F'); |
|
373 | + foreach ($num as $values) { |
|
374 | + foreach ($values as $age_value) { |
|
375 | + fill_y_data(1, (int) ($age_value / 365.25), 1); |
|
376 | + $total++; |
|
377 | + } |
|
378 | + } |
|
379 | + } else { |
|
380 | + $zstart = 0; |
|
381 | + foreach ($z_boundaries as $boundary) { |
|
382 | + $num = $stats->statsAgeQuery(false, 'DEAT', 'BOTH', $zstart, $boundary); |
|
383 | + foreach ($num as $values) { |
|
384 | + foreach ($values as $age_value) { |
|
385 | + fill_y_data($boundary, (int) ($age_value / 365.25), 1); |
|
386 | + $total++; |
|
387 | + } |
|
388 | + } |
|
389 | + $zstart = $boundary + 1; |
|
390 | + } |
|
391 | + } |
|
392 | 392 | |
393 | - return $total; |
|
393 | + return $total; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -403,48 +403,48 @@ discard block |
||
403 | 403 | * @return int |
404 | 404 | */ |
405 | 405 | function age_at_marriage($z_axis, array $z_boundaries, Stats $stats) { |
406 | - $total = 0; |
|
406 | + $total = 0; |
|
407 | 407 | |
408 | - if ($z_axis === 300) { |
|
409 | - $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
410 | - foreach ($num as $values) { |
|
411 | - fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
412 | - $total++; |
|
413 | - } |
|
414 | - $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
415 | - foreach ($num as $values) { |
|
416 | - fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
417 | - $total++; |
|
418 | - } |
|
419 | - } elseif ($z_axis === 301) { |
|
420 | - $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
421 | - foreach ($num as $values) { |
|
422 | - fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
423 | - $total++; |
|
424 | - } |
|
425 | - $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
426 | - foreach ($num as $values) { |
|
427 | - fill_y_data(1, (int) ($values['age'] / 365.25), 1); |
|
428 | - $total++; |
|
429 | - } |
|
430 | - } else { |
|
431 | - $zstart = 0; |
|
432 | - foreach ($z_boundaries as $boundary) { |
|
433 | - $num = $stats->statsMarrAgeQuery(false, 'M', $zstart, $boundary); |
|
434 | - foreach ($num as $values) { |
|
435 | - fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
436 | - $total++; |
|
437 | - } |
|
438 | - $num = $stats->statsMarrAgeQuery(false, 'F', $zstart, $boundary); |
|
439 | - foreach ($num as $values) { |
|
440 | - fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
441 | - $total++; |
|
442 | - } |
|
443 | - $zstart = $boundary + 1; |
|
444 | - } |
|
445 | - } |
|
408 | + if ($z_axis === 300) { |
|
409 | + $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
410 | + foreach ($num as $values) { |
|
411 | + fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
412 | + $total++; |
|
413 | + } |
|
414 | + $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
415 | + foreach ($num as $values) { |
|
416 | + fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
417 | + $total++; |
|
418 | + } |
|
419 | + } elseif ($z_axis === 301) { |
|
420 | + $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
421 | + foreach ($num as $values) { |
|
422 | + fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
423 | + $total++; |
|
424 | + } |
|
425 | + $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
426 | + foreach ($num as $values) { |
|
427 | + fill_y_data(1, (int) ($values['age'] / 365.25), 1); |
|
428 | + $total++; |
|
429 | + } |
|
430 | + } else { |
|
431 | + $zstart = 0; |
|
432 | + foreach ($z_boundaries as $boundary) { |
|
433 | + $num = $stats->statsMarrAgeQuery(false, 'M', $zstart, $boundary); |
|
434 | + foreach ($num as $values) { |
|
435 | + fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
436 | + $total++; |
|
437 | + } |
|
438 | + $num = $stats->statsMarrAgeQuery(false, 'F', $zstart, $boundary); |
|
439 | + foreach ($num as $values) { |
|
440 | + fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
441 | + $total++; |
|
442 | + } |
|
443 | + $zstart = $boundary + 1; |
|
444 | + } |
|
445 | + } |
|
446 | 446 | |
447 | - return $total; |
|
447 | + return $total; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -457,71 +457,71 @@ discard block |
||
457 | 457 | * @return int |
458 | 458 | */ |
459 | 459 | function age_at_first_marriage($z_axis, array $z_boundaries, Stats $stats) { |
460 | - $total = 0; |
|
460 | + $total = 0; |
|
461 | 461 | |
462 | - if ($z_axis === 300) { |
|
463 | - $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
464 | - $indi = array(); |
|
465 | - foreach ($num as $values) { |
|
466 | - if (!in_array($values['d_gid'], $indi)) { |
|
467 | - fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
468 | - $total++; |
|
469 | - $indi[] = $values['d_gid']; |
|
470 | - } |
|
471 | - } |
|
472 | - $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
473 | - $indi = array(); |
|
474 | - foreach ($num as $values) { |
|
475 | - if (!in_array($values['d_gid'], $indi)) { |
|
476 | - fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
477 | - $total++; |
|
478 | - $indi[] = $values['d_gid']; |
|
479 | - } |
|
480 | - } |
|
481 | - } elseif ($z_axis === 301) { |
|
482 | - $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
483 | - $indi = array(); |
|
484 | - foreach ($num as $values) { |
|
485 | - if (!in_array($values['d_gid'], $indi)) { |
|
486 | - fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
487 | - $total++; |
|
488 | - $indi[] = $values['d_gid']; |
|
489 | - } |
|
490 | - } |
|
491 | - $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
492 | - $indi = array(); |
|
493 | - foreach ($num as $values) { |
|
494 | - if (!in_array($values['d_gid'], $indi)) { |
|
495 | - fill_y_data(1, (int) ($values['age'] / 365.25), 1); |
|
496 | - $total++; |
|
497 | - $indi[] = $values['d_gid']; |
|
498 | - } |
|
499 | - } |
|
500 | - } else { |
|
501 | - $zstart = 0; |
|
502 | - $indi = array(); |
|
503 | - foreach ($z_boundaries as $boundary) { |
|
504 | - $num = $stats->statsMarrAgeQuery(false, 'M', $zstart, $boundary); |
|
505 | - foreach ($num as $values) { |
|
506 | - if (!in_array($values['d_gid'], $indi)) { |
|
507 | - fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
508 | - $total++; |
|
509 | - $indi[] = $values['d_gid']; |
|
510 | - } |
|
511 | - } |
|
512 | - $num = $stats->statsMarrAgeQuery(false, 'F', $zstart, $boundary); |
|
513 | - foreach ($num as $values) { |
|
514 | - if (!in_array($values['d_gid'], $indi)) { |
|
515 | - fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
516 | - $total++; |
|
517 | - $indi[] = $values['d_gid']; |
|
518 | - } |
|
519 | - } |
|
520 | - $zstart = $boundary + 1; |
|
521 | - } |
|
522 | - } |
|
462 | + if ($z_axis === 300) { |
|
463 | + $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
464 | + $indi = array(); |
|
465 | + foreach ($num as $values) { |
|
466 | + if (!in_array($values['d_gid'], $indi)) { |
|
467 | + fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
468 | + $total++; |
|
469 | + $indi[] = $values['d_gid']; |
|
470 | + } |
|
471 | + } |
|
472 | + $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
473 | + $indi = array(); |
|
474 | + foreach ($num as $values) { |
|
475 | + if (!in_array($values['d_gid'], $indi)) { |
|
476 | + fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
477 | + $total++; |
|
478 | + $indi[] = $values['d_gid']; |
|
479 | + } |
|
480 | + } |
|
481 | + } elseif ($z_axis === 301) { |
|
482 | + $num = $stats->statsMarrAgeQuery(false, 'M'); |
|
483 | + $indi = array(); |
|
484 | + foreach ($num as $values) { |
|
485 | + if (!in_array($values['d_gid'], $indi)) { |
|
486 | + fill_y_data(0, (int) ($values['age'] / 365.25), 1); |
|
487 | + $total++; |
|
488 | + $indi[] = $values['d_gid']; |
|
489 | + } |
|
490 | + } |
|
491 | + $num = $stats->statsMarrAgeQuery(false, 'F'); |
|
492 | + $indi = array(); |
|
493 | + foreach ($num as $values) { |
|
494 | + if (!in_array($values['d_gid'], $indi)) { |
|
495 | + fill_y_data(1, (int) ($values['age'] / 365.25), 1); |
|
496 | + $total++; |
|
497 | + $indi[] = $values['d_gid']; |
|
498 | + } |
|
499 | + } |
|
500 | + } else { |
|
501 | + $zstart = 0; |
|
502 | + $indi = array(); |
|
503 | + foreach ($z_boundaries as $boundary) { |
|
504 | + $num = $stats->statsMarrAgeQuery(false, 'M', $zstart, $boundary); |
|
505 | + foreach ($num as $values) { |
|
506 | + if (!in_array($values['d_gid'], $indi)) { |
|
507 | + fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
508 | + $total++; |
|
509 | + $indi[] = $values['d_gid']; |
|
510 | + } |
|
511 | + } |
|
512 | + $num = $stats->statsMarrAgeQuery(false, 'F', $zstart, $boundary); |
|
513 | + foreach ($num as $values) { |
|
514 | + if (!in_array($values['d_gid'], $indi)) { |
|
515 | + fill_y_data($boundary, (int) ($values['age'] / 365.25), 1); |
|
516 | + $total++; |
|
517 | + $indi[] = $values['d_gid']; |
|
518 | + } |
|
519 | + } |
|
520 | + $zstart = $boundary + 1; |
|
521 | + } |
|
522 | + } |
|
523 | 523 | |
524 | - return $total; |
|
524 | + return $total; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -534,38 +534,38 @@ discard block |
||
534 | 534 | * @return int |
535 | 535 | */ |
536 | 536 | function number_of_children($z_axis, array $z_boundaries, Stats $stats) { |
537 | - $total = 0; |
|
537 | + $total = 0; |
|
538 | 538 | |
539 | - if ($z_axis === 300) { |
|
540 | - $num = $stats->statsChildrenQuery(false); |
|
541 | - foreach ($num as $values) { |
|
542 | - fill_y_data(0, $values['f_numchil'], $values['total']); |
|
543 | - $total += $values['f_numchil'] * $values['total']; |
|
544 | - } |
|
545 | - } elseif ($z_axis === 301) { |
|
546 | - $num = $stats->statsChildrenQuery(false, 'M'); |
|
547 | - foreach ($num as $values) { |
|
548 | - fill_y_data(0, $values['num'], $values['total']); |
|
549 | - $total += $values['num'] * $values['total']; |
|
550 | - } |
|
551 | - $num = $stats->statsChildrenQuery(false, 'F'); |
|
552 | - foreach ($num as $values) { |
|
553 | - fill_y_data(1, $values['num'], $values['total']); |
|
554 | - $total += $values['num'] * $values['total']; |
|
555 | - } |
|
556 | - } else { |
|
557 | - $zstart = 0; |
|
558 | - foreach ($z_boundaries as $boundary) { |
|
559 | - $num = $stats->statsChildrenQuery(false, 'BOTH', $zstart, $boundary); |
|
560 | - foreach ($num as $values) { |
|
561 | - fill_y_data($boundary, $values['f_numchil'], $values['total']); |
|
562 | - $total += $values['f_numchil'] * $values['total']; |
|
563 | - } |
|
564 | - $zstart = $boundary + 1; |
|
565 | - } |
|
566 | - } |
|
539 | + if ($z_axis === 300) { |
|
540 | + $num = $stats->statsChildrenQuery(false); |
|
541 | + foreach ($num as $values) { |
|
542 | + fill_y_data(0, $values['f_numchil'], $values['total']); |
|
543 | + $total += $values['f_numchil'] * $values['total']; |
|
544 | + } |
|
545 | + } elseif ($z_axis === 301) { |
|
546 | + $num = $stats->statsChildrenQuery(false, 'M'); |
|
547 | + foreach ($num as $values) { |
|
548 | + fill_y_data(0, $values['num'], $values['total']); |
|
549 | + $total += $values['num'] * $values['total']; |
|
550 | + } |
|
551 | + $num = $stats->statsChildrenQuery(false, 'F'); |
|
552 | + foreach ($num as $values) { |
|
553 | + fill_y_data(1, $values['num'], $values['total']); |
|
554 | + $total += $values['num'] * $values['total']; |
|
555 | + } |
|
556 | + } else { |
|
557 | + $zstart = 0; |
|
558 | + foreach ($z_boundaries as $boundary) { |
|
559 | + $num = $stats->statsChildrenQuery(false, 'BOTH', $zstart, $boundary); |
|
560 | + foreach ($num as $values) { |
|
561 | + fill_y_data($boundary, $values['f_numchil'], $values['total']); |
|
562 | + $total += $values['f_numchil'] * $values['total']; |
|
563 | + } |
|
564 | + $zstart = $boundary + 1; |
|
565 | + } |
|
566 | + } |
|
567 | 567 | |
568 | - return $total; |
|
568 | + return $total; |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -576,30 +576,30 @@ discard block |
||
576 | 576 | * @param int $val |
577 | 577 | */ |
578 | 578 | function fill_y_data($z, $x, $val) { |
579 | - global $ydata, $xmax, $x_boundaries, $zmax, $z_boundaries, $xgiven, $zgiven; |
|
580 | - //-- calculate index $i out of given z value |
|
581 | - //-- calculate index $j out of given x value |
|
582 | - if ($xgiven) { |
|
583 | - $j = $x; |
|
584 | - } else { |
|
585 | - $j = 0; |
|
586 | - while (($x > $x_boundaries[$j]) && ($j < $xmax)) { |
|
587 | - $j++; |
|
588 | - } |
|
589 | - } |
|
590 | - if ($zgiven) { |
|
591 | - $i = $z; |
|
592 | - } else { |
|
593 | - $i = 0; |
|
594 | - while (($z > $z_boundaries[$i]) && ($i < $zmax)) { |
|
595 | - $i++; |
|
596 | - } |
|
597 | - } |
|
598 | - if (isset($ydata[$i][$j])) { |
|
599 | - $ydata[$i][$j] += $val; |
|
600 | - } else { |
|
601 | - $ydata[$i][$j] = $val; |
|
602 | - } |
|
579 | + global $ydata, $xmax, $x_boundaries, $zmax, $z_boundaries, $xgiven, $zgiven; |
|
580 | + //-- calculate index $i out of given z value |
|
581 | + //-- calculate index $j out of given x value |
|
582 | + if ($xgiven) { |
|
583 | + $j = $x; |
|
584 | + } else { |
|
585 | + $j = 0; |
|
586 | + while (($x > $x_boundaries[$j]) && ($j < $xmax)) { |
|
587 | + $j++; |
|
588 | + } |
|
589 | + } |
|
590 | + if ($zgiven) { |
|
591 | + $i = $z; |
|
592 | + } else { |
|
593 | + $i = 0; |
|
594 | + while (($z > $z_boundaries[$i]) && ($i < $zmax)) { |
|
595 | + $i++; |
|
596 | + } |
|
597 | + } |
|
598 | + if (isset($ydata[$i][$j])) { |
|
599 | + $ydata[$i][$j] += $val; |
|
600 | + } else { |
|
601 | + $ydata[$i][$j] = $val; |
|
602 | + } |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -613,138 +613,138 @@ discard block |
||
613 | 613 | * @param string[] $legend |
614 | 614 | */ |
615 | 615 | function my_plot($mytitle, $xdata, $xtitle, $ydata, $ytitle, $legend) { |
616 | - global $percentage, $male_female, $ymax, $scalefactor, $datastring, $imgurl; |
|
616 | + global $percentage, $male_female, $ymax, $scalefactor, $datastring, $imgurl; |
|
617 | 617 | |
618 | - // Google Chart API only allows text encoding for numbers less than 100 |
|
619 | - // and it does not allow adjusting the y-axis range, so we must find the maximum y-value |
|
620 | - // in order to adjust beforehand by changing the numbers |
|
618 | + // Google Chart API only allows text encoding for numbers less than 100 |
|
619 | + // and it does not allow adjusting the y-axis range, so we must find the maximum y-value |
|
620 | + // in order to adjust beforehand by changing the numbers |
|
621 | 621 | |
622 | - if ($male_female) { |
|
623 | - $stop = 2; |
|
624 | - } else { |
|
625 | - $stop = count($ydata); |
|
626 | - } |
|
627 | - if ($percentage) { |
|
628 | - $ypercentmax = 0; |
|
629 | - $yt = array(); |
|
630 | - for ($i = 0; $i < $stop; $i++) { |
|
631 | - if (isset($ydata[$i])) { |
|
632 | - $ymax = max($ydata[$i]); |
|
633 | - $yt[$i] = array_sum($ydata[$i]); |
|
634 | - if ($yt[$i] > 0) { |
|
635 | - $ypercent = round($ymax / $yt[$i] * 100, 1); |
|
636 | - $ypercentmax = max($ypercentmax, $ypercent); |
|
637 | - } |
|
638 | - } |
|
639 | - } |
|
640 | - $ymax = $ypercentmax; |
|
641 | - if ($ymax > 0) { |
|
642 | - $scalefactor = 100.0 / $ymax; |
|
643 | - } else { |
|
644 | - $scalefactor = 0; |
|
645 | - } |
|
646 | - $datastring = 'chd=t:'; |
|
647 | - for ($i = 0; $i < $stop; $i++) { |
|
648 | - if (isset($ydata[$i])) { |
|
649 | - foreach ($ydata[$i] as $j => $data) { |
|
650 | - if ($j > 0) { |
|
651 | - $datastring .= ','; |
|
652 | - } |
|
653 | - if ($yt[$i] > 0) { |
|
654 | - $datastring .= round($data / $yt[$i] * 100 * $scalefactor, 1); |
|
655 | - } else { |
|
656 | - $datastring .= '0'; |
|
657 | - } |
|
658 | - } |
|
659 | - if ($i !== $stop - 1) { |
|
660 | - $datastring .= '|'; |
|
661 | - } |
|
662 | - } |
|
663 | - } |
|
664 | - } else { |
|
665 | - for ($i = 0; $i < $stop; $i++) { |
|
666 | - $ymax = max($ymax, max($ydata[$i])); |
|
667 | - } |
|
668 | - if ($ymax > 0) { |
|
669 | - $scalefactor = 100.0 / $ymax; |
|
670 | - } else { |
|
671 | - $scalefactor = 0; |
|
672 | - } |
|
673 | - $datastring = 'chd=t:'; |
|
674 | - for ($i = 0; $i < $stop; $i++) { |
|
675 | - foreach ($ydata[$i] as $j => $data) { |
|
676 | - if ($j > 0) { |
|
677 | - $datastring .= ','; |
|
678 | - } |
|
679 | - $datastring .= round($data * $scalefactor, 1); |
|
680 | - } |
|
681 | - if ($i !== $stop - 1) { |
|
682 | - $datastring .= '|'; |
|
683 | - } |
|
684 | - } |
|
685 | - } |
|
686 | - $colors = array('0000FF', 'FFA0CB', '9F00FF', 'FF7000', '905030', 'FF0000', '00FF00', 'F0F000'); |
|
687 | - $colorstring = 'chco='; |
|
688 | - for ($i = 0; $i < $stop; $i++) { |
|
689 | - if (isset($colors[$i])) { |
|
690 | - $colorstring .= $colors[$i]; |
|
691 | - if ($i !== ($stop - 1)) { |
|
692 | - $colorstring .= ','; |
|
693 | - } |
|
694 | - } |
|
695 | - } |
|
622 | + if ($male_female) { |
|
623 | + $stop = 2; |
|
624 | + } else { |
|
625 | + $stop = count($ydata); |
|
626 | + } |
|
627 | + if ($percentage) { |
|
628 | + $ypercentmax = 0; |
|
629 | + $yt = array(); |
|
630 | + for ($i = 0; $i < $stop; $i++) { |
|
631 | + if (isset($ydata[$i])) { |
|
632 | + $ymax = max($ydata[$i]); |
|
633 | + $yt[$i] = array_sum($ydata[$i]); |
|
634 | + if ($yt[$i] > 0) { |
|
635 | + $ypercent = round($ymax / $yt[$i] * 100, 1); |
|
636 | + $ypercentmax = max($ypercentmax, $ypercent); |
|
637 | + } |
|
638 | + } |
|
639 | + } |
|
640 | + $ymax = $ypercentmax; |
|
641 | + if ($ymax > 0) { |
|
642 | + $scalefactor = 100.0 / $ymax; |
|
643 | + } else { |
|
644 | + $scalefactor = 0; |
|
645 | + } |
|
646 | + $datastring = 'chd=t:'; |
|
647 | + for ($i = 0; $i < $stop; $i++) { |
|
648 | + if (isset($ydata[$i])) { |
|
649 | + foreach ($ydata[$i] as $j => $data) { |
|
650 | + if ($j > 0) { |
|
651 | + $datastring .= ','; |
|
652 | + } |
|
653 | + if ($yt[$i] > 0) { |
|
654 | + $datastring .= round($data / $yt[$i] * 100 * $scalefactor, 1); |
|
655 | + } else { |
|
656 | + $datastring .= '0'; |
|
657 | + } |
|
658 | + } |
|
659 | + if ($i !== $stop - 1) { |
|
660 | + $datastring .= '|'; |
|
661 | + } |
|
662 | + } |
|
663 | + } |
|
664 | + } else { |
|
665 | + for ($i = 0; $i < $stop; $i++) { |
|
666 | + $ymax = max($ymax, max($ydata[$i])); |
|
667 | + } |
|
668 | + if ($ymax > 0) { |
|
669 | + $scalefactor = 100.0 / $ymax; |
|
670 | + } else { |
|
671 | + $scalefactor = 0; |
|
672 | + } |
|
673 | + $datastring = 'chd=t:'; |
|
674 | + for ($i = 0; $i < $stop; $i++) { |
|
675 | + foreach ($ydata[$i] as $j => $data) { |
|
676 | + if ($j > 0) { |
|
677 | + $datastring .= ','; |
|
678 | + } |
|
679 | + $datastring .= round($data * $scalefactor, 1); |
|
680 | + } |
|
681 | + if ($i !== $stop - 1) { |
|
682 | + $datastring .= '|'; |
|
683 | + } |
|
684 | + } |
|
685 | + } |
|
686 | + $colors = array('0000FF', 'FFA0CB', '9F00FF', 'FF7000', '905030', 'FF0000', '00FF00', 'F0F000'); |
|
687 | + $colorstring = 'chco='; |
|
688 | + for ($i = 0; $i < $stop; $i++) { |
|
689 | + if (isset($colors[$i])) { |
|
690 | + $colorstring .= $colors[$i]; |
|
691 | + if ($i !== ($stop - 1)) { |
|
692 | + $colorstring .= ','; |
|
693 | + } |
|
694 | + } |
|
695 | + } |
|
696 | 696 | |
697 | - $titleLength = strpos($mytitle . "\n", "\n"); |
|
698 | - $title = substr($mytitle, 0, $titleLength); |
|
697 | + $titleLength = strpos($mytitle . "\n", "\n"); |
|
698 | + $title = substr($mytitle, 0, $titleLength); |
|
699 | 699 | |
700 | - $imgurl = 'https://chart.googleapis.com/chart?cht=bvg&chs=950x300&chf=bg,s,ffffff00|c,s,ffffff00&chtt=' . rawurlencode($title) . '&' . $datastring . '&' . $colorstring . '&chbh='; |
|
701 | - if (count($ydata) > 3) { |
|
702 | - $imgurl .= '5,1'; |
|
703 | - } elseif (count($ydata) < 2) { |
|
704 | - $imgurl .= '45,1'; |
|
705 | - } else { |
|
706 | - $imgurl .= '20,3'; |
|
707 | - } |
|
708 | - $imgurl .= '&chxt=x,x,y,y&chxl=0:|'; |
|
709 | - foreach ($xdata as $data) { |
|
710 | - $imgurl .= rawurlencode($data) . '|'; |
|
711 | - } |
|
700 | + $imgurl = 'https://chart.googleapis.com/chart?cht=bvg&chs=950x300&chf=bg,s,ffffff00|c,s,ffffff00&chtt=' . rawurlencode($title) . '&' . $datastring . '&' . $colorstring . '&chbh='; |
|
701 | + if (count($ydata) > 3) { |
|
702 | + $imgurl .= '5,1'; |
|
703 | + } elseif (count($ydata) < 2) { |
|
704 | + $imgurl .= '45,1'; |
|
705 | + } else { |
|
706 | + $imgurl .= '20,3'; |
|
707 | + } |
|
708 | + $imgurl .= '&chxt=x,x,y,y&chxl=0:|'; |
|
709 | + foreach ($xdata as $data) { |
|
710 | + $imgurl .= rawurlencode($data) . '|'; |
|
711 | + } |
|
712 | 712 | |
713 | - $imgurl .= '1:||||' . rawurlencode($xtitle) . '|2:|'; |
|
714 | - $imgurl .= '0|'; |
|
715 | - if ($percentage) { |
|
716 | - for ($i = 1; $i < 11; $i++) { |
|
717 | - if ($ymax < 11) { |
|
718 | - $imgurl .= round($ymax * $i / 10, 1) . '|'; |
|
719 | - } else { |
|
720 | - $imgurl .= round($ymax * $i / 10, 0) . '|'; |
|
721 | - } |
|
722 | - } |
|
723 | - $imgurl .= '3:||%|'; |
|
724 | - } else { |
|
725 | - if ($ymax < 11) { |
|
726 | - for ($i = 1; $i < $ymax + 1; $i++) { |
|
727 | - $imgurl .= round($ymax * $i / ($ymax), 0) . '|'; |
|
728 | - } |
|
729 | - } else { |
|
730 | - for ($i = 1; $i < 11; $i++) { |
|
731 | - $imgurl .= round($ymax * $i / 10, 0) . '|'; |
|
732 | - } |
|
733 | - } |
|
734 | - $imgurl .= '3:||' . rawurlencode($ytitle) . '|'; |
|
735 | - } |
|
736 | - // Only show legend if y-data is non-2-dimensional |
|
737 | - if (count($ydata) > 1) { |
|
738 | - $imgurl .= '&chdl='; |
|
739 | - foreach ($legend as $i => $data) { |
|
740 | - if ($i > 0) { |
|
741 | - $imgurl .= '|'; |
|
742 | - } |
|
743 | - $imgurl .= rawurlencode($data); |
|
744 | - } |
|
745 | - } |
|
746 | - $title = strstr($mytitle, '|', true); |
|
747 | - echo '<img src="', $imgurl, '" width="950" height="300" alt="', Filter::escapeHtml($title), '" title="', Filter::escapeHtml($title), '">'; |
|
713 | + $imgurl .= '1:||||' . rawurlencode($xtitle) . '|2:|'; |
|
714 | + $imgurl .= '0|'; |
|
715 | + if ($percentage) { |
|
716 | + for ($i = 1; $i < 11; $i++) { |
|
717 | + if ($ymax < 11) { |
|
718 | + $imgurl .= round($ymax * $i / 10, 1) . '|'; |
|
719 | + } else { |
|
720 | + $imgurl .= round($ymax * $i / 10, 0) . '|'; |
|
721 | + } |
|
722 | + } |
|
723 | + $imgurl .= '3:||%|'; |
|
724 | + } else { |
|
725 | + if ($ymax < 11) { |
|
726 | + for ($i = 1; $i < $ymax + 1; $i++) { |
|
727 | + $imgurl .= round($ymax * $i / ($ymax), 0) . '|'; |
|
728 | + } |
|
729 | + } else { |
|
730 | + for ($i = 1; $i < 11; $i++) { |
|
731 | + $imgurl .= round($ymax * $i / 10, 0) . '|'; |
|
732 | + } |
|
733 | + } |
|
734 | + $imgurl .= '3:||' . rawurlencode($ytitle) . '|'; |
|
735 | + } |
|
736 | + // Only show legend if y-data is non-2-dimensional |
|
737 | + if (count($ydata) > 1) { |
|
738 | + $imgurl .= '&chdl='; |
|
739 | + foreach ($legend as $i => $data) { |
|
740 | + if ($i > 0) { |
|
741 | + $imgurl .= '|'; |
|
742 | + } |
|
743 | + $imgurl .= rawurlencode($data); |
|
744 | + } |
|
745 | + } |
|
746 | + $title = strstr($mytitle, '|', true); |
|
747 | + echo '<img src="', $imgurl, '" width="950" height="300" alt="', Filter::escapeHtml($title), '" title="', Filter::escapeHtml($title), '">'; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | /** |
@@ -753,44 +753,44 @@ discard block |
||
753 | 753 | * @param string $x_axis_boundaries |
754 | 754 | */ |
755 | 755 | function calculate_axis($x_axis_boundaries) { |
756 | - global $x_axis, $xdata, $xmax, $x_boundaries; |
|
756 | + global $x_axis, $xdata, $xmax, $x_boundaries; |
|
757 | 757 | |
758 | - // Calculate xdata and zdata elements out of chart values |
|
759 | - $hulpar = explode(',', $x_axis_boundaries); |
|
760 | - $i = 1; |
|
761 | - if ($x_axis === 21 && $hulpar[0] == 1) { |
|
762 | - $xdata[0] = 0; |
|
763 | - } else { |
|
764 | - $xdata[0] = format_range_of_numbers(0, $hulpar[0]); |
|
765 | - } |
|
766 | - $x_boundaries[0] = $hulpar[0] - 1; |
|
767 | - while (isset($hulpar[$i])) { |
|
768 | - $i1 = $i - 1; |
|
769 | - if (($hulpar[$i] - $hulpar[$i1]) === 1) { |
|
770 | - $xdata[$i] = $hulpar[$i1]; |
|
771 | - $x_boundaries[$i] = $hulpar[$i1]; |
|
772 | - } elseif ($hulpar[$i1] === $hulpar[0]) { |
|
773 | - $xdata[$i] = format_range_of_numbers($hulpar[$i1], $hulpar[$i]); |
|
774 | - $x_boundaries[$i] = $hulpar[$i]; |
|
775 | - } else { |
|
776 | - $xdata[$i] = format_range_of_numbers($hulpar[$i1] + 1, $hulpar[$i]); |
|
777 | - $x_boundaries[$i] = $hulpar[$i]; |
|
778 | - } |
|
779 | - $i++; |
|
780 | - } |
|
781 | - $xdata[$i] = $hulpar[$i - 1]; |
|
782 | - $x_boundaries[$i] = $hulpar[$i - 1]; |
|
783 | - if ($hulpar[$i - 1] === $i) { |
|
784 | - $xmax = $i + 1; |
|
785 | - } else { |
|
786 | - $xmax = $i; |
|
787 | - } |
|
788 | - $xdata[$xmax] = /* I18N: Label on a graph; 40+ means 40 or more */ I18N::translate('%s+', I18N::number($hulpar[$i - 1])); |
|
789 | - $x_boundaries[$xmax] = 10000; |
|
790 | - $xmax = $xmax + 1; |
|
791 | - if ($xmax > 20) { |
|
792 | - $xmax = 20; |
|
793 | - } |
|
758 | + // Calculate xdata and zdata elements out of chart values |
|
759 | + $hulpar = explode(',', $x_axis_boundaries); |
|
760 | + $i = 1; |
|
761 | + if ($x_axis === 21 && $hulpar[0] == 1) { |
|
762 | + $xdata[0] = 0; |
|
763 | + } else { |
|
764 | + $xdata[0] = format_range_of_numbers(0, $hulpar[0]); |
|
765 | + } |
|
766 | + $x_boundaries[0] = $hulpar[0] - 1; |
|
767 | + while (isset($hulpar[$i])) { |
|
768 | + $i1 = $i - 1; |
|
769 | + if (($hulpar[$i] - $hulpar[$i1]) === 1) { |
|
770 | + $xdata[$i] = $hulpar[$i1]; |
|
771 | + $x_boundaries[$i] = $hulpar[$i1]; |
|
772 | + } elseif ($hulpar[$i1] === $hulpar[0]) { |
|
773 | + $xdata[$i] = format_range_of_numbers($hulpar[$i1], $hulpar[$i]); |
|
774 | + $x_boundaries[$i] = $hulpar[$i]; |
|
775 | + } else { |
|
776 | + $xdata[$i] = format_range_of_numbers($hulpar[$i1] + 1, $hulpar[$i]); |
|
777 | + $x_boundaries[$i] = $hulpar[$i]; |
|
778 | + } |
|
779 | + $i++; |
|
780 | + } |
|
781 | + $xdata[$i] = $hulpar[$i - 1]; |
|
782 | + $x_boundaries[$i] = $hulpar[$i - 1]; |
|
783 | + if ($hulpar[$i - 1] === $i) { |
|
784 | + $xmax = $i + 1; |
|
785 | + } else { |
|
786 | + $xmax = $i; |
|
787 | + } |
|
788 | + $xdata[$xmax] = /* I18N: Label on a graph; 40+ means 40 or more */ I18N::translate('%s+', I18N::number($hulpar[$i - 1])); |
|
789 | + $x_boundaries[$xmax] = 10000; |
|
790 | + $xmax = $xmax + 1; |
|
791 | + if ($xmax > 20) { |
|
792 | + $xmax = 20; |
|
793 | + } |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | * @return string |
803 | 803 | */ |
804 | 804 | function format_range_of_numbers($x, $y) { |
805 | - return /* I18N: A range of numbers */ I18N::translate( |
|
806 | - '%1$s–%2$s', |
|
807 | - I18N::number($x), |
|
808 | - I18N::number($y) |
|
809 | - ); |
|
805 | + return /* I18N: A range of numbers */ I18N::translate( |
|
806 | + '%1$s–%2$s', |
|
807 | + I18N::number($x), |
|
808 | + I18N::number($y) |
|
809 | + ); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -815,30 +815,30 @@ discard block |
||
815 | 815 | * @param string $boundaries_z_axis |
816 | 816 | */ |
817 | 817 | function calculate_legend($boundaries_z_axis) { |
818 | - global $legend, $zmax, $z_boundaries; |
|
818 | + global $legend, $zmax, $z_boundaries; |
|
819 | 819 | |
820 | - // calculate the legend values |
|
821 | - $hulpar = explode(',', $boundaries_z_axis); |
|
822 | - $i = 1; |
|
823 | - $date = new Date('BEF ' . $hulpar[0]); |
|
824 | - $legend[0] = strip_tags($date->display()); |
|
825 | - $z_boundaries[0] = $hulpar[0] - 1; |
|
826 | - while (isset($hulpar[$i])) { |
|
827 | - $i1 = $i - 1; |
|
828 | - $date = new Date('BET ' . $hulpar[$i1] . ' AND ' . ($hulpar[$i] - 1)); |
|
829 | - $legend[$i] = strip_tags($date->display()); |
|
830 | - $z_boundaries[$i] = $hulpar[$i] - 1; |
|
831 | - $i++; |
|
832 | - } |
|
833 | - $zmax = $i; |
|
834 | - $zmax1 = $zmax - 1; |
|
835 | - $date = new Date('AFT ' . $hulpar[$zmax1]); |
|
836 | - $legend[$zmax] = strip_tags($date->display()); |
|
837 | - $z_boundaries[$zmax] = 10000; |
|
838 | - $zmax = $zmax + 1; |
|
839 | - if ($zmax > 8) { |
|
840 | - $zmax = 8; |
|
841 | - } |
|
820 | + // calculate the legend values |
|
821 | + $hulpar = explode(',', $boundaries_z_axis); |
|
822 | + $i = 1; |
|
823 | + $date = new Date('BEF ' . $hulpar[0]); |
|
824 | + $legend[0] = strip_tags($date->display()); |
|
825 | + $z_boundaries[0] = $hulpar[0] - 1; |
|
826 | + while (isset($hulpar[$i])) { |
|
827 | + $i1 = $i - 1; |
|
828 | + $date = new Date('BET ' . $hulpar[$i1] . ' AND ' . ($hulpar[$i] - 1)); |
|
829 | + $legend[$i] = strip_tags($date->display()); |
|
830 | + $z_boundaries[$i] = $hulpar[$i] - 1; |
|
831 | + $i++; |
|
832 | + } |
|
833 | + $zmax = $i; |
|
834 | + $zmax1 = $zmax - 1; |
|
835 | + $date = new Date('AFT ' . $hulpar[$zmax1]); |
|
836 | + $legend[$zmax] = strip_tags($date->display()); |
|
837 | + $z_boundaries[$zmax] = 10000; |
|
838 | + $zmax = $zmax + 1; |
|
839 | + if ($zmax > 8) { |
|
840 | + $zmax = 8; |
|
841 | + } |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | global $legend, $xdata, $ydata, $xmax, $zmax, $z_boundaries, $xgiven, $zgiven, $percentage, $male_female; |
@@ -853,527 +853,527 @@ discard block |
||
853 | 853 | |
854 | 854 | switch ($x_axis) { |
855 | 855 | case '1': |
856 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), Filter::get('chart_type'), Filter::get('SURN'))); |
|
857 | - break; |
|
856 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), Filter::get('chart_type'), Filter::get('SURN'))); |
|
857 | + break; |
|
858 | 858 | case '2': |
859 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'birth_distribution_chart')); |
|
860 | - break; |
|
859 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'birth_distribution_chart')); |
|
860 | + break; |
|
861 | 861 | case '3': |
862 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'death_distribution_chart')); |
|
863 | - break; |
|
862 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'death_distribution_chart')); |
|
863 | + break; |
|
864 | 864 | case '4': |
865 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'marriage_distribution_chart')); |
|
866 | - break; |
|
865 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'marriage_distribution_chart')); |
|
866 | + break; |
|
867 | 867 | case '11': |
868 | - $monthdata = array(); |
|
869 | - for ($i = 0; $i < 12; ++$i) { |
|
870 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
871 | - } |
|
872 | - $xgiven = true; |
|
873 | - $zgiven = false; |
|
874 | - $title = I18N::translate('Month of birth'); |
|
875 | - $xtitle = I18N::translate('month'); |
|
876 | - $ytitle = I18N::translate('numbers'); |
|
877 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
878 | - $xdata = $monthdata; |
|
879 | - $xmax = 12; |
|
880 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
881 | - calculate_legend($boundaries_z_axis); |
|
882 | - } |
|
883 | - $percentage = false; |
|
884 | - if ($y_axis === 201) { |
|
885 | - $percentage = false; |
|
886 | - $ytitle = I18N::translate('Individuals'); |
|
887 | - } elseif ($y_axis === 202) { |
|
888 | - $percentage = true; |
|
889 | - $ytitle = I18N::translate('percentage'); |
|
890 | - } |
|
891 | - $male_female = false; |
|
892 | - if ($z_axis === 300) { |
|
893 | - $zgiven = false; |
|
894 | - $legend[0] = 'all'; |
|
895 | - $zmax = 1; |
|
896 | - $z_boundaries[0] = 100000; |
|
897 | - } elseif ($z_axis === 301) { |
|
898 | - $male_female = true; |
|
899 | - $zgiven = true; |
|
900 | - $legend[0] = I18N::translate('Male'); |
|
901 | - $legend[1] = I18N::translate('Female'); |
|
902 | - $zmax = 2; |
|
903 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
904 | - } elseif ($z_axis === 302) { |
|
905 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
906 | - } |
|
907 | - //-- reset the data array |
|
908 | - for ($i = 0; $i < $zmax; $i++) { |
|
909 | - for ($j = 0; $j < $xmax; $j++) { |
|
910 | - $ydata[$i][$j] = 0; |
|
911 | - } |
|
912 | - } |
|
913 | - $total = month_of_birth($z_axis, $z_boundaries, $stats); |
|
914 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
915 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
916 | - break; |
|
868 | + $monthdata = array(); |
|
869 | + for ($i = 0; $i < 12; ++$i) { |
|
870 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
871 | + } |
|
872 | + $xgiven = true; |
|
873 | + $zgiven = false; |
|
874 | + $title = I18N::translate('Month of birth'); |
|
875 | + $xtitle = I18N::translate('month'); |
|
876 | + $ytitle = I18N::translate('numbers'); |
|
877 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
878 | + $xdata = $monthdata; |
|
879 | + $xmax = 12; |
|
880 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
881 | + calculate_legend($boundaries_z_axis); |
|
882 | + } |
|
883 | + $percentage = false; |
|
884 | + if ($y_axis === 201) { |
|
885 | + $percentage = false; |
|
886 | + $ytitle = I18N::translate('Individuals'); |
|
887 | + } elseif ($y_axis === 202) { |
|
888 | + $percentage = true; |
|
889 | + $ytitle = I18N::translate('percentage'); |
|
890 | + } |
|
891 | + $male_female = false; |
|
892 | + if ($z_axis === 300) { |
|
893 | + $zgiven = false; |
|
894 | + $legend[0] = 'all'; |
|
895 | + $zmax = 1; |
|
896 | + $z_boundaries[0] = 100000; |
|
897 | + } elseif ($z_axis === 301) { |
|
898 | + $male_female = true; |
|
899 | + $zgiven = true; |
|
900 | + $legend[0] = I18N::translate('Male'); |
|
901 | + $legend[1] = I18N::translate('Female'); |
|
902 | + $zmax = 2; |
|
903 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
904 | + } elseif ($z_axis === 302) { |
|
905 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
906 | + } |
|
907 | + //-- reset the data array |
|
908 | + for ($i = 0; $i < $zmax; $i++) { |
|
909 | + for ($j = 0; $j < $xmax; $j++) { |
|
910 | + $ydata[$i][$j] = 0; |
|
911 | + } |
|
912 | + } |
|
913 | + $total = month_of_birth($z_axis, $z_boundaries, $stats); |
|
914 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
915 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
916 | + break; |
|
917 | 917 | case '12': |
918 | - $monthdata = array(); |
|
919 | - for ($i = 0; $i < 12; ++$i) { |
|
920 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
921 | - } |
|
922 | - $xgiven = true; |
|
923 | - $zgiven = false; |
|
924 | - $title = I18N::translate('Month of death'); |
|
925 | - $xtitle = I18N::translate('month'); |
|
926 | - $ytitle = I18N::translate('numbers'); |
|
927 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
928 | - $xdata = $monthdata; |
|
929 | - $xmax = 12; |
|
930 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
931 | - calculate_legend($boundaries_z_axis); |
|
932 | - } |
|
933 | - $percentage = false; |
|
934 | - if ($y_axis === 201) { |
|
935 | - $percentage = false; |
|
936 | - $ytitle = I18N::translate('Individuals'); |
|
937 | - } elseif ($y_axis === 202) { |
|
938 | - $percentage = true; |
|
939 | - $ytitle = I18N::translate('percentage'); |
|
940 | - } |
|
941 | - $male_female = false; |
|
942 | - if ($z_axis === 300) { |
|
943 | - $zgiven = false; |
|
944 | - $legend[0] = 'all'; |
|
945 | - $zmax = 1; |
|
946 | - $z_boundaries[0] = 100000; |
|
947 | - } elseif ($z_axis === 301) { |
|
948 | - $male_female = true; |
|
949 | - $zgiven = true; |
|
950 | - $legend[0] = I18N::translate('Male'); |
|
951 | - $legend[1] = I18N::translate('Female'); |
|
952 | - $zmax = 2; |
|
953 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
954 | - } elseif ($z_axis === 302) { |
|
955 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
956 | - } |
|
957 | - //-- reset the data array |
|
958 | - for ($i = 0; $i < $zmax; $i++) { |
|
959 | - for ($j = 0; $j < $xmax; $j++) { |
|
960 | - $ydata[$i][$j] = 0; |
|
961 | - } |
|
962 | - } |
|
963 | - $total = month_of_death($z_axis, $z_boundaries, $stats); |
|
964 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
965 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
966 | - break; |
|
918 | + $monthdata = array(); |
|
919 | + for ($i = 0; $i < 12; ++$i) { |
|
920 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
921 | + } |
|
922 | + $xgiven = true; |
|
923 | + $zgiven = false; |
|
924 | + $title = I18N::translate('Month of death'); |
|
925 | + $xtitle = I18N::translate('month'); |
|
926 | + $ytitle = I18N::translate('numbers'); |
|
927 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
928 | + $xdata = $monthdata; |
|
929 | + $xmax = 12; |
|
930 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
931 | + calculate_legend($boundaries_z_axis); |
|
932 | + } |
|
933 | + $percentage = false; |
|
934 | + if ($y_axis === 201) { |
|
935 | + $percentage = false; |
|
936 | + $ytitle = I18N::translate('Individuals'); |
|
937 | + } elseif ($y_axis === 202) { |
|
938 | + $percentage = true; |
|
939 | + $ytitle = I18N::translate('percentage'); |
|
940 | + } |
|
941 | + $male_female = false; |
|
942 | + if ($z_axis === 300) { |
|
943 | + $zgiven = false; |
|
944 | + $legend[0] = 'all'; |
|
945 | + $zmax = 1; |
|
946 | + $z_boundaries[0] = 100000; |
|
947 | + } elseif ($z_axis === 301) { |
|
948 | + $male_female = true; |
|
949 | + $zgiven = true; |
|
950 | + $legend[0] = I18N::translate('Male'); |
|
951 | + $legend[1] = I18N::translate('Female'); |
|
952 | + $zmax = 2; |
|
953 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
954 | + } elseif ($z_axis === 302) { |
|
955 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
956 | + } |
|
957 | + //-- reset the data array |
|
958 | + for ($i = 0; $i < $zmax; $i++) { |
|
959 | + for ($j = 0; $j < $xmax; $j++) { |
|
960 | + $ydata[$i][$j] = 0; |
|
961 | + } |
|
962 | + } |
|
963 | + $total = month_of_death($z_axis, $z_boundaries, $stats); |
|
964 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
965 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
966 | + break; |
|
967 | 967 | case '13': |
968 | - $monthdata = array(); |
|
969 | - for ($i = 0; $i < 12; ++$i) { |
|
970 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
971 | - } |
|
968 | + $monthdata = array(); |
|
969 | + for ($i = 0; $i < 12; ++$i) { |
|
970 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
971 | + } |
|
972 | 972 | |
973 | - if ($z_axis === 301) { |
|
974 | - $z_axis = 300; |
|
975 | - } |
|
976 | - $xgiven = true; |
|
977 | - $zgiven = false; |
|
978 | - $title = I18N::translate('Month of marriage'); |
|
979 | - $xtitle = I18N::translate('month'); |
|
980 | - $ytitle = I18N::translate('numbers'); |
|
981 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
982 | - $xdata = $monthdata; |
|
983 | - $xmax = 12; |
|
984 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
985 | - calculate_legend($boundaries_z_axis); |
|
986 | - } |
|
987 | - $percentage = false; |
|
988 | - if ($y_axis === 201) { |
|
989 | - $percentage = false; |
|
990 | - $ytitle = I18N::translate('Families'); |
|
991 | - } elseif ($y_axis === 202) { |
|
992 | - $percentage = true; |
|
993 | - $ytitle = I18N::translate('percentage'); |
|
994 | - } |
|
995 | - $male_female = false; |
|
996 | - if ($z_axis === 300) { |
|
997 | - $zgiven = false; |
|
998 | - $legend[0] = 'all'; |
|
999 | - $zmax = 1; |
|
1000 | - $z_boundaries[0] = 100000; |
|
1001 | - } elseif ($z_axis === 301) { |
|
1002 | - $male_female = true; |
|
1003 | - $zgiven = true; |
|
1004 | - $legend[0] = I18N::translate('Male'); |
|
1005 | - $legend[1] = I18N::translate('Female'); |
|
1006 | - $zmax = 2; |
|
1007 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1008 | - } elseif ($z_axis === 302) { |
|
1009 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1010 | - } |
|
1011 | - //-- reset the data array |
|
1012 | - for ($i = 0; $i < $zmax; $i++) { |
|
1013 | - for ($j = 0; $j < $xmax; $j++) { |
|
1014 | - $ydata[$i][$j] = 0; |
|
1015 | - } |
|
1016 | - } |
|
1017 | - $total = month_of_marriage($z_axis, $z_boundaries, $stats); |
|
1018 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1019 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1020 | - break; |
|
973 | + if ($z_axis === 301) { |
|
974 | + $z_axis = 300; |
|
975 | + } |
|
976 | + $xgiven = true; |
|
977 | + $zgiven = false; |
|
978 | + $title = I18N::translate('Month of marriage'); |
|
979 | + $xtitle = I18N::translate('month'); |
|
980 | + $ytitle = I18N::translate('numbers'); |
|
981 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
982 | + $xdata = $monthdata; |
|
983 | + $xmax = 12; |
|
984 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
985 | + calculate_legend($boundaries_z_axis); |
|
986 | + } |
|
987 | + $percentage = false; |
|
988 | + if ($y_axis === 201) { |
|
989 | + $percentage = false; |
|
990 | + $ytitle = I18N::translate('Families'); |
|
991 | + } elseif ($y_axis === 202) { |
|
992 | + $percentage = true; |
|
993 | + $ytitle = I18N::translate('percentage'); |
|
994 | + } |
|
995 | + $male_female = false; |
|
996 | + if ($z_axis === 300) { |
|
997 | + $zgiven = false; |
|
998 | + $legend[0] = 'all'; |
|
999 | + $zmax = 1; |
|
1000 | + $z_boundaries[0] = 100000; |
|
1001 | + } elseif ($z_axis === 301) { |
|
1002 | + $male_female = true; |
|
1003 | + $zgiven = true; |
|
1004 | + $legend[0] = I18N::translate('Male'); |
|
1005 | + $legend[1] = I18N::translate('Female'); |
|
1006 | + $zmax = 2; |
|
1007 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1008 | + } elseif ($z_axis === 302) { |
|
1009 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1010 | + } |
|
1011 | + //-- reset the data array |
|
1012 | + for ($i = 0; $i < $zmax; $i++) { |
|
1013 | + for ($j = 0; $j < $xmax; $j++) { |
|
1014 | + $ydata[$i][$j] = 0; |
|
1015 | + } |
|
1016 | + } |
|
1017 | + $total = month_of_marriage($z_axis, $z_boundaries, $stats); |
|
1018 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1019 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1020 | + break; |
|
1021 | 1021 | case '14': |
1022 | - $monthdata = array(); |
|
1023 | - for ($i = 0; $i < 12; ++$i) { |
|
1024 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1025 | - } |
|
1026 | - $xgiven = true; |
|
1027 | - $zgiven = false; |
|
1028 | - $title = I18N::translate('Month of birth of first child in a relation'); |
|
1029 | - $xtitle = I18N::translate('month'); |
|
1030 | - $ytitle = I18N::translate('numbers'); |
|
1031 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1032 | - $xdata = $monthdata; |
|
1033 | - $xmax = 12; |
|
1034 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1035 | - calculate_legend($boundaries_z_axis); |
|
1036 | - } |
|
1037 | - $percentage = false; |
|
1038 | - if ($y_axis === 201) { |
|
1039 | - $percentage = false; |
|
1040 | - $ytitle = I18N::translate('Children'); |
|
1041 | - } elseif ($y_axis === 202) { |
|
1042 | - $percentage = true; |
|
1043 | - $ytitle = I18N::translate('percentage'); |
|
1044 | - } |
|
1045 | - $male_female = false; |
|
1046 | - if ($z_axis === 300) { |
|
1047 | - $zgiven = false; |
|
1048 | - $legend[0] = 'all'; |
|
1049 | - $zmax = 1; |
|
1050 | - $z_boundaries[0] = 100000; |
|
1051 | - } elseif ($z_axis === 301) { |
|
1052 | - $male_female = true; |
|
1053 | - $zgiven = true; |
|
1054 | - $legend[0] = I18N::translate('Male'); |
|
1055 | - $legend[1] = I18N::translate('Female'); |
|
1056 | - $zmax = 2; |
|
1057 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1058 | - } elseif ($z_axis === 302) { |
|
1059 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1060 | - } |
|
1061 | - //-- reset the data array |
|
1062 | - for ($i = 0; $i < $zmax; $i++) { |
|
1063 | - for ($j = 0; $j < $xmax; $j++) { |
|
1064 | - $ydata[$i][$j] = 0; |
|
1065 | - } |
|
1066 | - } |
|
1067 | - $total = month_of_birth_of_first_child($z_axis, $z_boundaries, $stats); |
|
1068 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1069 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1070 | - break; |
|
1022 | + $monthdata = array(); |
|
1023 | + for ($i = 0; $i < 12; ++$i) { |
|
1024 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1025 | + } |
|
1026 | + $xgiven = true; |
|
1027 | + $zgiven = false; |
|
1028 | + $title = I18N::translate('Month of birth of first child in a relation'); |
|
1029 | + $xtitle = I18N::translate('month'); |
|
1030 | + $ytitle = I18N::translate('numbers'); |
|
1031 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1032 | + $xdata = $monthdata; |
|
1033 | + $xmax = 12; |
|
1034 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1035 | + calculate_legend($boundaries_z_axis); |
|
1036 | + } |
|
1037 | + $percentage = false; |
|
1038 | + if ($y_axis === 201) { |
|
1039 | + $percentage = false; |
|
1040 | + $ytitle = I18N::translate('Children'); |
|
1041 | + } elseif ($y_axis === 202) { |
|
1042 | + $percentage = true; |
|
1043 | + $ytitle = I18N::translate('percentage'); |
|
1044 | + } |
|
1045 | + $male_female = false; |
|
1046 | + if ($z_axis === 300) { |
|
1047 | + $zgiven = false; |
|
1048 | + $legend[0] = 'all'; |
|
1049 | + $zmax = 1; |
|
1050 | + $z_boundaries[0] = 100000; |
|
1051 | + } elseif ($z_axis === 301) { |
|
1052 | + $male_female = true; |
|
1053 | + $zgiven = true; |
|
1054 | + $legend[0] = I18N::translate('Male'); |
|
1055 | + $legend[1] = I18N::translate('Female'); |
|
1056 | + $zmax = 2; |
|
1057 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1058 | + } elseif ($z_axis === 302) { |
|
1059 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1060 | + } |
|
1061 | + //-- reset the data array |
|
1062 | + for ($i = 0; $i < $zmax; $i++) { |
|
1063 | + for ($j = 0; $j < $xmax; $j++) { |
|
1064 | + $ydata[$i][$j] = 0; |
|
1065 | + } |
|
1066 | + } |
|
1067 | + $total = month_of_birth_of_first_child($z_axis, $z_boundaries, $stats); |
|
1068 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1069 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1070 | + break; |
|
1071 | 1071 | case '15': |
1072 | - $monthdata = array(); |
|
1073 | - for ($i = 0; $i < 12; ++$i) { |
|
1074 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1075 | - } |
|
1072 | + $monthdata = array(); |
|
1073 | + for ($i = 0; $i < 12; ++$i) { |
|
1074 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1075 | + } |
|
1076 | 1076 | |
1077 | - if ($z_axis === 301) { |
|
1078 | - $z_axis = 300; |
|
1079 | - } |
|
1080 | - $xgiven = true; |
|
1081 | - $zgiven = false; |
|
1082 | - $title = I18N::translate('Month of first marriage'); |
|
1083 | - $xtitle = I18N::translate('month'); |
|
1084 | - $ytitle = I18N::translate('numbers'); |
|
1085 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1086 | - $xdata = $monthdata; |
|
1087 | - $xmax = 12; |
|
1088 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1089 | - calculate_legend($boundaries_z_axis); |
|
1090 | - } |
|
1091 | - $percentage = false; |
|
1092 | - if ($y_axis === 201) { |
|
1093 | - $percentage = false; |
|
1094 | - $ytitle = I18N::translate('Families'); |
|
1095 | - } elseif ($y_axis === 202) { |
|
1096 | - $percentage = true; |
|
1097 | - $ytitle = I18N::translate('percentage'); |
|
1098 | - } |
|
1099 | - $male_female = false; |
|
1100 | - if ($z_axis === 300) { |
|
1101 | - $zgiven = false; |
|
1102 | - $legend[0] = 'all'; |
|
1103 | - $zmax = 1; |
|
1104 | - $z_boundaries[0] = 100000; |
|
1105 | - } elseif ($z_axis === 301) { |
|
1106 | - $male_female = true; |
|
1107 | - $zgiven = true; |
|
1108 | - $legend[0] = I18N::translate('Male'); |
|
1109 | - $legend[1] = I18N::translate('Female'); |
|
1110 | - $zmax = 2; |
|
1111 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1112 | - } elseif ($z_axis === 302) { |
|
1113 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1114 | - } |
|
1115 | - //-- reset the data array |
|
1116 | - for ($i = 0; $i < $zmax; $i++) { |
|
1117 | - for ($j = 0; $j < $xmax; $j++) { |
|
1118 | - $ydata[$i][$j] = 0; |
|
1119 | - } |
|
1120 | - } |
|
1121 | - $total = month_of_first_marriage($z_axis, $z_boundaries, $stats); |
|
1122 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1123 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1124 | - break; |
|
1077 | + if ($z_axis === 301) { |
|
1078 | + $z_axis = 300; |
|
1079 | + } |
|
1080 | + $xgiven = true; |
|
1081 | + $zgiven = false; |
|
1082 | + $title = I18N::translate('Month of first marriage'); |
|
1083 | + $xtitle = I18N::translate('month'); |
|
1084 | + $ytitle = I18N::translate('numbers'); |
|
1085 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1086 | + $xdata = $monthdata; |
|
1087 | + $xmax = 12; |
|
1088 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1089 | + calculate_legend($boundaries_z_axis); |
|
1090 | + } |
|
1091 | + $percentage = false; |
|
1092 | + if ($y_axis === 201) { |
|
1093 | + $percentage = false; |
|
1094 | + $ytitle = I18N::translate('Families'); |
|
1095 | + } elseif ($y_axis === 202) { |
|
1096 | + $percentage = true; |
|
1097 | + $ytitle = I18N::translate('percentage'); |
|
1098 | + } |
|
1099 | + $male_female = false; |
|
1100 | + if ($z_axis === 300) { |
|
1101 | + $zgiven = false; |
|
1102 | + $legend[0] = 'all'; |
|
1103 | + $zmax = 1; |
|
1104 | + $z_boundaries[0] = 100000; |
|
1105 | + } elseif ($z_axis === 301) { |
|
1106 | + $male_female = true; |
|
1107 | + $zgiven = true; |
|
1108 | + $legend[0] = I18N::translate('Male'); |
|
1109 | + $legend[1] = I18N::translate('Female'); |
|
1110 | + $zmax = 2; |
|
1111 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1112 | + } elseif ($z_axis === 302) { |
|
1113 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1114 | + } |
|
1115 | + //-- reset the data array |
|
1116 | + for ($i = 0; $i < $zmax; $i++) { |
|
1117 | + for ($j = 0; $j < $xmax; $j++) { |
|
1118 | + $ydata[$i][$j] = 0; |
|
1119 | + } |
|
1120 | + } |
|
1121 | + $total = month_of_first_marriage($z_axis, $z_boundaries, $stats); |
|
1122 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1123 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1124 | + break; |
|
1125 | 1125 | case '17': |
1126 | - $monthdata = array(); |
|
1127 | - for ($i = 0; $i < 12; ++$i) { |
|
1128 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1129 | - } |
|
1130 | - $xgiven = false; |
|
1131 | - $zgiven = false; |
|
1132 | - $title = I18N::translate('Age related to birth year'); |
|
1133 | - $xtitle = I18N::translate('age'); |
|
1134 | - $ytitle = I18N::translate('numbers'); |
|
1135 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1136 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1137 | - calculate_axis($boundaries_x_axis); |
|
1138 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1139 | - calculate_legend($boundaries_z_axis); |
|
1140 | - } |
|
1141 | - $percentage = false; |
|
1142 | - if ($y_axis === 201) { |
|
1143 | - $percentage = false; |
|
1144 | - $ytitle = I18N::translate('Individuals'); |
|
1145 | - } elseif ($y_axis === 202) { |
|
1146 | - $percentage = true; |
|
1147 | - $ytitle = I18N::translate('percentage'); |
|
1148 | - } |
|
1149 | - $male_female = false; |
|
1150 | - if ($z_axis === 300) { |
|
1151 | - $zgiven = false; |
|
1152 | - $legend[0] = 'all'; |
|
1153 | - $zmax = 1; |
|
1154 | - $z_boundaries[0] = 100000; |
|
1155 | - } elseif ($z_axis === 301) { |
|
1156 | - $male_female = true; |
|
1157 | - $zgiven = true; |
|
1158 | - $legend[0] = I18N::translate('Male'); |
|
1159 | - $legend[1] = I18N::translate('Female'); |
|
1160 | - $zmax = 2; |
|
1161 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1162 | - } elseif ($z_axis === 302) { |
|
1163 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1164 | - } |
|
1165 | - //-- reset the data array |
|
1166 | - for ($i = 0; $i < $zmax; $i++) { |
|
1167 | - for ($j = 0; $j < $xmax; $j++) { |
|
1168 | - $ydata[$i][$j] = 0; |
|
1169 | - } |
|
1170 | - } |
|
1171 | - $total = lifespan_by_birth_year($z_axis, $z_boundaries, $stats); |
|
1172 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1173 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1174 | - break; |
|
1126 | + $monthdata = array(); |
|
1127 | + for ($i = 0; $i < 12; ++$i) { |
|
1128 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1129 | + } |
|
1130 | + $xgiven = false; |
|
1131 | + $zgiven = false; |
|
1132 | + $title = I18N::translate('Age related to birth year'); |
|
1133 | + $xtitle = I18N::translate('age'); |
|
1134 | + $ytitle = I18N::translate('numbers'); |
|
1135 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1136 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1137 | + calculate_axis($boundaries_x_axis); |
|
1138 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1139 | + calculate_legend($boundaries_z_axis); |
|
1140 | + } |
|
1141 | + $percentage = false; |
|
1142 | + if ($y_axis === 201) { |
|
1143 | + $percentage = false; |
|
1144 | + $ytitle = I18N::translate('Individuals'); |
|
1145 | + } elseif ($y_axis === 202) { |
|
1146 | + $percentage = true; |
|
1147 | + $ytitle = I18N::translate('percentage'); |
|
1148 | + } |
|
1149 | + $male_female = false; |
|
1150 | + if ($z_axis === 300) { |
|
1151 | + $zgiven = false; |
|
1152 | + $legend[0] = 'all'; |
|
1153 | + $zmax = 1; |
|
1154 | + $z_boundaries[0] = 100000; |
|
1155 | + } elseif ($z_axis === 301) { |
|
1156 | + $male_female = true; |
|
1157 | + $zgiven = true; |
|
1158 | + $legend[0] = I18N::translate('Male'); |
|
1159 | + $legend[1] = I18N::translate('Female'); |
|
1160 | + $zmax = 2; |
|
1161 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1162 | + } elseif ($z_axis === 302) { |
|
1163 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1164 | + } |
|
1165 | + //-- reset the data array |
|
1166 | + for ($i = 0; $i < $zmax; $i++) { |
|
1167 | + for ($j = 0; $j < $xmax; $j++) { |
|
1168 | + $ydata[$i][$j] = 0; |
|
1169 | + } |
|
1170 | + } |
|
1171 | + $total = lifespan_by_birth_year($z_axis, $z_boundaries, $stats); |
|
1172 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1173 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1174 | + break; |
|
1175 | 1175 | case '18': |
1176 | - $monthdata = array(); |
|
1177 | - for ($i = 0; $i < 12; ++$i) { |
|
1178 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1179 | - } |
|
1180 | - $xgiven = false; |
|
1181 | - $zgiven = false; |
|
1182 | - $title = I18N::translate('Age related to death year'); |
|
1183 | - $xtitle = I18N::translate('age'); |
|
1184 | - $ytitle = I18N::translate('numbers'); |
|
1185 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1186 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1187 | - calculate_axis($boundaries_x_axis); |
|
1188 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1189 | - calculate_legend($boundaries_z_axis); |
|
1190 | - } |
|
1191 | - $percentage = false; |
|
1192 | - if ($y_axis === 201) { |
|
1193 | - $percentage = false; |
|
1194 | - $ytitle = I18N::translate('Individuals'); |
|
1195 | - } elseif ($y_axis === 202) { |
|
1196 | - $percentage = true; |
|
1197 | - $ytitle = I18N::translate('percentage'); |
|
1198 | - } |
|
1199 | - $male_female = false; |
|
1200 | - if ($z_axis === 300) { |
|
1201 | - $zgiven = false; |
|
1202 | - $legend[0] = 'all'; |
|
1203 | - $zmax = 1; |
|
1204 | - $z_boundaries[0] = 100000; |
|
1205 | - } elseif ($z_axis === 301) { |
|
1206 | - $male_female = true; |
|
1207 | - $zgiven = true; |
|
1208 | - $legend[0] = I18N::translate('Male'); |
|
1209 | - $legend[1] = I18N::translate('Female'); |
|
1210 | - $zmax = 2; |
|
1211 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1212 | - } elseif ($z_axis === 302) { |
|
1213 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1214 | - } |
|
1215 | - //-- reset the data array |
|
1216 | - for ($i = 0; $i < $zmax; $i++) { |
|
1217 | - for ($j = 0; $j < $xmax; $j++) { |
|
1218 | - $ydata[$i][$j] = 0; |
|
1219 | - } |
|
1220 | - } |
|
1221 | - $total = lifespan_by_death_year($z_axis, $z_boundaries, $stats); |
|
1222 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1223 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1224 | - break; |
|
1176 | + $monthdata = array(); |
|
1177 | + for ($i = 0; $i < 12; ++$i) { |
|
1178 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1179 | + } |
|
1180 | + $xgiven = false; |
|
1181 | + $zgiven = false; |
|
1182 | + $title = I18N::translate('Age related to death year'); |
|
1183 | + $xtitle = I18N::translate('age'); |
|
1184 | + $ytitle = I18N::translate('numbers'); |
|
1185 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1186 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1187 | + calculate_axis($boundaries_x_axis); |
|
1188 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1189 | + calculate_legend($boundaries_z_axis); |
|
1190 | + } |
|
1191 | + $percentage = false; |
|
1192 | + if ($y_axis === 201) { |
|
1193 | + $percentage = false; |
|
1194 | + $ytitle = I18N::translate('Individuals'); |
|
1195 | + } elseif ($y_axis === 202) { |
|
1196 | + $percentage = true; |
|
1197 | + $ytitle = I18N::translate('percentage'); |
|
1198 | + } |
|
1199 | + $male_female = false; |
|
1200 | + if ($z_axis === 300) { |
|
1201 | + $zgiven = false; |
|
1202 | + $legend[0] = 'all'; |
|
1203 | + $zmax = 1; |
|
1204 | + $z_boundaries[0] = 100000; |
|
1205 | + } elseif ($z_axis === 301) { |
|
1206 | + $male_female = true; |
|
1207 | + $zgiven = true; |
|
1208 | + $legend[0] = I18N::translate('Male'); |
|
1209 | + $legend[1] = I18N::translate('Female'); |
|
1210 | + $zmax = 2; |
|
1211 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1212 | + } elseif ($z_axis === 302) { |
|
1213 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1214 | + } |
|
1215 | + //-- reset the data array |
|
1216 | + for ($i = 0; $i < $zmax; $i++) { |
|
1217 | + for ($j = 0; $j < $xmax; $j++) { |
|
1218 | + $ydata[$i][$j] = 0; |
|
1219 | + } |
|
1220 | + } |
|
1221 | + $total = lifespan_by_death_year($z_axis, $z_boundaries, $stats); |
|
1222 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1223 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1224 | + break; |
|
1225 | 1225 | case '19': |
1226 | - $monthdata = array(); |
|
1227 | - for ($i = 0; $i < 12; ++$i) { |
|
1228 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1229 | - } |
|
1230 | - $xgiven = false; |
|
1231 | - $zgiven = false; |
|
1232 | - $title = I18N::translate('Age in year of marriage'); |
|
1233 | - $xtitle = I18N::translate('age'); |
|
1234 | - $ytitle = I18N::translate('numbers'); |
|
1235 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1236 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1237 | - calculate_axis($boundaries_x_axis); |
|
1238 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1239 | - calculate_legend($boundaries_z_axis); |
|
1240 | - } |
|
1241 | - $percentage = false; |
|
1242 | - if ($y_axis === 201) { |
|
1243 | - $percentage = false; |
|
1244 | - $ytitle = I18N::translate('Individuals'); |
|
1245 | - } elseif ($y_axis === 202) { |
|
1246 | - $percentage = true; |
|
1247 | - $ytitle = I18N::translate('percentage'); |
|
1248 | - } |
|
1249 | - $male_female = false; |
|
1250 | - $z_boundaries[0] = 100000; |
|
1251 | - if ($z_axis === 300) { |
|
1252 | - $zgiven = false; |
|
1253 | - $legend[0] = 'all'; |
|
1254 | - $zmax = 1; |
|
1255 | - } elseif ($z_axis === 301) { |
|
1256 | - $male_female = true; |
|
1257 | - $zgiven = true; |
|
1258 | - $legend[0] = I18N::translate('Male'); |
|
1259 | - $legend[1] = I18N::translate('Female'); |
|
1260 | - $zmax = 2; |
|
1261 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1262 | - } elseif ($z_axis === 302) { |
|
1263 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1264 | - } |
|
1265 | - //-- reset the data array |
|
1266 | - for ($i = 0; $i < $zmax; $i++) { |
|
1267 | - for ($j = 0; $j < $xmax; $j++) { |
|
1268 | - $ydata[$i][$j] = 0; |
|
1269 | - } |
|
1270 | - } |
|
1271 | - $total = age_at_marriage($z_axis, $z_boundaries, $stats); |
|
1272 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1273 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1274 | - break; |
|
1226 | + $monthdata = array(); |
|
1227 | + for ($i = 0; $i < 12; ++$i) { |
|
1228 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1229 | + } |
|
1230 | + $xgiven = false; |
|
1231 | + $zgiven = false; |
|
1232 | + $title = I18N::translate('Age in year of marriage'); |
|
1233 | + $xtitle = I18N::translate('age'); |
|
1234 | + $ytitle = I18N::translate('numbers'); |
|
1235 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1236 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1237 | + calculate_axis($boundaries_x_axis); |
|
1238 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1239 | + calculate_legend($boundaries_z_axis); |
|
1240 | + } |
|
1241 | + $percentage = false; |
|
1242 | + if ($y_axis === 201) { |
|
1243 | + $percentage = false; |
|
1244 | + $ytitle = I18N::translate('Individuals'); |
|
1245 | + } elseif ($y_axis === 202) { |
|
1246 | + $percentage = true; |
|
1247 | + $ytitle = I18N::translate('percentage'); |
|
1248 | + } |
|
1249 | + $male_female = false; |
|
1250 | + $z_boundaries[0] = 100000; |
|
1251 | + if ($z_axis === 300) { |
|
1252 | + $zgiven = false; |
|
1253 | + $legend[0] = 'all'; |
|
1254 | + $zmax = 1; |
|
1255 | + } elseif ($z_axis === 301) { |
|
1256 | + $male_female = true; |
|
1257 | + $zgiven = true; |
|
1258 | + $legend[0] = I18N::translate('Male'); |
|
1259 | + $legend[1] = I18N::translate('Female'); |
|
1260 | + $zmax = 2; |
|
1261 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1262 | + } elseif ($z_axis === 302) { |
|
1263 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1264 | + } |
|
1265 | + //-- reset the data array |
|
1266 | + for ($i = 0; $i < $zmax; $i++) { |
|
1267 | + for ($j = 0; $j < $xmax; $j++) { |
|
1268 | + $ydata[$i][$j] = 0; |
|
1269 | + } |
|
1270 | + } |
|
1271 | + $total = age_at_marriage($z_axis, $z_boundaries, $stats); |
|
1272 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1273 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1274 | + break; |
|
1275 | 1275 | case '20': |
1276 | - $monthdata = array(); |
|
1277 | - for ($i = 0; $i < 12; ++$i) { |
|
1278 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1279 | - } |
|
1280 | - $xgiven = false; |
|
1281 | - $zgiven = false; |
|
1282 | - $title = I18N::translate('Age in year of first marriage'); |
|
1283 | - $xtitle = I18N::translate('age'); |
|
1284 | - $ytitle = I18N::translate('numbers'); |
|
1285 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1286 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1287 | - calculate_axis($boundaries_x_axis); |
|
1288 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1289 | - calculate_legend($boundaries_z_axis); |
|
1290 | - } |
|
1291 | - $percentage = false; |
|
1292 | - if ($y_axis === 201) { |
|
1293 | - $percentage = false; |
|
1294 | - $ytitle = I18N::translate('Individuals'); |
|
1295 | - } elseif ($y_axis === 202) { |
|
1296 | - $percentage = true; |
|
1297 | - $ytitle = I18N::translate('percentage'); |
|
1298 | - } |
|
1299 | - $male_female = false; |
|
1300 | - if ($z_axis === 300) { |
|
1301 | - $zgiven = false; |
|
1302 | - $legend[0] = 'all'; |
|
1303 | - $zmax = 1; |
|
1304 | - $z_boundaries[0] = 100000; |
|
1305 | - } elseif ($z_axis === 301) { |
|
1306 | - $male_female = true; |
|
1307 | - $zgiven = true; |
|
1308 | - $legend[0] = I18N::translate('Male'); |
|
1309 | - $legend[1] = I18N::translate('Female'); |
|
1310 | - $zmax = 2; |
|
1311 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1312 | - } elseif ($z_axis === 302) { |
|
1313 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1314 | - } |
|
1315 | - //-- reset the data array |
|
1316 | - for ($i = 0; $i < $zmax; $i++) { |
|
1317 | - for ($j = 0; $j < $xmax; $j++) { |
|
1318 | - $ydata[$i][$j] = 0; |
|
1319 | - } |
|
1320 | - } |
|
1321 | - $total = age_at_first_marriage($z_axis, $z_boundaries, $stats); |
|
1322 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1323 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1324 | - break; |
|
1276 | + $monthdata = array(); |
|
1277 | + for ($i = 0; $i < 12; ++$i) { |
|
1278 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1279 | + } |
|
1280 | + $xgiven = false; |
|
1281 | + $zgiven = false; |
|
1282 | + $title = I18N::translate('Age in year of first marriage'); |
|
1283 | + $xtitle = I18N::translate('age'); |
|
1284 | + $ytitle = I18N::translate('numbers'); |
|
1285 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1286 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1287 | + calculate_axis($boundaries_x_axis); |
|
1288 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1289 | + calculate_legend($boundaries_z_axis); |
|
1290 | + } |
|
1291 | + $percentage = false; |
|
1292 | + if ($y_axis === 201) { |
|
1293 | + $percentage = false; |
|
1294 | + $ytitle = I18N::translate('Individuals'); |
|
1295 | + } elseif ($y_axis === 202) { |
|
1296 | + $percentage = true; |
|
1297 | + $ytitle = I18N::translate('percentage'); |
|
1298 | + } |
|
1299 | + $male_female = false; |
|
1300 | + if ($z_axis === 300) { |
|
1301 | + $zgiven = false; |
|
1302 | + $legend[0] = 'all'; |
|
1303 | + $zmax = 1; |
|
1304 | + $z_boundaries[0] = 100000; |
|
1305 | + } elseif ($z_axis === 301) { |
|
1306 | + $male_female = true; |
|
1307 | + $zgiven = true; |
|
1308 | + $legend[0] = I18N::translate('Male'); |
|
1309 | + $legend[1] = I18N::translate('Female'); |
|
1310 | + $zmax = 2; |
|
1311 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1312 | + } elseif ($z_axis === 302) { |
|
1313 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1314 | + } |
|
1315 | + //-- reset the data array |
|
1316 | + for ($i = 0; $i < $zmax; $i++) { |
|
1317 | + for ($j = 0; $j < $xmax; $j++) { |
|
1318 | + $ydata[$i][$j] = 0; |
|
1319 | + } |
|
1320 | + } |
|
1321 | + $total = age_at_first_marriage($z_axis, $z_boundaries, $stats); |
|
1322 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1323 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1324 | + break; |
|
1325 | 1325 | case '21': |
1326 | - $monthdata = array(); |
|
1327 | - for ($i = 0; $i < 12; ++$i) { |
|
1328 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1329 | - } |
|
1330 | - $xgiven = false; |
|
1331 | - $zgiven = false; |
|
1332 | - $title = I18N::translate('Number of children'); |
|
1333 | - $xtitle = I18N::translate('children'); |
|
1334 | - $ytitle = I18N::translate('numbers'); |
|
1335 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-numbers'); |
|
1336 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1337 | - calculate_axis($boundaries_x_axis); |
|
1338 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1339 | - calculate_legend($boundaries_z_axis); |
|
1340 | - } |
|
1341 | - $percentage = false; |
|
1342 | - if ($y_axis === 201) { |
|
1343 | - $percentage = false; |
|
1344 | - $ytitle = I18N::translate('Families'); |
|
1345 | - } elseif ($y_axis === 202) { |
|
1346 | - $percentage = true; |
|
1347 | - $ytitle = I18N::translate('percentage'); |
|
1348 | - } |
|
1349 | - $male_female = false; |
|
1350 | - if ($z_axis === 300) { |
|
1351 | - $zgiven = false; |
|
1352 | - $legend[0] = 'all'; |
|
1353 | - $zmax = 1; |
|
1354 | - $z_boundaries[0] = 100000; |
|
1355 | - } elseif ($z_axis === 301) { |
|
1356 | - $male_female = true; |
|
1357 | - $zgiven = true; |
|
1358 | - $legend[0] = I18N::translate('Male'); |
|
1359 | - $legend[1] = I18N::translate('Female'); |
|
1360 | - $zmax = 2; |
|
1361 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1362 | - } elseif ($z_axis === 302) { |
|
1363 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1364 | - } |
|
1365 | - //-- reset the data array |
|
1366 | - for ($i = 0; $i < $zmax; $i++) { |
|
1367 | - for ($j = 0; $j < $xmax; $j++) { |
|
1368 | - $ydata[$i][$j] = 0; |
|
1369 | - } |
|
1370 | - } |
|
1371 | - $total = number_of_children($z_axis, $z_boundaries, $stats); |
|
1372 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalChildren(); |
|
1373 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1374 | - break; |
|
1326 | + $monthdata = array(); |
|
1327 | + for ($i = 0; $i < 12; ++$i) { |
|
1328 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1329 | + } |
|
1330 | + $xgiven = false; |
|
1331 | + $zgiven = false; |
|
1332 | + $title = I18N::translate('Number of children'); |
|
1333 | + $xtitle = I18N::translate('children'); |
|
1334 | + $ytitle = I18N::translate('numbers'); |
|
1335 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-numbers'); |
|
1336 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1337 | + calculate_axis($boundaries_x_axis); |
|
1338 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1339 | + calculate_legend($boundaries_z_axis); |
|
1340 | + } |
|
1341 | + $percentage = false; |
|
1342 | + if ($y_axis === 201) { |
|
1343 | + $percentage = false; |
|
1344 | + $ytitle = I18N::translate('Families'); |
|
1345 | + } elseif ($y_axis === 202) { |
|
1346 | + $percentage = true; |
|
1347 | + $ytitle = I18N::translate('percentage'); |
|
1348 | + } |
|
1349 | + $male_female = false; |
|
1350 | + if ($z_axis === 300) { |
|
1351 | + $zgiven = false; |
|
1352 | + $legend[0] = 'all'; |
|
1353 | + $zmax = 1; |
|
1354 | + $z_boundaries[0] = 100000; |
|
1355 | + } elseif ($z_axis === 301) { |
|
1356 | + $male_female = true; |
|
1357 | + $zgiven = true; |
|
1358 | + $legend[0] = I18N::translate('Male'); |
|
1359 | + $legend[1] = I18N::translate('Female'); |
|
1360 | + $zmax = 2; |
|
1361 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1362 | + } elseif ($z_axis === 302) { |
|
1363 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1364 | + } |
|
1365 | + //-- reset the data array |
|
1366 | + for ($i = 0; $i < $zmax; $i++) { |
|
1367 | + for ($j = 0; $j < $xmax; $j++) { |
|
1368 | + $ydata[$i][$j] = 0; |
|
1369 | + } |
|
1370 | + } |
|
1371 | + $total = number_of_children($z_axis, $z_boundaries, $stats); |
|
1372 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalChildren(); |
|
1373 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1374 | + break; |
|
1375 | 1375 | default: |
1376 | - echo '<i class="icon-loading-large"></i>'; |
|
1377 | - break; |
|
1376 | + echo '<i class="icon-loading-large"></i>'; |
|
1377 | + break; |
|
1378 | 1378 | } |
1379 | 1379 | echo '</div>'; |
@@ -852,528 +852,528 @@ |
||
852 | 852 | echo '<div class="statistics_chart" title="', I18N::translate('Statistics chart'), '">'; |
853 | 853 | |
854 | 854 | switch ($x_axis) { |
855 | -case '1': |
|
856 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), Filter::get('chart_type'), Filter::get('SURN'))); |
|
857 | - break; |
|
858 | -case '2': |
|
859 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'birth_distribution_chart')); |
|
860 | - break; |
|
861 | -case '3': |
|
862 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'death_distribution_chart')); |
|
863 | - break; |
|
864 | -case '4': |
|
865 | - echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'marriage_distribution_chart')); |
|
866 | - break; |
|
867 | -case '11': |
|
868 | - $monthdata = array(); |
|
869 | - for ($i = 0; $i < 12; ++$i) { |
|
870 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
871 | - } |
|
872 | - $xgiven = true; |
|
873 | - $zgiven = false; |
|
874 | - $title = I18N::translate('Month of birth'); |
|
875 | - $xtitle = I18N::translate('month'); |
|
876 | - $ytitle = I18N::translate('numbers'); |
|
877 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
878 | - $xdata = $monthdata; |
|
879 | - $xmax = 12; |
|
880 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
881 | - calculate_legend($boundaries_z_axis); |
|
882 | - } |
|
883 | - $percentage = false; |
|
884 | - if ($y_axis === 201) { |
|
885 | - $percentage = false; |
|
886 | - $ytitle = I18N::translate('Individuals'); |
|
887 | - } elseif ($y_axis === 202) { |
|
888 | - $percentage = true; |
|
889 | - $ytitle = I18N::translate('percentage'); |
|
890 | - } |
|
891 | - $male_female = false; |
|
892 | - if ($z_axis === 300) { |
|
893 | - $zgiven = false; |
|
894 | - $legend[0] = 'all'; |
|
895 | - $zmax = 1; |
|
896 | - $z_boundaries[0] = 100000; |
|
897 | - } elseif ($z_axis === 301) { |
|
898 | - $male_female = true; |
|
899 | - $zgiven = true; |
|
900 | - $legend[0] = I18N::translate('Male'); |
|
901 | - $legend[1] = I18N::translate('Female'); |
|
902 | - $zmax = 2; |
|
903 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
904 | - } elseif ($z_axis === 302) { |
|
905 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
906 | - } |
|
907 | - //-- reset the data array |
|
908 | - for ($i = 0; $i < $zmax; $i++) { |
|
909 | - for ($j = 0; $j < $xmax; $j++) { |
|
910 | - $ydata[$i][$j] = 0; |
|
911 | - } |
|
912 | - } |
|
913 | - $total = month_of_birth($z_axis, $z_boundaries, $stats); |
|
914 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
915 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
916 | - break; |
|
917 | -case '12': |
|
918 | - $monthdata = array(); |
|
919 | - for ($i = 0; $i < 12; ++$i) { |
|
920 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
921 | - } |
|
922 | - $xgiven = true; |
|
923 | - $zgiven = false; |
|
924 | - $title = I18N::translate('Month of death'); |
|
925 | - $xtitle = I18N::translate('month'); |
|
926 | - $ytitle = I18N::translate('numbers'); |
|
927 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
928 | - $xdata = $monthdata; |
|
929 | - $xmax = 12; |
|
930 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
931 | - calculate_legend($boundaries_z_axis); |
|
932 | - } |
|
933 | - $percentage = false; |
|
934 | - if ($y_axis === 201) { |
|
935 | - $percentage = false; |
|
936 | - $ytitle = I18N::translate('Individuals'); |
|
937 | - } elseif ($y_axis === 202) { |
|
938 | - $percentage = true; |
|
939 | - $ytitle = I18N::translate('percentage'); |
|
940 | - } |
|
941 | - $male_female = false; |
|
942 | - if ($z_axis === 300) { |
|
943 | - $zgiven = false; |
|
944 | - $legend[0] = 'all'; |
|
945 | - $zmax = 1; |
|
946 | - $z_boundaries[0] = 100000; |
|
947 | - } elseif ($z_axis === 301) { |
|
948 | - $male_female = true; |
|
949 | - $zgiven = true; |
|
950 | - $legend[0] = I18N::translate('Male'); |
|
951 | - $legend[1] = I18N::translate('Female'); |
|
952 | - $zmax = 2; |
|
953 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
954 | - } elseif ($z_axis === 302) { |
|
955 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
956 | - } |
|
957 | - //-- reset the data array |
|
958 | - for ($i = 0; $i < $zmax; $i++) { |
|
959 | - for ($j = 0; $j < $xmax; $j++) { |
|
960 | - $ydata[$i][$j] = 0; |
|
961 | - } |
|
962 | - } |
|
963 | - $total = month_of_death($z_axis, $z_boundaries, $stats); |
|
964 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
965 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
966 | - break; |
|
967 | -case '13': |
|
968 | - $monthdata = array(); |
|
969 | - for ($i = 0; $i < 12; ++$i) { |
|
970 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
971 | - } |
|
855 | + case '1': |
|
856 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), Filter::get('chart_type'), Filter::get('SURN'))); |
|
857 | + break; |
|
858 | + case '2': |
|
859 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'birth_distribution_chart')); |
|
860 | + break; |
|
861 | + case '3': |
|
862 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'death_distribution_chart')); |
|
863 | + break; |
|
864 | + case '4': |
|
865 | + echo $stats->chartDistribution(array(Filter::get('chart_shows'), 'marriage_distribution_chart')); |
|
866 | + break; |
|
867 | + case '11': |
|
868 | + $monthdata = array(); |
|
869 | + for ($i = 0; $i < 12; ++$i) { |
|
870 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
871 | + } |
|
872 | + $xgiven = true; |
|
873 | + $zgiven = false; |
|
874 | + $title = I18N::translate('Month of birth'); |
|
875 | + $xtitle = I18N::translate('month'); |
|
876 | + $ytitle = I18N::translate('numbers'); |
|
877 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
878 | + $xdata = $monthdata; |
|
879 | + $xmax = 12; |
|
880 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
881 | + calculate_legend($boundaries_z_axis); |
|
882 | + } |
|
883 | + $percentage = false; |
|
884 | + if ($y_axis === 201) { |
|
885 | + $percentage = false; |
|
886 | + $ytitle = I18N::translate('Individuals'); |
|
887 | + } elseif ($y_axis === 202) { |
|
888 | + $percentage = true; |
|
889 | + $ytitle = I18N::translate('percentage'); |
|
890 | + } |
|
891 | + $male_female = false; |
|
892 | + if ($z_axis === 300) { |
|
893 | + $zgiven = false; |
|
894 | + $legend[0] = 'all'; |
|
895 | + $zmax = 1; |
|
896 | + $z_boundaries[0] = 100000; |
|
897 | + } elseif ($z_axis === 301) { |
|
898 | + $male_female = true; |
|
899 | + $zgiven = true; |
|
900 | + $legend[0] = I18N::translate('Male'); |
|
901 | + $legend[1] = I18N::translate('Female'); |
|
902 | + $zmax = 2; |
|
903 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
904 | + } elseif ($z_axis === 302) { |
|
905 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
906 | + } |
|
907 | + //-- reset the data array |
|
908 | + for ($i = 0; $i < $zmax; $i++) { |
|
909 | + for ($j = 0; $j < $xmax; $j++) { |
|
910 | + $ydata[$i][$j] = 0; |
|
911 | + } |
|
912 | + } |
|
913 | + $total = month_of_birth($z_axis, $z_boundaries, $stats); |
|
914 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
915 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
916 | + break; |
|
917 | + case '12': |
|
918 | + $monthdata = array(); |
|
919 | + for ($i = 0; $i < 12; ++$i) { |
|
920 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
921 | + } |
|
922 | + $xgiven = true; |
|
923 | + $zgiven = false; |
|
924 | + $title = I18N::translate('Month of death'); |
|
925 | + $xtitle = I18N::translate('month'); |
|
926 | + $ytitle = I18N::translate('numbers'); |
|
927 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
928 | + $xdata = $monthdata; |
|
929 | + $xmax = 12; |
|
930 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
931 | + calculate_legend($boundaries_z_axis); |
|
932 | + } |
|
933 | + $percentage = false; |
|
934 | + if ($y_axis === 201) { |
|
935 | + $percentage = false; |
|
936 | + $ytitle = I18N::translate('Individuals'); |
|
937 | + } elseif ($y_axis === 202) { |
|
938 | + $percentage = true; |
|
939 | + $ytitle = I18N::translate('percentage'); |
|
940 | + } |
|
941 | + $male_female = false; |
|
942 | + if ($z_axis === 300) { |
|
943 | + $zgiven = false; |
|
944 | + $legend[0] = 'all'; |
|
945 | + $zmax = 1; |
|
946 | + $z_boundaries[0] = 100000; |
|
947 | + } elseif ($z_axis === 301) { |
|
948 | + $male_female = true; |
|
949 | + $zgiven = true; |
|
950 | + $legend[0] = I18N::translate('Male'); |
|
951 | + $legend[1] = I18N::translate('Female'); |
|
952 | + $zmax = 2; |
|
953 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
954 | + } elseif ($z_axis === 302) { |
|
955 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
956 | + } |
|
957 | + //-- reset the data array |
|
958 | + for ($i = 0; $i < $zmax; $i++) { |
|
959 | + for ($j = 0; $j < $xmax; $j++) { |
|
960 | + $ydata[$i][$j] = 0; |
|
961 | + } |
|
962 | + } |
|
963 | + $total = month_of_death($z_axis, $z_boundaries, $stats); |
|
964 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
965 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
966 | + break; |
|
967 | + case '13': |
|
968 | + $monthdata = array(); |
|
969 | + for ($i = 0; $i < 12; ++$i) { |
|
970 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
971 | + } |
|
972 | 972 | |
973 | - if ($z_axis === 301) { |
|
974 | - $z_axis = 300; |
|
975 | - } |
|
976 | - $xgiven = true; |
|
977 | - $zgiven = false; |
|
978 | - $title = I18N::translate('Month of marriage'); |
|
979 | - $xtitle = I18N::translate('month'); |
|
980 | - $ytitle = I18N::translate('numbers'); |
|
981 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
982 | - $xdata = $monthdata; |
|
983 | - $xmax = 12; |
|
984 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
985 | - calculate_legend($boundaries_z_axis); |
|
986 | - } |
|
987 | - $percentage = false; |
|
988 | - if ($y_axis === 201) { |
|
989 | - $percentage = false; |
|
990 | - $ytitle = I18N::translate('Families'); |
|
991 | - } elseif ($y_axis === 202) { |
|
992 | - $percentage = true; |
|
993 | - $ytitle = I18N::translate('percentage'); |
|
994 | - } |
|
995 | - $male_female = false; |
|
996 | - if ($z_axis === 300) { |
|
997 | - $zgiven = false; |
|
998 | - $legend[0] = 'all'; |
|
999 | - $zmax = 1; |
|
1000 | - $z_boundaries[0] = 100000; |
|
1001 | - } elseif ($z_axis === 301) { |
|
1002 | - $male_female = true; |
|
1003 | - $zgiven = true; |
|
1004 | - $legend[0] = I18N::translate('Male'); |
|
1005 | - $legend[1] = I18N::translate('Female'); |
|
1006 | - $zmax = 2; |
|
1007 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1008 | - } elseif ($z_axis === 302) { |
|
1009 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1010 | - } |
|
1011 | - //-- reset the data array |
|
1012 | - for ($i = 0; $i < $zmax; $i++) { |
|
1013 | - for ($j = 0; $j < $xmax; $j++) { |
|
1014 | - $ydata[$i][$j] = 0; |
|
1015 | - } |
|
1016 | - } |
|
1017 | - $total = month_of_marriage($z_axis, $z_boundaries, $stats); |
|
1018 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1019 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1020 | - break; |
|
1021 | -case '14': |
|
1022 | - $monthdata = array(); |
|
1023 | - for ($i = 0; $i < 12; ++$i) { |
|
1024 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1025 | - } |
|
1026 | - $xgiven = true; |
|
1027 | - $zgiven = false; |
|
1028 | - $title = I18N::translate('Month of birth of first child in a relation'); |
|
1029 | - $xtitle = I18N::translate('month'); |
|
1030 | - $ytitle = I18N::translate('numbers'); |
|
1031 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1032 | - $xdata = $monthdata; |
|
1033 | - $xmax = 12; |
|
1034 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1035 | - calculate_legend($boundaries_z_axis); |
|
1036 | - } |
|
1037 | - $percentage = false; |
|
1038 | - if ($y_axis === 201) { |
|
1039 | - $percentage = false; |
|
1040 | - $ytitle = I18N::translate('Children'); |
|
1041 | - } elseif ($y_axis === 202) { |
|
1042 | - $percentage = true; |
|
1043 | - $ytitle = I18N::translate('percentage'); |
|
1044 | - } |
|
1045 | - $male_female = false; |
|
1046 | - if ($z_axis === 300) { |
|
1047 | - $zgiven = false; |
|
1048 | - $legend[0] = 'all'; |
|
1049 | - $zmax = 1; |
|
1050 | - $z_boundaries[0] = 100000; |
|
1051 | - } elseif ($z_axis === 301) { |
|
1052 | - $male_female = true; |
|
1053 | - $zgiven = true; |
|
1054 | - $legend[0] = I18N::translate('Male'); |
|
1055 | - $legend[1] = I18N::translate('Female'); |
|
1056 | - $zmax = 2; |
|
1057 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1058 | - } elseif ($z_axis === 302) { |
|
1059 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1060 | - } |
|
1061 | - //-- reset the data array |
|
1062 | - for ($i = 0; $i < $zmax; $i++) { |
|
1063 | - for ($j = 0; $j < $xmax; $j++) { |
|
1064 | - $ydata[$i][$j] = 0; |
|
1065 | - } |
|
1066 | - } |
|
1067 | - $total = month_of_birth_of_first_child($z_axis, $z_boundaries, $stats); |
|
1068 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1069 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1070 | - break; |
|
1071 | -case '15': |
|
1072 | - $monthdata = array(); |
|
1073 | - for ($i = 0; $i < 12; ++$i) { |
|
1074 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1075 | - } |
|
973 | + if ($z_axis === 301) { |
|
974 | + $z_axis = 300; |
|
975 | + } |
|
976 | + $xgiven = true; |
|
977 | + $zgiven = false; |
|
978 | + $title = I18N::translate('Month of marriage'); |
|
979 | + $xtitle = I18N::translate('month'); |
|
980 | + $ytitle = I18N::translate('numbers'); |
|
981 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
982 | + $xdata = $monthdata; |
|
983 | + $xmax = 12; |
|
984 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
985 | + calculate_legend($boundaries_z_axis); |
|
986 | + } |
|
987 | + $percentage = false; |
|
988 | + if ($y_axis === 201) { |
|
989 | + $percentage = false; |
|
990 | + $ytitle = I18N::translate('Families'); |
|
991 | + } elseif ($y_axis === 202) { |
|
992 | + $percentage = true; |
|
993 | + $ytitle = I18N::translate('percentage'); |
|
994 | + } |
|
995 | + $male_female = false; |
|
996 | + if ($z_axis === 300) { |
|
997 | + $zgiven = false; |
|
998 | + $legend[0] = 'all'; |
|
999 | + $zmax = 1; |
|
1000 | + $z_boundaries[0] = 100000; |
|
1001 | + } elseif ($z_axis === 301) { |
|
1002 | + $male_female = true; |
|
1003 | + $zgiven = true; |
|
1004 | + $legend[0] = I18N::translate('Male'); |
|
1005 | + $legend[1] = I18N::translate('Female'); |
|
1006 | + $zmax = 2; |
|
1007 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1008 | + } elseif ($z_axis === 302) { |
|
1009 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1010 | + } |
|
1011 | + //-- reset the data array |
|
1012 | + for ($i = 0; $i < $zmax; $i++) { |
|
1013 | + for ($j = 0; $j < $xmax; $j++) { |
|
1014 | + $ydata[$i][$j] = 0; |
|
1015 | + } |
|
1016 | + } |
|
1017 | + $total = month_of_marriage($z_axis, $z_boundaries, $stats); |
|
1018 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1019 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1020 | + break; |
|
1021 | + case '14': |
|
1022 | + $monthdata = array(); |
|
1023 | + for ($i = 0; $i < 12; ++$i) { |
|
1024 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1025 | + } |
|
1026 | + $xgiven = true; |
|
1027 | + $zgiven = false; |
|
1028 | + $title = I18N::translate('Month of birth of first child in a relation'); |
|
1029 | + $xtitle = I18N::translate('month'); |
|
1030 | + $ytitle = I18N::translate('numbers'); |
|
1031 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1032 | + $xdata = $monthdata; |
|
1033 | + $xmax = 12; |
|
1034 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1035 | + calculate_legend($boundaries_z_axis); |
|
1036 | + } |
|
1037 | + $percentage = false; |
|
1038 | + if ($y_axis === 201) { |
|
1039 | + $percentage = false; |
|
1040 | + $ytitle = I18N::translate('Children'); |
|
1041 | + } elseif ($y_axis === 202) { |
|
1042 | + $percentage = true; |
|
1043 | + $ytitle = I18N::translate('percentage'); |
|
1044 | + } |
|
1045 | + $male_female = false; |
|
1046 | + if ($z_axis === 300) { |
|
1047 | + $zgiven = false; |
|
1048 | + $legend[0] = 'all'; |
|
1049 | + $zmax = 1; |
|
1050 | + $z_boundaries[0] = 100000; |
|
1051 | + } elseif ($z_axis === 301) { |
|
1052 | + $male_female = true; |
|
1053 | + $zgiven = true; |
|
1054 | + $legend[0] = I18N::translate('Male'); |
|
1055 | + $legend[1] = I18N::translate('Female'); |
|
1056 | + $zmax = 2; |
|
1057 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1058 | + } elseif ($z_axis === 302) { |
|
1059 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1060 | + } |
|
1061 | + //-- reset the data array |
|
1062 | + for ($i = 0; $i < $zmax; $i++) { |
|
1063 | + for ($j = 0; $j < $xmax; $j++) { |
|
1064 | + $ydata[$i][$j] = 0; |
|
1065 | + } |
|
1066 | + } |
|
1067 | + $total = month_of_birth_of_first_child($z_axis, $z_boundaries, $stats); |
|
1068 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1069 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1070 | + break; |
|
1071 | + case '15': |
|
1072 | + $monthdata = array(); |
|
1073 | + for ($i = 0; $i < 12; ++$i) { |
|
1074 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1075 | + } |
|
1076 | 1076 | |
1077 | - if ($z_axis === 301) { |
|
1078 | - $z_axis = 300; |
|
1079 | - } |
|
1080 | - $xgiven = true; |
|
1081 | - $zgiven = false; |
|
1082 | - $title = I18N::translate('Month of first marriage'); |
|
1083 | - $xtitle = I18N::translate('month'); |
|
1084 | - $ytitle = I18N::translate('numbers'); |
|
1085 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1086 | - $xdata = $monthdata; |
|
1087 | - $xmax = 12; |
|
1088 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1089 | - calculate_legend($boundaries_z_axis); |
|
1090 | - } |
|
1091 | - $percentage = false; |
|
1092 | - if ($y_axis === 201) { |
|
1093 | - $percentage = false; |
|
1094 | - $ytitle = I18N::translate('Families'); |
|
1095 | - } elseif ($y_axis === 202) { |
|
1096 | - $percentage = true; |
|
1097 | - $ytitle = I18N::translate('percentage'); |
|
1098 | - } |
|
1099 | - $male_female = false; |
|
1100 | - if ($z_axis === 300) { |
|
1101 | - $zgiven = false; |
|
1102 | - $legend[0] = 'all'; |
|
1103 | - $zmax = 1; |
|
1104 | - $z_boundaries[0] = 100000; |
|
1105 | - } elseif ($z_axis === 301) { |
|
1106 | - $male_female = true; |
|
1107 | - $zgiven = true; |
|
1108 | - $legend[0] = I18N::translate('Male'); |
|
1109 | - $legend[1] = I18N::translate('Female'); |
|
1110 | - $zmax = 2; |
|
1111 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1112 | - } elseif ($z_axis === 302) { |
|
1113 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1114 | - } |
|
1115 | - //-- reset the data array |
|
1116 | - for ($i = 0; $i < $zmax; $i++) { |
|
1117 | - for ($j = 0; $j < $xmax; $j++) { |
|
1118 | - $ydata[$i][$j] = 0; |
|
1119 | - } |
|
1120 | - } |
|
1121 | - $total = month_of_first_marriage($z_axis, $z_boundaries, $stats); |
|
1122 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1123 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1124 | - break; |
|
1125 | -case '17': |
|
1126 | - $monthdata = array(); |
|
1127 | - for ($i = 0; $i < 12; ++$i) { |
|
1128 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1129 | - } |
|
1130 | - $xgiven = false; |
|
1131 | - $zgiven = false; |
|
1132 | - $title = I18N::translate('Age related to birth year'); |
|
1133 | - $xtitle = I18N::translate('age'); |
|
1134 | - $ytitle = I18N::translate('numbers'); |
|
1135 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1136 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1137 | - calculate_axis($boundaries_x_axis); |
|
1138 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1139 | - calculate_legend($boundaries_z_axis); |
|
1140 | - } |
|
1141 | - $percentage = false; |
|
1142 | - if ($y_axis === 201) { |
|
1143 | - $percentage = false; |
|
1144 | - $ytitle = I18N::translate('Individuals'); |
|
1145 | - } elseif ($y_axis === 202) { |
|
1146 | - $percentage = true; |
|
1147 | - $ytitle = I18N::translate('percentage'); |
|
1148 | - } |
|
1149 | - $male_female = false; |
|
1150 | - if ($z_axis === 300) { |
|
1151 | - $zgiven = false; |
|
1152 | - $legend[0] = 'all'; |
|
1153 | - $zmax = 1; |
|
1154 | - $z_boundaries[0] = 100000; |
|
1155 | - } elseif ($z_axis === 301) { |
|
1156 | - $male_female = true; |
|
1157 | - $zgiven = true; |
|
1158 | - $legend[0] = I18N::translate('Male'); |
|
1159 | - $legend[1] = I18N::translate('Female'); |
|
1160 | - $zmax = 2; |
|
1161 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1162 | - } elseif ($z_axis === 302) { |
|
1163 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1164 | - } |
|
1165 | - //-- reset the data array |
|
1166 | - for ($i = 0; $i < $zmax; $i++) { |
|
1167 | - for ($j = 0; $j < $xmax; $j++) { |
|
1168 | - $ydata[$i][$j] = 0; |
|
1169 | - } |
|
1170 | - } |
|
1171 | - $total = lifespan_by_birth_year($z_axis, $z_boundaries, $stats); |
|
1172 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1173 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1174 | - break; |
|
1175 | -case '18': |
|
1176 | - $monthdata = array(); |
|
1177 | - for ($i = 0; $i < 12; ++$i) { |
|
1178 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1179 | - } |
|
1180 | - $xgiven = false; |
|
1181 | - $zgiven = false; |
|
1182 | - $title = I18N::translate('Age related to death year'); |
|
1183 | - $xtitle = I18N::translate('age'); |
|
1184 | - $ytitle = I18N::translate('numbers'); |
|
1185 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1186 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1187 | - calculate_axis($boundaries_x_axis); |
|
1188 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1189 | - calculate_legend($boundaries_z_axis); |
|
1190 | - } |
|
1191 | - $percentage = false; |
|
1192 | - if ($y_axis === 201) { |
|
1193 | - $percentage = false; |
|
1194 | - $ytitle = I18N::translate('Individuals'); |
|
1195 | - } elseif ($y_axis === 202) { |
|
1196 | - $percentage = true; |
|
1197 | - $ytitle = I18N::translate('percentage'); |
|
1198 | - } |
|
1199 | - $male_female = false; |
|
1200 | - if ($z_axis === 300) { |
|
1201 | - $zgiven = false; |
|
1202 | - $legend[0] = 'all'; |
|
1203 | - $zmax = 1; |
|
1204 | - $z_boundaries[0] = 100000; |
|
1205 | - } elseif ($z_axis === 301) { |
|
1206 | - $male_female = true; |
|
1207 | - $zgiven = true; |
|
1208 | - $legend[0] = I18N::translate('Male'); |
|
1209 | - $legend[1] = I18N::translate('Female'); |
|
1210 | - $zmax = 2; |
|
1211 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1212 | - } elseif ($z_axis === 302) { |
|
1213 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1214 | - } |
|
1215 | - //-- reset the data array |
|
1216 | - for ($i = 0; $i < $zmax; $i++) { |
|
1217 | - for ($j = 0; $j < $xmax; $j++) { |
|
1218 | - $ydata[$i][$j] = 0; |
|
1219 | - } |
|
1220 | - } |
|
1221 | - $total = lifespan_by_death_year($z_axis, $z_boundaries, $stats); |
|
1222 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1223 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1224 | - break; |
|
1225 | -case '19': |
|
1226 | - $monthdata = array(); |
|
1227 | - for ($i = 0; $i < 12; ++$i) { |
|
1228 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1229 | - } |
|
1230 | - $xgiven = false; |
|
1231 | - $zgiven = false; |
|
1232 | - $title = I18N::translate('Age in year of marriage'); |
|
1233 | - $xtitle = I18N::translate('age'); |
|
1234 | - $ytitle = I18N::translate('numbers'); |
|
1235 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1236 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1237 | - calculate_axis($boundaries_x_axis); |
|
1238 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1239 | - calculate_legend($boundaries_z_axis); |
|
1240 | - } |
|
1241 | - $percentage = false; |
|
1242 | - if ($y_axis === 201) { |
|
1243 | - $percentage = false; |
|
1244 | - $ytitle = I18N::translate('Individuals'); |
|
1245 | - } elseif ($y_axis === 202) { |
|
1246 | - $percentage = true; |
|
1247 | - $ytitle = I18N::translate('percentage'); |
|
1248 | - } |
|
1249 | - $male_female = false; |
|
1250 | - $z_boundaries[0] = 100000; |
|
1251 | - if ($z_axis === 300) { |
|
1252 | - $zgiven = false; |
|
1253 | - $legend[0] = 'all'; |
|
1254 | - $zmax = 1; |
|
1255 | - } elseif ($z_axis === 301) { |
|
1256 | - $male_female = true; |
|
1257 | - $zgiven = true; |
|
1258 | - $legend[0] = I18N::translate('Male'); |
|
1259 | - $legend[1] = I18N::translate('Female'); |
|
1260 | - $zmax = 2; |
|
1261 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1262 | - } elseif ($z_axis === 302) { |
|
1263 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1264 | - } |
|
1265 | - //-- reset the data array |
|
1266 | - for ($i = 0; $i < $zmax; $i++) { |
|
1267 | - for ($j = 0; $j < $xmax; $j++) { |
|
1268 | - $ydata[$i][$j] = 0; |
|
1269 | - } |
|
1270 | - } |
|
1271 | - $total = age_at_marriage($z_axis, $z_boundaries, $stats); |
|
1272 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1273 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1274 | - break; |
|
1275 | -case '20': |
|
1276 | - $monthdata = array(); |
|
1277 | - for ($i = 0; $i < 12; ++$i) { |
|
1278 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1279 | - } |
|
1280 | - $xgiven = false; |
|
1281 | - $zgiven = false; |
|
1282 | - $title = I18N::translate('Age in year of first marriage'); |
|
1283 | - $xtitle = I18N::translate('age'); |
|
1284 | - $ytitle = I18N::translate('numbers'); |
|
1285 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1286 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1287 | - calculate_axis($boundaries_x_axis); |
|
1288 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1289 | - calculate_legend($boundaries_z_axis); |
|
1290 | - } |
|
1291 | - $percentage = false; |
|
1292 | - if ($y_axis === 201) { |
|
1293 | - $percentage = false; |
|
1294 | - $ytitle = I18N::translate('Individuals'); |
|
1295 | - } elseif ($y_axis === 202) { |
|
1296 | - $percentage = true; |
|
1297 | - $ytitle = I18N::translate('percentage'); |
|
1298 | - } |
|
1299 | - $male_female = false; |
|
1300 | - if ($z_axis === 300) { |
|
1301 | - $zgiven = false; |
|
1302 | - $legend[0] = 'all'; |
|
1303 | - $zmax = 1; |
|
1304 | - $z_boundaries[0] = 100000; |
|
1305 | - } elseif ($z_axis === 301) { |
|
1306 | - $male_female = true; |
|
1307 | - $zgiven = true; |
|
1308 | - $legend[0] = I18N::translate('Male'); |
|
1309 | - $legend[1] = I18N::translate('Female'); |
|
1310 | - $zmax = 2; |
|
1311 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1312 | - } elseif ($z_axis === 302) { |
|
1313 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1314 | - } |
|
1315 | - //-- reset the data array |
|
1316 | - for ($i = 0; $i < $zmax; $i++) { |
|
1317 | - for ($j = 0; $j < $xmax; $j++) { |
|
1318 | - $ydata[$i][$j] = 0; |
|
1319 | - } |
|
1320 | - } |
|
1321 | - $total = age_at_first_marriage($z_axis, $z_boundaries, $stats); |
|
1322 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1323 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1324 | - break; |
|
1325 | -case '21': |
|
1326 | - $monthdata = array(); |
|
1327 | - for ($i = 0; $i < 12; ++$i) { |
|
1328 | - $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1329 | - } |
|
1330 | - $xgiven = false; |
|
1331 | - $zgiven = false; |
|
1332 | - $title = I18N::translate('Number of children'); |
|
1333 | - $xtitle = I18N::translate('children'); |
|
1334 | - $ytitle = I18N::translate('numbers'); |
|
1335 | - $boundaries_x_axis = Filter::get('x-axis-boundaries-numbers'); |
|
1336 | - $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1337 | - calculate_axis($boundaries_x_axis); |
|
1338 | - if ($z_axis !== 300 && $z_axis !== 301) { |
|
1339 | - calculate_legend($boundaries_z_axis); |
|
1340 | - } |
|
1341 | - $percentage = false; |
|
1342 | - if ($y_axis === 201) { |
|
1343 | - $percentage = false; |
|
1344 | - $ytitle = I18N::translate('Families'); |
|
1345 | - } elseif ($y_axis === 202) { |
|
1346 | - $percentage = true; |
|
1347 | - $ytitle = I18N::translate('percentage'); |
|
1348 | - } |
|
1349 | - $male_female = false; |
|
1350 | - if ($z_axis === 300) { |
|
1351 | - $zgiven = false; |
|
1352 | - $legend[0] = 'all'; |
|
1353 | - $zmax = 1; |
|
1354 | - $z_boundaries[0] = 100000; |
|
1355 | - } elseif ($z_axis === 301) { |
|
1356 | - $male_female = true; |
|
1357 | - $zgiven = true; |
|
1358 | - $legend[0] = I18N::translate('Male'); |
|
1359 | - $legend[1] = I18N::translate('Female'); |
|
1360 | - $zmax = 2; |
|
1361 | - $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1362 | - } elseif ($z_axis === 302) { |
|
1363 | - $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1364 | - } |
|
1365 | - //-- reset the data array |
|
1366 | - for ($i = 0; $i < $zmax; $i++) { |
|
1367 | - for ($j = 0; $j < $xmax; $j++) { |
|
1368 | - $ydata[$i][$j] = 0; |
|
1369 | - } |
|
1370 | - } |
|
1371 | - $total = number_of_children($z_axis, $z_boundaries, $stats); |
|
1372 | - $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalChildren(); |
|
1373 | - my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1374 | - break; |
|
1375 | -default: |
|
1376 | - echo '<i class="icon-loading-large"></i>'; |
|
1377 | - break; |
|
1077 | + if ($z_axis === 301) { |
|
1078 | + $z_axis = 300; |
|
1079 | + } |
|
1080 | + $xgiven = true; |
|
1081 | + $zgiven = false; |
|
1082 | + $title = I18N::translate('Month of first marriage'); |
|
1083 | + $xtitle = I18N::translate('month'); |
|
1084 | + $ytitle = I18N::translate('numbers'); |
|
1085 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1086 | + $xdata = $monthdata; |
|
1087 | + $xmax = 12; |
|
1088 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1089 | + calculate_legend($boundaries_z_axis); |
|
1090 | + } |
|
1091 | + $percentage = false; |
|
1092 | + if ($y_axis === 201) { |
|
1093 | + $percentage = false; |
|
1094 | + $ytitle = I18N::translate('Families'); |
|
1095 | + } elseif ($y_axis === 202) { |
|
1096 | + $percentage = true; |
|
1097 | + $ytitle = I18N::translate('percentage'); |
|
1098 | + } |
|
1099 | + $male_female = false; |
|
1100 | + if ($z_axis === 300) { |
|
1101 | + $zgiven = false; |
|
1102 | + $legend[0] = 'all'; |
|
1103 | + $zmax = 1; |
|
1104 | + $z_boundaries[0] = 100000; |
|
1105 | + } elseif ($z_axis === 301) { |
|
1106 | + $male_female = true; |
|
1107 | + $zgiven = true; |
|
1108 | + $legend[0] = I18N::translate('Male'); |
|
1109 | + $legend[1] = I18N::translate('Female'); |
|
1110 | + $zmax = 2; |
|
1111 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1112 | + } elseif ($z_axis === 302) { |
|
1113 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1114 | + } |
|
1115 | + //-- reset the data array |
|
1116 | + for ($i = 0; $i < $zmax; $i++) { |
|
1117 | + for ($j = 0; $j < $xmax; $j++) { |
|
1118 | + $ydata[$i][$j] = 0; |
|
1119 | + } |
|
1120 | + } |
|
1121 | + $total = month_of_first_marriage($z_axis, $z_boundaries, $stats); |
|
1122 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalFamilies(); |
|
1123 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1124 | + break; |
|
1125 | + case '17': |
|
1126 | + $monthdata = array(); |
|
1127 | + for ($i = 0; $i < 12; ++$i) { |
|
1128 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1129 | + } |
|
1130 | + $xgiven = false; |
|
1131 | + $zgiven = false; |
|
1132 | + $title = I18N::translate('Age related to birth year'); |
|
1133 | + $xtitle = I18N::translate('age'); |
|
1134 | + $ytitle = I18N::translate('numbers'); |
|
1135 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1136 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1137 | + calculate_axis($boundaries_x_axis); |
|
1138 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1139 | + calculate_legend($boundaries_z_axis); |
|
1140 | + } |
|
1141 | + $percentage = false; |
|
1142 | + if ($y_axis === 201) { |
|
1143 | + $percentage = false; |
|
1144 | + $ytitle = I18N::translate('Individuals'); |
|
1145 | + } elseif ($y_axis === 202) { |
|
1146 | + $percentage = true; |
|
1147 | + $ytitle = I18N::translate('percentage'); |
|
1148 | + } |
|
1149 | + $male_female = false; |
|
1150 | + if ($z_axis === 300) { |
|
1151 | + $zgiven = false; |
|
1152 | + $legend[0] = 'all'; |
|
1153 | + $zmax = 1; |
|
1154 | + $z_boundaries[0] = 100000; |
|
1155 | + } elseif ($z_axis === 301) { |
|
1156 | + $male_female = true; |
|
1157 | + $zgiven = true; |
|
1158 | + $legend[0] = I18N::translate('Male'); |
|
1159 | + $legend[1] = I18N::translate('Female'); |
|
1160 | + $zmax = 2; |
|
1161 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1162 | + } elseif ($z_axis === 302) { |
|
1163 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1164 | + } |
|
1165 | + //-- reset the data array |
|
1166 | + for ($i = 0; $i < $zmax; $i++) { |
|
1167 | + for ($j = 0; $j < $xmax; $j++) { |
|
1168 | + $ydata[$i][$j] = 0; |
|
1169 | + } |
|
1170 | + } |
|
1171 | + $total = lifespan_by_birth_year($z_axis, $z_boundaries, $stats); |
|
1172 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1173 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1174 | + break; |
|
1175 | + case '18': |
|
1176 | + $monthdata = array(); |
|
1177 | + for ($i = 0; $i < 12; ++$i) { |
|
1178 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1179 | + } |
|
1180 | + $xgiven = false; |
|
1181 | + $zgiven = false; |
|
1182 | + $title = I18N::translate('Age related to death year'); |
|
1183 | + $xtitle = I18N::translate('age'); |
|
1184 | + $ytitle = I18N::translate('numbers'); |
|
1185 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages'); |
|
1186 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1187 | + calculate_axis($boundaries_x_axis); |
|
1188 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1189 | + calculate_legend($boundaries_z_axis); |
|
1190 | + } |
|
1191 | + $percentage = false; |
|
1192 | + if ($y_axis === 201) { |
|
1193 | + $percentage = false; |
|
1194 | + $ytitle = I18N::translate('Individuals'); |
|
1195 | + } elseif ($y_axis === 202) { |
|
1196 | + $percentage = true; |
|
1197 | + $ytitle = I18N::translate('percentage'); |
|
1198 | + } |
|
1199 | + $male_female = false; |
|
1200 | + if ($z_axis === 300) { |
|
1201 | + $zgiven = false; |
|
1202 | + $legend[0] = 'all'; |
|
1203 | + $zmax = 1; |
|
1204 | + $z_boundaries[0] = 100000; |
|
1205 | + } elseif ($z_axis === 301) { |
|
1206 | + $male_female = true; |
|
1207 | + $zgiven = true; |
|
1208 | + $legend[0] = I18N::translate('Male'); |
|
1209 | + $legend[1] = I18N::translate('Female'); |
|
1210 | + $zmax = 2; |
|
1211 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1212 | + } elseif ($z_axis === 302) { |
|
1213 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1214 | + } |
|
1215 | + //-- reset the data array |
|
1216 | + for ($i = 0; $i < $zmax; $i++) { |
|
1217 | + for ($j = 0; $j < $xmax; $j++) { |
|
1218 | + $ydata[$i][$j] = 0; |
|
1219 | + } |
|
1220 | + } |
|
1221 | + $total = lifespan_by_death_year($z_axis, $z_boundaries, $stats); |
|
1222 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1223 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1224 | + break; |
|
1225 | + case '19': |
|
1226 | + $monthdata = array(); |
|
1227 | + for ($i = 0; $i < 12; ++$i) { |
|
1228 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1229 | + } |
|
1230 | + $xgiven = false; |
|
1231 | + $zgiven = false; |
|
1232 | + $title = I18N::translate('Age in year of marriage'); |
|
1233 | + $xtitle = I18N::translate('age'); |
|
1234 | + $ytitle = I18N::translate('numbers'); |
|
1235 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1236 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1237 | + calculate_axis($boundaries_x_axis); |
|
1238 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1239 | + calculate_legend($boundaries_z_axis); |
|
1240 | + } |
|
1241 | + $percentage = false; |
|
1242 | + if ($y_axis === 201) { |
|
1243 | + $percentage = false; |
|
1244 | + $ytitle = I18N::translate('Individuals'); |
|
1245 | + } elseif ($y_axis === 202) { |
|
1246 | + $percentage = true; |
|
1247 | + $ytitle = I18N::translate('percentage'); |
|
1248 | + } |
|
1249 | + $male_female = false; |
|
1250 | + $z_boundaries[0] = 100000; |
|
1251 | + if ($z_axis === 300) { |
|
1252 | + $zgiven = false; |
|
1253 | + $legend[0] = 'all'; |
|
1254 | + $zmax = 1; |
|
1255 | + } elseif ($z_axis === 301) { |
|
1256 | + $male_female = true; |
|
1257 | + $zgiven = true; |
|
1258 | + $legend[0] = I18N::translate('Male'); |
|
1259 | + $legend[1] = I18N::translate('Female'); |
|
1260 | + $zmax = 2; |
|
1261 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1262 | + } elseif ($z_axis === 302) { |
|
1263 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1264 | + } |
|
1265 | + //-- reset the data array |
|
1266 | + for ($i = 0; $i < $zmax; $i++) { |
|
1267 | + for ($j = 0; $j < $xmax; $j++) { |
|
1268 | + $ydata[$i][$j] = 0; |
|
1269 | + } |
|
1270 | + } |
|
1271 | + $total = age_at_marriage($z_axis, $z_boundaries, $stats); |
|
1272 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1273 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1274 | + break; |
|
1275 | + case '20': |
|
1276 | + $monthdata = array(); |
|
1277 | + for ($i = 0; $i < 12; ++$i) { |
|
1278 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1279 | + } |
|
1280 | + $xgiven = false; |
|
1281 | + $zgiven = false; |
|
1282 | + $title = I18N::translate('Age in year of first marriage'); |
|
1283 | + $xtitle = I18N::translate('age'); |
|
1284 | + $ytitle = I18N::translate('numbers'); |
|
1285 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-ages_m'); |
|
1286 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1287 | + calculate_axis($boundaries_x_axis); |
|
1288 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1289 | + calculate_legend($boundaries_z_axis); |
|
1290 | + } |
|
1291 | + $percentage = false; |
|
1292 | + if ($y_axis === 201) { |
|
1293 | + $percentage = false; |
|
1294 | + $ytitle = I18N::translate('Individuals'); |
|
1295 | + } elseif ($y_axis === 202) { |
|
1296 | + $percentage = true; |
|
1297 | + $ytitle = I18N::translate('percentage'); |
|
1298 | + } |
|
1299 | + $male_female = false; |
|
1300 | + if ($z_axis === 300) { |
|
1301 | + $zgiven = false; |
|
1302 | + $legend[0] = 'all'; |
|
1303 | + $zmax = 1; |
|
1304 | + $z_boundaries[0] = 100000; |
|
1305 | + } elseif ($z_axis === 301) { |
|
1306 | + $male_female = true; |
|
1307 | + $zgiven = true; |
|
1308 | + $legend[0] = I18N::translate('Male'); |
|
1309 | + $legend[1] = I18N::translate('Female'); |
|
1310 | + $zmax = 2; |
|
1311 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1312 | + } elseif ($z_axis === 302) { |
|
1313 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1314 | + } |
|
1315 | + //-- reset the data array |
|
1316 | + for ($i = 0; $i < $zmax; $i++) { |
|
1317 | + for ($j = 0; $j < $xmax; $j++) { |
|
1318 | + $ydata[$i][$j] = 0; |
|
1319 | + } |
|
1320 | + } |
|
1321 | + $total = age_at_first_marriage($z_axis, $z_boundaries, $stats); |
|
1322 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalIndividuals(); |
|
1323 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1324 | + break; |
|
1325 | + case '21': |
|
1326 | + $monthdata = array(); |
|
1327 | + for ($i = 0; $i < 12; ++$i) { |
|
1328 | + $monthdata[$i] = GregorianDate::monthNameNominativeCase($i + 1, false); |
|
1329 | + } |
|
1330 | + $xgiven = false; |
|
1331 | + $zgiven = false; |
|
1332 | + $title = I18N::translate('Number of children'); |
|
1333 | + $xtitle = I18N::translate('children'); |
|
1334 | + $ytitle = I18N::translate('numbers'); |
|
1335 | + $boundaries_x_axis = Filter::get('x-axis-boundaries-numbers'); |
|
1336 | + $boundaries_z_axis = Filter::get('z-axis-boundaries-periods', null, '0'); |
|
1337 | + calculate_axis($boundaries_x_axis); |
|
1338 | + if ($z_axis !== 300 && $z_axis !== 301) { |
|
1339 | + calculate_legend($boundaries_z_axis); |
|
1340 | + } |
|
1341 | + $percentage = false; |
|
1342 | + if ($y_axis === 201) { |
|
1343 | + $percentage = false; |
|
1344 | + $ytitle = I18N::translate('Families'); |
|
1345 | + } elseif ($y_axis === 202) { |
|
1346 | + $percentage = true; |
|
1347 | + $ytitle = I18N::translate('percentage'); |
|
1348 | + } |
|
1349 | + $male_female = false; |
|
1350 | + if ($z_axis === 300) { |
|
1351 | + $zgiven = false; |
|
1352 | + $legend[0] = 'all'; |
|
1353 | + $zmax = 1; |
|
1354 | + $z_boundaries[0] = 100000; |
|
1355 | + } elseif ($z_axis === 301) { |
|
1356 | + $male_female = true; |
|
1357 | + $zgiven = true; |
|
1358 | + $legend[0] = I18N::translate('Male'); |
|
1359 | + $legend[1] = I18N::translate('Female'); |
|
1360 | + $zmax = 2; |
|
1361 | + $xtitle = $xtitle . I18N::translate(' per gender'); |
|
1362 | + } elseif ($z_axis === 302) { |
|
1363 | + $xtitle = $xtitle . I18N::translate(' per time period'); |
|
1364 | + } |
|
1365 | + //-- reset the data array |
|
1366 | + for ($i = 0; $i < $zmax; $i++) { |
|
1367 | + for ($j = 0; $j < $xmax; $j++) { |
|
1368 | + $ydata[$i][$j] = 0; |
|
1369 | + } |
|
1370 | + } |
|
1371 | + $total = number_of_children($z_axis, $z_boundaries, $stats); |
|
1372 | + $hstr = $title . '|' . I18N::translate('Counts ') . ' ' . I18N::number($total) . ' ' . I18N::translate('of') . ' ' . $stats->totalChildren(); |
|
1373 | + my_plot($hstr, $xdata, $xtitle, $ydata, $ytitle, $legend); |
|
1374 | + break; |
|
1375 | + default: |
|
1376 | + echo '<i class="icon-loading-large"></i>'; |
|
1377 | + break; |
|
1378 | 1378 | } |
1379 | 1379 | echo '</div>'; |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return int |
38 | 38 | */ |
39 | -function month_of_birth($z_axis, array $z_boundaries, Stats $stats) { |
|
39 | +function month_of_birth($z_axis, array $z_boundaries, Stats $stats) |
|
40 | +{ |
|
40 | 41 | $total = 0; |
41 | 42 | |
42 | 43 | if ($z_axis === 300) { |
@@ -92,7 +93,8 @@ discard block |
||
92 | 93 | * |
93 | 94 | * @return int |
94 | 95 | */ |
95 | -function month_of_birth_of_first_child($z_axis, array $z_boundaries, Stats $stats) { |
|
96 | +function month_of_birth_of_first_child($z_axis, array $z_boundaries, Stats $stats) |
|
97 | +{ |
|
96 | 98 | $total = 0; |
97 | 99 | |
98 | 100 | if ($z_axis === 300) { |
@@ -148,7 +150,8 @@ discard block |
||
148 | 150 | * |
149 | 151 | * @return int |
150 | 152 | */ |
151 | -function month_of_death($z_axis, array $z_boundaries, Stats $stats) { |
|
153 | +function month_of_death($z_axis, array $z_boundaries, Stats $stats) |
|
154 | +{ |
|
152 | 155 | $total = 0; |
153 | 156 | |
154 | 157 | if ($z_axis === 300) { |
@@ -204,7 +207,8 @@ discard block |
||
204 | 207 | * |
205 | 208 | * @return int |
206 | 209 | */ |
207 | -function month_of_marriage($z_axis, array $z_boundaries, Stats $stats) { |
|
210 | +function month_of_marriage($z_axis, array $z_boundaries, Stats $stats) |
|
211 | +{ |
|
208 | 212 | $total = 0; |
209 | 213 | |
210 | 214 | if ($z_axis === 300) { |
@@ -245,7 +249,8 @@ discard block |
||
245 | 249 | * |
246 | 250 | * @return int |
247 | 251 | */ |
248 | -function month_of_first_marriage($z_axis, array $z_boundaries, Stats $stats) { |
|
252 | +function month_of_first_marriage($z_axis, array $z_boundaries, Stats $stats) |
|
253 | +{ |
|
249 | 254 | $total = 0; |
250 | 255 | |
251 | 256 | if ($z_axis === 300) { |
@@ -298,7 +303,8 @@ discard block |
||
298 | 303 | * |
299 | 304 | * @return int |
300 | 305 | */ |
301 | -function lifespan_by_birth_year($z_axis, array $z_boundaries, Stats $stats) { |
|
306 | +function lifespan_by_birth_year($z_axis, array $z_boundaries, Stats $stats) |
|
307 | +{ |
|
302 | 308 | $total = 0; |
303 | 309 | |
304 | 310 | if ($z_axis === 300) { |
@@ -350,7 +356,8 @@ discard block |
||
350 | 356 | * |
351 | 357 | * @return int |
352 | 358 | */ |
353 | -function lifespan_by_death_year($z_axis, array $z_boundaries, Stats $stats) { |
|
359 | +function lifespan_by_death_year($z_axis, array $z_boundaries, Stats $stats) |
|
360 | +{ |
|
354 | 361 | $total = 0; |
355 | 362 | |
356 | 363 | if ($z_axis === 300) { |
@@ -402,7 +409,8 @@ discard block |
||
402 | 409 | * |
403 | 410 | * @return int |
404 | 411 | */ |
405 | -function age_at_marriage($z_axis, array $z_boundaries, Stats $stats) { |
|
412 | +function age_at_marriage($z_axis, array $z_boundaries, Stats $stats) |
|
413 | +{ |
|
406 | 414 | $total = 0; |
407 | 415 | |
408 | 416 | if ($z_axis === 300) { |
@@ -456,7 +464,8 @@ discard block |
||
456 | 464 | * |
457 | 465 | * @return int |
458 | 466 | */ |
459 | -function age_at_first_marriage($z_axis, array $z_boundaries, Stats $stats) { |
|
467 | +function age_at_first_marriage($z_axis, array $z_boundaries, Stats $stats) |
|
468 | +{ |
|
460 | 469 | $total = 0; |
461 | 470 | |
462 | 471 | if ($z_axis === 300) { |
@@ -533,7 +542,8 @@ discard block |
||
533 | 542 | * |
534 | 543 | * @return int |
535 | 544 | */ |
536 | -function number_of_children($z_axis, array $z_boundaries, Stats $stats) { |
|
545 | +function number_of_children($z_axis, array $z_boundaries, Stats $stats) |
|
546 | +{ |
|
537 | 547 | $total = 0; |
538 | 548 | |
539 | 549 | if ($z_axis === 300) { |
@@ -575,7 +585,8 @@ discard block |
||
575 | 585 | * @param int $x |
576 | 586 | * @param int $val |
577 | 587 | */ |
578 | -function fill_y_data($z, $x, $val) { |
|
588 | +function fill_y_data($z, $x, $val) |
|
589 | +{ |
|
579 | 590 | global $ydata, $xmax, $x_boundaries, $zmax, $z_boundaries, $xgiven, $zgiven; |
580 | 591 | //-- calculate index $i out of given z value |
581 | 592 | //-- calculate index $j out of given x value |
@@ -612,7 +623,8 @@ discard block |
||
612 | 623 | * @param string $ytitle |
613 | 624 | * @param string[] $legend |
614 | 625 | */ |
615 | -function my_plot($mytitle, $xdata, $xtitle, $ydata, $ytitle, $legend) { |
|
626 | +function my_plot($mytitle, $xdata, $xtitle, $ydata, $ytitle, $legend) |
|
627 | +{ |
|
616 | 628 | global $percentage, $male_female, $ymax, $scalefactor, $datastring, $imgurl; |
617 | 629 | |
618 | 630 | // Google Chart API only allows text encoding for numbers less than 100 |
@@ -752,7 +764,8 @@ discard block |
||
752 | 764 | * |
753 | 765 | * @param string $x_axis_boundaries |
754 | 766 | */ |
755 | -function calculate_axis($x_axis_boundaries) { |
|
767 | +function calculate_axis($x_axis_boundaries) |
|
768 | +{ |
|
756 | 769 | global $x_axis, $xdata, $xmax, $x_boundaries; |
757 | 770 | |
758 | 771 | // Calculate xdata and zdata elements out of chart values |
@@ -801,7 +814,8 @@ discard block |
||
801 | 814 | * |
802 | 815 | * @return string |
803 | 816 | */ |
804 | -function format_range_of_numbers($x, $y) { |
|
817 | +function format_range_of_numbers($x, $y) |
|
818 | +{ |
|
805 | 819 | return /* I18N: A range of numbers */ I18N::translate( |
806 | 820 | '%1$s–%2$s', |
807 | 821 | I18N::number($x), |
@@ -814,7 +828,8 @@ discard block |
||
814 | 828 | * |
815 | 829 | * @param string $boundaries_z_axis |
816 | 830 | */ |
817 | -function calculate_legend($boundaries_z_axis) { |
|
831 | +function calculate_legend($boundaries_z_axis) |
|
832 | +{ |
|
818 | 833 | global $legend, $zmax, $z_boundaries; |
819 | 834 | |
820 | 835 | // calculate the legend values |
@@ -29,92 +29,92 @@ discard block |
||
29 | 29 | |
30 | 30 | $controller = new PageController; |
31 | 31 | $controller |
32 | - ->restrictAccess(Auth::isManager($WT_TREE)) |
|
33 | - ->setPageTitle(I18N::translate('Check for errors') . ' — ' . $WT_TREE->getTitleHtml()) |
|
34 | - ->pageHeader(); |
|
32 | + ->restrictAccess(Auth::isManager($WT_TREE)) |
|
33 | + ->setPageTitle(I18N::translate('Check for errors') . ' — ' . $WT_TREE->getTitleHtml()) |
|
34 | + ->pageHeader(); |
|
35 | 35 | |
36 | 36 | // We need to work with raw GEDCOM data, as we are looking for errors |
37 | 37 | // which may prevent the GedcomRecord objects from working. |
38 | 38 | |
39 | 39 | $rows = Database::prepare( |
40 | - "SELECT i_id AS xref, 'INDI' AS type, i_gedcom AS gedrec FROM `##individuals` WHERE i_file=?" . |
|
41 | - " UNION " . |
|
42 | - "SELECT f_id AS xref, 'FAM' AS type, f_gedcom AS gedrec FROM `##families` WHERE f_file=?" . |
|
43 | - " UNION " . |
|
44 | - "SELECT s_id AS xref, 'SOUR' AS type, s_gedcom AS gedrec FROM `##sources` WHERE s_file=?" . |
|
45 | - " UNION " . |
|
46 | - "SELECT m_id AS xref, 'OBJE' AS type, m_gedcom AS gedrec FROM `##media` WHERE m_file=?" . |
|
47 | - " UNION " . |
|
48 | - "SELECT o_id AS xref, o_type AS type, o_gedcom AS gedrec FROM `##other` WHERE o_file=? AND o_type NOT IN ('HEAD', 'TRLR')" |
|
40 | + "SELECT i_id AS xref, 'INDI' AS type, i_gedcom AS gedrec FROM `##individuals` WHERE i_file=?" . |
|
41 | + " UNION " . |
|
42 | + "SELECT f_id AS xref, 'FAM' AS type, f_gedcom AS gedrec FROM `##families` WHERE f_file=?" . |
|
43 | + " UNION " . |
|
44 | + "SELECT s_id AS xref, 'SOUR' AS type, s_gedcom AS gedrec FROM `##sources` WHERE s_file=?" . |
|
45 | + " UNION " . |
|
46 | + "SELECT m_id AS xref, 'OBJE' AS type, m_gedcom AS gedrec FROM `##media` WHERE m_file=?" . |
|
47 | + " UNION " . |
|
48 | + "SELECT o_id AS xref, o_type AS type, o_gedcom AS gedrec FROM `##other` WHERE o_file=? AND o_type NOT IN ('HEAD', 'TRLR')" |
|
49 | 49 | )->execute(array($WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId(), $WT_TREE->getTreeId()))->fetchAll(); |
50 | 50 | |
51 | 51 | $records = array(); |
52 | 52 | foreach ($rows as $row) { |
53 | - $records[$row->xref] = $row; |
|
53 | + $records[$row->xref] = $row; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | // Need to merge pending new/changed/deleted records |
57 | 57 | |
58 | 58 | $rows = Database::prepare( |
59 | - "SELECT xref, SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(CASE WHEN old_gedcom='' THEN new_gedcom ELSE old_gedcom END, '\n', 1), ' ', 3), ' ', -1) AS type, new_gedcom AS gedrec" . |
|
60 | - " FROM (" . |
|
61 | - " SELECT MAX(change_id) AS change_id" . |
|
62 | - " FROM `##change`" . |
|
63 | - " WHERE gedcom_id=? AND status='pending'" . |
|
64 | - " GROUP BY xref" . |
|
65 | - " ) AS t1" . |
|
66 | - " JOIN `##change` t2 USING (change_id)" |
|
59 | + "SELECT xref, SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(CASE WHEN old_gedcom='' THEN new_gedcom ELSE old_gedcom END, '\n', 1), ' ', 3), ' ', -1) AS type, new_gedcom AS gedrec" . |
|
60 | + " FROM (" . |
|
61 | + " SELECT MAX(change_id) AS change_id" . |
|
62 | + " FROM `##change`" . |
|
63 | + " WHERE gedcom_id=? AND status='pending'" . |
|
64 | + " GROUP BY xref" . |
|
65 | + " ) AS t1" . |
|
66 | + " JOIN `##change` t2 USING (change_id)" |
|
67 | 67 | )->execute(array($WT_TREE->getTreeId()))->fetchAll(); |
68 | 68 | |
69 | 69 | foreach ($rows as $row) { |
70 | - if ($row->gedrec) { |
|
71 | - // new/updated record |
|
72 | - $records[$row->xref] = $row; |
|
73 | - } else { |
|
74 | - // deleted record |
|
75 | - unset($records[$row->xref]); |
|
76 | - } |
|
70 | + if ($row->gedrec) { |
|
71 | + // new/updated record |
|
72 | + $records[$row->xref] = $row; |
|
73 | + } else { |
|
74 | + // deleted record |
|
75 | + unset($records[$row->xref]); |
|
76 | + } |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | // Keep a list of upper case XREFs, to detect mismatches. |
80 | 80 | $ukeys = array(); |
81 | 81 | foreach (array_keys($records) as $key) { |
82 | - $ukeys[strtoupper($key)] = $key; |
|
82 | + $ukeys[strtoupper($key)] = $key; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // LOOK FOR BROKEN LINKS |
86 | 86 | $XREF_LINKS = array( |
87 | - 'NOTE' => 'NOTE', |
|
88 | - 'SOUR' => 'SOUR', |
|
89 | - 'REPO' => 'REPO', |
|
90 | - 'OBJE' => 'OBJE', |
|
91 | - 'SUBM' => 'SUBM', |
|
92 | - 'FAMC' => 'FAM', |
|
93 | - 'FAMS' => 'FAM', |
|
94 | - //'ADOP'=>'FAM', // Need to handle this case specially. We may have both ADOP and FAMC links to the same FAM, but only store one. |
|
95 | - 'HUSB' => 'INDI', |
|
96 | - 'WIFE' => 'INDI', |
|
97 | - 'CHIL' => 'INDI', |
|
98 | - 'ASSO' => 'INDI', |
|
99 | - '_ASSO' => 'INDI', // A webtrees extension |
|
100 | - 'ALIA' => 'INDI', |
|
101 | - 'AUTH' => 'INDI', // A webtrees extension |
|
102 | - 'ANCI' => 'SUBM', |
|
103 | - 'DESI' => 'SUBM', |
|
104 | - '_WT_OBJE_SORT' => 'OBJE', |
|
105 | - '_LOC' => '_LOC', |
|
87 | + 'NOTE' => 'NOTE', |
|
88 | + 'SOUR' => 'SOUR', |
|
89 | + 'REPO' => 'REPO', |
|
90 | + 'OBJE' => 'OBJE', |
|
91 | + 'SUBM' => 'SUBM', |
|
92 | + 'FAMC' => 'FAM', |
|
93 | + 'FAMS' => 'FAM', |
|
94 | + //'ADOP'=>'FAM', // Need to handle this case specially. We may have both ADOP and FAMC links to the same FAM, but only store one. |
|
95 | + 'HUSB' => 'INDI', |
|
96 | + 'WIFE' => 'INDI', |
|
97 | + 'CHIL' => 'INDI', |
|
98 | + 'ASSO' => 'INDI', |
|
99 | + '_ASSO' => 'INDI', // A webtrees extension |
|
100 | + 'ALIA' => 'INDI', |
|
101 | + 'AUTH' => 'INDI', // A webtrees extension |
|
102 | + 'ANCI' => 'SUBM', |
|
103 | + 'DESI' => 'SUBM', |
|
104 | + '_WT_OBJE_SORT' => 'OBJE', |
|
105 | + '_LOC' => '_LOC', |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | $RECORD_LINKS = array( |
109 | - 'INDI' => array('NOTE', 'OBJE', 'SOUR', 'SUBM', 'ASSO', '_ASSO', 'FAMC', 'FAMS', 'ALIA', '_WT_OBJE_SORT', '_LOC'), |
|
110 | - 'FAM' => array('NOTE', 'OBJE', 'SOUR', 'SUBM', 'ASSO', '_ASSO', 'HUSB', 'WIFE', 'CHIL', '_LOC'), |
|
111 | - 'SOUR' => array('NOTE', 'OBJE', 'REPO', 'AUTH'), |
|
112 | - 'REPO' => array('NOTE'), |
|
113 | - 'OBJE' => array('NOTE'), // The spec also allows SOUR, but we treat this as a warning |
|
114 | - 'NOTE' => array(), // The spec also allows SOUR, but we treat this as a warning |
|
115 | - 'SUBM' => array('NOTE', 'OBJE'), |
|
116 | - 'SUBN' => array('SUBM'), |
|
117 | - '_LOC' => array('SOUR', 'OBJE', '_LOC'), |
|
109 | + 'INDI' => array('NOTE', 'OBJE', 'SOUR', 'SUBM', 'ASSO', '_ASSO', 'FAMC', 'FAMS', 'ALIA', '_WT_OBJE_SORT', '_LOC'), |
|
110 | + 'FAM' => array('NOTE', 'OBJE', 'SOUR', 'SUBM', 'ASSO', '_ASSO', 'HUSB', 'WIFE', 'CHIL', '_LOC'), |
|
111 | + 'SOUR' => array('NOTE', 'OBJE', 'REPO', 'AUTH'), |
|
112 | + 'REPO' => array('NOTE'), |
|
113 | + 'OBJE' => array('NOTE'), // The spec also allows SOUR, but we treat this as a warning |
|
114 | + 'NOTE' => array(), // The spec also allows SOUR, but we treat this as a warning |
|
115 | + 'SUBM' => array('NOTE', 'OBJE'), |
|
116 | + 'SUBN' => array('SUBM'), |
|
117 | + '_LOC' => array('SOUR', 'OBJE', '_LOC'), |
|
118 | 118 | ); |
119 | 119 | |
120 | 120 | $errors = false; |
@@ -144,71 +144,71 @@ discard block |
||
144 | 144 | $all_links = array(); |
145 | 145 | $upper_links = array(); |
146 | 146 | foreach ($records as $record) { |
147 | - $all_links[$record->xref] = array(); |
|
148 | - $upper_links[strtoupper($record->xref)] = $record->xref; |
|
149 | - preg_match_all('/\n\d (' . WT_REGEX_TAG . ') @([^#@\n][^\n@]*)@/', $record->gedrec, $matches, PREG_SET_ORDER); |
|
150 | - foreach ($matches as $match) { |
|
151 | - $all_links[$record->xref][$match[2]] = $match[1]; |
|
152 | - } |
|
147 | + $all_links[$record->xref] = array(); |
|
148 | + $upper_links[strtoupper($record->xref)] = $record->xref; |
|
149 | + preg_match_all('/\n\d (' . WT_REGEX_TAG . ') @([^#@\n][^\n@]*)@/', $record->gedrec, $matches, PREG_SET_ORDER); |
|
150 | + foreach ($matches as $match) { |
|
151 | + $all_links[$record->xref][$match[2]] = $match[1]; |
|
152 | + } |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | foreach ($all_links as $xref1 => $links) { |
156 | - $type1 = $records[$xref1]->type; |
|
157 | - foreach ($links as $xref2 => $type2) { |
|
158 | - $type3 = isset($records[$xref2]) ? $records[$xref2]->type : ''; |
|
159 | - if (!array_key_exists($xref2, $all_links)) { |
|
160 | - if (array_key_exists(strtoupper($xref2), $upper_links)) { |
|
161 | - echo warning( |
|
162 | - link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
163 | - /* I18N: placeholders are GEDCOM XREFs, such as R123 */ |
|
164 | - I18N::translate('%1$s does not exist. Did you mean %2$s?', format_link($xref2), format_link($upper_links[strtoupper($xref2)])) |
|
165 | - ); |
|
166 | - } else { |
|
167 | - echo error( |
|
168 | - link_message( |
|
169 | - $type1, $xref1, $type2, $xref2) . ' ' . |
|
170 | - /* I18N: placeholders are GEDCOM XREFs, such as R123 */ |
|
171 | - I18N::translate('%1$s does not exist.', format_link($xref2)) |
|
172 | - ); |
|
173 | - } |
|
174 | - } elseif ($type2 === 'SOUR' && $type1 === 'NOTE') { |
|
175 | - // Notes are intended to add explanations and comments to other records. They should not have their own sources. |
|
176 | - } elseif ($type2 === 'SOUR' && $type1 === 'OBJE') { |
|
177 | - // Media objects are intended to illustrate other records, facts, and source/citations. They should not have their own sources. |
|
178 | - } elseif ($type2 === 'OBJE' && $type1 === 'REPO') { |
|
179 | - echo warning( |
|
180 | - link_message($type1, $xref1, $type2, $xref2) . ' ' . I18N::translate('This type of link is not allowed here.') |
|
181 | - ); |
|
182 | - } elseif (!array_key_exists($type1, $RECORD_LINKS) || !in_array($type2, $RECORD_LINKS[$type1]) || !array_key_exists($type2, $XREF_LINKS)) { |
|
183 | - echo error( |
|
184 | - link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
185 | - I18N::translate('This type of link is not allowed here.') |
|
186 | - ); |
|
187 | - } elseif ($XREF_LINKS[$type2] !== $type3) { |
|
188 | - // Target XREF does exist - but is invalid |
|
189 | - echo error( |
|
190 | - link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
191 | - /* I18N: %1$s is an internal ID number such as R123. %2$s and %3$s are record types, such as INDI or SOUR */ |
|
192 | - I18N::translate('%1$s is a %2$s but a %3$s is expected.', format_link($xref2), format_type($type3), format_type($type2)) |
|
193 | - ); |
|
194 | - } elseif ( |
|
195 | - $type2 === 'FAMC' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'CHIL') || |
|
196 | - $type2 === 'FAMS' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'HUSB' && $all_links[$xref2][$xref1] !== 'WIFE') || |
|
197 | - $type2 === 'CHIL' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'FAMC') || |
|
198 | - $type2 === 'HUSB' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'FAMS') || |
|
199 | - $type2 === 'WIFE' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'FAMS') |
|
200 | - ) { |
|
201 | - echo error( |
|
202 | - link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
203 | - /* I18N: %1$s and %2$s are internal ID numbers such as R123 */ |
|
204 | - I18N::translate('%1$s does not have a link back to %2$s.', format_link($xref2), format_link($xref1)) |
|
205 | - ); |
|
206 | - } |
|
207 | - } |
|
156 | + $type1 = $records[$xref1]->type; |
|
157 | + foreach ($links as $xref2 => $type2) { |
|
158 | + $type3 = isset($records[$xref2]) ? $records[$xref2]->type : ''; |
|
159 | + if (!array_key_exists($xref2, $all_links)) { |
|
160 | + if (array_key_exists(strtoupper($xref2), $upper_links)) { |
|
161 | + echo warning( |
|
162 | + link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
163 | + /* I18N: placeholders are GEDCOM XREFs, such as R123 */ |
|
164 | + I18N::translate('%1$s does not exist. Did you mean %2$s?', format_link($xref2), format_link($upper_links[strtoupper($xref2)])) |
|
165 | + ); |
|
166 | + } else { |
|
167 | + echo error( |
|
168 | + link_message( |
|
169 | + $type1, $xref1, $type2, $xref2) . ' ' . |
|
170 | + /* I18N: placeholders are GEDCOM XREFs, such as R123 */ |
|
171 | + I18N::translate('%1$s does not exist.', format_link($xref2)) |
|
172 | + ); |
|
173 | + } |
|
174 | + } elseif ($type2 === 'SOUR' && $type1 === 'NOTE') { |
|
175 | + // Notes are intended to add explanations and comments to other records. They should not have their own sources. |
|
176 | + } elseif ($type2 === 'SOUR' && $type1 === 'OBJE') { |
|
177 | + // Media objects are intended to illustrate other records, facts, and source/citations. They should not have their own sources. |
|
178 | + } elseif ($type2 === 'OBJE' && $type1 === 'REPO') { |
|
179 | + echo warning( |
|
180 | + link_message($type1, $xref1, $type2, $xref2) . ' ' . I18N::translate('This type of link is not allowed here.') |
|
181 | + ); |
|
182 | + } elseif (!array_key_exists($type1, $RECORD_LINKS) || !in_array($type2, $RECORD_LINKS[$type1]) || !array_key_exists($type2, $XREF_LINKS)) { |
|
183 | + echo error( |
|
184 | + link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
185 | + I18N::translate('This type of link is not allowed here.') |
|
186 | + ); |
|
187 | + } elseif ($XREF_LINKS[$type2] !== $type3) { |
|
188 | + // Target XREF does exist - but is invalid |
|
189 | + echo error( |
|
190 | + link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
191 | + /* I18N: %1$s is an internal ID number such as R123. %2$s and %3$s are record types, such as INDI or SOUR */ |
|
192 | + I18N::translate('%1$s is a %2$s but a %3$s is expected.', format_link($xref2), format_type($type3), format_type($type2)) |
|
193 | + ); |
|
194 | + } elseif ( |
|
195 | + $type2 === 'FAMC' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'CHIL') || |
|
196 | + $type2 === 'FAMS' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'HUSB' && $all_links[$xref2][$xref1] !== 'WIFE') || |
|
197 | + $type2 === 'CHIL' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'FAMC') || |
|
198 | + $type2 === 'HUSB' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'FAMS') || |
|
199 | + $type2 === 'WIFE' && (!array_key_exists($xref1, $all_links[$xref2]) || $all_links[$xref2][$xref1] !== 'FAMS') |
|
200 | + ) { |
|
201 | + echo error( |
|
202 | + link_message($type1, $xref1, $type2, $xref2) . ' ' . |
|
203 | + /* I18N: %1$s and %2$s are internal ID numbers such as R123 */ |
|
204 | + I18N::translate('%1$s does not have a link back to %2$s.', format_link($xref2), format_link($xref1)) |
|
205 | + ); |
|
206 | + } |
|
207 | + } |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | if (!$errors) { |
211 | - echo '<li class="list-group-item">', I18N::translate('No errors have been found.'), '</li>'; |
|
211 | + echo '<li class="list-group-item">', I18N::translate('No errors have been found.'), '</li>'; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | echo '</ul>'; |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | * @return string |
225 | 225 | */ |
226 | 226 | function link_message($type1, $xref1, $type2, $xref2) { |
227 | - return /* I18N: The placeholders are GEDCOM XREFs and tags. e.g. “INDI I123 contains a FAMC link to F234.” */ I18N::translate( |
|
228 | - '%1$s %2$s has a %3$s link to %4$s.', |
|
229 | - format_type($type1), |
|
230 | - format_link($xref1), |
|
231 | - format_type($type2), |
|
232 | - format_link($xref2) |
|
233 | - ); |
|
227 | + return /* I18N: The placeholders are GEDCOM XREFs and tags. e.g. “INDI I123 contains a FAMC link to F234.” */ I18N::translate( |
|
228 | + '%1$s %2$s has a %3$s link to %4$s.', |
|
229 | + format_type($type1), |
|
230 | + format_link($xref1), |
|
231 | + format_type($type2), |
|
232 | + format_link($xref2) |
|
233 | + ); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return string |
242 | 242 | */ |
243 | 243 | function format_link($xref) { |
244 | - return '<b><a href="gedrecord.php?pid=' . $xref . '">' . $xref . '</a></b>'; |
|
244 | + return '<b><a href="gedrecord.php?pid=' . $xref . '">' . $xref . '</a></b>'; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @return string |
253 | 253 | */ |
254 | 254 | function format_type($type) { |
255 | - return '<b title="' . strip_tags(GedcomTag::getLabel($type)) . '">' . $type . '</b>'; |
|
255 | + return '<b title="' . strip_tags(GedcomTag::getLabel($type)) . '">' . $type . '</b>'; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * @return string |
264 | 264 | */ |
265 | 265 | function error($message) { |
266 | - global $errors; |
|
267 | - $errors = true; |
|
266 | + global $errors; |
|
267 | + $errors = true; |
|
268 | 268 | |
269 | - return '<li class="list-group-item list-group-item-danger">' . $message . '</li>'; |
|
269 | + return '<li class="list-group-item list-group-item-danger">' . $message . '</li>'; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @return string |
278 | 278 | */ |
279 | 279 | function warning($message) { |
280 | - global $errors; |
|
281 | - $errors = true; |
|
280 | + global $errors; |
|
281 | + $errors = true; |
|
282 | 282 | |
283 | - return '<li class="list-group-item list-group-item-warning">' . $message . '</li>'; |
|
283 | + return '<li class="list-group-item list-group-item-warning">' . $message . '</li>'; |
|
284 | 284 | } |
@@ -223,7 +223,8 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return string |
225 | 225 | */ |
226 | -function link_message($type1, $xref1, $type2, $xref2) { |
|
226 | +function link_message($type1, $xref1, $type2, $xref2) |
|
227 | +{ |
|
227 | 228 | return /* I18N: The placeholders are GEDCOM XREFs and tags. e.g. “INDI I123 contains a FAMC link to F234.” */ I18N::translate( |
228 | 229 | '%1$s %2$s has a %3$s link to %4$s.', |
229 | 230 | format_type($type1), |
@@ -240,7 +241,8 @@ discard block |
||
240 | 241 | * |
241 | 242 | * @return string |
242 | 243 | */ |
243 | -function format_link($xref) { |
|
244 | +function format_link($xref) |
|
245 | +{ |
|
244 | 246 | return '<b><a href="gedrecord.php?pid=' . $xref . '">' . $xref . '</a></b>'; |
245 | 247 | } |
246 | 248 | |
@@ -251,7 +253,8 @@ discard block |
||
251 | 253 | * |
252 | 254 | * @return string |
253 | 255 | */ |
254 | -function format_type($type) { |
|
256 | +function format_type($type) |
|
257 | +{ |
|
255 | 258 | return '<b title="' . strip_tags(GedcomTag::getLabel($type)) . '">' . $type . '</b>'; |
256 | 259 | } |
257 | 260 | |
@@ -262,7 +265,8 @@ discard block |
||
262 | 265 | * |
263 | 266 | * @return string |
264 | 267 | */ |
265 | -function error($message) { |
|
268 | +function error($message) |
|
269 | +{ |
|
266 | 270 | global $errors; |
267 | 271 | $errors = true; |
268 | 272 | |
@@ -276,7 +280,8 @@ discard block |
||
276 | 280 | * |
277 | 281 | * @return string |
278 | 282 | */ |
279 | -function warning($message) { |
|
283 | +function warning($message) |
|
284 | +{ |
|
280 | 285 | global $errors; |
281 | 286 | $errors = true; |
282 | 287 |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | $controller = new PageController; |
32 | 32 | $controller |
33 | - ->addExternalJavascript(WT_ADMIN_JS_URL) |
|
34 | - ->restrictAccess(Auth::isAdmin() || Auth::isManager($WT_TREE)) |
|
35 | - ->setPageTitle(I18N::translate('Manage family trees')); |
|
33 | + ->addExternalJavascript(WT_ADMIN_JS_URL) |
|
34 | + ->restrictAccess(Auth::isAdmin() || Auth::isManager($WT_TREE)) |
|
35 | + ->setPageTitle(I18N::translate('Manage family trees')); |
|
36 | 36 | |
37 | 37 | // Show a reduced page when there are more than a certain number of trees |
38 | 38 | $multiple_tree_threshold = Site::getPreference('MULTIPLE_TREE_THRESHOLD') ?: 500; |
@@ -40,126 +40,126 @@ discard block |
||
40 | 40 | // Note that glob() returns false instead of an empty array when open_basedir_restriction |
41 | 41 | // is in force and no files are found. See PHP bug #47358. |
42 | 42 | if (defined('GLOB_BRACE')) { |
43 | - $gedcom_files = glob(WT_DATA_DIR . '*.{ged,Ged,GED}', GLOB_NOSORT | GLOB_BRACE) ?: array(); |
|
43 | + $gedcom_files = glob(WT_DATA_DIR . '*.{ged,Ged,GED}', GLOB_NOSORT | GLOB_BRACE) ?: array(); |
|
44 | 44 | } else { |
45 | - $gedcom_files = array_merge( |
|
46 | - glob(WT_DATA_DIR . '*.ged', GLOB_NOSORT) ?: array(), |
|
47 | - glob(WT_DATA_DIR . '*.Ged', GLOB_NOSORT) ?: array(), |
|
48 | - glob(WT_DATA_DIR . '*.GED', GLOB_NOSORT) ?: array() |
|
49 | - ); |
|
45 | + $gedcom_files = array_merge( |
|
46 | + glob(WT_DATA_DIR . '*.ged', GLOB_NOSORT) ?: array(), |
|
47 | + glob(WT_DATA_DIR . '*.Ged', GLOB_NOSORT) ?: array(), |
|
48 | + glob(WT_DATA_DIR . '*.GED', GLOB_NOSORT) ?: array() |
|
49 | + ); |
|
50 | 50 | } |
51 | 51 | // Process POST actions |
52 | 52 | switch (Filter::post('action')) { |
53 | 53 | case 'delete': |
54 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
55 | - if (Filter::checkCsrf() && $gedcom_id) { |
|
56 | - $tree = Tree::findById($gedcom_id); |
|
57 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
58 | - $tree->delete(); |
|
59 | - } |
|
60 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
61 | - |
|
62 | - return; |
|
54 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
55 | + if (Filter::checkCsrf() && $gedcom_id) { |
|
56 | + $tree = Tree::findById($gedcom_id); |
|
57 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
58 | + $tree->delete(); |
|
59 | + } |
|
60 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
61 | + |
|
62 | + return; |
|
63 | 63 | case 'setdefault': |
64 | - if (Filter::checkCsrf()) { |
|
65 | - Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged')); |
|
66 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success'); |
|
67 | - } |
|
68 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
64 | + if (Filter::checkCsrf()) { |
|
65 | + Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged')); |
|
66 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success'); |
|
67 | + } |
|
68 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
69 | 69 | |
70 | - return; |
|
70 | + return; |
|
71 | 71 | case 'new_tree': |
72 | - $basename = basename(Filter::post('tree_name')); |
|
73 | - $tree_title = Filter::post('tree_title'); |
|
74 | - |
|
75 | - if (Filter::checkCsrf() && $basename && $tree_title) { |
|
76 | - if (Tree::findByName($basename)) { |
|
77 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger'); |
|
78 | - } else { |
|
79 | - Tree::create($basename, $tree_title); |
|
80 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success'); |
|
81 | - } |
|
82 | - } |
|
83 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename)); |
|
84 | - |
|
85 | - return; |
|
72 | + $basename = basename(Filter::post('tree_name')); |
|
73 | + $tree_title = Filter::post('tree_title'); |
|
74 | + |
|
75 | + if (Filter::checkCsrf() && $basename && $tree_title) { |
|
76 | + if (Tree::findByName($basename)) { |
|
77 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger'); |
|
78 | + } else { |
|
79 | + Tree::create($basename, $tree_title); |
|
80 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success'); |
|
81 | + } |
|
82 | + } |
|
83 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename)); |
|
84 | + |
|
85 | + return; |
|
86 | 86 | case 'replace_upload': |
87 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
88 | - $keep_media = Filter::post('keep_media', '1', '0'); |
|
89 | - $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
90 | - $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
91 | - $tree = Tree::findById($gedcom_id); |
|
92 | - |
|
93 | - if (Filter::checkCsrf() && $tree) { |
|
94 | - $tree->setPreference('keep_media', $keep_media); |
|
95 | - $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
96 | - $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
97 | - if (isset($_FILES['tree_name'])) { |
|
98 | - if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { |
|
99 | - $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); |
|
100 | - } else { |
|
101 | - FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger'); |
|
102 | - } |
|
103 | - } else { |
|
104 | - FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
105 | - } |
|
106 | - } |
|
107 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | - |
|
109 | - return; |
|
87 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
88 | + $keep_media = Filter::post('keep_media', '1', '0'); |
|
89 | + $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
90 | + $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
91 | + $tree = Tree::findById($gedcom_id); |
|
92 | + |
|
93 | + if (Filter::checkCsrf() && $tree) { |
|
94 | + $tree->setPreference('keep_media', $keep_media); |
|
95 | + $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
96 | + $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
97 | + if (isset($_FILES['tree_name'])) { |
|
98 | + if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { |
|
99 | + $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); |
|
100 | + } else { |
|
101 | + FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger'); |
|
102 | + } |
|
103 | + } else { |
|
104 | + FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
105 | + } |
|
106 | + } |
|
107 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | + |
|
109 | + return; |
|
110 | 110 | case 'replace_import': |
111 | - $basename = basename(Filter::post('tree_name')); |
|
112 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
113 | - $keep_media = Filter::post('keep_media', '1', '0'); |
|
114 | - $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
115 | - $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
116 | - $tree = Tree::findById($gedcom_id); |
|
117 | - |
|
118 | - if (Filter::checkCsrf() && $tree) { |
|
119 | - $tree->setPreference('keep_media', $keep_media); |
|
120 | - $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
121 | - $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
122 | - if ($basename) { |
|
123 | - $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); |
|
124 | - } else { |
|
125 | - FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
126 | - } |
|
127 | - } |
|
128 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
129 | - |
|
130 | - return; |
|
111 | + $basename = basename(Filter::post('tree_name')); |
|
112 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
113 | + $keep_media = Filter::post('keep_media', '1', '0'); |
|
114 | + $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
115 | + $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
116 | + $tree = Tree::findById($gedcom_id); |
|
117 | + |
|
118 | + if (Filter::checkCsrf() && $tree) { |
|
119 | + $tree->setPreference('keep_media', $keep_media); |
|
120 | + $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
121 | + $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
122 | + if ($basename) { |
|
123 | + $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); |
|
124 | + } else { |
|
125 | + FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
126 | + } |
|
127 | + } |
|
128 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
129 | + |
|
130 | + return; |
|
131 | 131 | |
132 | 132 | case 'synchronize': |
133 | - if (Filter::checkCsrf()) { |
|
134 | - $basenames = array(); |
|
135 | - |
|
136 | - foreach ($gedcom_files as $gedcom_file) { |
|
137 | - $filemtime = filemtime($gedcom_file); // Only import files that have changed |
|
138 | - $basename = basename($gedcom_file); |
|
139 | - $basenames[] = $basename; |
|
140 | - |
|
141 | - $tree = Tree::findByName($basename); |
|
142 | - if (!$tree) { |
|
143 | - $tree = Tree::create($basename, $basename); |
|
144 | - } |
|
145 | - if ($tree->getPreference('filemtime') != $filemtime) { |
|
146 | - $tree->importGedcomFile($gedcom_file, $basename); |
|
147 | - $tree->setPreference('filemtime', $filemtime); |
|
148 | - FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success'); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - foreach (Tree::getAll() as $tree) { |
|
153 | - if (!in_array($tree->getName(), $basenames)) { |
|
154 | - FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
155 | - $tree->delete(); |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - } |
|
160 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
161 | - |
|
162 | - return; |
|
133 | + if (Filter::checkCsrf()) { |
|
134 | + $basenames = array(); |
|
135 | + |
|
136 | + foreach ($gedcom_files as $gedcom_file) { |
|
137 | + $filemtime = filemtime($gedcom_file); // Only import files that have changed |
|
138 | + $basename = basename($gedcom_file); |
|
139 | + $basenames[] = $basename; |
|
140 | + |
|
141 | + $tree = Tree::findByName($basename); |
|
142 | + if (!$tree) { |
|
143 | + $tree = Tree::create($basename, $basename); |
|
144 | + } |
|
145 | + if ($tree->getPreference('filemtime') != $filemtime) { |
|
146 | + $tree->importGedcomFile($gedcom_file, $basename); |
|
147 | + $tree->setPreference('filemtime', $filemtime); |
|
148 | + FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success'); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + foreach (Tree::getAll() as $tree) { |
|
153 | + if (!in_array($tree->getName(), $basenames)) { |
|
154 | + FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
155 | + $tree->delete(); |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + } |
|
160 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
161 | + |
|
162 | + return; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $default_tree_title = /* I18N: Default name for a new tree */ I18N::translate('My family tree'); |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | $default_tree_number = 1; |
168 | 168 | $existing_trees = Tree::getNameList(); |
169 | 169 | while (array_key_exists($default_tree_name . $default_tree_number, $existing_trees)) { |
170 | - $default_tree_number++; |
|
170 | + $default_tree_number++; |
|
171 | 171 | } |
172 | 172 | $default_tree_name .= $default_tree_number; |
173 | 173 | |
174 | 174 | // Process GET actions |
175 | 175 | switch (Filter::get('action')) { |
176 | 176 | case 'importform': |
177 | - $controller |
|
178 | - ->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file')) |
|
179 | - ->pageHeader(); |
|
177 | + $controller |
|
178 | + ->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file')) |
|
179 | + ->pageHeader(); |
|
180 | 180 | |
181 | - ?> |
|
181 | + ?> |
|
182 | 182 | <ol class="breadcrumb small"> |
183 | 183 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
184 | 184 | <li><a href="admin_trees_manage.php"><?php echo I18N::translate('Manage family trees'); ?></a></li> |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | <h1><?php echo $controller->getPageTitle(); ?></h1> |
189 | 189 | <?php |
190 | 190 | |
191 | - $tree = Tree::findById(Filter::getInteger('gedcom_id')); |
|
192 | - // Check it exists |
|
193 | - if (!$tree) { |
|
194 | - break; |
|
195 | - } |
|
196 | - $gedcom_filename = $tree->getPreference('gedcom_filename') |
|
197 | - ?> |
|
191 | + $tree = Tree::findById(Filter::getInteger('gedcom_id')); |
|
192 | + // Check it exists |
|
193 | + if (!$tree) { |
|
194 | + break; |
|
195 | + } |
|
196 | + $gedcom_filename = $tree->getPreference('gedcom_filename') |
|
197 | + ?> |
|
198 | 198 | <p> |
199 | 199 | <?php echo /* I18N: %s is the name of a family tree */ I18N::translate('This will delete all the genealogy data from “%s” and replace it with data from a GEDCOM file.', $tree->getTitleHtml()); ?> |
200 | 200 | </p> |
@@ -230,33 +230,33 @@ discard block |
||
230 | 230 | <?php echo WT_DATA_DIR; ?> |
231 | 231 | </span> |
232 | 232 | <?php |
233 | - $d = opendir(WT_DATA_DIR); |
|
234 | - $files = array(); |
|
235 | - while (($f = readdir($d)) !== false) { |
|
236 | - if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) { |
|
237 | - $fp = fopen(WT_DATA_DIR . $f, 'rb'); |
|
238 | - $header = fread($fp, 64); |
|
239 | - fclose($fp); |
|
240 | - if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) { |
|
241 | - $files[] = $f; |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
245 | - echo '<select name="tree_name" class="form-control" id="import-server-file">'; |
|
246 | - echo '<option value=""></option>'; |
|
247 | - sort($files); |
|
248 | - foreach ($files as $gedcom_file) { |
|
249 | - echo '<option value="', Filter::escapeHtml($gedcom_file), '" '; |
|
250 | - if ($gedcom_file === $gedcom_filename) { |
|
251 | - echo ' selected'; |
|
252 | - } |
|
253 | - echo'>', Filter::escapeHtml($gedcom_file), '</option>'; |
|
254 | - } |
|
255 | - if (!$files) { |
|
256 | - echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>'; |
|
257 | - } |
|
258 | - echo '</select>'; |
|
259 | - ?> |
|
233 | + $d = opendir(WT_DATA_DIR); |
|
234 | + $files = array(); |
|
235 | + while (($f = readdir($d)) !== false) { |
|
236 | + if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) { |
|
237 | + $fp = fopen(WT_DATA_DIR . $f, 'rb'); |
|
238 | + $header = fread($fp, 64); |
|
239 | + fclose($fp); |
|
240 | + if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) { |
|
241 | + $files[] = $f; |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | + echo '<select name="tree_name" class="form-control" id="import-server-file">'; |
|
246 | + echo '<option value=""></option>'; |
|
247 | + sort($files); |
|
248 | + foreach ($files as $gedcom_file) { |
|
249 | + echo '<option value="', Filter::escapeHtml($gedcom_file), '" '; |
|
250 | + if ($gedcom_file === $gedcom_filename) { |
|
251 | + echo ' selected'; |
|
252 | + } |
|
253 | + echo'>', Filter::escapeHtml($gedcom_file), '</option>'; |
|
254 | + } |
|
255 | + if (!$files) { |
|
256 | + echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>'; |
|
257 | + } |
|
258 | + echo '</select>'; |
|
259 | + ?> |
|
260 | 260 | </div> |
261 | 261 | </div> |
262 | 262 | </div> |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | </form> |
314 | 314 | <?php |
315 | 315 | |
316 | - return; |
|
316 | + return; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | if (!Tree::getAll()) { |
320 | - FlashMessages::addMessage(I18N::translate('You need to create a family tree.'), 'info'); |
|
320 | + FlashMessages::addMessage(I18N::translate('You need to create a family tree.'), 'info'); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | $controller->pageHeader(); |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | // On sites with hundreds or thousands of trees, this page becomes very large. |
327 | 327 | // Just show the current tree, the default tree, and unimported trees |
328 | 328 | if (count($all_trees) >= $multiple_tree_threshold) { |
329 | - $all_trees = array_filter($all_trees, function (Tree $x) use ($WT_TREE) { |
|
330 | - return $x->getPreference('imported') === '0' || $WT_TREE->getTreeId() === $x->getTreeId() || $x->getName() === Site::getPreference('DEFAULT_GEDCOM'); |
|
331 | - }); |
|
329 | + $all_trees = array_filter($all_trees, function (Tree $x) use ($WT_TREE) { |
|
330 | + return $x->getPreference('imported') === '0' || $WT_TREE->getTreeId() === $x->getTreeId() || $x->getName() === Site::getPreference('DEFAULT_GEDCOM'); |
|
331 | + }); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | // List the gedcoms available to this user |
@@ -356,23 +356,23 @@ discard block |
||
356 | 356 | <div class="panel-body"> |
357 | 357 | <?php |
358 | 358 | |
359 | - // The third row shows an optional progress bar and a list of maintenance options |
|
360 | - $importing = Database::prepare( |
|
361 | - "SELECT 1 FROM `##gedcom_chunk` WHERE gedcom_id = ? AND imported = '0' LIMIT 1" |
|
362 | - )->execute(array($tree->getTreeId()))->fetchOne(); |
|
363 | - if ($importing) { |
|
364 | - ?> |
|
359 | + // The third row shows an optional progress bar and a list of maintenance options |
|
360 | + $importing = Database::prepare( |
|
361 | + "SELECT 1 FROM `##gedcom_chunk` WHERE gedcom_id = ? AND imported = '0' LIMIT 1" |
|
362 | + )->execute(array($tree->getTreeId()))->fetchOne(); |
|
363 | + if ($importing) { |
|
364 | + ?> |
|
365 | 365 | <div id="import<?php echo $tree->getTreeId(); ?>" class="col-xs-12"> |
366 | 366 | <div class="progress"> |
367 | 367 | <?php echo I18N::translate('Calculating…'); ?> |
368 | 368 | </div> |
369 | 369 | </div> |
370 | 370 | <?php |
371 | - $controller->addInlineJavascript( |
|
372 | - 'jQuery("#import' . $tree->getTreeId() . '").load("import.php?gedcom_id=' . $tree->getTreeId() . '");' |
|
373 | - ); |
|
374 | - } |
|
375 | - ?> |
|
371 | + $controller->addInlineJavascript( |
|
372 | + 'jQuery("#import' . $tree->getTreeId() . '").load("import.php?gedcom_id=' . $tree->getTreeId() . '");' |
|
373 | + ); |
|
374 | + } |
|
375 | + ?> |
|
376 | 376 | <div class="row<?php echo $importing ? ' hidden' : ''; ?>" id="actions<?php echo $tree->getTreeId(); ?>"> |
377 | 377 | <div class="col-sm-6 col-md-3"> |
378 | 378 | <h3> |
@@ -50,116 +50,116 @@ discard block |
||
50 | 50 | } |
51 | 51 | // Process POST actions |
52 | 52 | switch (Filter::post('action')) { |
53 | -case 'delete': |
|
54 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
55 | - if (Filter::checkCsrf() && $gedcom_id) { |
|
56 | - $tree = Tree::findById($gedcom_id); |
|
57 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
58 | - $tree->delete(); |
|
59 | - } |
|
60 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
61 | - |
|
62 | - return; |
|
63 | -case 'setdefault': |
|
64 | - if (Filter::checkCsrf()) { |
|
65 | - Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged')); |
|
66 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success'); |
|
67 | - } |
|
68 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
69 | - |
|
70 | - return; |
|
71 | -case 'new_tree': |
|
72 | - $basename = basename(Filter::post('tree_name')); |
|
73 | - $tree_title = Filter::post('tree_title'); |
|
74 | - |
|
75 | - if (Filter::checkCsrf() && $basename && $tree_title) { |
|
76 | - if (Tree::findByName($basename)) { |
|
77 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger'); |
|
78 | - } else { |
|
79 | - Tree::create($basename, $tree_title); |
|
80 | - FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success'); |
|
81 | - } |
|
82 | - } |
|
83 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename)); |
|
84 | - |
|
85 | - return; |
|
86 | -case 'replace_upload': |
|
87 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
88 | - $keep_media = Filter::post('keep_media', '1', '0'); |
|
89 | - $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
90 | - $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
91 | - $tree = Tree::findById($gedcom_id); |
|
92 | - |
|
93 | - if (Filter::checkCsrf() && $tree) { |
|
94 | - $tree->setPreference('keep_media', $keep_media); |
|
95 | - $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
96 | - $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
97 | - if (isset($_FILES['tree_name'])) { |
|
98 | - if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { |
|
99 | - $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); |
|
100 | - } else { |
|
101 | - FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger'); |
|
102 | - } |
|
103 | - } else { |
|
104 | - FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
105 | - } |
|
106 | - } |
|
107 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | - |
|
109 | - return; |
|
110 | -case 'replace_import': |
|
111 | - $basename = basename(Filter::post('tree_name')); |
|
112 | - $gedcom_id = Filter::postInteger('gedcom_id'); |
|
113 | - $keep_media = Filter::post('keep_media', '1', '0'); |
|
114 | - $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
115 | - $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
116 | - $tree = Tree::findById($gedcom_id); |
|
117 | - |
|
118 | - if (Filter::checkCsrf() && $tree) { |
|
119 | - $tree->setPreference('keep_media', $keep_media); |
|
120 | - $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
121 | - $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
122 | - if ($basename) { |
|
123 | - $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); |
|
124 | - } else { |
|
125 | - FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
126 | - } |
|
127 | - } |
|
128 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
129 | - |
|
130 | - return; |
|
131 | - |
|
132 | -case 'synchronize': |
|
133 | - if (Filter::checkCsrf()) { |
|
134 | - $basenames = array(); |
|
135 | - |
|
136 | - foreach ($gedcom_files as $gedcom_file) { |
|
137 | - $filemtime = filemtime($gedcom_file); // Only import files that have changed |
|
138 | - $basename = basename($gedcom_file); |
|
139 | - $basenames[] = $basename; |
|
140 | - |
|
141 | - $tree = Tree::findByName($basename); |
|
142 | - if (!$tree) { |
|
143 | - $tree = Tree::create($basename, $basename); |
|
144 | - } |
|
145 | - if ($tree->getPreference('filemtime') != $filemtime) { |
|
146 | - $tree->importGedcomFile($gedcom_file, $basename); |
|
147 | - $tree->setPreference('filemtime', $filemtime); |
|
148 | - FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success'); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - foreach (Tree::getAll() as $tree) { |
|
153 | - if (!in_array($tree->getName(), $basenames)) { |
|
154 | - FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
155 | - $tree->delete(); |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - } |
|
160 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
161 | - |
|
162 | - return; |
|
53 | + case 'delete': |
|
54 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
55 | + if (Filter::checkCsrf() && $gedcom_id) { |
|
56 | + $tree = Tree::findById($gedcom_id); |
|
57 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
58 | + $tree->delete(); |
|
59 | + } |
|
60 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
61 | + |
|
62 | + return; |
|
63 | + case 'setdefault': |
|
64 | + if (Filter::checkCsrf()) { |
|
65 | + Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged')); |
|
66 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success'); |
|
67 | + } |
|
68 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
69 | + |
|
70 | + return; |
|
71 | + case 'new_tree': |
|
72 | + $basename = basename(Filter::post('tree_name')); |
|
73 | + $tree_title = Filter::post('tree_title'); |
|
74 | + |
|
75 | + if (Filter::checkCsrf() && $basename && $tree_title) { |
|
76 | + if (Tree::findByName($basename)) { |
|
77 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger'); |
|
78 | + } else { |
|
79 | + Tree::create($basename, $tree_title); |
|
80 | + FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success'); |
|
81 | + } |
|
82 | + } |
|
83 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename)); |
|
84 | + |
|
85 | + return; |
|
86 | + case 'replace_upload': |
|
87 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
88 | + $keep_media = Filter::post('keep_media', '1', '0'); |
|
89 | + $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
90 | + $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
91 | + $tree = Tree::findById($gedcom_id); |
|
92 | + |
|
93 | + if (Filter::checkCsrf() && $tree) { |
|
94 | + $tree->setPreference('keep_media', $keep_media); |
|
95 | + $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
96 | + $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
97 | + if (isset($_FILES['tree_name'])) { |
|
98 | + if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { |
|
99 | + $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); |
|
100 | + } else { |
|
101 | + FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger'); |
|
102 | + } |
|
103 | + } else { |
|
104 | + FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
105 | + } |
|
106 | + } |
|
107 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
108 | + |
|
109 | + return; |
|
110 | + case 'replace_import': |
|
111 | + $basename = basename(Filter::post('tree_name')); |
|
112 | + $gedcom_id = Filter::postInteger('gedcom_id'); |
|
113 | + $keep_media = Filter::post('keep_media', '1', '0'); |
|
114 | + $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); |
|
115 | + $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); |
|
116 | + $tree = Tree::findById($gedcom_id); |
|
117 | + |
|
118 | + if (Filter::checkCsrf() && $tree) { |
|
119 | + $tree->setPreference('keep_media', $keep_media); |
|
120 | + $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); |
|
121 | + $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); |
|
122 | + if ($basename) { |
|
123 | + $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); |
|
124 | + } else { |
|
125 | + FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); |
|
126 | + } |
|
127 | + } |
|
128 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
129 | + |
|
130 | + return; |
|
131 | + |
|
132 | + case 'synchronize': |
|
133 | + if (Filter::checkCsrf()) { |
|
134 | + $basenames = array(); |
|
135 | + |
|
136 | + foreach ($gedcom_files as $gedcom_file) { |
|
137 | + $filemtime = filemtime($gedcom_file); // Only import files that have changed |
|
138 | + $basename = basename($gedcom_file); |
|
139 | + $basenames[] = $basename; |
|
140 | + |
|
141 | + $tree = Tree::findByName($basename); |
|
142 | + if (!$tree) { |
|
143 | + $tree = Tree::create($basename, $basename); |
|
144 | + } |
|
145 | + if ($tree->getPreference('filemtime') != $filemtime) { |
|
146 | + $tree->importGedcomFile($gedcom_file, $basename); |
|
147 | + $tree->setPreference('filemtime', $filemtime); |
|
148 | + FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success'); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + foreach (Tree::getAll() as $tree) { |
|
153 | + if (!in_array($tree->getName(), $basenames)) { |
|
154 | + FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); |
|
155 | + $tree->delete(); |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + } |
|
160 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); |
|
161 | + |
|
162 | + return; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $default_tree_title = /* I18N: Default name for a new tree */ I18N::translate('My family tree'); |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | |
174 | 174 | // Process GET actions |
175 | 175 | switch (Filter::get('action')) { |
176 | -case 'importform': |
|
177 | - $controller |
|
178 | - ->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file')) |
|
179 | - ->pageHeader(); |
|
176 | + case 'importform': |
|
177 | + $controller |
|
178 | + ->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file')) |
|
179 | + ->pageHeader(); |
|
180 | 180 | |
181 | - ?> |
|
181 | + ?> |
|
182 | 182 | <ol class="breadcrumb small"> |
183 | 183 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
184 | 184 | <li><a href="admin_trees_manage.php"><?php echo I18N::translate('Manage family trees'); ?></a></li> |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | <h1><?php echo $controller->getPageTitle(); ?></h1> |
189 | 189 | <?php |
190 | 190 | |
191 | - $tree = Tree::findById(Filter::getInteger('gedcom_id')); |
|
192 | - // Check it exists |
|
193 | - if (!$tree) { |
|
194 | - break; |
|
195 | - } |
|
196 | - $gedcom_filename = $tree->getPreference('gedcom_filename') |
|
197 | - ?> |
|
198 | - <p> |
|
191 | + $tree = Tree::findById(Filter::getInteger('gedcom_id')); |
|
192 | + // Check it exists |
|
193 | + if (!$tree) { |
|
194 | + break; |
|
195 | + } |
|
196 | + $gedcom_filename = $tree->getPreference('gedcom_filename') |
|
197 | + ?> |
|
198 | + <p> |
|
199 | 199 | <?php echo /* I18N: %s is the name of a family tree */ I18N::translate('This will delete all the genealogy data from “%s” and replace it with data from a GEDCOM file.', $tree->getTitleHtml()); ?> |
200 | 200 | </p> |
201 | 201 | <form class="form form-horizontal" name="gedcomimportform" method="post" enctype="multipart/form-data" onsubmit="return checkGedcomImportForm('<?php echo Filter::escapeHtml(I18N::translate('You have selected a GEDCOM file with a different name. Is this correct?')); ?>');"> |
@@ -228,35 +228,35 @@ discard block |
||
228 | 228 | <div class="input-group"> |
229 | 229 | <span class="input-group-addon"> |
230 | 230 | <?php echo WT_DATA_DIR; ?> |
231 | - </span> |
|
231 | + </span> |
|
232 | 232 | <?php |
233 | - $d = opendir(WT_DATA_DIR); |
|
234 | - $files = array(); |
|
235 | - while (($f = readdir($d)) !== false) { |
|
236 | - if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) { |
|
237 | - $fp = fopen(WT_DATA_DIR . $f, 'rb'); |
|
238 | - $header = fread($fp, 64); |
|
239 | - fclose($fp); |
|
240 | - if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) { |
|
241 | - $files[] = $f; |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
245 | - echo '<select name="tree_name" class="form-control" id="import-server-file">'; |
|
246 | - echo '<option value=""></option>'; |
|
247 | - sort($files); |
|
248 | - foreach ($files as $gedcom_file) { |
|
249 | - echo '<option value="', Filter::escapeHtml($gedcom_file), '" '; |
|
250 | - if ($gedcom_file === $gedcom_filename) { |
|
251 | - echo ' selected'; |
|
252 | - } |
|
253 | - echo'>', Filter::escapeHtml($gedcom_file), '</option>'; |
|
254 | - } |
|
255 | - if (!$files) { |
|
256 | - echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>'; |
|
257 | - } |
|
258 | - echo '</select>'; |
|
259 | - ?> |
|
233 | + $d = opendir(WT_DATA_DIR); |
|
234 | + $files = array(); |
|
235 | + while (($f = readdir($d)) !== false) { |
|
236 | + if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) { |
|
237 | + $fp = fopen(WT_DATA_DIR . $f, 'rb'); |
|
238 | + $header = fread($fp, 64); |
|
239 | + fclose($fp); |
|
240 | + if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) { |
|
241 | + $files[] = $f; |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | + echo '<select name="tree_name" class="form-control" id="import-server-file">'; |
|
246 | + echo '<option value=""></option>'; |
|
247 | + sort($files); |
|
248 | + foreach ($files as $gedcom_file) { |
|
249 | + echo '<option value="', Filter::escapeHtml($gedcom_file), '" '; |
|
250 | + if ($gedcom_file === $gedcom_filename) { |
|
251 | + echo ' selected'; |
|
252 | + } |
|
253 | + echo'>', Filter::escapeHtml($gedcom_file), '</option>'; |
|
254 | + } |
|
255 | + if (!$files) { |
|
256 | + echo '<option disabled selected>', I18N::translate('No GEDCOM files found.'), '</option>'; |
|
257 | + } |
|
258 | + echo '</select>'; |
|
259 | + ?> |
|
260 | 260 | </div> |
261 | 261 | </div> |
262 | 262 | </div> |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | > |
299 | 299 | <p class="small text-muted"> |
300 | 300 | <?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. A “path” is something like “C:\Documents\Genealogy\Photos\John_Smith.jpeg” */ I18N::translate('Some genealogy software creates GEDCOM files that contain media filenames with full paths. These paths will not exist on the web-server. To allow webtrees to find the file, the first part of the path must be removed.'); ?> |
301 | - <?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. %s are all folder names */ I18N::translate('For example, if the GEDCOM file contains %1$s and webtrees expects to find %2$s in the media folder, then you would need to remove %3$s.', '<code>C:\\Documents\\family\\photo.jpeg</code>', '<code>family\\photo.jpeg</code>', '<code>C:\\Documents\\</code>'); ?> |
|
301 | + <?php echo /* I18N: Help text for the “GEDCOM media path” configuration setting. %s are all folder names */ I18N::translate('For example, if the GEDCOM file contains %1$s and webtrees expects to find %2$s in the media folder, then you would need to remove %3$s.', '<code>C:\\Documents\\family\\photo.jpeg</code>', '<code>family\\photo.jpeg</code>', '<code>C:\\Documents\\</code>'); ?> |
|
302 | 302 | </p> |
303 | 303 | </div> |
304 | 304 | </fieldset> |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | </form> |
314 | 314 | <?php |
315 | 315 | |
316 | - return; |
|
316 | + return; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | if (!Tree::getAll()) { |
@@ -436,8 +436,11 @@ |
||
436 | 436 | <i class="fa fa-li fa-star"></i> |
437 | 437 | <?php if ($tree->getName() == Site::getPreference('DEFAULT_GEDCOM')): ?> |
438 | 438 | <?php echo I18N::translate('Default family tree'); ?> |
439 | - <?php else: ?> |
|
440 | - <a href="#" onclick="document.defaultform<?php echo $tree->getTreeId(); ?>.submit();"> |
|
439 | + <?php else { |
|
440 | + : ?> |
|
441 | + <a href="#" onclick="document.defaultform<?php echo $tree->getTreeId(); |
|
442 | +} |
|
443 | +?>.submit();"> |
|
441 | 444 | <?php echo I18N::translate('Set as default'); ?> |
442 | 445 | <span class="sr-only"> |
443 | 446 | <?php echo $tree->getTitleHtml(); ?> |
@@ -32,48 +32,48 @@ discard block |
||
32 | 32 | |
33 | 33 | $record = GedcomRecord::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE); |
34 | 34 | if ( |
35 | - $record instanceof Individual || |
|
36 | - $record instanceof Family || |
|
37 | - $record instanceof Source || |
|
38 | - $record instanceof Repository || |
|
39 | - $record instanceof Note || |
|
40 | - $record instanceof Media |
|
35 | + $record instanceof Individual || |
|
36 | + $record instanceof Family || |
|
37 | + $record instanceof Source || |
|
38 | + $record instanceof Repository || |
|
39 | + $record instanceof Note || |
|
40 | + $record instanceof Media |
|
41 | 41 | ) { |
42 | - header('Location: ' . WT_BASE_URL . $record->getRawUrl()); |
|
42 | + header('Location: ' . WT_BASE_URL . $record->getRawUrl()); |
|
43 | 43 | |
44 | - return; |
|
44 | + return; |
|
45 | 45 | } |
46 | 46 | $controller = new GedcomRecordController($record); |
47 | 47 | |
48 | 48 | if ($controller->record && $controller->record->canShow()) { |
49 | - if ($controller->record->isPendingDeletion()) { |
|
50 | - if (Auth::isModerator($controller->record->getTree())) { |
|
51 | - FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( |
|
52 | - 'This record has been deleted. You should review the deletion and then %1$s or %2$s it.', |
|
53 | - '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', |
|
54 | - '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>' |
|
55 | - ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
56 | - } elseif (Auth::isEditor($controller->record->getTree())) { |
|
57 | - FlashMessages::addMessage(I18N::translate('This record has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
58 | - } |
|
59 | - } elseif ($controller->record->isPendingAddtion()) { |
|
60 | - if (Auth::isModerator($controller->record->getTree())) { |
|
61 | - FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( |
|
62 | - 'This record has been edited. You should review the changes and then %1$s or %2$s them.', |
|
63 | - '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', |
|
64 | - '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>' |
|
65 | - ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
66 | - } elseif (Auth::isEditor($controller->record->getTree())) { |
|
67 | - FlashMessages::addMessage(I18N::translate('This record has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
68 | - } |
|
69 | - } |
|
70 | - $controller->pageHeader(); |
|
49 | + if ($controller->record->isPendingDeletion()) { |
|
50 | + if (Auth::isModerator($controller->record->getTree())) { |
|
51 | + FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( |
|
52 | + 'This record has been deleted. You should review the deletion and then %1$s or %2$s it.', |
|
53 | + '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', |
|
54 | + '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>' |
|
55 | + ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
56 | + } elseif (Auth::isEditor($controller->record->getTree())) { |
|
57 | + FlashMessages::addMessage(I18N::translate('This record has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
58 | + } |
|
59 | + } elseif ($controller->record->isPendingAddtion()) { |
|
60 | + if (Auth::isModerator($controller->record->getTree())) { |
|
61 | + FlashMessages::addMessage(/* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate( |
|
62 | + 'This record has been edited. You should review the changes and then %1$s or %2$s them.', |
|
63 | + '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', |
|
64 | + '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>' |
|
65 | + ) . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
66 | + } elseif (Auth::isEditor($controller->record->getTree())) { |
|
67 | + FlashMessages::addMessage(I18N::translate('This record has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning'); |
|
68 | + } |
|
69 | + } |
|
70 | + $controller->pageHeader(); |
|
71 | 71 | } else { |
72 | - FlashMessages::addMessage(I18N::translate('This record does not exist or you do not have permission to view it.'), 'danger'); |
|
73 | - http_response_code(404); |
|
74 | - $controller->pageHeader(); |
|
72 | + FlashMessages::addMessage(I18N::translate('This record does not exist or you do not have permission to view it.'), 'danger'); |
|
73 | + http_response_code(404); |
|
74 | + $controller->pageHeader(); |
|
75 | 75 | |
76 | - return; |
|
76 | + return; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $controller->addInlineJavascript(' |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | <div id="record-edit"> |
142 | 142 | <table class="facts_table"> |
143 | 143 | <?php |
144 | - foreach ($facts as $fact) { |
|
145 | - FunctionsPrintFacts::printFact($fact, $controller->record); |
|
146 | - } |
|
147 | - ?> |
|
144 | + foreach ($facts as $fact) { |
|
145 | + FunctionsPrintFacts::printFact($fact, $controller->record); |
|
146 | + } |
|
147 | + ?> |
|
148 | 148 | </table> |
149 | 149 | </div> |
150 | 150 |
@@ -34,6 +34,6 @@ |
||
34 | 34 | $controller->pageHeader(); |
35 | 35 | |
36 | 36 | echo '<div id="sourcelist-page">', |
37 | - '<h2>', I18N::translate('Sources'), '</h2>'; |
|
38 | - echo FunctionsPrintLists::sourceTable(FunctionsDb::getSourceList($WT_TREE)); |
|
37 | + '<h2>', I18N::translate('Sources'), '</h2>'; |
|
38 | + echo FunctionsPrintLists::sourceTable(FunctionsDb::getSourceList($WT_TREE)); |
|
39 | 39 | echo '</div>'; |
@@ -34,6 +34,6 @@ |
||
34 | 34 | $controller->pageHeader(); |
35 | 35 | |
36 | 36 | echo '<div id="repolist-page">', |
37 | - '<h2>', I18N::translate('Repositories'), '</h2>'; |
|
38 | - echo FunctionsPrintLists::repositoryTable(FunctionsDb::getRepositoryList($WT_TREE)); |
|
37 | + '<h2>', I18N::translate('Repositories'), '</h2>'; |
|
38 | + echo FunctionsPrintLists::repositoryTable(FunctionsDb::getRepositoryList($WT_TREE)); |
|
39 | 39 | echo '</div>'; |
@@ -36,56 +36,56 @@ discard block |
||
36 | 36 | |
37 | 37 | $controller = new SimpleController; |
38 | 38 | $controller |
39 | - ->restrictAccess($to_user || Auth::isAdmin() && ($to === 'all' || $to === 'last_6mo' || $to === 'never_logged')) |
|
40 | - ->setPageTitle(I18N::translate('webtrees message')); |
|
39 | + ->restrictAccess($to_user || Auth::isAdmin() && ($to === 'all' || $to === 'last_6mo' || $to === 'never_logged')) |
|
40 | + ->setPageTitle(I18N::translate('webtrees message')); |
|
41 | 41 | |
42 | 42 | $errors = ''; |
43 | 43 | |
44 | 44 | // Is this message from a member or a visitor? |
45 | 45 | if (Auth::check()) { |
46 | - $from = Auth::user()->getUserName(); |
|
46 | + $from = Auth::user()->getUserName(); |
|
47 | 47 | } else { |
48 | - // Visitors must provide a valid email address |
|
49 | - if ($from_email && (!preg_match("/(.+)@(.+)/", $from_email, $match) || function_exists('checkdnsrr') && checkdnsrr($match[2]) === false)) { |
|
50 | - $errors .= '<p class="ui-state-error">' . I18N::translate('Please enter a valid email address.') . '</p>'; |
|
51 | - $action = 'compose'; |
|
52 | - } |
|
48 | + // Visitors must provide a valid email address |
|
49 | + if ($from_email && (!preg_match("/(.+)@(.+)/", $from_email, $match) || function_exists('checkdnsrr') && checkdnsrr($match[2]) === false)) { |
|
50 | + $errors .= '<p class="ui-state-error">' . I18N::translate('Please enter a valid email address.') . '</p>'; |
|
51 | + $action = 'compose'; |
|
52 | + } |
|
53 | 53 | |
54 | - // Do not allow anonymous visitors to include links to external sites |
|
55 | - if (preg_match('/(?!' . preg_quote(WT_BASE_URL, '/') . ')(((?:ftp|http|https):\/\/)[a-zA-Z0-9.-]+)/', $subject . $body, $match)) { |
|
56 | - $errors .= |
|
57 | - '<p class="ui-state-error">' . I18N::translate('You are not allowed to send messages that contain external links.') . '</p>' . |
|
58 | - '<p class="ui-state-highlight">' . /* I18N: e.g. ‘You should delete the “http://” from “http://www.example.com” and try again.’ */ I18N::translate('You should delete the “%1$s” from “%2$s” and try again.', $match[2], $match[1]) . '</p>' . |
|
59 | - Log::addAuthenticationLog('Possible spam message from "' . $from_name . '"/"' . $from_email . '", subject="' . $subject . '", body="' . $body . '"'); |
|
60 | - $action = 'compose'; |
|
61 | - } |
|
62 | - $from = $from_email; |
|
54 | + // Do not allow anonymous visitors to include links to external sites |
|
55 | + if (preg_match('/(?!' . preg_quote(WT_BASE_URL, '/') . ')(((?:ftp|http|https):\/\/)[a-zA-Z0-9.-]+)/', $subject . $body, $match)) { |
|
56 | + $errors .= |
|
57 | + '<p class="ui-state-error">' . I18N::translate('You are not allowed to send messages that contain external links.') . '</p>' . |
|
58 | + '<p class="ui-state-highlight">' . /* I18N: e.g. ‘You should delete the “http://” from “http://www.example.com” and try again.’ */ I18N::translate('You should delete the “%1$s” from “%2$s” and try again.', $match[2], $match[1]) . '</p>' . |
|
59 | + Log::addAuthenticationLog('Possible spam message from "' . $from_name . '"/"' . $from_email . '", subject="' . $subject . '", body="' . $body . '"'); |
|
60 | + $action = 'compose'; |
|
61 | + } |
|
62 | + $from = $from_email; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Ensure the user always visits this page twice - once to compose it and again to send it. |
66 | 66 | // This makes it harder for spammers. |
67 | 67 | switch ($action) { |
68 | 68 | case 'compose': |
69 | - Session::put('good_to_send', true); |
|
70 | - break; |
|
69 | + Session::put('good_to_send', true); |
|
70 | + break; |
|
71 | 71 | case 'send': |
72 | - // Only send messages if we've come straight from the compose page. |
|
73 | - if (!Session::get('good_to_send')) { |
|
74 | - Log::addAuthenticationLog('Attempt to send a message without visiting the compose page. Spam attack?'); |
|
75 | - $action = 'compose'; |
|
76 | - } |
|
77 | - if (!Filter::checkCsrf()) { |
|
78 | - $action = 'compose'; |
|
79 | - } |
|
80 | - Session::forget('good_to_send'); |
|
81 | - break; |
|
72 | + // Only send messages if we've come straight from the compose page. |
|
73 | + if (!Session::get('good_to_send')) { |
|
74 | + Log::addAuthenticationLog('Attempt to send a message without visiting the compose page. Spam attack?'); |
|
75 | + $action = 'compose'; |
|
76 | + } |
|
77 | + if (!Filter::checkCsrf()) { |
|
78 | + $action = 'compose'; |
|
79 | + } |
|
80 | + Session::forget('good_to_send'); |
|
81 | + break; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | switch ($action) { |
85 | 85 | case 'compose': |
86 | - $controller |
|
87 | - ->pageHeader() |
|
88 | - ->addInlineJavascript(' |
|
86 | + $controller |
|
87 | + ->pageHeader() |
|
88 | + ->addInlineJavascript(' |
|
89 | 89 | function checkForm(frm) { |
90 | 90 | if (frm.subject.value === "") { |
91 | 91 | alert("' . I18N::translate('Please enter a message subject.') . '"); |
@@ -100,105 +100,105 @@ discard block |
||
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | '); |
103 | - echo '<span class="subheaders">', I18N::translate('Send a message'), '</span>'; |
|
104 | - echo $errors; |
|
103 | + echo '<span class="subheaders">', I18N::translate('Send a message'), '</span>'; |
|
104 | + echo $errors; |
|
105 | 105 | |
106 | - if (!Auth::check()) { |
|
107 | - echo '<br><br>', I18N::translate('<b>Please note:</b> Private information of living individuals will only be given to family relatives and close friends. You will be asked to verify your relationship before you will receive any private data. Sometimes information of dead individuals may also be private. If this is the case, it is because there is not enough information known about the individual to determine whether they are alive or not and we probably do not have more information on this individual.<br><br>Before asking a question, please verify that you are inquiring about the correct individual by checking dates, places, and close relatives. If you are submitting changes to the genealogy data, please include the sources where you obtained the data.'); |
|
108 | - } |
|
109 | - echo '<br><form name="messageform" method="post" action="message.php" onsubmit="t = new Date(); document.messageform.time.value=t.toUTCString(); return checkForm(this);">'; |
|
110 | - echo Filter::getCsrf(); |
|
111 | - echo '<table>'; |
|
112 | - if ($to !== 'all' && $to !== 'last_6mo' && $to !== 'never_logged') { |
|
113 | - echo '<tr><td></td><td>', I18N::translate('This message will be sent to %s', '<b>' . $to_user->getRealNameHtml() . '</b>'), '</td></tr>'; |
|
114 | - } |
|
115 | - if (!Auth::check()) { |
|
116 | - echo '<tr style="vertical-align:top;"><td width="15%">', I18N::translate('Your name'), '</td>'; |
|
117 | - echo '<td><input type="text" name="from_name" size="40" value="', Filter::escapeHtml($from_name), '"></td></tr><tr style="vertical-align:top;"><td>', I18N::translate('Email address'), '</td><td><input type="email" name="from_email" size="40" value="', Filter::escapeHtml($from_email), '"><br>', I18N::translate('Please provide your email address so that we may contact you in response to this message. If you do not provide your email address we will not be able to respond to your inquiry. Your email address will not be used in any other way besides responding to this inquiry.'), '<br><br></td></tr>'; |
|
118 | - } |
|
119 | - echo '<tr style="vertical-align:top;"><td>', I18N::translate('Subject'), '</td>'; |
|
120 | - echo '<td>'; |
|
121 | - echo '<input type="hidden" name="action" value="send">'; |
|
122 | - echo '<input type="hidden" name="to" value="', Filter::escapeHtml($to), '">'; |
|
123 | - echo '<input type="hidden" name="time" value="">'; |
|
124 | - echo '<input type="hidden" name="method" value="', $method, '">'; |
|
125 | - echo '<input type="hidden" name="url" value="', Filter::escapeHtml($url), '">'; |
|
126 | - echo '<input type="text" name="subject" size="50" value="', Filter::escapeHtml($subject), '"><br></td></tr>'; |
|
127 | - echo '<tr style="vertical-align:top;"><td>', I18N::translate('Body'), '<br></td><td><textarea name="body" cols="50" rows="7">', Filter::escapeHtml($body), '</textarea><br></td></tr>'; |
|
128 | - echo '<tr><td></td><td><input type="submit" value="', I18N::translate('Send'), '"></td></tr>'; |
|
129 | - echo '</table>'; |
|
130 | - echo '</form>'; |
|
131 | - if ($method === 'messaging2') { |
|
132 | - echo I18N::translate('When you send this message you will receive a copy sent via email to the address you provided.'); |
|
133 | - } |
|
134 | - echo |
|
135 | - '<br><br><br><br>', |
|
136 | - '<p id="save-cancel">', |
|
137 | - '<input type="button" class="cancel" value="', I18N::translate('close'), '" onclick="window.close();">', |
|
138 | - '</p>'; |
|
139 | - break; |
|
106 | + if (!Auth::check()) { |
|
107 | + echo '<br><br>', I18N::translate('<b>Please note:</b> Private information of living individuals will only be given to family relatives and close friends. You will be asked to verify your relationship before you will receive any private data. Sometimes information of dead individuals may also be private. If this is the case, it is because there is not enough information known about the individual to determine whether they are alive or not and we probably do not have more information on this individual.<br><br>Before asking a question, please verify that you are inquiring about the correct individual by checking dates, places, and close relatives. If you are submitting changes to the genealogy data, please include the sources where you obtained the data.'); |
|
108 | + } |
|
109 | + echo '<br><form name="messageform" method="post" action="message.php" onsubmit="t = new Date(); document.messageform.time.value=t.toUTCString(); return checkForm(this);">'; |
|
110 | + echo Filter::getCsrf(); |
|
111 | + echo '<table>'; |
|
112 | + if ($to !== 'all' && $to !== 'last_6mo' && $to !== 'never_logged') { |
|
113 | + echo '<tr><td></td><td>', I18N::translate('This message will be sent to %s', '<b>' . $to_user->getRealNameHtml() . '</b>'), '</td></tr>'; |
|
114 | + } |
|
115 | + if (!Auth::check()) { |
|
116 | + echo '<tr style="vertical-align:top;"><td width="15%">', I18N::translate('Your name'), '</td>'; |
|
117 | + echo '<td><input type="text" name="from_name" size="40" value="', Filter::escapeHtml($from_name), '"></td></tr><tr style="vertical-align:top;"><td>', I18N::translate('Email address'), '</td><td><input type="email" name="from_email" size="40" value="', Filter::escapeHtml($from_email), '"><br>', I18N::translate('Please provide your email address so that we may contact you in response to this message. If you do not provide your email address we will not be able to respond to your inquiry. Your email address will not be used in any other way besides responding to this inquiry.'), '<br><br></td></tr>'; |
|
118 | + } |
|
119 | + echo '<tr style="vertical-align:top;"><td>', I18N::translate('Subject'), '</td>'; |
|
120 | + echo '<td>'; |
|
121 | + echo '<input type="hidden" name="action" value="send">'; |
|
122 | + echo '<input type="hidden" name="to" value="', Filter::escapeHtml($to), '">'; |
|
123 | + echo '<input type="hidden" name="time" value="">'; |
|
124 | + echo '<input type="hidden" name="method" value="', $method, '">'; |
|
125 | + echo '<input type="hidden" name="url" value="', Filter::escapeHtml($url), '">'; |
|
126 | + echo '<input type="text" name="subject" size="50" value="', Filter::escapeHtml($subject), '"><br></td></tr>'; |
|
127 | + echo '<tr style="vertical-align:top;"><td>', I18N::translate('Body'), '<br></td><td><textarea name="body" cols="50" rows="7">', Filter::escapeHtml($body), '</textarea><br></td></tr>'; |
|
128 | + echo '<tr><td></td><td><input type="submit" value="', I18N::translate('Send'), '"></td></tr>'; |
|
129 | + echo '</table>'; |
|
130 | + echo '</form>'; |
|
131 | + if ($method === 'messaging2') { |
|
132 | + echo I18N::translate('When you send this message you will receive a copy sent via email to the address you provided.'); |
|
133 | + } |
|
134 | + echo |
|
135 | + '<br><br><br><br>', |
|
136 | + '<p id="save-cancel">', |
|
137 | + '<input type="button" class="cancel" value="', I18N::translate('close'), '" onclick="window.close();">', |
|
138 | + '</p>'; |
|
139 | + break; |
|
140 | 140 | |
141 | 141 | case 'send': |
142 | - if ($from_email) { |
|
143 | - $from = $from_email; |
|
144 | - } |
|
142 | + if ($from_email) { |
|
143 | + $from = $from_email; |
|
144 | + } |
|
145 | 145 | |
146 | - $toarray = array($to); |
|
147 | - if ($to === 'all') { |
|
148 | - $toarray = array(); |
|
149 | - foreach (User::all() as $user) { |
|
150 | - $toarray[$user->getUserId()] = $user->getUserName(); |
|
151 | - } |
|
152 | - } |
|
153 | - if ($to === 'never_logged') { |
|
154 | - $toarray = array(); |
|
155 | - foreach (User::all() as $user) { |
|
156 | - if ($user->getPreference('verified_by_admin') && $user->getPreference('reg_timestamp') > $user->getPreference('sessiontime')) { |
|
157 | - $toarray[$user->getUserId()] = $user->getUserName(); |
|
158 | - } |
|
159 | - } |
|
160 | - } |
|
161 | - if ($to === 'last_6mo') { |
|
162 | - $toarray = array(); |
|
163 | - $sixmos = 60 * 60 * 24 * 30 * 6; //-- timestamp for six months |
|
164 | - foreach (User::all() as $user) { |
|
165 | - if ($user->getPreference('sessiontime') > 0 && (WT_TIMESTAMP - $user->getPreference('sessiontime') > $sixmos)) { |
|
166 | - $toarray[$user->getUserId()] = $user->getUserName(); |
|
167 | - } elseif (!$user->getPreference('verified_by_admin') && (WT_TIMESTAMP - $user->getPreference('reg_timestamp') > $sixmos)) { |
|
168 | - //-- not verified by registration past 6 months |
|
169 | - $toarray[$user->getUserId()] = $user->getUserName(); |
|
170 | - } |
|
171 | - } |
|
172 | - } |
|
173 | - $i = 0; |
|
174 | - foreach ($toarray as $indexval => $to) { |
|
175 | - $message = array(); |
|
176 | - $message['to'] = $to; |
|
177 | - $message['from'] = $from; |
|
178 | - if (!empty($from_name)) { |
|
179 | - $message['from_name'] = $from_name; |
|
180 | - $message['from_email'] = $from_email; |
|
181 | - } |
|
182 | - $message['subject'] = $subject; |
|
183 | - $message['body'] = nl2br($body, false); |
|
184 | - $message['created'] = WT_TIMESTAMP; |
|
185 | - $message['method'] = $method; |
|
186 | - $message['url'] = $url; |
|
187 | - if ($i > 0) { |
|
188 | - $message['no_from'] = true; |
|
189 | - } |
|
190 | - if (addMessage($message)) { |
|
191 | - FlashMessages::addMessage(I18N::translate('The message was successfully sent to %s.', Filter::escapeHtml($to))); |
|
192 | - } else { |
|
193 | - FlashMessages::addMessage(I18N::translate('The message was not sent.')); |
|
194 | - Log::addErrorLog('Unable to send a message. FROM:' . $from . ' TO:' . $to . ' (failed to send)'); |
|
195 | - } |
|
196 | - $i++; |
|
197 | - } |
|
198 | - $controller |
|
199 | - ->pageHeader() |
|
200 | - ->addInlineJavascript('window.opener.location.reload(); window.close();'); |
|
201 | - break; |
|
146 | + $toarray = array($to); |
|
147 | + if ($to === 'all') { |
|
148 | + $toarray = array(); |
|
149 | + foreach (User::all() as $user) { |
|
150 | + $toarray[$user->getUserId()] = $user->getUserName(); |
|
151 | + } |
|
152 | + } |
|
153 | + if ($to === 'never_logged') { |
|
154 | + $toarray = array(); |
|
155 | + foreach (User::all() as $user) { |
|
156 | + if ($user->getPreference('verified_by_admin') && $user->getPreference('reg_timestamp') > $user->getPreference('sessiontime')) { |
|
157 | + $toarray[$user->getUserId()] = $user->getUserName(); |
|
158 | + } |
|
159 | + } |
|
160 | + } |
|
161 | + if ($to === 'last_6mo') { |
|
162 | + $toarray = array(); |
|
163 | + $sixmos = 60 * 60 * 24 * 30 * 6; //-- timestamp for six months |
|
164 | + foreach (User::all() as $user) { |
|
165 | + if ($user->getPreference('sessiontime') > 0 && (WT_TIMESTAMP - $user->getPreference('sessiontime') > $sixmos)) { |
|
166 | + $toarray[$user->getUserId()] = $user->getUserName(); |
|
167 | + } elseif (!$user->getPreference('verified_by_admin') && (WT_TIMESTAMP - $user->getPreference('reg_timestamp') > $sixmos)) { |
|
168 | + //-- not verified by registration past 6 months |
|
169 | + $toarray[$user->getUserId()] = $user->getUserName(); |
|
170 | + } |
|
171 | + } |
|
172 | + } |
|
173 | + $i = 0; |
|
174 | + foreach ($toarray as $indexval => $to) { |
|
175 | + $message = array(); |
|
176 | + $message['to'] = $to; |
|
177 | + $message['from'] = $from; |
|
178 | + if (!empty($from_name)) { |
|
179 | + $message['from_name'] = $from_name; |
|
180 | + $message['from_email'] = $from_email; |
|
181 | + } |
|
182 | + $message['subject'] = $subject; |
|
183 | + $message['body'] = nl2br($body, false); |
|
184 | + $message['created'] = WT_TIMESTAMP; |
|
185 | + $message['method'] = $method; |
|
186 | + $message['url'] = $url; |
|
187 | + if ($i > 0) { |
|
188 | + $message['no_from'] = true; |
|
189 | + } |
|
190 | + if (addMessage($message)) { |
|
191 | + FlashMessages::addMessage(I18N::translate('The message was successfully sent to %s.', Filter::escapeHtml($to))); |
|
192 | + } else { |
|
193 | + FlashMessages::addMessage(I18N::translate('The message was not sent.')); |
|
194 | + Log::addErrorLog('Unable to send a message. FROM:' . $from . ' TO:' . $to . ' (failed to send)'); |
|
195 | + } |
|
196 | + $i++; |
|
197 | + } |
|
198 | + $controller |
|
199 | + ->pageHeader() |
|
200 | + ->addInlineJavascript('window.opener.location.reload(); window.close();'); |
|
201 | + break; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -209,120 +209,120 @@ discard block |
||
209 | 209 | * @return bool |
210 | 210 | */ |
211 | 211 | function addMessage($message) { |
212 | - global $WT_TREE; |
|
212 | + global $WT_TREE; |
|
213 | 213 | |
214 | - $success = true; |
|
214 | + $success = true; |
|
215 | 215 | |
216 | - $sender = User::findByIdentifier($message['from']); |
|
217 | - $recipient = User::findByIdentifier($message['to']); |
|
216 | + $sender = User::findByIdentifier($message['from']); |
|
217 | + $recipient = User::findByIdentifier($message['to']); |
|
218 | 218 | |
219 | - // Sender may not be a webtrees user |
|
220 | - if ($sender) { |
|
221 | - $sender_email = $sender->getEmail(); |
|
222 | - $sender_real_name = $sender->getRealName(); |
|
223 | - } else { |
|
224 | - $sender_email = $message['from']; |
|
225 | - $sender_real_name = $message['from_name']; |
|
226 | - } |
|
219 | + // Sender may not be a webtrees user |
|
220 | + if ($sender) { |
|
221 | + $sender_email = $sender->getEmail(); |
|
222 | + $sender_real_name = $sender->getRealName(); |
|
223 | + } else { |
|
224 | + $sender_email = $message['from']; |
|
225 | + $sender_real_name = $message['from_name']; |
|
226 | + } |
|
227 | 227 | |
228 | - // Send a copy of the copy message back to the sender. |
|
229 | - if ($message['method'] !== 'messaging') { |
|
230 | - // Switch to the sender’s language. |
|
231 | - if ($sender) { |
|
232 | - I18N::init($sender->getPreference('language')); |
|
233 | - } |
|
228 | + // Send a copy of the copy message back to the sender. |
|
229 | + if ($message['method'] !== 'messaging') { |
|
230 | + // Switch to the sender’s language. |
|
231 | + if ($sender) { |
|
232 | + I18N::init($sender->getPreference('language')); |
|
233 | + } |
|
234 | 234 | |
235 | - $copy_email = $message['body']; |
|
236 | - if (!empty($message['url'])) { |
|
237 | - $copy_email .= |
|
238 | - Mail::EOL . Mail::EOL . '--------------------------------------' . Mail::EOL . |
|
239 | - I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . Mail::EOL; |
|
240 | - } |
|
235 | + $copy_email = $message['body']; |
|
236 | + if (!empty($message['url'])) { |
|
237 | + $copy_email .= |
|
238 | + Mail::EOL . Mail::EOL . '--------------------------------------' . Mail::EOL . |
|
239 | + I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . Mail::EOL; |
|
240 | + } |
|
241 | 241 | |
242 | - if ($sender) { |
|
243 | - // Message from a signed-in user |
|
244 | - $copy_email = I18N::translate('You sent the following message to a webtrees user:') . ' ' . $recipient->getRealNameHtml() . Mail::EOL . Mail::EOL . $copy_email; |
|
245 | - } else { |
|
246 | - // Message from a visitor |
|
247 | - $copy_email = I18N::translate('You sent the following message to a webtrees administrator:') . Mail::EOL . Mail::EOL . Mail::EOL . $copy_email; |
|
248 | - } |
|
242 | + if ($sender) { |
|
243 | + // Message from a signed-in user |
|
244 | + $copy_email = I18N::translate('You sent the following message to a webtrees user:') . ' ' . $recipient->getRealNameHtml() . Mail::EOL . Mail::EOL . $copy_email; |
|
245 | + } else { |
|
246 | + // Message from a visitor |
|
247 | + $copy_email = I18N::translate('You sent the following message to a webtrees administrator:') . Mail::EOL . Mail::EOL . Mail::EOL . $copy_email; |
|
248 | + } |
|
249 | 249 | |
250 | - $success = $success && Mail::send( |
|
251 | - // “From:” header |
|
252 | - $WT_TREE, |
|
253 | - // “To:” header |
|
254 | - $sender_email, |
|
255 | - $sender_real_name, |
|
256 | - // “Reply-To:” header |
|
257 | - Site::getPreference('SMTP_FROM_NAME'), |
|
258 | - $WT_TREE->getPreference('title'), |
|
259 | - // Message body |
|
260 | - I18N::translate('webtrees message') . ' - ' . $message['subject'], |
|
261 | - $copy_email |
|
262 | - ); |
|
263 | - } |
|
250 | + $success = $success && Mail::send( |
|
251 | + // “From:” header |
|
252 | + $WT_TREE, |
|
253 | + // “To:” header |
|
254 | + $sender_email, |
|
255 | + $sender_real_name, |
|
256 | + // “Reply-To:” header |
|
257 | + Site::getPreference('SMTP_FROM_NAME'), |
|
258 | + $WT_TREE->getPreference('title'), |
|
259 | + // Message body |
|
260 | + I18N::translate('webtrees message') . ' - ' . $message['subject'], |
|
261 | + $copy_email |
|
262 | + ); |
|
263 | + } |
|
264 | 264 | |
265 | - // Switch to the recipient’s language. |
|
266 | - I18N::init($recipient->getPreference('language')); |
|
267 | - if (isset($message['from_name'])) { |
|
268 | - $message['body'] = |
|
269 | - I18N::translate('Your name') . ' ' . $message['from_name'] . Mail::EOL . |
|
270 | - I18N::translate('Email address') . ' ' . $message['from_email'] . Mail::EOL . Mail::EOL . |
|
271 | - $message['body']; |
|
272 | - } |
|
265 | + // Switch to the recipient’s language. |
|
266 | + I18N::init($recipient->getPreference('language')); |
|
267 | + if (isset($message['from_name'])) { |
|
268 | + $message['body'] = |
|
269 | + I18N::translate('Your name') . ' ' . $message['from_name'] . Mail::EOL . |
|
270 | + I18N::translate('Email address') . ' ' . $message['from_email'] . Mail::EOL . Mail::EOL . |
|
271 | + $message['body']; |
|
272 | + } |
|
273 | 273 | |
274 | - // Add another footer - unless we are an admin |
|
275 | - if (!Auth::isAdmin()) { |
|
276 | - if (!empty($message['url'])) { |
|
277 | - $message['body'] .= |
|
278 | - Mail::EOL . Mail::EOL . |
|
279 | - '--------------------------------------' . Mail::EOL . |
|
280 | - I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . Mail::EOL; |
|
281 | - } |
|
282 | - } |
|
274 | + // Add another footer - unless we are an admin |
|
275 | + if (!Auth::isAdmin()) { |
|
276 | + if (!empty($message['url'])) { |
|
277 | + $message['body'] .= |
|
278 | + Mail::EOL . Mail::EOL . |
|
279 | + '--------------------------------------' . Mail::EOL . |
|
280 | + I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . Mail::EOL; |
|
281 | + } |
|
282 | + } |
|
283 | 283 | |
284 | - if (empty($message['created'])) { |
|
285 | - $message['created'] = gmdate("D, d M Y H:i:s T"); |
|
286 | - } |
|
284 | + if (empty($message['created'])) { |
|
285 | + $message['created'] = gmdate("D, d M Y H:i:s T"); |
|
286 | + } |
|
287 | 287 | |
288 | - if ($message['method'] !== 'messaging3' && $message['method'] !== 'mailto' && $message['method'] !== 'none') { |
|
289 | - Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)") |
|
290 | - ->execute(array( |
|
291 | - $message['from'], |
|
292 | - WT_CLIENT_IP, |
|
293 | - $recipient->getUserId(), |
|
294 | - $message['subject'], |
|
295 | - str_replace('<br>', '', $message['body']), // Remove the <br> that we added for the external email. Perhaps create different messages |
|
296 | - )); |
|
297 | - } |
|
298 | - if ($message['method'] !== 'messaging') { |
|
299 | - if ($sender) { |
|
300 | - $original_email = /* I18N: %s is a person's name */ I18N::translate('%s sent you the following message.', $sender->getRealNameHtml()); |
|
301 | - } else { |
|
302 | - if (!empty($message['from_name'])) { |
|
303 | - $original_email = /* I18N: %s is a person's name */ I18N::translate('%s sent you the following message.', $message['from_name']); |
|
304 | - } else { |
|
305 | - $original_email = /* I18N: %s is a person's name */ I18N::translate('%s sent you the following message.', $message['from']); |
|
306 | - } |
|
307 | - } |
|
308 | - $original_email .= Mail::EOL . Mail::EOL . $message['body']; |
|
288 | + if ($message['method'] !== 'messaging3' && $message['method'] !== 'mailto' && $message['method'] !== 'none') { |
|
289 | + Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)") |
|
290 | + ->execute(array( |
|
291 | + $message['from'], |
|
292 | + WT_CLIENT_IP, |
|
293 | + $recipient->getUserId(), |
|
294 | + $message['subject'], |
|
295 | + str_replace('<br>', '', $message['body']), // Remove the <br> that we added for the external email. Perhaps create different messages |
|
296 | + )); |
|
297 | + } |
|
298 | + if ($message['method'] !== 'messaging') { |
|
299 | + if ($sender) { |
|
300 | + $original_email = /* I18N: %s is a person's name */ I18N::translate('%s sent you the following message.', $sender->getRealNameHtml()); |
|
301 | + } else { |
|
302 | + if (!empty($message['from_name'])) { |
|
303 | + $original_email = /* I18N: %s is a person's name */ I18N::translate('%s sent you the following message.', $message['from_name']); |
|
304 | + } else { |
|
305 | + $original_email = /* I18N: %s is a person's name */ I18N::translate('%s sent you the following message.', $message['from']); |
|
306 | + } |
|
307 | + } |
|
308 | + $original_email .= Mail::EOL . Mail::EOL . $message['body']; |
|
309 | 309 | |
310 | - $success = $success && Mail::send( |
|
311 | - // “From:” header |
|
312 | - $WT_TREE, |
|
313 | - // “To:” header |
|
314 | - $recipient->getEmail(), |
|
315 | - $recipient->getRealName(), |
|
316 | - // “Reply-To:” header |
|
317 | - $sender_email, |
|
318 | - $sender_real_name, |
|
319 | - // Message body |
|
320 | - I18N::translate('webtrees message') . ' - ' . $message['subject'], |
|
321 | - $original_email |
|
322 | - ); |
|
323 | - } |
|
310 | + $success = $success && Mail::send( |
|
311 | + // “From:” header |
|
312 | + $WT_TREE, |
|
313 | + // “To:” header |
|
314 | + $recipient->getEmail(), |
|
315 | + $recipient->getRealName(), |
|
316 | + // “Reply-To:” header |
|
317 | + $sender_email, |
|
318 | + $sender_real_name, |
|
319 | + // Message body |
|
320 | + I18N::translate('webtrees message') . ' - ' . $message['subject'], |
|
321 | + $original_email |
|
322 | + ); |
|
323 | + } |
|
324 | 324 | |
325 | - I18N::init(WT_LOCALE); // restore language settings if needed |
|
325 | + I18N::init(WT_LOCALE); // restore language settings if needed |
|
326 | 326 | |
327 | - return $success; |
|
327 | + return $success; |
|
328 | 328 | } |
@@ -65,20 +65,20 @@ |
||
65 | 65 | // Ensure the user always visits this page twice - once to compose it and again to send it. |
66 | 66 | // This makes it harder for spammers. |
67 | 67 | switch ($action) { |
68 | -case 'compose': |
|
69 | - Session::put('good_to_send', true); |
|
70 | - break; |
|
71 | -case 'send': |
|
72 | - // Only send messages if we've come straight from the compose page. |
|
73 | - if (!Session::get('good_to_send')) { |
|
74 | - Log::addAuthenticationLog('Attempt to send a message without visiting the compose page. Spam attack?'); |
|
75 | - $action = 'compose'; |
|
76 | - } |
|
77 | - if (!Filter::checkCsrf()) { |
|
78 | - $action = 'compose'; |
|
79 | - } |
|
80 | - Session::forget('good_to_send'); |
|
81 | - break; |
|
68 | + case 'compose': |
|
69 | + Session::put('good_to_send', true); |
|
70 | + break; |
|
71 | + case 'send': |
|
72 | + // Only send messages if we've come straight from the compose page. |
|
73 | + if (!Session::get('good_to_send')) { |
|
74 | + Log::addAuthenticationLog('Attempt to send a message without visiting the compose page. Spam attack?'); |
|
75 | + $action = 'compose'; |
|
76 | + } |
|
77 | + if (!Filter::checkCsrf()) { |
|
78 | + $action = 'compose'; |
|
79 | + } |
|
80 | + Session::forget('good_to_send'); |
|
81 | + break; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | switch ($action) { |
@@ -208,7 +208,8 @@ |
||
208 | 208 | * |
209 | 209 | * @return bool |
210 | 210 | */ |
211 | -function addMessage($message) { |
|
211 | +function addMessage($message) |
|
212 | +{ |
|
212 | 213 | global $WT_TREE; |
213 | 214 | |
214 | 215 | $success = true; |