summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-06-28 23:33:32 +0100
committerGreg Roach <fisharebest@webtrees.net>2018-06-30 10:51:44 +0100
commitf15adfdfd5766d4cca131b59e4f881d1cbc3ca6e (patch)
tree36b2afbff5fbece75e9bf6e18da0b9f704d44044 /app
parentf161acc3fa4eb4bdf096acee5b8a2bf8ff14b0ca (diff)
downloadwebtrees-f15adfdfd5766d4cca131b59e4f881d1cbc3ca6e.tar.gz
webtrees-f15adfdfd5766d4cca131b59e4f881d1cbc3ca6e.tar.bz2
webtrees-f15adfdfd5766d4cca131b59e4f881d1cbc3ca6e.zip
Convert print_indi_form function to view
Diffstat (limited to 'app')
-rw-r--r--app/Functions/FunctionsCharts.php6
-rw-r--r--app/Http/Controllers/EditFamilyController.php106
-rw-r--r--app/Http/Controllers/EditIndividualController.php320
-rw-r--r--app/Http/Controllers/IndividualController.php2
4 files changed, 430 insertions, 4 deletions
diff --git a/app/Functions/FunctionsCharts.php b/app/Functions/FunctionsCharts.php
index f82f0fed4f..d365107848 100644
--- a/app/Functions/FunctionsCharts.php
+++ b/app/Functions/FunctionsCharts.php
@@ -286,9 +286,9 @@ class FunctionsCharts {
if ($sosa == 0 && Auth::isEditor($family->getTree())) {
echo '<br>';
- echo '<a href="edit_interface.php?action=add_child_to_family&amp;ged=' . e($family->getTree()->getName()) . '&amp;xref=' . $family->getXref() . '&amp;gender=U">' . I18N::translate('Add a child to this family') . '</a>';
- echo ' <a class="icon-sex_m_15x15" href="edit_interface.php?action=add_child_to_family&amp;ged=' . e($family->getTree()->getName()) . '&amp;xref=' . $family->getXref() . '&amp;gender=M" title="', I18N::translate('son'), '"></a>';
- echo ' <a class="icon-sex_f_15x15" href="edit_interface.php?action=add_child_to_family&amp;ged=' . e($family->getTree()->getName()) . '&amp;xref=' . $family->getXref() . '&amp;gender=F" title="', I18N::translate('daughter'), '"></a>';
+ echo '<a href="' . e(route('add-child-to-family', ['gender' => 'U', 'ged' => $family->getTree()->getName(), 'xref' => $family->getXref()])) . '">' . I18N::translate('Add a child to this family') . '</a>';
+ echo ' <a class="icon-sex_m_15x15" href="' . e(route('add-child-to-family', ['gender' => 'M', 'ged' => $family->getTree()->getName(), 'xref' => $family->getXref()])) . '" title="', I18N::translate('son'), '"></a>';
+ echo ' <a class="icon-sex_f_15x15" href="' . e(route('add-child-to-family', ['gender' => 'F', 'ged' => $family->getTree()->getName(), 'xref' => $family->getXref()])) . '" title="', I18N::translate('daughter'), '"></a>';
echo '<br><br>';
}
echo '</td>';
diff --git a/app/Http/Controllers/EditFamilyController.php b/app/Http/Controllers/EditFamilyController.php
index caf3fd6432..42fbc24185 100644
--- a/app/Http/Controllers/EditFamilyController.php
+++ b/app/Http/Controllers/EditFamilyController.php
@@ -88,4 +88,110 @@ class EditFamilyController extends AbstractBaseController {
return new RedirectResponse($family->url());
}
+
+ /**
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function addChild(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+ $gender = $request->get('gender', 'U');
+
+ $family = Family::getInstance($xref, $tree);
+
+ $this->checkFamilyAccess($family, true);
+
+ $title = $family->getFullName() . ' - ' . I18N::translate('Add a child');
+
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => $title,
+ 'nextaction' => 'add_child_to_family_action',
+ 'individual' => null,
+ 'family' => $family,
+ 'name_fact' => null,
+ 'famtag' => 'CHIL',
+ 'gender' => $gender,
+ ]);
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function addChildAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $family = Family::getInstance($xref, $tree);
+
+ $this->checkFamilyAccess($family, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($family->url());
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function addSpouse(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+ $famtag = $request->get('famtag', '');
+
+ $family = Family::getInstance($xref, $tree);
+
+ $this->checkFamilyAccess($family, true);
+
+ if ($famtag === 'WIFE') {
+ $title = I18N::translate('Add a wife');
+ $gender = 'F';
+ } else {
+ $title = I18N::translate('Add a husband');
+ $gender = 'M';
+ }
+
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => $title,
+ 'nextaction' => 'add_spouse_to_family_action',
+ 'individual' => null,
+ 'family' => $family,
+ 'name_fact' => null,
+ 'famtag' => $famtag,
+ 'gender' => $gender,
+ ]);
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function addSpouseAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $family = Family::getInstance($xref, $tree);
+
+ $this->checkFamilyAccess($family, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($family->url());
+ }
}
diff --git a/app/Http/Controllers/EditIndividualController.php b/app/Http/Controllers/EditIndividualController.php
index 32ef158aa5..140fb6952b 100644
--- a/app/Http/Controllers/EditIndividualController.php
+++ b/app/Http/Controllers/EditIndividualController.php
@@ -23,6 +23,7 @@ use Fisharebest\Webtrees\Tree;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Controller for edit forms and responses.
@@ -210,4 +211,323 @@ class EditIndividualController extends AbstractBaseController {
return new RedirectResponse($individual->url());
}
+
+ /**
+ * Add a child to an existing individual (creating a one-parent family).
+ *
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function addChild(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ $title = $individual->getFullName() . ' - ' . I18N::translate('Add a child to create a one-parent family');
+
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => $title,
+ 'nextaction' => 'add_child_to_individual_action',
+ 'individual' => $individual,
+ 'family' => null,
+ 'name_fact' => null,
+ 'famtag' => 'CHIL',
+ 'gender' => 'U',
+ ]);
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function addChildAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($individual->url());
+ }
+
+ /**
+ * Add a parent to an existing individual (creating a one-parent family).
+ *
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function addParent(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+ $gender = $request->get('gender', 'U');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ if ($gender === 'F') {
+ $title = $individual->getFullName() . ' - ' . I18N::translate('Add a mother');
+ $famtag = 'WIFE';
+ } else {
+ $title = $individual->getFullName() . ' - ' . I18N::translate('Add a father');
+ $famtag = 'HUSB';
+ }
+
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => $title,
+ 'nextaction' => 'add_parent_to_individual_action',
+ 'individual' => $individual,
+ 'family' => null,
+ 'name_fact' => null,
+ 'famtag' => $famtag,
+ 'gender' => $gender,
+ ]);
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function addParentAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($individual->url());
+ }
+
+ /**
+ * Add a spouse to an existing individual (creating a new family).
+ *
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function addSpouse(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $gender = $request->get('gender', 'F');
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ if ($gender === 'F') {
+ $title = $individual->getFullName() . ' - ' . I18N::translate('Add a wife');
+ $famtag = 'WIFE';
+ } else {
+ $title = $individual->getFullName() . ' - ' . I18N::translate('Add a husband');
+ $famtag = 'HUSB';
+ }
+
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => $title,
+ 'nextaction' => 'add_spouse_to_individual_action',
+ 'individual' => $individual,
+ 'family' => null,
+ 'name_fact' => null,
+ 'famtag' => $famtag,
+ 'gender' => $gender,
+ ]);
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function addSpouseAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($individual->url());
+ }
+
+ /**
+ * Add an unlinked individual
+ *
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function addUnlinked(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => I18N::translate('Create an individual'),
+ 'nextaction' => 'add_unlinked_indi_action',
+ 'individual' => null,
+ 'family' => null,
+ 'name_fact' => null,
+ 'famtag' => null,
+ 'gender' => 'U',
+ ]);
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function addUnlinkedAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($individual->url());
+ }
+
+ /**
+ * Edit a name record.
+ *
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function editName(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $fact_id = $request->get('fact_id', '');
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ // Find the fact to edit
+ $name_fact = null;
+ foreach ($individual->getFacts() as $fact) {
+ if ($fact->getFactId() === $fact_id && $fact->canEdit()) {
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => I18N::translate('Edit the name'),
+ 'nextaction' => 'update',
+ 'individual' => $individual,
+ 'family' => null,
+ 'name_fact' => $name_fact,
+ 'famtag' => '',
+ 'gender' => $individual->getSex(),
+ ]);
+ }
+ }
+
+ throw new NotFoundHttpException;
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function editNameAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($individual->url());
+ }
+
+ /**
+ * Add a new name record.
+ *
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function addName(Request $request): Response {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ $title = $individual->getFullName() . ' — ' . I18N::translate('Add a name');
+
+ return $this->viewResponse('edit/new-individual', [
+ 'tree' => $tree,
+ 'title' => $title,
+ 'nextaction' => 'update',
+ 'individual' => $individual,
+ 'family' => null,
+ 'name_fact' => null,
+ 'famtag' => '',
+ 'gender' => $individual->getSex(),
+ ]);
+ }
+
+ /**
+ * @param Request $request
+ *
+ * @return RedirectResponse
+ */
+ public function addNameAction(Request $request): RedirectResponse {
+ /** @var Tree $tree */
+ $tree = $request->attributes->get('tree');
+
+ $xref = $request->get('xref', '');
+
+ $individual = Individual::getInstance($xref, $tree);
+
+ $this->checkIndividualAccess($individual, true);
+
+ // @TODO move edit_interface.php code here
+
+ return new RedirectResponse($individual->url());
+ }
}
diff --git a/app/Http/Controllers/IndividualController.php b/app/Http/Controllers/IndividualController.php
index af2b3fbe60..34f75501b3 100644
--- a/app/Http/Controllers/IndividualController.php
+++ b/app/Http/Controllers/IndividualController.php
@@ -319,7 +319,7 @@ class IndividualController extends AbstractBaseController {
]) .
FontAwesome::linkIcon('edit', I18N::translate('Edit the name'), [
'class' => 'btn btn-link',
- 'href' => 'edit_interface.php?action=editname&xref=' . $individual->getXref() . '&fact_id=' . $fact->getFactId() . '&ged=' . e($individual->getTree()->getName()),
+ 'href' => route('edit-name', ['xref' => $individual->getXref(), 'fact_id' => $fact->getFactId(), 'ged' => $individual->getTree()->getName()]),
]);
} else {
$edit_links = '';