cvs: pear(ZEND_ENGINE_2) /XML_Transformer Transformer.php test.php /XML_Transformer/Transformer CallbackRegistry.php Namespace.php Util.php
/XML_Transformer/Transformer/Driver Cache.php OutputBuffer.php

From: Date: Sat, 18 Jan 2003 18:37:34 +0000
Subject: cvs: pear(ZEND_ENGINE_2) /XML_Transformer Transformer.php test.php /XML_Transformer/Transformer CallbackRegistry.php Namespace.php Util.php
/XML_Transformer/Transformer/Driver Cache.php OutputBuffer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8387@lists.php.net to get a copy of this message
sebastian Sat Jan 18 13:37:34 2003 EDT Modified files: (Branch: ZEND_ENGINE_2) /pear/XML_Transformer Transformer.php test.php /pear/XML_Transformer/Transformer CallbackRegistry.php Namespace.php Util.php /pear/XML_Transformer/Transformer/Driver Cache.php OutputBuffer.php Log: First set of changes to leverage the new features of the ZendEngine 2.

Index: pear/XML_Transformer/Transformer.php diff -u pear/XML_Transformer/Transformer.php:1.109.2.1 pear/XML_Transformer/Transformer.php:1.109.2.2 --- pear/XML_Transformer/Transformer.php:1.109.2.1 Sat Jan 18 13:16:27 2003 +++ pear/XML_Transformer/Transformer.php Sat Jan 18 13:37:33 2003 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +---------------------------------------------------------------------------+ // -// $Id: Transformer.php,v 1.109.2.1 2003/01/18 18:16:27 sebastian Exp $ +// $Id: Transformer.php,v 1.109.2.2 2003/01/18 18:37:33 sebastian Exp $ // require_once 'XML/Transformer/CallbackRegistry.php'; @@ -28,17 +28,17 @@ * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @author Kristian Köhntopp <kris@koehntopp.de> -* @version $Revision: 1.109.2.1 $ +* @version $Revision: 1.109.2.2 $ * @access public */ -class XML_Transformer { +class XML::Transformer { // {{{ Members /** * @var object - * @access private + * @access protected */ - var $_callbackRegistry = null; + protected $callbackRegistry = null; /** * If true, XML attribute and element names will be @@ -46,9 +46,9 @@ * * @var boolean * @access private - * @see $_caseFoldingTo + * @see $caseFoldingTo */ - var $_caseFolding = false; + private $caseFolding = false; /** * Can be set to either CASE_UPPER or CASE_LOWER @@ -56,9 +56,9 @@ * * @var integer * @access private - * @see $_caseFolding + * @see $caseFolding */ - var $_caseFoldingTo = CASE_UPPER; + private $caseFoldingTo = CASE_UPPER; /** * If true, debugging information will be sent to @@ -66,9 +66,9 @@ * * @var boolean * @access private - * @see $_debugFilter + * @see $debugFilter */ - var $_debug = false; + private $debug = false; /** * If not empty, debugging information will only be generated @@ -76,9 +76,9 @@ * * @var array * @access private - * @see $_debug + * @see $debug */ - var $_debugFilter = array(); + private $debugFilter = array(); /** * Specifies the target to which error messages and @@ -86,48 +86,48 @@ * * @var string * @access private - * @see $_debug + * @see $debug */ - var $_logTarget = 'error_log'; + private $logTarget = 'error_log'; /** * @var array * @access private */ - var $_attributesStack = array(); + private $attributesStack = array(); /** * @var array * @access private */ - var $_cdataStack = array(''); + private $cdataStack = array(''); /** * @var array * @access private */ - var $_elementStack = array(); + private $elementStack = array(); /** * @var integer * @access private */ - var $_level = 0; + private $level = 0; /** * @var string * @access private */ - var $_lastProcessed = ''; + private $lastProcessed = ''; /** * @var boolean * @access public */ - var $_secondPassRequired = false; + public $secondPassRequired = false; // }}} - // {{{ function XML_Transformer($parameters = array()) + // {{{ public function __construct($parameters = array()) /** * Constructor. @@ -135,17 +135,17 @@ * @param array * @access public */ - function XML_Transformer($parameters = array()) { + public function __construct($parameters = array()) { // Parse parameters array. if (isset($parameters['debug'])) { $this->setDebug($parameters['debug']); } - $this->_caseFolding = isset($parameters['caseFolding']) ? $parameters['caseFolding'] : false; - $this->_caseFoldingTo = isset($parameters['caseFoldingTo']) ? $parameters['caseFoldingTo'] : CASE_UPPER; - $this->_lastProcessed = isset($parameters['lastProcessed']) ? $parameters['lastProcessed'] : ''; - $this->_logTarget = isset($parameters['logTarget']) ? $parameters['logTarget'] : 'error_log'; + $this->caseFolding = isset($parameters['caseFolding']) ? $parameters['caseFolding'] : false; + $this->caseFoldingTo = isset($parameters['caseFoldingTo']) ? $parameters['caseFoldingTo'] : CASE_UPPER; + $this->lastProcessed = isset($parameters['lastProcessed']) ? $parameters['lastProcessed'] : ''; + $this->logTarget = isset($parameters['logTarget']) ? $parameters['logTarget'] : 'error_log'; $autoload = isset($parameters['autoload']) ? $parameters['autoload'] : false; $overloadedNamespaces = isset($parameters['overloadedNamespaces']) ? $parameters['overloadedNamespaces'] : array(); @@ -153,7 +153,7 @@ // Initialize callback registry. - $this->_callbackRegistry = &XML_Transformer_CallbackRegistry::singleton( + $this->callbackRegistry = XML::Transformer::CallbackRegistry::getInstance( $recursiveOperation ); @@ -165,12 +165,12 @@ } if ($autoload !== false) { - $this->_autoload($autoload); + $this->autoload($autoload); } } // }}} - // {{{ function canonicalize($target) + // {{{ public function canonicalize($target) /** * Canonicalizes a given attributes array or element name. @@ -179,14 +179,14 @@ * @return mixed * @access public */ - function canonicalize($target) { - if ($this->_caseFolding) { + public function canonicalize($target) { + if ($this->caseFolding) { if (is_string($target)) { - return ($this->_caseFoldingTo == CASE_UPPER) ? strtoupper($target) : strtolower($target); + return ($this->caseFoldingTo == CASE_UPPER) ? strtoupper($target) : strtolower($target); } else { return array_change_key_case( $target, - $this->_caseFoldingTo + $this->caseFoldingTo ); } } @@ -195,7 +195,7 @@ } // }}} - // {{{ function stackdump() + // {{{ public function stackdump() /** * Returns a stack dump as a debugging aid. @@ -204,19 +204,19 @@ * @return string * @access public */ - function stackdump() { + public function stackdump() { $stackdump = sprintf( "Stackdump (level: %s) follows:\n", - $this->_level + $this->level ); - for ($i = $this->_level; $i >= 0; $i--) { + for ($i = $this->level; $i >= 0; $i--) { $stackdump .= sprintf( "level=%d\nelement=%s:%s\ncdata=%s\n\n", $i, - isset($this->_elementStack[$i]) ? $this->_elementStack[$i] : '', - isset($this->_attributesStack[$i]) ? XML_Transformer_Util::attributesToString($this->_attributesStack[$i]) : '', - isset($this->_cdataStack[$i]) ? $this->_cdataStack[$i] : '' + isset($this->elementStack[$i]) ? $this->elementStack[$i] : '', + isset($this->attributesStack[$i]) ? XML::Transformer::Util::attributesToString($this->attributesStack[$i]) : '', + isset($this->cdataStack[$i]) ? $this->cdataStack[$i] : '' ); } @@ -224,7 +224,7 @@ } // }}} - // {{{ function overloadNamespace($namespacePrefix, &$object, $recursiveOperation = '') + // {{{ public function overloadNamespace($namespacePrefix, $object, $recursiveOperation = '') /** * Overloads an XML Namespace. @@ -234,7 +234,7 @@ * @param boolean * @access public */ - function overloadNamespace($namespacePrefix, &$object, $recursiveOperation = '') { + public function overloadNamespace($namespacePrefix, $object, $recursiveOperation = '') { if (empty($namespacePrefix) || $namespacePrefix == '&MAIN') { $namespacePrefix = '&MAIN'; @@ -242,7 +242,7 @@ $namespacePrefix = $this->canonicalize($namespacePrefix); } - $result = $this->_callbackRegistry->overloadNamespace( + $result = $this->callbackRegistry->overloadNamespace( $namespacePrefix, $object, $recursiveOperation @@ -250,7 +250,7 @@ if ($result === true) { if ($object->secondPassRequired) { - $this->_secondPassRequired = true; + $this->secondPassRequired = true; } // Call initObserver() on the object, if it exists. @@ -262,15 +262,15 @@ ); } } else { - XML_Transformer_Util::logMessage( + XML::Transformer::Util::logMessage( $result, - $this->_logTarget + $this->logTarget ); } } // }}} - // {{{ function unOverloadNamespace($namespacePrefix) + // {{{ public function unOverloadNamespace($namespacePrefix) /** * Reverts overloading of a given XML Namespace. @@ -278,12 +278,12 @@ * @param string * @access public */ - function unOverloadNamespace($namespacePrefix) { - $this->_callbackRegistry->unOverloadNamespace($namespacePrefix); + public function unOverloadNamespace($namespacePrefix) { + $this->callbackRegistry->unOverloadNamespace($namespacePrefix); } // }}} - // {{{ function isOverloadedNamespace($namespacePrefix) + // {{{ public function isOverloadedNamespace($namespacePrefix) /** * Returns true if a given namespace is overloaded, @@ -293,14 +293,14 @@ * @return boolean * @access public */ - function isOverloadedNamespace($namespacePrefix) { - return $this->_callbackRegistry->isOverloadedNamespace( + public function isOverloadedNamespace($namespacePrefix) { + return $this->callbackRegistry->isOverloadedNamespace( $this->canonicalize($namespacePrefix) ); } // }}} - // {{{ function setCaseFolding($caseFolding) + // {{{ public function setCaseFolding($caseFolding) /** * Sets the XML parser's case-folding option. @@ -309,16 +309,16 @@ * @param integer * @access public */ - function setCaseFolding($caseFolding, $caseFoldingTo = CASE_UPPER) { + public function setCaseFolding($caseFolding, $caseFoldingTo = CASE_UPPER) { if (is_bool($caseFolding) && ($caseFoldingTo == CASE_LOWER || $caseFoldingTo == CASE_UPPER)) { - $this->_caseFolding = $caseFolding; - $this->_caseFoldingTo = $caseFoldingTo; + $this->caseFolding = $caseFolding; + $this->caseFoldingTo = $caseFoldingTo; } } // }}} - // {{{ function setDebug($debug) + // {{{ public function setDebug($debug) /** * Enables or disables debugging information. @@ -326,19 +326,19 @@ * @param mixed * @access public */ - function setDebug($debug) { + public function setDebug($debug) { if (is_array($debug)) { - $this->_debug = true; - $this->_debugFilter = array_flip($debug); + $this->debug = true; + $this->debugFilter = array_flip($debug); } else if (is_bool($debug)) { - $this->_debug = $debug; + $this->debug = $debug; } } // }}} - // {{{ function setLogTarget($logTarget) + // {{{ public function setLogTarget($logTarget) /** * Sets the target to which error messages and @@ -347,12 +347,12 @@ * @param string * @access public */ - function setLogTarget($logTarget) { - $this->_logTarget = $logTarget; + public function setLogTarget($logTarget) { + $this->logTarget = $logTarget; } // }}} - // {{{ function setRecursiveOperation($recursiveOperation) + // {{{ public function setRecursiveOperation($recursiveOperation) /** * Enables or disables the recursive operation. @@ -360,12 +360,12 @@ * @param boolean * @access public */ - function setRecursiveOperation($recursiveOperation) { - $this->_callbackRegistry->setRecursiveOperation($recursiveOperation); + public function setRecursiveOperation($recursiveOperation) { + $this->callbackRegistry->setRecursiveOperation($recursiveOperation); } // }}} - // {{{ function transform($xml) + // {{{ public function transform($xml) /** * Transforms a given XML string using the registered @@ -375,7 +375,7 @@ * @return string * @access public */ - function transform($xml) { + public function transform($xml) { // Don't process input when it contains no XML elements. if (strpos($xml, '<') === false) { @@ -387,13 +387,13 @@ $parser = xml_parser_create(); xml_set_object($parser, $this); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, $this->_caseFolding); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, $this->caseFolding); // Register SAX callbacks. - xml_set_element_handler($parser, '_startElement', '_endElement'); - xml_set_character_data_handler($parser, '_characterData'); - xml_set_default_handler($parser, '_characterData'); + xml_set_element_handler($parser, 'startElement', 'endElement'); + xml_set_character_data_handler($parser, 'characterData'); + xml_set_default_handler($parser, 'characterData'); // Parse input. @@ -420,37 +420,37 @@ ); } - XML_Transformer_Util::logMessage( + XML::Transformer::Util::logMessage( $errorMessage . "\n" . $this->stackdump(), - $this->_logTarget + $this->logTarget ); return ''; } - $result = $this->_cdataStack[0]; + $result = $this->cdataStack[0]; // Clean up. xml_parser_free($parser); - $this->_attributesStack = array(); - $this->_cdataStack = array(''); - $this->_elementStack = array(); - $this->_level = 0; - $this->_lastProcessed = ''; + $this->attributesStack = array(); + $this->cdataStack = array(''); + $this->elementStack = array(); + $this->level = 0; + $this->lastProcessed = ''; // Perform second transformation pass, if required. - $secondPassRequired = $this->_secondPassRequired; + $secondPassRequired = $this->secondPassRequired; if ($secondPassRequired) { - $this->_secondPassRequired = false; + $this->secondPassRequired = false; $result = $this->transform($result); } - $this->_secondPassRequired = $secondPassRequired; + $this->secondPassRequired = $secondPassRequired; // Return result of the transformation. @@ -458,7 +458,7 @@ } // }}} - // {{{ function _startElement($parser, $element, $attributes) + // {{{ private function startElement($parser, $element, $attributes) /** * SAX callback for 'startElement' event. @@ -468,36 +468,36 @@ * @param array * @access private */ - function _startElement($parser, $element, $attributes) { + private function startElement($parser, $element, $attributes) { $attributes = $this->canonicalize($attributes); $element = $this->canonicalize($element); - $process = $this->_lastProcessed != $element; + $process = $this->lastProcessed != $element; list($namespacePrefix, $qElement) = - XML_Transformer_Util::qualifiedElement($element); + XML::Transformer::Util::qualifiedElement($element); // Push element's name and attributes onto the stack. - $this->_level++; - $this->_elementStack[$this->_level] = $element; - $this->_attributesStack[$this->_level] = $attributes; + $this->level++; + $this->elementStack[$this->level] = $element; + $this->attributesStack[$this->level] = $attributes; - $this->_debug( + $this->debug( sprintf( 'startElement[%d]: %s %s', - $this->_level, + $this->level, $element, - XML_Transformer_Util::attributesToString($attributes) + XML::Transformer::Util::attributesToString($attributes) ), $element ); if ($process && - isset($this->_callbackRegistry->overloadedNamespaces[$namespacePrefix]['active'])) { + isset($this->callbackRegistry->overloadedNamespaces[$namespacePrefix]['active'])) { // The event is handled by a callback // that is registered for this namespace. - $cdata = $this->_callbackRegistry->overloadedNamespaces[$namespacePrefix]['object']->startElement( + $cdata = $this->callbackRegistry->overloadedNamespaces[$namespacePrefix]['object']->startElement( $qElement, $attributes ); @@ -508,15 +508,15 @@ $cdata = sprintf( '<%s%s>', $element, - XML_Transformer_Util::attributesToString($attributes) + XML::Transformer::Util::attributesToString($attributes) ); } - $this->_cdataStack[$this->_level] = $cdata; + $this->cdataStack[$this->level] = $cdata; } // }}} - // {{{ function _endElement($parser, $element) + // {{{ private function endElement($parser, $element) /** * SAX callback for 'endElement' event. @@ -525,21 +525,21 @@ * @param string * @access private */ - function _endElement($parser, $element) { - $cdata = $this->_cdataStack[$this->_level]; + private function endElement($parser, $element) { + $cdata = $this->cdataStack[$this->level]; $element = $this->canonicalize($element); - $process = $this->_lastProcessed != $element; + $process = $this->lastProcessed != $element; $recursion = false; list($namespacePrefix, $qElement) = - XML_Transformer_Util::qualifiedElement($element); + XML::Transformer::Util::qualifiedElement($element); if ($process && - isset($this->_callbackRegistry->overloadedNamespaces[$namespacePrefix]['active'])) { + isset($this->callbackRegistry->overloadedNamespaces[$namespacePrefix]['active'])) { // The event is handled by a callback // that is registered for this namespace. - $result = $this->_callbackRegistry->overloadedNamespaces[$namespacePrefix]['object']->endElement( + $result = $this->callbackRegistry->overloadedNamespaces[$namespacePrefix]['object']->endElement( $qElement, $cdata ); @@ -553,8 +553,8 @@ } $recursion = $reparse && - isset($this->_elementStack[$this->_level-1]) && - $this->_callbackRegistry->overloadedNamespaces[$namespacePrefix]['recursiveOperation']; + isset($this->elementStack[$this->level-1]) && + $this->callbackRegistry->overloadedNamespaces[$namespacePrefix]['recursiveOperation']; } else { // No callback was registered for this element's // closing tag, copy it. @@ -565,10 +565,10 @@ if ($recursion) { // Recursively process this transformation's result. - $this->_debug( + $this->debug( sprintf( 'start recursion[%d]: %s', - $this->_level, + $this->level, $cdata ), '&RECURSE' @@ -576,30 +576,30 @@ $transformer = new XML_Transformer( array( - 'caseFolding' => $this->_caseFolding, - 'caseFoldingTo' => $this->_caseFoldingTo, + 'caseFolding' => $this->caseFolding, + 'caseFoldingTo' => $this->caseFoldingTo, 'lastProcessed' => $element ) ); $cdata = $transformer->transform($cdata); - $this->_debug( + $this->debug( sprintf( 'end recursion[%d]: %s', - $this->_level, + $this->level, $cdata ), '&RECURSE' ); } - $this->_debug( + $this->debug( sprintf( 'endElement[%d]: %s (with cdata=%s)', - $this->_level, + $this->level, $element, - $this->_cdataStack[$this->_level] + $this->cdataStack[$this->level] ), $element ); @@ -607,11 +607,11 @@ // Move result of this transformation step to // the parent's CDATA section. - $this->_cdataStack[--$this->_level] .= $cdata; + $this->cdataStack[--$this->level] .= $cdata; } // }}} - // {{{ function _characterData($parser, $cdata) + // {{{ private function characterData($parser, $cdata) /** * SAX callback for 'characterData' event. @@ -620,22 +620,22 @@ * @param string * @access private */ - function _characterData($parser, $cdata) { - $this->_debug( + private function characterData($parser, $cdata) { + $this->debug( sprintf( 'cdata [%d]: %s + %s', - $this->_level, - $this->_cdataStack[$this->_level], + $this->level, + $this->cdataStack[$this->level], $cdata ), '&CDATA' ); - $this->_cdataStack[$this->_level] .= $cdata; + $this->cdataStack[$this->level] .= $cdata; } // }}} - // {{{ function _autoload($namespaces) + // {{{ private function autoload($namespaces) /** * Loads either all (true) or a selection of namespace @@ -644,7 +644,7 @@ * @param mixed * @access private */ - function _autoload($namespaces) { + private function autoload($namespaces) { $path = dirname(__FILE__) . '/Transformer/Namespace/'; if ($namespaces === true) { @@ -669,8 +669,7 @@ foreach ($namespaces as $namespace) { if (@include_once($path . $namespace . '.php')) { - $className = 'XML_Transformer_Namespace_' . $namespace; - $object = new $className; + $object = new XML::Transformer::Namespace::$namespace; $this->overloadNamespace( !empty($object->defaultNamespacePrefix) ? $object->defaultNamespacePrefix : $namespace, @@ -681,7 +680,7 @@ } // }}} - // {{{ function _debug($debugMessage, $currentElement = '') + // {{{ protected function debug($debugMessage, $currentElement = '') /** * Sends a debug message to error.log, if debugging is enabled. @@ -689,13 +688,13 @@ * @param string * @access private */ - function _debug($debugMessage, $currentElement = '') { - if ($this->_debug && - (empty($this->_debugFilter) || - isset($this->_debugFilter[$currentElement]))) { - XML_Transformer_Util::logMessage( + protected function debug($debugMessage, $currentElement = '') { + if ($this->debug && + (empty($this->debugFilter) || + isset($this->debugFilter[$currentElement]))) { + XML::Transformer::Util::logMessage( $debugMessage, - $this->_logTarget + $this->logTarget ); } } Index: pear/XML_Transformer/test.php diff -u pear/XML_Transformer/test.php:1.10.2.1 pear/XML_Transformer/test.php:1.10.2.2 --- pear/XML_Transformer/test.php:1.10.2.1 Sat Jan 18 13:16:27 2003 +++ pear/XML_Transformer/test.php Sat Jan 18 13:37:33 2003 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +---------------------------------------------------------------------------+ // -// $Id: test.php,v 1.10.2.1 2003/01/18 18:16:27 sebastian Exp $ +// $Id: test.php,v 1.10.2.2 2003/01/18 18:37:33 sebastian Exp $ // require_once 'PHPUnit.php'; @@ -46,9 +46,9 @@ } } -class XML_Transformer_Test extends PHPUnit_TestCase { - function testNoRecursion() { - $t = new XML_Transformer; +class XML::Transformer::Test extends PHPUnit::TestCase { + public function testNoRecursion() { + $t = new XML::Transformer; $t->overloadNamespace( '&MAIN', @@ -64,8 +64,8 @@ ); } - function testRecursion() { - $t = new XML_Transformer; + public function testRecursion() { + $t = new XML::Transformer; $t->overloadNamespace( '&MAIN', @@ -81,8 +81,8 @@ ); } - function testSelfReplacing() { - $t = new XML_Transformer; + public function testSelfReplacing() { + $t = new XML::Transformer; $t->overloadNamespace( '&MAIN', @@ -99,6 +99,6 @@ } } -$result = PHPUnit::run(new PHPUnit_TestSuite('XML_Transformer_Test')); +$result = PHPUnit::run(new PHPUnit::TestSuite('XML::Transformer::Test')); echo $result->toString(); ?> Index: pear/XML_Transformer/Transformer/CallbackRegistry.php diff -u pear/XML_Transformer/Transformer/CallbackRegistry.php:1.15.2.1 pear/XML_Transformer/Transformer/CallbackRegistry.php:1.15.2.2 --- pear/XML_Transformer/Transformer/CallbackRegistry.php:1.15.2.1 Sat Jan 18 13:16:27 2003 +++ pear/XML_Transformer/Transformer/CallbackRegistry.php Sat Jan 18 13:37:33 2003 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +---------------------------------------------------------------------------+ // -// $Id: CallbackRegistry.php,v 1.15.2.1 2003/01/18 18:16:27 sebastian Exp $ +// $Id: CallbackRegistry.php,v 1.15.2.2 2003/01/18 18:37:33 sebastian Exp $ // /** @@ -21,23 +21,23 @@ * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @author Kristian Köhntopp <kris@koehntopp.de> -* @version $Revision: 1.15.2.1 $ +* @version $Revision: 1.15.2.2 $ * @access public */ -class XML_Transformer_CallbackRegistry { +class XML::Transformer::CallbackRegistry { // {{{ Members /** * @var array * @access public */ - var $overloadedNamespaces = array(); + public $overloadedNamespaces = array(); /** * @var boolean * @access private */ - var $_locked = false; + private $locked = false; /** * If true, the transformation will continue recursively @@ -47,10 +47,17 @@ * @var boolean * @access private */ - var $_recursiveOperation = true; + private $recursiveOperation = true; + + /** + * @var object + * @access private + * @static + */ + private static $instance; // }}} - // {{{ function XML_Transformer_CallbackRegistry($recursiveOperation) + // {{{ public function __construct($recursiveOperation) /** * Constructor. @@ -58,12 +65,12 @@ * @param boolean * @access public */ - function XML_Transformer_CallbackRegistry($recursiveOperation) { - $this->_recursiveOperation = $recursiveOperation; + protected function __construct($recursiveOperation) { + $this->recursiveOperation = $recursiveOperation; } // }}} - // {{{ function &singleton($recursiveOperation) + // {{{ function getInstance($recursiveOperation) /** * Singleton. @@ -71,18 +78,16 @@ * @param boolean * @access public */ - function &singleton($recursiveOperation) { - static $instance; - - if (!isset($instance)) { - $instance = new XML_Transformer_CallbackRegistry($recursiveOperation); + public static function getInstance($recursiveOperation) { + if (!isset(self::$instance)) { + self::$instance = new XML::Transformer::CallbackRegistry($recursiveOperation); } - return $instance; + return self::$instance; } // }}} - // {{{ function overloadNamespace($namespacePrefix, &$object, $recursiveOperation = '') + // {{{ public function overloadNamespace($namespacePrefix, $object, $recursiveOperation = '') /** * Overloads an XML Namespace. @@ -93,7 +98,7 @@ * @return mixed * @access public */ - function overloadNamespace($namespacePrefix, &$object, $recursiveOperation = '') { + public function overloadNamespace($namespacePrefix, $object, $recursiveOperation = '') { if (!is_object($object)) { return sprintf( 'Cannot overload namespace "%s", ' . @@ -125,14 +130,14 @@ } $this->overloadedNamespaces[$namespacePrefix]['active'] = true; - $this->overloadedNamespaces[$namespacePrefix]['object'] = &$object; - $this->overloadedNamespaces[$namespacePrefix]['recursiveOperation'] = is_bool($recursiveOperation) ? $recursiveOperation : $this->_recursiveOperation; + $this->overloadedNamespaces[$namespacePrefix]['object'] = $object; + $this->overloadedNamespaces[$namespacePrefix]['recursiveOperation'] = is_bool($recursiveOperation) ? $recursiveOperation : $this->recursiveOperation; return true; } // }}} - // {{{ function unOverloadNamespace($namespacePrefix) + // {{{ public function unOverloadNamespace($namespacePrefix) /** * Reverts overloading of a given XML Namespace. @@ -140,14 +145,14 @@ * @param string * @access public */ - function unOverloadNamespace($namespacePrefix) { + public function unOverloadNamespace($namespacePrefix) { if (isset($this->overloadedNamespaces[$namespacePrefix])) { unset($this->overloadedNamespaces[$namespacePrefix]); } } // }}} - // {{{ function isOverloadedNamespace($namespacePrefix) + // {{{ public function isOverloadedNamespace($namespacePrefix) /** * Returns true if a given namespace is overloaded, @@ -157,14 +162,14 @@ * @return boolean * @access public */ - function isOverloadedNamespace($namespacePrefix) { + public function isOverloadedNamespace($namespacePrefix) { return isset( $this->overloadedNamespaces[$namespacePrefix] ); } // }}} - // {{{ function setRecursiveOperation($recursiveOperation) + // {{{ public function setRecursiveOperation($recursiveOperation) /** * Enables or disables the recursive operation. @@ -172,14 +177,14 @@ * @param boolean * @access public */ - function setRecursiveOperation($recursiveOperation) { + public function setRecursiveOperation($recursiveOperation) { if (is_bool($recursiveOperation)) { - $this->_recursiveOperation = $recursiveOperation; + $this->recursiveOperation = $recursiveOperation; } } // }}} - // {{{ function function getLock($namespace) + // {{{ public function function getLock($namespace) /** * Lock all namespace handlers except a given one. @@ -189,8 +194,8 @@ * @access public * @see releaseLock() */ - function getLock($namespace) { - if (!$this->_locked) { + public function getLock($namespace) { + if (!$this->locked) { $namespacePrefixes = array_keys($this->overloadedNamespaces); foreach ($namespacePrefixes as $namespacePrefix) { @@ -199,7 +204,7 @@ } } - $this->_locked = true; + $this->locked = true; return true; } @@ -208,7 +213,7 @@ } // }}} - // {{{ function releaseLock() + // {{{ public function releaseLock() /** * Releases a lock. @@ -216,14 +221,14 @@ * @access public * @see getLock() */ - function releaseLock() { + public function releaseLock() { $namespacePrefixes = array_keys($this->overloadedNamespaces); foreach ($namespacePrefixes as $namespacePrefix) { $this->overloadedNamespaces[$namespacePrefix]['active'] = true; } - $this->_locked = false; + $this->locked = false; } // }}} Index: pear/XML_Transformer/Transformer/Namespace.php diff -u pear/XML_Transformer/Transformer/Namespace.php:1.19.2.1 pear/XML_Transformer/Transformer/Namespace.php:1.19.2.2 --- pear/XML_Transformer/Transformer/Namespace.php:1.19.2.1 Sat Jan 18 13:16:27 2003 +++ pear/XML_Transformer/Transformer/Namespace.php Sat Jan 18 13:37:33 2003 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +---------------------------------------------------------------------------+ // -// $Id: Namespace.php,v 1.19.2.1 2003/01/18 18:16:27 sebastian Exp $ +// $Id: Namespace.php,v 1.19.2.2 2003/01/18 18:37:33 sebastian Exp $ // require_once 'XML/Transformer/Util.php'; @@ -63,38 +63,38 @@ * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @author Kristian Köhntopp <kris@koehntopp.de> -* @version $Revision: 1.19.2.1 $ +* @version $Revision: 1.19.2.2 $ * @access public */ -class XML_Transformer_Namespace { +class XML::Transformer::Namespace { // {{{ Members /** * @var string * @access public */ - var $defaultNamespacePrefix = ''; + public $defaultNamespacePrefix = ''; /** * @var boolean * @access public */ - var $secondPassRequired = false; + public $secondPassRequired = false; /** * @var array * @access private */ - var $_prefix = array(); + private $prefix = array(); /** * @var string * @access private */ - var $_transformer = ''; + private $transformer = ''; // }}} - // {{{ function initObserver($prefix, &$object) + // {{{ public function initObserver($prefix, &$object) /** * Called by XML_Transformer at initialization time. @@ -106,13 +106,13 @@ * @param object * @access public */ - function initObserver($prefix, &$object) { - $this->_prefix[] = $prefix; - $this->_transformer = $object; + public function initObserver($prefix, $object) { + $this->prefix[] = $prefix; + $this->transformer = $object; } // }}} - // {{{ function startElement($element, $attributes) + // {{{ public function startElement($element, $attributes) /** * Wrapper for startElement handler. @@ -122,7 +122,7 @@ * @return string * @access public */ - function startElement($element, $attributes) { + public function startElement($element, $attributes) { $do = 'start_' . $element; if (method_exists($this, $do)) { @@ -133,12 +133,12 @@ "<%s%s>", $element, - XML_Transformer_Util::attributesToString($attributes) + XML::Transformer::Util::attributesToString($attributes) ); } // }}} - // {{{ function endElement($element, $cdata) + // {{{ public function endElement($element, $cdata) /** * Wrapper for endElement handler. @@ -148,7 +148,7 @@ * @return array * @access public */ - function endElement($element, $cdata) { + public function endElement($element, $cdata) { $do = 'end_' . $element; if (method_exists($this, $do)) { @@ -167,30 +167,30 @@ } // }}} - // {{{ function function getLock() + // {{{ protected function getLock() /** * Lock all other namespace handlers. * * @return boolean - * @access public + * @access protected * @see releaseLock() */ - function getLock() { - return $this->_transformer->_callbackRegistry->getLock($this->_prefix[0]); + protected function getLock() { + return $this->transformer->_callbackRegistry->getLock($this->prefix[0]); } // }}} - // {{{ function releaseLock() + // {{{ protected function releaseLock() /** * Releases a lock. * - * @access public + * @access protected * @see getLock() */ - function releaseLock() { - $this->_transformer->_callbackRegistry->releaseLock(); + protected function releaseLock() { + $this->transformer->_callbackRegistry->releaseLock(); } // }}} Index: pear/XML_Transformer/Transformer/Util.php diff -u pear/XML_Transformer/Transformer/Util.php:1.7.2.1 pear/XML_Transformer/Transformer/Util.php:1.7.2.2 --- pear/XML_Transformer/Transformer/Util.php:1.7.2.1 Sat Jan 18 13:16:28 2003 +++ pear/XML_Transformer/Transformer/Util.php Sat Jan 18 13:37:33 2003 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +---------------------------------------------------------------------------+ // -// $Id: Util.php,v 1.7.2.1 2003/01/18 18:16:28 sebastian Exp $ +// $Id: Util.php,v 1.7.2.2 2003/01/18 18:37:33 sebastian Exp $ // /** @@ -21,11 +21,11 @@ * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @author Kristian Köhntopp <kris@koehntopp.de> -* @version $Revision: 1.7.2.1 $ +* @version $Revision: 1.7.2.2 $ * @access public */ -class XML_Transformer_Util { - // {{{ function attributesToString($attributes) +class XML::Transformer::Util { + // {{{ public static function attributesToString($attributes) /** * Returns string representation of attributes array. @@ -35,7 +35,7 @@ * @access public * @static */ - function attributesToString($attributes) { + public static function attributesToString($attributes) { $string = ''; if (is_array($attributes)) { @@ -50,7 +50,7 @@ } // }}} - // {{{ function logMessage($logMessage, $target = 'error_log') + // {{{ public static function logMessage($logMessage, $target = 'error_log') /** * Sends an error message to a given target. @@ -60,7 +60,7 @@ * @access public * @static */ - function logMessage($logMessage, $target = 'error_log') { + public static function logMessage($logMessage, $target = 'error_log') { switch ($target) { case 'echo': { echo $logMessage; @@ -74,7 +74,7 @@ } // }}} - // {{{ function qualifiedElement($element) + // {{{ public static function qualifiedElement($element) /** * Returns namespace and qualified element name @@ -85,7 +85,7 @@ * @access public * @static */ - function qualifiedElement($element) { + public static function qualifiedElement($element) { if (strstr($element, ':')) { return explode(':', $element); } else { Index: pear/XML_Transformer/Transformer/Driver/Cache.php diff -u pear/XML_Transformer/Transformer/Driver/Cache.php:1.4.2.1 pear/XML_Transformer/Transformer/Driver/Cache.php:1.4.2.2 --- pear/XML_Transformer/Transformer/Driver/Cache.php:1.4.2.1 Sat Jan 18 13:16:28 2003 +++ pear/XML_Transformer/Transformer/Driver/Cache.php Sat Jan 18 13:37:33 2003 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +---------------------------------------------------------------------------+ // -// $Id: Cache.php,v 1.4.2.1 2003/01/18 18:16:28 sebastian Exp $ +// $Id: Cache.php,v 1.4.2.2 2003/01/18 18:37:33 sebastian Exp $ // require_once 'Cache/Lite.php'; @@ -24,20 +24,20 @@ * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @author Kristian Köhntopp <kris@koehntopp.de> -* @version $Revision: 1.4.2.1 $ +* @version $Revision: 1.4.2.2 $ * @access public */ -class XML_Transformer_Driver_Cache extends XML_Transformer { +class XML::Transformer::Driver::Cache extends XML::Transformer { // {{{ Members /** * @var object * @access private */ - var $_cache = false; + private $cache = false; // }}} - // {{{ function XML_Transformer_Driver_Cache($parameters = array()) + // {{{ public function __construct($parameters = array()) /** * Constructor. @@ -45,13 +45,13 @@ * @param array * @access public */ - function XML_Transformer_Driver_Cache($parameters = array()) { - $this->XML_Transformer($parameters); - $this->_cache = new Cache_Lite($parameters); + public function __construct($parameters = array()) { + parent::__construct($parameters); + $this->cache = new Cache_Lite($parameters); } // }}} - // {{{ function transform($xml, $cacheID = '') + // {{{ public function transform($xml, $cacheID = '') /** * Cached transformation a given XML string using @@ -62,17 +62,17 @@ * @return string * @access public */ - function transform($xml, $cacheID = '') { + public function transform($xml, $cacheID = '') { $cacheID = ($cacheID != '') ? $cacheID : md5($xml); - $cachedResult = $this->_cache->get($cacheID, 'XML_Transformer'); + $cachedResult = $this->cache->get($cacheID, 'XML_Transformer'); if ($cachedResult !== false) { return $cachedResult; } $result = parent::transform($xml); - $this->_cache->save($result, $cacheID, 'XML_Transformer'); + $this->cache->save($result, $cacheID, 'XML_Transformer'); return $result; } Index: pear/XML_Transformer/Transformer/Driver/OutputBuffer.php diff -u pear/XML_Transformer/Transformer/Driver/OutputBuffer.php:1.5.2.1 pear/XML_Transformer/Transformer/Driver/OutputBuffer.php:1.5.2.2 --- pear/XML_Transformer/Transformer/Driver/OutputBuffer.php:1.5.2.1 Sat Jan 18 13:16:28 2003 +++ pear/XML_Transformer/Transformer/Driver/OutputBuffer.php Sat Jan 18 13:37:33 2003 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +---------------------------------------------------------------------------+ // -// $Id: OutputBuffer.php,v 1.5.2.1 2003/01/18 18:16:28 sebastian Exp $ +// $Id: OutputBuffer.php,v 1.5.2.2 2003/01/18 18:37:33 sebastian Exp $ // require_once 'XML/Transformer.php'; @@ -55,20 +55,20 @@ * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @author Kristian Köhntopp <kris@koehntopp.de> -* @version $Revision: 1.5.2.1 $ +* @version $Revision: 1.5.2.2 $ * @access public */ -class XML_Transformer_Driver_OutputBuffer extends XML_Transformer { +class XML::Transformer::Driver::OutputBuffer extends XML::Transformer { // {{{ Members /** * @var boolean * @access private */ - var $_started = false; + private $started = false; // }}} - // {{{ function XML_Transformer_Driver_OutputBuffer($parameters = array()) + // {{{ public function __construct($parameters = array()) /** * Constructor. @@ -76,10 +76,10 @@ * @param array * @access public */ - function XML_Transformer_Driver_OutputBuffer($parameters = array()) { - $this->XML_Transformer($parameters); + public function __construct($parameters = array()) { + parent::__construct($parameters); - if (!empty($this->_callbackRegistry->overloadedNamespaces)) { + if (!empty($this->callbackRegistry->overloadedNamespaces)) { $this->start(); } } @@ -94,16 +94,16 @@ * @access public */ function start() { - if (!$this->_started) { + if (!$this->started) { ob_start( array( $this, 'transform' ) ); - $this->_started = true; + $this->started = true; - $this->_debug( + $this->debug( 'start: ' . serialize($this) ); }
« previous php.pear.cvs (#8387) next »