public static function constructFamilyTitle($husbandGivenname, $husbandSurname, $wifeGivenname, $wifeSurname) { // construct name and append id $husbandName = StructuredData::constructName($husbandGivenname, $husbandSurname); $wifeName = StructuredData::constructName($wifeGivenname, $wifeSurname); $titleText = StructuredData::constructFamilyName($husbandName, $wifeName); if ($titleText) { return StructuredData::appendUniqueId(Title::newFromText($titleText, NS_FAMILY)); } else { return null; } }
/** * Create wiki text from xml property */ protected function toWikiText($parser) { global $wgESINHandler, $wgOut; $result = ''; if (isset($this->xml)) { // $result = '{| id="structuredData" border=1 class="floatright" cellpadding=4 cellspacing=0 width=30%'."\n"; // $result = "<div class=\"infobox-header\">Family Information</div>\n{|\n"; // $result = "{|\n"; // $hideTopBorder = false; // $result .= $this->addValuesToTableDL(null, $this->xml->husband, 'formatFamilyMember', array('Husband', @$this->xml->husband[0]), $hideTopBorder); // $hideTopBorder = $hideTopBorder || isset($this->xml->husband); // $result .= $this->addValuesToTableDL(null, $this->xml->wife, 'formatFamilyMember', array('Wife', @$this->xml->wife[0]), $hideTopBorder); // $hideTopBorder = $hideTopBorder || isset($this->xml->wife); // $result .= $wgESINHandler->showEventsFacts($this->xml, $hideTopBorder); // if (isset($this->xml->child)) { // $result .= "|-\n! Children\n"; // $result .= $this->addValuesToTableDL(null, $this->xml->child, 'formatFamilyMember', array(null, null), true); // } // $result .= $this->showWatchers(); // $result .= "|}\n"; // add infobox $image = $wgESINHandler->getPrimaryImage($this->xml); $numHusbands = $numWives = 0; foreach ($this->xml->husband as $spouse) { $numHusbands++; } foreach ($this->xml->wife as $spouse) { $numWives++; } if ($numHusbands < 1) { $numHusbands = 1; } if ($numWives < 1) { $numWives = 1; } $width = floor(100 / ($numHusbands + $numWives)); $spouses = ''; $firstChildClass = 'first-child'; $husbandName = $wifeName = ''; if (isset($this->xml->husband)) { foreach ($this->xml->husband as $spouse) { $spouses .= $this->getSpouseInfo($spouse, $width, $firstChildClass); $firstChildClass = ''; if (!$husbandName) { $husbandName = StructuredData::constructName(@$spouse['given'], @$spouse['surname']); } } } else { list($hg, $hs, $wg, $ws) = StructuredData::parseFamilyTitle($this->titleString); $spouses .= $this->getSpouseInfo(null, $width, $firstChildClass, $hg, $hs, true); $firstChildClass = ''; $husbandName = StructuredData::constructName($hg, $hs); } if ($image) { $spouses .= $this->getImageInfo($image, $firstChildClass); $firstChildClass = ''; } if (isset($this->xml->wife)) { foreach ($this->xml->wife as $spouse) { $spouses .= $this->getSpouseInfo($spouse, $width, $firstChildClass); $firstChildClass = ''; if (!$wifeName) { $wifeName = StructuredData::constructName(@$spouse['given'], @$spouse['surname']); } } } else { list($hg, $hs, $wg, $ws) = StructuredData::parseFamilyTitle($this->titleString); $spouses .= $this->getSpouseInfo(null, $width, $firstChildClass, $wg, $ws, false); $firstChildClass = ''; $wifeName = StructuredData::constructName($wg, $ws); } // check rename needed if (!$this->isGedcomPage && mb_strpos($this->titleString, 'Unknown') !== false) { list($hg, $hs, $wg, $ws) = StructuredData::parseFamilyTitle($this->titleString); $husbandTitle = StructuredData::constructName($hg, $hs); $wifeTitle = StructuredData::constructName($wg, $ws); if (Person::isRenameNeeded($husbandTitle, $husbandName) || Person::isRenameNeeded($wifeTitle, $wifeName)) { $correctTitle = StructuredData::constructFamilyName($husbandName, $wifeName); $t = Title::makeTitle(NS_SPECIAL, 'Movepage'); $url = $t->getLocalURL('target=' . $this->title->getPrefixedURL() . '&wpNewTitle=' . wfUrlencode("Family:{$correctTitle}") . '&wpReason=' . wfUrlencode('make page title agree with name')); $parser->mOutput->mSubtitle = 'This page can be <a href="' . $url . '">renamed</a>'; $wgOut->setSubtitle($parser->mOutput->mSubtitle); } } $marriageDate = $marriagePlace = ''; $marriageFound = false; if (isset($this->xml->event_fact)) { foreach ($this->xml->event_fact as $eventFact) { if ($eventFact['type'] == 'Marriage') { $marriageFound = true; $marriageDate = (string) $eventFact['date']; $marriagePlace = $this->getPlace($eventFact); } } } $marriage = ''; if ($marriageFound) { $marriage = "<div class=\"wr-infobox-event\">m. <span class=\"wr-infobox-date\">{$marriageDate}</span> <span class=\"wr-infobox-place\">{$marriagePlace}</span></div>"; } $result = <<<END <div class="wr-infobox wr-infobox-family"> <table class="wr-infobox-spouses"> <tr> {$spouses} </tr> </table> {$marriage} </div> <wr_ad></wr_ad> <div id="wr_familytreelink"><span class="wr-familytreelink-text">Family tree</span><span class="wr-familytreelink-arrow">▼</span></div> END; // add source citations, images, notes $result .= $wgESINHandler->addSourcesImagesNotes($this, $parser); // add categories $surnames = array(); foreach ($this->xml->husband as $husband) { $surnames[] = (string) $husband['surname']; } foreach ($this->xml->wife as $wife) { $surnames[] = (string) $wife['surname']; } $places = ESINHandler::getPlaces($this->xml); $result .= StructuredData::addCategories($surnames, $places, false); } return $result; }
private function getPageTitle() { $ns = (int) $this->xml['ns']; if ($ns == NS_PERSON) { $pageTitle = StructuredData::constructName($this->cleanName(@$this->xml->name['given'], true), $this->cleanName(@$this->xml->name['surname'], false)); } else { if ($ns == NS_FAMILY) { $husbandName = $wifeName = 'Unknown'; foreach ($this->xml->husband as $spouse) { $husbandName = StructuredData::constructName($this->cleanName(@$spouse['given'], true), $this->cleanName(@$spouse['surname'], false)); break; } foreach ($this->xml->wife as $spouse) { $wifeName = StructuredData::constructName($this->cleanName(@$spouse['given'], true), $this->cleanName(@$spouse['surname'], false)); break; } $pageTitle = StructuredData::constructFamilyName($husbandName, $wifeName); } else { $pageTitle = $this->xml['title']; } } return $pageTitle; }