Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -3,20 +3,20 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* XML Handler: Rewritten for PHP5
|
||||
* By Matt Mecham
|
||||
* Last Updated: $Date: 2010-09-15 19:24:25 -0400 (Wed, 15 Sep 2010) $
|
||||
* Last Updated: $Date: 2011-08-30 16:47:25 -0400 (Tue, 30 Aug 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Kernel
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since 25th February 2004
|
||||
* @version $Revision: 464 $
|
||||
* @version $Revision: 9433 $
|
||||
*
|
||||
*
|
||||
* Example Usage:
|
||||
@@ -67,7 +67,7 @@
|
||||
* /* Grabbing specific data values from all 'products'... * /
|
||||
* foreach( $xml->fetchElements('product') as $products )
|
||||
* {
|
||||
* print $xml->fetchItem( $products, 'title' ) . "\";
|
||||
* print $xml->fetchItem( $products, 'title' ) . "\\";
|
||||
* }
|
||||
*
|
||||
* /* Prints... * /
|
||||
@@ -155,49 +155,43 @@ class classXML
|
||||
/**
|
||||
* Document character set
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_docCharSet = 'utf-8';
|
||||
protected $_docCharSet = 'utf-8';
|
||||
|
||||
/**
|
||||
* Current document object
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private $_dom;
|
||||
protected $_dom;
|
||||
|
||||
/**
|
||||
* Array of DOM objects
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private $_domObjects = array();
|
||||
protected $_domObjects = array();
|
||||
|
||||
/**
|
||||
* XML array
|
||||
*
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private $_xmlArray = array();
|
||||
protected $_xmlArray = array();
|
||||
|
||||
/**
|
||||
* Conversion class
|
||||
*
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
private static $classConvertCharset;
|
||||
protected static $classConvertCharset;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string Character Set
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( $charSet )
|
||||
{
|
||||
@@ -207,8 +201,7 @@ class classXML
|
||||
/**
|
||||
* Create new document
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function newXMLDocument()
|
||||
{
|
||||
@@ -218,7 +211,6 @@ class classXML
|
||||
/**
|
||||
* Fetch the document
|
||||
*
|
||||
* @access public
|
||||
* @return XML data
|
||||
*/
|
||||
public function fetchDocument()
|
||||
@@ -230,11 +222,10 @@ class classXML
|
||||
/**
|
||||
* Add element into the document
|
||||
*
|
||||
* @access public
|
||||
* @param string Name of tag to create
|
||||
* @param string [Name of parent tag (optional)]
|
||||
* @param array [Attributes]
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function addElement( $tag, $parentTag='', $attributes=array() )
|
||||
{
|
||||
@@ -249,11 +240,10 @@ class classXML
|
||||
* $xml->addElementAsRecord( 'parentTag', 'myTag', $data );
|
||||
* $xml->addElementAsRecord( 'parentTag', array( 'myTag', array( 'attr' => 'value' ) ), $data );
|
||||
*
|
||||
* @access public
|
||||
* @param string Name of parent tag
|
||||
* @param mixed Tag wrapper
|
||||
* @param array Array of data to add
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function addElementAsRecord( $parentTag, $tag, $data )
|
||||
{
|
||||
@@ -314,10 +304,9 @@ class classXML
|
||||
/**
|
||||
* Add attributes to a node
|
||||
*
|
||||
* @access public
|
||||
* @param string Name of tag
|
||||
* @param array Array of attributes in key => value format
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function addAttributes( $tag, $data )
|
||||
{
|
||||
@@ -333,9 +322,8 @@ class classXML
|
||||
/**
|
||||
* Load a document from a file
|
||||
*
|
||||
* @access public
|
||||
* @param string File name
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function load( $filename )
|
||||
{
|
||||
@@ -346,20 +334,26 @@ class classXML
|
||||
/**
|
||||
* Load a document from a string
|
||||
*
|
||||
* @access public
|
||||
* @param string XML Data
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function loadXML( $xmlData )
|
||||
{
|
||||
$this->_dom = new DOMDocument;
|
||||
$this->_dom->loadXML( $xmlData );
|
||||
|
||||
if( defined('LIBXML_PARSEHUGE') )
|
||||
{
|
||||
$this->_dom->loadXML( $xmlData, LIBXML_PARSEHUGE );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_dom->loadXML( $xmlData );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function: Fetch elements based on tag name
|
||||
*
|
||||
* @access public
|
||||
* @param string Tag Name to fetch from the DOM tree
|
||||
* @param object Node to start from
|
||||
* @return array Node elements
|
||||
@@ -375,7 +369,6 @@ class classXML
|
||||
/**
|
||||
* Wrapper function: Fetch all items within a parent tag
|
||||
*
|
||||
* @access public
|
||||
* @param object DOM object as returned from getElementsByTagName
|
||||
* @param array array of node names to skip
|
||||
* @return array Array of elements
|
||||
@@ -406,7 +399,6 @@ class classXML
|
||||
/**
|
||||
* Wrapper function: Fetch items from an element node
|
||||
*
|
||||
* @access public
|
||||
* @param object DOM object as returned from getElementsByTagName
|
||||
* @param string [Optional: Tag name if the DOM is a parent]
|
||||
* @return string Returned item
|
||||
@@ -427,7 +419,6 @@ class classXML
|
||||
/**
|
||||
* Wrapper function: Fetch attributes from an element node's item
|
||||
*
|
||||
* @access public
|
||||
* @param object DOM object as returned from getElementsByTagName
|
||||
* @param string Attribute name required...
|
||||
* @param string [Optional: Tag name if the DOM is a parent]
|
||||
@@ -449,7 +440,6 @@ class classXML
|
||||
/**
|
||||
* Wrapper function: Fetch all attributes from an element node's item
|
||||
*
|
||||
* @access public
|
||||
* @param object DOM object as returned from getElementsByTagName
|
||||
* @param string Tag name to fetch attribute from
|
||||
* @return array Array of node items
|
||||
@@ -471,7 +461,6 @@ class classXML
|
||||
/**
|
||||
* Fetch entire DOM tree into a single array
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function fetchXMLAsArray()
|
||||
@@ -482,11 +471,10 @@ class classXML
|
||||
/**
|
||||
* Internal function to recurse through and collect nodes and data
|
||||
*
|
||||
* @access private
|
||||
* @param DOM object Node element
|
||||
* @return array
|
||||
*/
|
||||
private function _fetchXMLAsArray( $node )
|
||||
protected function _fetchXMLAsArray( $node )
|
||||
{
|
||||
$_xmlArray = array();
|
||||
|
||||
@@ -554,11 +542,10 @@ class classXML
|
||||
/**
|
||||
* Encode CDATA XML attribute (Make safe for transport)
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
private function _xmlConvertSafecdata( $v )
|
||||
protected function _xmlConvertSafecdata( $v )
|
||||
{
|
||||
$v = str_replace( "<![CDATA[", "<!#^#|CDATA|", $v );
|
||||
$v = str_replace( "]]>" , "|#^#]>" , $v );
|
||||
@@ -569,11 +556,10 @@ class classXML
|
||||
/**
|
||||
* Decode CDATA XML attribute (Make safe for transport)
|
||||
*
|
||||
* @access private
|
||||
* @param string Raw data
|
||||
* @return string Converted Data
|
||||
*/
|
||||
private function _xmlUnconvertSafecdata( $v )
|
||||
protected function _xmlUnconvertSafecdata( $v )
|
||||
{
|
||||
$v = str_replace( "<!#^#|CDATA|", "<![CDATA[", $v );
|
||||
$v = str_replace( "|#^#]>" , "]]>" , $v );
|
||||
@@ -584,11 +570,10 @@ class classXML
|
||||
/**
|
||||
* Return a tag object
|
||||
*
|
||||
* @access private
|
||||
* @param string Name of tag
|
||||
* @return object
|
||||
*/
|
||||
private function _node( $tag )
|
||||
protected function _node( $tag )
|
||||
{
|
||||
if ( isset($this->_domObjects[ $tag ]) )
|
||||
{
|
||||
@@ -603,11 +588,10 @@ class classXML
|
||||
/**
|
||||
* Convert from native to UTF-8 for saving XML
|
||||
*
|
||||
* @access private
|
||||
* @param string Input Text
|
||||
* @return string Converted Text ready for XML saving
|
||||
*/
|
||||
private function _inputToXml( $text )
|
||||
protected function _inputToXml( $text )
|
||||
{
|
||||
/* Do we need to make safe on CDATA? */
|
||||
if ( preg_match( "/['\"\[\]<>&]/", $text ) )
|
||||
@@ -634,11 +618,10 @@ class classXML
|
||||
/**
|
||||
* Convert from UTF-8 to native for saving XML
|
||||
*
|
||||
* @access private
|
||||
* @param string Input Text
|
||||
* @return string Converted Text ready for returning to app
|
||||
*/
|
||||
private function _xmlToOutput( $text )
|
||||
protected function _xmlToOutput( $text )
|
||||
{
|
||||
/* Unconvert cdata */
|
||||
$text = $this->_xmlUnconvertSafecdata( $text );
|
||||
@@ -662,14 +645,13 @@ class classXML
|
||||
/**
|
||||
* Convert a string between charsets. XML will always be UTF-8
|
||||
*
|
||||
* @access private
|
||||
* @param string Input String
|
||||
* @param string Current char set
|
||||
* @param string Destination char set
|
||||
* @return string Parsed string
|
||||
* @todo [Future] If an error is set in classConvertCharset, show it or log it somehow
|
||||
*/
|
||||
private function _convertCharsets( $text, $original_cset, $destination_cset="UTF-8" )
|
||||
protected function _convertCharsets( $text, $original_cset, $destination_cset="UTF-8" )
|
||||
{
|
||||
$original_cset = strtolower($original_cset);
|
||||
$destination_cset = strtolower( $destination_cset );
|
||||
@@ -686,7 +668,7 @@ class classXML
|
||||
|
||||
if ( ! is_object( self::$classConvertCharset ) )
|
||||
{
|
||||
require_once( dirname(__FILE__) . '/classConvertCharset.php' );
|
||||
require_once( dirname(__FILE__) . '/classConvertCharset.php' );/*noLibHook*/
|
||||
self::$classConvertCharset = new classConvertCharset();
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
Reference in new issue
Block a user