depage-xmldb v2.3.1
XML documents in a relational database
Loading...
Searching...
No Matches
Document Class Reference

Detailed Description

Definition at line 15 of file Document.php.

Public Member Functions

 __construct ($xmlDb, $docId)
 Construct.
 getDocId ()
 Get Doc ID.
 getXml ($addIdAttribute=true)
 getXml
 getDocInfo ()
 gets info about a document by doc_id
 getDoctypeHandler ()
 getPermissions ()
 getNamespacesAndEntities ()
 gets the namespaces and the entities of the document
 getHistory ()
 getHistory
 isReleased ()
 isReleased
 isPublished ()
 isPublished
 getNodeId ($node)
 gets node db-id from db-id attribute
 getNodeDataId ($node)
 gets node db-dataid from db-dataid attribute
 getNodeNameById ($id)
 gets node_name by node db-id
 getParentIdById ($id)
 gets parent db-id by one of its child_nodes-id
 getIndexById ($id)
 gets the index of a node in the child list of its parent node (number of siblings before it); this is the index the targetIndex of addNode, moveNode and copyNode refers to, so
 getNodeIdsByXpath ($xpath)
 gets node_ids by xpath
 getSubdocByNodeId ($id, $addIdAttribute=true)
 gets an xml-document-object from specific db-id
 getSubdocByXpath ($xpath, $addIdAttribute=true)
 gets document by xpath.
 getAttribute ($nodeId, $attrName)
 gets attribute of node
 getAttributes ($nodeId)
 gets all attributes of a node by id
 buildNode ($name, $attributes)
 removeIdAttr ($node)
 recursively remove all db-id attributes from node
 clearDoc ()
 clean all nodes inside of document
 save (\DomDocument $xml)
 savePatch (\DomDocument $xml)
 saves a document reusing the parts of the tree that did not change; subtrees whose merkle subhash equals the subhash stored in the database are skipped without looking at their content, only changed nodes are updated and only added or removed subtrees are inserted or deleted.
 getLastPatchStats ()
 number of nodes that could be skipped/updated/deleted/inserted by the last savePatch()/saveNodePatch() call, ['fallback' => true] when it fell back to a full save()/saveNode(); the counts of a saveNodePatch() cover the patched subtree, not the whole document
 deleteNode ($nodeId)
 saveNode ($node)
 saves the subtree of a node; the subtree is deleted and written again, the parent and the position of the node are kept
 saveNodePatch ($node)
 saves a subtree of the document reusing the parts of the tree that did not change; works like savePatch() below $node: subtrees whose merkle subhash equals the subhash stored in the database are skipped without looking at their content, only changed nodes are updated and only added or removed subtrees are inserted or deleted.
 addNode (\DomNode $node, $targetId, $targetIndex=-1, $extras=[])
 adds a node to the child list of a node
 addNodeByName ($name, $targetId, $targetIndex, $extras=[])
 creates the node(s) the doctype handler defines for a name and adds them to the child list of a node
 replaceNode ($node, $idToReplace)
 replaces a node in database
 duplicateNode ($nodeId, $recursive=false)
 duplicates node in database, and inserts it in the next position
 moveNode ($nodeId, $targetId, $targetIndex)
 moves a node to a position in the child list of another node
 moveNodeIn ($nodeId, $targetId)
 moves node to another node (append child)
 moveNodeBefore ($nodeId, $targetId)
 moves node before another node (insert before)
 moveNodeAfter ($nodeId, $targetId)
 moves node after another node
 copyNode ($nodeId, $targetId, $targetIndex)
 copies a node to a position in the child list of another node
 copyNodeIn ($nodeId, $targetId)
 copy node to another node
 copyNodeBefore ($nodeId, $targetId)
 copy node before another node
 copyNodeAfter ($nodeId, $targetId)
 copy node after another node
 setAttribute ($nodeId, $attrName, $attrValue)
 sets attribute of node
 removeAttribute ($nodeId, $attrName)
 removes an attribute of a node
 hashDomNode ($node)
 hashDomNode
 beginTransactionAltering ()
 opens a transaction that changes the document
 beginTransactionNonAltering ()
 opens a transaction that only reads the document
 endTransaction ()
 closes the innermost open transaction level
 rollBackTransaction ()
 rolls back to the start of the innermost open transaction level, keeping the outer transaction levels (if any) intact
 clearDocInfoCache ()
 drops the memoized document info; has to be called when the document row or its history changes outside of the document's own transactions (like the history writes of DocumentHistory do)
 updateLastChange ($timestamp=null, $uid=null)
 set or updates the lastchange date and uid for the current document
 clearCache ()
 clears the node-cache

