Ejemplo n.º 1
0
 function getNodeWithTranslateTags($bMarkAsUntranslated, $oContentField)
 {
     $oNode = null;
     if ($this->getMovedNode()) {
         //return moved node and don't touch it's translation flags
         //AnwDebug::log("getNodeWithTranslateTags : NO subdiffs/movedNode");
         $oNode = $this->getMovedNode();
     } else {
         $oNode = $this->oNode;
         //can't remember why did I put that here?
         //if (AnwXml::xmlIsTranslatableParent($oNode))
         //{
         //we don't need to check ancestors, it was already checked by applyDiffsToTranslation
         if ($bMarkAsUntranslated == true && !AnwXml::xmlIsTranslatableParent($oNode)) {
             //if we enter in a <fix> node, don't mark childs as untranslated !
             $bMarkAsUntranslated = false;
         }
         if ($this->hasSubAddedDiffs()) {
             //if a child of $node has been linked to a moved node, replace this subnode by the related moved node
             $i = 0;
             $oSubChilds = $oNode->childNodes;
             foreach ($this->aoSubAddedDiffs as $oSubDiffAdded) {
                 $oSubChild = $oSubChilds->item($i);
                 //AnwDebug::log("getNodeWithTranslateTags : subdiffs --->");
                 if ($oSubDiffAdded->getMovedNode()) {
                     //let's replace this child by the moved node
                     $oNewNode = $oSubDiffAdded->getMovedNode();
                     $oNewNode = $oNode->ownerDocument->importNode($oNewNode, true);
                     $oNode->replaceChild($oNewNode, $oSubChild);
                 } else {
                     //automatically replaced?
                     $oNewNode = $oSubDiffAdded->getNodeWithTranslateTags($bMarkAsUntranslated, $oContentField);
                 }
                 //AnwDebug::log("getNodeWithTranslateTags : <--- subdiffs");
                 $i++;
             }
         } else {
             //AnwDebug::log("getNodeWithTranslateTags : NO subdiffs/NO MovedNode -> addTranslateTags");
             if ($bMarkAsUntranslated) {
                 //$oNode = AnwXml::xmlAddTranslateTags($oNode);
                 $oNode = AnwXml::xmlSetContentFieldUntranslated($oNode, $oContentField);
             }
         }
         //}
     }
     //AnwDebug::log("getNodeWithTranslateTags result : ".htmlentities(AnwUtils::xmlDumpNode($oNode)));
     return $oNode;
 }