Ejemplo n.º 1
0
 private static function findMovedNodes_findDeleted($aoDiffs, $oDiffAdded)
 {
     $oNodeRef = $oDiffAdded->getNode();
     foreach ($aoDiffs as $i => $oDiff) {
         if ($oDiff->getDiffType() == AnwDiff::TYPE_DIFFS) {
             $oDiffDeleted = self::findMovedNodes_findDeleted($oDiff->getAllDiffs(), $oDiffAdded);
             if ($oDiffDeleted) {
                 return $oDiffDeleted;
             }
         } else {
             if ($oDiff->getDiffType() == AnwDiff::TYPE_DELETED && !$oDiff->getMovedDiff() || $oDiff->getDiffType() == AnwDiff::TYPE_EDITED && !$oDiff->getDiffDeleted()->getMovedDiff()) {
                 if ($oDiff->getDiffType() == AnwDiff::TYPE_EDITED) {
                     $oDiff = $oDiff->getDiffDeleted();
                     //...
                     //AnwDebug::logdetail("findMovedNodes : !special EDITED !!!");
                 }
                 //AnwDebug::log("findMovedNodes : compare ".htmlentities(AnwUtils::xmlDumpNode($oNodeRef))." <---> ".htmlentities(AnwUtils::xmlDumpNode($oDiff->getNode())));
                 //warning: do the test hasSubMovedDiff() here, not before, as there could be a valid subdeleted node child of a parent deletednode having already another subdeletednode
                 if (!$oDiff->getMovedDiff() && !$oDiff->hasSubMovedDiff() && AnwXml::xmlAreSimilarNodesAllowTextLayoutChange($oDiff->getNode(), $oNodeRef)) {
                     return $oDiff;
                 } else {
                     if ($oDiff->hasSubDeletedDiffs()) {
                         //continue search into subdeleted diffs
                         $aoSubDiffs = $oDiff->getSubDeletedDiffs();
                         $oDiffDeleted = self::findMovedNodes_findDeleted($aoSubDiffs, $oDiffAdded);
                         if ($oDiffDeleted) {
                             return $oDiffDeleted;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }