本文整理汇总了PHP中Family::updatePersonLink方法的典型用法代码示例。如果您正苦于以下问题:PHP Family::updatePersonLink方法的具体用法?PHP Family::updatePersonLink怎么用?PHP Family::updatePersonLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Family
的用法示例。
在下文中一共展示了Family::updatePersonLink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: propagateEditData
/**
* Propagate data in xml property to other articles if necessary
* @param string $oldText contains text being replaced
* @param String $text which we never touch when propagating places
* @param bool $textChanged which we never touch when propagating places
* @return bool true if propagation was successful
*/
protected function propagateEditData($oldText, &$text, &$textChanged)
{
global $wrIsGedcomUpload, $wgESINHandler;
$result = true;
// cache new xml - it's used right away to generate family badges on the related person pages,
// if you don't cache it, the badges pick up the old html
$this->cachePageXml();
// update people that link to this family, because the family-badge contents could have changed
// TODO this could be made more efficient by only invalidating if names, birthdates, or deathdates have changed
$u = new HTMLCacheUpdate($this->title, 'pagelinks');
$u->doUpdate();
// get current info
$propagatedData = Family::getPropagatedData($this->xml);
$redirTitle = Title::newFromRedirect($text);
// get original info
$origPropagatedData = Family::getPropagatedData(null);
// don't bother construction page text from WLH in a gedcom upload because nothing will link to this new page
if (!@$wrIsGedcomUpload && (!$oldText || mb_strpos($oldText, '<family>') === false)) {
// oldText contains MediaWiki:noarticletext if the article is being created
// construct <family> text from What Links Here
$oldText = $this->getPageTextFromWLH(false);
}
$origXml = null;
if ($oldText) {
$origXml = StructuredData::getXml('family', $oldText);
if (isset($origXml)) {
$origPropagatedData = Family::getPropagatedData($origXml);
}
}
// TODO!!!
// Revert, Unmerge, and eventually Undo should be getting the current attrs for existing people from origPropagatedData
// and getting the current attrs and redirect-titles for newly-added people from the Person pages when adding the family title to them
// then unmerge wouldn't need to get them in unmerge, and revert wouldn't be broken, and undo won't break things.
// This duplicates the functionality found in fromEditFields, but it allows us to update the pages without going through fromEditFields
// and it doesn't require reading any pages that we weren't reading already.
// Also, instead of isMerging, if this Family page is on the propagation manager blacklist, then you can't trust the prior version
// and we should get the person attrs from the Person pages for _all_ family members.
// Finally, make sure that after redirects we don't have 2 links to the same Person (and also two links to the same Family on Person pages).
// ignore changes of the husband <-> wife role for the same person
$temp = array_diff($propagatedData['husbands'], $origPropagatedData['wives']);
$origPropagatedData['wives'] = array_diff($origPropagatedData['wives'], $propagatedData['husbands']);
$propagatedData['husbands'] = $temp;
$temp = array_diff($propagatedData['wives'], $origPropagatedData['husbands']);
$origPropagatedData['husbands'] = array_diff($origPropagatedData['husbands'], $propagatedData['wives']);
$propagatedData['wives'] = $temp;
$result = $result && $this->propagateFamilyMemberEditData($propagatedData['husbands'], $origPropagatedData['husbands'], 'husband', 'spouse_of_family', $text, $textChanged);
$result = $result && $this->propagateFamilyMemberEditData($propagatedData['wives'], $origPropagatedData['wives'], 'wife', 'spouse_of_family', $text, $textChanged);
$result = $result && $this->propagateFamilyMemberEditData($propagatedData['children'], $origPropagatedData['children'], 'child', 'child_of_family', $text, $textChanged);
if (StructuredData::removeDuplicateLinks('husband|wife|child', $text)) {
$textChanged = true;
}
$result = $result && $wgESINHandler->propagateSINEdit($this->title, 'family', $this->titleString, $propagatedData, $origPropagatedData, $text, $textChanged);
// ensure footer tag is still there (might have been removed by editing the last section)
if ($redirTitle == null && strpos($text, ESINHandler::ESIN_FOOTER_TAG) === false) {
if (strlen($text) > 0 && substr($text, strlen($text) - 1) != "\n") {
$text .= "\n";
}
$text .= ESINHandler::ESIN_FOOTER_TAG;
$textChanged = true;
}
// update watchlist summary if changed
$summary = Family::getSummary($this->xml, $this->title);
$origSummary = Family::getSummary($origXml, $this->title);
if ($summary != $origSummary) {
StructuredData::updateWatchlistSummary($this->title, $summary);
}
// if it's a redirect, add the people, families, and images that were on this page to the redirect target
// but don't bother updating the redir target during a merge
if ($redirTitle != null && PropagationManager::isPropagatablePage($redirTitle)) {
// get the text of the redir page
$article = StructuredData::getArticle($redirTitle, true);
if ($article) {
$content =& $article->fetchContent();
$updated = false;
// add husbands from this page to the redir page
foreach ($origPropagatedData['husbands'] as $p) {
// get propagated data for p
$pd = Person::getPropagatedData(StructuredData::getXmlForTitle('person', Title::newFromText($p, NS_PERSON)));
Family::updatePersonLink('husband', $p, $p, $pd, 'spouse_of_family', $content, $updated);
}
// add wives from this page to the redir page
foreach ($origPropagatedData['wives'] as $p) {
$pd = Person::getPropagatedData(StructuredData::getXmlForTitle('person', Title::newFromText($p, NS_PERSON)));
Family::updatePersonLink('wife', $p, $p, $pd, 'spouse_of_family', $content, $updated);
}
// add children from this page to the redir page
foreach ($origPropagatedData['children'] as $p) {
$pd = Person::getPropagatedData(StructuredData::getXmlForTitle('person', Title::newFromText($p, NS_PERSON)));
Family::updatePersonLink('child', $p, $p, $pd, 'child_of_family', $content, $updated);
}
// add images from this page to the redir page
foreach ($origPropagatedData['images'] as $i) {
ESINHandler::updateImageLink('family', $i['filename'], $i['filename'], $i['caption'], $content, $updated);
//.........这里部分代码省略.........
示例2: updateFamily
private function updateFamily($familyTitle, $familyTag, $newPersonTag, $newTitle, &$propagatedData, &$text, &$textChanged)
{
if (!PropagationManager::isPropagatablePage($familyTitle)) {
return true;
}
$result = true;
$article = StructuredData::getArticle($familyTitle, true);
if ($article) {
$content =& $article->fetchContent();
// fetches from master
$updated = false;
Family::updatePersonLink($newPersonTag, $this->titleString, $newTitle, $propagatedData, $familyTag, $content, $updated);
if ($updated) {
$result = $article->doEdit($content, self::PROPAGATE_MESSAGE . ' [[' . $this->title->getPrefixedText() . ']]', PROPAGATE_EDIT_FLAGS);
StructuredData::purgeTitle($familyTitle, +1);
// purge family with a fudge factor so person link will be blue
} else {
error_log("propagating person {$this->titleString} nothing changed in {$familyTitle->getPrefixedText()}");
}
// if we're not deleting this entry (newTitle is not empty), and the family article is a redirect (article title != familyTitle),
// we need to update the family page title in the person page text
if ($newTitle && $familyTitle->getText() != $article->getTitle()->getText()) {
$old = 'title="' . StructuredData::escapeXml($familyTitle->getText()) . '"';
$new = 'title="' . StructuredData::escapeXml($article->getTitle()->getText()) . '"';
$text = str_replace($old, $new, $text);
$textChanged = true;
}
}
return $result;
}