19 require_once(BASE.
"wcmf/3rdparty/PhpXmlDb/xmldb.php");
20 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceFacade.php");
21 require_once(BASE.
"wcmf/lib/core/class.WCMFException.php");
34 define(
"ROOT_NODE_NAME",
'XmlDatabase');
83 $old_error_handler = set_error_handler(
"XMLUtilErrorHandler");
92 set_error_handler($old_error_handler);
104 $old_error_handler = set_error_handler(
"XMLUtilErrorHandler");
113 set_error_handler($old_error_handler);
125 $nodePathArray = $this->XmlDb->evaluate($nodeQuery);
126 foreach ($nodePathArray as $nodePath)
127 array_push($oids, $this->
_GetOID($nodePath));
139 $old_error_handler = set_error_handler(
"XMLUtilErrorHandler");
149 $this->bModifyFlag =
true;
152 set_error_handler($old_error_handler);
163 $old_error_handler = set_error_handler(
"XMLUtilErrorHandler");
173 $this->bModifyFlag =
true;
176 set_error_handler($old_error_handler);
187 $old_error_handler = set_error_handler(
"XMLUtilErrorHandler");
197 $this->bModifyFlag =
true;
200 set_error_handler($old_error_handler);
213 $idTablePath =
'/*/'.$idTable;
215 $idPaths = $this->XmlDb->evaluate($idTablePath);
216 if (
sizeof($idPaths) == 0)
219 $rootPathArray = $this->XmlDb->evaluate(
"/*");
221 $idNode =
"<$idTable>$newID</$idTable>";
222 $this->XmlDb->appendChild($rootPathArray[0], $idNode);
227 $nextID = intval($this->XmlDb->getData($idTablePath));
229 $this->XmlDb->replaceData($idPaths[0], $newID);
252 $iResult = $this->XmlDb->getAttributes($nodePath);
254 $iResult[$elementName] = $this->XmlDb->getData($nodePath);
256 $parentPath = $this->XmlDb->getParentXPath($nodePath);
257 $iResult[
'ptype'] = array_pop($this->
_GetTypes($parentPath));
258 $parentAttributes = $this->XmlDb->getAttributes($parentPath);
280 $childrenPathArray = $this->XmlDb->evaluate($nodePath.
'/*');
281 foreach($childrenPathArray as $childPath)
284 $childType = array_pop($this->
_GetTypes($childPath));
285 $childAttributes = $this->XmlDb->getAttributes($childPath);
287 array_push($iResult, array(
'type' => $childType,
'id' => $childId));
304 if ($parentOID != null)
315 foreach($elementNames as $elementName)
320 $nodeString =
"<".$nodeDef[
'type'].
">".$nodeContent.
"</".$nodeDef[
'type'].
">";
323 $nodePath = $this->XmlDb->appendChild($parentPath, $nodeString);
326 $addAttributes = array();
329 foreach($attributeNames as $attributeName)
333 $this->XmlDb->setAttributes($nodePath, $addAttributes);
357 foreach($elementNames as $elementName)
361 $this->XmlDb->replaceData($nodePath, $nodeContent);
364 $addAttributes = array();
366 foreach($attributeNames as $attributeName)
370 $this->XmlDb->setAttributes($nodePath, $addAttributes);
395 if (!$this->_FunctionPermitted($action))
397 $this->_errorMsg =
'The function call is not allowed.';
400 if (!$this->bFileOpen)
402 $this->_errorMsg =
'The Open call did not open the file successfully.';
405 if (!$this->bWriteAccess)
407 $this->_errorMsg =
'To alter the database, you need to open it with write access.';
426 $nodeQuery =
"descendant::".$nodeDef[
'type'];
428 $nodeQuery =
"descendant::".$nodeDef[
'type'].
"[@".$this->_idName.
"='".$nodeDef[
'id'].
"']";
430 $nodePathArray = $this->XmlDb->evaluate($nodeQuery);
431 return $nodePathArray[0];
441 preg_match_all(
'/\/(.+)\[[0-9]+\]/U', $path, $matches);
452 $old_error_handler = set_error_handler(
"XMLUtilErrorHandler");
456 $type = array_pop($this->
_GetTypes($nodePath));
457 $nodeAttributes = $this->XmlDb->getAttributes($nodePath);
461 set_error_handler($old_error_handler);
GetNodeData($oid, $elementName)
_GetNodeData($oid, $elementName)
throwEx($message, $file='', $line='')
XMLUtil helps in using XML files as storage. XMLUtil is a subclass of CXmlDb that is customized for u...
_InsertNode(&$node, $parentOID)
decomposeOID($oid, $validate=true)
InsertNode(&$node, $parentOID)
XMLUtilErrorHandler($errno, $errstr, $errfile, $errline)