2003-06-05 17:06:52 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-08 08:18:22 +00:00
|
|
|
| PHP Version 5 |
|
2003-06-05 17:06:52 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2014-01-03 03:08:10 +00:00
|
|
|
| Copyright (c) 1997-2014 The PHP Group |
|
2003-06-05 17:06:52 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2003-06-05 17:06:52 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2003-06-05 17:06:52 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Christian Stocker <chregu@php.net> |
|
|
|
|
| Rob Richards <rrichards@php.net> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "php.h"
|
2003-08-22 15:04:29 +00:00
|
|
|
#if HAVE_LIBXML && HAVE_DOM
|
2003-06-05 17:06:52 +00:00
|
|
|
#include "php_dom.h"
|
|
|
|
|
|
|
|
/*
|
2004-05-31 12:50:28 +00:00
|
|
|
* class DOMDocumentType extends DOMNode
|
2003-06-05 17:06:52 +00:00
|
|
|
*
|
|
|
|
* URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-412266927
|
|
|
|
* Since:
|
|
|
|
*/
|
|
|
|
|
2007-09-27 18:00:48 +00:00
|
|
|
const zend_function_entry php_dom_documenttype_class_functions[] = {
|
2011-07-25 11:42:53 +00:00
|
|
|
PHP_FE_END
|
2003-06-05 17:06:52 +00:00
|
|
|
};
|
|
|
|
|
2004-11-18 19:54:30 +00:00
|
|
|
/* {{{ name string
|
2003-06-05 17:06:52 +00:00
|
|
|
readonly=yes
|
|
|
|
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1844763134
|
|
|
|
Since:
|
|
|
|
*/
|
2014-04-15 18:30:41 +00:00
|
|
|
int dom_documenttype_name_read(dom_object *obj, zval *retval TSRMLS_DC)
|
2003-06-05 17:06:52 +00:00
|
|
|
{
|
2014-04-15 18:30:41 +00:00
|
|
|
xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
|
2004-02-16 13:06:33 +00:00
|
|
|
|
|
|
|
if (dtdptr == NULL) {
|
|
|
|
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-04-15 18:30:41 +00:00
|
|
|
ZVAL_STRING(retval, (char *) (dtdptr->name));
|
2003-06-05 17:06:52 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
|
2004-11-18 19:54:30 +00:00
|
|
|
/* {{{ entities DOMNamedNodeMap
|
2003-06-05 17:06:52 +00:00
|
|
|
readonly=yes
|
|
|
|
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1788794630
|
|
|
|
Since:
|
|
|
|
*/
|
2014-04-15 18:30:41 +00:00
|
|
|
int dom_documenttype_entities_read(dom_object *obj, zval *retval TSRMLS_DC)
|
2003-06-05 17:06:52 +00:00
|
|
|
{
|
2014-04-15 18:30:41 +00:00
|
|
|
xmlDtdPtr doctypep = (xmlDtdPtr) dom_object_get_node(obj);
|
2003-06-05 17:06:52 +00:00
|
|
|
xmlHashTable *entityht;
|
2003-11-29 20:40:18 +00:00
|
|
|
dom_object *intern;
|
2003-06-05 17:06:52 +00:00
|
|
|
|
2004-02-16 13:06:33 +00:00
|
|
|
if (doctypep == NULL) {
|
|
|
|
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-04-15 18:30:41 +00:00
|
|
|
php_dom_create_interator(retval, DOM_NAMEDNODEMAP TSRMLS_CC);
|
2003-06-05 17:06:52 +00:00
|
|
|
|
|
|
|
entityht = (xmlHashTable *) doctypep->entities;
|
2003-11-29 20:40:18 +00:00
|
|
|
|
2014-04-15 18:30:41 +00:00
|
|
|
intern = Z_DOMOBJ_P(retval);
|
2004-08-30 15:07:20 +00:00
|
|
|
dom_namednode_iter(obj, XML_ENTITY_NODE, intern, entityht, NULL, NULL TSRMLS_CC);
|
2003-11-29 20:40:18 +00:00
|
|
|
|
2003-06-05 17:06:52 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
|
2004-11-18 19:54:30 +00:00
|
|
|
/* {{{ notations DOMNamedNodeMap
|
2003-06-05 17:06:52 +00:00
|
|
|
readonly=yes
|
|
|
|
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D46829EF
|
|
|
|
Since:
|
|
|
|
*/
|
2014-04-15 18:30:41 +00:00
|
|
|
int dom_documenttype_notations_read(dom_object *obj, zval *retval TSRMLS_DC)
|
2003-06-05 17:06:52 +00:00
|
|
|
{
|
2014-04-15 18:30:41 +00:00
|
|
|
xmlDtdPtr doctypep = (xmlDtdPtr) dom_object_get_node(obj);
|
2003-06-05 17:06:52 +00:00
|
|
|
xmlHashTable *notationht;
|
2003-11-29 20:40:18 +00:00
|
|
|
dom_object *intern;
|
2003-06-05 17:06:52 +00:00
|
|
|
|
2004-02-16 13:06:33 +00:00
|
|
|
if (doctypep == NULL) {
|
|
|
|
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-04-15 18:30:41 +00:00
|
|
|
php_dom_create_interator(retval, DOM_NAMEDNODEMAP TSRMLS_CC);
|
2003-12-03 21:27:01 +00:00
|
|
|
|
2003-11-29 20:40:18 +00:00
|
|
|
notationht = (xmlHashTable *) doctypep->notations;
|
2003-06-05 17:06:52 +00:00
|
|
|
|
2014-04-15 18:30:41 +00:00
|
|
|
intern = Z_DOMOBJ_P(retval);
|
2004-08-30 15:07:20 +00:00
|
|
|
dom_namednode_iter(obj, XML_NOTATION_NODE, intern, notationht, NULL, NULL TSRMLS_CC);
|
2003-06-05 17:06:52 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
|
2004-11-18 19:54:30 +00:00
|
|
|
/* {{{ publicId string
|
2003-06-05 17:06:52 +00:00
|
|
|
readonly=yes
|
|
|
|
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-publicId
|
|
|
|
Since: DOM Level 2
|
|
|
|
*/
|
2014-04-15 18:30:41 +00:00
|
|
|
int dom_documenttype_public_id_read(dom_object *obj, zval *retval TSRMLS_DC)
|
2003-06-05 17:06:52 +00:00
|
|
|
{
|
2014-04-15 18:30:41 +00:00
|
|
|
xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
|
2003-06-05 17:06:52 +00:00
|
|
|
|
2004-02-16 13:06:33 +00:00
|
|
|
if (dtdptr == NULL) {
|
|
|
|
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2003-06-05 17:06:52 +00:00
|
|
|
if (dtdptr->ExternalID) {
|
2014-04-15 18:30:41 +00:00
|
|
|
ZVAL_STRING(retval, (char *) (dtdptr->ExternalID));
|
2003-06-05 17:06:52 +00:00
|
|
|
} else {
|
2014-04-15 18:30:41 +00:00
|
|
|
ZVAL_EMPTY_STRING(retval);
|
2003-06-05 17:06:52 +00:00
|
|
|
}
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
|
2004-11-18 19:54:30 +00:00
|
|
|
/* {{{ systemId string
|
2003-06-05 17:06:52 +00:00
|
|
|
readonly=yes
|
|
|
|
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-systemId
|
|
|
|
Since: DOM Level 2
|
|
|
|
*/
|
2014-04-15 18:30:41 +00:00
|
|
|
int dom_documenttype_system_id_read(dom_object *obj, zval *retval TSRMLS_DC)
|
2003-06-05 17:06:52 +00:00
|
|
|
{
|
2014-04-15 18:30:41 +00:00
|
|
|
xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
|
2003-06-05 17:06:52 +00:00
|
|
|
|
2004-02-16 13:06:33 +00:00
|
|
|
if (dtdptr == NULL) {
|
|
|
|
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2003-06-05 17:06:52 +00:00
|
|
|
if (dtdptr->SystemID) {
|
2014-04-15 18:30:41 +00:00
|
|
|
ZVAL_STRING(retval, (char *) (dtdptr->SystemID));
|
2003-06-05 17:06:52 +00:00
|
|
|
} else {
|
2014-04-15 18:30:41 +00:00
|
|
|
ZVAL_EMPTY_STRING(retval);
|
2003-06-05 17:06:52 +00:00
|
|
|
}
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
|
2004-11-18 19:54:30 +00:00
|
|
|
/* {{{ internalSubset string
|
2003-06-05 17:06:52 +00:00
|
|
|
readonly=yes
|
|
|
|
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-Core-DocType-internalSubset
|
|
|
|
Since: DOM Level 2
|
|
|
|
*/
|
2014-04-15 18:30:41 +00:00
|
|
|
int dom_documenttype_internal_subset_read(dom_object *obj, zval *retval TSRMLS_DC)
|
2003-06-05 17:06:52 +00:00
|
|
|
{
|
2014-04-15 18:30:41 +00:00
|
|
|
xmlDtdPtr dtdptr = (xmlDtdPtr) dom_object_get_node(obj);
|
2014-04-16 12:13:45 +00:00
|
|
|
xmlDtdPtr intsubset;
|
2003-06-05 17:06:52 +00:00
|
|
|
|
2004-02-16 13:06:33 +00:00
|
|
|
if (dtdptr == NULL) {
|
|
|
|
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2014-04-25 20:32:51 +00:00
|
|
|
if (dtdptr->doc != NULL && ((intsubset = xmlGetIntSubset(dtdptr->doc)) != NULL)) {
|
2014-04-16 12:13:45 +00:00
|
|
|
smart_str ret_buf = {0};
|
|
|
|
xmlNodePtr cur = intsubset->children;
|
|
|
|
|
|
|
|
while (cur != NULL) {
|
|
|
|
xmlOutputBuffer *buff = xmlAllocOutputBuffer(NULL);
|
|
|
|
|
|
|
|
if (buff != NULL) {
|
|
|
|
xmlNodeDumpOutput (buff, NULL, cur, 0, 0, NULL);
|
|
|
|
xmlOutputBufferFlush(buff);
|
|
|
|
|
2012-08-09 18:02:33 +00:00
|
|
|
#ifdef LIBXML2_NEW_BUFFER
|
2014-04-16 13:06:57 +00:00
|
|
|
smart_str_appendl(&ret_buf, xmlOutputBufferGetContent(buff), xmlOutputBufferGetSize(buff));
|
2012-08-09 18:02:33 +00:00
|
|
|
#else
|
2014-04-16 12:13:45 +00:00
|
|
|
smart_str_appendl(&ret_buf, buff->buffer->content, buff->buffer->use);
|
2012-08-09 18:02:33 +00:00
|
|
|
#endif
|
2014-04-16 12:13:45 +00:00
|
|
|
|
|
|
|
(void)xmlOutputBufferClose(buff);
|
|
|
|
}
|
|
|
|
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
|
2014-04-25 20:32:51 +00:00
|
|
|
if (ret_buf.s) {
|
|
|
|
smart_str_0(&ret_buf);
|
|
|
|
ZVAL_STR(retval, ret_buf.s);
|
2003-06-05 17:06:52 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-25 20:32:51 +00:00
|
|
|
ZVAL_NULL(retval);
|
2003-06-05 17:06:52 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* }}} */
|
|
|
|
|
2003-08-22 15:04:29 +00:00
|
|
|
#endif
|
2008-08-14 08:39:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
* vim600: noet sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: noet sw=4 ts=4
|
|
|
|
*/
|