diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2019-01-23 10:28:39 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2019-01-23 10:28:39 +0000 |
| commit | e2b8114de32f4ac3319ef4ec97dceddeff185499 (patch) | |
| tree | 5b382cf8dbd45c7ab724dbf878ee4eaff5751417 | |
| parent | d6a521701f4c0fa425e8a739537f9a51f593422b (diff) | |
| download | webtrees-e2b8114de32f4ac3319ef4ec97dceddeff185499.tar.gz webtrees-e2b8114de32f4ac3319ef4ec97dceddeff185499.tar.bz2 webtrees-e2b8114de32f4ac3319ef4ec97dceddeff185499.zip | |
Merge chart controllers into chart modules
| -rw-r--r-- | app/Http/Controllers/LifespansChartController.php | 392 | ||||
| -rw-r--r-- | app/Module/LifespansChartModule.php | 382 | ||||
| -rw-r--r-- | resources/views/modules/lifespans-chart/chart-page.phtml (renamed from resources/views/lifespans-page.phtml) | 12 | ||||
| -rw-r--r-- | resources/views/modules/lifespans-chart/chart.phtml (renamed from resources/views/lifespans-chart.phtml) | 0 | ||||
| -rw-r--r-- | resources/views/modules/timeline-chart/chart-page.phtml | 2 | ||||
| -rw-r--r-- | routes/web.php | 2 |
6 files changed, 389 insertions, 401 deletions
diff --git a/app/Http/Controllers/LifespansChartController.php b/app/Http/Controllers/LifespansChartController.php deleted file mode 100644 index b6e959cc0e..0000000000 --- a/app/Http/Controllers/LifespansChartController.php +++ /dev/null @@ -1,392 +0,0 @@ -<?php -/** - * webtrees: online genealogy - * Copyright (C) 2019 webtrees development team - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -declare(strict_types=1); - -namespace Fisharebest\Webtrees\Http\Controllers; - -use Fisharebest\ExtCalendar\GregorianCalendar; -use Fisharebest\Webtrees\ColorGenerator; -use Fisharebest\Webtrees\Date; -use Fisharebest\Webtrees\I18N; -use Fisharebest\Webtrees\Individual; -use Fisharebest\Webtrees\Module\LifespansChartModule; -use Fisharebest\Webtrees\Place; -use Fisharebest\Webtrees\Tree; -use Illuminate\Database\Capsule\Manager as DB; -use Illuminate\Database\Query\JoinClause; -use stdClass; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * A chart showing the lifespans of individuals. - */ -class LifespansChartController extends AbstractBaseController -{ - // Parameters for generating colors - private const RANGE = 120; // degrees - private const SATURATION = 100; // percent - private const LIGHTNESS = 30; // percent - private const ALPHA = 0.25; - - /** - * A form to request the chart parameters. - * - * @param Request $request - * @param Tree $tree - * - * @return Response - */ - public function page(Request $request, Tree $tree): Response - { - $this->checkModuleIsActive($tree, LifespansChartModule::class); - - $xrefs = (array) $request->get('xrefs', []); - $addxref = $request->get('addxref', ''); - $addfam = (bool) $request->get('addfam', false); - $placename = $request->get('placename', ''); - $start = $request->get('start', ''); - $end = $request->get('end', ''); - - $place = new Place($placename, $tree); - $start_date = new Date($start); - $end_date = new Date($end); - - // Add an individual, and family members - $individual = Individual::getInstance($addxref, $tree); - if ($individual !== null) { - $xrefs[] = $addxref; - if ($addfam) { - $xrefs = array_merge($xrefs, $this->closeFamily($individual)); - } - } - - // Select by date and/or place. - if ($start_date->isOK() && $end_date->isOK() && $placename !== '') { - $date_xrefs = $this->findIndividualsByDate($start_date, $end_date, $tree); - $place_xrefs = $this->findIndividualsByPlace($place, $tree); - $xrefs = array_intersect($date_xrefs, $place_xrefs); - } elseif ($start_date->isOK() && $end_date->isOK()) { - $xrefs = $this->findIndividualsByDate($start_date, $end_date, $tree); - } elseif ($placename !== '') { - $xrefs = $this->findIndividualsByPlace($place, $tree); - } - - // Filter duplicates and private individuals. - $xrefs = array_unique($xrefs); - $xrefs = array_filter($xrefs, function (string $xref) use ($tree): bool { - $individual = Individual::getInstance($xref, $tree); - - return $individual !== null && $individual->canShow(); - }); - - $title = I18N::translate('Lifespans'); - $subtitle = $this->subtitle(count($xrefs), $start_date, $end_date, $placename); - - return $this->viewResponse('lifespans-page', [ - 'xrefs' => $xrefs, - 'subtitle' => $subtitle, - 'title' => $title, - ]); - } - - /** - * @param Request $request - * @param Tree $tree - * - * @return Response - */ - public function chart(Request $request, Tree $tree): Response - { - $this->checkModuleIsActive($tree, LifespansChartModule::class); - - $xrefs = (array) $request->get('xrefs', []); - $xrefs = array_unique($xrefs); - - /** @var Individual[] $individuals */ - $individuals = array_map(function (string $xref) use ($tree) { - return Individual::getInstance($xref, $tree); - }, $xrefs); - - $individuals = array_filter($individuals, function (Individual $individual = null): bool { - return $individual !== null && $individual->canShow(); - }); - - // Sort the array in order of birth year - usort($individuals, function (Individual $a, Individual $b) { - return Date::compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); - }); - - $subtitle = $request->get('subtitle'); - - // Round to whole decades - $start_year = (int) floor($this->minYear($individuals) / 10) * 10; - $end_year = (int) ceil($this->maxYear($individuals) / 10) * 10; - - $lifespans = $this->layoutIndividuals($individuals); - - $max_rows = array_reduce($lifespans, function ($carry, stdClass $item) { - return max($carry, $item->row); - }, 0); - - $html = view('lifespans-chart', [ - 'dir' => I18N::direction(), - 'end_year' => $end_year, - 'lifespans' => $lifespans, - 'max_rows' => $max_rows, - 'start_year' => $start_year, - 'subtitle' => $subtitle, - ]); - - return new Response($html); - } - - /** - * - * - * @param Individual[] $individuals - * - * @return stdClass[] - */ - private function layoutIndividuals(array $individuals): array - { - $colors = [ - 'M' => new ColorGenerator(240, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE * -1), - 'F' => new ColorGenerator(000, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE), - 'U' => new ColorGenerator(120, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE), - ]; - - $current_year = (int) date('Y'); - - // Latest year used in each row - $rows = []; - - $lifespans = []; - - foreach ($individuals as $individual) { - $birth_jd = $individual->getEstimatedBirthDate()->minimumJulianDay(); - $birth_year = $this->jdToYear($birth_jd); - $death_jd = $individual->getEstimatedDeathDate()->maximumJulianDay(); - $death_year = $this->jdToYear($death_jd); - - // Don't show death dates in the future. - $death_year = min($death_year, $current_year); - - // Add this individual to the next row in the chart... - $next_row = count($rows); - // ...unless we can find an existing row where it fits. - foreach ($rows as $row => $year) { - if ($year < $birth_year) { - $next_row = $row; - break; - } - } - - // Fill the row up to the year (leaving a small gap) - $rows[$next_row] = $death_year; - - $lifespans[] = (object) [ - 'background' => $colors[$individual->getSex()]->getNextColor(), - 'birth_year' => $birth_year, - 'death_year' => $death_year, - 'id' => 'individual-' . md5($individual->xref()), - 'individual' => $individual, - 'row' => $next_row, - ]; - } - - return $lifespans; - } - - /** - * Find the latest event year for individuals - * - * @param array $individuals - * - * @return int - */ - private function maxYear(array $individuals): int - { - $jd = array_reduce($individuals, function ($carry, Individual $item) { - return max($carry, $item->getEstimatedDeathDate()->maximumJulianDay()); - }, 0); - - $year = $this->jdToYear($jd); - - // Don't show future dates - return min($year, (int) date('Y')); - } - - /** - * Find the earliest event year for individuals - * - * @param array $individuals - * - * @return int - */ - private function minYear(array $individuals): int - { - $jd = array_reduce($individuals, function ($carry, Individual $item) { - return min($carry, $item->getEstimatedBirthDate()->minimumJulianDay()); - }, PHP_INT_MAX); - - return $this->jdToYear($jd); - } - - /** - * Convert a julian day to a gregorian year - * - * @param int $jd - * - * @return int - */ - private function jdToYear(int $jd): int - { - if ($jd === 0) { - return 0; - } - - $gregorian = new GregorianCalendar(); - [$y] = $gregorian->jdToYmd($jd); - - return $y; - } - - /** - * @param Date $start - * @param Date $end - * @param Tree $tree - * - * @return string[] - */ - private function findIndividualsByDate(Date $start, Date $end, Tree $tree): array - { - return DB::table('individuals') - ->join('dates', function (JoinClause $join): void { - $join - ->on('d_file', '=', 'i_file') - ->on('d_gid', '=', 'i_id'); - }) - ->where('i_file', '=', $tree->id()) - ->where('d_julianday1', '<=', $end->maximumJulianDay()) - ->where('d_julianday2', '>=', $start->minimumJulianDay()) - ->whereNotIn('d_fact', ['BAPL', 'ENDL', 'SLGC', 'SLGS', '_TODO', 'CHAN']) - ->pluck('i_id') - ->all(); - } - - /** - * @param Place $place - * @param Tree $tree - * - * @return string[] - */ - private function findIndividualsByPlace(Place $place, Tree $tree): array - { - return DB::table('individuals') - ->join('placelinks', function (JoinClause $join): void { - $join - ->on('pl_file', '=', 'i_file') - ->on('pl_gid', '=', 'i_id'); - }) - ->where('i_file', '=', $tree->id()) - ->where('pl_p_id', '=', $place->getPlaceId()) - ->pluck('i_id') - ->all(); - } - - /** - * Find the close family members of an individual. - * - * @param Individual $individual - * - * @return string[] - */ - private function closeFamily(Individual $individual): array - { - $xrefs = []; - - foreach ($individual->getSpouseFamilies() as $family) { - foreach ($family->getChildren() as $child) { - $xrefs[] = $child->xref(); - } - - foreach ($family->getSpouses() as $spouse) { - $xrefs[] = $spouse->xref(); - } - } - - foreach ($individual->getChildFamilies() as $family) { - foreach ($family->getChildren() as $child) { - $xrefs[] = $child->xref(); - } - - foreach ($family->getSpouses() as $spouse) { - $xrefs[] = $spouse->xref(); - } - } - - return $xrefs; - } - - /** - * Generate a subtitle, based on filter parameters - * - * @param int $count - * @param Date $start - * @param Date $end - * @param string $placename - * - * @return string - */ - private function subtitle(int $count, Date $start, Date $end, string $placename): string - { - if ($start->isOK() && $end->isOK() && $placename !== '') { - return I18N::plural( - '%s individual with events in %s between %s and %s', - '%s individuals with events in %s between %s and %s', - $count, - I18N::number($count), - $placename, - $start->display(false, '%Y'), - $end->display(false, '%Y') - ); - } - - if ($placename !== '') { - return I18N::plural( - '%s individual with events in %s', - '%s individuals with events in %s', - $count, - I18N::number($count), - $placename - ); - } - - if ($start->isOK() && $end->isOK()) { - return I18N::plural( - '%s individual with events between %s and %s', - '%s individuals with events between %s and %s', - $count, - I18N::number($count), - $start->display(false, '%Y'), - $end->display(false, '%Y') - ); - } - - return I18N::plural('%s individual', '%s individuals', $count, I18N::number($count)); - } -} diff --git a/app/Module/LifespansChartModule.php b/app/Module/LifespansChartModule.php index e86fb5fdc3..b9900067b9 100644 --- a/app/Module/LifespansChartModule.php +++ b/app/Module/LifespansChartModule.php @@ -17,8 +17,18 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Module; +use Fisharebest\ExtCalendar\GregorianCalendar; +use Fisharebest\Webtrees\ColorGenerator; +use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Place; +use Fisharebest\Webtrees\Tree; +use Illuminate\Database\Capsule\Manager as DB; +use Illuminate\Database\Query\JoinClause; +use stdClass; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; /** * Class LifespansChartModule @@ -27,6 +37,12 @@ class LifespansChartModule extends AbstractModule implements ModuleInterface, Mo { use ModuleChartTrait; + // Parameters for generating colors + protected const RANGE = 120; // degrees + protected const SATURATION = 100; // percent + protected const LIGHTNESS = 30; // percent + protected const ALPHA = 0.25; + /** * How should this module be labelled on tabs, menus, etc.? * @@ -69,9 +85,373 @@ class LifespansChartModule extends AbstractModule implements ModuleInterface, Mo */ public function chartUrl(Individual $individual, array $parameters = []): string { - return route('lifespans', [ + return route('module', [ + 'module' => $this->name(), + 'action' => 'Chart', 'xrefs[]' => $individual->xref(), 'ged' => $individual->tree()->name(), ] + $parameters); } + + /** + * A form to request the chart parameters. + * + * @param Request $request + * @param Tree $tree + * + * @return Response + */ + public function getChartAction(Request $request, Tree $tree): Response + { + $ajax = $request->get('ajax'); + $xrefs = (array) $request->get('xrefs', []); + $addxref = $request->get('addxref', ''); + $addfam = (bool) $request->get('addfam', false); + $placename = $request->get('placename', ''); + $start = $request->get('start', ''); + $end = $request->get('end', ''); + + $place = new Place($placename, $tree); + $start_date = new Date($start); + $end_date = new Date($end); + + $xrefs = array_unique($xrefs); + + // Add an individual, and family members + $individual = Individual::getInstance($addxref, $tree); + if ($individual !== null) { + $xrefs[] = $addxref; + if ($addfam) { + $xrefs = array_merge($xrefs, $this->closeFamily($individual)); + } + } + + // Select by date and/or place. + if ($start_date->isOK() && $end_date->isOK() && $placename !== '') { + $date_xrefs = $this->findIndividualsByDate($start_date, $end_date, $tree); + $place_xrefs = $this->findIndividualsByPlace($place, $tree); + $xrefs = array_intersect($date_xrefs, $place_xrefs); + } elseif ($start_date->isOK() && $end_date->isOK()) { + $xrefs = $this->findIndividualsByDate($start_date, $end_date, $tree); + } elseif ($placename !== '') { + $xrefs = $this->findIndividualsByPlace($place, $tree); + } + + // Filter duplicates and private individuals. + $xrefs = array_unique($xrefs); + $xrefs = array_filter($xrefs, function (string $xref) use ($tree): bool { + $individual = Individual::getInstance($xref, $tree); + + return $individual !== null && $individual->canShow(); + }); + + if ($ajax === '1') { + $subtitle = $this->subtitle(count($xrefs), $start_date, $end_date, $placename); + + return $this->chart($tree, $xrefs, $subtitle); + } + + $ajax_url = route('module', [ + 'ajax' => '1', + 'module' => $this->name(), + 'action' => 'Chart', + 'ged' => $tree->name(), + 'xrefs' => $xrefs, + ]); + + $reset_url = route('module', [ + 'module' => $this->name(), + 'action' => 'Chart', + 'ged' => $tree->name(), + ]); + + return $this->viewResponse('modules/lifespans-chart/chart-page', [ + 'ajax_url' => $ajax_url, + 'module_name' => $this->name(), + 'reset_url' => $reset_url, + 'title' => $this->title(), + 'xrefs' => $xrefs, + ]); + } + + /** + * @param Tree $tree + * @param array $xrefs + * @param string $subtitle + * + * @return Response + */ + protected function chart(Tree $tree, array $xrefs, string $subtitle): Response + { + /** @var Individual[] $individuals */ + $individuals = array_map(function (string $xref) use ($tree) { + return Individual::getInstance($xref, $tree); + }, $xrefs); + + $individuals = array_filter($individuals, function (Individual $individual = null): bool { + return $individual !== null && $individual->canShow(); + }); + + // Sort the array in order of birth year + usort($individuals, function (Individual $a, Individual $b) { + return Date::compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); + }); + + // Round to whole decades + $start_year = (int) floor($this->minYear($individuals) / 10) * 10; + $end_year = (int) ceil($this->maxYear($individuals) / 10) * 10; + + $lifespans = $this->layoutIndividuals($individuals); + + $max_rows = array_reduce($lifespans, function ($carry, stdClass $item) { + return max($carry, $item->row); + }, 0); + + $html = view('modules/lifespans-chart/chart', [ + 'dir' => I18N::direction(), + 'end_year' => $end_year, + 'lifespans' => $lifespans, + 'max_rows' => $max_rows, + 'start_year' => $start_year, + 'subtitle' => $subtitle, + ]); + + return new Response($html); + } + + /** + * + * + * @param Individual[] $individuals + * + * @return stdClass[] + */ + private function layoutIndividuals(array $individuals): array + { + $colors = [ + 'M' => new ColorGenerator(240, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE * -1), + 'F' => new ColorGenerator(000, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE), + 'U' => new ColorGenerator(120, self::SATURATION, self::LIGHTNESS, self::ALPHA, self::RANGE), + ]; + + $current_year = (int) date('Y'); + + // Latest year used in each row + $rows = []; + + $lifespans = []; + + foreach ($individuals as $individual) { + $birth_jd = $individual->getEstimatedBirthDate()->minimumJulianDay(); + $birth_year = $this->jdToYear($birth_jd); + $death_jd = $individual->getEstimatedDeathDate()->maximumJulianDay(); + $death_year = $this->jdToYear($death_jd); + + // Don't show death dates in the future. + $death_year = min($death_year, $current_year); + + // Add this individual to the next row in the chart... + $next_row = count($rows); + // ...unless we can find an existing row where it fits. + foreach ($rows as $row => $year) { + if ($year < $birth_year) { + $next_row = $row; + break; + } + } + + // Fill the row up to the year (leaving a small gap) + $rows[$next_row] = $death_year; + + $lifespans[] = (object) [ + 'background' => $colors[$individual->getSex()]->getNextColor(), + 'birth_year' => $birth_year, + 'death_year' => $death_year, + 'id' => 'individual-' . md5($individual->xref()), + 'individual' => $individual, + 'row' => $next_row, + ]; + } + + return $lifespans; + } + + /** + * Find the latest event year for individuals + * + * @param array $individuals + * + * @return int + */ + protected function maxYear(array $individuals): int + { + $jd = array_reduce($individuals, function ($carry, Individual $item) { + return max($carry, $item->getEstimatedDeathDate()->maximumJulianDay()); + }, 0); + + $year = $this->jdToYear($jd); + + // Don't show future dates + return min($year, (int) date('Y')); + } + + /** + * Find the earliest event year for individuals + * + * @param array $individuals + * + * @return int + */ + protected function minYear(array $individuals): int + { + $jd = array_reduce($individuals, function ($carry, Individual $item) { + return min($carry, $item->getEstimatedBirthDate()->minimumJulianDay()); + }, PHP_INT_MAX); + + return $this->jdToYear($jd); + } + + /** + * Convert a julian day to a gregorian year + * + * @param int $jd + * + * @return int + */ + protected function jdToYear(int $jd): int + { + if ($jd === 0) { + return 0; + } + + $gregorian = new GregorianCalendar(); + [$y] = $gregorian->jdToYmd($jd); + + return $y; + } + + /** + * @param Date $start + * @param Date $end + * @param Tree $tree + * + * @return string[] + */ + protected function findIndividualsByDate(Date $start, Date $end, Tree $tree): array + { + return DB::table('individuals') + ->join('dates', function (JoinClause $join): void { + $join + ->on('d_file', '=', 'i_file') + ->on('d_gid', '=', 'i_id'); + }) + ->where('i_file', '=', $tree->id()) + ->where('d_julianday1', '<=', $end->maximumJulianDay()) + ->where('d_julianday2', '>=', $start->minimumJulianDay()) + ->whereNotIn('d_fact', ['BAPL', 'ENDL', 'SLGC', 'SLGS', '_TODO', 'CHAN']) + ->pluck('i_id') + ->all(); + } + + /** + * @param Place $place + * @param Tree $tree + * + * @return string[] + */ + protected function findIndividualsByPlace(Place $place, Tree $tree): array + { + return DB::table('individuals') + ->join('placelinks', function (JoinClause $join): void { + $join + ->on('pl_file', '=', 'i_file') + ->on('pl_gid', '=', 'i_id'); + }) + ->where('i_file', '=', $tree->id()) + ->where('pl_p_id', '=', $place->getPlaceId()) + ->pluck('i_id') + ->all(); + } + + /** + * Find the close family members of an individual. + * + * @param Individual $individual + * + * @return string[] + */ + protected function closeFamily(Individual $individual): array + { + $xrefs = []; + + foreach ($individual->getSpouseFamilies() as $family) { + foreach ($family->getChildren() as $child) { + $xrefs[] = $child->xref(); + } + + foreach ($family->getSpouses() as $spouse) { + $xrefs[] = $spouse->xref(); + } + } + + foreach ($individual->getChildFamilies() as $family) { + foreach ($family->getChildren() as $child) { + $xrefs[] = $child->xref(); + } + + foreach ($family->getSpouses() as $spouse) { + $xrefs[] = $spouse->xref(); + } + } + + return $xrefs; + } + + /** + * Generate a subtitle, based on filter parameters + * + * @param int $count + * @param Date $start + * @param Date $end + * @param string $placename + * + * @return string + */ + protected function subtitle(int $count, Date $start, Date $end, string $placename): string + { + if ($start->isOK() && $end->isOK() && $placename !== '') { + return I18N::plural( + '%s individual with events in %s between %s and %s', + '%s individuals with events in %s between %s and %s', + $count, + I18N::number($count), + $placename, + $start->display(false, '%Y'), + $end->display(false, '%Y') + ); + } + + if ($placename !== '') { + return I18N::plural( + '%s individual with events in %s', + '%s individuals with events in %s', + $count, + I18N::number($count), + $placename + ); + } + + if ($start->isOK() && $end->isOK()) { + return I18N::plural( + '%s individual with events between %s and %s', + '%s individuals with events between %s and %s', + $count, + I18N::number($count), + $start->display(false, '%Y'), + $end->display(false, '%Y') + ); + } + + return I18N::plural('%s individual', '%s individuals', $count, I18N::number($count)); + } } diff --git a/resources/views/lifespans-page.phtml b/resources/views/modules/lifespans-chart/chart-page.phtml index b633e97da6..7b65947fcb 100644 --- a/resources/views/lifespans-page.phtml +++ b/resources/views/modules/lifespans-chart/chart-page.phtml @@ -7,11 +7,13 @@ </h2> <form class="wt-page-options wt-page-options-lifespans-chart d-print-none"> - <input type="hidden" name="route" value="lifespans"> + <input type="hidden" name="route" value="module"> + <input type="hidden" name="module" value="<?= e($module_name) ?>"> + <input type="hidden" name="action" value="Chart"> <input type="hidden" name="ged" value="<?= e($tree->name()) ?>"> <?php foreach ($xrefs as $xref) : ?> - <input name="xrefs[]" type="hidden" value="<?= e($xref) ?>"> + <input name="xrefs[]" type="hidden" value="<?= e($xref) ?>"> <?php endforeach ?> <div class="row form-group"> @@ -39,7 +41,7 @@ <?= I18N::translate('Place') ?> </label> <div class="col-sm-9 wt-page-options-value"> - <input class="form-control" id="placename" name="placename" type="text"> + <input class="form-control" id="placename" name="placename" type="text" data-autocomplete-url="<?= e(route('autocomplete-place')) ?>"> </div> </div> @@ -67,7 +69,7 @@ <button type="submit" class="btn btn-primary" type="submit"> <?= /* I18N: A button label. */ I18N::translate('add') ?> </button> - <a class="btn btn-secondary" href="<?= e(route('lifespans', ['ged' => $tree->name()])) ?>"> + <a class="btn btn-secondary" href="<?= e($reset_url) ?>"> <?= /* I18N: A button label. */ I18N::translate('reset') ?> </a> </div> @@ -75,4 +77,4 @@ </form> -<div class="wt-ajax-load wt-page-content wt-chart wt-timeline-chart" data-ajax-url="<?= e(route('lifespans-chart', ['ged' => $tree->name(), 'xrefs' => $xrefs, 'subtitle' => $subtitle])) ?>"></div> +<div class="wt-ajax-load wt-page-content wt-chart wt-timeline-chart" data-ajax-url="<?= e($ajax_url) ?>"></div> diff --git a/resources/views/lifespans-chart.phtml b/resources/views/modules/lifespans-chart/chart.phtml index 974f223c93..974f223c93 100644 --- a/resources/views/lifespans-chart.phtml +++ b/resources/views/modules/lifespans-chart/chart.phtml diff --git a/resources/views/modules/timeline-chart/chart-page.phtml b/resources/views/modules/timeline-chart/chart-page.phtml index bdef28cd80..a8d5441ba3 100644 --- a/resources/views/modules/timeline-chart/chart-page.phtml +++ b/resources/views/modules/timeline-chart/chart-page.phtml @@ -13,7 +13,7 @@ <input type="hidden" name="scale" value="<?= e($scale) ?>"> <?php foreach ($individuals as $individual) : ?> - <input name="xrefs[]" type="hidden" value="<?= e($individual->xref()) ?>"> + <input name="xrefs[]" type="hidden" value="<?= e($individual->xref()) ?>"> <?php endforeach ?> <div class="row form-group"> diff --git a/routes/web.php b/routes/web.php index acb8438ab9..b15069b911 100644 --- a/routes/web.php +++ b/routes/web.php @@ -276,8 +276,6 @@ if ($tree instanceof Tree && $tree->getPreference('imported') === '1') { 'GET:source-list' => 'ListController@sourceList', 'GET:interactive' => 'InteractiveChartController@page', 'GET:interactive-chart' => 'InteractiveChartController@chart', - 'GET:lifespans' => 'LifespansChartController@page', - 'GET:lifespans-chart' => 'LifespansChartController@chart', 'GET:relationships' => 'RelationshipsChartController@page', 'GET:relationships-chart' => 'RelationshipsChartController@chart', 'GET:statistics' => 'StatisticsChartController@page', |
