$var) { $newvars[$name]["id"] = $var; if (!empty($type[$name]) && (($type[$name]=="INDI") || ($type[$name]=="FAM") || ($type[$name]=="SOUR"))) { $gedcom = find_gedcom_record($var, WT_GED_ID); if (empty($gedcom)) { $action="setup"; } // If we wanted a FAM, and were given an INDI, look for a spouse if ($type[$name]=="FAM") { if (preg_match("/0 @.+@ INDI/", $gedcom)>0) { if (preg_match('/\n1 FAMS @(.+)@/', $gedcom, $match)) { $gedcom = find_family_record($match[1], WT_GED_ID); if (!empty($gedcom)) { $vars[$name] = $match[1]; } else { $action="setup"; } } } } $newvars[$name]["gedcom"] = $gedcom; } } $vars = $newvars; unset($newvars); foreach ($varnames as $indexval => $name) { if (!isset($vars[$name])) { $vars[$name]["id"] = ""; } } $reports=array(); foreach (WT_Module::getActiveReports() as $rep) { foreach ($rep->getReportMenus() as $menu) { if (preg_match('/report=('.preg_quote(WT_MODULES_DIR, '/').'[a-z0-9_]+\/[a-z0-9_]+\.xml)/', $menu->link, $match)) { $reports[$match[1]]=$menu->label; } } } if (!empty($report)) { if (!array_key_exists($report, $reports)) { $action = "choose"; } } //-- choose a report to run if ($action=="choose") { print_header(WT_I18N::translate('Choose a report to run')); echo "

\n
\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo "\n"; echo ""; echo "
", WT_I18N::translate('Choose a report to run'), "
", WT_I18N::translate('Select report'), "
\n

\n"; print_footer(); } //-- setup report to run elseif ($action=="setup") { print_header(WT_I18N::translate('Enter report values')); if ($ENABLE_AUTOCOMPLETE) { require_once WT_ROOT."js/autocomplete.js.htm"; } //-- make sure the report exists if (!file_exists($report)) { echo "", WT_I18N::translate('File not found.'), " ", $report, "\n"; } else { require_once WT_ROOT."includes/reportheader.php"; $report_array = array(); //-- start the sax parser $xml_parser = xml_parser_create(); //-- make sure everything is case sensitive xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); //-- set the main element handler functions xml_set_element_handler($xml_parser, "startElement", "endElement"); //-- set the character data handler xml_set_character_data_handler($xml_parser, "characterData"); //-- open the file if (!($fp = fopen($report, "r"))) { die("could not open XML input"); } //-- read the file and parse it 4kb at a time while (($data = fread($fp, 4096))) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf($data."\nXML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); // Paste Found ID from a pop-up window echo WT_JS_START; ?> var pastefield; function paste_id(value) { pastefield.value=value; } \n"; echo "\n"; echo "\n"; echo ""; echo ""; echo "\n"; $doctitle = trim($report_array["title"]); if (!isset($report_array["inputs"])) { $report_array["inputs"] = array(); } foreach ($report_array["inputs"] as $indexval => $input) { if ($input["name"] == "sources" || $input["name"] != "sources") { if ($input["name"] != "photos" || $MULTI_MEDIA) { // url forced default value ? if (isset($_REQUEST[$input["name"]])) { $input["default"]=$_REQUEST[$input["name"]]; // update doc title for bookmarking $doctitle .= " "; if (strpos($input["name"],"date2")!==false) { $doctitle .= "-"; } $doctitle .= $input["default"]; if (strpos($input["name"],"date1")!==false) { $doctitle .= "-"; } } echo "\n"; } } } ?>
", WT_I18N::translate('Enter report values'), "
", WT_I18N::translate('Selected Report'), "", $report_array["title"], "
\n"; echo "\n"; echo WT_I18N::translate($input["value"]), ""; if (!isset($input["type"])) { $input["type"] = "text"; } if (!isset($input["default"])) { $input["default"] = ""; } if (isset($input["lookup"])) { if ($input["lookup"]=="INDI") { if (!empty($pid)) { $input["default"] = $pid; } else { $input["default"] = check_rootid($input["default"]); } } if ($input["lookup"]=="FAM") { if (!empty($famid)) { $input["default"] = $famid; } else { // Default the FAM to the first spouse family of the default INDI $person=WT_Person::getInstance(check_rootid($input["default"])); if ($person) { $sfams=$person->getSpouseFamilies(); if ($sfams) { $input["default"] = reset($sfams)->getXref(); } } } } if ($input["lookup"]=="SOUR") { if (!empty($sid)) { $input["default"] = $sid; } } } if ($input["type"]=="text") { echo ""; } if ($input["type"]=="checkbox") { echo ""; } if ($input["type"]=="select") { echo "\n"; } if (isset($input["lookup"])) { echo ""; if ($input["lookup"]=="INDI") { print_findindi_link("pid",""); } elseif ($input["lookup"]=="PLAC") { print_findplace_link($input["name"]); } elseif ($input["lookup"]=="FAM") { print_findfamily_link("famid"); } elseif ($input["lookup"]=="SOUR") { print_findsource_link($input["name"]); } elseif ($input["lookup"]=="DATE") { $text = WT_I18N::translate('Select a date'); if (isset($WT_IMAGES["button_calendar"])) { $Link = "\"".$text."\""; } else { $Link = $text; } ?> " onclick="cal_toggleDate('div_', ''); return false;">
" style="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;">
" alt="PDF" title="PDF" /> " alt="HTML" title="HTML" />
/>
"; echo " "; echo " "; echo "