Static Public Member Functions

static parseAttributeString ($value)
 parses a stored attribute string into a name => value map; used by getAttributes and by the batch value resolution of the Indexer
static removeNodeAttr ($node, $dbNs, $attribute)
 recursively remove attributes from node

Data Fields

const POS_GAP = Helpers\Positions::POS_GAP
 distance between the sparse positions of sibling nodes; inserting a node between two neighbours takes the midpoint of their positions, the child list is rebalanced once the space between two neighbours drops below POS_MIN_GAP (the position management itself is done by Helpers\Positions)
const POS_MIN_GAP = Helpers\Positions::POS_MIN_GAP
const PATCH_MAX_CHANGE_RATIO = Patch\PatchPlanner::MAX_CHANGE_RATIO
 savePatch() falls back to a full save() and saveNodePatch() to a full saveNode() when more than this ratio of the nodes of the patched subtree changed; below that limit patching writes fewer rows than deleting and reinserting the tree would
Data Fields inherited from DocumentWriterHost
const SORTKEY_PAD = 20
 number of decimal digits used for the position part of the recursive CTE sortkey; limits the tree depth the recursive queries can order to strlen-limit / SORTKEY_PAD levels
const SAVE_BATCH_SIZE = 200
 maximum number of nodes written with a single statement; the write pipeline inserts nodes in batches of this size (the auto incremented ids of such a batch are read back with one select over the unique sibling index), the subhash refresh and the position rebalancing write their rows in batches of this size

Protected Member Functions

 positions ()
 the collaborator managing the sparse sibling positions of this document's nodes
 writer ()
 the collaborator running the write pipeline (DOM trees to rows) for this document; the transaction stays on the document and the doctype handler, the node lookups and the read path are reached through the Interfaces\DocumentWriterHost interface this class implements
 getNodeAttributeById ($id, $attribute)
 rebalancePositions ($parentId, $order=null)
 renumbers the children of a parent node to have an even distance of self::POS_GAP between their positions; called when the sparse positions of a child list are exhausted
 planPatch (\DomDocument $xml, $docInfo)
 compares the nodes of $xml with the nodes stored in the database and collects the minimal set of changes into a plan for applyPatch(); returns null when the document can not be patched (replaced root, missing database ids or too many changes)
 planNodePatch ($node, $checkRoot=false)
 compares the subtree rooted at $node with the nodes stored under the db:id its root element carries and collects the minimal set of changes into a plan for applyPatch(); returns null when the subtree can not be patched (replaced root, missing database id or too many changes)
 applyPatch ($plan)
 executes the change plan of planPatch(), all nodes that were not touched by the plan keep their database row (and with it position and subhash) untouched
 getNamespaceString ($xml)
 returns the namespace string that save() stores in the ns column of the document for the given xml document
 moveNodeChecked ($nodeId, $targetId, callable $getIndex)
 moves a node if the doctype handler allows it; the four moveNode* variants differ only in how they compute the index to move to, $getIndex resolves it inside the transaction
 copyNodeChecked ($nodeId, $targetId, callable $getIndex)
 copies a node if the doctype handler allows it; the four copyNode* variants differ only in how they compute the index to copy to, $getIndex resolves it inside the transaction
 getFreeNodeIds ($preference=[])
 gets unused db-node-ids for saving nodes; the result is kept in free_element_ids, where the write pipeline takes the ids for its nodes from
 addChildnodesByQuery ($query, $row, $parentNode)
 add child nodes of a node to DOMDocument
 getAppendIndex ($targetId)
 gets the index a child would get when it is appended to the child list of a node, i.e.
 getNamespace ($name)
 parseNodename
 extractNamespaces ($str)
 saveNodePrivate ($node)
 saveNodeIn ($node, $targetId, $targetIndex, $incChildren)
 saves a node into the child list of a target node
 getNodeArrayForSaving (&$nodeArray, $node, $parentIndex=null, $pos=0, $stripwhitespace=true)
 gets all nodes of a document in one array
 saveNodeToDb ($node, $id, $targetId, $targetIndex, $setPosition=false)
 saves a node to database
 inTransaction (callable $work, bool $altering=true)
 runs $work() inside a transaction and ends the transaction afterwards; rolls back to the transaction level (keeping outer transaction levels intact) and rethrows the exception when the work fails, so the transaction never stays open on an error
 refreshSubhashes ()
 recalculates the merkle style subhash of every node of the document; a subhash covers the stored type, name and value of the node plus the subhashes of all its children, so comparing one hash answers whether a whole subtree changed.

