public function propagateSINMoveDeleteUndelete($thisTitle, $tag, $oldTitleString, $newTitleString, &$propagatedData, &$text, &$textChanged) { $result = true; $newTitle = $newTitleString ? Title::newFromText($newTitleString, $tag == 'person' ? NS_PERSON : NS_FAMILY) : null; foreach ($propagatedData['images'] as $i) { $imageTitle = Title::newFromText((string) $i['filename'], NS_IMAGE); PropagationManager::addPropagatedAction($thisTitle, 'delimage', $imageTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addimage', $imageTitle); } // don't need to check propagated action before calling updateImage, because propagateSINMoveDeleteUndelete is never part of a loop $result = $result && $this->updateImage($thisTitle, $imageTitle, $tag, $oldTitleString, $newTitleString, $propagatedData, $text, $textChanged); } return $result; }
/** * Propagate move, delete, or undelete to other articles if necessary * * @param String $newTitleString null in case of delete; same as this title string in case of undelete * @param String $text text of article * @param bool $textChanged set to true if we change the text * @return bool true if success */ protected function propagateMoveDeleteUndelete($newTitleString, $newNs, &$text, &$textChanged) { global $wgESINHandler; $result = true; $newTitle = $newTitleString ? Title::newFromText($newTitleString, NS_PERSON) : null; // if we're undeleting, add additional families from WLH if ($this->titleString == $newTitleString) { $wlh = simplexml_load_string($this->getPageTextFromWLH(false)); // get text for all families $familyText = $this->getFamilyData($wlh->child_of_family, $this->xml->child_of_family, 'child_of_family') . $this->getFamilyData($wlh->spouse_of_family, $this->xml->spouse_of_family, 'spouse_of_family') . $wgESINHandler->getImageData($wlh->image, $this->xml->image); // update text: replace old family information with new $text = preg_replace("\$<((child|spouse)_of_family|image) [^>]*>\n\$", '', $text); $text = preg_replace('$</person>$', StructuredData::protectRegexReplace($familyText . '</person>'), $text, 1); $this->xml = StructuredData::getXml($this->tagName, $text); $textChanged = true; } // get data to propagate $propagatedData = Person::getPropagatedData($this->xml); foreach ($propagatedData['parentFamilies'] as $f) { $familyTitle = Title::newFromText((string) $f, NS_FAMILY); PropagationManager::addPropagatedAction($this->title, 'delchild_of_family', $familyTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addchild_of_family', $familyTitle); } // don't need to check propagated action before calling updateFamily, because propagateMoveDeleteUndelete is never part of a loop $result = $result && $this->updateFamily($familyTitle, 'child_of_family', 'child', $newTitleString, $propagatedData, $text, $textChanged); } $spouseTag = $propagatedData['gender'] == 'F' ? 'wife' : 'husband'; foreach ($propagatedData['spouseFamilies'] as $f) { $familyTitle = Title::newFromText((string) $f, NS_FAMILY); PropagationManager::addPropagatedAction($this->title, 'delspouse_of_family', $familyTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addspouse_of_family', $familyTitle); } // don't need to check propagated action before calling updateFamily, because propagateMoveDeleteUndelete is never part of a loop $result = $result && $this->updateFamily($familyTitle, 'spouse_of_family', $spouseTag, $newTitleString, $propagatedData, $text, $textChanged); } if (StructuredData::removeDuplicateLinks('child_of_family|spouse_of_family', $text)) { $textChanged = true; } $result = $result && $wgESINHandler->propagateSINMoveDeleteUndelete($this->title, 'person', $this->titleString, $newTitleString, $propagatedData, $text, $textChanged); if (!$result) { error_log("ERROR! Person move/delete/undelete not propagated: {$this->titleString} -> " . ($newTitleString ? $newTitleString : "[delete]") . "\n"); } return $result; }
/** * Propagate move, delete, or undelete to other articles if necessary * * @param String $newTitleString null in case of delete; same as this title string in case of undelete * @param String $text text of article * @param bool $textChanged set to true if we change the text * @return bool true if success */ protected function propagateMoveDeleteUndelete($newTitleString, $newNs, &$text, &$textChanged) { global $wgESINHandler; $result = true; $newTitle = $newTitleString ? Title::newFromText($newTitleString, NS_FAMILY) : null; // if we're undeleting, add additional people from WLH, getting updated person data if ($this->titleString == $newTitleString) { $wlh = simplexml_load_string($this->getPageTextFromWLH(false)); // get text for all people // TODO is propagateEditData called after Undelete? if so, then we could get updated person attributes there $personText = $this->getPersonData($wlh->husband, $this->xml->husband, 'husband') . $this->getPersonData($wlh->wife, $this->xml->wife, 'wife') . $this->getPersonData($wlh->child, $this->xml->child, 'child') . $wgESINHandler->getImageData($wlh->image, $this->xml->image); // update text: replace old family information with new $text = preg_replace("\$<(husband|wife|child|image) [^>]*>\n\$", '', $text); $text = preg_replace('$</family>$', StructuredData::protectRegexReplace($personText . '</family>'), $text, 1); $this->xml = StructuredData::getXml($this->tagName, $text); $textChanged = true; } // get data to propagate $propagatedData = Family::getPropagatedData($this->xml); foreach ($propagatedData['husbands'] as $p) { $personTitle = Title::newFromText((string) $p, NS_PERSON); PropagationManager::addPropagatedAction($this->title, 'delspouse', $personTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addspouse', $personTitle); } // don't need to check propagated action before calling updatePerson, because propagateMoveDeleteUndelete is never part of a loop $result = $result && $this->updatePerson($personTitle, 'husband', 'spouse_of_family', $newTitleString, $text, $textChanged); } foreach ($propagatedData['wives'] as $p) { $personTitle = Title::newFromText((string) $p, NS_PERSON); PropagationManager::addPropagatedAction($this->title, 'delspouse', $personTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addspouse', $personTitle); } // don't need to check propagated action before calling updatePerson, because propagateMoveDeleteUndelete is never part of a loop $result = $result && $this->updatePerson($personTitle, 'wife', 'spouse_of_family', $newTitleString, $text, $textChanged); } foreach ($propagatedData['children'] as $p) { $personTitle = Title::newFromText((string) $p, NS_PERSON); PropagationManager::addPropagatedAction($this->title, 'delchild', $personTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addchild', $personTitle); } // don't need to check propagated action before calling updatePerson, because propagateMoveDeleteUndelete is never part of a loop $result = $result && $this->updatePerson($personTitle, 'child', 'child_of_family', $newTitleString, $text, $textChanged); } if (StructuredData::removeDuplicateLinks('husband|wife|child', $text)) { $textChanged = true; } $result = $result && $wgESINHandler->propagateSINMoveDeleteUndelete($this->title, 'family', $this->titleString, $newTitleString, $propagatedData, $text, $textChanged); if (!$result) { error_log("ERROR! Family move/delete/undelete not propagated: {$this->titleString} -> " . ($newTitleString ? $newTitleString : "[delete]") . "\n"); } return $result; }
/** * Propagate move, delete, or undelete to other articles if necessary * * @param String $newTitleString null in case of delete; same as this title string in case of undelete * @param String $text text of article * @param bool $textChanged set to true if we change the text * @return bool true if success */ protected function propagateMoveDeleteUndelete($newTitleString, $newNs, &$text, &$textChanged) { $result = true; $newTitle = $newTitleString ? Title::newFromText($newTitleString, NS_IMAGE) : null; // if we're undeleting, add additional people from WLH, getting updated person data if ($this->titleString == $newTitleString) { list($people, $families) = SDImage::getPropagatedData($this->xml); $this->addWhatLinksHere($people, $families); $pageText = $this->getPageElements($people, 'person', NS_PERSON) . $this->getPageElements($families, 'family', NS_FAMILY); // update text: replace old family information with new $text = preg_replace("\$<(person|family) [^>]*>\n\$", '', $text); $text = preg_replace('$</' . $this->tagName . '>$', StructuredData::protectRegexReplace($pageText . '</' . $this->tagName . '>'), $text, 1); $this->xml = StructuredData::getXml($this->tagName, $text); $textChanged = true; } // get data to propagate list($people, $families) = SDImage::getPropagatedData($this->xml); foreach ($people as $p) { $linkTitle = Title::newFromText((string) $p, NS_PERSON); PropagationManager::addPropagatedAction($this->title, 'dellink', $linkTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addlink', $linkTitle); } // don't need to check propagated action before calling updatePage, because propagateMoveDeleteUndelete is never part of a loop $result = $result && $this->updatePage($linkTitle, 'person', $newTitleString, $text, $textChanged); } foreach ($families as $p) { $linkTitle = Title::newFromText((string) $p, NS_FAMILY); PropagationManager::addPropagatedAction($this->title, 'dellink', $linkTitle); if ($newTitle) { PropagationManager::addPropagatedAction($newTitle, 'addlink', $linkTitle); } // don't need to check propagated action before calling updatePage, because propagateMoveDeleteUndelete is never part of a loop $result = $result && $this->updatePage($linkTitle, 'family', $newTitleString, $text, $textChanged); } if (!$result) { error_log("ERROR! Family move/delete/undelete not propagated: {$this->titleString} -> " . ($newTitleString ? $newTitleString : "[delete]") . "\n"); } return $result; }