示例#1
0
 /**
  * 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;
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * 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;
     $result = true;
     // get current info
     list($people, $families) = SDImage::getPropagatedData($this->xml);
     // get original info
     list($origPeople, $origFamilies) = array(array(), array());
     // 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, '<' . $this->tagName . '>') === false)) {
         // oldText contains MediaWiki:noarticletext if the article is being created
         // generate origPeople and origFamilies from What Links Here
         $this->addWhatLinksHere($origPeople, $origFamilies);
     } else {
         $origXml = StructuredData::getXml($this->tagName, $oldText);
         if (isset($origXml)) {
             list($origPeople, $origFamilies) = SDImage::getPropagatedData($origXml);
         }
     }
     $result = $result && $this->propagatePageEditData($people, $origPeople, 'person', NS_PERSON, $text, $textChanged);
     $result = $result && $this->propagatePageEditData($families, $origFamilies, 'family', NS_FAMILY, $text, $textChanged);
     if (StructuredData::removeDuplicateLinks('person|family', $text)) {
         $textChanged = true;
     }
     if (!$result) {
         error_log("ERROR! Image edit/rollback not propagated: {$this->titleString}\n");
     }
     return $result;
 }