Protected Attributes

 $pdo
 $cache
 $dbNs
 $tablePrefix
 $tableDocs
 $tableXml
 $xmlDb
 $docId
 $idAttribute = 'id'
 $idDataAttribute = 'dataid'
 $freeElementIds = []
 $doctypeHandlers = []
 $entities = ''
 $namespaceString = ''
 $namespaces = []
 $lastchange = ''
 $lastchangeUid = ''
 $docInfo = null
 memoized result of getDocInfo(); every altering save updates the document row (and the history may change the release state), so the memo is dropped in updateLastChange, endTransaction and rollBackTransaction
 $docInfoLoaded = false
 $positions = null
 lazily built collaborators: the sparse position management, shared by the read (index), save, move and patch code paths, and the subhash updater
 $subhashUpdater = null
 $patchPlanner = null
 $patchApplier = null
 $writer = null
 $subhashesDirty = false
 set by updateLastChange, checked in endTransaction: the subhashes of the document are recalculated before the outermost altering transaction is committed
 $lastPatchStats = null
 statistics about the changes applied by the last savePatch() or saveNodePatch() call, null before the first incremental save

Constructor & Destructor Documentation

◆ __construct()

__construct ( $xmlDb,
$docId )
Parameters
$xmlDb
$docId

Definition at line 96 of file Document.php.

Member Function Documentation

◆ addChildnodesByQuery()

addChildnodesByQuery ( $query,
$row,
$parentNode )
protected
Parameters
$query(object) database query to get next row
$row(object) last result row for parent
$parentNode(object) DOMElement of parent node or empty DOMDocument
Returns
$row (object) values of last queried row

Definition at line 1391 of file Document.php.

◆ addNode()

addNode ( \DomNode $node,
$targetId,
$targetIndex = -1,
$extras = [] )
Parameters
$node(\DomNode) node to add
$targetId(int) db-id of the node to add the node to
$targetIndex(int) index the node gets in the child list of $targetId, -1 appends it
$extras(array) additional data for the doctype handler
Returns
(int|false) db-id of the added node, false if it was not added

Definition at line 949 of file Document.php.

◆ addNodeByName()

addNodeByName ( $name,
$targetId,
$targetIndex,
$extras = [] )
Parameters
$name(string) name of the node to create
$targetId(int) db-id of the node to add the node to
$targetIndex(int) index the first new node gets in the child list of $targetId, the other ones are added behind it, -1 appends all of them
$extras(array) additional data for the doctype handler
Returns
(int|false) db-id of the last node that was added, false if the nodes were not added

Definition at line 977 of file Document.php.

◆ applyPatch()

applyPatch ( $plan)
protected

Definition at line 828 of file Document.php.

◆ beginTransactionAltering()

beginTransactionAltering ( )

the outermost level starts a database transaction, the inner levels use savepoints

Returns
int the level of the transaction

Definition at line 1595 of file Document.php.

◆ beginTransactionNonAltering()

beginTransactionNonAltering ( )

the outermost level starts a database transaction, the inner levels use savepoints

Returns
int the level of the transaction

Definition at line 1607 of file Document.php.

◆ buildNode()

buildNode ( $name,
$attributes )
Parameters
$name
$attributes
Returns
\DOMElement

Definition at line 619 of file Document.php.

◆ clearCache()

clearCache ( )

the whole document namespace is dropped, not only the caches of the changed nodes: every cached subdocument embeds the document's db:lastchange attribute in its root element, so any change to the document makes the cached subdocuments of all its nodes stale

Definition at line 1737 of file Document.php.

◆ clearDoc()

clearDoc ( )
Returns
$doc (array)

Definition at line 649 of file Document.php.

◆ clearDocInfoCache()

clearDocInfoCache ( )

