@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * You should have received a copy of the GNU General Public License |
| 14 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 | */ |
| 16 | -declare(strict_types=1); |
|
| 16 | +declare(strict_types = 1); |
|
| 17 | 17 | |
| 18 | 18 | namespace Fisharebest\Webtrees\Http\Controllers; |
| 19 | 19 | |
@@ -103,25 +103,25 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | switch ($step) { |
| 106 | - default: |
|
| 107 | - case 1: |
|
| 108 | - return $this->viewResponse('setup/step-1-language', $data); |
|
| 109 | - case 2: |
|
| 110 | - return $this->viewResponse('setup/step-2-server-checks', $data); |
|
| 111 | - case 3: |
|
| 112 | - return $this->viewResponse('setup/step-3-database-connection', $data); |
|
| 113 | - case 4: |
|
| 114 | - return $this->viewResponse('setup/step-4-database-name', $data); |
|
| 115 | - case 5: |
|
| 116 | - return $this->viewResponse('setup/step-5-administrator', $data); |
|
| 117 | - case 6: |
|
| 118 | - $error = $this->createConfigFile($data['dbhost'], $data['dbport'], $data['dbuser'], $data['dbpass'], $data['dbname'], $data['tblpfx'], $data['wtname'], $data['wtuser'], $data['wtpass'], $data['wtemail']); |
|
| 119 | - |
|
| 120 | - if ($error === '') { |
|
| 121 | - return new RedirectResponse(Html::url('index.php', [])); |
|
| 122 | - } else { |
|
| 123 | - return $this->viewResponse('setup/step-6-failed', ['error' => $error]); |
|
| 124 | - } |
|
| 106 | + default: |
|
| 107 | + case 1: |
|
| 108 | + return $this->viewResponse('setup/step-1-language', $data); |
|
| 109 | + case 2: |
|
| 110 | + return $this->viewResponse('setup/step-2-server-checks', $data); |
|
| 111 | + case 3: |
|
| 112 | + return $this->viewResponse('setup/step-3-database-connection', $data); |
|
| 113 | + case 4: |
|
| 114 | + return $this->viewResponse('setup/step-4-database-name', $data); |
|
| 115 | + case 5: |
|
| 116 | + return $this->viewResponse('setup/step-5-administrator', $data); |
|
| 117 | + case 6: |
|
| 118 | + $error = $this->createConfigFile($data['dbhost'], $data['dbport'], $data['dbuser'], $data['dbpass'], $data['dbname'], $data['tblpfx'], $data['wtname'], $data['wtuser'], $data['wtpass'], $data['wtemail']); |
|
| 119 | + |
|
| 120 | + if ($error === '') { |
|
| 121 | + return new RedirectResponse(Html::url('index.php', [])); |
|
| 122 | + } else { |
|
| 123 | + return $this->viewResponse('setup/step-6-failed', ['error' => $error]); |
|
| 124 | + } |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
@@ -371,24 +371,24 @@ discard block |
||
| 371 | 371 | $memory_limit = ini_get('memory_limit'); |
| 372 | 372 | |
| 373 | 373 | switch (substr($memory_limit, -1)) { |
| 374 | - case 'k': |
|
| 375 | - case 'K': |
|
| 376 | - $memory_limit = substr($memory_limit, 0, -1) / 1024; |
|
| 377 | - break; |
|
| 378 | - case 'm': |
|
| 379 | - case 'M': |
|
| 380 | - $memory_limit = substr($memory_limit, 0, -1); |
|
| 381 | - break; |
|
| 382 | - case 'g': |
|
| 383 | - case 'G': |
|
| 384 | - $memory_limit = substr($memory_limit, 0, -1) * 1024; |
|
| 385 | - break; |
|
| 386 | - case 't': |
|
| 387 | - case 'T': |
|
| 388 | - $memory_limit = substr($memory_limit, 0, -1) * 1024 * 1024; |
|
| 389 | - break; |
|
| 390 | - default: |
|
| 391 | - $memory_limit = $memory_limit / 1024 / 1024; |
|
| 374 | + case 'k': |
|
| 375 | + case 'K': |
|
| 376 | + $memory_limit = substr($memory_limit, 0, -1) / 1024; |
|
| 377 | + break; |
|
| 378 | + case 'm': |
|
| 379 | + case 'M': |
|
| 380 | + $memory_limit = substr($memory_limit, 0, -1); |
|
| 381 | + break; |
|
| 382 | + case 'g': |
|
| 383 | + case 'G': |
|
| 384 | + $memory_limit = substr($memory_limit, 0, -1) * 1024; |
|
| 385 | + break; |
|
| 386 | + case 't': |
|
| 387 | + case 'T': |
|
| 388 | + $memory_limit = substr($memory_limit, 0, -1) * 1024 * 1024; |
|
| 389 | + break; |
|
| 390 | + default: |
|
| 391 | + $memory_limit = $memory_limit / 1024 / 1024; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | return (int) $memory_limit; |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * You should have received a copy of the GNU General Public License |
| 14 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 | */ |
| 16 | -declare(strict_types=1); |
|
| 16 | +declare(strict_types = 1); |
|
| 17 | 17 | |
| 18 | 18 | namespace Fisharebest\Webtrees\Http\Controllers; |
| 19 | 19 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * You should have received a copy of the GNU General Public License |
| 14 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 | */ |
| 16 | -declare(strict_types=1); |
|
| 16 | +declare(strict_types = 1); |
|
| 17 | 17 | |
| 18 | 18 | namespace Fisharebest\Webtrees\Http\Controllers; |
| 19 | 19 | |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | * @return Response |
| 727 | 727 | */ |
| 728 | 728 | public function changesLogData(Request $request): Response { |
| 729 | - list($select, , $where, $args1) = $this->changesQuery($request); |
|
| 729 | + list($select,, $where, $args1) = $this->changesQuery($request); |
|
| 730 | 730 | list($order_by, $limit, $args2) = $this->dataTablesPagination($request); |
| 731 | 731 | |
| 732 | 732 | $rows = Database::prepare( |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | * @return Response |
| 801 | 801 | */ |
| 802 | 802 | public function changesLogDownload(Request $request): Response { |
| 803 | - list($select, , $where, $args) = $this->changesQuery($request); |
|
| 803 | + list($select,, $where, $args) = $this->changesQuery($request); |
|
| 804 | 804 | |
| 805 | 805 | $rows = Database::prepare($select . $where)->execute($args)->fetchAll(); |
| 806 | 806 | |
@@ -749,14 +749,14 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | foreach ($differences as $difference) { |
| 751 | 751 | switch ($difference[1]) { |
| 752 | - case MyersDiff::DELETE: |
|
| 753 | - $diff_lines[] = '<del>' . $difference[0] . '</del>'; |
|
| 754 | - break; |
|
| 755 | - case MyersDiff::INSERT: |
|
| 756 | - $diff_lines[] = '<ins>' . $difference[0] . '</ins>'; |
|
| 757 | - break; |
|
| 758 | - default: |
|
| 759 | - $diff_lines[] = $difference[0]; |
|
| 752 | + case MyersDiff::DELETE: |
|
| 753 | + $diff_lines[] = '<del>' . $difference[0] . '</del>'; |
|
| 754 | + break; |
|
| 755 | + case MyersDiff::INSERT: |
|
| 756 | + $diff_lines[] = '<ins>' . $difference[0] . '</ins>'; |
|
| 757 | + break; |
|
| 758 | + default: |
|
| 759 | + $diff_lines[] = $difference[0]; |
|
| 760 | 760 | } |
| 761 | 761 | } |
| 762 | 762 | |
@@ -1599,12 +1599,12 @@ discard block |
||
| 1599 | 1599 | // Datatables numbers columns 0, 1, 2 |
| 1600 | 1600 | // MySQL numbers columns 1, 2, 3 |
| 1601 | 1601 | switch ($value['dir']) { |
| 1602 | - case 'asc': |
|
| 1603 | - $order_by .= (1 + $value['column']) . ' ASC '; |
|
| 1604 | - break; |
|
| 1605 | - case 'desc': |
|
| 1606 | - $order_by .= (1 + $value['column']) . ' DESC '; |
|
| 1607 | - break; |
|
| 1602 | + case 'asc': |
|
| 1603 | + $order_by .= (1 + $value['column']) . ' ASC '; |
|
| 1604 | + break; |
|
| 1605 | + case 'desc': |
|
| 1606 | + $order_by .= (1 + $value['column']) . ' DESC '; |
|
| 1607 | + break; |
|
| 1608 | 1608 | } |
| 1609 | 1609 | } |
| 1610 | 1610 | } else { |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * You should have received a copy of the GNU General Public License |
| 14 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 | */ |
| 16 | -declare(strict_types=1); |
|
| 16 | +declare(strict_types = 1); |
|
| 17 | 17 | |
| 18 | 18 | namespace Fisharebest\Webtrees\Http\Controllers; |
| 19 | 19 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * You should have received a copy of the GNU General Public License |
| 14 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 | */ |
| 16 | -declare(strict_types=1); |
|
| 16 | +declare(strict_types = 1); |
|
| 17 | 17 | |
| 18 | 18 | namespace Fisharebest\Webtrees; |
| 19 | 19 | |
@@ -329,12 +329,12 @@ discard block |
||
| 329 | 329 | $method = $user->getPreference('contactmethod'); |
| 330 | 330 | |
| 331 | 331 | switch ($method) { |
| 332 | - case 'none': |
|
| 333 | - return ''; |
|
| 334 | - case 'mailto': |
|
| 335 | - return '<a href="mailto:' . Html::escape($user->getEmail()) . '">' . $user->getRealNameHtml() . '</a>'; |
|
| 336 | - default: |
|
| 337 | - return '<a href="message.php?to=' . rawurlencode($user->getUserName()) . '&ged=' . $this->tree->getNameUrl() . '&url=' . Html::escape(Functions::getQueryUrl()) . '">' . $user->getRealNameHtml() . '</a>'; |
|
| 332 | + case 'none': |
|
| 333 | + return ''; |
|
| 334 | + case 'mailto': |
|
| 335 | + return '<a href="mailto:' . Html::escape($user->getEmail()) . '">' . $user->getRealNameHtml() . '</a>'; |
|
| 336 | + default: |
|
| 337 | + return '<a href="message.php?to=' . rawurlencode($user->getUserName()) . '&ged=' . $this->tree->getNameUrl() . '&url=' . Html::escape(Functions::getQueryUrl()) . '">' . $user->getRealNameHtml() . '</a>'; |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
@@ -1413,20 +1413,20 @@ discard block |
||
| 1413 | 1413 | $records = []; |
| 1414 | 1414 | foreach ($favorites as $favorite) { |
| 1415 | 1415 | switch ($favorite['type']) { |
| 1416 | - case 'URL': |
|
| 1417 | - $submenus[] = new Menu($favorite['title'], $favorite['url']); |
|
| 1418 | - break; |
|
| 1419 | - case 'INDI': |
|
| 1420 | - case 'FAM': |
|
| 1421 | - case 'SOUR': |
|
| 1422 | - case 'OBJE': |
|
| 1423 | - case 'NOTE': |
|
| 1424 | - $record = GedcomRecord::getInstance($favorite['gid'], $this->tree); |
|
| 1425 | - if ($record && $record->canShowName()) { |
|
| 1426 | - $submenus[] = new Menu($record->getFullName(), $record->getHtmlUrl()); |
|
| 1427 | - $records[] = $record; |
|
| 1428 | - } |
|
| 1429 | - break; |
|
| 1416 | + case 'URL': |
|
| 1417 | + $submenus[] = new Menu($favorite['title'], $favorite['url']); |
|
| 1418 | + break; |
|
| 1419 | + case 'INDI': |
|
| 1420 | + case 'FAM': |
|
| 1421 | + case 'SOUR': |
|
| 1422 | + case 'OBJE': |
|
| 1423 | + case 'NOTE': |
|
| 1424 | + $record = GedcomRecord::getInstance($favorite['gid'], $this->tree); |
|
| 1425 | + if ($record && $record->canShowName()) { |
|
| 1426 | + $submenus[] = new Menu($record->getFullName(), $record->getHtmlUrl()); |
|
| 1427 | + $records[] = $record; |
|
| 1428 | + } |
|
| 1429 | + break; |
|
| 1430 | 1430 | } |
| 1431 | 1431 | } |
| 1432 | 1432 | |
@@ -933,14 +933,14 @@ discard block |
||
| 933 | 933 | $tags = preg_split('/[: ]/', $tag); |
| 934 | 934 | $value = $this->getGedcomValue($tag, $level, $this->gedrec); |
| 935 | 935 | switch (end($tags)) { |
| 936 | - case 'DATE': |
|
| 937 | - $tmp = new Date($value); |
|
| 938 | - $value = $tmp->display(); |
|
| 939 | - break; |
|
| 940 | - case 'PLAC': |
|
| 941 | - $tmp = new Place($value, $WT_TREE); |
|
| 942 | - $value = $tmp->getShortName(); |
|
| 943 | - break; |
|
| 936 | + case 'DATE': |
|
| 937 | + $tmp = new Date($value); |
|
| 938 | + $value = $tmp->display(); |
|
| 939 | + break; |
|
| 940 | + case 'PLAC': |
|
| 941 | + $tmp = new Place($value, $WT_TREE); |
|
| 942 | + $value = $tmp->getShortName(); |
|
| 943 | + break; |
|
| 944 | 944 | } |
| 945 | 945 | if ($useBreak == '1') { |
| 946 | 946 | // Insert <br> when multiple dates exist. |
@@ -1333,22 +1333,22 @@ discard block |
||
| 1333 | 1333 | // Arithmetic functions |
| 1334 | 1334 | if (preg_match("/(\d+)\s*([\-\+\*\/])\s*(\d+)/", $value, $match)) { |
| 1335 | 1335 | switch ($match[2]) { |
| 1336 | - case '+': |
|
| 1337 | - $t = $match[1] + $match[3]; |
|
| 1338 | - $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1339 | - break; |
|
| 1340 | - case '-': |
|
| 1341 | - $t = $match[1] - $match[3]; |
|
| 1342 | - $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1343 | - break; |
|
| 1344 | - case '*': |
|
| 1345 | - $t = $match[1] * $match[3]; |
|
| 1346 | - $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1347 | - break; |
|
| 1348 | - case '/': |
|
| 1349 | - $t = $match[1] / $match[3]; |
|
| 1350 | - $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1351 | - break; |
|
| 1336 | + case '+': |
|
| 1337 | + $t = $match[1] + $match[3]; |
|
| 1338 | + $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1339 | + break; |
|
| 1340 | + case '-': |
|
| 1341 | + $t = $match[1] - $match[3]; |
|
| 1342 | + $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1343 | + break; |
|
| 1344 | + case '*': |
|
| 1345 | + $t = $match[1] * $match[3]; |
|
| 1346 | + $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1347 | + break; |
|
| 1348 | + case '/': |
|
| 1349 | + $t = $match[1] / $match[3]; |
|
| 1350 | + $value = preg_replace('/' . $match[1] . "\s*([\-\+\*\/])\s*" . $match[3] . '/', $t, $value); |
|
| 1351 | + break; |
|
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| 1354 | 1354 | if (strpos($value, '@') !== false) { |
@@ -1816,179 +1816,179 @@ discard block |
||
| 1816 | 1816 | } |
| 1817 | 1817 | // Some filters/sorts can be applied using SQL, while others require PHP |
| 1818 | 1818 | switch ($listname) { |
| 1819 | - case 'pending': |
|
| 1820 | - $rows = Database::prepare( |
|
| 1821 | - "SELECT xref, CASE new_gedcom WHEN '' THEN old_gedcom ELSE new_gedcom END AS gedcom" . |
|
| 1822 | - " FROM `##change`" . " WHERE (xref, change_id) IN (" . |
|
| 1823 | - " SELECT xref, MAX(change_id)" . |
|
| 1824 | - " FROM `##change`" . |
|
| 1825 | - " WHERE status = 'pending' AND gedcom_id = :tree_id" . |
|
| 1826 | - " GROUP BY xref" . |
|
| 1827 | - " )" |
|
| 1828 | - )->execute([ |
|
| 1829 | - 'tree_id' => $WT_TREE->getTreeId(), |
|
| 1830 | - ])->fetchAll(); |
|
| 1831 | - $this->list = []; |
|
| 1832 | - foreach ($rows as $row) { |
|
| 1833 | - $this->list[] = GedcomRecord::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
| 1834 | - } |
|
| 1835 | - break; |
|
| 1836 | - case 'individual': |
|
| 1837 | - $sql_select = "SELECT i_id AS xref, i_gedcom AS gedcom FROM `##individuals` "; |
|
| 1838 | - $sql_join = ""; |
|
| 1839 | - $sql_where = " WHERE i_file = :tree_id"; |
|
| 1840 | - $sql_order_by = ""; |
|
| 1841 | - $sql_params = ['tree_id' => $WT_TREE->getTreeId()]; |
|
| 1842 | - foreach ($attrs as $attr => $value) { |
|
| 1843 | - if (strpos($attr, 'filter') === 0 && $value) { |
|
| 1844 | - $value = $this->substituteVars($value, false); |
|
| 1845 | - // Convert the various filters into SQL |
|
| 1846 | - if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) { |
|
| 1847 | - $sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=i_file AND {$attr}.d_gid=i_id)"; |
|
| 1848 | - $sql_where .= " AND {$attr}.d_fact = :{$attr}fact"; |
|
| 1849 | - $sql_params[$attr . 'fact'] = $match[1]; |
|
| 1850 | - $date = new Date($match[3]); |
|
| 1851 | - if ($match[2] == 'LTE') { |
|
| 1852 | - $sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date"; |
|
| 1853 | - $sql_params[$attr . 'date'] = $date->maximumJulianDay(); |
|
| 1854 | - } else { |
|
| 1855 | - $sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date"; |
|
| 1856 | - $sql_params[$attr . 'date'] = $date->minimumJulianDay(); |
|
| 1857 | - } |
|
| 1858 | - if ($sortby == $match[1]) { |
|
| 1859 | - $sortby = ""; |
|
| 1860 | - $sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1"; |
|
| 1861 | - } |
|
| 1862 | - unset($attrs[$attr]); // This filter has been fully processed |
|
| 1863 | - } elseif (preg_match('/^NAME CONTAINS (.*)$/', $value, $match)) { |
|
| 1864 | - // Do nothing, unless you have to |
|
| 1865 | - if ($match[1] != '' || $sortby == 'NAME') { |
|
| 1866 | - $sql_join .= " JOIN `##name` AS {$attr} ON (n_file=i_file AND n_id=i_id)"; |
|
| 1867 | - // Search the DB only if there is any name supplied |
|
| 1868 | - if ($match[1] != '') { |
|
| 1869 | - $names = explode(' ', $match[1]); |
|
| 1870 | - foreach ($names as $n => $name) { |
|
| 1871 | - $sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')"; |
|
| 1872 | - $sql_params[$attr . 'name' . $n] = $name; |
|
| 1873 | - } |
|
| 1819 | + case 'pending': |
|
| 1820 | + $rows = Database::prepare( |
|
| 1821 | + "SELECT xref, CASE new_gedcom WHEN '' THEN old_gedcom ELSE new_gedcom END AS gedcom" . |
|
| 1822 | + " FROM `##change`" . " WHERE (xref, change_id) IN (" . |
|
| 1823 | + " SELECT xref, MAX(change_id)" . |
|
| 1824 | + " FROM `##change`" . |
|
| 1825 | + " WHERE status = 'pending' AND gedcom_id = :tree_id" . |
|
| 1826 | + " GROUP BY xref" . |
|
| 1827 | + " )" |
|
| 1828 | + )->execute([ |
|
| 1829 | + 'tree_id' => $WT_TREE->getTreeId(), |
|
| 1830 | + ])->fetchAll(); |
|
| 1831 | + $this->list = []; |
|
| 1832 | + foreach ($rows as $row) { |
|
| 1833 | + $this->list[] = GedcomRecord::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
| 1834 | + } |
|
| 1835 | + break; |
|
| 1836 | + case 'individual': |
|
| 1837 | + $sql_select = "SELECT i_id AS xref, i_gedcom AS gedcom FROM `##individuals` "; |
|
| 1838 | + $sql_join = ""; |
|
| 1839 | + $sql_where = " WHERE i_file = :tree_id"; |
|
| 1840 | + $sql_order_by = ""; |
|
| 1841 | + $sql_params = ['tree_id' => $WT_TREE->getTreeId()]; |
|
| 1842 | + foreach ($attrs as $attr => $value) { |
|
| 1843 | + if (strpos($attr, 'filter') === 0 && $value) { |
|
| 1844 | + $value = $this->substituteVars($value, false); |
|
| 1845 | + // Convert the various filters into SQL |
|
| 1846 | + if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) { |
|
| 1847 | + $sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=i_file AND {$attr}.d_gid=i_id)"; |
|
| 1848 | + $sql_where .= " AND {$attr}.d_fact = :{$attr}fact"; |
|
| 1849 | + $sql_params[$attr . 'fact'] = $match[1]; |
|
| 1850 | + $date = new Date($match[3]); |
|
| 1851 | + if ($match[2] == 'LTE') { |
|
| 1852 | + $sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date"; |
|
| 1853 | + $sql_params[$attr . 'date'] = $date->maximumJulianDay(); |
|
| 1854 | + } else { |
|
| 1855 | + $sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date"; |
|
| 1856 | + $sql_params[$attr . 'date'] = $date->minimumJulianDay(); |
|
| 1874 | 1857 | } |
| 1875 | - // Let the DB do the name sorting even when no name was entered |
|
| 1876 | - if ($sortby == 'NAME') { |
|
| 1877 | - $sortby = ''; |
|
| 1878 | - $sql_order_by .= ($sql_order_by ? ', ' : ' ORDER BY ') . "{$attr}.n_sort"; |
|
| 1858 | + if ($sortby == $match[1]) { |
|
| 1859 | + $sortby = ""; |
|
| 1860 | + $sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1"; |
|
| 1879 | 1861 | } |
| 1862 | + unset($attrs[$attr]); // This filter has been fully processed |
|
| 1863 | + } elseif (preg_match('/^NAME CONTAINS (.*)$/', $value, $match)) { |
|
| 1864 | + // Do nothing, unless you have to |
|
| 1865 | + if ($match[1] != '' || $sortby == 'NAME') { |
|
| 1866 | + $sql_join .= " JOIN `##name` AS {$attr} ON (n_file=i_file AND n_id=i_id)"; |
|
| 1867 | + // Search the DB only if there is any name supplied |
|
| 1868 | + if ($match[1] != '') { |
|
| 1869 | + $names = explode(' ', $match[1]); |
|
| 1870 | + foreach ($names as $n => $name) { |
|
| 1871 | + $sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')"; |
|
| 1872 | + $sql_params[$attr . 'name' . $n] = $name; |
|
| 1873 | + } |
|
| 1874 | + } |
|
| 1875 | + // Let the DB do the name sorting even when no name was entered |
|
| 1876 | + if ($sortby == 'NAME') { |
|
| 1877 | + $sortby = ''; |
|
| 1878 | + $sql_order_by .= ($sql_order_by ? ', ' : ' ORDER BY ') . "{$attr}.n_sort"; |
|
| 1879 | + } |
|
| 1880 | + } |
|
| 1881 | + unset($attrs[$attr]); // This filter has been fully processed |
|
| 1882 | + } elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) { |
|
| 1883 | + $sql_where .= " AND i_gedcom REGEXP :{$attr}gedcom"; |
|
| 1884 | + // PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT" |
|
| 1885 | + $sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]); |
|
| 1886 | + unset($attrs[$attr]); // This filter has been fully processed |
|
| 1887 | + } elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) { |
|
| 1888 | + $sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file = i_file)"; |
|
| 1889 | + $sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file = {$attr}b.pl_file AND {$attr}b.pl_p_id = {$attr}a.p_id AND {$attr}b.pl_gid = i_id)"; |
|
| 1890 | + $sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')"; |
|
| 1891 | + $sql_params[$attr . 'place'] = $match[1]; |
|
| 1892 | + // Don't unset this filter. This is just initial filtering |
|
| 1893 | + } elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) { |
|
| 1894 | + $sql_where .= " AND i_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')"; |
|
| 1895 | + $sql_params[$attr . 'contains1'] = $match[1]; |
|
| 1896 | + $sql_params[$attr . 'contains2'] = $match[2]; |
|
| 1897 | + $sql_params[$attr . 'contains3'] = $match[3]; |
|
| 1898 | + // Don't unset this filter. This is just initial filtering |
|
| 1880 | 1899 | } |
| 1881 | - unset($attrs[$attr]); // This filter has been fully processed |
|
| 1882 | - } elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) { |
|
| 1883 | - $sql_where .= " AND i_gedcom REGEXP :{$attr}gedcom"; |
|
| 1884 | - // PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT" |
|
| 1885 | - $sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]); |
|
| 1886 | - unset($attrs[$attr]); // This filter has been fully processed |
|
| 1887 | - } elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) { |
|
| 1888 | - $sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file = i_file)"; |
|
| 1889 | - $sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file = {$attr}b.pl_file AND {$attr}b.pl_p_id = {$attr}a.p_id AND {$attr}b.pl_gid = i_id)"; |
|
| 1890 | - $sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')"; |
|
| 1891 | - $sql_params[$attr . 'place'] = $match[1]; |
|
| 1892 | - // Don't unset this filter. This is just initial filtering |
|
| 1893 | - } elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) { |
|
| 1894 | - $sql_where .= " AND i_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')"; |
|
| 1895 | - $sql_params[$attr . 'contains1'] = $match[1]; |
|
| 1896 | - $sql_params[$attr . 'contains2'] = $match[2]; |
|
| 1897 | - $sql_params[$attr . 'contains3'] = $match[3]; |
|
| 1898 | - // Don't unset this filter. This is just initial filtering |
|
| 1899 | 1900 | } |
| 1900 | 1901 | } |
| 1901 | - } |
|
| 1902 | 1902 | |
| 1903 | - $this->list = []; |
|
| 1904 | - $rows = Database::prepare( |
|
| 1905 | - $sql_select . $sql_join . $sql_where . $sql_order_by |
|
| 1906 | - )->execute($sql_params)->fetchAll(); |
|
| 1907 | - |
|
| 1908 | - foreach ($rows as $row) { |
|
| 1909 | - $this->list[$row->xref] = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
| 1910 | - } |
|
| 1911 | - break; |
|
| 1912 | - |
|
| 1913 | - case 'family': |
|
| 1914 | - $sql_select = "SELECT f_id AS xref, f_gedcom AS gedcom FROM `##families`"; |
|
| 1915 | - $sql_join = ""; |
|
| 1916 | - $sql_where = " WHERE f_file = :tree_id"; |
|
| 1917 | - $sql_order_by = ""; |
|
| 1918 | - $sql_params = ['tree_id' => $WT_TREE->getTreeId()]; |
|
| 1919 | - foreach ($attrs as $attr => $value) { |
|
| 1920 | - if (strpos($attr, 'filter') === 0 && $value) { |
|
| 1921 | - $value = $this->substituteVars($value, false); |
|
| 1922 | - // Convert the various filters into SQL |
|
| 1923 | - if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) { |
|
| 1924 | - $sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=f_file AND {$attr}.d_gid=f_id)"; |
|
| 1925 | - $sql_where .= " AND {$attr}.d_fact = :{$attr}fact"; |
|
| 1926 | - $sql_params[$attr . 'fact'] = $match[1]; |
|
| 1927 | - $date = new Date($match[3]); |
|
| 1928 | - if ($match[2] == 'LTE') { |
|
| 1929 | - $sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date"; |
|
| 1930 | - $sql_params[$attr . 'date'] = $date->maximumJulianDay(); |
|
| 1931 | - } else { |
|
| 1932 | - $sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date"; |
|
| 1933 | - $sql_params[$attr . 'date'] = $date->minimumJulianDay(); |
|
| 1934 | - } |
|
| 1935 | - if ($sortby == $match[1]) { |
|
| 1936 | - $sortby = ''; |
|
| 1937 | - $sql_order_by .= ($sql_order_by ? ', ' : ' ORDER BY ') . "{$attr}.d_julianday1"; |
|
| 1938 | - } |
|
| 1939 | - unset($attrs[$attr]); // This filter has been fully processed |
|
| 1940 | - } elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) { |
|
| 1941 | - $sql_where .= " AND f_gedcom REGEXP :{$attr}gedcom"; |
|
| 1942 | - // PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT" |
|
| 1943 | - $sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]); |
|
| 1944 | - unset($attrs[$attr]); // This filter has been fully processed |
|
| 1945 | - } elseif (preg_match('/^NAME CONTAINS (.+)$/', $value, $match)) { |
|
| 1946 | - // Do nothing, unless you have to |
|
| 1947 | - if ($match[1] != '' || $sortby == 'NAME') { |
|
| 1948 | - $sql_join .= " JOIN `##name` AS {$attr} ON n_file = f_file AND n_id IN (f_husb, f_wife)"; |
|
| 1949 | - // Search the DB only if there is any name supplied |
|
| 1950 | - if ($match[1] != '') { |
|
| 1951 | - $names = explode(' ', $match[1]); |
|
| 1952 | - foreach ($names as $n => $name) { |
|
| 1953 | - $sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')"; |
|
| 1954 | - $sql_params[$attr . 'name' . $n] = $name; |
|
| 1955 | - } |
|
| 1903 | + $this->list = []; |
|
| 1904 | + $rows = Database::prepare( |
|
| 1905 | + $sql_select . $sql_join . $sql_where . $sql_order_by |
|
| 1906 | + )->execute($sql_params)->fetchAll(); |
|
| 1907 | + |
|
| 1908 | + foreach ($rows as $row) { |
|
| 1909 | + $this->list[$row->xref] = Individual::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
| 1910 | + } |
|
| 1911 | + break; |
|
| 1912 | + |
|
| 1913 | + case 'family': |
|
| 1914 | + $sql_select = "SELECT f_id AS xref, f_gedcom AS gedcom FROM `##families`"; |
|
| 1915 | + $sql_join = ""; |
|
| 1916 | + $sql_where = " WHERE f_file = :tree_id"; |
|
| 1917 | + $sql_order_by = ""; |
|
| 1918 | + $sql_params = ['tree_id' => $WT_TREE->getTreeId()]; |
|
| 1919 | + foreach ($attrs as $attr => $value) { |
|
| 1920 | + if (strpos($attr, 'filter') === 0 && $value) { |
|
| 1921 | + $value = $this->substituteVars($value, false); |
|
| 1922 | + // Convert the various filters into SQL |
|
| 1923 | + if (preg_match('/^(\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) { |
|
| 1924 | + $sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=f_file AND {$attr}.d_gid=f_id)"; |
|
| 1925 | + $sql_where .= " AND {$attr}.d_fact = :{$attr}fact"; |
|
| 1926 | + $sql_params[$attr . 'fact'] = $match[1]; |
|
| 1927 | + $date = new Date($match[3]); |
|
| 1928 | + if ($match[2] == 'LTE') { |
|
| 1929 | + $sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date"; |
|
| 1930 | + $sql_params[$attr . 'date'] = $date->maximumJulianDay(); |
|
| 1931 | + } else { |
|
| 1932 | + $sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date"; |
|
| 1933 | + $sql_params[$attr . 'date'] = $date->minimumJulianDay(); |
|
| 1956 | 1934 | } |
| 1957 | - // Let the DB do the name sorting even when no name was entered |
|
| 1958 | - if ($sortby == 'NAME') { |
|
| 1935 | + if ($sortby == $match[1]) { |
|
| 1959 | 1936 | $sortby = ''; |
| 1960 | - $sql_order_by .= ($sql_order_by ? ', ' : ' ORDER BY ') . "{$attr}.n_sort"; |
|
| 1937 | + $sql_order_by .= ($sql_order_by ? ', ' : ' ORDER BY ') . "{$attr}.d_julianday1"; |
|
| 1938 | + } |
|
| 1939 | + unset($attrs[$attr]); // This filter has been fully processed |
|
| 1940 | + } elseif (preg_match('/^REGEXP \/(.+)\//', $value, $match)) { |
|
| 1941 | + $sql_where .= " AND f_gedcom REGEXP :{$attr}gedcom"; |
|
| 1942 | + // PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT" |
|
| 1943 | + $sql_params[$attr . 'gedcom'] = str_replace('\n', "\n", $match[1]); |
|
| 1944 | + unset($attrs[$attr]); // This filter has been fully processed |
|
| 1945 | + } elseif (preg_match('/^NAME CONTAINS (.+)$/', $value, $match)) { |
|
| 1946 | + // Do nothing, unless you have to |
|
| 1947 | + if ($match[1] != '' || $sortby == 'NAME') { |
|
| 1948 | + $sql_join .= " JOIN `##name` AS {$attr} ON n_file = f_file AND n_id IN (f_husb, f_wife)"; |
|
| 1949 | + // Search the DB only if there is any name supplied |
|
| 1950 | + if ($match[1] != '') { |
|
| 1951 | + $names = explode(' ', $match[1]); |
|
| 1952 | + foreach ($names as $n => $name) { |
|
| 1953 | + $sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')"; |
|
| 1954 | + $sql_params[$attr . 'name' . $n] = $name; |
|
| 1955 | + } |
|
| 1956 | + } |
|
| 1957 | + // Let the DB do the name sorting even when no name was entered |
|
| 1958 | + if ($sortby == 'NAME') { |
|
| 1959 | + $sortby = ''; |
|
| 1960 | + $sql_order_by .= ($sql_order_by ? ', ' : ' ORDER BY ') . "{$attr}.n_sort"; |
|
| 1961 | + } |
|
| 1961 | 1962 | } |
| 1963 | + unset($attrs[$attr]); // This filter has been fully processed |
|
| 1964 | + } elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) { |
|
| 1965 | + $sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file=f_file)"; |
|
| 1966 | + $sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file={$attr}b.pl_file AND {$attr}b.pl_p_id={$attr}a.p_id AND {$attr}b.pl_gid=f_id)"; |
|
| 1967 | + $sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')"; |
|
| 1968 | + $sql_params[$attr . 'place'] = $match[1]; |
|
| 1969 | + // Don't unset this filter. This is just initial filtering |
|
| 1970 | + } elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) { |
|
| 1971 | + $sql_where .= " AND f_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')"; |
|
| 1972 | + $sql_params[$attr . 'contains1'] = $match[1]; |
|
| 1973 | + $sql_params[$attr . 'contains2'] = $match[2]; |
|
| 1974 | + $sql_params[$attr . 'contains3'] = $match[3]; |
|
| 1975 | + // Don't unset this filter. This is just initial filtering |
|
| 1962 | 1976 | } |
| 1963 | - unset($attrs[$attr]); // This filter has been fully processed |
|
| 1964 | - } elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) { |
|
| 1965 | - $sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file=f_file)"; |
|
| 1966 | - $sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file={$attr}b.pl_file AND {$attr}b.pl_p_id={$attr}a.p_id AND {$attr}b.pl_gid=f_id)"; |
|
| 1967 | - $sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')"; |
|
| 1968 | - $sql_params[$attr . 'place'] = $match[1]; |
|
| 1969 | - // Don't unset this filter. This is just initial filtering |
|
| 1970 | - } elseif (preg_match('/^(\w*):*(\w*) CONTAINS (.+)$/', $value, $match)) { |
|
| 1971 | - $sql_where .= " AND f_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')"; |
|
| 1972 | - $sql_params[$attr . 'contains1'] = $match[1]; |
|
| 1973 | - $sql_params[$attr . 'contains2'] = $match[2]; |
|
| 1974 | - $sql_params[$attr . 'contains3'] = $match[3]; |
|
| 1975 | - // Don't unset this filter. This is just initial filtering |
|
| 1976 | 1977 | } |
| 1977 | 1978 | } |
| 1978 | - } |
|
| 1979 | 1979 | |
| 1980 | - $this->list = []; |
|
| 1981 | - $rows = Database::prepare( |
|
| 1982 | - $sql_select . $sql_join . $sql_where . $sql_order_by |
|
| 1983 | - )->execute($sql_params)->fetchAll(); |
|
| 1980 | + $this->list = []; |
|
| 1981 | + $rows = Database::prepare( |
|
| 1982 | + $sql_select . $sql_join . $sql_where . $sql_order_by |
|
| 1983 | + )->execute($sql_params)->fetchAll(); |
|
| 1984 | 1984 | |
| 1985 | - foreach ($rows as $row) { |
|
| 1986 | - $this->list[$row->xref] = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
| 1987 | - } |
|
| 1988 | - break; |
|
| 1985 | + foreach ($rows as $row) { |
|
| 1986 | + $this->list[$row->xref] = Family::getInstance($row->xref, $WT_TREE, $row->gedcom); |
|
| 1987 | + } |
|
| 1988 | + break; |
|
| 1989 | 1989 | |
| 1990 | - default: |
|
| 1991 | - throw new \DomainException('Invalid list name: ' . $listname); |
|
| 1990 | + default: |
|
| 1991 | + throw new \DomainException('Invalid list name: ' . $listname); |
|
| 1992 | 1992 | } |
| 1993 | 1993 | |
| 1994 | 1994 | $filters = []; |
@@ -2049,17 +2049,17 @@ discard block |
||
| 2049 | 2049 | $searchstr = '1 ' . $tag; |
| 2050 | 2050 | } |
| 2051 | 2051 | switch ($expr) { |
| 2052 | - case 'CONTAINS': |
|
| 2053 | - if ($t == 'PLAC') { |
|
| 2054 | - $searchstr .= "[^\n]*[, ]*" . $val; |
|
| 2055 | - } else { |
|
| 2056 | - $searchstr .= "[^\n]*" . $val; |
|
| 2057 | - } |
|
| 2058 | - $filters[] = $searchstr; |
|
| 2059 | - break; |
|
| 2060 | - default: |
|
| 2061 | - $filters2[] = ['tag' => $tag, 'expr' => $expr, 'val' => $val]; |
|
| 2062 | - break; |
|
| 2052 | + case 'CONTAINS': |
|
| 2053 | + if ($t == 'PLAC') { |
|
| 2054 | + $searchstr .= "[^\n]*[, ]*" . $val; |
|
| 2055 | + } else { |
|
| 2056 | + $searchstr .= "[^\n]*" . $val; |
|
| 2057 | + } |
|
| 2058 | + $filters[] = $searchstr; |
|
| 2059 | + break; |
|
| 2060 | + default: |
|
| 2061 | + $filters2[] = ['tag' => $tag, 'expr' => $expr, 'val' => $val]; |
|
| 2062 | + break; |
|
| 2063 | 2063 | } |
| 2064 | 2064 | } |
| 2065 | 2065 | } |
@@ -2103,31 +2103,31 @@ discard block |
||
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | 2105 | switch ($expr) { |
| 2106 | - case 'GTE': |
|
| 2107 | - if ($t == 'DATE') { |
|
| 2108 | - $date1 = new Date($v); |
|
| 2109 | - $date2 = new Date($val); |
|
| 2110 | - $keep = (Date::compare($date1, $date2) >= 0); |
|
| 2111 | - } elseif ($val >= $v) { |
|
| 2112 | - $keep = true; |
|
| 2113 | - } |
|
| 2114 | - break; |
|
| 2115 | - case 'LTE': |
|
| 2116 | - if ($t == 'DATE') { |
|
| 2117 | - $date1 = new Date($v); |
|
| 2118 | - $date2 = new Date($val); |
|
| 2119 | - $keep = (Date::compare($date1, $date2) <= 0); |
|
| 2120 | - } elseif ($val >= $v) { |
|
| 2121 | - $keep = true; |
|
| 2122 | - } |
|
| 2123 | - break; |
|
| 2124 | - default: |
|
| 2125 | - if ($v == $val) { |
|
| 2126 | - $keep = true; |
|
| 2127 | - } else { |
|
| 2128 | - $keep = false; |
|
| 2129 | - } |
|
| 2130 | - break; |
|
| 2106 | + case 'GTE': |
|
| 2107 | + if ($t == 'DATE') { |
|
| 2108 | + $date1 = new Date($v); |
|
| 2109 | + $date2 = new Date($val); |
|
| 2110 | + $keep = (Date::compare($date1, $date2) >= 0); |
|
| 2111 | + } elseif ($val >= $v) { |
|
| 2112 | + $keep = true; |
|
| 2113 | + } |
|
| 2114 | + break; |
|
| 2115 | + case 'LTE': |
|
| 2116 | + if ($t == 'DATE') { |
|
| 2117 | + $date1 = new Date($v); |
|
| 2118 | + $date2 = new Date($val); |
|
| 2119 | + $keep = (Date::compare($date1, $date2) <= 0); |
|
| 2120 | + } elseif ($val >= $v) { |
|
| 2121 | + $keep = true; |
|
| 2122 | + } |
|
| 2123 | + break; |
|
| 2124 | + default: |
|
| 2125 | + if ($v == $val) { |
|
| 2126 | + $keep = true; |
|
| 2127 | + } else { |
|
| 2128 | + $keep = false; |
|
| 2129 | + } |
|
| 2130 | + break; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | } |
| 2133 | 2133 | } |
@@ -2139,26 +2139,26 @@ discard block |
||
| 2139 | 2139 | } |
| 2140 | 2140 | |
| 2141 | 2141 | switch ($sortby) { |
| 2142 | - case 'NAME': |
|
| 2143 | - uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare'); |
|
| 2144 | - break; |
|
| 2145 | - case 'CHAN': |
|
| 2146 | - uasort($this->list, function (GedcomRecord $x, GedcomRecord $y) { |
|
| 2147 | - return $y->lastChangeTimestamp(true) - $x->lastChangeTimestamp(true); |
|
| 2148 | - }); |
|
| 2149 | - break; |
|
| 2150 | - case 'BIRT:DATE': |
|
| 2151 | - uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate'); |
|
| 2152 | - break; |
|
| 2153 | - case 'DEAT:DATE': |
|
| 2154 | - uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate'); |
|
| 2155 | - break; |
|
| 2156 | - case 'MARR:DATE': |
|
| 2157 | - uasort($this->list, '\Fisharebest\Webtrees\Family::compareMarrDate'); |
|
| 2158 | - break; |
|
| 2159 | - default: |
|
| 2160 | - // unsorted or already sorted by SQL |
|
| 2161 | - break; |
|
| 2142 | + case 'NAME': |
|
| 2143 | + uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare'); |
|
| 2144 | + break; |
|
| 2145 | + case 'CHAN': |
|
| 2146 | + uasort($this->list, function (GedcomRecord $x, GedcomRecord $y) { |
|
| 2147 | + return $y->lastChangeTimestamp(true) - $x->lastChangeTimestamp(true); |
|
| 2148 | + }); |
|
| 2149 | + break; |
|
| 2150 | + case 'BIRT:DATE': |
|
| 2151 | + uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate'); |
|
| 2152 | + break; |
|
| 2153 | + case 'DEAT:DATE': |
|
| 2154 | + uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate'); |
|
| 2155 | + break; |
|
| 2156 | + case 'MARR:DATE': |
|
| 2157 | + uasort($this->list, '\Fisharebest\Webtrees\Family::compareMarrDate'); |
|
| 2158 | + break; |
|
| 2159 | + default: |
|
| 2160 | + // unsorted or already sorted by SQL |
|
| 2161 | + break; |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | array_push($this->repeats_stack, [$this->repeats, $this->repeat_bytes]); |
@@ -2309,88 +2309,88 @@ discard block |
||
| 2309 | 2309 | if (!empty($person)) { |
| 2310 | 2310 | $this->list[$id] = $person; |
| 2311 | 2311 | switch ($group) { |
| 2312 | - case 'child-family': |
|
| 2313 | - foreach ($person->getChildFamilies() as $family) { |
|
| 2314 | - $husband = $family->getHusband(); |
|
| 2315 | - $wife = $family->getWife(); |
|
| 2316 | - if (!empty($husband)) { |
|
| 2317 | - $this->list[$husband->getXref()] = $husband; |
|
| 2318 | - } |
|
| 2319 | - if (!empty($wife)) { |
|
| 2320 | - $this->list[$wife->getXref()] = $wife; |
|
| 2321 | - } |
|
| 2322 | - $children = $family->getChildren(); |
|
| 2323 | - foreach ($children as $child) { |
|
| 2324 | - if (!empty($child)) { |
|
| 2325 | - $this->list[$child->getXref()] = $child; |
|
| 2312 | + case 'child-family': |
|
| 2313 | + foreach ($person->getChildFamilies() as $family) { |
|
| 2314 | + $husband = $family->getHusband(); |
|
| 2315 | + $wife = $family->getWife(); |
|
| 2316 | + if (!empty($husband)) { |
|
| 2317 | + $this->list[$husband->getXref()] = $husband; |
|
| 2318 | + } |
|
| 2319 | + if (!empty($wife)) { |
|
| 2320 | + $this->list[$wife->getXref()] = $wife; |
|
| 2321 | + } |
|
| 2322 | + $children = $family->getChildren(); |
|
| 2323 | + foreach ($children as $child) { |
|
| 2324 | + if (!empty($child)) { |
|
| 2325 | + $this->list[$child->getXref()] = $child; |
|
| 2326 | + } |
|
| 2326 | 2327 | } |
| 2327 | 2328 | } |
| 2328 | - } |
|
| 2329 | - break; |
|
| 2330 | - case 'spouse-family': |
|
| 2331 | - foreach ($person->getSpouseFamilies() as $family) { |
|
| 2332 | - $husband = $family->getHusband(); |
|
| 2333 | - $wife = $family->getWife(); |
|
| 2334 | - if (!empty($husband)) { |
|
| 2335 | - $this->list[$husband->getXref()] = $husband; |
|
| 2336 | - } |
|
| 2337 | - if (!empty($wife)) { |
|
| 2338 | - $this->list[$wife->getXref()] = $wife; |
|
| 2339 | - } |
|
| 2340 | - $children = $family->getChildren(); |
|
| 2341 | - foreach ($children as $child) { |
|
| 2342 | - if (!empty($child)) { |
|
| 2343 | - $this->list[$child->getXref()] = $child; |
|
| 2329 | + break; |
|
| 2330 | + case 'spouse-family': |
|
| 2331 | + foreach ($person->getSpouseFamilies() as $family) { |
|
| 2332 | + $husband = $family->getHusband(); |
|
| 2333 | + $wife = $family->getWife(); |
|
| 2334 | + if (!empty($husband)) { |
|
| 2335 | + $this->list[$husband->getXref()] = $husband; |
|
| 2336 | + } |
|
| 2337 | + if (!empty($wife)) { |
|
| 2338 | + $this->list[$wife->getXref()] = $wife; |
|
| 2339 | + } |
|
| 2340 | + $children = $family->getChildren(); |
|
| 2341 | + foreach ($children as $child) { |
|
| 2342 | + if (!empty($child)) { |
|
| 2343 | + $this->list[$child->getXref()] = $child; |
|
| 2344 | + } |
|
| 2344 | 2345 | } |
| 2345 | 2346 | } |
| 2346 | - } |
|
| 2347 | - break; |
|
| 2348 | - case 'direct-ancestors': |
|
| 2349 | - $this->addAncestors($this->list, $id, false, $maxgen); |
|
| 2350 | - break; |
|
| 2351 | - case 'ancestors': |
|
| 2352 | - $this->addAncestors($this->list, $id, true, $maxgen); |
|
| 2353 | - break; |
|
| 2354 | - case 'descendants': |
|
| 2355 | - $this->list[$id]->generation = 1; |
|
| 2356 | - $this->addDescendancy($this->list, $id, false, $maxgen); |
|
| 2357 | - break; |
|
| 2358 | - case 'all': |
|
| 2359 | - $this->addAncestors($this->list, $id, true, $maxgen); |
|
| 2360 | - $this->addDescendancy($this->list, $id, true, $maxgen); |
|
| 2361 | - break; |
|
| 2347 | + break; |
|
| 2348 | + case 'direct-ancestors': |
|
| 2349 | + $this->addAncestors($this->list, $id, false, $maxgen); |
|
| 2350 | + break; |
|
| 2351 | + case 'ancestors': |
|
| 2352 | + $this->addAncestors($this->list, $id, true, $maxgen); |
|
| 2353 | + break; |
|
| 2354 | + case 'descendants': |
|
| 2355 | + $this->list[$id]->generation = 1; |
|
| 2356 | + $this->addDescendancy($this->list, $id, false, $maxgen); |
|
| 2357 | + break; |
|
| 2358 | + case 'all': |
|
| 2359 | + $this->addAncestors($this->list, $id, true, $maxgen); |
|
| 2360 | + $this->addDescendancy($this->list, $id, true, $maxgen); |
|
| 2361 | + break; |
|
| 2362 | 2362 | } |
| 2363 | 2363 | } |
| 2364 | 2364 | |
| 2365 | 2365 | switch ($sortby) { |
| 2366 | - case 'NAME': |
|
| 2367 | - uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare'); |
|
| 2368 | - break; |
|
| 2369 | - case 'BIRT:DATE': |
|
| 2370 | - uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate'); |
|
| 2371 | - break; |
|
| 2372 | - case 'DEAT:DATE': |
|
| 2373 | - uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate'); |
|
| 2374 | - break; |
|
| 2375 | - case 'generation': |
|
| 2376 | - $newarray = []; |
|
| 2377 | - reset($this->list); |
|
| 2378 | - $genCounter = 1; |
|
| 2379 | - while (count($newarray) < count($this->list)) { |
|
| 2380 | - foreach ($this->list as $key => $value) { |
|
| 2381 | - $this->generation = $value->generation; |
|
| 2382 | - if ($this->generation == $genCounter) { |
|
| 2383 | - $newarray[$key] = new \stdClass; |
|
| 2384 | - $newarray[$key]->generation = $this->generation; |
|
| 2366 | + case 'NAME': |
|
| 2367 | + uasort($this->list, '\Fisharebest\Webtrees\GedcomRecord::compare'); |
|
| 2368 | + break; |
|
| 2369 | + case 'BIRT:DATE': |
|
| 2370 | + uasort($this->list, '\Fisharebest\Webtrees\Individual::compareBirthDate'); |
|
| 2371 | + break; |
|
| 2372 | + case 'DEAT:DATE': |
|
| 2373 | + uasort($this->list, '\Fisharebest\Webtrees\Individual::compareDeathDate'); |
|
| 2374 | + break; |
|
| 2375 | + case 'generation': |
|
| 2376 | + $newarray = []; |
|
| 2377 | + reset($this->list); |
|
| 2378 | + $genCounter = 1; |
|
| 2379 | + while (count($newarray) < count($this->list)) { |
|
| 2380 | + foreach ($this->list as $key => $value) { |
|
| 2381 | + $this->generation = $value->generation; |
|
| 2382 | + if ($this->generation == $genCounter) { |
|
| 2383 | + $newarray[$key] = new \stdClass; |
|
| 2384 | + $newarray[$key]->generation = $this->generation; |
|
| 2385 | + } |
|
| 2385 | 2386 | } |
| 2387 | + $genCounter++; |
|
| 2386 | 2388 | } |
| 2387 | - $genCounter++; |
|
| 2388 | - } |
|
| 2389 | - $this->list = $newarray; |
|
| 2390 | - break; |
|
| 2391 | - default: |
|
| 2392 | - // unsorted |
|
| 2393 | - break; |
|
| 2389 | + $this->list = $newarray; |
|
| 2390 | + break; |
|
| 2391 | + default: |
|
| 2392 | + // unsorted |
|
| 2393 | + break; |
|
| 2394 | 2394 | } |
| 2395 | 2395 | array_push($this->repeats_stack, [$this->repeats, $this->repeat_bytes]); |
| 2396 | 2396 | $this->repeat_bytes = xml_get_current_line_number($this->parser) + 1; |
@@ -46,15 +46,15 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function modAction($mod_action) { |
| 48 | 48 | switch ($mod_action) { |
| 49 | - case 'delete': |
|
| 50 | - $stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id"); |
|
| 51 | - |
|
| 52 | - foreach (Filter::postArray('message_id') as $id) { |
|
| 53 | - $stmt->execute([ |
|
| 54 | - 'message_id' => $id, |
|
| 55 | - 'user_id' => Auth::id(), |
|
| 56 | - ]); |
|
| 57 | - } |
|
| 49 | + case 'delete': |
|
| 50 | + $stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id"); |
|
| 51 | + |
|
| 52 | + foreach (Filter::postArray('message_id') as $id) { |
|
| 53 | + $stmt->execute([ |
|
| 54 | + 'message_id' => $id, |
|
| 55 | + 'user_id' => Auth::id(), |
|
| 56 | + ]); |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $ged = Filter::post('ged'); |