diff --git a/core/trunk/core/class/class_alert_engine.php b/core/trunk/core/class/class_alert_engine.php index c17e750accd9413a72295ddb72fbf7bc7ac4258b..74e7147e5ee91f13abec67b86e20159007fe55be 100644 --- a/core/trunk/core/class/class_alert_engine.php +++ b/core/trunk/core/class/class_alert_engine.php @@ -23,49 +23,6 @@ class alert_engine extends dbquery else parent::__construct($args[0]); } - /** - * Check on all open alerts insts if we can launch its - */ - public function check_all_alert_insts() - { - $tab_open_alerts_insts = array(); - $cpt_open_alerts_insts = 0; - $this->connect(); - $this->query("select * from ".$_SESSION['tablename']['al_alert_insts']." where status = 'WAIT' and alert_id in(select alert_id from ".$_SESSION['tablename']['al_alerts']." where alert_status = 'OPEN')order by alert_id"); - //$this->show(); - while($result = $this->fetch_object()) - { - $tab_open_alerts_insts[$cpt_open_alerts_insts]['alert_id'] = $result->alert_id; - $tab_open_alerts_insts[$cpt_open_alerts_insts]['sequence'] = $result->sequence; - $tab_open_alerts_insts[$cpt_open_alerts_insts]['due_date'] = $result->due_date; - $tab_open_alerts_insts[$cpt_open_alerts_insts]['status'] = $result->status; - $cpt_open_alerts_insts++; - } - //$this->show_array($tab_open_alerts_insts); - $this->check_launching_alerts($tab_open_alerts_insts); - //return $tab_open_alerts_insts; - } - - /** - * Check if we can launch alerts - */ - public function check_launching_alerts($tab_open_alerts_insts) - { - for($cpt_tab=0;$cpt_tab<count($tab_open_alerts_insts);$cpt_tab++) - { - echo "\r\nalert_id : ".$tab_open_alerts_insts[$cpt_tab]['alert_id']; - echo "\r\nsequence : ".$tab_open_alerts_insts[$cpt_tab]['sequence']; - echo "\r\ndue_date : ".$tab_open_alerts_insts[$cpt_tab]['due_date']; - echo "\r\nstatus : ".$tab_open_alerts_insts[$cpt_tab]['status']; - if($this->control_alert_due_date_lower_than_now($tab_open_alerts_insts[$cpt_tab]['due_date'])) - { - echo "\n\n************************************************\n"; - echo "\r\nalert_id : ".$tab_open_alerts_insts[$cpt_tab]['alert_id']." sequence : ".$tab_open_alerts_insts[$cpt_tab]['sequence']." due_date : ".$tab_open_alerts_insts[$cpt_tab]['due_date']." candidate to launch it!\r\n"; - $this->launch_alert($tab_open_alerts_insts[$cpt_tab]['alert_id'], $tab_open_alerts_insts[$cpt_tab]['sequence']); - } - } - } - /** * launch alert */ diff --git a/core/trunk/core/schema/Docserver.xsd b/core/trunk/core/schema/Docserver.xsd deleted file mode 100644 index b0cb4e87f44603ccd955f254a2ea57ef24d78229..0000000000000000000000000000000000000000 --- a/core/trunk/core/schema/Docserver.xsd +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:das="maarch:DataAccessService" - elementFormDefault="qualified"> - - <xsd:include schemaLocation='core/schema/datatypes.xsd' /> - <xsd:include schemaLocation='apps/maarch_entreprise/xml/datasources.xsd' /> - - <xsd:element name='Docserver' type='Docserver' - das:source='maarch_entreprise' - das:table='docservers' - das:key='docserver_id' - das:operations="CRUDL"> - </xsd:element> - - <xsd:complexType name='Docserver'> - <xsd:sequence> - <xsd:element name="device_label" type="varchar255" /> - <xsd:element name="path_template" type="varchar255" /> - </xsd:sequence> - <xsd:attribute name="docserver_id" type="varchar32" use="optional" default='1'/> - <xsd:attribute name="docserver_type_id" type="varchar32" use="required"/> - <xsd:attribute name="is_readonly" type="boolean" use="optional" default="N"/> - <xsd:attribute name="enabled" type="boolean" use="optional" default="Y"/> - <xsd:attribute name="coll_id" type="varchar32" use="required" /> - <xsd:attribute name="docserver_location_id" type="varchar32" use="required" /> - </xsd:complexType> - -</xsd:schema> \ No newline at end of file diff --git a/core/trunk/core/schema/datatypes.xsd b/core/trunk/core/schema/datatypes.xsd deleted file mode 100644 index 5d1aa696aa62c500a5017a13568e230daddd5e57..0000000000000000000000000000000000000000 --- a/core/trunk/core/schema/datatypes.xsd +++ /dev/null @@ -1,200 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:das="maarch:DataAccessService" - elementFormDefault="qualified" - > -<!-- ==================================================================== --> -<!-- ==== ==== --> -<!-- ==== DATA TYPES ==== --> -<!-- ==== ==== --> -<!-- ==================================================================== --> - - <!-- ==================================================================== --> - <!-- ==== CHARACTER DATA TYPES ==== --> - <!-- ==================================================================== --> - <!-- Character varying(10) --> - <xsd:simpleType name="varchar10" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(10)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="10"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character varying(20) --> - <xsd:simpleType name="varchar20" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(20)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="20"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character varying(32) --> - <xsd:simpleType name="varchar32" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(32)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="32"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character varying(50) --> - <xsd:simpleType name="varchar50" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(50)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="50"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character varying(64) --> - <xsd:simpleType name="varchar64" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(64)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="64"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character varying(100) --> - <xsd:simpleType name="varchar100" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(100)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="100"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character varying(128) --> - <xsd:simpleType name="varchar128" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(128)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="128"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character varying(255) --> - <xsd:simpleType name="varchar255" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(255)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="255"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Character text --> - <xsd:simpleType name="text" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>text</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:minLength value="0"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- Boolean --> - <xsd:simpleType name="boolean" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(1)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:enumeration value="Y"/> - <xsd:enumeration value="N"/> - </xsd:restriction> - </xsd:simpleType> - - - <!-- ==================================================================== --> - <!-- ==== NUMERIC DATA TYPES ==== --> - <!-- ==================================================================== --> - <xsd:simpleType name="bigint" das:enclosed='false'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>bigint</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:nonNegativeInteger"> - <xsd:minInclusive value="0"/> - <xsd:maxInclusive value="9223372036854775807"/> - </xsd:restriction> - </xsd:simpleType> - - <xsd:simpleType name="integer" das:enclosed='false'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>integer</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:nonNegativeInteger"> - <xsd:minInclusive value="0"/> - <xsd:maxInclusive value="2147483648"/> - </xsd:restriction> - </xsd:simpleType> - - <!-- ==================================================================== --> - <!-- ==== DATE AND TIME DATA TYPES ==== --> - <!-- ==================================================================== --> - <!-- Datetime --> - <xsd:simpleType name="datetime" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>timestamp</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:union memberTypes="xsd:date xsd:time xsd:string" das:baseType="xsd:string"/> - </xsd:simpleType> - - <!-- Datetime --> - <xsd:simpleType name="date" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>date</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:union memberTypes="xsd:date" das:baseType="xsd:string"/> - </xsd:simpleType> - - <xsd:simpleType name="fingerprint" das:enclosed='true'> - <xsd:annotation> - <xsd:appinfo> - <das:sqltype driver='postgresql'>character varying(64)</das:sqltype> - </xsd:appinfo> - </xsd:annotation> - <xsd:restriction base="xsd:string"> - <xsd:maxLength value="64"/> - <xsd:minLength value="1"/> - </xsd:restriction> - </xsd:simpleType> -</xsd:schema> diff --git a/core/trunk/core/tests/class/DataAccessService_Database.php b/core/trunk/core/tests/class/DataAccessService_Database.php deleted file mode 100644 index 6da9d2da790177dfd7124c99faf2e403ddd5d06c..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/DataAccessService_Database.php +++ /dev/null @@ -1,905 +0,0 @@ -<?php -class DataAccessService_Database - extends DataObjectController -{ - - private $databaseObject; - public $inTransaction; - private $queries = array(); - - public function connect($sourceNode) - { - $this->type = 'database'; - $params = array( - 'server' => $sourceNode->getAttribute('host'), - 'databasetype' => strtoupper($sourceNode->getAttribute('driver')), - 'user' => $sourceNode->getAttribute('user'), - 'pass' => $sourceNode->getAttribute('password'), - 'port' => $sourceNode->getAttribute('port'), - 'base' => $sourceNode->getAttribute('dbname') - ); - - $this->databaseObject = new dbquery($params); - $this->databaseObject->connect(); - } - - public function startTransaction() - { - $this->databaseObject->connect(); - if(!$this->inTransaction) { - //echo "<br/>DB Start transaction"; - $this->databaseObject->start_transaction(); - $this->inTransaction = true; - } - } - - public function commit() - { - if($this->inTransaction) { - //echo "<br/>DB Commit"; - $this->databaseObject->commit(); - $this->inTransaction = false; - } - } - - public function rollback() - { - if($this->inTransaction) { - //echo "<br/>DB Rollback"; - $this->databaseObject->rollback(); - $this->inTransaction = false; - } - } - - public function loadData( - $objectElement, - $parentObject, - $dataObjectDocument, - $key=false, - $filter=false, - $sortFields=false, - $sortOrder=false, - $limit=99999999, - $query=false - ) - { - - $objectName = $objectElement->getName(); - - $selectParts = array(); - - //********************************************************************* - // SELECT - //********************************************************************* - if(!$selectClause = - $this->getXRefs( - $objectElement, - 'selectClause' - ) - ) { - $selectClause = $this->createSelectExpression($objectElement); - $this->addXRefs( - $objectElement, - 'selectClause', - $selectClause - ); - } - $selectParts[] = "SELECT"; - $selectParts[] = $selectClause; - - //********************************************************************* - // FROM - //********************************************************************* - if(!$fromClause = - $this->getXRefs( - $objectElement, - 'fromClause' - ) - ) { - $fromClause = $this->createFromExpression($objectElement); - $this->addXRefs( - $objectElement, - 'fromClause', - $fromClause - ); - } - $selectParts[] = "FROM"; - $selectParts[] = $fromClause; - - //********************************************************************* - // WHERE - //********************************************************************* - $whereParts = array(); - - // WHERE KEY EXPRESSION - //********************************************************************* - if($key) { - if(!$keyExpression = - $this->getXRefs( - $objectElement, - 'keyExpression' - ) - ) { - $keyExpression = - $this->createKeyExpression($objectElement); - $this->addXRefs( - $objectElement, - 'keyExpression', - $keyExpression - ); - } - - $keyValues = explode(' ', $key); - foreach($keyValues as $i => $keyValue) { - $keyExpression = - str_replace('$'.$i, $keyValue, $keyExpression); - } - $whereParts[] = $keyExpression; - } - - // WHERE FILTER EXPRESSION - //********************************************************************* - if($filter) { - if(!$filterExpression = - $this->getXRefs( - $objectElement, - 'filterExpression' - ) - ) { - $filterExpression = - $this->createFilterExpression($objectElement); - $this->addXRefs( - $objectElement, - 'filterExpression', - $selectFilterExpression - ); - } - //echo "<br/>filter expression $filterExpression"; - $filterExpression = str_replace('$filter', $filter, $filterExpression); - $whereParts[] = '(' . $filterExpression .')'; - } - - // WHERE RELATION EXPRESSION - //********************************************************************* - if(is_object($parentObject) - && get_class($parentObject) != 'DataObjectDocument' - && $relation = $this->getRelation($objectElement, $parentObject) - ) { - //echo "<br/>Found relation between " . $objectElement->getName() . " and " . $parentObject->nodeName; - /*if(!$relationExpression = - $this->getXRefs($objectElement, 'relationExpression') - ) {*/ - $relationExpression = - $this->createRelationExpression( - $objectElement, - $relation - ); - /* $this->addXRefs( - $objectElement, - 'relationExpression', - $relationExpression - ); - }*/ - - if($relationExpression) { - preg_match_all('/\$\w+/', $relationExpression, $params); - foreach($params[0] as $paramName) { - $attrName = substr($paramName, 1); - //echo "<br/>Relation between " . $parentObject->getName() . " and " . $objectElement->getName() . " ==> key is $paramName value of $attrName is " . get_class($parentObject) . " ". $parentObject->$attrName; - $value = $parentObject->$attrName; - if(!$value || $value == '') $value = "99999999"; - $relationExpression = str_replace($paramName, $value, $relationExpression); - } - //echo "<br/>Relation expression is '$relationExpression'"; - $whereParts[] = $relationExpression; - } - } - - if($objectQuery = $this->getQuery($objectElement)) { - $whereParts[] = '(' . $objectQuery->nodeValue . ')'; - } - - if(count($whereParts) > 0) { - $selectParts[] = "WHERE"; - $selectParts[] = implode(' and ', $whereParts); - } - - //********************************************************************* - // SORT EXPRESSION - //********************************************************************* - if(!$sortExpression = - $this->getXRefs( - $objectElement, - 'sortExpression' - ) - ) { - $sortExpression = - $this->createSortExpression( - $objectElement, - $sortFields, - $sortOrder - ); - $this->addXRefs( - $objectElement, - 'sortExpression', - $sortExpression - ); - } - if($sortExpression) { - $selectParts[] = $sortExpression; - } - - - //********************************************************************* - // MERGE QUERY PARTS / EXECUTE - //********************************************************************* - $selectQuery = implode(' ', $selectParts); - - $this->queries[] = $selectQuery; - //echo "<pre>SELECT QUERY = " . $selectQuery . "</pre>"; - - try { - $this->databaseObject->connect(); - $result = $this->databaseObject->query( - $selectQuery, - $catchErrors=true - ); - } catch (Exception $e) { - throw $e; - } - if(!$result) { - $sqlError = $this->databaseObject->getError(); - throw new maarch\Exception($sqlError . ' [' .$selectQuery . ']'); - //$this->throwDatabaseException($selectQuery); - } else { - //********************************************************************* - // CREATE / FILL OBJECTS - //********************************************************************* - while($recordSet = $this->databaseObject->fetch_object()) { - $propertyCount = count($recordSet); - /*if($propertyCount === 1) { - $dataObject = - $dataObjectDocument->createElement( - $objectName, - $recordSet->$objectName - ); - } else {*/ - $dataObject = $this->createDataObject( - $objectElement, - $dataObjectDocument - ); - foreach($recordSet as $columnName => $columnValue) { - if($columnValue != '') { - $dataObject->$columnName = $columnValue; - } - } - //} - $parentObject[] = $dataObject; - $dataObject->logRead(); - } - } - } - - public function deleteData($objectElement, $dataObject) - { - $tableExpression = $this->createFromExpression($objectElement); - $deleteParts[] = "DELETE FROM"; - $deleteParts[] = $tableExpression; - - $keyExpression = $this->createUpdateKeyExpression($objectElement, $dataObject); - $deleteParts[] = "WHERE"; - $deleteParts[] = $keyExpression; - - $deleteQuery = implode(' ', $deleteParts); - - $this->queries[] = $deleteQuery; - //echo "<br/>DELETE QUERY = $deleteQuery"; - - try { - $this->databaseObject->connect(); - $result = $this->databaseObject->query( - $deleteQuery, - $catchErrors=true - ); - } catch (Exception $e) { - throw $e; - } - - if(!$result) { - $sqlError = $this->databaseObject->getError(); - throw new maarch\Exception($sqlError . ' [' .$deleteQuery . ']'); - //$this->throwDatabaseException($deleteQuery); - } else { - $keys = $this->databaseObject->fetch_object(); - return $keys; - } - - } - - public function insertData($objectElement, $dataObject) - { - // CREATE INSERT QUERY - $insertParts = array(); - - $tableExpression = $this->createFromExpression($objectElement); - $insertParts[] = "INSERT INTO"; - $insertParts[] = $tableExpression; - - $insertColumnsExpression = $this->createInsertColumnsExpression($objectElement, $dataObject); - $insertParts[] = "(" . $insertColumnsExpression . ")"; - - $insertValuesExpression = $this->createInsertValuesExpression($objectElement, $dataObject); - $insertParts[] = "VALUES"; - $insertParts[] = "(" . $insertValuesExpression . ")"; - - $insertParts[] = "RETURNING"; - $insertParts[] = $this->createReturnKeyExpression($objectElement); - - $insertQuery = implode(' ', $insertParts); - - $this->queries[] = $insertQuery; - - //echo "<br/>INSERT QUERY = $insertQuery"; - - try { - $this->databaseObject->connect(); - $result = $this->databaseObject->query( - $insertQuery, - $catchErrors=true - ); - } catch (Exception $e) { - throw $e; - } - if(!$result) { - $sqlError = $this->databaseObject->getError(); - throw new maarch\Exception($sqlError . ' [' .$insertQuery . ']'); - - //$this->throwDatabaseException($insertQuery); - } else { - $keys = $this->databaseObject->fetch_object(); - return $keys; - } - } - - public function updateData($objectElement, $dataObject) - { - global $argv; - $updateParts = array(); - - $tableExpression = $this->createFromExpression($objectElement); - $updateParts[] = "UPDATE"; - $updateParts[] = $tableExpression; - - // COLUMNS / VALUES - $updateExpression = $this->createUpdateExpression($objectElement, $dataObject); - $updateParts[] = "SET"; - $updateParts[] = $updateExpression; - - // Key - $keyExpression = $this->createUpdateKeyExpression($objectElement, $dataObject); - $updateParts[] = "WHERE"; - $updateParts[] = $keyExpression; - - $updateParts[] = "RETURNING"; - $updateParts[] = $this->createReturnKeyExpression($objectElement); - - $updateQuery = implode(' ', $updateParts); - - $this->queries[] = $updateQuery; - //echo "<pre>UPDATE QUERY = " . $updateQuery . "</pre>"; - - try { - if (isset($argv) && count($argv) > 0) { - //no new database connection, maybe in transaction - } else { - $this->databaseObject->connect(); - } - $result = $this->databaseObject->query( - $updateQuery, - $catchErrors=true - ); - } catch (Exception $e) { - throw $e; - } - - if(!$result) { - $sqlError = $this->databaseObject->getError(); - throw new maarch\Exception($sqlError . ' [' .$updateQuery . ']'); - //$this->throwDatabaseException($updateQuery); - } else { - $keys = $this->databaseObject->fetch_object(); - return $keys; - } - - } - - public function lastQuery() - { - return end($this->queries); - } - //************************************************************************* - // PRIVATE QUERY CREATION FUNCTIONS - //************************************************************************* - - // SELECT CLAUSE - //************************************************************************* - private function createSelectExpression($objectElement) - { - $selectColumns = array(); - $typeContents = $this->getObjectContents($objectElement); - $l = count($typeContents); - for($i=0; $i<$l; $i++) { - $contentNode = $typeContents[$i]; - $required = $contentNode->isRequired(); - $contentNode = $this->getRefNode($contentNode); - - if($contentNode->hasDatasource()) continue; - - $selectColumn = null; - // Column name - $columnName = $contentNode->getColumn(); - if($contentNode->hasAttribute('fixed')) { - // Value enclosure - $contentType = $this->getType($contentNode); - $enclosure = $contentType->getEnclosure(); - $selectColumn = - $enclosure - . $this->databaseObject->escape_string( - $contentNode->getAttribute('fixed')) - . $enclosure; - } elseif($contentNode->hasAttribute('default')) { - $contentType = $this->getType($contentNode); - $enclosure = $contentType->getEnclosure(); - $selectColumn = - "COALESCE (" - . $columnName - . ", " - . $enclosure - . $this->databaseObject->escape_string( - $contentNode->getAttribute('default')) - . $enclosure - . ")"; - } elseif(!$columnName) { - $selectColumn = "*"; - } else { - $selectColumn = $columnName; - } - - // Column alias - switch($contentNode->tagName) { - case 'xsd:attribute': - case 'xsd:element': - $selectColumn .= ' AS "' . $contentNode->getName() . '"'; - break; - case 'xsd:any': - break; - } - - $selectColumns[] = $selectColumn; - } - $selectClause = implode(', ', $selectColumns); - return $selectClause; - } - - // FROM CLAUSE - //************************************************************************* - private function createFromExpression($objectElement) - { - $tableExpressionParts = array(); - $tableExpressionParts[] = $objectElement->getTable(); - // If view - if($view = $this->getView($objectElement)) { - $joinExpressions = array(); - $joins = $this->query('./das:join', $view); - // Loop on joins - $l = $joins->length; - for($i=0; $i<$l; $i++) { - $join = $joins->item($i); - - $joinExpressionParts = array(); - - // joint tables - $parentElement = - $this->getElementByName($join->getAttribute('parent')); - $parentTable = $parentElement->getTable(); - $childElement = - $this->getElementByName($join->getAttribute('child')); - $childTable = $childElement->getTable(); - - // join mode - if($join->hasAttribute('join-mode')) { - $joinExpressionParts[] = $join->getAttribute('join-mode'); - } - $joinExpressionParts[] = 'JOIN'; - $joinExpressionParts[] = $childTable; - $joinExpressionParts[] = 'ON'; - - // Loop on join keys - $joinKeyColumns = array(); - $joinKeys = $this->query('./das:foreign-key', $join); - $m = $joinKeys->length; - for($j=0; $j<$m; $j++) { - $joinKey = $joinKeys->item($j); - $childKeyName = $joinKey->getAttribute('child-key'); - $childKeyProperty = - $this->getContentByName( - $childElement, - $childKeyName - ); - $childKeyColumn = $childKeyProperty->getColumn(); - if(strpos($childKeyColumn, ".")) $childKeyExpression = $childKeyColumn; - else $childKeyExpression = $childTable . "." . $childKeyColumn; - - $parentKeyName = $joinKey->getAttribute('parent-key'); - $parentKeyProperty = - $this->getContentByName( - $parentElement, - $parentKeyName - ); - $parentKeyColumn = $parentKeyProperty->getColumn(); - if(strpos($parentKeyColumn, ".")) $parentKeyExpression = $parentKeyColumn; - else $parentKeyExpression = $parentTable . "." . $parentKeyColumn; - - $joinKeyColumns[] = - $parentKeyExpression - . " = " - . $childKeyExpression; - } // End loop on join keys - $joinExpressionParts[] = implode(' and ', $joinKeyColumns); - $joinExpressions[] = implode(' ', $joinExpressionParts); - } // End loop on joins - $tableExpressionParts[] = implode(' ', $joinExpressions); - } // End if view - return implode(' ', $tableExpressionParts); - } - - // SELECT KEY - //************************************************************************* - private function createKeyExpression($objectElement) - { - $key = $objectElement->getAttribute('das:key'); - if(!$key) return false; - $keyFields = explode(' ', $key); - $l = count($keyFields); - $keyColumns = array(); - for($i=0; $i<$l; $i++) { - $keyField = $keyFields[$i]; - $keyNode = - $this->getContentByName( - $objectElement, - $keyField - ); - $keyRefNode = $this->getRefNode($keyNode); - $keyColumn = $keyRefNode->getColumn(); - $keyType = $this->getType($keyRefNode); - $enclosure = $keyType->getEnclosure(); - $keyColumns[] = - $keyColumn - . " = " - . $enclosure - . '$' . $i - . $enclosure; - } - return implode(' and ', $keyColumns); - } - - // FILTER - //************************************************************************* - private function createFilterExpression($objectElement) - { - $filterExpressions = array(); - if($filter = $objectElement->getFilter()) { - $filterFields = explode(' ', $filter); - $l = count($filterFields); - for($i=0; $i<$l; $i++) { - $filterName = $filterFields[$i]; - $filterProperty = - $this->getContentByName( - $objectElement, - $filterName - ); - $filterColumn = $filterProperty->getColumn(); - $filterType = $this->getType($filterProperty); - $enclosure = $filterType->getEnclosure(); - if($enclosure) { - $filterExpressions[] = - "UPPER(". $filterColumn . ") " - . "LIKE UPPER(" - . $enclosure - . '$filter' - . $enclosure - . ")"; - } else { - $filterExpressions[] = - $filterColumn - . ' = $filter '; - } - } - } - return implode(' or ', $filterExpressions); - } - - // ORDER - //************************************************************************* - private function createSortExpression( - $objectElement, - $sortFields=false, - $sortOrder=false - ) { - $sortExpressionParts = array(); - $sortColumns = array(); - - // No sort fields given, sort on key - if(!$sortFields) { - $sortFieldsArray = array(); - $key = $objectElement->getAttribute('das:key'); - if($key) {$keyFields = explode(' ', $key); - $l = count($keyFields); - for($i=0; $i<$l; $i++) { - $keyField = $keyFields[$i]; - $sortFieldsArray[] = $keyField; - } - } - } else { - $sortFieldsArray = explode(' ', $sortFields); - } - - for($i=0; $i<count($sortFieldsArray); $i++) { - $sortField = $sortFieldsArray[$i]; - $sortNode = - $this->getContentByName( - $objectElement, - $sortField - ); - $sortRefNode = $this->getRefNode($sortNode); - $sortColumn = $sortRefNode->getColumn(); - $sortColumns[] = $sortColumn; - } - - if(count($sortColumns) > 0) { - switch($sortOrder) { - case 'descending' : - $sortOrder = 'DESC'; - break; - case 'ascending' : - default : - $sortOrder = 'ASC'; - } - $sortExpressionParts[] = "ORDER BY"; - $sortExpressionParts[] = implode(', ', $sortColumns); - $sortExpressionParts[] = $sortOrder; - - } - return implode(' ', $sortExpressionParts); - } - - // RELATION - //************************************************************************* - private function createRelationExpression($objectElement, $relation) - { - $childTable = $objectElement->getTable(); - - $fkeys = $this->query('./das:foreign-key', $relation); - $fkeysLength = $fkeys->length; - $relationKeys = array(); - for($i=0; $i<$fkeysLength; $i++) { - $fkey = $fkeys->item($i); - $childKeyName = $fkey->getAttribute('child-key'); - $childKeyElement = - $this->getContentByName( - $objectElement, - $childKeyName - ); - $childKeyColumn = $childKeyElement->getColumn(); - $childKeyType = $this->getType($childKeyElement); - $enclosure = $childKeyType->getEnclosure(); - - if(strpos($childKeyColumn, ".")) $childKeyExpression = $childKeyColumn; - else $childKeyExpression = $childTable . "." . $childKeyColumn; - - $parentKeyName = $fkey->getAttribute('parent-key'); - $relationKeys[] = - $childKeyExpression - . " = " - . $enclosure - . '$' . $parentKeyName - . $enclosure; - } - return implode(' and ', $relationKeys); - } - - // INSERT COLUMNS - //************************************************************************* - private function createInsertColumnsExpression( - $objectElement, - $dataObject - ) { - $insertColumns = array(); - - //$serialKeyFields = $this->getSerialKeyFields($objectElement); - - $contents = $dataObject->getContents(); - $l = $contents->length; - for($i=0; $i<$l; $i++) { - $content = $contents->item($i); - $contentName = $content->getName(); - $contentNode = - $this->getContentByName( - $objectElement, - $contentName - ); - $contentNode = $this->getRefNode($contentNode); - if($contentNode->hasDatasource()) continue; - $insertColumns[] = $contentNode->getColumn(); - } - return implode(', ', $insertColumns); - } - - // INSERT VALUES - //************************************************************************* - private function createInsertValuesExpression( - $objectElement, - $dataObject - ) { - $insertValues = array(); - - //$serialKeyFields = $this->getSerialKeyFields($objectElement); - - $contents = $dataObject->getContents(); - $l = $contents->length; - for($i=0; $i<$l; $i++) { - $content = $contents->item($i); - $contentName = $content->getName(); - $contentNode = - $this->getContentByName( - $objectElement, - $contentName - ); - $contentNode = $this->getRefNode($contentNode); - if($contentNode->hasDatasource()) continue; - //if(!in_array($contentName, $serialKeyFields)) { - $contentType = $this->getType($contentNode); - $enclosure = $contentType->getEnclosure(); - $contentValue = - $enclosure - . $this->databaseObject->escape_string( - $dataObject->$contentName) - . $enclosure; - $insertValues[] = $contentValue; - //} - } - return implode(', ', $insertValues); - } - - // UPDATE COLUMNS - //************************************************************************* - private function createUpdateExpression($objectElement, $dataObject) - { - $updatedProperties = $dataObject->getUpdatedProperties(); - $updateColumns = array(); - //$serialKeyFields = $this->getSerialKeyFields($objectElement); - $contents = $dataObject->getContents(); - $l = $contents->length; - for($i=0; $i<$l; $i++) { - $content = $contents->item($i); - $contentName = $content->getName(); - if(in_array($contentName, $updatedProperties)) { - $contentNode = - $this->getContentByName( - $objectElement, - $contentName - ); - $contentNode = $this->getRefNode($contentNode); - if($contentNode->hasDatasource()) continue; - $contentType = $this->getType($contentNode); - $enclosure = $contentType->getEnclosure(); - $columnName = $contentNode->getColumn(); - $propertyValue = $dataObject->$contentName; - if($propertyValue === '') { - $columnValue = 'null'; - } else { - $columnValue = - $enclosure - . $this->databaseObject->escape_string( - $propertyValue) - . $enclosure; - } - $updateColumns[] = - $columnName - . " = " - . $columnValue; - - } - } - - return implode(', ', $updateColumns); - } - - // UPDATE KEY - //************************************************************************* - private function createUpdateKeyExpression($objectElement, $dataObject) - { - $key = $objectElement->getAttribute('das:key'); - $keyFields = explode(' ', $key); - $l = count($keyFields); - $updateKeyFields = array(); - for($i=0; $i<$l; $i++) { - $keyField = $keyFields[$i]; - $keyNode = - $this->getContentByName( - $objectElement, - $keyField - ); - $keyRefNode = $this->getRefNode($keyNode); - $keyColumn = $keyRefNode->getColumn(); - $keyType = $this->getType($keyRefNode); - $enclosure = $keyType->getEnclosure(); - $updateKeyFields[] = - $keyColumn . " = " - . $enclosure - . $this->databaseObject->escape_string( - $dataObject->$keyField) - . $enclosure; - } - return implode(' and ', $updateKeyFields); - } - - // RETURN CREATE KEY - //************************************************************************* - private function createReturnKeyExpression($objectElement) - { - $key = $objectElement->getAttribute('das:key'); - $keyFields = explode(' ', $key); - $l = count($keyFields); - $returnKeyFields = array(); - for($i=0; $i<$l; $i++) { - $keyField = $keyFields[$i]; - $keyNode = - $this->getContentByName( - $objectElement, - $keyField - ); - $keyRefNode = $this->getRefNode($keyNode); - $keyColumn = $keyRefNode->getColumn(); - $returnKeyFields[] = - $keyColumn - . " AS " . $keyField; - } - return implode(', ', $returnKeyFields); - } - - // EXCEPTIONS - //************************************************************************* - private function throwDatabaseException($query) - { - require_once 'core/tests/class/MessageController.php'; - require_once 'core/tests/class/Message.php'; - require_once 'core/tests/class/Exception.php'; - $messageController = new MessageController(); - $messageController->loadMessageFile('core/xml/DataAccessService_Messages.xml'); - $sqlError = $this->databaseObject->getError(); - if(!$sqlError) $sqlError = "-- unable to retrieve SQL error --"; - $exception = $messageController->getMessageText( - 'query_error', - false, - array( - $sqlError, - $query - ) - ); - throw new maarch\Exception($sqlError . ' [' .$query . ']'); - } - - private function enclose_reserved($columnName) - { - $reserved_words = array( - 'when', - ); - - if(in_array($columnName, $reserved_words)) - return '"' . $columnName . "'"; - else return $columnName; - } - -} - diff --git a/core/trunk/core/tests/class/DataAccessService_Inclusion.php b/core/trunk/core/tests/class/DataAccessService_Inclusion.php deleted file mode 100644 index 710a488a2bafc8b0a88200697bab17f88447f9b7..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/DataAccessService_Inclusion.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -class DataAccessService_Inclusion - extends schemaController -{ - public $parser; - - public function connect( - $parser - ) - { - $this->parser = $parser; - } - - -} \ No newline at end of file diff --git a/core/trunk/core/tests/class/DataAccessService_XML.php b/core/trunk/core/tests/class/DataAccessService_XML.php deleted file mode 100644 index 019160c0d4cccc997cc018a8882bc2010b0fc7b3..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/DataAccessService_XML.php +++ /dev/null @@ -1,227 +0,0 @@ -<?php -class DataAccessService_XML - extends DataObjectController -{ - public $file; - public $DOMDocument; - public $XSLT; - - public function DataAccessService_XML( - $file - ) - { - $this->file = $file; - $this->type = 'xml'; - $this->DOMDocument = new DOMDocument(); - $this->DOMDocument->load($file); - $this->XSLT = new XSLTProcessor(); - } - - - public function loadData($objectSchema, $parentObject, $key=false) - { - try { - $this->queryData($objectSchema, $parentObject, $key); - } catch (Exception $e) { - throw $e; - } - } - - //************************************************************************* - // PRIVATE XPATH QUERY CREATION FUNCTIONS - //************************************************************************* - private function makeSelectExpression($table) - { - $selectExpressionParts = array(); - foreach ($table->columns as $columnName => $column) { - $selectExpressionParts[] = "name()='" .$columnName."'"; - } - return implode(' or ', $selectExpressionParts); - - } - - private function makeValueExpression($table) - { - $valueExpressionParts = array(); - foreach ($table->columns as $columnName => $column) { - $valueExpressionPart = - '<xsl:template match="'.$columnName.'"> - <xsl:copy>'; - if($column->fixed) { - $valueExpressionPart .= $column->fixed; - } elseif($column->{'default'}) { - $valueExpressionPart .= - '<xsl:choose> - <xsl:when test="string-length(.) > 0"> - <xsl:value-of select="node()" /> - </xsl:when> - <xsl:otherwise>'.$column->{'default'}.'</xsl:otherwise> - </xsl:choose>'; - } else { - $valueExpressionPart .= - '<xsl:value-of select="node()" />'; - } - $valueExpressionPart .= - '</xsl:copy> - </xsl:template>'; - $valueExpressionParts[] = $valueExpressionPart; - } - return implode('', $valueExpressionParts); - } - - private function makeSelectKeyExpression($table, $key) - { - $selectKeyExpressionParts = array(); - if(isset($table->primaryKey) && !is_null($table->primaryKey)) { - $keyColumns = $table->primaryKey->getColumns(); - $keyValues = explode(' ', $key); - for($i=0; $i<count($keyColumns); $i++) { - $keyColumnName = $keyColumns[$i]; - $keyColumn = $table->columns[$keyColumnName]; - $keyValue = "'" . $keyValues[$i] . "'"; - $selectKeyExpressionParts[] = './' . $keyColumnName . '=' . $keyValue; - } - $selectKeyExpression = implode(' and ', $selectKeyExpressionParts); - return $selectKeyExpression; - } - } - - private function makeFilterExpression($table) - { - $filterExpressionParts = array(); - if(isset($table->filter) && !is_null($table->filter) - && isset($table->filterValue) && !is_null($table->filterValue)) { - $filterColumns = explode(' ', $table->filter); - $filterValue = "'" . $table->filterValue . "'"; - for($i=0; $i<count($filterColumns); $i++) { - $filterColumnName = $filterColumns[$i]; - $filterColumn = $table->columns[$filterColumnName]; - $filterExpressionParts[] = "starts-with(" . './' . $filterColumnName . ',' . $filterValue . ')'; - } - $filterExpression = implode(' or ', $filterExpressionParts); - return $filterExpression; - } - } - - private function makeRelationExpression($relation, $table, $parentObject) - { - $relationExpressionParts = array(); - $childColumns = explode(' ', $relation->childColumns); - $parentColumns = explode(' ', $relation->parentColumns); - for($i=0; $i<count($childColumns); $i++) { - $childColumnName = $childColumns[$i]; - $parentColumnName = $parentColumns[$i]; - $childColumn = $table->columns[$childColumnName]; - $parentColumnValue = "'" . $parentObject->{$parentColumnName} . "'"; - $relationExpressionParts[] = "./" . $childColumnName . " = " . $parentColumnValue; - } - $relationExpression = implode(' and ', $relationExpressionParts); - return $relationExpression; - } - - private function makeSortExpression($table) - { - if($table->order) { - return '<xsl:sort select="*['.$table->order->select.']" order="'.$table->order->mode.'"/>'; - } elseif(isset($table->primaryKey) && !is_null($table->primaryKey)) { - $orderElements = $table->primaryKey->getColumns(); - print_r($orderElements); - for($i=0; $i<count($orderElements); $i++) { - $orderElements[$i] = "name()='".$orderElements[$i]."'"; - } - $order->select = implode(' or ' , $orderElements); - $order->mode = 'ascending'; - return '<xsl:sort select="*['.$order->select.']" order="'.$order->mode.'"/>'; - } - } - - //************************************************************************* - // PRIVATE XPATH QUERY EXECUTION FUNCTIONS - //************************************************************************* - private function queryData($objectSchema, $parentObject, $key=false) - { - if(@$parentObject->ownerDocument) { - $document = $parentObject->ownerDocument; - } else { - $document = $parentObject; - } - - $tableName = $objectSchema->getTableName(); - - $table = $this->tables[$tableName]; - - // Select - $selectExpression = $this->makeSelectExpression($table); - - // Values - $valueExpression = $this->makeValueExpression($table); - - // Where - $whereExpressionParts = array('.'); - if($parentObject - && $parentObject != $document - && $relation = $this->getRelation($parentObject->tagName, $tableName)) { - //echo "<br/>relation " . print_r($relation, true); - $whereExpressionParts[] = $this->makeRelationExpression($relation, $table, $parentObject); - } - if($key && $keyExpression = $this->makeSelectKeyExpression($table, $key)) { - $whereExpressionParts[] = $keyExpression; - } - $filterExpression = $this->makeFilterExpression($table); - if($filterExpression) { - $whereExpressionParts[] = $filterExpression; - } - $whereExpression = implode(' and ', $whereExpressionParts); - // === database ? - - $tableQuery = $table->name . "[" . $whereExpression . "]"; - - // Order - $sortExpression = $this->makeSortExpression($table); - - $xslString = - '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> - <xsl:template match="/"> - <root> - <xsl:apply-templates select="//'.$tableQuery.'"> - '. $sortExpression .' - </xsl:apply-templates> - </root> - </xsl:template> - <xsl:template match="'.$tableName.'"> - <xsl:copy> - <xsl:apply-templates select="*['.$selectExpression.']" /> - </xsl:copy> - </xsl:template> - '.$valueExpression.' - </xsl:stylesheet>'; - - echo "<pre>XSL = " . htmlspecialchars($xslString) . "</pre>"; - - $XSL = new DOMDocument(); - $XSL->formatOutput = true; - $XSL->loadXML($xslString); - $this->XSLT->importStylesheet( $XSL ); - - $root = $this->DOMDocument->documentElement; - - $DOMDocument = $this->XSLT->transformToDoc($root); - echo htmlspecialchars($DOMDocument->saveXML()); - $results = array(); - $DOMTable = $DOMDocument->documentElement->childNodes; - for($i=0; $i<$DOMTable->length; $i++) { - $dataObject = $document->createElement($objectSchema->name); - $parentObject->appendChild($dataObject); - - $DOMRow = $DOMTable->item($i); - $DOMColumns = $DOMRow->childNodes; - for($j=0; $j<$DOMColumns->length; $j++) { - $DOMColumn = $DOMColumns->item($j); - $columnName = $DOMColumn->tagName; - $columnValue = $DOMColumn->nodeValue; - $columnNode = $document->createElement($columnName, $columnValue); - $dataObject->appendChild($columnNode); - } - } - } -} \ No newline at end of file diff --git a/core/trunk/core/tests/class/DataObject.php b/core/trunk/core/tests/class/DataObject.php deleted file mode 100644 index e649b338eb586145152148c5ce17a3a68a44c185..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/DataObject.php +++ /dev/null @@ -1,1059 +0,0 @@ -<?php - -class DataObjectDocument - extends DOMDocument - implements ArrayAccess -{ - - //************************************************************************* - // CONSTRUCTOR - //************************************************************************* - public function DataObjectDocument() - { - parent::__construct(); - $this->formatOutput = false; - $this->preserveWhiteSpace = false; - $this->registerNodeClass('DOMAttr', 'DataObjectAttribute'); - $this->registerNodeClass('DOMElement', 'DataObjectElement'); - $this->registerNodeClass('DOMComment', 'DataObjectComment'); - } - - - //************************************************************************* - // DOM METHODS - //************************************************************************* - public function query($query) - { - $xpath = new DOMXPath($this); - return $xpath->query($query); - } - - - public function createProperty($name) - { - $propertyStrings[] = 'dataObjectProperty'; - $propertyStrings[] = 'name="' . $name . '"'; - $DataObjectProperty = $this->createComment(implode(" ", $propertyStrings)); - return $DataObjectProperty; - } - - public function createDataObject($name) - { - $childStrings[] = 'dataObject'; - $childStrings[] = 'name="' . $name . '"'; - $DataObjectChild = $this->createComment(implode(" ", $childStrings)); - return $DataObjectChild; - } - - public function createLog($operation, $level=DataObjectLog::INFO, $detail=false) - { - $messageStrings[] = 'dataObjectLog'; - $messageStrings[] = 'operation="' . $operation . '"'; - $messageStrings[] = 'level="' . (string)$level . '"'; - if($detail) $messageStrings[] = $detail; - $DataObjectLog = $this->createComment(implode(" ", $messageStrings)); - return $DataObjectLog; - } - - public function importDataObject($DOMNode) - { - $dataObject = $this->importNode( - $DOMNode, - true - ); - return $dataObject; - } - - public function getChildNodesByTagName($name=false) - { - if(!$name) $name = '*'; - $XPath = new DOMXPath($this); - $nodes = $XPath->query( - '/' . $name - ); - return $nodes; - } - - public function getCommentDataObjects() - { - $xpath = new DOMXPath($this); - $dataObjects = - $xpath->query( - "/comment()[starts-with(., 'dataObject ')]", - $this - ); - return $dataObjects; - } - - public function getCommentDataObject($name) - { - $dataObjects = $this->getCommentDataObjects(); - for($i=0; $i<$dataObjects->length; $i++) { - $dataObject = $dataObjects->item($i); - if($dataObject->getAttribute('name') == $name) { - return $dataObject; - } - } - } - - //************************************************************************* - // MAGIC METHODS - //************************************************************************* - public function __get($name) - { - // Element - $nodes = $this->query('/' . $name); - return array($nodes->item(0)); - } - - public function __set($name, $value) - { - switch($name) { - case '' : - $this->appendChild($value); - break; - default: - $resultNodes = $this->query('/'.$name); - switch ((string)$resultNodes->length) { - case '0' : - $resultNode = $this->createElement($name, $value); - $this->appendChild($resultNode); - break; - case '1' : - $resultNode = $resultNodes->item(0); - if((string)$resultNode->nodeValue == $value) { - return; - } - //$this->logChange(DataObjectChange::UPDATE, $name, (string)$resultNode->nodeValue, $value); - $resultNode->nodeValue = $value; - break; - } - } - } - - //************************************************************************* - // ITERATOR METHODS - //************************************************************************* - public function getIterator() { - $childNodes = $this->documentElement->childNodes; - $childArray = array(); - for($i=0; $i<$childNodes->length; $i++) { - $childNode = $childNodes->item($i); - $childName = $childNode->tagName; - $childValue = $childNode->nodeValue; - $childArray[$childName] = $childValue; - } - return new ArrayIterator($childArray); - } - - //************************************************************************* - // ARRAYACCESS METHODS - //************************************************************************* - public function offsetSet($offset, $value) - { - if($value->ownerDocument != $this) { - $dataObject = $this->importNode($value, true); - } else { - $dataObject = $value; - } - $this->appendChild($dataObject); - } - - public function offsetExists($offset) - { - - } - - public function offsetUnset($offset) - { - } - - public function offsetGet($offset) - { - - } - - // XML INTERFACE - //************************************************************************* - public function asXML() - { - return $this->C14N(false,true); - } - - public function show($withComments=true, $prettyAttrs=false, $returnValue=false) - { - // add marker linefeeds to aid the pretty-tokeniser (adds a linefeed between all tag-end boundaries) - $xml = preg_replace('/(>)(<)(\/*)/', "$1\n$2$3", $this->C14N(false, $withComments)); - - // now indent the tags - $token = strtok($xml, "\n"); - $result = ''; // holds formatted version as it is built - $pad = 0; // initial indent - $matches = array(); // returns from preg_matches() - - // scan each line and adjust indent based on opening/closing tags - while ($token !== false) { - $comment = false; - // 1. open and closing tags on same line - no change - if (preg_match('/.+<\/\w[^>]*>$/', $token, $matches)) { - $indent = 0; - // 2. closing tag - outdent now - } elseif (preg_match('/^<\/\w/', $token, $matches)) { - $indent = 0; - $pad--; - // 3. opening tag - don't pad this one, only subsequent tags - } elseif (preg_match('/^<\w[^>]*[^\/]>.*$/', $token, $matches)) { - $indent = 1; - // 4. no indentation needed - } else { - $indent = 0; - } - if($prettyAttrs) { - if(preg_match('/<\!\-\-\s*\w[^>]*\s*\-\->/', $token, $matches)) { - // nothing - } else { - $token = $this->showAttr($token, $pad); - } - } - // pad the line with the required number of leading spaces - $line = str_pad($token, strlen($token)+($pad*4), ' ', STR_PAD_LEFT); - $result .= $line . "\n"; // add to the cumulative result, with linefeed - $token = strtok("\n"); // get the next token - $pad += $indent; // update the pad size for subsequent lines - } - if($returnValue) { - return $result; - } else { - echo "<pre>"; - echo htmlspecialchars($result); - echo "</pre>"; - } - } - - private function showAttr($token, $pad) - { - $return = ''; - $array = preg_split("/\s(\w+=)/", $token, -1, PREG_SPLIT_DELIM_CAPTURE); - for($i=0; $i<count($array); $i++) { - $item = $array[$i]; - if(preg_match('/^\w+=$/', $item)) { - if($i>0 && $i<count($array)) $attrpad = $pad + 1; - else $attrpad = $pad; - $attrname = str_pad($item, strlen($item)+($attrpad*2), ' ', STR_PAD_LEFT); - $return .= $attrname; - } else { - $return .= $item; - if($i<count($array)-1) $return .= "\n"; - } - } - return $return; - } - -} - -/***************************************************************************** -** ** -** DATA OBJECT ELEMENT ** -** ** -*****************************************************************************/ -class DataObjectElement - extends DOMElement - implements IteratorAggregate, ArrayAccess -{ - - // DOM METHODS - //************************************************************************* - public function query($query, $contextElement=false) - { - if(!$contextElement) $contextElement = $this; - $xpath = new DOMXPath($this->ownerDocument); - return $xpath->query($query, $contextElement); - } - - // OBJECT METHODS - //************************************************************************* - public function getName() - { - return $this->tagName; - } - - public function getProperties() - { - $XPath = new DOMXPath($this->ownerDocument); - $nodes = $XPath->query( - './@*' - . ' | ' - . './*', - $this - ); - for($i=0; $i<$nodes->length; $i++) { - $node = $nodes->item($i); - $propertyName = $node->nodeName; - $propertyValue = $node->nodeValue; - switch($node->nodeType) { - case XML_ATTRIBUTE_NODE: - $propertiesArray[$propertyName] = $propertyValue; - break; - case XML_ELEMENT_NODE: - if($node->getElementsByTagName('*')->length == 0) { - $propertiesArray[$propertyName] = $propertyValue; - } - break; - } - } - return $propertiesArray; - } - - public function getContents() - { - $XPath = new DOMXPath($this->ownerDocument); - $contents = $XPath->query( - './@* | ./*', - $this - ); - return $contents; - - } - - public function getAttributes() - { - $XPath = new DOMXPath($this->ownerDocument); - $attributes = $XPath->query( - './@*', - $this - ); - return $attributes; - } - - public function getElements() - { - $XPath = new DOMXPath($this->ownerDocument); - $elements = $XPath->query( - './*', - $this - ); - return $elements; - } - - public function getChildNodesByTagName($name=false) - { - if(!$name) $name = '*'; - $XPath = new DOMXPath($this->ownerDocument); - $nodes = $XPath->query( - './' . $name, - $this - ); - return $nodes; - } - - public function getnodePath() - { - $nodePath = parent::getNodePath(); - - $nodePath = str_replace('[1]', '', $nodePath); - - return $nodePath; - } - - // MAGIC METHODS - //************************************************************************* - public function __set($name, $value) - { - /* - <!ENTITY ndash "–"> <!-- en dash, U+2013 ISOpub --> - <!ENTITY mdash "—"> <!-- em dash, U+2014 ISOpub --> - <!ENTITY lsquo "‘"> <!-- left single quotation mark, U+2018 ISOnum --> - <!ENTITY rsquo "’"> <!-- right single quotation mark, U+2019 ISOnum --> - <!ENTITY sbquo "‚"> <!-- single low-9 quotation mark, U+201A NEW --> - <!ENTITY ldquo "amp;“"> <!-- left double quotation mark, U+201C ISOnum --> - <!ENTITY rdquo "”"> <!-- right double quotation mark, U+201D ISOnum --> - */ - - // Property storage is an attribute - if($this->hasAttribute($name)) { - $valueBefore = $this->getAttribute($name); - if(is_null($value)) { - //echo "<br/>1 - Property $name is attribute, old value was '$valueBefore', new value is null ==> remove attribute"; - $this->removeAttribute($name); - $this->logUpdate($name, $valueBefore, 'null'); - } else if( - (is_scalar($value) || !$value) - && $valueBefore != $value - ) { - //echo "<br/>2 - Property $name is attribute, old value was '$valueBefore', new value is string or false => set attribute"; - $this->setAttribute($name, $value); - $this->logUpdate($name, $valueBefore, $value); - } - - return; - } - - // Property storage is an existing element - $XPath = new DOMXPath($this->ownerDocument); - $propertyNodes = $XPath->query('./' . $name, $this); - if($propertyNodes->length > 0) { - $propertyNode = $propertyNodes->item(0); - $valueBefore = $propertyNode->nodeValue; - if(is_null($value)) { - //echo "<br/>3 - Property $name is element, old value was '$valueBefore', new value is null => comment element"; - $commentedProperty = - $this->ownerDocument->createProperty($name); - $this->replaceChild($commentedProperty, $propertyNode); - $this->logUpdate($name, $valueBefore, 'null'); - } elseif( - (is_scalar($value) || !$value) - && $valueBefore != $value - ) { - //echo "<br/>4 - Property $name is element, old value was '$valueBefore', new value is string or false => set element"; - $propertyNode->nodeValue = $value; - $this->logUpdate($name, $valueBefore, $value); - } - - return; - } - - // Property storage is a commented element - if($commentedProperty = $this->getCommentProperty($name)) { - if(is_null($value)) { - //echo "<br/>5 - Property $name is a commented element, new value is null => no action"; - } elseif(is_scalar($value) || !$value) { - //echo "<br/>6 - Property $name is a commented element, new value is string or false => set element"; - $propertyNode = - $this->ownerDocument->createElement($name, $value); - $this->replaceChild($propertyNode, $commentedProperty); - $this->logUpdate($name, 'null', $value); - } - return; - } - - // Property storage not found = add attribute - if(is_scalar($value) || !$value) { - //echo "<br/>7 - Property $name not found, new value is string or false, adding attribute"; - $this->setAttribute($name, $value); - $this->logUpdate($name, 'null', $value); - return; - } - - } - - public function __get($name) - { - if(!$name) return false; - // Storage is an attribute - if($this->hasAttribute($name)) { - //echo "<br/>$name is an attribute"; - return (string)$this->getAttribute($name); - } - - // Storage is an element - $XPath = new DOMXPath($this->ownerDocument); - $nodes = $XPath->query( - './' . $name, - $this - ); - - // Storage is a commentDataObject -> return array of instance - if($commentDataObject = $this->getCommentDataObject($name)) { - $dataObjectList = new DataObjectList($nodes); - return $dataObjectList; - } - - if($commentProperty = $this->getCommentProperty($name)) { - return null; - } - - // Storage is a property element -> return value - if($nodes->length === 1 - && $nodes->item(0)->getElementsByTagName('*')->length === 0 - ) { - return (string)$nodes->item(0)->nodeValue; - } - - if($nodes->length > 0 - && $nodes->item(0)->getElementsByTagName('*')->length > 0 - ) { - $dataObjectList = new DataObjectList($nodes); - return $dataObjectList; - } - } - - public function __isset($name) - { - // Attribute == property - if($this->hasAttribute($name)) { - return true; - } - // Element - $XPath = new DOMXPath($this->ownerDocument); - $nodes = $XPath->query( - './' . $name, - $this - ); - if($nodes->length > 0) return true; - } - - public function __toString() - { - return $this->C14N(); - } - - // ITERATOR METHODS - //************************************************************************* - public function getIterator() - { - $returnArray = $this->asArray('*'); - return new ArrayIterator($returnArray); - } - - private function asArray($name) - { - $returnArray = array(); - $nodes = $this->ownerDocument->query( - $this->getNodePath() . '/@'. $name - . ' | ' - . $this->getNodePath() . '/'. $name - ); - for($i=0; $i<$nodes->length; $i++) { - $node = $nodes->item($i); - $returnArray[] = $node; - } - return $returnArray; - } - - // ARRAYACCESS METHODS - //************************************************************************* - public function offsetSet($offset, $dataObject) - { - if($dataObject->ownerDocument != $this->onwerDocument) { - $dataObject = $this->ownerDocument->importNode($dataObject, true); - } - $objectName = $dataObject->getName(); - $refDataObject = $this->getCommentDataObject($objectName); - if(is_null($offset)) $offset = 999999; - for($i=0; $i<$offset; $i++) { - if($refDataObject->nextSibling - && $refDataObject->nextSibling->getName() == $objectName) { - $refDataObject = $refDataObject->nextSibling; - } else { - break; - } - } - $this->insertBefore( - $dataObject, - $refDataObject->nextSibling - ); - } - - public function offsetExists($offset) - { - - } - - public function offsetUnset($offset) - { - - } - - public function offsetGet($offset) - { - - } - - // DATA OBJECT COMMENT METHODS - //************************************************************************* - public function getCommentProperties() - { - $xpath = new DOMXPath($this->ownerDocument); - $properties = - $xpath->query( - "./comment()[starts-with(., 'dataObjectProperty')]", - $this - ); - return $properties; - } - - public function getCommentProperty($name) - { - $properties = $this->getCommentProperties(); - for($i=0; $i<$properties->length; $i++) { - $property = $properties->item($i); - if($property->getAttribute('name') == $name) { - return $property; - } - } - } - - public function getCommentDataObjects() - { - $xpath = new DOMXPath($this->ownerDocument); - $dataObjects = - $xpath->query( - "./comment()[starts-with(., 'dataObject ')]", - $this - ); - return $dataObjects; - } - - public function getCommentDataObject($name) - { - $dataObjects = $this->getCommentDataObjects(); - for($i=0; $i<$dataObjects->length; $i++) { - $dataObject = $dataObjects->item($i); - if($dataObject->getAttribute('name') == $name) { - return $dataObject; - } - } - } - - // DATA OBJECT LOGS - //************************************************************************* - public function logCreate() - { - $log = - $this->ownerDocument->createLog( - DataObjectLog::CREATE, - DataObjectLog::INFO - ); - $this->appendChild($log); - } - - public function logRead() - { - $this->clearLogs(); - $log = - $this->ownerDocument->createLog( - DataObjectLog::READ, - DataObjectLog::INFO - ); - $this->appendChild($log); - } - - public function logDelete() - { - $log = - $this->ownerDocument->createLog( - DataObjectLog::DELETE, - DataObjectLog::INFO - ); - $this->appendChild($log); - } - - public function logUpdate($name, $valueBefore, $valueAfter) - { - $messageDetail = - 'name="' . $name - . '" value-before="' . $valueBefore - . '" value-after="' . $valueAfter . '"'; - $message = - $this->ownerDocument->createLog( - DataObjectLog::UPDATE, - DataObjectLog::INFO, - $messageDetail - ); - $this->appendChild($message); - } - - public function logValidate($code, $message, $level) - { - $messageDetail = 'code="' . $code . '" message="' . $message . '"'; - $message = - $this->ownerDocument->createLog( - DataObjectLog::VALIDATE, - $level, - $messageDetail - ); - $this->appendChild($message); - } - - public function getLogs() - { - $xpath = new DOMXPath($this->ownerDocument); - $logs = - $xpath->query( - "./comment()[starts-with(., 'dataObjectLog')]", - $this - ); - return $logs; - } - - public function firstLog() - { - $xpath = new DOMXPath($this->ownerDocument); - $logs = - $xpath->query( - "./comment()[starts-with(., 'dataObjectLog')]", - $this - ); - return $logs->item(0); - } - - public function clearLogs() - { - $logs = $this->getLogs(); - for($i=0; $i<$logs->length; $i++) { - $log = $logs->item($i); - $this->removeChild($log); - } - } - - public function isCreated() - { - $firstLog = $this->firstLog(); - if($firstLog->getAttribute('operation') - == DataObjectLog::CREATE) return true; - } - - public function isDeleted() - { - $logs = $this->getLogs(); - $l = $logs->length; - for($i=$l-1; $i>=0; $i--) { - $log = $logs->item($i); - if($log->getAttribute('operation') == DataObjectLog::DELETE) { - return true; - } - } - } - - public function isRead() - { - $firstLog = $this->firstLog(); - if($firstLog->getAttribute('operation') == DataObjectLog::READ) { - return true; - } - } - - public function getUpdatedProperties() - { - $updatedProperties = array(); - $logs = $this->getLogs(); - for($i=0; $i<$logs->length; $i++) { - $log = $logs->item($i); - if($log->getAttribute('operation') == DataObjectLog::UPDATE) { - $updatedProperties[] = $log->getAttribute('name'); - } - } - return $updatedProperties; - } - - public function getValidationErrors() - { - $validationErrors = array(); - $logs = $this->getLogs(); - for($i=0; $i<$logs->length; $i++) { - $log = $logs->item($i); - if($log->getAttribute('operation') == DataObjectLog::VALIDATE) { - $validationErrors[] = - new Message( - $log->getAttribute('code'), - $log->getAttribute('message'), - $log->getAttribute('level') - ); - } - } - return $validationErrors; - } - - - // XML INTERFACE - //************************************************************************* - public function asXML() - { - return $this->C14N(false,true); - } - - public function show($withComments=true, $prettyAttrs=false, $returnValue=false) - { - // add marker linefeeds to aid the pretty-tokeniser (adds a linefeed between all tag-end boundaries) - $xml = preg_replace('/(>)(<)(\/*)/', "$1\n$2$3", $this->C14N(false, $withComments)); - - // now indent the tags - $token = strtok($xml, "\n"); - $result = ''; // holds formatted version as it is built - $pad = 0; // initial indent - $matches = array(); // returns from preg_matches() - - // scan each line and adjust indent based on opening/closing tags - while ($token !== false) { - $comment = false; - // 1. open and closing tags on same line - no change - if (preg_match('/.+<\/\w[^>]*>$/', $token, $matches)) { - $indent = 0; - // 2. closing tag - outdent now - } elseif (preg_match('/^<\/\w/', $token, $matches)) { - $indent = 0; - $pad--; - // 3. opening tag - don't pad this one, only subsequent tags - } elseif (preg_match('/^<\w[^>]*[^\/]>.*$/', $token, $matches)) { - $indent = 1; - // 4. no indentation needed - } else { - $indent = 0; - } - if($prettyAttrs) { - if(preg_match('/<\!\-\-\s*\w[^>]*\s*\-\->/', $token, $matches)) { - // nothing - } else { - $token = $this->showAttr($token, $pad); - } - } - // pad the line with the required number of leading spaces - $line = str_pad($token, strlen($token)+($pad*4), ' ', STR_PAD_LEFT); - $result .= $line . "\n"; // add to the cumulative result, with linefeed - $token = strtok("\n"); // get the next token - $pad += $indent; // update the pad size for subsequent lines - } - if($returnValue) { - return $result; - } else { - echo "<pre>"; - echo htmlspecialchars($result); - echo "</pre>"; - } - } - - private function showAttr($token, $pad) - { - $return = ''; - $array = preg_split("/\s(\w+=)/", $token, -1, PREG_SPLIT_DELIM_CAPTURE); - for($i=0; $i<count($array); $i++) { - $item = $array[$i]; - if(preg_match('/^\w+=$/', $item)) { - if($i>0 && $i<count($array)) $attrpad = $pad + 1; - else $attrpad = $pad; - $attrname = str_pad($item, strlen($item)+($attrpad*2), ' ', STR_PAD_LEFT); - $return .= $attrname; - } else { - $return .= $item; - if($i<count($array)-1) $return .= "\n"; - } - } - return $return; - } - -} - -/***************************************************************************** -** ** -** DATA OBJECT ATTRIBUTE ** -** ** -*****************************************************************************/ -class DataObjectAttribute - extends DOMAttr -{ - - public function getName() - { - return $this->name; - } - - public function __toString() - { - return (string)$this->nodeValue; - } - -} - -/***************************************************************************** -** ** -** DATA OBJECT COMMENT ** -** ** -*****************************************************************************/ -class DataObjectComment - extends DOMComment -{ - public function getAttribute($name) - { - $attribute_array = array(); - // Match attribute-name attribute-value pairs. - $hasAttributes = preg_match_all( - '#([^\s=]+)\s*=\s*(\'[^<\']*\'|"[^<"]*")#', - $this, $matches, PREG_SET_ORDER); - if ($hasAttributes) { - foreach ($matches as $attribute) { - $attribute_array[$attribute[1]] = - substr($attribute[2], 1, -1); - } - } - return $attribute_array[$name]; - } - - public function getName() - { - $contents = split(' ', $this); - for($i=0; $i<count($contents); $i++) { - $content = $contents[$i]; - if(mb_strlen(trim($content)) > 0) { - return $content; - } - } - - } - - public function __get($name) - { - if($name == 'tagName') { - $found = preg_match('#^\s*[\w_]+\s#', $this, $matches); - return $matches[0]; - } - } - - public function __toString() - { - return (string)$this->nodeValue; - } -} - -/***************************************************************************** -** ** -** DATA OBJECT LOG ** -** ** -*****************************************************************************/ - -class DataObjectLog - extends DataObjectComment -{ - const NONE = 'NONE'; - const CREATE = 'CREATE'; - const READ = 'READ'; - const UPDATE = 'UPDATE'; - const DELETE = 'DELETE'; - const ENUMERATE = 'LIST'; - const VALIDATE = 'VALIDATE'; - - const INFO = 0; - const WARNING = 1; - const ERROR = 2; - const FATAL = 3; - -} - -/***************************************************************************** -** ** -** DATA OBJECT LIST ** -** ** -*****************************************************************************/ -class DataObjectList - implements IteratorAggregate, ArrayAccess, Countable -{ - - private $storage = array(); - public $length; - - - public function DataObjectList($nodeList=false) - { - if($nodeList) { - $l = $nodeList->length; - for($i=0; $i<$l; $i++) { - $this->storage[$i] = $nodeList->item($i); - } - } - $this->length = count($this->storage); - } - - public function asXMLArray() - { - $XMLArray = array(); - for($i=0; $i<count($this->storage); $i++) { - $XMLArray[] = $this->storage[$i]->asXML(); - } - return $XMLArray; - } - - public function show() - { - $showArray = array(); - for($i=0; $i<count($this->storage); $i++) { - $showArray[] = htmlspecialchars($this->storage[$i]->show(true, false, true)); - } - echo "<pre>"; - print_r($showArray); - echo "</pre>"; - - } - - public function last() - { - return end($this->storage); - } - - //************************************************************************* - // MAGIC METHODS - //************************************************************************* - public function __get($name) - { - if($name == 'length') return count($this->storage); - } - - - //************************************************************************* - // DOM NODELITS EMULATION - //************************************************************************* - public function item($offset) - { - return $this->storage[$offset]; - } - - //************************************************************************* - // DOM ELEMENT EMULATION - //************************************************************************* - public function query($query) - { - if($firstObject = $this->storage[0]) { - $dataObjectDocument = $firstObject->ownerDocument; - $xpath = new DOMXPath($dataObjectDocument); - return $xpath->query($query); - } else { - return false; - } - } - - //************************************************************************* - // ITERATOR METHODS - //************************************************************************* - public function getIterator() { - return new ArrayIterator($this->storage); - } - - //************************************************************************* - // COUNTABLE METHODS - //************************************************************************* - public function count() - { - return count($this->storage); - } - - //************************************************************************* - // ARRAYACCESS METHODS - //************************************************************************* - public function offsetSet($offset, $value) - { - if(!$offset) $offset = count($this->storage); - $this->storage[$offset] = $value; - $this->length = count($this->storage); - } - - public function offsetExists($offset) - { - return isset($this->storage[$offset]); - } - - public function offsetUnset($offset) - { - unset($this->storage[$offset]); - $this->length = count($this->storage); - } - - public function offsetGet($offset) - { - return $this->storage[$offset]; - } - - public function end() - { - return end($this->storage); - } - - -} \ No newline at end of file diff --git a/core/trunk/core/tests/class/DataObjectController.php b/core/trunk/core/tests/class/DataObjectController.php deleted file mode 100644 index 498a3ff8a594a7bb99160bf648c72c85126de4ca..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/DataObjectController.php +++ /dev/null @@ -1,1366 +0,0 @@ -<?php - -// Schema -require_once 'core/tests/class/Schema.php'; - -// Document & objects -require_once 'core/tests/class/DataObject.php'; - -// Data access services -require_once 'core/tests/class/DataAccessService_Database.php'; -require_once 'core/tests/class/DataAccessService_XML.php'; - -// Messages -require_once 'core/tests/class/MessageController.php'; -require_once 'core/tests/class/Message.php'; -require_once 'core/tests/class/Exception.php'; - -class DataObjectController - extends DOMXPath -{ - - public $dataObjectDocuments = array(); - protected $dataAccessServices = array(); - protected $XRefs = array(); - protected $messageController; - public $inTransaction; - public $transactionControl; - - //************************************************************************* - // CONSTRUCTOR - //************************************************************************* - public function DataObjectController() - { - //$this->XRefs = new SchemaXRefs(); - $this->messageController = new MessageController(); - $this->messageController->loadMessageFile( - $_SESSION['config']['corepath'] - . 'core/xml/DataObjectController_Messages.xml' - ); - } - - // Load schema from master Xsd file - public function loadXSD($XSDFile) - { - // Construct Schema and load XSD with includes - $schema = new Schema(); - $schema->loadXSD($XSDFile); - - // Construct SchemaController - parent::__construct($schema); - $this->schema = $this->document; - } - - // Include XSD file content to master schema - public function includeXSD($XSDFile) - { - $this->schema->includeXSD( - $this->schema, - $XSDFile, - $this->schema - ); - } - - // Load schema from Schema object - public function loadSchema($schemaXML) - { - // Construct SchemaController - parent::__construct($schemaXML); - $this->schema = $this->document; - - } - - //************************************************************************* - // PUBLIC SCHEMA INFO - //************************************************************************* - public function getKeyProperties($objectName) - { - $objectElement = $this->getElementByName($objectName); - return explode(' ', $objectElement->getAttribute('das:key')); - } - - public function getFilterProperties($objectName) - { - $objectElement = $this->getElementByName($objectName); - $filters = explode(' ', $objectElement->getFilter()); - $return = array(); - for($i=0; $i<count($filters); $i++) { - $filter = $filters[$i]; - $propertyName = str_replace( - "@", - "", - $filter->getAttribute('xpath') - ); - $return[] = $propertyName; - } - return $return; - } - - public function getObjectProperties($objectName) - { - $objectProperties = array(); - $objectElement = $this->getElementByName($objectName); - $objectContents = $this->getObjectContents($objectElement); - $l = count($objectContents); - for($i=0; $i<$l; $i++) { - $contentNode = $objectContents[$i]; - if($contentNode->hasDatasource()) continue; - $objectProperties[] = $contentNode; - } - return $objectProperties; - } - - public function getObjectChildren($objectName) - { - $objectChildren = array(); - $objectElement = $this->getElementByName($objectName); - $objectContents = $this->getObjectContents($objectElement); - $l = count($objectContents); - for($i=0; $i<$l; $i++) { - $contentNode = $objectContents[$i]; - $contentNode = $this->getRefNode($contentNode); - if(!$contentNode->hasDatasource()) continue; - $objectChildren[] = $contentNode; - } - return $objectChildren; - } - - public function getTypeEnumeration( - $typeName - ) { - $typeEnumeration = new DataObjectList(); - - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - - $simpleType = $this->getTypeByName($typeName); - $enumerations = $this->query('.//xsd:enumeration', $simpleType); - $l = $enumerations->length; - for($i=0; $i<$l; $i++) { - $enumeration = $enumerations->item($i); - $dataObject = $dataObjectDocument->importNode($enumeration, true); - $dataObjectDocument->appendChild($dataObject); - $typeEnumeration[] = $dataObject; - } - return $typeEnumeration; - } - - //************************************************************************* - // PUBLIC OBJECT HANDLING FUNCTIONS - //************************************************************************* - public function create( - $objectName, - $parentDataObject=false - ) { - if($parentDataObject) { - $dataObjectDocument = $parentDataObject->ownerDocument; - } else { - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - } - $schemaElement = $this->getElementByName($objectName); - - if(!$schemaElement->isCreatable()) - throw new maarch\Exception("Object $objectName can not be created"); - - $dataObject = - $this->createDataObject( - $schemaElement, - $dataObjectDocument, - $includeChildren = true - ); - $dataObject->logCreate(); - $dataObjectDocument[] = $dataObject; - - return $dataObject; - } - - public function enumerate( - $objectName, - $filter=false, - $sort=false, - $order=false, - $limit=false - ) - { - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - - $rootElement = $this->query( - '/xsd:schema/xsd:element[@das:module != ""]' - )->item(0); - - $rootDataObject = - $this->createDataObject( - $rootElement, - $dataObjectDocument - ); - $dataObjectDocument->appendChild($rootDataObject); - - $schemaElement = $this->getElementByName($objectName); - if(!$schemaElement->isListable()) - throw new maarch\Exception("Object $objectName can not be listed"); - - $refElement = $this->getRefNode($schemaElement); - - $this->listDataObject( - $refElement, - $rootDataObject, - $dataObjectDocument, - $key, - $filter, - $sort, - $order, - $limit - ); - - $dataObjectsNodeList = $rootDataObject->query("./" . $objectName); - - $dataObjectList = new DataObjectList($dataObjectsNodeList); - - return $dataObjectList; - } - - public function read( - $objectName, - $key, - $readChildren=true, - $levelToShow='full' - ) { - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - - $objectElement = $this->getElementByName($objectName); - - if(!$objectElement->isReadable()) throw new maarch\Exception("Object $objectName can not be read"); - - $this->readDataObject( - $objectElement, - $dataObjectDocument, - $dataObjectDocument, - $key, - $readChildren, - $levelToShow - ); - return $dataObjectDocument->documentElement; - } - - public function save( - $dataObject, - $saveChildren = true - ) { - $objectElement = $this->getElementByName($dataObject->tagName); - $dataObjectDocument = $dataObject->ownerDocument; - if(!$this->inTransaction) { - $this->startTransaction('controller'); - } - try { - $key = $this->saveDataObject( - $objectElement, - $dataObject, - $saveChildren - ); - if($this->transactionControl == 'controller') { - $this->commit(); - } - return $key; - } catch (maarch\Exception $e) { - $this->rollback(); - throw $e; - } - } - - public function readChildren( - $dataObject - ) { - $objectName = $dataObject->getName(); - $objectElement = $this->getElementByName($objectName); - $this->readChildDataObjects( - $objectElement, - $dataObject, - $dataObject->ownerDocument - ); - return $dataObject; - } - - public function loadXMLArray($XMLArray) - { - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - - $rootNode = $dataObjectDocument->createElement('root'); - $dataObjectDocument->appendChild($rootNode); - - $dataObjectList = new DataObjectList(); - for($i=0; $i<count($XMLArray); $i++) { - $dataObject = $this->loadXML($XMLArray[$i]); - $rootNode->appendChild($dataObjectDocument->importNode($dataObject,true)); - $dataObjectList[] = $dataObject; - } - return $dataObjectList; - } - - - public function loadXML($xml) - { - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - $dataObjectDocument->loadXML($xml); - $dataObject = $dataObjectDocument->documentElement; - return $dataObject; - } - - public function load($XmlFile) - { - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - $dataObjectDocument->load($XmlFile); - $dataObject = $dataObjectDocument->documentElement; - return $dataObject; - } - - public function delete($dataObject) - { - $objectElement = $this->getElementByName($dataObject->tagName); - if(!$objectElement->isDeletable()) throw new maarch\Exception("Object $objectName can not be deleted"); - $this->deleteDataObject($objectElement, $dataObject); - } - - public function copy( - $dataObject, - $newName = false, - $resetKey = true, - $copyChildren = false, - $parentDataObject = false - ){ - - $newObject = - $this->copyDataObject( - $dataObject, - $parentDataObject, - $newName, - $resetKey, - $copyChildren - ); - - return $newObject; - } - - public function validate($dataObject) - { - $messageController = new MessageController(); - $messageController->loadMessageFile( - $_SESSION['config']['corepath'] - . '/core/xml/DataObjectController_Messages.xml' - ); - - // Validate with specific business script - //********************************************************************* - /*$objectElement = $this->getElementByName($dataObject->tagName); - if($objectElement->hasAttribute('das:validation')) { - include_once $objectElement->getAttribute('das:validation'); - }*/ - - // Validate against schema - //********************************************************************* - $XsdString = $this->schema->saveXML(); - libxml_use_internal_errors(true); - $dataObjectDocument = $dataObject->ownerDocument; - if(!$dataObjectDocument->schemaValidateSource($XsdString)) { - $blockingErrors = 0; - $libXMLErrors = libxml_get_errors(); - foreach ($libXMLErrors as $libXMLError) { - switch ($libXMLError->level) { - case LIBXML_ERR_ERROR: - case LIBXML_ERR_FATAL: - $blockingErrors++; - break; - } - $dataObject->logValidate( - $libXMLError->code, - $libXMLError->message, - $libXMLError->level); - } - libxml_clear_errors(); - libxml_use_internal_errors(false); - if($blockingErrors > 0) { - return false; - } else { - return true; - } - } else { - $dataObject->logValidate('0000', DataObjectLog::INFO, 'Valid'); - libxml_clear_errors(); - libxml_use_internal_errors(false); - return true; - } - - } - - //************************************************************************* - // protected OBJECT HANDLING FUNCTIONS - //************************************************************************* - protected function createDataObject( - $objectElement, - $dataObjectDocument, - $includeChildren = false - ) { - $objectName = $objectElement->getName(); - - $dataObject = $dataObjectDocument->createElement($objectName); - - // Add children and attributes - $objectContents = $this->getObjectContents($objectElement); - $l = count($objectContents); - for($i=0; $i<$l; $i++) { - $contentNode = $objectContents[$i]; - $contentName = $contentNode->getName(); - $required = $contentNode->isRequired(); - $refNode = $this->getRefNode($contentNode); - $contentValue = $this->getValue($refNode); - - switch($refNode->tagName) { - case 'xsd:attribute': - if($contentValue != '') { - $dataObject->setAttribute( - $contentName, - $contentValue - ); - } - break; - case 'xsd:element': - if($refNode->hasDatasource()) { - // Comment DataObject - $childObject = - $dataObjectDocument->createDataObject( - $contentName - ); - $dataObject->appendChild($childObject); - // Instance if required and included - if(!$contentNode->isCreatable()) continue; - if($required && $includeChildren) { - $childObject = $this->createDataObject( - $refNode, - $dataObjectDocument, - true - ); - $dataObject->appendChild($childObject); - $childObject->logCreate(); - } - } else { - // Property Element - if($required) { - $property = - $dataObjectDocument->createElement( - $contentName, - $contentValue - ); - } else { - $property = - $dataObjectDocument->createProperty( - $contentName - ); - } - $dataObject->appendChild($property); - } - break; - } - } - - return $dataObject; - } - - protected function listDataObject( - $objectElement, - $parentObject, - $dataObjectDocument, - $key=false, - $filter=false, - $sort=false, - $order='ascending', - $limit=99999999 - ) { - try { - if($dataAccessService = - $this->getDataAccessService($objectElement) - ) { - $dataAccessService->loadData( - $objectElement, - $parentObject, - $dataObjectDocument, - $key, - $filter, - $sort, - $order, - $limit - ); - } else { - $dataObject = $this->createDataObject( - $objectElement, - $dataObjectDocument - ); - $parentObject->appendChild($dataObject); - $dataObject->logRead(); - } - } catch (maarch\Exception $e) { - throw $e; - } - } - - protected function readDataObject( - $objectElement, - $parentObject, - $dataObjectDocument, - $key=false, - $readChildren=true, - $levelToShow='full' - ) { - try { - if($dataAccessService = - $this->getDataAccessService($objectElement) - ) { - $dataAccessService->loadData( - $objectElement, - $parentObject, - $dataObjectDocument, - $key, - $filter, - $sort, - $order, - $limit - ); - } else { - $dataObject = $this->createDataObject( - $objectElement, - $dataObjectDocument - ); - $parentObject->appendChild($dataObject); - $dataObject->logRead(); - } - - if($readChildren) { - // Process read object(s) child objects - $newObjects = - $parentObject->getChildNodesByTagName( - $objectElement->getName() - ); - $m = $newObjects->length; - for($j=0; $j<$m; $j++) { - $newObject = $newObjects->item($j); - $this->readChildDataObjects( - $objectElement, - $newObject, - $dataObjectDocument, - $levelToShow - ); - } - } - - } catch (maarch\Exception $e) { - throw $e; - } - } - - public function readChildDataObjects( - $objectElement, - $dataObject, - $dataObjectDocument, - $levelToShow='full' - ) { - // Get list of childElements - $objectContents = $this->getObjectContents($objectElement); - $l = count($objectContents); - $decompte = $levelToShow; - for($i=0; $i<$l; $i++) { - $objectNode = $objectContents[$i]; - if(!$objectNode->isReadable()) continue; - $refNode = $this->getRefNode($objectNode); - if(!$refNode->hasDatasource()) continue; - //echo "<br/>Read relation between " . $dataObject->tagName . " and child " . $objectNode->getName(); - $relation = $this->getRelation($objectNode, $dataObject); - if(!$relation) continue; - //echo "<br/>Read child of " . $objectElement->getName() . " named " . $refNode->getName(); - if((string)$levelToShow=='full'){ - $this->readDataObject( - $refNode, - $dataObject, - $dataObjectDocument - ); - - }else{ - if($decompte==1){ - $this->readDataObject( - $refNode, - $dataObject, - $dataObjectDocument, - false, - false - ); - - }elseif($decompte==0){ - //on affiche rien - }else{ - $decompte--; - $this->readDataObject( - $refNode, - $dataObject, - $dataObjectDocument, - false, - true, - $decompte - ); - - } - } - } - } - - protected function saveDataObject( - $objectElement, - $dataObject, - $saveChildren=true - ) { - try { - $refElement = $this->getRefNode($objectElement); - if($dataAccessService = - $this->getDataAccessService($refElement) - ) { - if($dataObject->isCreated() - && !$dataObject->isDeleted() - ) { - $key = $dataAccessService->insertData( - $refElement, - $dataObject - ); - $this->setDataObjectKey( - $refElement, - $dataObject, - $key - ); - if($saveChildren) { - $this->saveChildDataObjects( - $objectElement, - $dataObject - ); - } - } elseif ($dataObject->isRead() - && !$dataObject->isDeleted() - ) { - if($refElement->isUpdatable() - && count($dataObject->getUpdatedProperties()) > 0 - ) { - $key = $dataAccessService->updateData( - $refElement, - $dataObject - ); - } - $key = $dataObject; - if($saveChildren) { - $this->saveChildDataObjects( - $objectElement, - $dataObject - ); - } - } elseif ($dataObject->isRead() - && $dataObject->isDeleted()) { - if($refElement->isDeletable()) { - $this->saveChildDataObjects( - $objectElement, - $dataObject - ); - } - $key = $dataAccessService->deleteData( - $refElement, - $dataObject - ); - $dataObject->parentNode->removeChild($dataObject); - } elseif ( - $dataObject->isCreated() - && $dataObject->isDeleted() - ) { - $dataObject->parentNode->removeChild($dataObject); - } - } - - $dataObject->clearLogs(); - $dataObject->logRead(); - return $key; - } catch (maarch\Exception $e) { - throw $e; - } - } - - protected function setDataObjectKey( - $objectElement, - $dataObject, - $returnKey = false - ) { - $key = $objectElement->getAttribute('das:key'); - if(!$key) return false; - $keyFields = explode(' ', $key); - $l = count($keyFields); - for($i=0; $i<$l; $i++) { - $keyField = $keyFields[$i]; - if(!isset($dataObject->$keyField) - || mb_strlen(trim($dataObject->$keyField)) == 0 - ) { - $dataObject->$keyField = $returnKey->$keyField; - } - } - } - - protected function saveChildDataObjects( - $objectElement, - $dataObject - ) { - $objectContents = $this->getObjectContents($objectElement); - $l = count($objectContents); - for($i=0; $i<$l; $i++) { - $objectNode = $objectContents[$i]; - - $refNode = $this->getRefNode($objectNode); - if(!$refNode->hasDatasource()) continue; - - // Get relation between dataObject and child - //echo "<br/>Relation between child " . $refNode->getName() . " and parent " . $dataObject->getName(); - $relation = $this->getRelation($refNode, $dataObject); - if($relation) { - $fkeys = $this->query('./das:foreign-key', $relation); - $n = $fkeys->length; - } - // List children elements of given type - $childObjects = - $dataObject->getChildNodesByTagName( - $objectNode->getName() - ); - $m = $childObjects->length; - for($j=0; $j<$m; $j++) { - $childObject = $childObjects->item($j); - - // Assign key values to child if needed - if($relation) { - for($k=0; $k<$n; $k++) { - $fkey = $fkeys->item($k); - $parentKey = $fkey->getAttribute('parent-key'); - $childKey = $fkey->getAttribute('child-key'); - //echo "<br/>parentkey is $parentKey, childkey is $childKey"; - $childObject->$childKey = $dataObject->$parentKey; - //echo " --> childkey set to :" . $childObject->$childKey; - } - } - - $this->saveDataObject( - $objectNode, - $childObject - ); - } - } - - } - - protected function deleteDataObject( - $objectElement, - $dataObject - ) { - - $dataObject->logDelete(); - - // Process children - $objectContents = $this->getObjectContents($objectElement); - $l = count($objectContents); - for($i=0; $i<$l; $i++) { - $objectNode = $objectContents[$i]; - if(!$objectNode->isDeletable()) continue; - $refNode = $this->getRefNode($objectNode); - if(!$refNode->hasDatasource()) continue; - - // List children elements of given type - $childObjects = - $dataObject->getChildNodesByTagName( - $refNode->getName() - ); - $m = $childObjects->length; - - for($j=0; $j<$m; $j++) { - $childObject = $childObjects->item($j); - $this->deleteDataObject( - $refNode, - $childObject - ); - } - } - } - - protected function copyDataObject( - $dataObject, - $parentDataObject = false, - $newName = false, - $resetKey = true, - $copyChildren = false - ) { - - if($parentDataObject) { - $dataObjectDocument = $parentDataObject->ownerDocument; - } else { - $dataObjectDocument = new DataObjectDocument(); - $this->dataObjectDocuments[] = $dataObjectDocument; - } - - if(!$newName) $newName = $dataObject->tagName; - - $keyProperties = $this->getKeyProperties($newName); - - $newObject = - $this->create( - $newName, - $parentDataObject - ); - // Copy Properties except keys if not required - $objectProperties = $this->getObjectProperties($newName); - foreach($objectProperties as $propertyNode) { - $propertyName = $propertyNode->getName(); - if($resetKey && - in_array($propertyName, $keyProperties) - ) { - continue; - } - if($dataObject->$propertyName) { - $newObject->$propertyName = $dataObject->$propertyName; - } - } - - // Copy Children objects if requested - if($copyChildren) { - $objectChildren = $this->getObjectChildren($newName); - foreach($objectChildren as $childNode) { - $objectName = $childNode->getName(); - $childObjects = $dataObject->$objectName; - for($i=0; $i<$childObjects->length; $i++) { - $childObject = $childObjects->item($i); - $newChildObject = - $this->copyDataObject( - $childObject, - $dataObject, - $newName = false, - $resetKey, - $copyChildren - ); - $newObject[] = $newChildObject; - } - } - } - - $newObject->clearLogs(); - $newObject->logCreate(); - return $newObject; - } - - //************************************************************************* - // DATA OBJECTS QUERY FUNCTIONS - //************************************************************************* - protected function getDataObjectElement($dataObject) - { - $objectName = $dataObject->tagName; - return $this->getElementByName($objectName); - } - - protected function getDataObjectDocument($dataObject) - { - return $dataObject->documentElement(); - } - - //************************************************************************* - // DATA ACCESS SERVICE FUNCTIONS - //************************************************************************* - protected function createDataAccessServices() - { - $das = $this->query('//das:source'); - for($i=0; $i<$das->length; $i++) { - $dasNode = $das->item($i); - $parentElement = $dasNode->parentNode->parentNode->parentNode; - // xsd:?????/xsd:annotation/xsd:appinfo - if ($parentElement == $this->schema->documentElement) { - $dasName = $dasNode->getAttribute('name'); - } else { - $dasName = $parentElement->getName(); - } - $this->createDataAccessService( - $dasName, $dasNode - ); - } - } - - protected function getDataAccessService($node) - { - if($node->hasAttribute('das:source')) { - $sourceName = $node->getAttribute('das:source'); - if(!isset($this->dataAccessServices[$sourceName])) { - $sourceNode = $this->query( - '//das:source[@name="' - . $sourceName - . '"]' - )->item(0); - $this->createDataAccessService($sourceName, $sourceNode); - } - } elseif($sourceNode = $this->query( - './xsd:annotation/xsd:appinfo/das:source', - $node - )->item(0) - ) { - $sourceName = $node->getAttribute('name'); - if(!isset($this->dataAccessServices[$sourceName])) { - $this->createDataAccessService($sourceName, $sourceNode); - } - } - return $this->dataAccessServices[$sourceName]; - - } - - protected function createDataAccessService($sourceName, $sourceNode) - { - switch($sourceNode->getAttribute('type')) { - case 'database': - $this->dataAccessServices[$sourceName] = - new DataAccessService_Database(); - $this->dataAccessServices[$sourceName]->loadSchema($this->schema); - $this->dataAccessServices[$sourceName]->connect($sourceNode); - $this->dataAccessServices[$sourceName]->XRefs = &$this->XRefs; - break; - case 'xml': - break; - } - } - - public function startTransaction($transactionControl='caller') - { - //echo "<br/>Starting transaction for control " . $transactionControl; - $this->transactionControl = $transactionControl; - $this->createDataAccessServices(); - foreach($this->dataAccessServices as $dasName => $dataAccessService) { - //echo "<br/>Start transaction for ". $dasName; - if(method_exists($dataAccessService, 'startTransaction')) { - $dataAccessService->startTransaction(); - } - } - $this->inTransaction = true; - } - - public function commit() - { - //echo "<br/>Commit transaction for control " . $this->transactionControl; - foreach($this->dataAccessServices as $dataAccessService) { - if(method_exists($dataAccessService, 'commit')) { - $dataAccessService->commit(); - } - } - } - - public function rollback() - { - //echo "<br/>Rollbak transaction for control " . $this->transactionControl; - foreach($this->dataAccessServices as $dataAccessService) { - if(method_exists($dataAccessService, 'rollback')) { - $dataAccessService->rollback(); - } - } - } - - //************************************************************************* - // SCHEMA QUERY FUNCTIONS - //************************************************************************* - protected function getElementByName($name) - { - $element = $this->query( - '/xsd:schema/xsd:element[@name = "' - . $name - . '"]' - )->item(0); - if(!$element) { - throw new maarch\Exception("Element $name is not defined"); - } - return $element; - } - - protected function getAttributeByName($name) - { - $attribute = $this->query( - '/xsd:schema/xsd:attribute[@name = "' - . $name - . '"]' - )->item(0); - if(!$attribute) throw new maarch\Exception("Attribute $name is not defined"); - return $attribute; - } - - - protected function getTypeByName($typeName) - { - $type = $this->query( - '/xsd:schema/xsd:simpleType[@name = "' - . $typeName - . '"]' - . ' | ' - . '/xsd:schema/xsd:complexType[@name = "' - . $typeName - . '"]' - )->item(0); - if(!$type) throw new maarch\Exception("Type $typeName is not defined"); - return $type; - } - - protected function hasDatasource($node) - { - if($node->hasDatasource() - || $this->query( - './xsd:annotation/xsd:appinfo/das:source', - $node - )->length > 0 - ){ - return true; - } - - } - - protected function getContentByName($objectElement, $name) - { - $objectContents = $this->getObjectContents($objectElement); - $l = count($objectContents); - for($i=0; $i<$l; $i++) { - $contentNode = $objectContents[$i]; - if($contentNode->getName() == $name) { - return $contentNode; - } - } - - throw new maarch\Exception("Content $name of object name " . $objectElement->getName() . " is not defined"); - } - - protected function getRefNode($node) - { - if($node->hasAttribute('ref')) { - $refNode = $this->query( - '//'.$node->tagName.'[@name = "' - . $node->getAttribute('ref') - . '"]' - )->item(0); - if(!$refNode) - throw new maarch\Exception("Referenced node " - . $node->getAttribute('ref') - . " is not defined" - ); - return $refNode; - } else { - return $node; - } - } - - protected function getValue($node) - { - if($node->hasAttribute('fixed')) { - return $node->getAttribute('fixed'); - } - if($node->hasAttribute('default')) { - return $node->getAttribute('default'); - } - } - - protected function getType($node) - { - //echo "<br/>Get type of $node->tagName " . $node->getAttribute('name'); - //if(!$type = $this->getXRefs($node, 'type')) { - if($node->hasAttribute('type')) { - $typeName = $node->getAttribute('type'); - if(substr($typeName, 0, 3) == 'xsd') { - $this->addBuiltInType($typeName); - } - $types = $this->query( - '//xsd:complexType[@name="' - . $typeName - . '"] | //xsd:simpleType[@name="' - . $typeName - . '"]' - ); - } else { - $typeName = "defined online"; - $types = $this->query( - './xsd:complexType | ./xsd:simpleType', - $node - ); - } - if($types->length == 0) throw new maarch\Exception("Type $typeName not found for " . $node->tagName . " " . $node->getAttribute('name')); - $type = $types->item(0); - // $this->addXRefs($node, 'type', $type); - //} - - return $type; - } - - protected function addBuiltInType($typeName) - { - $builtInType = $this->schema->createElement('xsd:simpleType'); - $builtInType->setAttribute('name', $typeName); - - // Define if enclosed or not - $nonEnclosedTypes = array( - 'xsd:float', - 'xsd:double', - 'xsd:decimal', - 'xsd:integer', - 'xsd:nonPositiveInteger', - 'xsd:negativeInteger', - 'xsd:long', - 'xsd:int', - 'xsd:short', - 'xsd:byte', - 'xsd:nonNegativeInteger', - 'xsd:positiveInteger', - 'xsd:unsignedLong', - 'xsd:unsignedInt', - 'xsd:unsignedShort', - 'xsd:unsignedByte', - 'xsd:boolean', - ); - $enclosedTypes = array( - 'xsd:string', - 'xsd:normalizedString', - 'xsd:token', - 'xsd:language', - 'xsd:name', - 'xsd:NCName', - 'xsd:ID', - 'xsd:IDREF', - 'xsd:ENTITY', - 'xsd:NMTOKEN', - 'xsd:QNAME', - 'xsd:NOTATION', - 'xsd:date', - 'xsd:time', - 'xsd:datetime', - 'xsd:gYear', - 'xsd:gYearMonth', - 'xsd:gMonth', - 'xsd:gMonthDay', - 'xsd:gDay', - 'xsd:duration', - 'xsd:base64binary', - 'xsd:hexBinary', - 'xsd:anyURI', - ); - - if(!in_array($typeName, $nonEnclosedTypes)) { - $builtInType->setAttribute('das:enclosed', 'true'); - } - $this->schema->appendChild($builtInType); - } - - protected function getView($element) - { - if($element->hasAttribute('das:view')) { - $viewName = $element->getAttribute('das:view'); - $views = - $this->query('//xsd:annotation/xsd:appinfo/das:view[@name="' - . $viewName - . '"]'); - if($views->length == 0) throw new maarch\Exception("Referenced view $viewName not found"); - return $views->item(0); - } elseif($views = $this->query('./xsd:annotation/xsd:appinfo/das:view', $element)) { - return $views->item(0); - } - } - - protected function getRelation( - $objectElement, - $dataObject - ) { - $relations = $this->query( - '//xsd:annotation/xsd:appinfo/das:relation[' - . '@parent="' . $dataObject->tagName - . '" and @child="' . $objectElement->getName() - . '"]' - ); - if($relations->length == 0) return false; - return $relations->item(0); - } - - protected function getAttributes($node) - { - $attributes = $this->query('./xsd:attribute', $node); - if($attributes->length == 0) return false; - return $attributes; - } - - protected function getGroup($node) - { - $groups = $this->query('./xsd:group', $node); - if($groups->length == 0) return false; - return $groups->item(0); - } - - protected function getSequence($node) - { - $sequences = $this->query('./xsd:sequence', $node); - if($sequences->length == 0) return false; - return $sequences->item(0); - } - - protected function getAll($node) - { - $alls = $this->query('./xsd:all', $node); - if($alls->length == 0) return false; - return $alls->item(0); - } - - protected function getAny($node) - { - $anys = $this->query('./xsd:any', $node); - if($anys->length == 0) return false; - return $anys->item(0); - } - - protected function getElements($node) - { - $elements = $this->query('./xsd:element', $node); - return $elements; - } - - protected function getQuery($node) - { - if($node->hasAttribute('das:query')) { - $queryName = $node->getAttribute('das:query'); - $queryNode = $this->query( - '//das:query[@name="' - . $queryName - . '"]' - )->item(0); - return $queryNode; - } elseif( - $queryNode = $this->query( - './xsd:annotation/xsd:appinfo/das:query' - , $node - )->item(0) - ) { - return $queryNode; - } - } - - - //************************************************************************* - // PARSE TYPE - //************************************************************************* - public function getObjectContents($objectElement) - { - if(!$objectContents = - $this->getXRefs($objectElement, 'contents') - ) { - $objectContents = array(); - $objectElement = $this->getRefNode($objectElement); - $objectType = $this->getType($objectElement); - $objectContents = $this->getTypeContents($objectType); - $this->addXRefs( - $objectElement, - 'contents', - $objectContents - ); - } - return $objectContents; - } - - public function getTypeContents($type) - { - $typeContents = array(); - $typeChildren = $type->childNodes; - $l = $typeChildren->length; - for($i=0; $i<$l; $i++) { - $typeChild = $typeChildren->item($i); - switch($typeChild->tagName) { - // complexTypes - case 'xsd:group': - break; - - case 'xsd:all': - break; - - case 'xsd:choice': - break; - - case 'xsd:sequence': - $sequenceElements = - $this->getSequenceElements( - $typeChild - ); - - $typeContents = - array_merge( - $typeContents, - $sequenceElements - ); - break; - - case 'xsd:attribute': - $typeContents[] = $typeChild; - break; - - case 'xsd:attributeGroup': - break; - - case 'xsd:anyAttribute': - break; - } - } - return $typeContents; - } - - protected function getSequenceElements($sequence) - { - $sequenceElements = array(); - //any, choice, element, group, sequence - $sequenceChildren = $sequence->childNodes; - $l = $sequenceChildren->length; - for($i=0; $i<$l; $i++) { - $sequenceChild = $sequenceChildren->item($i); - switch($sequenceChild->tagName) { - case 'xsd:element': - $sequenceElements[] = $sequenceChild; - break; - - case 'xsd:any': - break; - - case 'xsd:choice': - break; - - case 'xsd:sequence': - $sequenceSequenceElements = - $this->getSequenceElements( - $sequenceChild - ); - $sequenceElements = - array_merge( - $sequenceElements, - $sequenceSequenceElements - ); - break; - } - } - return $sequenceElements; - } - - //************************************************************************* - // CROSSED REFERENCES - //************************************************************************* - protected function getXRefs($element, $queryTag) - { - //echo "<br/>get XRefs[" . $element->tagName . "][".$element->getName()."][$queryTag] => "; - $XRefs = $this->XRefs[$element->tagName][$element->getName()][$queryTag]; - //echo count($XRefs); - return $XRefs; - } - - protected function addXRefs($element, $queryTag, $XRefs) - { - //echo "<br/>add XRefs[" . $element->tagName . "][".$element->getName()."][$queryTag] => " . count($XRefs); - $this->XRefs[$element->tagName][$element->getName()][$queryTag] = $XRefs; - } - - -} diff --git a/core/trunk/core/tests/class/Exception.php b/core/trunk/core/tests/class/Exception.php deleted file mode 100644 index 85f46e54e5ba2942af4bb7be98c3218b90e594bb..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/Exception.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -namespace maarch; -class Exception - extends \Exception -{ - - public $id; - public $level; - public $message; - - public function Exception($message, $code=false) - { - if(is_object($message) && get_class($message) == 'Message') { - parent::__construct($message->message, $code); - $this->id = $message->id; - $this->level = $message->level; - } else { - parent::__construct($message, $code); - $this->level = $level; - } - } - -} \ No newline at end of file diff --git a/core/trunk/core/tests/class/LibXMLError_parser.php b/core/trunk/core/tests/class/LibXMLError_parser.php deleted file mode 100644 index 64d0a3e5c2d0ba8b7900627ac2a42e44695fb748..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/LibXMLError_parser.php +++ /dev/null @@ -1,870 +0,0 @@ -<?php - -class LibXMLError_parser -{ - private $domains = array( - 0 => array('libxml_constant' => 'XML_FROM_NONE', 'name' => ''), - 1 => array('libxml_constant' => 'XML_FROM_PARSER', 'name' => 'XML parser'), - 2 => array('libxml_constant' => 'XML_FROM_TREE', 'name' => 'Tree module'), - 3 => array('libxml_constant' => 'XML_FROM_NAMESPACE ', 'name' => 'XML Namespace module'), - 4 => array('libxml_constant' => 'XML_FROM_DTD', 'name' => 'XML DTD validation with parser context'), - 5 => array('libxml_constant' => 'XML_FROM_HTML', 'name' => 'HTML parser'), - 6 => array('libxml_constant' => 'XML_FROM_MEMORY', 'name' => 'Memory allocator'), - 7 => array('libxml_constant' => 'XML_FROM_OUTPUT', 'name' => 'Serialization code'), - 8 => array('libxml_constant' => 'XML_FROM_IO', 'name' => 'Input/Output stack'), - 9 => array('libxml_constant' => 'XML_FROM_FTP', 'name' => 'FTP module'), - 10 => array('libxml_constant' => 'XML_FROM_HTTP', 'name' => 'HTTP module'), - 11 => array('libxml_constant' => 'XML_FROM_XINCLUDE', 'name' => 'XInclude processing'), - 12 => array('libxml_constant' => 'XML_FROM_XPATH', 'name' => 'XPath module'), - 13 => array('libxml_constant' => 'XML_FROM_XPOINTER', 'name' => 'XPointer module'), - 14 => array('libxml_constant' => 'XML_FROM_REGEXP', 'name' => 'Regular expressions module'), - 15 => array('libxml_constant' => 'XML_FROM_DATATYPE', 'name' => 'W3C XML Schemas Datatype module'), - 16 => array('libxml_constant' => 'XML_FROM_SCHEMASP', 'name' => 'W3C XML Schemas parser module'), - 17 => array('libxml_constant' => 'XML_FROM_SCHEMASV', 'name' => 'W3C XML Schemas validation module'), - 18 => array('libxml_constant' => 'XML_FROM_RELAXNGP', 'name' => 'Relax-NG parser module'), - 19 => array('libxml_constant' => 'XML_FROM_RELAXNGV', 'name' => 'Relax-NG validator module'), - 20 => array('libxml_constant' => 'XML_FROM_CATALOG', 'name' => 'Catalog module'), - 21 => array('libxml_constant' => 'XML_FROM_C14N', 'name' => 'Canonicalization module'), - 22 => array('libxml_constant' => 'XML_FROM_XSLT', 'name' => 'XSLT engine from libxslt'), - 23 => array('libxml_constant' => 'XML_FROM_VALID', 'name' => 'XML DTD validation with valid context'), - 24 => array('libxml_constant' => 'XML_FROM_CHECK', 'name' => 'Error checking module'), - 25 => array('libxml_constant' => 'XML_FROM_WRITER', 'name' => 'xmlwriter module'), - 26 => array('libxml_constant' => 'XML_FROM_MODULE', 'name' => 'dynamically loaded module module'), - 27 => array('libxml_constant' => 'XML_FROM_I18N', 'name' => 'module handling character conversion'), - 28 => array('libxml_constant' => 'XML_FROM_SCHEMATRONV', 'name' => 'Schematron validator module'), - 29 => array('libxml_constant' => 'XML_FROM_BUFFER', 'name' => 'Buffers module'), - 30 => array('libxml_constant' => 'XML_FROM_URI', 'name' => 'URI module'), - ); - - private $errors = array( - 0 => array('libxml_constant' => 'XML_ERR_OK', 'description' => ''), - 1 => array('libxml_constant' => 'XML_ERR_INTERNAL_ERROR', 'description' => ''), - 2 => array('libxml_constant' => 'XML_ERR_NO_MEMORY', 'description' => ''), - 3 => array('libxml_constant' => 'XML_ERR_DOCUMENT_START', 'description' => ''), - 4 => array('libxml_constant' => 'XML_ERR_DOCUMENT_EMPTY', 'description' => ''), - 5 => array('libxml_constant' => 'XML_ERR_DOCUMENT_END', 'description' => ''), - 6 => array('libxml_constant' => 'XML_ERR_INVALID_HEX_CHARREF', 'description' => ''), - 7 => array('libxml_constant' => 'XML_ERR_INVALID_DEC_CHARREF', 'description' => ''), - 8 => array('libxml_constant' => 'XML_ERR_INVALID_CHARREF', 'description' => ''), - 9 => array('libxml_constant' => 'XML_ERR_INVALID_CHAR', 'description' => ''), - 10 => array('libxml_constant' => 'XML_ERR_CHARREF_AT_EOF', 'description' => ''), - 11 => array('libxml_constant' => 'XML_ERR_CHARREF_IN_PROLOG', 'description' => ''), - 12 => array('libxml_constant' => 'XML_ERR_CHARREF_IN_EPILOG', 'description' => ''), - 13 => array('libxml_constant' => 'XML_ERR_CHARREF_IN_DTD', 'description' => ''), - 14 => array('libxml_constant' => 'XML_ERR_ENTITYREF_AT_EOF', 'description' => ''), - 15 => array('libxml_constant' => 'XML_ERR_ENTITYREF_IN_PROLOG', 'description' => ''), - 16 => array('libxml_constant' => 'XML_ERR_ENTITYREF_IN_EPILOG', 'description' => ''), - 17 => array('libxml_constant' => 'XML_ERR_ENTITYREF_IN_DTD', 'description' => ''), - 18 => array('libxml_constant' => 'XML_ERR_PEREF_AT_EOF', 'description' => ''), - 19 => array('libxml_constant' => 'XML_ERR_PEREF_IN_PROLOG', 'description' => ''), - 20 => array('libxml_constant' => 'XML_ERR_PEREF_IN_EPILOG', 'description' => ''), - 21 => array('libxml_constant' => 'XML_ERR_PEREF_IN_INT_SUBSET', 'description' => ''), - 22 => array('libxml_constant' => 'XML_ERR_ENTITYREF_NO_NAME', 'description' => ''), - 23 => array('libxml_constant' => 'XML_ERR_ENTITYREF_SEMICOL_MISSING', 'description' => ''), - 24 => array('libxml_constant' => 'XML_ERR_PEREF_NO_NAME', 'description' => ''), - 25 => array('libxml_constant' => 'XML_ERR_PEREF_SEMICOL_MISSING', 'description' => ''), - 26 => array('libxml_constant' => 'XML_ERR_UNDECLARED_ENTITY', 'description' => ''), - 27 => array('libxml_constant' => 'XML_WAR_UNDECLARED_ENTITY', 'description' => ''), - 28 => array('libxml_constant' => 'XML_ERR_UNPARSED_ENTITY', 'description' => ''), - 29 => array('libxml_constant' => 'XML_ERR_ENTITY_IS_EXTERNAL', 'description' => ''), - 30 => array('libxml_constant' => 'XML_ERR_ENTITY_IS_PARAMETER', 'description' => ''), - 31 => array('libxml_constant' => 'XML_ERR_UNKNOWN_ENCODING', 'description' => ''), - 32 => array('libxml_constant' => 'XML_ERR_UNSUPPORTED_ENCODING', 'description' => ''), - 33 => array('libxml_constant' => 'XML_ERR_STRING_NOT_STARTED', 'description' => ''), - 34 => array('libxml_constant' => 'XML_ERR_STRING_NOT_CLOSED', 'description' => ''), - 35 => array('libxml_constant' => 'XML_ERR_NS_DECL_ERROR', 'description' => ''), - 36 => array('libxml_constant' => 'XML_ERR_ENTITY_NOT_STARTED', 'description' => ''), - 37 => array('libxml_constant' => 'XML_ERR_ENTITY_NOT_FINISHED', 'description' => ''), - 38 => array('libxml_constant' => 'XML_ERR_LT_IN_ATTRIBUTE', 'description' => ''), - 39 => array('libxml_constant' => 'XML_ERR_ATTRIBUTE_NOT_STARTED', 'description' => ''), - 40 => array('libxml_constant' => 'XML_ERR_ATTRIBUTE_NOT_FINISHED', 'description' => ''), - 41 => array('libxml_constant' => 'XML_ERR_ATTRIBUTE_WITHOUT_VALUE', 'description' => ''), - 42 => array('libxml_constant' => 'XML_ERR_ATTRIBUTE_REDEFINED', 'description' => ''), - 43 => array('libxml_constant' => 'XML_ERR_LITERAL_NOT_STARTED', 'description' => ''), - 44 => array('libxml_constant' => 'XML_ERR_LITERAL_NOT_FINISHED', 'description' => ''), - 45 => array('libxml_constant' => 'XML_ERR_COMMENT_NOT_FINISHED', 'description' => ''), - 46 => array('libxml_constant' => 'XML_ERR_PI_NOT_STARTED', 'description' => ''), - 47 => array('libxml_constant' => 'XML_ERR_PI_NOT_FINISHED', 'description' => ''), - 48 => array('libxml_constant' => 'XML_ERR_NOTATION_NOT_STARTED', 'description' => ''), - 49 => array('libxml_constant' => 'XML_ERR_NOTATION_NOT_FINISHED', 'description' => ''), - 50 => array('libxml_constant' => 'XML_ERR_ATTLIST_NOT_STARTED', 'description' => ''), - 51 => array('libxml_constant' => 'XML_ERR_ATTLIST_NOT_FINISHED', 'description' => ''), - 52 => array('libxml_constant' => 'XML_ERR_MIXED_NOT_STARTED', 'description' => ''), - 53 => array('libxml_constant' => 'XML_ERR_MIXED_NOT_FINISHED', 'description' => ''), - 54 => array('libxml_constant' => 'XML_ERR_ELEMCONTENT_NOT_STARTED', 'description' => ''), - 55 => array('libxml_constant' => 'XML_ERR_ELEMCONTENT_NOT_FINISHED', 'description' => ''), - 56 => array('libxml_constant' => 'XML_ERR_XMLDECL_NOT_STARTED', 'description' => ''), - 57 => array('libxml_constant' => 'XML_ERR_XMLDECL_NOT_FINISHED', 'description' => ''), - 58 => array('libxml_constant' => 'XML_ERR_CONDSEC_NOT_STARTED', 'description' => ''), - 59 => array('libxml_constant' => 'XML_ERR_CONDSEC_NOT_FINISHED', 'description' => ''), - 60 => array('libxml_constant' => 'XML_ERR_EXT_SUBSET_NOT_FINISHED', 'description' => ''), - 61 => array('libxml_constant' => 'XML_ERR_DOCTYPE_NOT_FINISHED', 'description' => ''), - 62 => array('libxml_constant' => 'XML_ERR_MISPLACED_CDATA_END', 'description' => ''), - 63 => array('libxml_constant' => 'XML_ERR_CDATA_NOT_FINISHED', 'description' => ''), - 64 => array('libxml_constant' => 'XML_ERR_RESERVED_XML_NAME', 'description' => ''), - 65 => array('libxml_constant' => 'XML_ERR_SPACE_REQUIRED', 'description' => ''), - 66 => array('libxml_constant' => 'XML_ERR_SEPARATOR_REQUIRED', 'description' => ''), - 67 => array('libxml_constant' => 'XML_ERR_NMTOKEN_REQUIRED', 'description' => ''), - 68 => array('libxml_constant' => 'XML_ERR_NAME_REQUIRED', 'description' => ''), - 69 => array('libxml_constant' => 'XML_ERR_PCDATA_REQUIRED', 'description' => ''), - 70 => array('libxml_constant' => 'XML_ERR_URI_REQUIRED', 'description' => ''), - 71 => array('libxml_constant' => 'XML_ERR_PUBID_REQUIRED', 'description' => ''), - 72 => array('libxml_constant' => 'XML_ERR_LT_REQUIRED', 'description' => ''), - 73 => array('libxml_constant' => 'XML_ERR_GT_REQUIRED', 'description' => ''), - 74 => array('libxml_constant' => 'XML_ERR_LTSLASH_REQUIRED', 'description' => ''), - 75 => array('libxml_constant' => 'XML_ERR_EQUAL_REQUIRED', 'description' => ''), - 76 => array('libxml_constant' => 'XML_ERR_TAG_NAME_MISMATCH', 'description' => ''), - 77 => array('libxml_constant' => 'XML_ERR_TAG_NOT_FINISHED', 'description' => ''), - 78 => array('libxml_constant' => 'XML_ERR_STANDALONE_VALUE', 'description' => ''), - 79 => array('libxml_constant' => 'XML_ERR_ENCODING_NAME', 'description' => ''), - 80 => array('libxml_constant' => 'XML_ERR_HYPHEN_IN_COMMENT', 'description' => ''), - 81 => array('libxml_constant' => 'XML_ERR_INVALID_ENCODING', 'description' => ''), - 82 => array('libxml_constant' => 'XML_ERR_EXT_ENTITY_STANDALONE', 'description' => ''), - 83 => array('libxml_constant' => 'XML_ERR_CONDSEC_INVALID', 'description' => ''), - 84 => array('libxml_constant' => 'XML_ERR_VALUE_REQUIRED', 'description' => ''), - 85 => array('libxml_constant' => 'XML_ERR_NOT_WELL_BALANCED', 'description' => ''), - 86 => array('libxml_constant' => 'XML_ERR_EXTRA_CONTENT', 'description' => ''), - 87 => array('libxml_constant' => 'XML_ERR_ENTITY_CHAR_ERROR', 'description' => ''), - 88 => array('libxml_constant' => 'XML_ERR_ENTITY_PE_INTERNAL', 'description' => ''), - 89 => array('libxml_constant' => 'XML_ERR_ENTITY_LOOP', 'description' => ''), - 90 => array('libxml_constant' => 'XML_ERR_ENTITY_BOUNDARY', 'description' => ''), - 91 => array('libxml_constant' => 'XML_ERR_INVALID_URI', 'description' => ''), - 92 => array('libxml_constant' => 'XML_ERR_URI_FRAGMENT', 'description' => ''), - 93 => array('libxml_constant' => 'XML_WAR_CATALOG_PI', 'description' => ''), - 94 => array('libxml_constant' => 'XML_ERR_NO_DTD', 'description' => ''), - 95 => array('libxml_constant' => 'XML_ERR_CONDSEC_INVALID_KEYWORD', 'description' => ''), - 96 => array('libxml_constant' => 'XML_ERR_VERSION_MISSING', 'description' => ''), - 97 => array('libxml_constant' => 'XML_WAR_UNKNOWN_VERSION', 'description' => ''), - 98 => array('libxml_constant' => 'XML_WAR_LANG_VALUE', 'description' => ''), - 99 => array('libxml_constant' => 'XML_WAR_NS_URI', 'description' => ''), - 100 => array('libxml_constant' => 'XML_WAR_NS_URI_RELATIVE', 'description' => ''), - 101 => array('libxml_constant' => 'XML_ERR_MISSING_ENCODING', 'description' => ''), - 102 => array('libxml_constant' => 'XML_WAR_SPACE_VALUE', 'description' => ''), - 103 => array('libxml_constant' => 'XML_ERR_NOT_STANDALONE', 'description' => ''), - 104 => array('libxml_constant' => 'XML_ERR_ENTITY_PROCESSING', 'description' => ''), - 105 => array('libxml_constant' => 'XML_ERR_NOTATION_PROCESSING', 'description' => ''), - 106 => array('libxml_constant' => 'XML_WAR_NS_COLUMN', 'description' => ''), - 107 => array('libxml_constant' => 'XML_WAR_ENTITY_REDEFINED', 'description' => ''), - 108 => array('libxml_constant' => 'XML_ERR_UNKNOWN_VERSION', 'description' => ''), - 109 => array('libxml_constant' => 'XML_ERR_VERSION_MISMATCH', 'description' => ''), - 110 => array('libxml_constant' => 'XML_ERR_NAME_TOO_LONG', 'description' => ''), - 200 => array('libxml_constant' => 'XML_NS_ERR_XML_NAMESPACE', 'description' => ''), - 201 => array('libxml_constant' => 'XML_NS_ERR_UNDEFINED_NAMESPACE', 'description' => ''), - 202 => array('libxml_constant' => 'XML_NS_ERR_QNAME', 'description' => ''), - 203 => array('libxml_constant' => 'XML_NS_ERR_ATTRIBUTE_REDEFINED', 'description' => ''), - 204 => array('libxml_constant' => 'XML_NS_ERR_EMPTY', 'description' => ''), - 205 => array('libxml_constant' => 'XML_NS_ERR_COLON', 'description' => ''), - 500 => array('libxml_constant' => 'XML_DTD_ATTRIBUTE_DEFAULT', 'description' => ''), - 501 => array('libxml_constant' => 'XML_DTD_ATTRIBUTE_REDEFINED', 'description' => ''), - 502 => array('libxml_constant' => 'XML_DTD_ATTRIBUTE_VALUE', 'description' => ''), - 503 => array('libxml_constant' => 'XML_DTD_CONTENT_ERROR', 'description' => ''), - 504 => array('libxml_constant' => 'XML_DTD_CONTENT_MODEL', 'description' => ''), - 505 => array('libxml_constant' => 'XML_DTD_CONTENT_NOT_DETERMINIST', 'description' => ''), - 506 => array('libxml_constant' => 'XML_DTD_DIFFERENT_PREFIX', 'description' => ''), - 507 => array('libxml_constant' => 'XML_DTD_ELEM_DEFAULT_NAMESPACE', 'description' => ''), - 508 => array('libxml_constant' => 'XML_DTD_ELEM_NAMESPACE', 'description' => ''), - 509 => array('libxml_constant' => 'XML_DTD_ELEM_REDEFINED', 'description' => ''), - 510 => array('libxml_constant' => 'XML_DTD_EMPTY_NOTATION', 'description' => ''), - 511 => array('libxml_constant' => 'XML_DTD_ENTITY_TYPE', 'description' => ''), - 512 => array('libxml_constant' => 'XML_DTD_ID_FIXED', 'description' => ''), - 513 => array('libxml_constant' => 'XML_DTD_ID_REDEFINED', 'description' => ''), - 514 => array('libxml_constant' => 'XML_DTD_ID_SUBSET', 'description' => ''), - 515 => array('libxml_constant' => 'XML_DTD_INVALID_CHILD', 'description' => ''), - 516 => array('libxml_constant' => 'XML_DTD_INVALID_DEFAULT', 'description' => ''), - 517 => array('libxml_constant' => 'XML_DTD_LOAD_ERROR', 'description' => ''), - 518 => array('libxml_constant' => 'XML_DTD_MISSING_ATTRIBUTE', 'description' => ''), - 519 => array('libxml_constant' => 'XML_DTD_MIXED_CORRUPT', 'description' => ''), - 520 => array('libxml_constant' => 'XML_DTD_MULTIPLE_ID', 'description' => ''), - 521 => array('libxml_constant' => 'XML_DTD_NO_DOC', 'description' => ''), - 522 => array('libxml_constant' => 'XML_DTD_NO_DTD', 'description' => ''), - 523 => array('libxml_constant' => 'XML_DTD_NO_ELEM_NAME', 'description' => ''), - 524 => array('libxml_constant' => 'XML_DTD_NO_PREFIX', 'description' => ''), - 525 => array('libxml_constant' => 'XML_DTD_NO_ROOT', 'description' => ''), - 526 => array('libxml_constant' => 'XML_DTD_NOTATION_REDEFINED', 'description' => ''), - 527 => array('libxml_constant' => 'XML_DTD_NOTATION_VALUE', 'description' => ''), - 528 => array('libxml_constant' => 'XML_DTD_NOT_EMPTY', 'description' => ''), - 529 => array('libxml_constant' => 'XML_DTD_NOT_PCDATA', 'description' => ''), - 530 => array('libxml_constant' => 'XML_DTD_NOT_STANDALONE', 'description' => ''), - 531 => array('libxml_constant' => 'XML_DTD_ROOT_NAME', 'description' => ''), - 532 => array('libxml_constant' => 'XML_DTD_STANDALONE_WHITE_SPACE', 'description' => ''), - 533 => array('libxml_constant' => 'XML_DTD_UNKNOWN_ATTRIBUTE', 'description' => ''), - 534 => array('libxml_constant' => 'XML_DTD_UNKNOWN_ELEM', 'description' => ''), - 535 => array('libxml_constant' => 'XML_DTD_UNKNOWN_ENTITY', 'description' => ''), - 536 => array('libxml_constant' => 'XML_DTD_UNKNOWN_ID', 'description' => ''), - 537 => array('libxml_constant' => 'XML_DTD_UNKNOWN_NOTATION', 'description' => ''), - 538 => array('libxml_constant' => 'XML_DTD_STANDALONE_DEFAULTED', 'description' => ''), - 539 => array('libxml_constant' => 'XML_DTD_XMLID_VALUE', 'description' => ''), - 540 => array('libxml_constant' => 'XML_DTD_XMLID_TYPE', 'description' => ''), - 541 => array('libxml_constant' => 'XML_DTD_DUP_TOKEN', 'description' => ''), - 800 => array('libxml_constant' => 'XML_HTML_STRUCURE_ERROR', 'description' => ''), - 801 => array('libxml_constant' => 'XML_HTML_UNKNOWN_TAG', 'description' => ''), - 1000 => array('libxml_constant' => 'XML_RNGP_ANYNAME_ATTR_ANCESTOR', 'description' => ''), - 1001 => array('libxml_constant' => 'XML_RNGP_ATTR_CONFLICT', 'description' => ''), - 1002 => array('libxml_constant' => 'XML_RNGP_ATTRIBUTE_CHILDREN', 'description' => ''), - 1003 => array('libxml_constant' => 'XML_RNGP_ATTRIBUTE_CONTENT', 'description' => ''), - 1004 => array('libxml_constant' => 'XML_RNGP_ATTRIBUTE_EMPTY', 'description' => ''), - 1005 => array('libxml_constant' => 'XML_RNGP_ATTRIBUTE_NOOP', 'description' => ''), - 1006 => array('libxml_constant' => 'XML_RNGP_CHOICE_CONTENT', 'description' => ''), - 1007 => array('libxml_constant' => 'XML_RNGP_CHOICE_EMPTY', 'description' => ''), - 1008 => array('libxml_constant' => 'XML_RNGP_CREATE_FAILURE', 'description' => ''), - 1009 => array('libxml_constant' => 'XML_RNGP_DATA_CONTENT', 'description' => ''), - 1010 => array('libxml_constant' => 'XML_RNGP_DEF_CHOICE_AND_INTERLEAVE', 'description' => ''), - 1011 => array('libxml_constant' => 'XML_RNGP_DEFINE_CREATE_FAILED', 'description' => ''), - 1012 => array('libxml_constant' => 'XML_RNGP_DEFINE_EMPTY', 'description' => ''), - 1013 => array('libxml_constant' => 'XML_RNGP_DEFINE_MISSING', 'description' => ''), - 1014 => array('libxml_constant' => 'XML_RNGP_DEFINE_NAME_MISSING', 'description' => ''), - 1015 => array('libxml_constant' => 'XML_RNGP_ELEM_CONTENT_EMPTY', 'description' => ''), - 1016 => array('libxml_constant' => 'XML_RNGP_ELEM_CONTENT_ERROR', 'description' => ''), - 1017 => array('libxml_constant' => 'XML_RNGP_ELEMENT_EMPTY', 'description' => ''), - 1018 => array('libxml_constant' => 'XML_RNGP_ELEMENT_CONTENT', 'description' => ''), - 1019 => array('libxml_constant' => 'XML_RNGP_ELEMENT_NAME', 'description' => ''), - 1020 => array('libxml_constant' => 'XML_RNGP_ELEMENT_NO_CONTENT', 'description' => ''), - 1021 => array('libxml_constant' => 'XML_RNGP_ELEM_TEXT_CONFLICT', 'description' => ''), - 1022 => array('libxml_constant' => 'XML_RNGP_EMPTY', 'description' => ''), - 1023 => array('libxml_constant' => 'XML_RNGP_EMPTY_CONSTRUCT', 'description' => ''), - 1024 => array('libxml_constant' => 'XML_RNGP_EMPTY_CONTENT', 'description' => ''), - 1025 => array('libxml_constant' => 'XML_RNGP_EMPTY_NOT_EMPTY', 'description' => ''), - 1026 => array('libxml_constant' => 'XML_RNGP_ERROR_TYPE_LIB', 'description' => ''), - 1027 => array('libxml_constant' => 'XML_RNGP_EXCEPT_EMPTY', 'description' => ''), - 1028 => array('libxml_constant' => 'XML_RNGP_EXCEPT_MISSING', 'description' => ''), - 1029 => array('libxml_constant' => 'XML_RNGP_EXCEPT_MULTIPLE', 'description' => ''), - 1030 => array('libxml_constant' => 'XML_RNGP_EXCEPT_NO_CONTENT', 'description' => ''), - 1031 => array('libxml_constant' => 'XML_RNGP_EXTERNALREF_EMTPY', 'description' => ''), - 1032 => array('libxml_constant' => 'XML_RNGP_EXTERNAL_REF_FAILURE', 'description' => ''), - 1033 => array('libxml_constant' => 'XML_RNGP_EXTERNALREF_RECURSE', 'description' => ''), - 1034 => array('libxml_constant' => 'XML_RNGP_FORBIDDEN_ATTRIBUTE', 'description' => ''), - 1035 => array('libxml_constant' => 'XML_RNGP_FOREIGN_ELEMENT', 'description' => ''), - 1036 => array('libxml_constant' => 'XML_RNGP_GRAMMAR_CONTENT', 'description' => ''), - 1037 => array('libxml_constant' => 'XML_RNGP_GRAMMAR_EMPTY', 'description' => ''), - 1038 => array('libxml_constant' => 'XML_RNGP_GRAMMAR_MISSING', 'description' => ''), - 1039 => array('libxml_constant' => 'XML_RNGP_GRAMMAR_NO_START', 'description' => ''), - 1040 => array('libxml_constant' => 'XML_RNGP_GROUP_ATTR_CONFLICT', 'description' => ''), - 1041 => array('libxml_constant' => 'XML_RNGP_HREF_ERROR', 'description' => ''), - 1042 => array('libxml_constant' => 'XML_RNGP_INCLUDE_EMPTY', 'description' => ''), - 1043 => array('libxml_constant' => 'XML_RNGP_INCLUDE_FAILURE', 'description' => ''), - 1044 => array('libxml_constant' => 'XML_RNGP_INCLUDE_RECURSE', 'description' => ''), - 1045 => array('libxml_constant' => 'XML_RNGP_INTERLEAVE_ADD', 'description' => ''), - 1046 => array('libxml_constant' => 'XML_RNGP_INTERLEAVE_CREATE_FAILED', 'description' => ''), - 1047 => array('libxml_constant' => 'XML_RNGP_INTERLEAVE_EMPTY', 'description' => ''), - 1048 => array('libxml_constant' => 'XML_RNGP_INTERLEAVE_NO_CONTENT', 'description' => ''), - 1049 => array('libxml_constant' => 'XML_RNGP_INVALID_DEFINE_NAME', 'description' => ''), - 1050 => array('libxml_constant' => 'XML_RNGP_INVALID_URI', 'description' => ''), - 1051 => array('libxml_constant' => 'XML_RNGP_INVALID_VALUE', 'description' => ''), - 1052 => array('libxml_constant' => 'XML_RNGP_MISSING_HREF', 'description' => ''), - 1053 => array('libxml_constant' => 'XML_RNGP_NAME_MISSING', 'description' => ''), - 1054 => array('libxml_constant' => 'XML_RNGP_NEED_COMBINE', 'description' => ''), - 1055 => array('libxml_constant' => 'XML_RNGP_NOTALLOWED_NOT_EMPTY', 'description' => ''), - 1056 => array('libxml_constant' => 'XML_RNGP_NSNAME_ATTR_ANCESTOR', 'description' => ''), - 1057 => array('libxml_constant' => 'XML_RNGP_NSNAME_NO_NS', 'description' => ''), - 1058 => array('libxml_constant' => 'XML_RNGP_PARAM_FORBIDDEN', 'description' => ''), - 1059 => array('libxml_constant' => 'XML_RNGP_PARAM_NAME_MISSING', 'description' => ''), - 1060 => array('libxml_constant' => 'XML_RNGP_PARENTREF_CREATE_FAILED', 'description' => ''), - 1061 => array('libxml_constant' => 'XML_RNGP_PARENTREF_NAME_INVALID', 'description' => ''), - 1062 => array('libxml_constant' => 'XML_RNGP_PARENTREF_NO_NAME', 'description' => ''), - 1063 => array('libxml_constant' => 'XML_RNGP_PARENTREF_NO_PARENT', 'description' => ''), - 1064 => array('libxml_constant' => 'XML_RNGP_PARENTREF_NOT_EMPTY', 'description' => ''), - 1065 => array('libxml_constant' => 'XML_RNGP_PARSE_ERROR', 'description' => ''), - 1066 => array('libxml_constant' => 'XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME', 'description' => ''), - 1067 => array('libxml_constant' => 'XML_RNGP_PAT_ATTR_ATTR', 'description' => ''), - 1068 => array('libxml_constant' => 'XML_RNGP_PAT_ATTR_ELEM', 'description' => ''), - 1069 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_ATTR', 'description' => ''), - 1070 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_ELEM', 'description' => ''), - 1071 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_EMPTY', 'description' => ''), - 1072 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_GROUP', 'description' => ''), - 1073 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE', 'description' => ''), - 1074 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_LIST', 'description' => ''), - 1075 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_ONEMORE', 'description' => ''), - 1076 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_REF', 'description' => ''), - 1077 => array('libxml_constant' => 'XML_RNGP_PAT_DATA_EXCEPT_TEXT', 'description' => ''), - 1078 => array('libxml_constant' => 'XML_RNGP_PAT_LIST_ATTR', 'description' => ''), - 1079 => array('libxml_constant' => 'XML_RNGP_PAT_LIST_ELEM', 'description' => ''), - 1080 => array('libxml_constant' => 'XML_RNGP_PAT_LIST_INTERLEAVE', 'description' => ''), - 1081 => array('libxml_constant' => 'XML_RNGP_PAT_LIST_LIST', 'description' => ''), - 1082 => array('libxml_constant' => 'XML_RNGP_PAT_LIST_REF', 'description' => ''), - 1083 => array('libxml_constant' => 'XML_RNGP_PAT_LIST_TEXT', 'description' => ''), - 1084 => array('libxml_constant' => 'XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME', 'description' => ''), - 1085 => array('libxml_constant' => 'XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME', 'description' => ''), - 1086 => array('libxml_constant' => 'XML_RNGP_PAT_ONEMORE_GROUP_ATTR', 'description' => ''), - 1087 => array('libxml_constant' => 'XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR', 'description' => ''), - 1088 => array('libxml_constant' => 'XML_RNGP_PAT_START_ATTR', 'description' => ''), - 1089 => array('libxml_constant' => 'XML_RNGP_PAT_START_DATA', 'description' => ''), - 1090 => array('libxml_constant' => 'XML_RNGP_PAT_START_EMPTY', 'description' => ''), - 1091 => array('libxml_constant' => 'XML_RNGP_PAT_START_GROUP', 'description' => ''), - 1092 => array('libxml_constant' => 'XML_RNGP_PAT_START_INTERLEAVE', 'description' => ''), - 1093 => array('libxml_constant' => 'XML_RNGP_PAT_START_LIST', 'description' => ''), - 1094 => array('libxml_constant' => 'XML_RNGP_PAT_START_ONEMORE', 'description' => ''), - 1095 => array('libxml_constant' => 'XML_RNGP_PAT_START_TEXT', 'description' => ''), - 1096 => array('libxml_constant' => 'XML_RNGP_PAT_START_VALUE', 'description' => ''), - 1097 => array('libxml_constant' => 'XML_RNGP_PREFIX_UNDEFINED', 'description' => ''), - 1098 => array('libxml_constant' => 'XML_RNGP_REF_CREATE_FAILED', 'description' => ''), - 1099 => array('libxml_constant' => 'XML_RNGP_REF_CYCLE', 'description' => ''), - 1100 => array('libxml_constant' => 'XML_RNGP_REF_NAME_INVALID', 'description' => ''), - 1101 => array('libxml_constant' => 'XML_RNGP_REF_NO_DEF', 'description' => ''), - 1102 => array('libxml_constant' => 'XML_RNGP_REF_NO_NAME', 'description' => ''), - 1103 => array('libxml_constant' => 'XML_RNGP_REF_NOT_EMPTY', 'description' => ''), - 1104 => array('libxml_constant' => 'XML_RNGP_START_CHOICE_AND_INTERLEAVE', 'description' => ''), - 1105 => array('libxml_constant' => 'XML_RNGP_START_CONTENT', 'description' => ''), - 1106 => array('libxml_constant' => 'XML_RNGP_START_EMPTY', 'description' => ''), - 1107 => array('libxml_constant' => 'XML_RNGP_START_MISSING', 'description' => ''), - 1108 => array('libxml_constant' => 'XML_RNGP_TEXT_EXPECTED', 'description' => ''), - 1109 => array('libxml_constant' => 'XML_RNGP_TEXT_HAS_CHILD', 'description' => ''), - 1110 => array('libxml_constant' => 'XML_RNGP_TYPE_MISSING', 'description' => ''), - 1111 => array('libxml_constant' => 'XML_RNGP_TYPE_NOT_FOUND', 'description' => ''), - 1112 => array('libxml_constant' => 'XML_RNGP_TYPE_VALUE', 'description' => ''), - 1113 => array('libxml_constant' => 'XML_RNGP_UNKNOWN_ATTRIBUTE', 'description' => ''), - 1114 => array('libxml_constant' => 'XML_RNGP_UNKNOWN_COMBINE', 'description' => ''), - 1115 => array('libxml_constant' => 'XML_RNGP_UNKNOWN_CONSTRUCT', 'description' => ''), - 1116 => array('libxml_constant' => 'XML_RNGP_UNKNOWN_TYPE_LIB', 'description' => ''), - 1117 => array('libxml_constant' => 'XML_RNGP_URI_FRAGMENT', 'description' => ''), - 1118 => array('libxml_constant' => 'XML_RNGP_URI_NOT_ABSOLUTE', 'description' => ''), - 1119 => array('libxml_constant' => 'XML_RNGP_VALUE_EMPTY', 'description' => ''), - 1120 => array('libxml_constant' => 'XML_RNGP_VALUE_NO_CONTENT', 'description' => ''), - 1121 => array('libxml_constant' => 'XML_RNGP_XMLNS_NAME', 'description' => ''), - 1122 => array('libxml_constant' => 'XML_RNGP_XML_NS', 'description' => ''), - 1200 => array('libxml_constant' => 'XML_XPATH_EXPRESSION_OK', 'description' => ''), - 1201 => array('libxml_constant' => 'XML_XPATH_NUMBER_ERROR', 'description' => ''), - 1202 => array('libxml_constant' => 'XML_XPATH_UNFINISHED_LITERAL_ERROR', 'description' => ''), - 1203 => array('libxml_constant' => 'XML_XPATH_START_LITERAL_ERROR', 'description' => ''), - 1204 => array('libxml_constant' => 'XML_XPATH_VARIABLE_REF_ERROR', 'description' => ''), - 1205 => array('libxml_constant' => 'XML_XPATH_UNDEF_VARIABLE_ERROR', 'description' => ''), - 1206 => array('libxml_constant' => 'XML_XPATH_INVALID_PREDICATE_ERROR', 'description' => ''), - 1207 => array('libxml_constant' => 'XML_XPATH_EXPR_ERROR', 'description' => ''), - 1208 => array('libxml_constant' => 'XML_XPATH_UNCLOSED_ERROR', 'description' => ''), - 1209 => array('libxml_constant' => 'XML_XPATH_UNKNOWN_FUNC_ERROR', 'description' => ''), - 1210 => array('libxml_constant' => 'XML_XPATH_INVALID_OPERAND', 'description' => ''), - 1211 => array('libxml_constant' => 'XML_XPATH_INVALID_TYPE', 'description' => ''), - 1212 => array('libxml_constant' => 'XML_XPATH_INVALID_ARITY', 'description' => ''), - 1213 => array('libxml_constant' => 'XML_XPATH_INVALID_CTXT_SIZE', 'description' => ''), - 1214 => array('libxml_constant' => 'XML_XPATH_INVALID_CTXT_POSITION', 'description' => ''), - 1215 => array('libxml_constant' => 'XML_XPATH_MEMORY_ERROR', 'description' => ''), - 1216 => array('libxml_constant' => 'XML_XPTR_SYNTAX_ERROR', 'description' => ''), - 1217 => array('libxml_constant' => 'XML_XPTR_RESOURCE_ERROR', 'description' => ''), - 1218 => array('libxml_constant' => 'XML_XPTR_SUB_RESOURCE_ERROR', 'description' => ''), - 1219 => array('libxml_constant' => 'XML_XPATH_UNDEF_PREFIX_ERROR', 'description' => ''), - 1220 => array('libxml_constant' => 'XML_XPATH_ENCODING_ERROR', 'description' => ''), - 1221 => array('libxml_constant' => 'XML_XPATH_INVALID_CHAR_ERROR', 'description' => ''), - 1300 => array('libxml_constant' => 'XML_TREE_INVALID_HEX', 'description' => ''), - 1301 => array('libxml_constant' => 'XML_TREE_INVALID_DEC', 'description' => ''), - 1302 => array('libxml_constant' => 'XML_TREE_UNTERMINATED_ENTITY', 'description' => ''), - 1303 => array('libxml_constant' => 'XML_TREE_NOT_UTF8', 'description' => ''), - 1400 => array('libxml_constant' => 'XML_SAVE_NOT_UTF8', 'description' => ''), - 1401 => array('libxml_constant' => 'XML_SAVE_CHAR_INVALID', 'description' => ''), - 1402 => array('libxml_constant' => 'XML_SAVE_NO_DOCTYPE', 'description' => ''), - 1403 => array('libxml_constant' => 'XML_SAVE_UNKNOWN_ENCODING', 'description' => ''), - 1450 => array('libxml_constant' => 'XML_REGEXP_COMPILE_ERROR', 'description' => ''), - 1500 => array('libxml_constant' => 'XML_IO_UNKNOWN', 'description' => ''), - 1501 => array('libxml_constant' => 'XML_IO_EACCES', 'description' => ''), - 1502 => array('libxml_constant' => 'XML_IO_EAGAIN', 'description' => ''), - 1503 => array('libxml_constant' => 'XML_IO_EBADF', 'description' => ''), - 1504 => array('libxml_constant' => 'XML_IO_EBADMSG', 'description' => ''), - 1505 => array('libxml_constant' => 'XML_IO_EBUSY', 'description' => ''), - 1506 => array('libxml_constant' => 'XML_IO_ECANCELED', 'description' => ''), - 1507 => array('libxml_constant' => 'XML_IO_ECHILD', 'description' => ''), - 1508 => array('libxml_constant' => 'XML_IO_EDEADLK', 'description' => ''), - 1509 => array('libxml_constant' => 'XML_IO_EDOM', 'description' => ''), - 1510 => array('libxml_constant' => 'XML_IO_EEXIST', 'description' => ''), - 1511 => array('libxml_constant' => 'XML_IO_EFAULT', 'description' => ''), - 1512 => array('libxml_constant' => 'XML_IO_EFBIG', 'description' => ''), - 1513 => array('libxml_constant' => 'XML_IO_EINPROGRESS', 'description' => ''), - 1514 => array('libxml_constant' => 'XML_IO_EINTR', 'description' => ''), - 1515 => array('libxml_constant' => 'XML_IO_EINVAL', 'description' => ''), - 1516 => array('libxml_constant' => 'XML_IO_EIO', 'description' => ''), - 1517 => array('libxml_constant' => 'XML_IO_EISDIR', 'description' => ''), - 1518 => array('libxml_constant' => 'XML_IO_EMFILE', 'description' => ''), - 1519 => array('libxml_constant' => 'XML_IO_EMLINK', 'description' => ''), - 1520 => array('libxml_constant' => 'XML_IO_EMSGSIZE', 'description' => ''), - 1521 => array('libxml_constant' => 'XML_IO_ENAMETOOLONG', 'description' => ''), - 1522 => array('libxml_constant' => 'XML_IO_ENFILE', 'description' => ''), - 1523 => array('libxml_constant' => 'XML_IO_ENODEV', 'description' => ''), - 1524 => array('libxml_constant' => 'XML_IO_ENOENT', 'description' => ''), - 1525 => array('libxml_constant' => 'XML_IO_ENOEXEC', 'description' => ''), - 1526 => array('libxml_constant' => 'XML_IO_ENOLCK', 'description' => ''), - 1527 => array('libxml_constant' => 'XML_IO_ENOMEM', 'description' => ''), - 1528 => array('libxml_constant' => 'XML_IO_ENOSPC', 'description' => ''), - 1529 => array('libxml_constant' => 'XML_IO_ENOSYS', 'description' => ''), - 1530 => array('libxml_constant' => 'XML_IO_ENOTDIR', 'description' => ''), - 1531 => array('libxml_constant' => 'XML_IO_ENOTEMPTY', 'description' => ''), - 1532 => array('libxml_constant' => 'XML_IO_ENOTSUP', 'description' => ''), - 1533 => array('libxml_constant' => 'XML_IO_ENOTTY', 'description' => ''), - 1534 => array('libxml_constant' => 'XML_IO_ENXIO', 'description' => ''), - 1535 => array('libxml_constant' => 'XML_IO_EPERM', 'description' => ''), - 1536 => array('libxml_constant' => 'XML_IO_EPIPE', 'description' => ''), - 1537 => array('libxml_constant' => 'XML_IO_ERANGE', 'description' => ''), - 1538 => array('libxml_constant' => 'XML_IO_EROFS', 'description' => ''), - 1539 => array('libxml_constant' => 'XML_IO_ESPIPE', 'description' => ''), - 1540 => array('libxml_constant' => 'XML_IO_ESRCH', 'description' => ''), - 1541 => array('libxml_constant' => 'XML_IO_ETIMEDOUT', 'description' => ''), - 1542 => array('libxml_constant' => 'XML_IO_EXDEV', 'description' => ''), - 1543 => array('libxml_constant' => 'XML_IO_NETWORK_ATTEMPT', 'description' => ''), - 1544 => array('libxml_constant' => 'XML_IO_ENCODER', 'description' => ''), - 1545 => array('libxml_constant' => 'XML_IO_FLUSH', 'description' => ''), - 1546 => array('libxml_constant' => 'XML_IO_WRITE', 'description' => ''), - 1547 => array('libxml_constant' => 'XML_IO_NO_INPUT', 'description' => ''), - 1548 => array('libxml_constant' => 'XML_IO_BUFFER_FULL', 'description' => ''), - 1549 => array('libxml_constant' => 'XML_IO_LOAD_ERROR', 'description' => ''), - 1550 => array('libxml_constant' => 'XML_IO_ENOTSOCK', 'description' => ''), - 1551 => array('libxml_constant' => 'XML_IO_EISCONN', 'description' => ''), - 1552 => array('libxml_constant' => 'XML_IO_ECONNREFUSED', 'description' => ''), - 1553 => array('libxml_constant' => 'XML_IO_ENETUNREACH', 'description' => ''), - 1554 => array('libxml_constant' => 'XML_IO_EADDRINUSE', 'description' => ''), - 1555 => array('libxml_constant' => 'XML_IO_EALREADY', 'description' => ''), - 1556 => array('libxml_constant' => 'XML_IO_EAFNOSUPPORT', 'description' => ''), - 1600 => array('libxml_constant' => 'XML_XINCLUDE_RECURSION', 'description' => ''), - 1601 => array('libxml_constant' => 'XML_XINCLUDE_PARSE_VALUE', 'description' => ''), - 1602 => array('libxml_constant' => 'XML_XINCLUDE_ENTITY_DEF_MISMATCH', 'description' => ''), - 1603 => array('libxml_constant' => 'XML_XINCLUDE_NO_HREF', 'description' => ''), - 1604 => array('libxml_constant' => 'XML_XINCLUDE_NO_FALLBACK', 'description' => ''), - 1605 => array('libxml_constant' => 'XML_XINCLUDE_HREF_URI', 'description' => ''), - 1606 => array('libxml_constant' => 'XML_XINCLUDE_TEXT_FRAGMENT', 'description' => ''), - 1607 => array('libxml_constant' => 'XML_XINCLUDE_TEXT_DOCUMENT', 'description' => ''), - 1608 => array('libxml_constant' => 'XML_XINCLUDE_INVALID_CHAR', 'description' => ''), - 1609 => array('libxml_constant' => 'XML_XINCLUDE_BUILD_FAILED', 'description' => ''), - 1610 => array('libxml_constant' => 'XML_XINCLUDE_UNKNOWN_ENCODING', 'description' => ''), - 1611 => array('libxml_constant' => 'XML_XINCLUDE_MULTIPLE_ROOT', 'description' => ''), - 1612 => array('libxml_constant' => 'XML_XINCLUDE_XPTR_FAILED', 'description' => ''), - 1613 => array('libxml_constant' => 'XML_XINCLUDE_XPTR_RESULT', 'description' => ''), - 1614 => array('libxml_constant' => 'XML_XINCLUDE_INCLUDE_IN_INCLUDE', 'description' => ''), - 1615 => array('libxml_constant' => 'XML_XINCLUDE_FALLBACKS_IN_INCLUDE', 'description' => ''), - 1616 => array('libxml_constant' => 'XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE', 'description' => ''), - 1617 => array('libxml_constant' => 'XML_XINCLUDE_DEPRECATED_NS', 'description' => ''), - 1618 => array('libxml_constant' => 'XML_XINCLUDE_FRAGMENT_ID', 'description' => ''), - 1650 => array('libxml_constant' => 'XML_CATALOG_MISSING_ATTR', 'description' => ''), - 1651 => array('libxml_constant' => 'XML_CATALOG_ENTRY_BROKEN', 'description' => ''), - 1652 => array('libxml_constant' => 'XML_CATALOG_PREFER_VALUE', 'description' => ''), - 1653 => array('libxml_constant' => 'XML_CATALOG_NOT_CATALOG', 'description' => ''), - 1654 => array('libxml_constant' => 'XML_CATALOG_RECURSION', 'description' => ''), - 1700 => array('libxml_constant' => 'XML_SCHEMAP_PREFIX_UNDEFINED', 'description' => ''), - 1701 => array('libxml_constant' => 'XML_SCHEMAP_ATTRFORMDEFAULT_VALUE', 'description' => ''), - 1702 => array('libxml_constant' => 'XML_SCHEMAP_ATTRGRP_NONAME_NOREF', 'description' => ''), - 1703 => array('libxml_constant' => 'XML_SCHEMAP_ATTR_NONAME_NOREF', 'description' => ''), - 1704 => array('libxml_constant' => 'XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF', 'description' => ''), - 1705 => array('libxml_constant' => 'XML_SCHEMAP_ELEMFORMDEFAULT_VALUE', 'description' => ''), - 1706 => array('libxml_constant' => 'XML_SCHEMAP_ELEM_NONAME_NOREF', 'description' => ''), - 1707 => array('libxml_constant' => 'XML_SCHEMAP_EXTENSION_NO_BASE', 'description' => ''), - 1708 => array('libxml_constant' => 'XML_SCHEMAP_FACET_NO_VALUE', 'description' => ''), - 1709 => array('libxml_constant' => 'XML_SCHEMAP_FAILED_BUILD_IMPORT', 'description' => ''), - 1710 => array('libxml_constant' => 'XML_SCHEMAP_GROUP_NONAME_NOREF', 'description' => ''), - 1711 => array('libxml_constant' => 'XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI', 'description' => ''), - 1712 => array('libxml_constant' => 'XML_SCHEMAP_IMPORT_REDEFINE_NSNAME', 'description' => ''), - 1713 => array('libxml_constant' => 'XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI', 'description' => ''), - 1714 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_BOOLEAN', 'description' => ''), - 1715 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_ENUM', 'description' => ''), - 1716 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_FACET', 'description' => ''), - 1717 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_FACET_VALUE', 'description' => ''), - 1718 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_MAXOCCURS', 'description' => ''), - 1719 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_MINOCCURS', 'description' => ''), - 1720 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_REF_AND_SUBTYPE', 'description' => ''), - 1721 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_WHITE_SPACE', 'description' => ''), - 1722 => array('libxml_constant' => 'XML_SCHEMAP_NOATTR_NOREF', 'description' => ''), - 1723 => array('libxml_constant' => 'XML_SCHEMAP_NOTATION_NO_NAME', 'description' => ''), - 1724 => array('libxml_constant' => 'XML_SCHEMAP_NOTYPE_NOREF', 'description' => ''), - 1725 => array('libxml_constant' => 'XML_SCHEMAP_REF_AND_SUBTYPE', 'description' => ''), - 1726 => array('libxml_constant' => 'XML_SCHEMAP_RESTRICTION_NONAME_NOREF', 'description' => ''), - 1727 => array('libxml_constant' => 'XML_SCHEMAP_SIMPLETYPE_NONAME', 'description' => ''), - 1728 => array('libxml_constant' => 'XML_SCHEMAP_TYPE_AND_SUBTYPE', 'description' => ''), - 1729 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_ALL_CHILD', 'description' => ''), - 1730 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD', 'description' => ''), - 1731 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_ATTR_CHILD', 'description' => ''), - 1732 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD', 'description' => ''), - 1733 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP', 'description' => ''), - 1734 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_BASE_TYPE', 'description' => ''), - 1735 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_CHOICE_CHILD', 'description' => ''), - 1736 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD', 'description' => ''), - 1737 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD', 'description' => ''), - 1738 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_ELEM_CHILD', 'description' => ''), - 1739 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD', 'description' => ''), - 1740 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_FACET_CHILD', 'description' => ''), - 1741 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_FACET_TYPE', 'description' => ''), - 1742 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_GROUP_CHILD', 'description' => ''), - 1743 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_IMPORT_CHILD', 'description' => ''), - 1744 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_LIST_CHILD', 'description' => ''), - 1745 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_NOTATION_CHILD', 'description' => ''), - 1746 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD', 'description' => ''), - 1747 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_REF', 'description' => ''), - 1748 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD', 'description' => ''), - 1749 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD', 'description' => ''), - 1750 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD', 'description' => ''), - 1751 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD', 'description' => ''), - 1752 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD', 'description' => ''), - 1753 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_TYPE', 'description' => ''), - 1754 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_UNION_CHILD', 'description' => ''), - 1755 => array('libxml_constant' => 'XML_SCHEMAP_ELEM_DEFAULT_FIXED', 'description' => ''), - 1756 => array('libxml_constant' => 'XML_SCHEMAP_REGEXP_INVALID', 'description' => ''), - 1757 => array('libxml_constant' => 'XML_SCHEMAP_FAILED_LOAD', 'description' => ''), - 1758 => array('libxml_constant' => 'XML_SCHEMAP_NOTHING_TO_PARSE', 'description' => ''), - 1759 => array('libxml_constant' => 'XML_SCHEMAP_NOROOT', 'description' => ''), - 1760 => array('libxml_constant' => 'XML_SCHEMAP_REDEFINED_GROUP', 'description' => ''), - 1761 => array('libxml_constant' => 'XML_SCHEMAP_REDEFINED_TYPE', 'description' => ''), - 1762 => array('libxml_constant' => 'XML_SCHEMAP_REDEFINED_ELEMENT', 'description' => ''), - 1763 => array('libxml_constant' => 'XML_SCHEMAP_REDEFINED_ATTRGROUP', 'description' => ''), - 1764 => array('libxml_constant' => 'XML_SCHEMAP_REDEFINED_ATTR', 'description' => ''), - 1765 => array('libxml_constant' => 'XML_SCHEMAP_REDEFINED_NOTATION', 'description' => ''), - 1766 => array('libxml_constant' => 'XML_SCHEMAP_FAILED_PARSE', 'description' => ''), - 1767 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_PREFIX', 'description' => ''), - 1768 => array('libxml_constant' => 'XML_SCHEMAP_DEF_AND_PREFIX', 'description' => ''), - 1769 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD', 'description' => ''), - 1770 => array('libxml_constant' => 'XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI', 'description' => ''), - 1771 => array('libxml_constant' => 'XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI', 'description' => ''), - 1772 => array('libxml_constant' => 'XML_SCHEMAP_NOT_SCHEMA', 'description' => ''), - 1773 => array('libxml_constant' => 'XML_SCHEMAP_UNKNOWN_MEMBER_TYPE', 'description' => ''), - 1774 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_ATTR_USE', 'description' => ''), - 1775 => array('libxml_constant' => 'XML_SCHEMAP_RECURSIVE', 'description' => ''), - 1776 => array('libxml_constant' => 'XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE', 'description' => ''), - 1777 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_ATTR_COMBINATION', 'description' => ''), - 1778 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION', 'description' => ''), - 1779 => array('libxml_constant' => 'XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD', 'description' => ''), - 1780 => array('libxml_constant' => 'XML_SCHEMAP_INVALID_ATTR_NAME', 'description' => ''), - 1781 => array('libxml_constant' => 'XML_SCHEMAP_REF_AND_CONTENT', 'description' => ''), - 1782 => array('libxml_constant' => 'XML_SCHEMAP_CT_PROPS_CORRECT_1', 'description' => ''), - 1783 => array('libxml_constant' => 'XML_SCHEMAP_CT_PROPS_CORRECT_2', 'description' => ''), - 1784 => array('libxml_constant' => 'XML_SCHEMAP_CT_PROPS_CORRECT_3', 'description' => ''), - 1785 => array('libxml_constant' => 'XML_SCHEMAP_CT_PROPS_CORRECT_4', 'description' => ''), - 1786 => array('libxml_constant' => 'XML_SCHEMAP_CT_PROPS_CORRECT_5', 'description' => ''), - 1787 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1', 'description' => ''), - 1788 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1', 'description' => ''), - 1789 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2', 'description' => ''), - 1790 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2', 'description' => ''), - 1791 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3', 'description' => ''), - 1792 => array('libxml_constant' => 'XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER', 'description' => ''), - 1793 => array('libxml_constant' => 'XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE', 'description' => ''), - 1794 => array('libxml_constant' => 'XML_SCHEMAP_UNION_NOT_EXPRESSIBLE', 'description' => ''), - 1795 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT_3_1', 'description' => ''), - 1796 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT_3_2', 'description' => ''), - 1797 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1', 'description' => ''), - 1798 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2', 'description' => ''), - 1799 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3', 'description' => ''), - 1800 => array('libxml_constant' => 'XML_SCHEMAP_COS_CT_EXTENDS_1_3', 'description' => ''), - 1801 => array('libxml_constant' => 'XML_SCHEMAV_NOROOT', 'description' => ''), - 1802 => array('libxml_constant' => 'XML_SCHEMAV_UNDECLAREDELEM', 'description' => ''), - 1803 => array('libxml_constant' => 'XML_SCHEMAV_NOTTOPLEVEL', 'description' => ''), - 1804 => array('libxml_constant' => 'XML_SCHEMAV_MISSING', 'description' => ''), - 1805 => array('libxml_constant' => 'XML_SCHEMAV_WRONGELEM', 'description' => ''), - 1806 => array('libxml_constant' => 'XML_SCHEMAV_NOTYPE', 'description' => ''), - 1807 => array('libxml_constant' => 'XML_SCHEMAV_NOROLLBACK', 'description' => ''), - 1808 => array('libxml_constant' => 'XML_SCHEMAV_ISABSTRACT', 'description' => ''), - 1809 => array('libxml_constant' => 'XML_SCHEMAV_NOTEMPTY', 'description' => ''), - 1810 => array('libxml_constant' => 'XML_SCHEMAV_ELEMCONT', 'description' => ''), - 1811 => array('libxml_constant' => 'XML_SCHEMAV_HAVEDEFAULT', 'description' => ''), - 1812 => array('libxml_constant' => 'XML_SCHEMAV_NOTNILLABLE', 'description' => ''), - 1813 => array('libxml_constant' => 'XML_SCHEMAV_EXTRACONTENT', 'description' => ''), - 1814 => array('libxml_constant' => 'XML_SCHEMAV_INVALIDATTR', 'description' => ''), - 1815 => array('libxml_constant' => 'XML_SCHEMAV_INVALIDELEM', 'description' => ''), - 1816 => array('libxml_constant' => 'XML_SCHEMAV_NOTDETERMINIST', 'description' => ''), - 1817 => array('libxml_constant' => 'XML_SCHEMAV_CONSTRUCT', 'description' => ''), - 1818 => array('libxml_constant' => 'XML_SCHEMAV_INTERNAL', 'description' => ''), - 1819 => array('libxml_constant' => 'XML_SCHEMAV_NOTSIMPLE', 'description' => ''), - 1820 => array('libxml_constant' => 'XML_SCHEMAV_ATTRUNKNOWN', 'description' => ''), - 1821 => array('libxml_constant' => 'XML_SCHEMAV_ATTRINVALID', 'description' => ''), - 1822 => array('libxml_constant' => 'XML_SCHEMAV_VALUE', 'description' => ''), - 1823 => array('libxml_constant' => 'XML_SCHEMAV_FACET', 'description' => ''), - 1824 => array('libxml_constant' => 'XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1', 'description' => 'Invalid value for the type'), - 1825 => array('libxml_constant' => 'XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2', 'description' => ''), - 1826 => array('libxml_constant' => 'XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3', 'description' => ''), - 1827 => array('libxml_constant' => 'XML_SCHEMAV_CVC_TYPE_3_1_1', 'description' => ''), - 1828 => array('libxml_constant' => 'XML_SCHEMAV_CVC_TYPE_3_1_2', 'description' => ''), - 1829 => array('libxml_constant' => 'XML_SCHEMAV_CVC_FACET_VALID', 'description' => ''), - 1830 => array('libxml_constant' => 'XML_SCHEMAV_CVC_LENGTH_VALID', 'description' => ''), - 1831 => array('libxml_constant' => 'XML_SCHEMAV_CVC_MINLENGTH_VALID', 'description' => ''), - 1832 => array('libxml_constant' => 'XML_SCHEMAV_CVC_MAXLENGTH_VALID', 'description' => ''), - 1833 => array('libxml_constant' => 'XML_SCHEMAV_CVC_MININCLUSIVE_VALID', 'description' => ''), - 1834 => array('libxml_constant' => 'XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID', 'description' => ''), - 1835 => array('libxml_constant' => 'XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID', 'description' => ''), - 1836 => array('libxml_constant' => 'XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID', 'description' => ''), - 1837 => array('libxml_constant' => 'XML_SCHEMAV_CVC_TOTALDIGITS_VALID', 'description' => ''), - 1838 => array('libxml_constant' => 'XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID', 'description' => ''), - 1839 => array('libxml_constant' => 'XML_SCHEMAV_CVC_PATTERN_VALID', 'description' => ''), - 1840 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ENUMERATION_VALID', 'description' => 'Value not in the set'), - 1841 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1', 'description' => ''), - 1842 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2', 'description' => ''), - 1843 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3', 'description' => ''), - 1844 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4', 'description' => ''), - 1845 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_1', 'description' => ''), - 1846 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_2', 'description' => ''), - 1847 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_3_1', 'description' => ''), - 1848 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_3_2_1', 'description' => ''), - 1849 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_3_2_2', 'description' => ''), - 1850 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_4_1', 'description' => ''), - 1851 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_4_2', 'description' => ''), - 1852 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_4_3', 'description' => ''), - 1853 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_5_1_1', 'description' => ''), - 1854 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_5_1_2', 'description' => ''), - 1855 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_5_2_1', 'description' => ''), - 1856 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_5_2_2_1', 'description' => ''), - 1857 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_5_2_2_2_1', 'description' => ''), - 1858 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_5_2_2_2_2', 'description' => ''), - 1859 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_6', 'description' => ''), - 1860 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ELT_7', 'description' => ''), - 1861 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ATTRIBUTE_1', 'description' => ''), - 1862 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ATTRIBUTE_2', 'description' => ''), - 1863 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ATTRIBUTE_3', 'description' => ''), - 1864 => array('libxml_constant' => 'XML_SCHEMAV_CVC_ATTRIBUTE_4', 'description' => ''), - 1865 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1', 'description' => ''), - 1866 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1', 'description' => ''), - 1867 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2', 'description' => ''), - 1868 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_4', 'description' => ''), - 1869 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1', 'description' => ''), - 1870 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2', 'description' => ''), - 1871 => array('libxml_constant' => 'XML_SCHEMAV_ELEMENT_CONTENT', 'description' => ''), - 1872 => array('libxml_constant' => 'XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING', 'description' => ''), - 1873 => array('libxml_constant' => 'XML_SCHEMAV_CVC_COMPLEX_TYPE_1', 'description' => ''), - 1874 => array('libxml_constant' => 'XML_SCHEMAV_CVC_AU', 'description' => ''), - 1875 => array('libxml_constant' => 'XML_SCHEMAV_CVC_TYPE_1', 'description' => ''), - 1876 => array('libxml_constant' => 'XML_SCHEMAV_CVC_TYPE_2', 'description' => ''), - 1877 => array('libxml_constant' => 'XML_SCHEMAV_CVC_IDC', 'description' => ''), - 1878 => array('libxml_constant' => 'XML_SCHEMAV_CVC_WILDCARD', 'description' => ''), - 1879 => array('libxml_constant' => 'XML_SCHEMAV_MISC', 'description' => ''), - 1900 => array('libxml_constant' => 'XML_XPTR_UNKNOWN_SCHEME', 'description' => ''), - 1901 => array('libxml_constant' => 'XML_XPTR_CHILDSEQ_START', 'description' => ''), - 1902 => array('libxml_constant' => 'XML_XPTR_EVAL_FAILED', 'description' => ''), - 1903 => array('libxml_constant' => 'XML_XPTR_EXTRA_OBJECTS', 'description' => ''), - 1950 => array('libxml_constant' => 'XML_C14N_CREATE_CTXT', 'description' => ''), - 1951 => array('libxml_constant' => 'XML_C14N_REQUIRES_UTF8', 'description' => ''), - 1952 => array('libxml_constant' => 'XML_C14N_CREATE_STACK', 'description' => ''), - 1953 => array('libxml_constant' => 'XML_C14N_INVALID_NODE', 'description' => ''), - 1954 => array('libxml_constant' => 'XML_C14N_UNKNOW_NODE', 'description' => ''), - 1955 => array('libxml_constant' => 'XML_C14N_RELATIVE_NAMESPACE', 'description' => ''), - 2000 => array('libxml_constant' => 'XML_FTP_PASV_ANSWER', 'description' => ''), - 2001 => array('libxml_constant' => 'XML_FTP_EPSV_ANSWER', 'description' => ''), - 2002 => array('libxml_constant' => 'XML_FTP_ACCNT', 'description' => ''), - 2003 => array('libxml_constant' => 'XML_FTP_URL_SYNTAX', 'description' => ''), - 2020 => array('libxml_constant' => 'XML_HTTP_URL_SYNTAX', 'description' => ''), - 2021 => array('libxml_constant' => 'XML_HTTP_USE_IP', 'description' => ''), - 2022 => array('libxml_constant' => 'XML_HTTP_UNKNOWN_HOST', 'description' => ''), - 3000 => array('libxml_constant' => 'XML_SCHEMAP_SRC_SIMPLE_TYPE_1', 'description' => ''), - 3001 => array('libxml_constant' => 'XML_SCHEMAP_SRC_SIMPLE_TYPE_2', 'description' => ''), - 3002 => array('libxml_constant' => 'XML_SCHEMAP_SRC_SIMPLE_TYPE_3', 'description' => ''), - 3003 => array('libxml_constant' => 'XML_SCHEMAP_SRC_SIMPLE_TYPE_4', 'description' => ''), - 3004 => array('libxml_constant' => 'XML_SCHEMAP_SRC_RESOLVE', 'description' => ''), - 3005 => array('libxml_constant' => 'XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE', 'description' => ''), - 3006 => array('libxml_constant' => 'XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE', 'description' => ''), - 3007 => array('libxml_constant' => 'XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES', 'description' => ''), - 3008 => array('libxml_constant' => 'XML_SCHEMAP_ST_PROPS_CORRECT_1', 'description' => ''), - 3009 => array('libxml_constant' => 'XML_SCHEMAP_ST_PROPS_CORRECT_2', 'description' => ''), - 3010 => array('libxml_constant' => 'XML_SCHEMAP_ST_PROPS_CORRECT_3', 'description' => ''), - 3011 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_1_1', 'description' => ''), - 3012 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_1_2', 'description' => ''), - 3013 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1', 'description' => ''), - 3014 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2', 'description' => ''), - 3015 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_1', 'description' => ''), - 3016 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1', 'description' => ''), - 3017 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2', 'description' => ''), - 3018 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1', 'description' => ''), - 3019 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2', 'description' => ''), - 3020 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3', 'description' => ''), - 3021 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4', 'description' => ''), - 3022 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5', 'description' => ''), - 3023 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_1', 'description' => ''), - 3024 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1', 'description' => ''), - 3025 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2', 'description' => ''), - 3026 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2', 'description' => ''), - 3027 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1', 'description' => ''), - 3028 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3', 'description' => ''), - 3029 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4', 'description' => ''), - 3030 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5', 'description' => ''), - 3031 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_DERIVED_OK_2_1', 'description' => ''), - 3032 => array('libxml_constant' => 'XML_SCHEMAP_COS_ST_DERIVED_OK_2_2', 'description' => ''), - 3033 => array('libxml_constant' => 'XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED', 'description' => ''), - 3034 => array('libxml_constant' => 'XML_SCHEMAP_S4S_ELEM_MISSING', 'description' => ''), - 3035 => array('libxml_constant' => 'XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED', 'description' => ''), - 3036 => array('libxml_constant' => 'XML_SCHEMAP_S4S_ATTR_MISSING', 'description' => ''), - 3037 => array('libxml_constant' => 'XML_SCHEMAP_S4S_ATTR_INVALID_VALUE', 'description' => ''), - 3038 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ELEMENT_1', 'description' => ''), - 3039 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ELEMENT_2_1', 'description' => ''), - 3040 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ELEMENT_2_2', 'description' => ''), - 3041 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ELEMENT_3', 'description' => ''), - 3042 => array('libxml_constant' => 'XML_SCHEMAP_P_PROPS_CORRECT_1', 'description' => ''), - 3043 => array('libxml_constant' => 'XML_SCHEMAP_P_PROPS_CORRECT_2_1', 'description' => ''), - 3044 => array('libxml_constant' => 'XML_SCHEMAP_P_PROPS_CORRECT_2_2', 'description' => ''), - 3045 => array('libxml_constant' => 'XML_SCHEMAP_E_PROPS_CORRECT_2', 'description' => ''), - 3046 => array('libxml_constant' => 'XML_SCHEMAP_E_PROPS_CORRECT_3', 'description' => ''), - 3047 => array('libxml_constant' => 'XML_SCHEMAP_E_PROPS_CORRECT_4', 'description' => ''), - 3048 => array('libxml_constant' => 'XML_SCHEMAP_E_PROPS_CORRECT_5', 'description' => ''), - 3049 => array('libxml_constant' => 'XML_SCHEMAP_E_PROPS_CORRECT_6', 'description' => ''), - 3050 => array('libxml_constant' => 'XML_SCHEMAP_SRC_INCLUDE', 'description' => ''), - 3051 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_1', 'description' => ''), - 3052 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_2', 'description' => ''), - 3053 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_3_1', 'description' => ''), - 3054 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_3_2', 'description' => ''), - 3055 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_4', 'description' => ''), - 3056 => array('libxml_constant' => 'XML_SCHEMAP_NO_XMLNS', 'description' => ''), - 3057 => array('libxml_constant' => 'XML_SCHEMAP_NO_XSI', 'description' => ''), - 3058 => array('libxml_constant' => 'XML_SCHEMAP_COS_VALID_DEFAULT_1', 'description' => ''), - 3059 => array('libxml_constant' => 'XML_SCHEMAP_COS_VALID_DEFAULT_2_1', 'description' => ''), - 3060 => array('libxml_constant' => 'XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1', 'description' => ''), - 3061 => array('libxml_constant' => 'XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2', 'description' => ''), - 3062 => array('libxml_constant' => 'XML_SCHEMAP_CVC_SIMPLE_TYPE', 'description' => ''), - 3063 => array('libxml_constant' => 'XML_SCHEMAP_COS_CT_EXTENDS_1_1', 'description' => ''), - 3064 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT_1_1', 'description' => ''), - 3065 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT_1_2', 'description' => ''), - 3066 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT_2', 'description' => ''), - 3067 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT_2_1', 'description' => ''), - 3068 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT_2_2', 'description' => ''), - 3069 => array('libxml_constant' => 'XML_SCHEMAP_INTERNAL', 'description' => ''), - 3070 => array('libxml_constant' => 'XML_SCHEMAP_NOT_DETERMINISTIC', 'description' => ''), - 3071 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1', 'description' => ''), - 3072 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2', 'description' => ''), - 3073 => array('libxml_constant' => 'XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3', 'description' => ''), - 3074 => array('libxml_constant' => 'XML_SCHEMAP_MG_PROPS_CORRECT_1', 'description' => ''), - 3075 => array('libxml_constant' => 'XML_SCHEMAP_MG_PROPS_CORRECT_2', 'description' => ''), - 3076 => array('libxml_constant' => 'XML_SCHEMAP_SRC_CT_1', 'description' => ''), - 3077 => array('libxml_constant' => 'XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3', 'description' => ''), - 3078 => array('libxml_constant' => 'XML_SCHEMAP_AU_PROPS_CORRECT_2', 'description' => ''), - 3079 => array('libxml_constant' => 'XML_SCHEMAP_A_PROPS_CORRECT_2', 'description' => ''), - 3080 => array('libxml_constant' => 'XML_SCHEMAP_C_PROPS_CORRECT', 'description' => ''), - 3081 => array('libxml_constant' => 'XML_SCHEMAP_SRC_REDEFINE', 'description' => ''), - 3082 => array('libxml_constant' => 'XML_SCHEMAP_SRC_IMPORT', 'description' => ''), - 3083 => array('libxml_constant' => 'XML_SCHEMAP_WARN_SKIP_SCHEMA', 'description' => ''), - 3084 => array('libxml_constant' => 'XML_SCHEMAP_WARN_UNLOCATED_SCHEMA', 'description' => ''), - 3085 => array('libxml_constant' => 'XML_SCHEMAP_WARN_ATTR_REDECL_PROH', 'description' => ''), - 3086 => array('libxml_constant' => 'XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH', 'description' => ''), - 3087 => array('libxml_constant' => 'XML_SCHEMAP_AG_PROPS_CORRECT', 'description' => ''), - 3088 => array('libxml_constant' => 'XML_SCHEMAP_COS_CT_EXTENDS_1_2', 'description' => ''), - 3089 => array('libxml_constant' => 'XML_SCHEMAP_AU_PROPS_CORRECT', 'description' => ''), - 3090 => array('libxml_constant' => 'XML_SCHEMAP_A_PROPS_CORRECT_3', 'description' => ''), - 3091 => array('libxml_constant' => 'XML_SCHEMAP_COS_ALL_LIMITED', 'description' => ''), - 4000 => array('libxml_constant' => 'XML_SCHEMATRONV_ASSERT', 'description' => ''), - 4001 => array('libxml_constant' => 'XML_SCHEMATRONV_REPORT', 'description' => ''), - 4900 => array('libxml_constant' => 'XML_MODULE_OPEN', 'description' => ''), - 4901 => array('libxml_constant' => 'XML_MODULE_CLOSE', 'description' => ''), - 5000 => array('libxml_constant' => 'XML_CHECK_FOUND_ELEMENT', 'description' => ''), - 5001 => array('libxml_constant' => 'XML_CHECK_FOUND_ATTRIBUTE', 'description' => ''), - 5002 => array('libxml_constant' => 'XML_CHECK_FOUND_TEXT', 'description' => ''), - 5003 => array('libxml_constant' => 'XML_CHECK_FOUND_CDATA', 'description' => ''), - 5004 => array('libxml_constant' => 'XML_CHECK_FOUND_ENTITYREF', 'description' => ''), - 5005 => array('libxml_constant' => 'XML_CHECK_FOUND_ENTITY', 'description' => ''), - 5006 => array('libxml_constant' => 'XML_CHECK_FOUND_PI', 'description' => ''), - 5007 => array('libxml_constant' => 'XML_CHECK_FOUND_COMMENT', 'description' => ''), - 5008 => array('libxml_constant' => 'XML_CHECK_FOUND_DOCTYPE', 'description' => ''), - 5009 => array('libxml_constant' => 'XML_CHECK_FOUND_FRAGMENT', 'description' => ''), - 5010 => array('libxml_constant' => 'XML_CHECK_FOUND_NOTATION', 'description' => ''), - 5011 => array('libxml_constant' => 'XML_CHECK_UNKNOWN_NODE', 'description' => ''), - 5012 => array('libxml_constant' => 'XML_CHECK_ENTITY_TYPE', 'description' => ''), - 5013 => array('libxml_constant' => 'XML_CHECK_NO_PARENT', 'description' => ''), - 5014 => array('libxml_constant' => 'XML_CHECK_NO_DOC', 'description' => ''), - 5015 => array('libxml_constant' => 'XML_CHECK_NO_NAME', 'description' => ''), - 5016 => array('libxml_constant' => 'XML_CHECK_NO_ELEM', 'description' => ''), - 5017 => array('libxml_constant' => 'XML_CHECK_WRONG_DOC', 'description' => ''), - 5018 => array('libxml_constant' => 'XML_CHECK_NO_PREV', 'description' => ''), - 5019 => array('libxml_constant' => 'XML_CHECK_WRONG_PREV', 'description' => ''), - 5020 => array('libxml_constant' => 'XML_CHECK_NO_NEXT', 'description' => ''), - 5021 => array('libxml_constant' => 'XML_CHECK_WRONG_NEXT', 'description' => ''), - 5022 => array('libxml_constant' => 'XML_CHECK_NOT_DTD', 'description' => ''), - 5023 => array('libxml_constant' => 'XML_CHECK_NOT_ATTR', 'description' => ''), - 5024 => array('libxml_constant' => 'XML_CHECK_NOT_ATTR_DECL', 'description' => ''), - 5025 => array('libxml_constant' => 'XML_CHECK_NOT_ELEM_DECL', 'description' => ''), - 5026 => array('libxml_constant' => 'XML_CHECK_NOT_ENTITY_DECL', 'description' => ''), - 5027 => array('libxml_constant' => 'XML_CHECK_NOT_NS_DECL', 'description' => ''), - 5028 => array('libxml_constant' => 'XML_CHECK_NO_HREF', 'description' => ''), - 5029 => array('libxml_constant' => 'XML_CHECK_WRONG_PARENT', 'description' => ''), - 5030 => array('libxml_constant' => 'XML_CHECK_NS_SCOPE', 'description' => ''), - 5031 => array('libxml_constant' => 'XML_CHECK_NS_ANCESTOR', 'description' => ''), - 5032 => array('libxml_constant' => 'XML_CHECK_NOT_UTF8', 'description' => ''), - 5033 => array('libxml_constant' => 'XML_CHECK_NO_DICT', 'description' => ''), - 5034 => array('libxml_constant' => 'XML_CHECK_NOT_NCNAME', 'description' => ''), - 5035 => array('libxml_constant' => 'XML_CHECK_OUTSIDE_DICT', 'description' => ''), - 5036 => array('libxml_constant' => 'XML_CHECK_WRONG_NAME', 'description' => ''), - 5037 => array('libxml_constant' => 'XML_CHECK_NAME_NOT_NULL', 'description' => ''), - 6000 => array('libxml_constant' => 'XML_I18N_NO_NAME', 'description' => ''), - 6001 => array('libxml_constant' => 'XML_I18N_NO_HANDLER', 'description' => ''), - 6002 => array('libxml_constant' => 'XML_I18N_EXCESS_HANDLER', 'description' => ''), - 6003 => array('libxml_constant' => 'XML_I18N_CONV_FAILED', 'description' => ''), - 6004 => array('libxml_constant' => 'XML_I18N_NO_OUTPUT', 'description' => ''), - 7000 => array('libxml_constant' => 'XML_BUF_OVERFLOW', 'description' => ''), - ); - - function parse($libxml_error) - { - $domain = null; - - $element = null; - $attribute = null; - $value = null; - $type = null; - $facet = null; - $set = null; - - preg_match_all( - "#\'([^\']*)\'#i", - $libxml_error->message, - $matchedArgs - ); - $args = $matchedArgs[1]; - - // Remove namespace - for($i=0; $i<count($args); $i++) { - $args[$i] = preg_replace("#\{([^\}]*)\}#i", '', $args[$i]); - } - - $domainId = (integer)substr(str_pad($libxml_error->code, 4, '0', STR_PAD_LEFT), 0, 2) - 1; - $domainName = $this->domains[$domainId]['name']; - $domainConst = $this->domains[$domainId]['libxml_constant']; - - switch($libxml_error->code) { - case '1824': - // Element '$1': '$2' is not a valid value of the atomic type '$3'. - // Element '$1', attribute '$2': '$3' is not a valid value of the atomic type '$4'. - $element = current($args); - if(strstr($libxml_error->message, "attribute '")) $attribute = next($args); - $value = next($args); - $type = next($args); - break; - - case '1840': - // Element '$1': [facet '$2'] The value '$3' is not an element of the set {$4, $5, $6... $n}. - // Element '$1', attribute '$2': [facet '$3'] The value '$4' is not an element of the set {$5, $6, $7... $n}. - $element = current($args); - if(strstr($libxml_error->message, "attribute '")) $attribute = next($args); - $facet = next($args); - $value = next($args); - while($setItem = next($args)) $set[] = $setItem; - break; - - case '1845': - // Element 'ArchiveTransfer': No matching global declaration available for the validation root. - $element = current($args); - break; - - case '1866': - // Element '$1', attribute '$2': The attribute '$3' is not allowed. - $element = current($args); - $attribute = next($args); - break; - - case '1871': - // Element '$1': This element is not expected. - $element = current($args); - break; - - case '3033': - // Element '{http://www.w3.org/2001/XMLSchema}complexType': The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))). - $element = current($args); - break; - - default: - - } - - $errorArgs = array( - 'level' => $libxml_error->level, - 'code' => $libxml_error->code, - 'message' => $libxml_error->message, - 'file' => $libxml_error->file, - 'line' => $libxml_error->line, - 'column' => $libxml_error->column, - 'domain' => $domainId, - 'domainConstant' => $domainConst, - 'domainName' => $domainName, - 'element' => $element, - 'attribute' => $attribute, - 'value' => $value, - 'type' => $type, - 'facet' => $facet, - 'set' => $set, - - ); - - return $errorArgs; - - } - -} diff --git a/core/trunk/core/tests/class/Message.php b/core/trunk/core/tests/class/Message.php deleted file mode 100644 index a95c62b0aea27e112c8f8317368dd492f3b0bb47..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/Message.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -class Message -{ - const INFO = 0; - const WARNING = 1; - const ERROR = 2; - const FATAL = 3; - - public $code; - public $message; - public $level; - - public function Message($code, $message, $level) - { - $this->code = $code; - $this->message = trim($message); - $this->level = $level; - } - - public function send($receiver=false) - { - if(!$receiver) $receiver = $_SESSION; - if(is_object($receiver)) { - $receiver->messages[] = $this; - } elseif(is_array($receiver)) { - $receiver['messages'][] = $this; - } - } - -} \ No newline at end of file diff --git a/core/trunk/core/tests/class/MessageController.php b/core/trunk/core/tests/class/MessageController.php deleted file mode 100644 index ae97dd33b7b5f7ae382eb04635f1af7e0b358a2f..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/MessageController.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php - -class MessageController - extends DOMDocument -{ - - private $logLevel; - private $debug; - private $xpath; - - public function __set($name, $value) - { - switch($name) { - case 'logLevel' : $this->logLevel = $value; - case 'debug' : $this->debug = $value; - } - } - - public function loadMessageFile($messageFile) - { - $customFilePath = - $_SESSION['config']['corepath'] . DIRECTORY_SEPARATOR - . 'custom' . DIRECTORY_SEPARATOR - . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR - . $messageFile; - - $relativeFilePath = - $_SESSION['config']['corepath'] . DIRECTORY_SEPARATOR - . $messageFile; - - if(is_file($customFilePath)) { - $loadMessageFile = $customFilePath; - } elseif(is_file($relativeFilePath)) { - $loadMessageFile = $relativeFilePath; - } elseif(is_file($messageFile)) { - $loadMessageFile = $messageFile; - } else { - throw new maarch\Exception("Failed to load message definition file $messageFile in $customFilePath or $relativeFilePath"); - } - - - if(!$this->documentElement) { - $this->registerNodeClass('DOMElement', 'MessageDefinition'); - $definitions = $this->CreateElement('messageDefinitions'); - $this->appendChild($definitions); - $this->xpath = new DOMXPath($this); - } else { - $definitions = $this->documentElement; - } - - $MessageFileXml = new DOMDocument(); - $MessageFileXml->load($loadMessageFile); - - $xPath = new DOMXPath($MessageFileXml); - - $Messages = $xPath->query('/messages/message'); - for($i=0; $i<$Messages->length; $i++) { - $importedMessage = $this->importNode($Messages->item($i), true); - $definitions->appendChild($importedMessage); - } - - } - - private function xpath($query, $contextElement=false) - { - if(!$contextElement) $contextElement = $this->documentElement; - $result = $this->xpath->query($query, $contextElement); - if($result) return $result; - else { - throw new maarch\Exception('XPath Error: ' . $query); - } - } - - public function getMessageDefinition($code) - { - try { - $definitions = $this->xpath("//message[@code='".$code."']"); - if($definitions && $definitions->length === 0) return false; - $definition = $definitions->item(0); - return $definition; - } catch (maarch\Exception $e) { - throw $e; - } - } - - public function getTexts( - $codePrefix, - $lang = false - ) - { - $texts = array(); - $definitions = $this->xpath("//message[starts-with(@code, '".$codePrefix."')]"); - - for($i=0; $i<$definitions->length; $i++) { - $definition = $definitions->item($i); - $text = $this->makeMessageText($definition, $lang); - if(!$text) $text = $definition->code; - $texts[$definition->code] = $text; - } - return $texts; - } - - public function getMessageText( - $code, - $lang = false, - $params = array() - ) - { - // Get message definition - try { - $definition = $this->getMessageDefinition($code); - if(!$definition) return $code; - - $text = $this->makeMessageText( - $definition, - $lang, - $params - ); - return $text; - } catch (maarch\Exception $e) { - throw $e; - } - } - - private function makeMessageText( - $definition, - $lang, - $params = array() - - ) - { - // Get message text in requested language - if(!$lang) $lang = $_SESSION['config']['lang']; - $texts = $this->xpath("./text[@lang='".$lang."']", $definition); - - // No text defined for language, return code - if($texts->length === 0) { - return $definition->code; - } - - // Get template text - $text = $texts->item(0)->nodeValue; - // Merge params (if fail return template) - $text = @vsprintf($text, $params); - - return $text; - } - - public function createMessage( - $code, - $lang = false, - $params = array() - ) - { - // Get message definition - $definition = $this->getMessageDefinition($code); - - // Make Text - $text = $this->makeMessageText( - $definition, - $lang, - $params - ); - - // Create message object - $message = new Message( - $code, - $text, - $definition->level - ); - - return $message; - } - -} - -class MessageDefinition - extends DOMelement -{ - - function __get($name) - { - if($this->hasAttribute($name)) { - return $this->getAttribute($name); - } - } - - -} \ No newline at end of file diff --git a/core/trunk/core/tests/class/Schema.php b/core/trunk/core/tests/class/Schema.php deleted file mode 100644 index 8aa325ec25bc2de5ba49a496f950c1baf83f1db6..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/Schema.php +++ /dev/null @@ -1,231 +0,0 @@ -<?php - -class Schema - extends DOMDocument -{ - - public $includedSchemaLocations = array(); - - public function Schema() - { - parent::__construct(); - $this->registerNodeClass('DOMNode', 'SchemaNode'); - $this->registerNodeClass('DOMElement', 'SchemaElement'); - $this->registerNodeClass('DOMAttr', 'SchemaAttribute'); - } - - public function loadXSD($schemaLocation, $rootSchema=false) - { - $schemaFullPath = $this->getFullPath( - $schemaLocation - ); - - $this->load($schemaFullPath); - if(!$rootSchema) $rootSchema = $this; - $this->processIncludes($this, $rootSchema); - } - - public function processIncludes($schema, $rootSchema) - { - $includes = $schema->getElementsByTagName('include'); - while($includes->length > 0) { - $include = $includes->item(0); - $includeSchemaLocation = $include->getAttribute('schemaLocation'); - if(!in_array( - $includeSchemaLocation, - $rootSchema->includedSchemaLocations) - ) { - $this->includeXSD($schema, $includeSchemaLocation, $rootSchema); - } - $include->parentNode->removeChild($include); - } - } - - public function includeXSD($schema, $includeSchemaLocation, $rootSchema) - { - $includeSchema = new Schema(); - - $schemaFullPath = $this->getFullPath( - $includeSchemaLocation - ); - - $includeSchema->loadXSD($schemaFullPath, $rootSchema); - $schemaContents = $includeSchema->documentElement->childNodes; - for($j=0; $j<$schemaContents->length; $j++) { - $importNode = $schemaContents->item($j); - $importedNode = $schema->importNode($importNode, true); - $schema->documentElement->appendChild($importedNode); - } - $rootSchema->includedSchemaLocations[] = $includeSchemaLocation; - } - - protected function getFullPath($schemaLocation) - { - $customFilePath = - $_SESSION['config']['corepath'] . DIRECTORY_SEPARATOR - . 'custom' . DIRECTORY_SEPARATOR - . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR - . $schemaLocation; - - $relativeFilePath = - $_SESSION['config']['corepath'] . DIRECTORY_SEPARATOR - . $schemaLocation; - - if(is_file($customFilePath)) { - return $customFilePath; - } elseif(is_file($relativeFilePath)) { - return $relativeFilePath; - } elseif(is_file($schemaLocation)) { - return $schemaLocation; - } else { - throw new maarch\Exception("Failed to load schema definition file $schemaLocation or $customFilePath or $relativeFilePath"); - } - - } - -} - -class SchemaNode - extends DOMNode -{ - -} - - -class SchemaElement - extends DOMElement -{ - // On xsd:element / xsd:attribute - public function hasDatasource() - { - if($this->hasAttribute('das:source')) - return true; - } - - public function getName() - { - if($this->hasAttribute('name')) { - return $this->getAttribute('name'); - } elseif($this->hasAttribute('ref')) { - return $this->getAttribute('ref'); - } - } - - public function getTable() - { - if($this->hasAttribute('das:table')) { - return $this->getAttribute('das:table'); - } else { - return $this->getAttribute('name'); - } - } - - public function getRightTable() - { - return $this->getAttribute('right-table'); - } - - public function getColumn() - { - if($this->hasAttribute('das:column')) { - return $this->getAttribute('das:column'); - } else { - return $this->getAttribute('name'); - } - } - - public function getOperations() - { - if($this->hasAttribute('das:operations')) { - return $this->getAttribute('das:operations'); - } else { - return '-R--L'; - } - } - - public function isCreatable() - { - $operations = $this->getOperations(); - if(strstr($operations, 'C')) return true; - } - - public function isReadable() - { - $operations = $this->getOperations(); - if(strstr($operations, 'R')) return true; - } - - public function isUpdatable() - { - $operations = $this->getOperations(); - if(strstr($operations, 'U')) return true; - } - - public function isDeletable() - { - $operations = $this->getOperations(); - if(strstr($operations, 'D')) return true; - } - - public function isListable() - { - $operations = $this->getOperations(); - if(strstr($operations, 'L')) return true; - } - - public function isRequired() - { - if($this->tagName == 'xsd:attribute' - && ( $this->getAttribute('use') == "required" - || $this->hasAttribute('default') - || $this->hasAttribute('fixed') - ) - ) { - return true; - } - if($this->tagName == 'xsd:element' - &&( strtolower($this->getAttribute('nillable')) == "false" - || $this->hasAttribute('default') - || $this->hasAttribute('fixed') - || $this->getAttribute('minOccurs') > 0 - || !$this->hasAttribute('minOccurs') - ) - ) { - return true; - } - } - - public function getFilter() - { - return $this->getAttribute('das:filter'); - } - - public function hasDefault() - { - if($this->hasAttribute('default')) return true; - } - - public function hasFixed() - { - if($this->hasAttribute('fixed')) return true; - } - - // On xsd:complexType / xsd:simpleType or das:foreign-key - public function getEnclosure() - { - if($this->getAttribute('das:enclosed') == 'true' - || $this->getAttribute('enclosed') == 'true') - { - return "'"; - } else { - return ""; - } - } - -} - -class SchemaAttribute - extends DOMAttr -{ - -} diff --git a/core/trunk/core/tests/class/UrlTest.php b/core/trunk/core/tests/class/UrlTest.php deleted file mode 100644 index 8ed17f550841a51f5bbe7da5fd9385eeb2dfff3a..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/UrlTest.php +++ /dev/null @@ -1,190 +0,0 @@ -<?php - -require_once dirname(__FILE__) . '/../../class/Url.php'; - -class UrlTest extends PHPUnit_Framework_TestCase -{ - - public function setUp() - { - global $_SERVER; - $this->_old_values = $_SERVER; - $url = 'http://example.com/entreprise/apps/maarch_entreprise/index.php'; - $this->_patchServerVars($url); - } - - public function tearDown() - { - $_SERVER = $this->_old_values; - Url::forget(); - } - - protected function _patchServerVars($url) { - global $_SERVER; - $url_parts = explode("/", $url, 4); - $_SERVER['HTTPS'] = (strpos($url_parts[0], 's') !== false) - ? 'on': ''; - $host_parts = explode(':', $url_parts[2]); - $_SERVER['HTTP_HOST'] = $url_parts[2]; - if (count($host_parts) == 2) { - $_SERVER['SERVER_PORT'] = $host_parts[1]; - } else { - $_SERVER['SERVER_PORT'] = ($_SERVER['HTTPS'] === 'on') - ? '443' : '80'; - } - if ((count($url_parts) > 3)) { - $uriParts = explode("?", $url_parts[3], 2); - $_SERVER['SCRIPT_NAME'] = '/' . $uriParts[0]; - $_SERVER['QUERY_STRING'] = (count($uriParts) > 1) - ? $uriParts[1] : ''; - } else { - $_SERVER['SCRIPT_NAME'] = ""; - $_SERVER['QUERY_STRING'] = ""; - } - } - - - - public function test_cache_cleared_on_forget() { - $old = Url::coreurl(); - Url::forget(); - - - $url = 'http://foo.com' - . '/bar'; - $this->_patchServerVars($url); - - $new = Url::coreurl(); - - $this->assertNotEquals($old, $new); - } - - public function test_cache_must_persist_between_two_instances() - { - $old = Url::coreurl(); - unset($u); - - $this->assertEquals('example.com', Url::host()); - } - - public function test_http_subdir_url_from_apps_index() - { - $url = 'http://example.com' - . '/entreprise/apps/maarch_entreprise/index.php'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'http://example.com/entreprise/', - Url::coreurl() - ); - } - - public function test_http_subdir_url_from_root_index() - { - $url = 'http://example.com' - . '/entreprise/index.php'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'http://example.com/entreprise/', - Url::coreurl() - ); - } - - public function test_https_subdir() - { - $url = 'https://example.com' - . '/entreprise/index.php'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'https://example.com/entreprise/', - Url::coreurl() - ); - $this->assertEquals('https', Url::proto()); - $this->assertEquals('443', Url::port()); - } - - public function test_http_url_at_server_root_root_index() - { - $url = 'http://example.com' - . '/index.php'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'http://example.com/', - Url::coreurl() - ); - $this->assertEquals('/', Url::baseUri()); - $this->assertEquals('/index.php', Url::requestUri()); - } - - public function test_http_url_at_server_root_apps_index() - { - $url = 'http://example.com' - . '/apps/maarch_entreprise/index.php'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'http://example.com/', - Url::coreurl() - ); - $this->assertEquals('/', Url::baseUri()); - $this->assertEquals('/apps/maarch_entreprise/index.php', - Url::requestUri()); - } - - public function test_http_non_standard_port() - { - $url = 'http://example.com:8080' - . '/entreprise/index.php'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'http://example.com:8080/entreprise/', - Url::coreurl() - ); - $this->assertEquals('http', Url::proto()); - $this->assertEquals('8080', Url::port()); - } - - public function test_https_non_standard_port() - { - $url = 'https://example.com:8043' - . '/entreprise/index.php'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'https://example.com:8043/entreprise/', - Url::coreurl() - ); - $this->assertEquals('https', Url::proto()); - $this->assertEquals('8043', Url::port()); - } - - public function test_query_string() - { - $url = 'https://example.com' - . '/entreprise/index.php?foo=bar'; - $this->_patchServerVars($url); - - $this->assertEquals( - 'https://example.com/entreprise/', - Url::coreurl() - ); - $this->assertEquals('/entreprise/index.php', Url::scriptName()); - $this->assertEquals('/entreprise/index.php?foo=bar', Url::requestUri()); - } -} - -#HTTPS - -#'SERVER_PORT' => 80 -#'HTTP_HOST' => 'example.com' -#'SCRIPT_NAME' => 'entreprise/apps/maarch_entreprise/index.php' - -#HTTP_X_FORWARDED_HOST -#HTTP_X_FORWARDED_PORT -#HTTP_X_FORWARDED_PROTO - -#HTTP_BASE_URL / HTTP_X_FORWARDED_PROTO / PATH_INFO diff --git a/core/trunk/core/tests/class/UrlWithProxyTest.php b/core/trunk/core/tests/class/UrlWithProxyTest.php deleted file mode 100644 index 5f8eb6dd436655590e3fc3dc340a8ca4099f1aae..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/UrlWithProxyTest.php +++ /dev/null @@ -1,181 +0,0 @@ -<?php - - -require_once dirname(__FILE__) . '/../../class/Url.php'; - -class UrlWithProxyTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - global $_SERVER; - $this->_old_values = $_SERVER; - $url = 'http://example.com/entreprise/apps/maarch_entreprise/index.php'; - $this->_patchServerVars($url); - } - - public function tearDown() - { - $_SERVER = $this->_old_values; - Url::forget(); - } - - protected function _patchServerVars($url) { - global $_SERVER; - $url_parts = explode("/", $url, 4); - $_SERVER['HTTPS'] = (strpos($url_parts[0], 's') !== false) - ? 'on': ''; - $host_parts = explode(':', $url_parts[2]); - $_SERVER['HTTP_HOST'] = $url_parts[2]; - if (count($host_parts) == 2) { - $_SERVER['SERVER_PORT'] = $host_parts[1]; - } else { - $_SERVER['SERVER_PORT'] = ($_SERVER['HTTPS'] === 'on') - ? '443' : '80'; - } - if ((count($url_parts) > 3)) { - $uriParts = explode("?", $url_parts[3], 2); - $_SERVER['SCRIPT_NAME'] = '/' . $uriParts[0]; - $_SERVER['QUERY_STRING'] = (count($uriParts) > 1) - ? $uriParts[1] : ''; - } else { - $_SERVER['SCRIPT_NAME'] = ""; - $_SERVER['QUERY_STRING'] = ""; - } - } - - protected function _patchServerProxyVars($url) - { - $url_parts = explode("/", $url, 4); - $_SERVER['HTTP_X_FORWARDED_PROTO'] = - (strpos($url_parts[0], 's') !== false) ? 'https' : 'http'; - - $host_parts = explode(':', $url_parts[2]); - - $_SERVER['HTTP_X_FORWARDED_HOST'] = $host_parts[0]; - - if (count($host_parts) == 2) { - $_SERVER['HTTP_X_FORWARDED_PORT'] = $host_parts[1]; - } else { - $_SERVER['HTTP_X_FORWARDED_PORT'] = - ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? '443' : '80'; - } - $_SERVER['HTTP_X_FORWARDED_SCRIPT_NAME'] = - '/' . ((count($url_parts) > 3) ? $url_parts[3] : ''); - - if ((count($url_parts) > 3)) { - $uriParts = explode("?", $url_parts[3], 2); - $_SERVER['HTTP_X_FORWARDED_SCRIPT_NAME'] = '/' . $uriParts[0]; - } else { - $_SERVER['HTTP_X_FORWARDED_SCRIPT_NAME'] = ""; - } - } - - - public function test_different_hosts_root_url() - { - $testCase = array('http://example.com/entreprise/index.php', - 'http://internal.local/entreprise/index.php', - 'http://example.com/entreprise/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - } - - public function test_different_hosts_apps_url() - { - $testCase = array('http://example.com/entreprise/apps/maarch_entreprise/index.php', - 'http://internal.local/entreprise/apps/maarch_entreprise/index.php', - 'http://example.com/entreprise/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - } - - public function test_different_ports_frontend_non_standard() - { - $testCase = array('http://example.com:8080/entreprise/apps/maarch_entreprise/index.php', - 'http://internal.local/entreprise/apps/maarch_entreprise/index.php', - 'http://example.com:8080/entreprise/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - } - - public function test_test_different_ports_backend_non_standard() - { - $testCase = array('http://example.com/entreprise/apps/maarch_entreprise/index.php', - 'http://internal.local:8080/entreprise/apps/maarch_entreprise/index.php', - 'http://example.com/entreprise/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - } - - public function test_test_different_ports_both_non_standard() - { - $testCase = array('http://example.com:8080/entreprise/apps/maarch_entreprise/index.php', - 'http://internal.local:8081/entreprise/apps/maarch_entreprise/index.php', - 'http://example.com:8080/entreprise/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - } - - public function test_different_hosts_and_uris() - { - $testCase = array('http://entreprise.example.com/apps/maarch_entreprise/index.php', - 'http://internal.local/entreprise/apps/maarch_entreprise/index.php', - 'http://entreprise.example.com/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - $this->assertEquals('/apps/maarch_entreprise/index.php', - Url::requestUri()); - } - - public function test_different_hosts_and_uris_root_index() - { - $testCase = array('http://entreprise.example.com/index.php', - 'http://internal.local/entreprise/index.php', - 'http://entreprise.example.com/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - $this->assertEquals('/index.php', - Url::requestUri()); - } - - - - public function test_different_protocols() - { - $testCase = array('https://example.com/entreprise/apps/maarch_entreprise/index.php', - 'http://internal.local/entreprise/apps/maarch_entreprise/index.php', - 'https://example.com/entreprise/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - } - - public function test_different_protocols_on_non_standard_ports() - { - $testCase = array('https://example.com:8043/entreprise/apps/maarch_entreprise/index.php', - 'http://internal.local:8080/entreprise/apps/maarch_entreprise/index.php', - 'https://example.com:8043/entreprise/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - } - - - public function test_with_query_string() - { - $testCase = array('https://example.com/index.php?foo=bar', - 'http://internal.local/index.php?foo=bar', - 'https://example.com/'); - call_user_func_array(array($this, "_test_implementation"), - $testCase); - $this->assertEquals('/index.php', Url::scriptName()); - $this->assertEquals('/index.php?foo=bar', Url::requestUri()); - } - - - - - public function _test_implementation($proxyUrl, $url, $expectedCoreUrl) { - $this->_patchServerVars($url); - $this->_patchServerProxyVars($proxyUrl); - $this->assertEquals($expectedCoreUrl, Url::coreurl()); - } -} \ No newline at end of file diff --git a/core/trunk/core/tests/class/ViewController.php b/core/trunk/core/tests/class/ViewController.php deleted file mode 100644 index c25b1afa54e38d0c2cf51cd869d7781914f27367..0000000000000000000000000000000000000000 --- a/core/trunk/core/tests/class/ViewController.php +++ /dev/null @@ -1,834 +0,0 @@ -<?php - -require_once( - 'core/tests/class/MessageController.php' -); - -class ViewController - extends DOMXPath -{ - public $baseUrl; - public $staticUrl; - public $scriptUrl; - public $fragments = array(); - - //************************************************************************* - // Constructor - //************************************************************************* - function ViewController() - { - $this->basePath = $_SESSION['config']['corepath']; - $this->baseUrl = $_SESSION['config']['coreurl']; - $this->staticUrl = $_SESSION['config']['businessappurl'] - . 'static.php?filename='; - } - - //************************************************************************* - // HTML Source management - //************************************************************************* - function loadHTMLFile($viewFile) - { - $customFilePath = - $_SESSION['config']['corepath'] . DIRECTORY_SEPARATOR - . 'custom' . DIRECTORY_SEPARATOR - . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR - . $viewFile; - - $relativeFilePath = - $_SESSION['config']['corepath'] . DIRECTORY_SEPARATOR - . $viewFile; - - if(is_file($customFilePath)) { - $loadFile = $customFilePath; - } elseif(is_file($relativeFilePath)) { - $loadFile = $relativeFilePath; - } elseif(is_file($viewFile)) { - $loadFile = $viewFile; - } else { - throw new maarch\Exception("Failed to load view file $viewFile"); - } - - $view = new View(); - $view->loadHTMLFile($loadFile); - if(!$view->encoding) $view->encoding = 'UTF-8'; - - parent::__construct($view); - $this->view = $this->document; - - return $this->view; - } - - function loadHTML($viewString) - { - $view = new View(); - $view->loadHTML($viewString); - if(!$view->encoding) $view->encoding = 'UTF-8'; - - parent::__construct($view); - $this->view = $this->document; - - return $this->view; - } - - function showView() - { - print $this->view->saveHTML(); - } - - function getView() - { - return $this->view->documentElement; - } - - function createView() - { - $view = new View(); - $view->encoding = 'UTF-8'; - parent::__construct($view); - $this->view = $this->document; - return $this->view; - } - - function loadFragmentFile($fragmentFile) - { - $fragmentView = new View(); - $fragmentView->loadHTMLFile($loadFile); - if(!$fragmentView->encoding) $fragmentView->encoding = 'UTF-8'; - - $this->fragments[] = $fragmentView; - - $fragment = $this->view->createDocumentFragment(); - $fragment->appendChild($fragmentView->documentElement); - - return $fragment; - } - - function getDataObjectListView( - $dataObjectList - ) { - - } - - function getDataObjectView( - $dataObject, - $mode - ) { - $dataObjectPath = $dataObject->getNodePath(); - - /*************************************************************************** - ** Link CSS - ***************************************************************************/ - $this->setHRefBaseUrl( - 'link', - $this->baseUrl - ); - - /*************************************************************************** - ** Script - ***************************************************************************/ - $this->setSrcBaseUrl( - 'script', - $this->baseUrl . 'js/' - ); - - /*************************************************************************** - ** Images - ***************************************************************************/ - $this->setSrcBaseUrl( - 'img', - $this->staticUrl - ); - - /*************************************************************************** - ** Ids - ***************************************************************************/ - $this->setUniqueIds( - $dataObject - ); - - /*************************************************************************** - ** Data - ***************************************************************************/ - $this->loadDataObject( - $dataObject - ); - - $dataObjectView = - $this->getElementById( - $dataObjectPath - ); - return $dataObjectView; - - } - - //************************************************************************* - // Get tags - //************************************************************************* - function getElementById($id, $contextNode=false) - { - if(!$contextNode) $contextNode = $this->view->documentElement; - $elements = $this->query("//*[@id='$id']", $contextNode); - if($elements->length == 0) return false; - return $elements->item(0); - } - - function getIds() - { - $ids = $this->query("//@id"); - return $ids; - } - - function getLabelFor($for) - { - $labels = $this->query("//label[@for='$for']"); - if($labels->length == 0) return false; - return $labels->item(0); - } - - function getLabels() - { - $labels = $this->query("//label"); - return $labels; - } - - function getImgs() - { - $imgs = $this->query("//img | //IMG"); - return $imgs; - } - - function getScripts() - { - $scripts = $this->query("//script | //SCRIPT"); - return $scripts; - } - - function getTableHeaderCols() - { - $th = $this->query("//th[@axis]"); - if($th->length == 0) return false; - return $th; - } - - function getDataTranslate() - { - $dataTranslate = $this->query("//*[@data-translate]"); - if($dataTranslate->length == 0) return false; - return $dataTranslate; - } - - //************************************************************************* - // Update tags - //************************************************************************* - function setLabelFor($for, $text) - { - $label = $this->getlabelFor($for); - if($label) $label->nodeValue = htmlentities($text, 0, $this->document->encoding); - } - - function setUniqueIds( - $RefData = false - ) { - if($RefData && method_exists($RefData, 'getNodePath')) { - $uniqueId = $RefData->getNodePath(); - if(substr($uniqueId, -3) == '[1]') { - $uniqueId = substr($uniqueId, 0, -3); - echo $uniqueId; - } - } else { - $uniqueId = uniqid(); - } - - // Add uniqueId prefix to ids - $ids = $this->getIds(); - for ($i=0; $i<$ids->length; $i++) { - $id = $ids->item($i); - $localId = $id->nodeValue; - - if(strpos($localId, $uniqueId) === 0) continue; - - /*$prefix = ''; - if($localId && $RefData->hasAttribute($localId)) { - $prefix = '@'; - }*/ - $newId = $uniqueId; - if($localId) { - $newId .= '/' . $prefix . $localId; - } - $id->nodeValue = $newId; - } - - // Add uniqueId to label fors - $labels = $this->getLabels(); - for ($i=0; $i<$labels->length; $i++) { - $label = $labels->item($i); - $localLabelFor = $label->getAttribute('for'); - if(strpos($localLabelFor, $uniqueId) === 0) continue; - - /*$prefix = ''; - if($localLabelFor && $RefData->hasAttribute($localLabelFor)) { - $prefix = '@'; - }*/ - $newLabelFor = $uniqueId; - if($localLabelFor) { - $newLabelFor .= '/' . $localLabelFor; - } - $label->setAttribute( - 'for', - $newLabelFor - ); - } - } - - function setSrcBaseUrl($tagName, $baseUrl) - { - $tags = $this->view->getElementsByTagName($tagName); - $tagsLength = $tags->length; - for ($i=0; $i<$tagsLength; $i++) { - $tag = $tags->item($i); - $tag->setAttribute( - 'src', - $baseUrl . $tag->getAttribute('src') - ); - } - } - - function setHRefBaseUrl($tagName, $baseUrl) - { - $tags = $this->view->getElementsByTagName($tagName); - $tagsLength = $tags->length; - for ($i=0; $i<$tagsLength; $i++) { - $tag = $tags->item($i); - $tag->setAttribute( - 'href', - $baseUrl . $tag->getAttribute('href') - ); - } - } - - function loadDataObject( - $DataObject, - $loadChildren = true - ) { - $DataObjectPath = $DataObject->getNodePath(); - $nodes = $DataObject->query('./* | ./@*'); - $nodeCount = $nodes->length; - for($i=0; $i<$nodeCount; $i++) { - $node = $nodes->item($i); - switch($node->nodeType) { - case XML_ELEMENT_NODE: - if($node->getElementsByTagName('*')->length == 0) { - // DataObjectProperty - $nodeName = $node->tagName; - } else { - // DataObject - if($loadChildren) { - $this->loadDataObject( - $node, - $loadChildren - ); - } - continue 2; - } - break; - case XML_ATTRIBUTE_NODE: - $nodeName = $node->name; - break; - } - $nodeValue = $node->nodeValue; - // Name of property - $viewElement = - $this->getElementById( - $nodeName - ); - // Path of Object / Name of property - if(!$viewElement) { - $viewElement = - $this->getElementById( - $DataObjectPath . '/' . $nodeName - ); - } - if($viewElement && isset($nodeValue)) { - $this->loadProperty( - $viewElement, - $nodeValue - ); - } - } - - } - - function loadProperty( - $viewElement, - $value - ) { - switch($viewElement->tagName) { - case 'input': - switch($viewElement->getAttribute('type')) { - case 'checkbox': - if($viewElement->getAttribute('value') == $value) - $viewElement->check(); - break; - - default: - $viewElement->setValue($value); - } - break; - - case 'select': - $option = - $this->query( - './/option[@value="'.$value.'"]', - $viewElement - )->item(0); - if($option) { - $option->select(); - if($option->parentNode->tagName == 'optgroup') - $option->parentNode->enable(); - } - - break; - - case 'td': - case 'textarea': - default: - $viewElement->nodeValue = $value; - } - - } - - function translate( - $MessageController - ) { - - $labels = $this->getLabels(); - for ($i=0; $i<$labels->length; $i++) { - $label = $labels->item($i); - $labelFor = $label->getAttribute('for'); - $labelText = $MessageController->getMessageText( - $labelFor - ); - if($labelText == $labelFor) continue; - $label->nodeValue = $labelText; - } - - $buttons = $this->query('//input[@type="button"]'); - for($i=0; $i<$buttons->length; $i++) { - $button = $buttons->item($i); - if($button->hasAttribute('value')) { - $button->setValue( - $MessageController->getMessageText( - $button->getAttribute('value') - ) - ); - } - } - - $titles = $this->query('//@title'); - for($i=0; $i<$titles->length; $i++) { - $title = $titles->item($i); - $title->nodeValue = - $MessageController->getMessageText( - $title->nodeValue - ); - } - - $translates = $this->query('//*[@data-translate]'); - for($i=0; $i<$translates->length; $i++) { - $translate = $translates->item($i); - $message = $translate->getAttribute('data-translate'); - $translation = - $MessageController->getMessageText( - $message - ); - if($translate->hasAttribute('value')) { - $translate->setAttribute( - 'value', - $translation - ); - } else { - $translate->nodeValue = $translation; - } - } - - } - - function disableInputs() - { - $inputs = - $this->query( - '//input | //textarea | //select' - ); - for($i=0; $i<$inputs->length; $i++) { - $inputs->item($i)->disable(); - } - } - -} - -//***************************************************************************** -// HTML PAGE / FRAGMENT -//***************************************************************************** -class View - extends DOMDocument -{ - - //************************************************************************* - // Constructor - //************************************************************************* - function View() - { - parent::__construct(); - $this->registerNodeClass('DOMElement', 'ViewElement'); - $this->registerNodeClass('DOMAttr', 'ViewAttribute'); - $this->registerNodeClass('DOMText', 'ViewText'); - $this->validateOnParse = true; - } - - //************************************************************************* - // DOM - //************************************************************************* - function createElement($tagName, $nodeValue=false) - { - $element = parent::createElement($tagName, $nodeValue); - if(!$this->documentElement) { - $this->appendChild($element); - } - return $element; - } - - //************************************************************************* - // Create tags - //************************************************************************* - function createSelect() - { - $select = $this->createElement('select'); - $this->appendChild($select); - return $select; - } - - function createOption($value, $label) - { - $option = $this->createElement('option', $label); - $option->setAttribute('value', $value); - return $option; - } - - function createOptionGroup($label) - { - $optionGroup = $this->createElement('optgroup'); - $optionGroup->setAttribute('label', $label); - return $optionGroup; - } - - function replaceViewNode($ViewNode, $replaceNode) - { - $replaceNode->parentNode->replaceChild( - $this->importNode($ViewNode, true), - $replaceNode - ); - } - - function createList($tag='ul') - { - $list = $this->createElement($tag); - return $list; - } - - function createTable( - $rows=0, - $columns=0, - $header=false - ) { - $table = $this->createElement('table'); - // Create header - if($header) { - $thead = $this->createElement('thead'); - $table->appendChild($thead); - $headerRow = - $this->createRow($columns, $header=true); - - } - // Create body - $tbody = $this->createElement('tbody'); - $table->appendChild($tbody); - for($i=0; $i<$rows; $i++) { - $row = $this->createRow($columns, $header=false); - $tbody->appendChild($row); - } - return $table; - } - - function createRow( - $columns=0, - $header=false - ) { - $row = $this->createElement('tr'); - for($i=0; $i<$columns; $i++) { - $column = $this->createColumn($header); - $row->appendChild($column); - } - return $row; - } - - function createColumn( - $header=false - ) { - if($header) $tag = 'th'; - else $tag = 'td'; - $column = $this->createElement($tag); - return $column; - } - - //************************************************************************* - // Outputs - //************************************************************************* - public function show() - { - echo $this->saveHTML(); - } - - public function getHTML() - { - return $this->saveHTML(); - } - - -} - - -//***************************************************************************** -// HTML TAGS -//***************************************************************************** -class ViewElement - extends DOMElement -{ - - //************************************************************************* - // Retrieve / display - //************************************************************************* - function getSource() - { - return $this->C14N(); - } - - function show() - { - echo $this->getSource(); - } - - //************************************************************************* - // Structure - //************************************************************************* - function appendViewNode($ViewNode) - { - $this->appendChild( - $this->ownerDocument->importNode($ViewNode, true) - ); - } - - //************************************************************************* - // Search - //************************************************************************* - function getAncestorsByTagName($tagName) - { - $xpath = new DOMXPath($this->ownerDocument); - $ancestors = - $xpath->query( - "./ancestor::*[name()='".$tagName."']", - $this - ); - return $ancestors; - } - - //************************************************************************* - // Standard attributes - //************************************************************************* - function setId($id) - { - $this->setAttribute('id', $id); - } - - function setName($name) - { - $this->setAttribute('name', $name); - } - - function setValue($value) - { - $this->setAttribute('value', $value); - } - - //************************************************************************* - // Custom HTML5 attributes - //************************************************************************* - function setDataAttribute($name, $value) - { - //$this->setAttribute('data-' . $name, htmlentities($value, 0, $this->encoding)); - $this->setAttribute('data-' . $name, $value); - } - - //************************************************************************* - // Lists - //************************************************************************* - function addList($type) - { - $list = $this->ownerDocument->createList($type); - $this->appendChild($list); - return $list; - } - - function addListItem($value, $definition=false) { - switch($this->tagName) { - case 'ul': - case 'ol': - $item = $this->ownerDocument->createElement('li', $value); - $this->appendChild($item); - return $item; - break; - - case 'dl': - $dt = $this->ownerDocument->createElement('dt', $value); - $this->appendChild($dt); - $dd = $this->ownerDocument->createElement('dd', $definition); - $this->appendChild($dd); - return $this->childNodes; - break; - } - - } - - //************************************************************************* - // Table - //************************************************************************* - function addTable( - $rows=0, - $columns=0, - $header=false - ) { - $table = - $this->ownerDocument->createTable( - $rows, - $columns, - $header - ); - $this->appendChild($table); - return $table; - } - - function addRow( - $columns=0, - $header=false - ) { - $row = - $this->ownerDocument->createRow( - $columns, - $header - ); - $this->appendChild($row); - return $row; - } - - function addColumn( - $header=false - ) { - $column = - $this->ownerDocument->createColumn( - $header - ); - $this->appendChild($column); - return $column; - } - - //************************************************************************* - // Inputs - //************************************************************************* - function addOption($value, $label) - { - $option = $this->ownerDocument->createOption($value, $label); - $this->appendChild($option); - return $option; - } - - function addOptionGroup($label) - { - $optionGroup = $this->ownerDocument->createOptionGroup($label); - $this->appendChild($optionGroup); - return $optionGroup; - } - - function disable() - { - $this->setAttribute('disabled', 'disabled'); - } - - function enable() - { - $this->removeAttribute('disabled'); - } - - function select() - { - $this->setAttribute('selected', 'selected'); - } - - function unselect() - { - $this->removeAttribute('selected'); - } - - function check() - { - $this->setAttribute('checked', 'checked'); - } - - function uncheck() - { - $this->removeAttribute('checked'); - } - - - //************************************************************************* - // Style - //************************************************************************* - function setStyle($name, $value) { - //echo "<br/>Set style $name = $value"; - if($this->hasAttribute('style')) { - //echo "<br/>" . $this->tagName . " Has attribute 'style'"; - $style = $this->getAttribute('style'); - if(preg_match("/".$name.":[\.|\s]*[^;]*/i", $style)) { - $style = preg_replace( - "/".$name.":[\.|\s]*[^;]*/i", - $name.": " . $value, - $style - ); - } else { - $style .= $name . ": " . $value . ";"; - } - } else { - //echo "<br/>no attribute 'style'"; - $style = $name . ": " . $value . ";"; - } - $this->setAttribute('style', $style); - } - - -} - -//***************************************************************************** -// ATTRIBUTES -//***************************************************************************** -class ViewAttribute - extends DOMAttr -{ - -} - -//***************************************************************************** -// TEXT -//***************************************************************************** -class ViewText - extends DOMText -{ - -} diff --git a/core/trunk/core/where_targets.php b/core/trunk/core/where_targets.php index ff11c7ad4511a2c69f681f05210ffcbbcfd49e88..4ac472d737ebdea1a330b31cb2b7a39cffda4b65 100644 --- a/core/trunk/core/where_targets.php +++ b/core/trunk/core/where_targets.php @@ -3,10 +3,3 @@ $core = new core_tools(); $core->load_lang(); $_ENV['targets'] = array(); $_ENV['targets']['DOC'] = _DOCS; - -if($core->is_module_loaded('moreq')) -{ - $_ENV['targets']['CLASS'] = _CLASS_SCHEME; -} - -?> diff --git a/core/trunk/core/xml/DataAccessService_Messages.xml b/core/trunk/core/xml/DataAccessService_Messages.xml deleted file mode 100644 index fd0ca06848f6de49f11abc9073e0e2415d01f304..0000000000000000000000000000000000000000 --- a/core/trunk/core/xml/DataAccessService_Messages.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<messages> - <message id='query_error' level='3'> - <text lang='fr'>Erreur sql [%1$s] lors de la requête = [%2$s]</text> - </message> -</messages> \ No newline at end of file diff --git a/core/trunk/core/xml/DataObjectController_Messages.xml b/core/trunk/core/xml/DataObjectController_Messages.xml deleted file mode 100644 index a150fdb53c93ee8c1de950acc77bc09156fe6703..0000000000000000000000000000000000000000 --- a/core/trunk/core/xml/DataObjectController_Messages.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<messages> - <message id='libxml1824' level='2'> - <text lang='fr'>Element '%1$s': '%2$s' n'est pas une valeur valide pour le type '%3$s'.</text> - </message> - <message id='libxml1824_attr' level='2'> - <text lang='fr'>Element '%1$s', attribut '%2$s': '%3$s' n'est pas une valeur valide pour le type '%4$s'.</text> - </message> - <message id='libxml1824_empty' level='2'> - <text lang='fr'>Element '%1$s': valeur obligatoire.</text> - </message> - <message id='libxml1824_empty_attr' level='2'> - <text lang='fr'>Element '%1$s', attribut '%2$s': valeur obligatoire.</text> - </message> - <message id='libxml1840' level='2'> - <text lang='fr'>Element '%1$s': [contrôle '%2$s'] La valeur '%3$s' n'est pas autorisée.</text> - </message> - <message id='libxml1840_empty' level='2'> - <text lang='fr'>Element '%1$s': [contrôle '%2$s'] La valeur 'nulle' n'est pas autorisée.</text> - </message> - <message id='libxml1840_attr' level='2'> - <text lang='fr'>Element '%1$s', attribut '%2$s': [contrôle '%3$s'] La valeur '%4$s' n'est pas autorisée.</text> - </message> - <message id='libxml1840_empty_attr' level='2'> - <text lang='fr'>Element '%1$s', attribut '%2$s': [contrôle '%3$s'] La valeur 'nulle' n'est pas autorisée.</text> - </message> - <message id='libxml1866' level='2'> - <text lang='fr'>Element '%1$s', attribut '%2$s': L'attribut n'est pas autorisé.</text> - </message> - <message id='libxml1871' level='2'> - <text lang='fr'>Element '%1$s': L'élément n'est pas autorisé.</text> - </message> - <message id='DataObjectController::read' level='0'> - <text lang='fr'>Objet %1$s chargé</text> - </message> - <message id='DataObjectController::create' level='0'> - <text lang='fr'>Object %1$s créé</text> - </message> - <message id='DataObjectController::validate_error' level='2'> - <text lang='fr'>Objet %1$s non valide : la valeur %3$s n'est pas autorisée pour %2$s</text> - </message> - <message id='DataObjectController::save_error' level='0'> - <text lang='fr'>Objet %1$s sauvegardé</text> - </message> - <message id='DataObjectController::save_error' level='2'> - <text lang='fr'>Objet %1$s non sauvegardé</text> - </message> -</messages> \ No newline at end of file diff --git a/core/trunk/ws_client.php b/core/trunk/ws_client.php deleted file mode 100755 index aefa22480bb49d19c24afea624e0b8aec1c9cabb..0000000000000000000000000000000000000000 --- a/core/trunk/ws_client.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -require('SOAP/Client.php'); -$proxy = array('user' => $_REQUEST['proxy1'], 'pass' => $_REQUEST['proxy2'], 'timeout' => '600'); -$wsdl = new SOAP_WSDL('http://127.0.0.1/maarch_entreprise/ws_server.php?WSDL', $proxy, false); -$client = $wsdl->getProxy(); -/*************** view Maarch document *********************/ -$fileContentArray = array(); -$fileContentArray = $client->viewResource((integer) $_REQUEST['id'], $_REQUEST['table']); -if($fileContentArray->status == "ok") { - $fileContent = base64_decode($fileContentArray->file_content); - $Fnm = $fileContentArray->tmp_path . DIRECTORY_SEPARATOR . rand() - . "_" . md5($fileContent) . "." . strtolower($fileContentArray->ext); - $inF = fopen($Fnm, "w"); - fwrite($inF, $fileContent); - fclose($inF); - header("Pragma: public"); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - header("Content-Type: ".strtolower($fileContentArray->mime_type)); - header("Content-Disposition: inline; filename=" - . basename('maarch.' . strtolower($fileContentArray->ext)) . ";" - ); - header("Content-Transfer-Encoding: binary"); - readfile($Fnm); - exit(); -} else { - echo $fileContentArray->error; -}