Definition at line 1661 of file Document.php.

◆ copyNode()

copyNode ( $nodeId,
$targetId,
$targetIndex )
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target (parent) node
$targetIndex(int) index the copy gets in the child list of $targetId, -1 appends it
Returns
(int|false) id of the copy, false if the node was not copied

Definition at line 1207 of file Document.php.

◆ copyNodeAfter()

copyNodeAfter ( $nodeId,
$targetId )
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target node

Definition at line 1245 of file Document.php.

◆ copyNodeBefore()

copyNodeBefore ( $nodeId,
$targetId )

(the node that is copied stays where it is, so the index of the copy is the plain index of the target node, it is not shifted by the move like it is in moveNodeBefore)

Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target node

Definition at line 1231 of file Document.php.

◆ copyNodeChecked()

copyNodeChecked ( $nodeId,
$targetId,
callable $getIndex )
protected
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of the target (parent) node
$getIndex(callable) resolves the index to copy to
Returns
(int|false) id of the copy, false if it was not made

Definition at line 1264 of file Document.php.

◆ copyNodeIn()

copyNodeIn ( $nodeId,
$targetId )
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target node

Definition at line 1217 of file Document.php.

◆ deleteNode()

deleteNode ( $nodeId)
Parameters
$nodeId
Returns
bool

Definition at line 860 of file Document.php.

◆ duplicateNode()

duplicateNode ( $nodeId,
$recursive = false )

@TODO behaviour should differ according to tree type - don't usually want to copy all sub nodes

Parameters
$nodeId(int) db-id of node
Returns
$success (bool)

Definition at line 1057 of file Document.php.

◆ endTransaction()

endTransaction ( )

the outermost level commits the database transaction, an inner level releases its savepoint; the hashes of the document are recalculated before the outermost level is committed

Returns
bool true if the outermost transaction has changed the document

Definition at line 1621 of file Document.php.

◆ extractNamespaces()

extractNamespaces ( $str)
protected

Definition at line 1494 of file Document.php.

◆ getAppendIndex()

getAppendIndex ( $targetId)
protected

the number of children it has now; this is the index -1 as targetIndex stands for

Parameters
$targetId(int) db-id of parent node
Returns
(int) index of an appended child

Definition at line 1473 of file Document.php.

◆ getAttribute()

getAttribute ( $nodeId,
$attrName )
Parameters
$nodeId(int) db-id of node
$attrName(string) name of attribute
Returns
$val (string) value

Definition at line 560 of file Document.php.

◆ getAttributes()

getAttributes ( $nodeId)
Parameters
$nodeId(int) db-id of node
Returns
$attributes (array) array of attributes

Definition at line 573 of file Document.php.

◆ getDocId()

getDocId ( )
Returns
int

Definition at line 117 of file Document.php.

◆ getDocInfo()

getDocInfo ( )

the result is memoized for the lifetime of this document instance and reloaded whenever the document or its history changed; the returned object is shared between the calls of one generation, so callers must not alter it

Returns
$info (object|false)

Definition at line 148 of file Document.php.

◆ getDoctypeHandler()

getDoctypeHandler ( )
Parameters
$docId
Returns
mixed

Implements DocumentWriterHost.

Definition at line 186 of file Document.php.

◆ getFreeNodeIds()

getFreeNodeIds ( $preference = [])
protected

Definition at line 1378 of file Document.php.

◆ getHistory()

getHistory ( )
Returns
history

Definition at line 248 of file Document.php.

◆ getIndexById()

getIndexById ( $id)

$doc->addNode($node, $parentId, $doc->getIndexById($siblingId));

adds a node in front of one of its siblings (moveNodeBefore() and moveNodeAfter() resolve that index for a node that already sits in the child list)

Parameters
$id(int) node db-id
Returns
$index (int) index in parents childlist, false if node doesn't exist.

Definition at line 404 of file Document.php.

◆ getLastPatchStats()

getLastPatchStats ( )

Definition at line 776 of file Document.php.

◆ getNamespace()

getNamespace ( $name)
protected
Parameters
mixed$name
Returns
void

Definition at line 1484 of file Document.php.

◆ getNamespacesAndEntities()

getNamespacesAndEntities ( )
Returns
object|false object with the properties "namespaces" and "entities" or false if the document does not exist