\n"; echo WT_JS_START, "document.title = \"", $doctitle, "\"", WT_JS_END; } print_footer(); } //-- run the report elseif ($action=="run") { if (strstr($report, "report_singlepage.xml")!==false) { $DEBUG=false; $pedigree=new ReportPedigree(); exit; } //-- load the report generator switch ($output) { case "HTML": header('Content-type: text/html; charset=UTF-8'); $wt_report = new WT_Report_HTML(); $ReportRoot = $wt_report; break; case "PDF": default: $wt_report = new WT_Report_PDF(); $ReportRoot = $wt_report; break; } $ascii_langs = array("en", "da", "nl", "fr", "he", "hu", "de", "nn", "es"); //-- setup special characters array to force embedded fonts $SpecialOrds = $RTLOrd; for ($i=195; $i<215; $i++) $SpecialOrds[] = $i; if (!isset($embed_fonts)) { if (in_array(WT_LOCALE, $ascii_langs)) { $embed_fonts = false; } else { $embed_fonts = true; } } /** * element handlers array * * Converts XML element names into functions * @global array $elementHandler */ $elementHandler = array(); $elementHandler["AgeAtDeath"]["start"] = "AgeAtDeathSHandler"; $elementHandler["br"]["start"] = "brSHandler"; $elementHandler["Body"]["start"] = "BodySHandler"; $elementHandler["Cell"]["end"] = "CellEHandler"; $elementHandler["Cell"]["start"] = "CellSHandler"; $elementHandler["Description"]["end"] = "DescriptionEHandler"; $elementHandler["Description"]["start"] = "DescriptionSHandler"; $elementHandler["Doc"]["end"] = "DocEHandler"; $elementHandler["Doc"]["start"] = "DocSHandler"; $elementHandler["Report"]["end"] = ""; $elementHandler["Report"]["start"] = ""; $elementHandler["Facts"]["end"] = "FactsEHandler"; $elementHandler["Facts"]["start"] = "FactsSHandler"; $elementHandler["Footer"]["start"] = "FooterSHandler"; $elementHandler["Footnote"]["end"] = "FootnoteEHandler"; $elementHandler["Footnote"]["start"] = "FootnoteSHandler"; $elementHandler["FootnoteTexts"]["start"] = "FootnoteTextsSHandler"; $elementHandler["Gedcom"]["end"] = "GedcomEHandler"; $elementHandler["Gedcom"]["start"] = "GedcomSHandler"; $elementHandler["GedcomValue"]["start"] = "GedcomValueSHandler"; $elementHandler["Generation"]["start"] = "GenerationSHandler"; $elementHandler["GetPersonName"]["start"] = "GetPersonNameSHandler"; $elementHandler["Header"]["start"] = "HeaderSHandler"; $elementHandler["HighlightedImage"]["start"] = "HighlightedImageSHandler"; $elementHandler["if"]["end"] = "ifEHandler"; $elementHandler["if"]["start"] = "ifSHandler"; $elementHandler["Image"]["start"] = "ImageSHandler"; $elementHandler["Input"]["end"] = ""; $elementHandler["Input"]["start"] = ""; $elementHandler["Line"]["start"] = "LineSHandler"; $elementHandler["List"]["end"] = "ListEHandler"; $elementHandler["List"]["start"] = "ListSHandler"; $elementHandler["ListTotal"]["start"] = "ListTotalSHandler"; $elementHandler["NewPage"]["start"] = "NewPageSHandler"; $elementHandler["Now"]["start"] = "NowSHandler"; $elementHandler["PageHeader"]["end"] = "PageHeaderEHandler"; $elementHandler["PageHeader"]["start"] = "PageHeaderSHandler"; $elementHandler["PageNum"]["start"] = "PageNumSHandler"; $elementHandler["Relatives"]["end"] = "RelativesEHandler"; $elementHandler["Relatives"]["start"] = "RelativesSHandler"; $elementHandler["RepeatTag"]["end"] = "RepeatTagEHandler"; $elementHandler["RepeatTag"]["start"] = "RepeatTagSHandler"; $elementHandler["SetVar"]["start"] = "SetVarSHandler"; $elementHandler["Style"]["start"] = "StyleSHandler"; $elementHandler["Text"]["end"] = "TextEHandler"; $elementHandler["Text"]["start"] = "TextSHandler"; $elementHandler["TextBox"]["end"] = "TextBoxEHandler"; $elementHandler["TextBox"]["start"] = "TextBoxSHandler"; $elementHandler["Title"]["end"] = "TitleEHandler"; $elementHandler["Title"]["start"] = "TitleSHandler"; $elementHandler["TotalPages"]["start"] = "TotalPagesSHandler"; $elementHandler["var"]["start"] = "varSHandler"; $elementHandler["varLetter"]["start"] = "varLetterSHandler"; $elementHandler["sp"]["start"] = "spSHandler"; /** * A new object of the currently used element class * * @global object $currentElement */ $currentElement = new Element(); /** * Should character data be printed * * This variable is turned on or off by the element handlers to tell whether the inner character * Data should be printed * @global boolean $printData */ $printData = false; /** * Title collector. Mark it if it has already been used * * @global boolean $reportTitle */ $reportTitle = false; /** * Description collector. Mark it if it has already been used * * @global boolean $reportDescription */ $reportDescription = false; /** * Print data stack * * As the XML is being processed there will be times when we need to turn on and off the * $printData variable as we encounter entinties in the XML. The stack allows us to * keep track of when to turn $printData on and off. * @global array $printDataStack */ $printDataStack = array(); /** * @todo add info * @global array $wt_reportStack */ $wt_reportStack = array(); /** * @todo add info * @global array $gedrecStack */ $gedrecStack = array(); /** * @todo add info * @global array $repeatsStack */ $repeatsStack = array(); /** * @todo add info * @global array $parserStack */ $parserStack = array(); /** * @todo add info * @global array $repeats */ $repeats = array(); /** * @todo add info * @global string $gedrec */ $gedrec = ""; /** * @todo add info * @global ???? $repeatBytes */ $repeatBytes = 0; /** * @todo add info * @global resource $parser */ $parser = ""; /** * @todo add info * @global int $processRepeats */ $processRepeats = 0; /** * @todo add info * @global ???? $processIfs */ $processIfs = 0; /** * @todo add info * @global ???? $processGedcoms */ $processGedcoms = 0; /** * Wether or not to print footnote * true = print, false = don't print */ $processFootnote = true; //-- start the sax parser $xml_parser = xml_parser_create(); //-- make sure everything is case sensitive xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); //-- set the main element handler functions xml_set_element_handler($xml_parser, "startElement", "endElement"); //-- set the character data handler xml_set_character_data_handler($xml_parser, "characterData"); //-- open the file if (!($fp = fopen($report, "r"))) { die("could not open XML input"); } //-- read the file and parse it 4kb at a time while (($data = fread($fp, 4096))) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf($data."\nXML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); }