. */ namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\FunctionsPrint; use Fisharebest\Webtrees\Report\ReportHtml; use Fisharebest\Webtrees\Report\ReportParserGenerate; use Fisharebest\Webtrees\Report\ReportParserSetup; use Fisharebest\Webtrees\Report\ReportPdf; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; define('WT_SCRIPT_NAME', 'reportengine.php'); require './includes/session.php'; $controller = new PageController; $famid = Filter::get('famid', WT_REGEX_XREF); $pid = Filter::get('pid', WT_REGEX_XREF); $action = Filter::get('action', 'choose|setup|run', 'choose'); $report = Filter::get('report'); $output = Filter::get('output', 'HTML|PDF', 'PDF'); $vars = Filter::get('vars'); $varnames = Filter::get('varnames'); $type = Filter::get('type'); if (!is_array($vars)) { $vars = array(); } if (!is_array($varnames)) { $varnames = array(); } if (!is_array($type)) { $type = array(); } //-- setup the arrays $newvars = array(); foreach ($vars as $name => $var) { $newvars[$name]['id'] = $var; if (!empty($type[$name])) { switch ($type[$name]) { case 'INDI': $record = Individual::getInstance($var, $WT_TREE); if ($record && $record->canShowName()) { $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE)); } else { $action = 'setup'; } break; case 'FAM': $record = Family::getInstance($var, $WT_TREE); if ($record && $record->canShowName()) { $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE)); } else { $action = 'setup'; } break; case 'SOUR': $record = Source::getInstance($var, $WT_TREE); if ($record && $record->canShowName()) { $newvars[$name]['gedcom'] = $record->privatizeGedcom(Auth::accessLevel($WT_TREE)); } else { $action = 'setup'; } break; default: break; } } } $vars = $newvars; foreach ($varnames as $name) { if (!isset($vars[$name])) { $vars[$name]['id'] = ''; } } $reports = array(); foreach (Module::getActiveReports($WT_TREE) as $rep) { $menu = $rep->getReportMenu(); if (preg_match('/report=(' . preg_quote(WT_MODULES_DIR, '/') . '[a-z0-9_]+\/[a-z0-9_]+\.xml)/', $menu->getLink(), $match)) { $reports[$match[1]] = $menu->getLabel(); } } if (!empty($report)) { if (!array_key_exists($report, $reports)) { $action = 'choose'; } } //-- choose a report to run switch ($action) { case 'choose': $controller ->setPageTitle(I18N::translate('Choose a report to run')) ->pageHeader(); echo '