Definition at line 230 of file Document.php.

◆ getNamespaceString()

getNamespaceString ( $xml)
protected

Definition at line 840 of file Document.php.

◆ getNodeArrayForSaving()

getNodeArrayForSaving ( & $nodeArray,
$node,
$parentIndex = null,
$pos = 0,
$stripwhitespace = true )
protected
Parameters
$nodeArray(array) list of nodes to add current node to
$node(domxmlnode) current node
$parentIndex(int) index of parent node in created node list
$pos(int) position of current node
$stripwhitespace(bool) whether to strip whitespace from textnodes while saving

Definition at line 1535 of file Document.php.

◆ getNodeAttributeById()

getNodeAttributeById ( $id,
$attribute )
protected

Definition at line 353 of file Document.php.

◆ getNodeDataId()

getNodeDataId ( $node)
Parameters
$node(domxmlnode) node to get id from
Returns
$dbId (int)

Definition at line 346 of file Document.php.

◆ getNodeId()

getNodeId ( $node)
Parameters
$node(domxmlnode) node to get id from
Returns
$dbId (int)

Definition at line 331 of file Document.php.

◆ getNodeIdsByXpath()

getNodeIdsByXpath ( $xpath)
Attention
this supports only a small subset of xpath-queries. so recheck source before using.
Parameters
$this->docId(int) id of document
$xpath(string) xpath to target node
Returns
$nodeids (array) array of found node ids
Todo
implement full xpath specifications

Definition at line 432 of file Document.php.

◆ getNodeNameById()

getNodeNameById ( $id)
Parameters
$id(int) node db-id
Returns
$nodeName (string) name of node, false if node doesn't exist.

Definition at line 374 of file Document.php.

◆ getParentIdById()

getParentIdById ( $id)
Parameters
$id(int) node db-id
Returns
$parentId (id) db-id of parent node, false, if node doesn't exist.

Implements DocumentWriterHost.

Definition at line 385 of file Document.php.

◆ getPermissions()

getPermissions ( )
Returns
mixed

Definition at line 220 of file Document.php.

◆ getSubdocByNodeId()

getSubdocByNodeId ( $id,
$addIdAttribute = true )
Parameters
$id(int) db-id of node to get
$addIdAttribute(bool) true, if you want to add the db-id attributes to xml-definition, false to remove them.

Implements DocumentWriterHost.

Definition at line 451 of file Document.php.

◆ getSubdocByXpath()

getSubdocByXpath ( $xpath,
$addIdAttribute = true )

if xpath directs to more than one node, only the first node will be returned.

Parameters
$xpath(string) xpath to target node
$addIdAttribute(bool) whether to add db:id attribute or not
Returns
$doc (domxmlobject)

Definition at line 540 of file Document.php.

◆ getXml()

getXml ( $addIdAttribute = true)
Returns
string

Definition at line 126 of file Document.php.

◆ hashDomNode()

hashDomNode ( $node)
Parameters
mixed$node
Returns
void

Definition at line 1356 of file Document.php.

◆ inTransaction()

inTransaction ( callable $work,
bool $altering = true )
protected
Parameters
$work(callable)
$altering(bool) whether the work alters the document
Returns
mixed return value of $work

Definition at line 1567 of file Document.php.

◆ isPublished()

isPublished ( )
Parameters
mixed
Returns
void

Definition at line 317 of file Document.php.

◆ isReleased()

isReleased ( )
Parameters
mixed
Returns
void

Definition at line 301 of file Document.php.

◆ moveNode()

moveNode ( $nodeId,
$targetId,
$targetIndex )
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target (parent) node
$targetIndex(int) index the node gets in the child list of $targetId, -1 appends it
Returns
(int|false) id of the old parent node, false if the node was not moved

Definition at line 1092 of file Document.php.

◆ moveNodeAfter()

moveNodeAfter ( $nodeId,
$targetId )
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target node

Definition at line 1128 of file Document.php.

◆ moveNodeBefore()

moveNodeBefore ( $nodeId,
$targetId )
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target node

Definition at line 1112 of file Document.php.

◆ moveNodeChecked()

moveNodeChecked ( $nodeId,
$targetId,
callable $getIndex )
protected
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of the target (parent) node
$getIndex(callable) resolves the index to move to
Returns
(int|false) id of the old parent node, false if the node was not moved

