mxCodec

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.

Summary
mxCodecXML codec for PHP object graphs.
Variables
documentThe owner document of the codec.
objectsMaps from IDs to objects.
elementsMaps from IDs to elements.
encodeDefaultsSpecifies if default values should be encoded.
Functions
mxGraphViewHtmlReaderConstructs a new HTML graph view reader.
putObjectAssoiates the given object with the given ID.
getObjectReturns the decoded object for the element with the specified ID in document.
lookupHook for subclassers to implement a custom lookup mechanism for cell IDs.
getElementByIdReturns the element with the given ID from document.
addElementAdds the given element to elements if it has an ID.
getIdReturns the ID of the specified object.
referenceHook for subclassers to implement a custom method for retrieving IDs from objects.
encodeEncodes the specified object and returns the resulting XML node.
decodeDecodes the given XML node.
encodeCellEncoding 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.
decodeCellDecodes cells that have been encoded using inversion, ie.
insertIntoGraphInserts the given cell into its parent and terminal cells.
setAttributeSets the attribute on the specified node to value.

Variables

document

var $document

The owner document of the codec.

objects

var $objects

Maps from IDs to objects.

elements

var $elements

Maps from IDs to elements.

encodeDefaults

var $encodeDefaults

Specifies if default values should be encoded.  Default is false.

Functions

mxGraphViewHtmlReader

Constructs a new HTML graph view reader.

putObject

function putObject($id,
$object)

Assoiates the given object with the given ID.

Parameters

idID for the object to be associated with.
objObject to be associated with the ID.

getObject

function getObject($id)

Returns the decoded object for the element with the specified ID in document.  If the object is not known then lookup is used to find an object.  If no object is found, then the element with the respective ID from the document is parsed using decode.

lookup

function lookup($id)

Hook for subclassers to implement a custom lookup mechanism for cell IDs.  This implementation always returns null.

Parameters

idID of the object to be returned.

getElementById

function getElementById($id)

Returns the element with the given ID from document.

Parameters

idString that contains the ID.

addElement

function addElement($node)

Adds the given element to elements if it has an ID.

getId

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.

Parameters

objObject to return the ID for.

reference

function reference($obj)

Hook for subclassers to implement a custom method for retrieving IDs from objects.  This implementation always returns null.

Parameters

objObject whose ID should be returned.

encode

function encode($obj)

Encodes the specified object and returns the resulting XML node.

Parameters

objObject to be encoded.

decode

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.

Parameters

nodeXML node to be decoded.
intoOptional object to be decodec into.

encodeCell

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.

Parameters

cellmxCell to be encoded.
nodeParent XML node to add the encoded cell into.
includeChildrenOptional boolean indicating if the function should include all descendents.  Default is true.

decodeCell

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.

Parameters

nodeXML node that contains the cell data.
restoreStructuresOptional boolean indicating whether the graph structure should be restored by calling insert and insertEdge on the parent and terminals, respectively.  Default is true.

insertIntoGraph

function insertIntoGraph($cell)

Inserts the given cell into its parent and terminal cells.

setAttribute

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.

Parameters

nodeXML node to set the attribute for.
attributesAttributename to be set.
valueNew value of the attribute.
var $document
The owner document of the codec.
var $objects
Maps from IDs to objects.
var $elements
Maps from IDs to elements.
var $encodeDefaults
Specifies if default values should be encoded.
function putObject($id,
$object)
Assoiates the given object with the given ID.
function getObject($id)
Returns the decoded object for the element with the specified ID in document.
function lookup($id)
Hook for subclassers to implement a custom lookup mechanism for cell IDs.
function getElementById($id)
Returns the element with the given ID from document.
function addElement($node)
Adds the given element to elements if it has an ID.
function getId($obj)
Returns the ID of the specified object.
function reference($obj)
Hook for subclassers to implement a custom method for retrieving IDs from objects.
function encode($obj)
Encodes the specified object and returns the resulting XML node.
function decode($node,  
$into =  null)
Decodes the given XML node.
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.
function decodeCell($node,  
$restoreStructures =  true)
Decodes cells that have been encoded using inversion, ie.
function insertIntoGraph($cell)
Inserts the given cell into its parent and terminal cells.
function setAttribute($node,
$attribute,
$value)
Sets the attribute on the specified node to value.
Cells are the elements of the graph model.
function getId()
Returns the Id of the cell as a string.
static function create($cell)
Creates the cell path for the given cell.
Codec for mxGraphModels.
Close