1 /*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | http://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Christian Stocker <chregu@php.net> |
14 | Rob Richards <rrichards@php.net> |
15 +----------------------------------------------------------------------+
16 */
17
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21
22 #include "php.h"
23 #if defined(HAVE_LIBXML) && defined(HAVE_DOM)
24 #include "php_dom.h"
25
26
27 /*
28 * class DOMEntity extends DOMNode
29 *
30 * URL: https://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-527DCFF2
31 * Since:
32 */
33
34 /* {{{ publicId string
35 readonly=yes
36 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025
37 Since:
38 */
dom_entity_public_id_read(dom_object * obj,zval * retval)39 int dom_entity_public_id_read(dom_object *obj, zval *retval)
40 {
41 xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
42
43 if (nodep == NULL) {
44 php_dom_throw_error(INVALID_STATE_ERR, 0);
45 return FAILURE;
46 }
47
48 if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
49 ZVAL_NULL(retval);
50 } else {
51 ZVAL_STRING(retval, (char *) (nodep->ExternalID));
52 }
53
54 return SUCCESS;
55 }
56
57 /* }}} */
58
59 /* {{{ systemId string
60 readonly=yes
61 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7C29F3E
62 Since:
63 */
dom_entity_system_id_read(dom_object * obj,zval * retval)64 int dom_entity_system_id_read(dom_object *obj, zval *retval)
65 {
66 xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
67
68 if (nodep == NULL) {
69 php_dom_throw_error(INVALID_STATE_ERR, 0);
70 return FAILURE;
71 }
72
73 if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
74 ZVAL_NULL(retval);
75 } else {
76 ZVAL_STRING(retval, (char *) (nodep->SystemID));
77 }
78
79 return SUCCESS;
80 }
81
82 /* }}} */
83
84 /* {{{ notationName string
85 readonly=yes
86 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-6ABAEB38
87 Since:
88 */
dom_entity_notation_name_read(dom_object * obj,zval * retval)89 int dom_entity_notation_name_read(dom_object *obj, zval *retval)
90 {
91 xmlEntity *nodep = (xmlEntity *) dom_object_get_node(obj);
92 char *content;
93
94 if (nodep == NULL) {
95 php_dom_throw_error(INVALID_STATE_ERR, 0);
96 return FAILURE;
97 }
98
99 if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
100 ZVAL_NULL(retval);
101 } else {
102 content = (char *) xmlNodeGetContent((xmlNodePtr) nodep);
103 ZVAL_STRING(retval, content);
104 xmlFree(content);
105 }
106
107 return SUCCESS;
108 }
109
110 /* }}} */
111
112 /* {{{ actualEncoding string
113 readonly=no
114 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-actualEncoding
115 Since: DOM Level 3
116 */
dom_entity_actual_encoding_read(dom_object * obj,zval * retval)117 int dom_entity_actual_encoding_read(dom_object *obj, zval *retval)
118 {
119 ZVAL_NULL(retval);
120 return SUCCESS;
121 }
122
dom_entity_actual_encoding_write(dom_object * obj,zval * newval)123 int dom_entity_actual_encoding_write(dom_object *obj, zval *newval)
124 {
125 return SUCCESS;
126 }
127
128 /* }}} */
129
130 /* {{{ encoding string
131 readonly=no
132 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-encoding
133 Since: DOM Level 3
134 */
dom_entity_encoding_read(dom_object * obj,zval * retval)135 int dom_entity_encoding_read(dom_object *obj, zval *retval)
136 {
137 ZVAL_NULL(retval);
138 return SUCCESS;
139 }
140
dom_entity_encoding_write(dom_object * obj,zval * newval)141 int dom_entity_encoding_write(dom_object *obj, zval *newval)
142 {
143 return SUCCESS;
144 }
145
146 /* }}} */
147
148 /* {{{ version string
149 readonly=no
150 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Entity3-version
151 Since: DOM Level 3
152 */
dom_entity_version_read(dom_object * obj,zval * retval)153 int dom_entity_version_read(dom_object *obj, zval *retval)
154 {
155 ZVAL_NULL(retval);
156 return SUCCESS;
157 }
158
dom_entity_version_write(dom_object * obj,zval * newval)159 int dom_entity_version_write(dom_object *obj, zval *newval)
160 {
161 return SUCCESS;
162 }
163
164 /* }}} */
165
166 #endif
167