Definition at line 1177 of file Document.php.

◆ moveNodeIn()

moveNodeIn ( $nodeId,
$targetId )
Parameters
$nodeId(int) db-id of node
$targetId(int) db-id of target node

Definition at line 1102 of file Document.php.

◆ parseAttributeString()

parseAttributeString ( $value)
static

Definition at line 597 of file Document.php.

◆ planNodePatch()

planNodePatch ( $node,
$checkRoot = false )
protected

$checkRoot rejects the plan (instead of renaming the row in place) when the root node is not compatible with the row its id points to, i.e. was replaced by a node of another type or name; saveNodePatch() uses this to fall back to a full saveNode()

Definition at line 810 of file Document.php.

◆ planPatch()

planPatch ( \DomDocument $xml,
$docInfo )
protected

Definition at line 786 of file Document.php.

◆ positions()

positions ( )
protected

Definition at line 260 of file Document.php.

◆ rebalancePositions()

rebalancePositions ( $parentId,
$order = null )
protected
Parameters
$parentId(int) db-id of parent node

Definition at line 415 of file Document.php.

◆ refreshSubhashes()

refreshSubhashes ( )
protected

subhashes do not include node ids, equal subtrees always have equal hashes.

nodes that already carry the hash they would be recalculated to are not touched; has to run inside a transaction (called by endTransaction before the commit).

Definition at line 1721 of file Document.php.

◆ removeAttribute()

removeAttribute ( $nodeId,
$attrName )
Parameters
$nodeId(int) db-id of node to set attribute
$attrName(string) name of attribute

Definition at line 1318 of file Document.php.

◆ removeIdAttr()

removeIdAttr ( $node)
Parameters
$node(domxmlnode) node to remove attribute from

Definition at line 639 of file Document.php.

◆ removeNodeAttr()

removeNodeAttr ( $node,
$dbNs,
$attribute )
static

Definition at line 1336 of file Document.php.

◆ replaceNode()

replaceNode ( $node,
$idToReplace )
Parameters
$node(domxmlnode) node to save
$idToReplace(int) db-id of node to be replaced
$this->docId(int) document db-id
Returns
$changedIds (array) list of db-ids that has been changed

Definition at line 1033 of file Document.php.

◆ rollBackTransaction()

rollBackTransaction ( )
Returns
bool true if a transaction level was rolled back, false if no transaction was open

Definition at line 1647 of file Document.php.

◆ save()

save ( \DomDocument $xml)
Parameters
$xml
Returns
mixed
Exceptions
xmlDbException

Definition at line 681 of file Document.php.

◆ saveNode()

saveNode ( $node)
See also
saveNodePatch() for incrementally saving a subtree
Parameters
$node(DomNode) subtree to save
Returns
$id (int) id of the root node of the subtree

Definition at line 886 of file Document.php.

◆ saveNodeIn()

saveNodeIn ( $node,
$targetId,
$targetIndex,
$incChildren )
protected
Parameters
$node(domxmlnode) node to save
$targetId(int) db-id of the node to save the node in
$targetIndex(int) index the node gets in the child list of $targetId, -1 appends it
$incChildren(bool) whether to save the child nodes too

Definition at line 1521 of file Document.php.

◆ saveNodePatch()

saveNodePatch ( $node)

$node is expected to carry the database id of the node it is saved over (like the result of getNode()); elements of the subtree without a db:id are matched against the leftover children of their parent by position.

a full saveNode() is done instead when the root node carries no database id, when it replaces the node its id points to or when more than PATCH_MAX_CHANGE_RATIO of the nodes of the subtree changed; parent and position of the subtree root are kept, as they are by saveNode().

Parameters
$node(DomNode) subtree to save
Returns
$id (int) id of the root node of the subtree

Definition at line 917 of file Document.php.

◆ saveNodePrivate()

saveNodePrivate ( $node)
protected

Definition at line 1508 of file Document.php.

◆ saveNodeToDb()

saveNodeToDb ( $node,
$id,
$targetId,
$targetIndex,
$setPosition = false )
protected
Parameters
$node(domxmlnode) node to save
$id(int) db-id to save node in
$targetId(int) db-id of parent node
$targetIndex(int) index the node gets in the child list of $targetId, -1 appends it
$setPosition(bool) whether to give the node a position in the child list of the target node
Returns
$id (int) db-id under which node has been saved

