XML codec for PHP object graphs. In order to resolve forward references when reading files the XML document that contains the data must be passed to the constructor.
mxCodec | XML codec for PHP object graphs. |
Variables | |
document | The owner document of the codec. |
objects | Maps from IDs to objects. |
elements | Maps from IDs to elements. |
encodeDefaults | Specifies if default values should be encoded. |
Functions | |
mxGraphViewHtmlReader | Constructs a new HTML graph view reader. |
putObject | Assoiates the given object with the given ID. |
getObject | Returns the decoded object for the element with the specified ID in document. |
lookup | Hook for subclassers to implement a custom lookup mechanism for cell IDs. |
getElementById | Returns the element with the given ID from document. |
addElement | Adds the given element to elements if it has an ID. |
getId | Returns the ID of the specified object. |
reference | Hook for subclassers to implement a custom method for retrieving IDs from objects. |
encode | Encodes the specified object and returns the resulting XML node. |
decode | Decodes the given XML node. |
encodeCell | Encoding of cell hierarchies is built-into the core, but is a higher-level function that needs to be explicitely used by the respective object encoders (eg. |
decodeCell | Decodes cells that have been encoded using inversion, ie. |
insertIntoGraph | Inserts the given cell into its parent and terminal cells. |
setAttribute | Sets the attribute on the specified node to value. |
function getElementById( $id )
Returns the element with the given ID from document.
id | String that contains the ID. |
function addElement( $node )
Adds the given element to elements if it has an ID.
function getId( $obj )
Returns the ID of the specified object. This implementation calls reference first and if that returns null handles the object as an mxCell by returning their IDs using mxCell.getId. If no ID exists for the given cell, then an on-the-fly ID is generated using mxCellPath.create.
obj | Object to return the ID for. |
function decode( $node, $into = null )
Decodes the given XML node. The optional “into” argument specifies an existing object to be used. If no object is given, then a new instance is created using the constructor from the codec.
The function returns the passed in object or the new instance if no object was given.
node | XML node to be decoded. |
into | Optional object to be decodec into. |
function encodeCell( $cell, $node, $includeChildren = true )
Encoding of cell hierarchies is built-into the core, but is a higher-level function that needs to be explicitely used by the respective object encoders (eg. mxModelCodec, <mxChildChangeCodec> and <mxRootChangeCodec>). This implementation writes the given cell and its children as a (flat) sequence into the given node. The children are not encoded if the optional includeChildren is false. The function is in charge of adding the result into the given node and has no return value.
cell | mxCell to be encoded. |
node | Parent XML node to add the encoded cell into. |
includeChildren | Optional boolean indicating if the function should include all descendents. Default is true. |
function decodeCell( $node, $restoreStructures = true )
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.
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 setAttribute( $node, $attribute, $value )
Sets the attribute on the specified node to value. This is a helper method that makes sure the attribute and value arguments are not null.
node | XML node to set the attribute for. |
attributes | Attributename to be set. |
value | New value of the attribute. |
The owner document of the codec.
var $document
Maps from IDs to objects.
var $objects
Maps from IDs to elements.
var $elements
Specifies if default values should be encoded.
var $encodeDefaults
Assoiates the given object with the given ID.
function putObject( $id, $object )
Returns the decoded object for the element with the specified ID in document.
function getObject( $id )
Hook for subclassers to implement a custom lookup mechanism for cell IDs.
function lookup( $id )
Returns the element with the given ID from document.
function getElementById( $id )
Adds the given element to elements if it has an ID.
function addElement( $node )
Returns the ID of the specified object.
function getId( $obj )
Hook for subclassers to implement a custom method for retrieving IDs from objects.
function reference( $obj )
Encodes the specified object and returns the resulting XML node.
function encode( $obj )
Decodes the given XML node.
function decode( $node, $into = null )
Encoding of cell hierarchies is built-into the core, but is a higher-level function that needs to be explicitely used by the respective object encoders (eg.
function encodeCell( $cell, $node, $includeChildren = true )
Decodes cells that have been encoded using inversion, ie.
function decodeCell( $node, $restoreStructures = true )
Inserts the given cell into its parent and terminal cells.
function insertIntoGraph( $cell )
Sets the attribute on the specified node to value.
function setAttribute( $node, $attribute, $value )
Returns the Id of the cell as a string.
function getId()
Creates the cell path for the given cell.
static function create( $cell )