summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2017-10-24 09:02:46 +0100
committerGreg Roach <fisharebest@gmail.com>2017-10-24 10:32:38 +0100
commitf8a18b14a43b3c7789b4672046d55a5a99854d22 (patch)
tree761991696bd0129cf170377f00180aebceaf6f1f
parent88ee75a980681a50a4b8a3c5d5a1a73b7e28ad7c (diff)
downloadwebtrees-f8a18b14a43b3c7789b4672046d55a5a99854d22.tar.gz
webtrees-f8a18b14a43b3c7789b4672046d55a5a99854d22.tar.bz2
webtrees-f8a18b14a43b3c7789b4672046d55a5a99854d22.zip
Fix: #1424 - title on interactive tree
-rw-r--r--app/Module/InteractiveTree/TreeView.php91
-rw-r--r--app/Module/InteractiveTreeModule.php12
-rw-r--r--compact.php2
-rw-r--r--modules_v3/tree/css/treeview.css2
-rw-r--r--resources/views/interactive-tree-chart.php17
-rw-r--r--resources/views/interactive-tree-page.php33
6 files changed, 91 insertions, 66 deletions
diff --git a/app/Module/InteractiveTree/TreeView.php b/app/Module/InteractiveTree/TreeView.php
index b637a70ba1..33b01f70be 100644
--- a/app/Module/InteractiveTree/TreeView.php
+++ b/app/Module/InteractiveTree/TreeView.php
@@ -16,9 +16,9 @@
namespace Fisharebest\Webtrees\Module\InteractiveTree;
use Fisharebest\Webtrees\Family;
-use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\View;
/**
* Class TreeView
@@ -27,51 +27,29 @@ class TreeView {
/** @var string HTML element name */
private $name;
- /** @var string Show all partners */
- private $all_partners;
-
/**
* Treeview Constructor
*
* @param string $name the name of the TreeView object’s instance
*/
public function __construct($name = 'tree') {
- $this->name = $name;
- $this->all_partners = Filter::cookie('allPartners', 'true|false', 'true');
+ $this->name = $name;
}
/**
* Draw the viewport which creates the draggable/zoomable framework
* Size is set by the container, as the viewport can scale itself automatically
*
- * @param Individual $root_person the id of the root person
+ * @param Individual $individual Draw the chart for this individual
* @param int $generations number of generations to draw
*
* @return string[] HTML and Javascript
*/
- public function drawViewport(Individual $root_person, $generations) {
- $html = '
- <a name="tv_content"></a>
- <div id="' . $this->name . '_out" class="tv_out">
- <div id="tv_tools">
- <ul>
- <li id="tvbCompact" class="tv_button">
- <img src="' . WT_MODULES_DIR . 'tree/images/compact.png" alt="' . I18N::translate('Use compact layout') . '" title="' . I18N::translate('Use compact layout') . '">
- </li>
- <li id="tvbAllPartners" class="tv_button' . ($this->all_partners === 'true' ? ' tvPressed' : '') . '">
- <a class="icon-sfamily" href="#" title="' . I18N::translate('Show all spouses and ancestors') . '"></a>
- </li>
- <li class="tv_button" id="' . $this->name . '_loading">
- <i class="icon-loading-small"></i>
- </li>
- </ul>
- </div>
- <h2 id="tree-title">' . I18N::translate('Interactive tree of %s', $root_person->getFullName()) . '</h2>
- <div id="' . $this->name . '_in" class="tv_in" dir="ltr">
- ' . $this->drawPerson($root_person, $generations, 0, null, null, true) . '
- </div>
- </div>
- ';
+ public function drawViewport(Individual $individual, $generations) {
+ $html = View::make('interactive-tree-chart', [
+ 'name' => $this->name,
+ 'individual' => $this->drawPerson($individual, $generations, 0, null, null, true),
+ ]);
return [$html, 'var ' . $this->name . 'Handler = new TreeViewHandler("' . $this->name . '");'];
}
@@ -265,19 +243,14 @@ class TreeView {
foreach ($person->getSpouseFamilies() as $family) {
$spouse = $family->getSpouse($person);
if ($spouse) {
- if ($spouse === $partner || $this->all_partners === 'true') {
- $spouse_parents = $spouse->getPrimaryChildFamily();
- if ($spouse_parents && $spouse_parents->getHusband()) {
- $fop[] = [$spouse_parents->getHusband(), $spouse_parents];
- } elseif ($spouse_parents && $spouse_parents->getWife()) {
- $fop[] = [$spouse_parents->getWife(), $spouse_parents];
- }
- $html .= $this->drawPersonName($spouse, $dashed);
- if ($this->all_partners !== 'true') {
- break; // we can stop here the foreach loop
- }
- $dashed = 'dashed';
+ $spouse_parents = $spouse->getPrimaryChildFamily();
+ if ($spouse_parents && $spouse_parents->getHusband()) {
+ $fop[] = [$spouse_parents->getHusband(), $spouse_parents];
+ } elseif ($spouse_parents && $spouse_parents->getWife()) {
+ $fop[] = [$spouse_parents->getWife(), $spouse_parents];
}
+ $html .= $this->drawPersonName($spouse, $dashed);
+ $dashed = 'dashed';
}
}
}
@@ -334,26 +307,22 @@ class TreeView {
* @return string
*/
private function drawPersonName(Individual $individual, $dashed = '') {
- if ($this->all_partners === 'true') {
- $family = $individual->getPrimaryChildFamily();
- if ($family) {
- $family_name = strip_tags($family->getFullName());
- } else {
- $family_name = I18N::translateContext('unknown family', 'unknown');
- }
- switch ($individual->getSex()) {
- case 'M':
- $title = ' title="' . /* I18N: e.g. “Son of [father name & mother name]” */ I18N::translate('Son of %s', $family_name) . '"';
- break;
- case 'F':
- $title = ' title="' . /* I18N: e.g. “Daughter of [father name & mother name]” */ I18N::translate('Daughter of %s', $family_name) . '"';
- break;
- default:
- $title = ' title="' . /* I18N: e.g. “Child of [father name & mother name]” */ I18N::translate('Child of %s', $family_name) . '"';
- break;
- }
+ $family = $individual->getPrimaryChildFamily();
+ if ($family) {
+ $family_name = strip_tags($family->getFullName());
} else {
- $title = '';
+ $family_name = I18N::translateContext('unknown family', 'unknown');
+ }
+ switch ($individual->getSex()) {
+ case 'M':
+ $title = ' title="' . /* I18N: e.g. “Son of [father name & mother name]” */ I18N::translate('Son of %s', $family_name) . '"';
+ break;
+ case 'F':
+ $title = ' title="' . /* I18N: e.g. “Daughter of [father name & mother name]” */ I18N::translate('Daughter of %s', $family_name) . '"';
+ break;
+ default:
+ $title = ' title="' . /* I18N: e.g. “Child of [father name & mother name]” */ I18N::translate('Child of %s', $family_name) . '"';
+ break;
}
$sex = $individual->getSex();
diff --git a/app/Module/InteractiveTreeModule.php b/app/Module/InteractiveTreeModule.php
index 932135741a..e2e38037bf 100644
--- a/app/Module/InteractiveTreeModule.php
+++ b/app/Module/InteractiveTreeModule.php
@@ -21,6 +21,7 @@ use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Menu;
use Fisharebest\Webtrees\Module\InteractiveTree\TreeView;
+use Fisharebest\Webtrees\View;
/**
* Class InteractiveTreeModule
@@ -127,7 +128,6 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
case 'treeview':
$controller = new ChartController;
$tv = new TreeView('tv');
- ob_start();
$person = $controller->getSignificantIndividual();
@@ -145,7 +145,15 @@ class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface
$("head").append(\'<link rel="stylesheet" type="text/css" href="' . $this->css() . '">\');
}
');
- echo $html;
+
+ echo View::make('interactive-tree-page', [
+ 'title' => $controller->getPageTitle(),
+ 'individual' => $controller->root,
+ 'html' => $html,
+ //'css' => $this->css(),
+ //'js' => $this->js(),
+ ]);
+
break;
case 'getDetails':
diff --git a/compact.php b/compact.php
index 1ab7092227..91e52a3849 100644
--- a/compact.php
+++ b/compact.php
@@ -45,5 +45,5 @@ $controller->pageHeader();
echo View::make('compact-chart-page', [
'title' => $controller->getPageTitle(),
'individual' => $controller->root,
- 'ajax_url' => $ajax_url,
+ 'ajax_url' => $ajax_url,
]);
diff --git a/modules_v3/tree/css/treeview.css b/modules_v3/tree/css/treeview.css
index 8c4bf1c370..3be38f7594 100644
--- a/modules_v3/tree/css/treeview.css
+++ b/modules_v3/tree/css/treeview.css
@@ -13,8 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#tree-title {text-align: center; margin-bottom: 100px;}
-
.tv_out {
position: relative;
overflow: hidden;
diff --git a/resources/views/interactive-tree-chart.php b/resources/views/interactive-tree-chart.php
new file mode 100644
index 0000000000..23e8642d65
--- /dev/null
+++ b/resources/views/interactive-tree-chart.php
@@ -0,0 +1,17 @@
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<div id="<?= $name ?>_out" class="tv_out">
+ <div id="tv_tools">
+ <ul>
+ <li id="tvbCompact" class="tv_button">
+ <img src="<?= WT_MODULES_DIR ?>tree/images/compact.png" alt="<?= I18N::translate('Use compact layout') ?>" title="<?= I18N::translate('Use compact layout') ?>">
+ </li>
+ <li class="tv_button" id="<?= $name ?>_loading">
+ <i class="icon-loading-small"></i>
+ </li>
+ </ul>
+ </div>
+ <div id="<?= $name ?>_in" class="tv_in" dir="ltr">
+ <?= $individual ?>
+ </div>
+</div>
diff --git a/resources/views/interactive-tree-page.php b/resources/views/interactive-tree-page.php
new file mode 100644
index 0000000000..0e4f5d952a
--- /dev/null
+++ b/resources/views/interactive-tree-page.php
@@ -0,0 +1,33 @@
+<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
+<?php use Fisharebest\Webtrees\Html; ?>
+<?php use Fisharebest\Webtrees\I18N; ?>
+
+<h2 class="wt-page-title">
+ <?= $title ?>
+</h2>
+
+<form class="wt-page-options wt-page-options-compact-chart d-print-none">
+ <input type="hidden" name="mod" value="tree">
+ <input type="hidden" name="mod_action" value="treeview">
+ <input type="hidden" name="ged" value="<?= Html::escape($individual->getTree()->getName()) ?>">
+
+ <div class="row form-group">
+ <label class="col-sm-3 col-form-label wt-page-options-label" for="rootid">
+ <?= I18N::translate('Individual') ?>
+ </label>
+ <div class="col-sm-9 wt-page-options-value">
+ <?= FunctionsEdit::formControlIndividual($individual, ['id' => 'rootid', 'name' => 'rootid']) ?>
+ </div>
+ </div>
+
+ <div class="row form-group">
+ <div class="col-sm-3 wt-page-options-label"></div>
+ <div class="col-sm-9 wt-page-options-value">
+ <input class="btn btn-primary" type="submit" value="<?= /* I18N: A button label. */ I18N::translate('view') ?>">
+ </div>
+ </div>
+</form>
+
+<div class="wt-page-content wt-chart wt-interactive-tree">
+ <?= $html ?>
+</div>