Definition at line 1552 of file Document.php.

◆ savePatch()

savePatch ( \DomDocument $xml)

the document is expected to contain the database ids of the current document (like the result of getXml()); elements without a db:id are matched against the leftover children of their parent by position.

a full save() is done instead when the root node was replaced, when the document carries no database ids or when more than PATCH_MAX_CHANGE_RATIO of the nodes changed.

See also
saveNodePatch() for incrementally saving a subtree
Parameters
$xml(DomDocument) xml document to save
Returns
$id (int) id of the document

Definition at line 733 of file Document.php.

◆ setAttribute()

setAttribute ( $nodeId,
$attrName,
$attrValue )
Parameters
$nodeId(int) db-id of node to set attribute
$attrName(string) name of attribute
$attrValue(string) new value of attribute

Definition at line 1288 of file Document.php.

◆ updateLastChange()

updateLastChange ( $timestamp = null,
$uid = null )
Parameters
$timestamp(int) optional timestamp, defaults to now
$uid(int) optional user id, defaults to current user, when user is set in xmlDb options

Implements DocumentWriterHost.

Definition at line 1672 of file Document.php.

◆ writer()

writer ( )
protected

Definition at line 279 of file Document.php.

Field Documentation

◆ $cache

$cache
protected

Definition at line 36 of file Document.php.

◆ $dbNs

$dbNs
protected

Definition at line 37 of file Document.php.

◆ $docId

$docId
protected

Definition at line 44 of file Document.php.

◆ $docInfo

$docInfo = null
protected

Definition at line 64 of file Document.php.

◆ $docInfoLoaded

$docInfoLoaded = false
protected

Definition at line 65 of file Document.php.

◆ $doctypeHandlers

$doctypeHandlers = []
protected

Definition at line 50 of file Document.php.

◆ $entities

$entities = ''
protected

Definition at line 52 of file Document.php.

◆ $freeElementIds

$freeElementIds = []
protected

Definition at line 49 of file Document.php.

◆ $idAttribute

$idAttribute = 'id'
protected

Definition at line 46 of file Document.php.

◆ $idDataAttribute

$idDataAttribute = 'dataid'
protected

Definition at line 47 of file Document.php.

◆ $lastchange

$lastchange = ''
protected

Definition at line 55 of file Document.php.

◆ $lastchangeUid

$lastchangeUid = ''
protected

Definition at line 56 of file Document.php.

◆ $lastPatchStats

$lastPatchStats = null
protected

Definition at line 89 of file Document.php.

◆ $namespaces

$namespaces = []
protected

Definition at line 54 of file Document.php.

◆ $namespaceString

$namespaceString = ''
protected

Definition at line 53 of file Document.php.

◆ $patchApplier

$patchApplier = null
protected

Definition at line 75 of file Document.php.

◆ $patchPlanner

$patchPlanner = null
protected

Definition at line 74 of file Document.php.

◆ $pdo

$pdo
protected

Definition at line 35 of file Document.php.

◆ $positions

$positions = null
protected

Definition at line 72 of file Document.php.

◆ $subhashesDirty

$subhashesDirty = false
protected

Definition at line 83 of file Document.php.

◆ $subhashUpdater

$subhashUpdater = null
protected

Definition at line 73 of file Document.php.

◆ $tableDocs

$tableDocs
protected

Definition at line 40 of file Document.php.

◆ $tablePrefix

$tablePrefix
protected

Definition at line 39 of file Document.php.

◆ $tableXml

$tableXml
protected

Definition at line 41 of file Document.php.

◆ $writer

$writer = null
protected

Definition at line 76 of file Document.php.

◆ $xmlDb

$xmlDb
protected

Definition at line 43 of file Document.php.

◆ PATCH_MAX_CHANGE_RATIO

const PATCH_MAX_CHANGE_RATIO = Patch\PatchPlanner::MAX_CHANGE_RATIO

Definition at line 33 of file Document.php.

◆ POS_GAP

const POS_GAP = Helpers\Positions::POS_GAP

Definition at line 24 of file Document.php.

◆ POS_MIN_GAP

const POS_MIN_GAP = Helpers\Positions::POS_MIN_GAP

Definition at line 25 of file Document.php.


The documentation for this class was generated from the following file: