Skip to content

Commit

Permalink
First version with client side rendering
Browse files Browse the repository at this point in the history
This version has no strict dependency for graphviz on the serverside
anymore.

Pictures in serverside rendering are still not working
  • Loading branch information
tillsc committed May 22, 2021
1 parent 4cfca67 commit 96b938b
Show file tree
Hide file tree
Showing 6 changed files with 936 additions and 297 deletions.
9 changes: 5 additions & 4 deletions functions_dot.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function createIndiList () {
// if multiple indis are defined
$indis = explode(",", $this->settings["indi"]);
for ($i=0;$i<count($indis);$i++) {
$this->addIndiToList($indis[$i], $this->indi_search_method["ance"], $this->indi_search_method["desc"], $this->indi_search_method["spou"], $this->indi_search_method["sibl"], TRUE, 0, $this->settings["ance_level"], $this->settings["desc_level"]);
$this->addIndiToList(trim($indis[$i]), $this->indi_search_method["ance"], $this->indi_search_method["desc"], $this->indi_search_method["spou"], $this->indi_search_method["sibl"], TRUE, 0, $this->settings["ance_level"], $this->settings["desc_level"]);
}
}

Expand Down Expand Up @@ -257,7 +257,8 @@ function createDOTDump() {
foreach ($f->children() as $child) {
if (!empty($child) && (isset($this->individuals[$child->xref()]))) {
//$this->families[$fid]["has_children"] = TRUE;
foreach ($this->individuals[$child->xref()]["fams"] as $fam_nr=>$fam) {
$fams = isset($this->individuals[$child->xref()]["fams"]) ? $this->individuals[$child->xref()]["fams"] : [];
foreach ($fams as $fam_nr=>$fam) {
$out .= $this->convertID($fid) . " -> " . $this->convertID($fam) . ":" . $this->convertID($child->xref()) . "\n";
}
}
Expand Down Expand Up @@ -1036,7 +1037,7 @@ function addIndiToList($pid, $ance = FALSE, $desc = FALSE, $spou = FALSE, $sibl
if (isset($this->settings["stop_proc"]) && $this->settings["stop_proc"] == TRUE) {
$stop_pids = explode(",", $this->settings["stop_pids"]);
for ($j=0;$j<count($stop_pids);$j++) {
if ($pid == $stop_pids[$j]){
if ($pid == trim($stop_pids[$j])){
// --- DEBUG ---
if ($this->settings["debug"]) {
$this->printDebug("($pid) -- STOP processing, because INDI is listed in the \"Stop tree processing on INDIs\"\n", $ind);
Expand Down Expand Up @@ -1515,7 +1516,7 @@ function addPhotoToIndi($pid) {
return $m->downloadUrl('inline');
}
else if (!$m->isExternal() && $m->fileExists($this->file_system)) {
return realpath($this->file_system->getAdapter()->applyPathPrefix($m->filename()));
return './'.$this->file_system->getAdapter()->applyPathPrefix('media/'.$m->filename());
} else {
return null;
}
Expand Down
77 changes: 40 additions & 37 deletions module.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ public function chartBoxMenu(Individual $individual): ?Menu

public function chartUrl(Individual $individual, array $parameters = []): string
{
return route('module', [
return route('module', array_merge($parameters, [
'module' => $this->name(),
'action' => 'Chart',
'xref' => $individual->xref(),
'tree' => $individual->tree()->name(),
]);
]));
}

public function getIndividual($tree, $xref): Individual
Expand All @@ -123,12 +123,13 @@ public function getChartAction(ServerRequestInterface $request): ResponseInterfa
$individual = $this->getIndividual($tree, $request->getQueryParams()['xref']);

$userDefaultVars = [ //Defaults (this cloud be defined in the config?)
"otype" => "svg",
"grdir" => $GVE_CONFIG["default_direction"],
"mclimit" => $GVE_CONFIG["default_mclimit"],
"psize" => $GVE_CONFIG["default_pagesize"],
"indiinc" => "indi",
"diagtype" => "decorated",
"with_photos" => "with_photos",
"with_photos" => "",
"use_abbr_place" => ($GVE_CONFIG['settings']['use_abbr_place'] ? "use_abbr_place" : ""),
"show_by" => "show_by",
"bd_type" => "gedcom",
Expand Down Expand Up @@ -157,12 +158,14 @@ public function getChartAction(ServerRequestInterface $request): ResponseInterfa
"ranksep" => $GVE_CONFIG["settings"]["ranksep"],
"nodesep" => $GVE_CONFIG["settings"]["nodesep"],
"other_pids" => '',
"stop_pid" => '',
"other_stop_pids" => ''
];
if (isset($_COOKIE["GVEUserDefaults"]) and $_COOKIE["GVEUserDefaults"] != "") {
if (!isset($_REQUEST['reset']) and isset($_COOKIE["GVEUserDefaults"]) and $_COOKIE["GVEUserDefaults"] != "") {
foreach (explode("|", $_COOKIE["GVEUserDefaults"]) as $s) {
$arr = explode("=", $s);
if (count($arr) == 2) {
//$userDefaultVars[$arr[0]] = $arr[1];
$userDefaultVars[$arr[0]] = $arr[1];
}
}
}
Expand All @@ -179,12 +182,12 @@ public function getChartAction(ServerRequestInterface $request): ResponseInterfa
return $this->viewResponse($this->name() . '::page', [
'tree' => $tree,
'individual' => $individual,
'otype' => 'svg',
'disposition' => false,
'disposition' => true,
'title' => 'GVExport',
'vars' => $userDefaultVars,
'otypes' => $otypes,
'gve_config' => $GVE_CONFIG
'gve_config' => $GVE_CONFIG,
'module' => $this
]);
}

Expand All @@ -200,8 +203,8 @@ public function postChartAction(ServerRequestInterface $request): ResponseInterf
if (isset($_REQUEST["vars"]["debug"])) {
return $this->showDOTFile($individual->tree(), $individual);
} else {
$temp_dir = $this->saveDOTFile($individual->tree(), $individual, $_REQUEST['otype'] == 'svg' || $_REQUEST['otype'] == 'dot');
return $this->downloadFile($temp_dir, $_REQUEST['otype']);
$temp_dir = $this->saveDOTFile($individual->tree(), $individual, $_REQUEST["vars"]["otype"] == 'svg' || $_REQUEST["vars"]["otype"] == 'dot');
return $this->downloadFile($temp_dir, $_REQUEST["vars"]["otype"]);
}
}

Expand All @@ -220,14 +223,14 @@ function downloadFile($temp_dir, $file_type)
$filename = $temp_dir . "/" . $basename; // new
if (!empty($GVE_CONFIG["output"][$file_type]["exec"])) {
// Multi-platform operability (by Thomas Ledoux)
$old_dir = getcwd(); // save the current directory
chdir($temp_dir); // change to the right directory for generation
$shell_cmd = $GVE_CONFIG["output"][$file_type]["exec"];
exec($shell_cmd, $temp, $return_var); // new
chdir($old_dir); // back to the saved directory
//$old_dir = getcwd(); // save the current directory
//chdir($temp_dir); // change to the right directory for generation
$shell_cmd = str_replace($GVE_CONFIG["filename"], $temp_dir . "/" .$GVE_CONFIG["filename"], $GVE_CONFIG["output"][$file_type]["exec"]);
exec($shell_cmd." 2>&1", $stdout_output, $return_var); // new
//chdir($old_dir); // back to the saved directory
if ($return_var !== 0) // check correct output generation
{
die("Error (return code $return_var) executing command \"$shell_cmd\".<br>Check path and Graphviz functionality!"); // new
die("Error (return code $return_var) executing command \"$shell_cmd\" in \"".getcwd()."\".<br>Check path and Graphviz functionality!<br><pre>".(join($stdout_output, "\n"))."</pre>"); // new
}
}

Expand Down Expand Up @@ -311,34 +314,34 @@ function createGraphVizDump($tree, $individual, $temp_dir, $use_urls_for_media)
}

// INDI id
if (!empty($_REQUEST["other_pids"])) {
$dot->setSettings("indi", $individual->xref() .','. $_REQUEST["other_pids"]);
if (!empty($vars["other_pids"])) {
$dot->setSettings("indi", $individual->xref() .','. $vars["other_pids"]);
$dot->setSettings("multi_indi", TRUE);
} else {
$dot->setSettings("indi", $individual->xref());
$dot->setSettings("multi_indi", FALSE);
}
// Stop PIDs
if (!empty($_REQUEST["other_stop_pids"]) || !empty($_REQUEST["stop_pid"])) {
$dot->setSettings("stop_pids", $_REQUEST["stop_pid"] .','. $_REQUEST["other_stop_pids"]);
if (!empty($vars["other_stop_pids"]) || !empty($vars["stop_pid"])) {
$dot->setSettings("stop_pids", $vars["stop_pid"] .','. $vars["other_stop_pids"]);
$dot->setSettings("stop_proc", TRUE);
} else {
$dot->setSettings("stop_proc", FALSE);
}

if (isset($vars['indiance'])) {
if ($vars['indiance'] == 'ance') {
$dot->setIndiSearchMethod("ance");
}
if (isset($vars['indisibl'])) {
if ($vars['indisibl'] == 'sibl') {
$dot->setIndiSearchMethod("sibl");
}
if (isset($vars['indidesc'])) {
if ($vars['indidesc'] == 'desc') {
$dot->setIndiSearchMethod("desc");
}
if (isset($vars['indispou'])) {
if ($vars['indispou'] == 'spou') {
$dot->setIndiSearchMethod("spou");
}
if (isset($vars['indicous'])) {
if ($vars['indicous'] == 'cous') {
$dot->setIndiSearchMethod("cous");
}
if (isset($vars['ance_level'])) {
Expand All @@ -356,7 +359,7 @@ function createGraphVizDump($tree, $individual, $temp_dir, $use_urls_for_media)
$dot->setSettings("mclimit", $_REQUEST["vars"]["mclimit"]);
}

if (isset($vars['marknr'])) {
if ($vars['marknr'] == 'marknr') {
$dot->setSettings("mark_not_related", TRUE);
}

Expand All @@ -382,45 +385,45 @@ function createGraphVizDump($tree, $individual, $temp_dir, $use_urls_for_media)
}

// Which data to show
if (isset($vars['show_by'])) {
if ($vars['show_by'] == 'show_by') {
$dot->setSettings("show_by", TRUE);
}
if (isset($vars['bd_type'])) {
$dot->setSettings("bd_type", $vars['bd_type']);
}
if (isset($vars['show_bp'])) {
if ($vars['show_bp'] == 'show_bp') {
$dot->setSettings("show_bp", TRUE);
}
if (isset($vars['show_dy'])) {
if ($vars['show_dy'] == 'show_dy') {
$dot->setSettings("show_dy", TRUE);
}
if (isset($vars['dd_type'])) {
$dot->setSettings("dd_type", $vars['dd_type']);
}
if (isset($vars['show_dp'])) {
if ($vars['show_dp'] == 'show_dp') {
$dot->setSettings("show_dp", TRUE);
}
if (isset($vars['show_my'])) {
if ($vars['show_my'] == 'show_my') {
$dot->setSettings("show_my", TRUE);
}
if (isset($vars['md_type'])) {
$dot->setSettings("md_type", $vars['md_type']);
}
if (isset($vars['show_mp'])) {
if ($vars['show_mp'] == 'show_mp') {
$dot->setSettings("show_mp", TRUE);
}
if (isset($vars['show_pid'])) {
if ($vars['show_pid'] == 'show_pid') {
$dot->setSettings("show_pid", TRUE);
}
if (isset($vars['show_fid'])) {
if ($vars['show_fid'] == 'show_fid') {
$dot->setSettings("show_fid", TRUE);
}

if (isset($vars['show_url'])) {
if ($vars['show_url'] == 'show_url') {
$dot->setSettings("show_url", TRUE);
}

if (isset($vars['use_abbr_place'])) {
if ($vars['use_abbr_place'] == 'use_abbr_place') {
$dot->setSettings("use_abbr_place", TRUE);
}

Expand Down Expand Up @@ -448,7 +451,7 @@ function createGraphVizDump($tree, $individual, $temp_dir, $use_urls_for_media)
// Settings
if (!empty($vars['diagtype'])) {
$dot->setSettings("diagram_type", $vars['diagtype']);
$dot->setSettings("diagram_type_combined_with_photo", !empty($vars['with_photos']));
$dot->setSettings("diagram_type_combined_with_photo", $vars['with_photos'] == 'with_photos');
}
if (!empty($vars['no_fams'])) {
$dot->setSettings("no_fams", $vars['no_fams']);
Expand Down
91 changes: 91 additions & 0 deletions resources/javascript/full.renderer.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/javascript/panzoom.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 96b938b

Please sign in to comment.