Exemplo n.º 1
0
 public function propagateSINEdit($thisTitle, $tag, $titleString, &$propagatedData, &$origPropagatedData, &$text, &$textChanged)
 {
     $result = true;
     $currFilenames = $this->getImageFilenames($propagatedData['images']);
     $origFilenames = $this->getImageFilenames($origPropagatedData['images']);
     $addImages = array_diff($currFilenames, $origFilenames);
     $delImages = array_diff($origFilenames, $currFilenames);
     $sameImages = array_intersect($currFilenames, $origFilenames);
     // remove backlink from deleted images
     $dummyPropagatedData = array();
     foreach ($delImages as $i) {
         $imageTitle = Title::newFromText($i, NS_IMAGE);
         PropagationManager::addPropagatedAction($thisTitle, 'delimage', $imageTitle);
         if (PropagationManager::isPropagatableAction($imageTitle, 'dellink', $thisTitle)) {
             $result = $result && $this->updateImage($thisTitle, $imageTitle, $tag, $titleString, null, $dummyPropagatedData, $text, $textChanged);
         }
     }
     // add backlink to new images
     foreach ($addImages as $i) {
         $imageTitle = Title::newFromText($i, NS_IMAGE);
         PropagationManager::addPropagatedAction($thisTitle, 'addimage', $imageTitle);
         if (PropagationManager::isPropagatableAction($imageTitle, 'addlink', $thisTitle)) {
             $result = $result && $this->updateImage($thisTitle, $imageTitle, $tag, $titleString, $titleString, $propagatedData, $text, $textChanged);
         }
     }
     // update data on same images
     if ($tag == 'person' && Person::propagatedFieldsChanged($propagatedData, $origPropagatedData)) {
         foreach ($sameImages as $i) {
             $imageTitle = Title::newFromText($i, NS_IMAGE);
             $result = $result && $this->updateImage($thisTitle, $imageTitle, $tag, $titleString, $titleString, $propagatedData, $text, $textChanged);
         }
     }
     return $result;
 }
Exemplo n.º 2
0
 private function propagateFamilyEditData($families, $origFamilies, $familyTag, $oldPersonTag, $newPersonTag, &$propagatedData, &$origPropagatedData, &$text, &$textChanged)
 {
     $result = true;
     $addFamilies = array_diff($families, $origFamilies);
     $delFamilies = array_diff($origFamilies, $families);
     $sameFamilies = array_intersect($families, $origFamilies);
     // remove from deleted families
     $dummyPropagatedData = Person::getPropagatedData(null);
     foreach ($delFamilies as $f) {
         $familyTitle = Title::newFromText($f, NS_FAMILY);
         PropagationManager::addPropagatedAction($this->title, 'del' . $familyTag, $familyTitle);
         if (PropagationManager::isPropagatableAction($familyTitle, 'del' . ($familyTag == 'child_of_family' ? 'child' : 'spouse'), $this->title)) {
             $result = $result && $this->updateFamily($familyTitle, $familyTag, $newPersonTag, null, $dummyPropagatedData, $text, $textChanged);
         }
     }
     // add to new families
     foreach ($addFamilies as $f) {
         $familyTitle = Title::newFromText($f, NS_FAMILY);
         PropagationManager::addPropagatedAction($this->title, 'add' . $familyTag, $familyTitle);
         if (PropagationManager::isPropagatableAction($familyTitle, 'add' . ($familyTag == 'child_of_family' ? 'child' : 'spouse'), $this->title)) {
             $result = $result && $this->updateFamily($familyTitle, $familyTag, $newPersonTag, $this->titleString, $propagatedData, $text, $textChanged);
         }
     }
     // update data on same families
     if ($oldPersonTag != $newPersonTag || Person::propagatedFieldsChanged($propagatedData, $origPropagatedData, $familyTag)) {
         foreach ($sameFamilies as $f) {
             $familyTitle = Title::newFromText($f, NS_FAMILY);
             // don't try to propagate changes to a family if this page was just added or deleted as a child of that family
             if (PropagationManager::isPropagatableAction($familyTitle, 'addchild', $this->title) && PropagationManager::isPropagatableAction($familyTitle, 'delchild', $this->title)) {
                 $result = $result && $this->updateFamily($familyTitle, $familyTag, $newPersonTag, $this->titleString, $propagatedData, $text, $textChanged);
             }
         }
     }
     return $result;
 }
Exemplo n.º 3
0
 private function propagateFamilyMemberEditData($members, $origMembers, $memberTag, $familyTag, &$text, &$textChanged)
 {
     $result = true;
     $addMembers = array_diff($members, $origMembers);
     $delMembers = array_diff($origMembers, $members);
     // remove from deleted members
     foreach ($delMembers as $p) {
         $personTitle = Title::newFromText($p, NS_PERSON);
         PropagationManager::addPropagatedAction($this->title, 'del' . ($memberTag == 'child' ? 'child' : 'spouse'), $personTitle);
         if (PropagationManager::isPropagatableAction($personTitle, 'del' . $familyTag, $this->title)) {
             $result = $result && $this->updatePerson($personTitle, $memberTag, $familyTag, null, $text, $textChanged);
         }
     }
     // add to new members
     foreach ($addMembers as $p) {
         $personTitle = Title::newFromText($p, NS_PERSON);
         PropagationManager::addPropagatedAction($this->title, 'add' . ($memberTag == 'child' ? 'child' : 'spouse'), $personTitle);
         if (PropagationManager::isPropagatableAction($personTitle, 'add' . $familyTag, $this->title)) {
             $result = $result && $this->updatePerson($personTitle, $memberTag, $familyTag, $this->titleString, $text, $textChanged);
         }
     }
     return $result;
 }
Exemplo n.º 4
0
 private function propagatePageEditData($members, $origMembers, $tag, $ns, &$text, &$textChanged)
 {
     $result = true;
     $addMembers = array_diff($members, $origMembers);
     $delMembers = array_diff($origMembers, $members);
     // remove from deleted members
     foreach ($delMembers as $p) {
         $linkTitle = Title::newFromText($p, $ns);
         PropagationManager::addPropagatedAction($this->title, 'dellink', $linkTitle);
         if (PropagationManager::isPropagatableAction($linkTitle, 'delimage', $this->title)) {
             $result = $result && $this->updatePage($linkTitle, $tag, null, $text, $textChanged);
         }
     }
     // add to new members
     foreach ($addMembers as $p) {
         $linkTitle = Title::newFromText($p, $ns);
         PropagationManager::addPropagatedAction($this->title, 'addlink', $linkTitle);
         if (PropagationManager::isPropagatableAction($linkTitle, 'addimage', $this->title)) {
             $result = $result && $this->updatePage($linkTitle, $tag, $this->titleString, $text, $textChanged);
         }
     }
     return $result;
 }