示例#1
0
 /**
  * Function: decodeCell
  *
  * Decodes cells that have been encoded using inversion, ie.
  * where the user object is the enclosing node in the XML,
  * and restores the group and graph structure in the cells.
  * Returns a new <mxCell> instance that represents the
  * given node.
  *
  * Parameters:
  *
  * node - XML node that contains the cell data.
  * restoreStructures - Optional boolean indicating whether
  * the graph structure should be restored by calling insert
  * and insertEdge on the parent and terminals, respectively.
  * Default is true.
  */
 function decodeCell($node, $restoreStructures = true)
 {
     $cell = null;
     if (isset($node) && $node->nodeType == XML_ELEMENT_NODE) {
         // Tries to find a codec for the given node name. If that does
         // not return a codec then the node is the user object (an XML node
         // that contains the mxCell, aka inversion).
         $decoder = mxCodecRegistry::getCodec($node->nodeName);
         // Tries to find the codec for the cell inside the user object.
         // This assumes all node names inside the user object are either
         // not registered or they correspond to a class for cells.
         if (!isset($decoder)) {
             $child = $node->firstChild;
             while (isset($child) && !$decoder instanceof mxCellCodec) {
                 $decoder = mxCodecRegistry::getCodec($child->nodeName);
                 $child = $child->nextSibling;
             }
         }
         if (!$decoder instanceof mxCellCodec) {
             $decoder = mxCodecRegistry::getCodec("mxCell");
         }
         $cell = $decoder->decode($this, $node);
         if ($restoreStructures) {
             $this->insertIntoGraph($cell);
         }
     }
     return $cell;
 }