cvs: pear /XML_Query2XML/XML/Query2XML/Command Base64.php CDATA.php Chain.php ColumnValue.php NonEmpty.php PHPCallback.php Static.php Unserialize.php
| From: | Lukas Feiler | Date: | Sat, 29 Sep 2007 23:14:24 +0000 |
| Subject: | cvs: pear /XML_Query2XML/XML/Query2XML/Command Base64.php CDATA.php Chain.php ColumnValue.php NonEmpty.php PHPCallback.php Static.php Unserialize.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-48711@lists.php.net to get a copy of this message | ||
lukasfeiler Sat Sep 29 23:14:24 2007 UTC
Modified files:
/pear/XML_Query2XML/XML/Query2XML/Command Base64.php CDATA.php
Chain.php ColumnValue.php
NonEmpty.php
PHPCallback.php
Static.php
Unserialize.php
Log:
@access private; PEAR CS: protected methods and properties without leading underscore
http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Base64.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Base64.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Base64.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Base64.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Base64.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Base64.php Sat Sep 29 23:14:23 2007 @@ -1,66 +1,68 @@ -<?php -/**This file contains the class XML_Query2XML_Command_Base64. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: Base64.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_Base64 extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that base64-encodes the string returned by a pre-processor. -* -* XML_Query2XML_Command_Base64 only works with a pre-processor -* that returns a string. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_Base64( -* new XML_Query2XML_Command_ColumnValue('name') //pre-processor -* ); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_Base64 extends XML_Query2XML_Command_Chain -{ - /**Called by XML_Query2XML for every record in the result set. - * - * @throws XML_Query2XML_ConfigException If the pre-processor returns - * something that cannot be converted to a string - * (i.e. an object or an array). - * @param array $record An associative array. - * @return string The base64-encoded version the string returned - * by the pre-processor. - */ - public function execute(array $record) - { - $data = $this->_runPreProcessor($record); - if (is_array($data) || is_object($data)) { - throw new XML_Query2XML_ConfigException( - $this->_configPath . ': XML_Query2XML_Command_Base64: string ' - . 'expected from pre-processor, but ' . gettype($data) . ' returned.' - ); - } - return base64_encode($data); - } -} +<?php +/**This file contains the class XML_Query2XML_Command_Base64. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: Base64.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_Base64 extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that base64-encodes the string returned by a pre-processor. +* +* XML_Query2XML_Command_Base64 only works with a pre-processor +* that returns a string. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_Base64( +* new XML_Query2XML_Command_ColumnValue('name') //pre-processor +* ); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_Base64 extends XML_Query2XML_Command_Chain +{ + /**Called by XML_Query2XML for every record in the result set. + * + * @throws XML_Query2XML_ConfigException If the pre-processor returns + * something that cannot be converted to a string + * (i.e. an object or an array). + * @param array $record An associative array. + * @return string The base64-encoded version the string returned + * by the pre-processor. + */ + public function execute(array $record) + { + $data = $this->runPreProcessor($record); + if (is_array($data) || is_object($data)) { + throw new XML_Query2XML_ConfigException( + $this->configPath . ': XML_Query2XML_Command_Base64: string ' + . 'expected from pre-processor, but ' . gettype($data) . ' returned.' + ); + } + return base64_encode($data); + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php Sat Sep 29 23:14:23 2007 @@ -15,7 +15,8 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @package XML_Query2XML -* @version $Id: CDATA.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ +* @version $Id: CDATA.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private */ /**XML_Query2XML_Command_CDATA extends the class XML_Query2XML_Command_Chain. @@ -34,6 +35,7 @@ * new XML_Query2XML_Command_ColumnValue('name') //pre-processor * ); * +* @access private * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @version Release: @package_version@ * @copyright Empowered Media 2006 @@ -56,10 +58,10 @@ public function execute(array $record) { $doc = new DOMDocument(); - $data = $this->_runPreProcessor($record); + $data = $this->runPreProcessor($record); if (is_array($data) || is_object($data)) { throw new XML_Query2XML_ConfigException( - $this->_configPath . 'XML_Query2XML_Command_CDATA: string expected ' + $this->configPath . 'XML_Query2XML_Command_CDATA: string expected ' . 'from pre-processor, but ' . gettype($data) . ' returned.' ); } http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Chain.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Chain.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Chain.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Chain.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Chain.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Chain.php Sat Sep 29 23:14:23 2007 @@ -15,7 +15,8 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @package XML_Query2XML -* @version $Id: Chain.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ +* @version $Id: Chain.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private */ /**XML_Query2XML_Command_Chain implements the interface XML_Query2XML_Callback. @@ -25,6 +26,7 @@ /**Abstract class extended by all command classes that are part of the * XML_Query2XML package. * +* @access private * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @version Release: @package_version@ * @copyright Empowered Media 2006 @@ -36,12 +38,12 @@ /**Another instance of XML_Query2XML_Command_Chain to process before this one. * @var XML_Query2XML_Command_Chain */ - protected $_preProcessor = null; + protected $preProcessor = null; /**The configuration path; it is used for exception messages * @var string */ - protected $_configPath = ''; + protected $configPath = ''; /**Constructor * @param XML_Query2XML_Command_Chain $preProcessor The pre-processor to be used. @@ -51,10 +53,10 @@ */ public function __construct(XML_Query2XML_Command_Chain $preProcessor = null, $configPath = '') { - $this->_preProcessor = $preProcessor; - $this->_configPath = $configPath; - if ($this->_configPath) { - $this->_configPath .= ': '; + $this->preProcessor = $preProcessor; + $this->configPath = $configPath; + if ($this->configPath) { + $this->configPath .= ': '; } } @@ -63,7 +65,7 @@ */ public function setPreProcessor(XML_Query2XML_Command_Chain $preProcessor) { - $this->_preProcessor = $preProcessor; + $this->preProcessor = $preProcessor; } /**Runs the pre-processor if one was defined and returns it's return value. @@ -72,14 +74,14 @@ * @param array $record The record to process - this is an associative array. * @return mixed Whatever was returned by the pre-processor */ - protected function _runPreProcessor(array $record) + protected function runPreProcessor(array $record) { - if (!is_null($this->_preProcessor)) { - return $this->_preProcessor->execute($record); + if (!is_null($this->preProcessor)) { + return $this->preProcessor->execute($record); } else { require_once 'XML/Query2XML.php'; throw new XML_Query2XML_ConfigException( - $this->_configPath . get_class($this) . ' requires a pre-processor.' + $this->configPath . get_class($this) . ' requires a pre-processor.' ); } } @@ -96,8 +98,8 @@ */ public function getFirstPreProcessor() { - if (!is_null($this->_preProcessor)) { - return $this->_preProcessor->getFirstPreProcessor(); + if (!is_null($this->preProcessor)) { + return $this->preProcessor->getFirstPreProcessor(); } return $this; } @@ -109,8 +111,8 @@ public function toString() { $str = get_class($this) . '('; - if (!is_null($this->_preProcessor)) { - $str .= $this->_preProcessor->toString(); + if (!is_null($this->preProcessor)) { + $str .= $this->preProcessor->toString(); } return $str . ')'; } http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php Sat Sep 29 23:14:23 2007 @@ -1,93 +1,95 @@ -<?php -/**This file contains the class XML_Query2XML_Command_ColumnValue. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: ColumnValue.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_ColumnValue extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that allows the column value to be used as the data source. -* -* This command class does not accept a pre-processor. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_ColumnValue('name'); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_ColumnValue extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource -{ - /**The column name. - * @var string - */ - private $_column = ''; - - /**Constructor - * @param string $column The name of the column. - * @param string $configPath The configuration path within the $options array. - */ - public function __construct($column, $configPath) - { - $this->_column = $column; - $this->_configPath = $configPath; - if ($this->_configPath) { - $this->_configPath .= ': '; - } - } - - /**Called by XML_Query2XML for every record in the result set. - * - * @throws XML_Query2XML_ConfigException If $column does not exist in the - * result set, i.e. $record[$column] does not exist. - * @param array $record An associative array. - * @return mixed The contents of $record[$column] where $column is the first - * argument passed to the constructor. - */ - public function execute(array $record) - { - if (array_key_exists($this->_column, $record)) { - return $record[$this->_column]; - } - throw new XML_Query2XML_ConfigException( - $this->_configPath . 'The column "' . $this->_column - . '" was not found in the result set' - ); - } - - /**This method is called by XML_Query2XML in case the asterisk shortcut was used. - * - * The interface XML_Query2XML_Command_DataSource requires an implementation of - * this method. - * - * @param string $columnName The column name that is to replace every occurance - * of the asterisk character '*' in $column (the first - * argument passed to the constructor). - */ - public function replaceAsterisks($columnName) - { - $this->_column = str_replace('*', $columnName, $this->_column); - } -} +<?php +/**This file contains the class XML_Query2XML_Command_ColumnValue. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: ColumnValue.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_ColumnValue extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that allows the column value to be used as the data source. +* +* This command class does not accept a pre-processor. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_ColumnValue('name'); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_ColumnValue extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource +{ + /**The column name. + * @var string + */ + private $_column = ''; + + /**Constructor + * @param string $column The name of the column. + * @param string $configPath The configuration path within the $options array. + */ + public function __construct($column, $configPath) + { + $this->_column = $column; + $this->configPath = $configPath; + if ($this->configPath) { + $this->configPath .= ': '; + } + } + + /**Called by XML_Query2XML for every record in the result set. + * + * @throws XML_Query2XML_ConfigException If $column does not exist in the + * result set, i.e. $record[$column] does not exist. + * @param array $record An associative array. + * @return mixed The contents of $record[$column] where $column is the first + * argument passed to the constructor. + */ + public function execute(array $record) + { + if (array_key_exists($this->_column, $record)) { + return $record[$this->_column]; + } + throw new XML_Query2XML_ConfigException( + $this->configPath . 'The column "' . $this->_column + . '" was not found in the result set' + ); + } + + /**This method is called by XML_Query2XML in case the asterisk shortcut was used. + * + * The interface XML_Query2XML_Command_DataSource requires an implementation of + * this method. + * + * @param string $columnName The column name that is to replace every occurance + * of the asterisk character '*' in $column (the first + * argument passed to the constructor). + */ + public function replaceAsterisks($columnName) + { + $this->_column = str_replace('*', $columnName, $this->_column); + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php Sat Sep 29 23:14:23 2007 @@ -1,67 +1,69 @@ -<?php -/**This file contains the class XML_Query2XML_Command_NonEmpty. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: NonEmpty.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_NonEmpty extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class implementing a condition based on whether the value -* returned by a pre-processor is an object or a non-empty string. -* -* XML_Query2XML_Command_NonEmpty requires a pre-processor to be used. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_NonEmpty( -* new XML_Query2XML_Command_ColumnValue('name') //pre-processor -* ); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_NonEmpty extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_Conditional -{ - /**Called by XML_Query2XML for every record in the result set. - * - * @throws XML_Query2XML_ConfigException If no pre-processor was set. - * @param array $record An associative array. - * @return mixed whatever is returned by the pre-processor - */ - public function execute(array $record) - { - return $this->_runPreProcessor($record); - } - - /**As this class implements XML_Query2XML_Command_Conditional, XML_Query2XML - * will call this method to determin whether the condition is fulfilled. - * @param mixed $value The value previously returned by $this->execute(). - * @return boolean Whether the condition is fulfilled. - */ - public function evaluateCondition($value) - { - return is_object($value) || - !(is_null($value) || (is_string($value) && strlen($value) == 0)); - } -} +<?php +/**This file contains the class XML_Query2XML_Command_NonEmpty. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: NonEmpty.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_NonEmpty extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class implementing a condition based on whether the value +* returned by a pre-processor is an object or a non-empty string. +* +* XML_Query2XML_Command_NonEmpty requires a pre-processor to be used. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_NonEmpty( +* new XML_Query2XML_Command_ColumnValue('name') //pre-processor +* ); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_NonEmpty extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_Conditional +{ + /**Called by XML_Query2XML for every record in the result set. + * + * @throws XML_Query2XML_ConfigException If no pre-processor was set. + * @param array $record An associative array. + * @return mixed whatever is returned by the pre-processor + */ + public function execute(array $record) + { + return $this->runPreProcessor($record); + } + + /**As this class implements XML_Query2XML_Command_Conditional, XML_Query2XML + * will call this method to determin whether the condition is fulfilled. + * @param mixed $value The value previously returned by $this->execute(). + * @return boolean Whether the condition is fulfilled. + */ + public function evaluateCondition($value) + { + return is_object($value) || + !(is_null($value) || (is_string($value) && strlen($value) == 0)); + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php Sat Sep 29 23:14:23 2007 @@ -1,135 +1,137 @@ -<?php -/**This file contains the class XML_Query2XML_Command_PHPCallback. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: PHPCallback.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_PHPCallback extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that invokes a callback function, using the return value as the -* data source. -* -* This command class does not accept a pre-processor. -* -* usage: -* <code> -* function myFunction($record) { ... } -* $commandObject = new XML_Query2XML_Command_PHPCallback('myFunction'); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_PHPCallback extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource -{ - private $_callback = null; - private $_args = array(); - - /**Constructor - * - * The following formats are supported for $callback: - * - 'myFunction' - * - 'myFunction(arg1, arg2, ...)' - * - 'MyClass::myStaticMethod' - * - 'MyClass::myStaticMethod(arg1, arg2, ...)' - * You can also pass additional string arguments to the callback function by - * specifing them within the opening and closing brace; e.g. 'Utils::limit(12)' - * will result in Util::limit() being called by execute() with the $record as - * the first and '12' as the second argument. - * If you do not want to pass additional arguments to the callback function, - * the opening and closing brace are optional. - * - * @throws XML_Query2XML_ConfigException If $callback is not callable. - * @param mixed $callback - * @param string $configPath The configuration path within the $options array. - * This argument is optional. - */ - public function __construct($callback, $configPath) - { - $this->_configPath = $configPath; - if ($this->_configPath) { - $this->_configPath .= ': '; - } - - $braceOpen = strpos($callback, '('); - if ($braceOpen !== false) { - $braceClose = strpos($callback, ')'); - if ($braceOpen + 1 < $braceClose) { - $argsString = substr( - $callback, $braceOpen + 1, $braceClose - $braceOpen - 1 - ); - $this->_args = explode(',', str_replace(', ', ',', $argsString)); - } - if ($braceOpen < $braceClose) { - $callback = substr($callback, 0, $braceOpen); - } - } - if (strpos($callback, '::') !== false) { - $callback = split('::', $callback); - } - if (!is_callable($callback, false, $callableName)) { - /* - * unit tests: _applyColumnStringToRecord/ - * throwConfigException_callback_function1.phpt - * throwConfigException_callback_function2.phpt - * throwConfigException_callback_method1.phpt - * throwConfigException_callback_method2.phpt - */ - throw new XML_Query2XML_ConfigException( - $this->_configPath . 'The method/function "' . $callableName - . '" is not callable.' - ); - } - $this->_callback = $callback; - } - - /**Called by XML_Query2XML for every record in the result set. - * - * @param array $record An associative array. - * @return mixed Whatever the callback function returned. - */ - public function execute(array $record) - { - return call_user_func_array( - $this->_callback, - array_merge(array($record), $this->_args) - ); - } - - /**This method is called by XML_Query2XML in case the asterisk shortcut was used. - * - * The interface XML_Query2XML_Command_DataSource requires an implementation of - * this method. - * - * @param string $columnName The column name that is to replace every occurance - * of the asterisk character '*' in any of the arguments - * specified in the 'myFunction(arg1, arg2, ...)' or - * 'MyClass::myStaticMethod(arg1, arg2, ...)' notation. - */ - public function replaceAsterisks($columnName) - { - foreach ($this->_args as $key => $arg) { - $this->_args[$key] = str_replace('*', $columnName, $this->_args[$key]); - } - } -} +<?php +/**This file contains the class XML_Query2XML_Command_PHPCallback. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: PHPCallback.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_PHPCallback extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that invokes a callback function, using the return value as the +* data source. +* +* This command class does not accept a pre-processor. +* +* usage: +* <code> +* function myFunction($record) { ... } +* $commandObject = new XML_Query2XML_Command_PHPCallback('myFunction'); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_PHPCallback extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource +{ + private $_callback = null; + private $_args = array(); + + /**Constructor + * + * The following formats are supported for $callback: + * - 'myFunction' + * - 'myFunction(arg1, arg2, ...)' + * - 'MyClass::myStaticMethod' + * - 'MyClass::myStaticMethod(arg1, arg2, ...)' + * You can also pass additional string arguments to the callback function by + * specifing them within the opening and closing brace; e.g. 'Utils::limit(12)' + * will result in Util::limit() being called by execute() with the $record as + * the first and '12' as the second argument. + * If you do not want to pass additional arguments to the callback function, + * the opening and closing brace are optional. + * + * @throws XML_Query2XML_ConfigException If $callback is not callable. + * @param mixed $callback + * @param string $configPath The configuration path within the $options array. + * This argument is optional. + */ + public function __construct($callback, $configPath) + { + $this->configPath = $configPath; + if ($this->configPath) { + $this->configPath .= ': '; + } + + $braceOpen = strpos($callback, '('); + if ($braceOpen !== false) { + $braceClose = strpos($callback, ')'); + if ($braceOpen + 1 < $braceClose) { + $argsString = substr( + $callback, $braceOpen + 1, $braceClose - $braceOpen - 1 + ); + $this->_args = explode(',', str_replace(', ', ',', $argsString)); + } + if ($braceOpen < $braceClose) { + $callback = substr($callback, 0, $braceOpen); + } + } + if (strpos($callback, '::') !== false) { + $callback = split('::', $callback); + } + if (!is_callable($callback, false, $callableName)) { + /* + * unit tests: _applyColumnStringToRecord/ + * throwConfigException_callback_function1.phpt + * throwConfigException_callback_function2.phpt + * throwConfigException_callback_method1.phpt + * throwConfigException_callback_method2.phpt + */ + throw new XML_Query2XML_ConfigException( + $this->configPath . 'The method/function "' . $callableName + . '" is not callable.' + ); + } + $this->_callback = $callback; + } + + /**Called by XML_Query2XML for every record in the result set. + * + * @param array $record An associative array. + * @return mixed Whatever the callback function returned. + */ + public function execute(array $record) + { + return call_user_func_array( + $this->_callback, + array_merge(array($record), $this->_args) + ); + } + + /**This method is called by XML_Query2XML in case the asterisk shortcut was used. + * + * The interface XML_Query2XML_Command_DataSource requires an implementation of + * this method. + * + * @param string $columnName The column name that is to replace every occurance + * of the asterisk character '*' in any of the arguments + * specified in the 'myFunction(arg1, arg2, ...)' or + * 'MyClass::myStaticMethod(arg1, arg2, ...)' notation. + */ + public function replaceAsterisks($columnName) + { + foreach ($this->_args as $key => $arg) { + $this->_args[$key] = str_replace('*', $columnName, $this->_args[$key]); + } + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Static.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Static.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Static.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Static.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Static.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Static.php Sat Sep 29 23:14:23 2007 @@ -1,90 +1,92 @@ -<?php -/**This file contains the class XML_Query2XML_Command_Static. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: Static.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_Static extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that allows a static value to be used as the data source. -* -* This command class does not accept a pre-processor. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_Static('my static value'); -* </code> -* -* The static value can also be an instance of DOMNode or an array of DOMNode -* instances: -* <code> -* $commandObject = new XML_Query2XML_Command_Static(new DOMElement('test')); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_Static extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource -{ - /**The static data. - * @var mixed - */ - private $_data = null; - - /**Constructor - * @param mixed $data The static data. - */ - public function __construct($data) - { - if ($data === false) { - $data = ''; - } - $this->_data = $data; - } - - /**Called by XML_Query2XML for every record in the result set. - * - * @param array $record An associative array. - * @return mixed Whatever was passed as $data to the constructor. - */ - public function execute(array $record) - { - return $this->_data; - } - - /**This method is called by XML_Query2XML in case the asterisk shortcut was used. - * - * The interface XML_Query2XML_Command_DataSource requires an implementation of - * this method. - * - * @param string $columnName The column name that is to replace every occurance - * of the asterisk character '*' in the static value, - * in case it is a string. - */ - public function replaceAsterisks($columnName) - { - if (is_string($this->_data)) { - $this->_data = str_replace('*', $columnName, $this->_data); - } - } -} +<?php +/**This file contains the class XML_Query2XML_Command_Static. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: Static.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_Static extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that allows a static value to be used as the data source. +* +* This command class does not accept a pre-processor. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_Static('my static value'); +* </code> +* +* The static value can also be an instance of DOMNode or an array of DOMNode +* instances: +* <code> +* $commandObject = new XML_Query2XML_Command_Static(new DOMElement('test')); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_Static extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource +{ + /**The static data. + * @var mixed + */ + private $_data = null; + + /**Constructor + * @param mixed $data The static data. + */ + public function __construct($data) + { + if ($data === false) { + $data = ''; + } + $this->_data = $data; + } + + /**Called by XML_Query2XML for every record in the result set. + * + * @param array $record An associative array. + * @return mixed Whatever was passed as $data to the constructor. + */ + public function execute(array $record) + { + return $this->_data; + } + + /**This method is called by XML_Query2XML in case the asterisk shortcut was used. + * + * The interface XML_Query2XML_Command_DataSource requires an implementation of + * this method. + * + * @param string $columnName The column name that is to replace every occurance + * of the asterisk character '*' in the static value, + * in case it is a string. + */ + public function replaceAsterisks($columnName) + { + if (is_string($this->_data)) { + $this->_data = str_replace('*', $columnName, $this->_data); + } + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php Sat Sep 29 23:14:23 2007 @@ -1,82 +1,84 @@ -<?php -/**This file contains the class XML_Query2XML_Command_Unserialize. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: Unserialize.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_Unserialize extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command object that allows unserialization of XML data returned by a pre-processor -* as a string. -* -* XML_Query2XML_Command_Unserialize only works with a pre-processor -* that returns a string. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_Unserialize( -* new XML_Query2XML_Command_ColumnValue('xml_data') //pre-processor -* ); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_Unserialize extends XML_Query2XML_Command_Chain -{ - /**Called by XML_Query2XML for every record in the result set. - * This method will return an instance of DOMElement or null - * if an empty string was returned by the pre-processor. - * - * @throws XML_Query2XML_ConfigException If the pre-processor returned - * something that cannot be converted to a string (i.e. an - * array or an object) or if that string could not be - * unserialized, i.e. was not corretly formatted XML. - * @param array $record An associative array. - * @return DOMElement - */ - public function execute(array $record) - { - $doc = new DOMDocument(); - $xml = $this->_runPreProcessor($record); - if (is_array($xml) || is_object($xml)) { - throw new XML_Query2XML_XMLException( - $this->_configPath . 'XML_Query2XML_Command_Unserialize: string ' - . 'expected from pre-processor, but ' . gettype($xml) . ' returned.' - ); - } else { - if (strlen($xml)) { - if (!@$doc->loadXML($xml)) { - throw new XML_Query2XML_XMLException( - $this->_configPath . 'XML_Query2XML_Command_Unserialize: ' - . 'Could not unserialize the following XML data: "' - . $xml . '"' - ); - } - return $doc->documentElement; - } else { - return null; - } - } - } -} +<?php +/**This file contains the class XML_Query2XML_Command_Unserialize. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: Unserialize.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_Unserialize extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command object that allows unserialization of XML data returned by a pre-processor +* as a string. +* +* XML_Query2XML_Command_Unserialize only works with a pre-processor +* that returns a string. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_Unserialize( +* new XML_Query2XML_Command_ColumnValue('xml_data') //pre-processor +* ); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_Unserialize extends XML_Query2XML_Command_Chain +{ + /**Called by XML_Query2XML for every record in the result set. + * This method will return an instance of DOMElement or null + * if an empty string was returned by the pre-processor. + * + * @throws XML_Query2XML_ConfigException If the pre-processor returned + * something that cannot be converted to a string (i.e. an + * array or an object) or if that string could not be + * unserialized, i.e. was not corretly formatted XML. + * @param array $record An associative array. + * @return DOMElement + */ + public function execute(array $record) + { + $doc = new DOMDocument(); + $xml = $this->runPreProcessor($record); + if (is_array($xml) || is_object($xml)) { + throw new XML_Query2XML_XMLException( + $this->configPath . 'XML_Query2XML_Command_Unserialize: string ' + . 'expected from pre-processor, but ' . gettype($xml) . ' returned.' + ); + } else { + if (strlen($xml)) { + if (!@$doc->loadXML($xml)) { + throw new XML_Query2XML_XMLException( + $this->configPath . 'XML_Query2XML_Command_Unserialize: ' + . 'Could not unserialize the following XML data: "' + . $xml . '"' + ); + } + return $doc->documentElement; + } else { + return null; + } + } + } +} ?> \ No newline at end of file
http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Base64.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Base64.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Base64.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Base64.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Base64.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Base64.php Sat Sep 29 23:14:23 2007 @@ -1,66 +1,68 @@ -<?php -/**This file contains the class XML_Query2XML_Command_Base64. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: Base64.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_Base64 extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that base64-encodes the string returned by a pre-processor. -* -* XML_Query2XML_Command_Base64 only works with a pre-processor -* that returns a string. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_Base64( -* new XML_Query2XML_Command_ColumnValue('name') //pre-processor -* ); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_Base64 extends XML_Query2XML_Command_Chain -{ - /**Called by XML_Query2XML for every record in the result set. - * - * @throws XML_Query2XML_ConfigException If the pre-processor returns - * something that cannot be converted to a string - * (i.e. an object or an array). - * @param array $record An associative array. - * @return string The base64-encoded version the string returned - * by the pre-processor. - */ - public function execute(array $record) - { - $data = $this->_runPreProcessor($record); - if (is_array($data) || is_object($data)) { - throw new XML_Query2XML_ConfigException( - $this->_configPath . ': XML_Query2XML_Command_Base64: string ' - . 'expected from pre-processor, but ' . gettype($data) . ' returned.' - ); - } - return base64_encode($data); - } -} +<?php +/**This file contains the class XML_Query2XML_Command_Base64. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: Base64.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_Base64 extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that base64-encodes the string returned by a pre-processor. +* +* XML_Query2XML_Command_Base64 only works with a pre-processor +* that returns a string. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_Base64( +* new XML_Query2XML_Command_ColumnValue('name') //pre-processor +* ); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_Base64 extends XML_Query2XML_Command_Chain +{ + /**Called by XML_Query2XML for every record in the result set. + * + * @throws XML_Query2XML_ConfigException If the pre-processor returns + * something that cannot be converted to a string + * (i.e. an object or an array). + * @param array $record An associative array. + * @return string The base64-encoded version the string returned + * by the pre-processor. + */ + public function execute(array $record) + { + $data = $this->runPreProcessor($record); + if (is_array($data) || is_object($data)) { + throw new XML_Query2XML_ConfigException( + $this->configPath . ': XML_Query2XML_Command_Base64: string ' + . 'expected from pre-processor, but ' . gettype($data) . ' returned.' + ); + } + return base64_encode($data); + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/CDATA.php Sat Sep 29 23:14:23 2007 @@ -15,7 +15,8 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @package XML_Query2XML -* @version $Id: CDATA.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ +* @version $Id: CDATA.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private */ /**XML_Query2XML_Command_CDATA extends the class XML_Query2XML_Command_Chain. @@ -34,6 +35,7 @@ * new XML_Query2XML_Command_ColumnValue('name') //pre-processor * ); * +* @access private * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @version Release: @package_version@ * @copyright Empowered Media 2006 @@ -56,10 +58,10 @@ public function execute(array $record) { $doc = new DOMDocument(); - $data = $this->_runPreProcessor($record); + $data = $this->runPreProcessor($record); if (is_array($data) || is_object($data)) { throw new XML_Query2XML_ConfigException( - $this->_configPath . 'XML_Query2XML_Command_CDATA: string expected ' + $this->configPath . 'XML_Query2XML_Command_CDATA: string expected ' . 'from pre-processor, but ' . gettype($data) . ' returned.' ); } http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Chain.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Chain.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Chain.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Chain.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Chain.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Chain.php Sat Sep 29 23:14:23 2007 @@ -15,7 +15,8 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @package XML_Query2XML -* @version $Id: Chain.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ +* @version $Id: Chain.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private */ /**XML_Query2XML_Command_Chain implements the interface XML_Query2XML_Callback. @@ -25,6 +26,7 @@ /**Abstract class extended by all command classes that are part of the * XML_Query2XML package. * +* @access private * @author Lukas Feiler <lukas.feiler@lukasfeiler.com> * @version Release: @package_version@ * @copyright Empowered Media 2006 @@ -36,12 +38,12 @@ /**Another instance of XML_Query2XML_Command_Chain to process before this one. * @var XML_Query2XML_Command_Chain */ - protected $_preProcessor = null; + protected $preProcessor = null; /**The configuration path; it is used for exception messages * @var string */ - protected $_configPath = ''; + protected $configPath = ''; /**Constructor * @param XML_Query2XML_Command_Chain $preProcessor The pre-processor to be used. @@ -51,10 +53,10 @@ */ public function __construct(XML_Query2XML_Command_Chain $preProcessor = null, $configPath = '') { - $this->_preProcessor = $preProcessor; - $this->_configPath = $configPath; - if ($this->_configPath) { - $this->_configPath .= ': '; + $this->preProcessor = $preProcessor; + $this->configPath = $configPath; + if ($this->configPath) { + $this->configPath .= ': '; } } @@ -63,7 +65,7 @@ */ public function setPreProcessor(XML_Query2XML_Command_Chain $preProcessor) { - $this->_preProcessor = $preProcessor; + $this->preProcessor = $preProcessor; } /**Runs the pre-processor if one was defined and returns it's return value. @@ -72,14 +74,14 @@ * @param array $record The record to process - this is an associative array. * @return mixed Whatever was returned by the pre-processor */ - protected function _runPreProcessor(array $record) + protected function runPreProcessor(array $record) { - if (!is_null($this->_preProcessor)) { - return $this->_preProcessor->execute($record); + if (!is_null($this->preProcessor)) { + return $this->preProcessor->execute($record); } else { require_once 'XML/Query2XML.php'; throw new XML_Query2XML_ConfigException( - $this->_configPath . get_class($this) . ' requires a pre-processor.' + $this->configPath . get_class($this) . ' requires a pre-processor.' ); } } @@ -96,8 +98,8 @@ */ public function getFirstPreProcessor() { - if (!is_null($this->_preProcessor)) { - return $this->_preProcessor->getFirstPreProcessor(); + if (!is_null($this->preProcessor)) { + return $this->preProcessor->getFirstPreProcessor(); } return $this; } @@ -109,8 +111,8 @@ public function toString() { $str = get_class($this) . '('; - if (!is_null($this->_preProcessor)) { - $str .= $this->_preProcessor->toString(); + if (!is_null($this->preProcessor)) { + $str .= $this->preProcessor->toString(); } return $str . ')'; } http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/ColumnValue.php Sat Sep 29 23:14:23 2007 @@ -1,93 +1,95 @@ -<?php -/**This file contains the class XML_Query2XML_Command_ColumnValue. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: ColumnValue.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_ColumnValue extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that allows the column value to be used as the data source. -* -* This command class does not accept a pre-processor. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_ColumnValue('name'); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_ColumnValue extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource -{ - /**The column name. - * @var string - */ - private $_column = ''; - - /**Constructor - * @param string $column The name of the column. - * @param string $configPath The configuration path within the $options array. - */ - public function __construct($column, $configPath) - { - $this->_column = $column; - $this->_configPath = $configPath; - if ($this->_configPath) { - $this->_configPath .= ': '; - } - } - - /**Called by XML_Query2XML for every record in the result set. - * - * @throws XML_Query2XML_ConfigException If $column does not exist in the - * result set, i.e. $record[$column] does not exist. - * @param array $record An associative array. - * @return mixed The contents of $record[$column] where $column is the first - * argument passed to the constructor. - */ - public function execute(array $record) - { - if (array_key_exists($this->_column, $record)) { - return $record[$this->_column]; - } - throw new XML_Query2XML_ConfigException( - $this->_configPath . 'The column "' . $this->_column - . '" was not found in the result set' - ); - } - - /**This method is called by XML_Query2XML in case the asterisk shortcut was used. - * - * The interface XML_Query2XML_Command_DataSource requires an implementation of - * this method. - * - * @param string $columnName The column name that is to replace every occurance - * of the asterisk character '*' in $column (the first - * argument passed to the constructor). - */ - public function replaceAsterisks($columnName) - { - $this->_column = str_replace('*', $columnName, $this->_column); - } -} +<?php +/**This file contains the class XML_Query2XML_Command_ColumnValue. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: ColumnValue.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_ColumnValue extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that allows the column value to be used as the data source. +* +* This command class does not accept a pre-processor. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_ColumnValue('name'); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_ColumnValue extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource +{ + /**The column name. + * @var string + */ + private $_column = ''; + + /**Constructor + * @param string $column The name of the column. + * @param string $configPath The configuration path within the $options array. + */ + public function __construct($column, $configPath) + { + $this->_column = $column; + $this->configPath = $configPath; + if ($this->configPath) { + $this->configPath .= ': '; + } + } + + /**Called by XML_Query2XML for every record in the result set. + * + * @throws XML_Query2XML_ConfigException If $column does not exist in the + * result set, i.e. $record[$column] does not exist. + * @param array $record An associative array. + * @return mixed The contents of $record[$column] where $column is the first + * argument passed to the constructor. + */ + public function execute(array $record) + { + if (array_key_exists($this->_column, $record)) { + return $record[$this->_column]; + } + throw new XML_Query2XML_ConfigException( + $this->configPath . 'The column "' . $this->_column + . '" was not found in the result set' + ); + } + + /**This method is called by XML_Query2XML in case the asterisk shortcut was used. + * + * The interface XML_Query2XML_Command_DataSource requires an implementation of + * this method. + * + * @param string $columnName The column name that is to replace every occurance + * of the asterisk character '*' in $column (the first + * argument passed to the constructor). + */ + public function replaceAsterisks($columnName) + { + $this->_column = str_replace('*', $columnName, $this->_column); + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/NonEmpty.php Sat Sep 29 23:14:23 2007 @@ -1,67 +1,69 @@ -<?php -/**This file contains the class XML_Query2XML_Command_NonEmpty. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: NonEmpty.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_NonEmpty extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class implementing a condition based on whether the value -* returned by a pre-processor is an object or a non-empty string. -* -* XML_Query2XML_Command_NonEmpty requires a pre-processor to be used. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_NonEmpty( -* new XML_Query2XML_Command_ColumnValue('name') //pre-processor -* ); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_NonEmpty extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_Conditional -{ - /**Called by XML_Query2XML for every record in the result set. - * - * @throws XML_Query2XML_ConfigException If no pre-processor was set. - * @param array $record An associative array. - * @return mixed whatever is returned by the pre-processor - */ - public function execute(array $record) - { - return $this->_runPreProcessor($record); - } - - /**As this class implements XML_Query2XML_Command_Conditional, XML_Query2XML - * will call this method to determin whether the condition is fulfilled. - * @param mixed $value The value previously returned by $this->execute(). - * @return boolean Whether the condition is fulfilled. - */ - public function evaluateCondition($value) - { - return is_object($value) || - !(is_null($value) || (is_string($value) && strlen($value) == 0)); - } -} +<?php +/**This file contains the class XML_Query2XML_Command_NonEmpty. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: NonEmpty.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_NonEmpty extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class implementing a condition based on whether the value +* returned by a pre-processor is an object or a non-empty string. +* +* XML_Query2XML_Command_NonEmpty requires a pre-processor to be used. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_NonEmpty( +* new XML_Query2XML_Command_ColumnValue('name') //pre-processor +* ); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_NonEmpty extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_Conditional +{ + /**Called by XML_Query2XML for every record in the result set. + * + * @throws XML_Query2XML_ConfigException If no pre-processor was set. + * @param array $record An associative array. + * @return mixed whatever is returned by the pre-processor + */ + public function execute(array $record) + { + return $this->runPreProcessor($record); + } + + /**As this class implements XML_Query2XML_Command_Conditional, XML_Query2XML + * will call this method to determin whether the condition is fulfilled. + * @param mixed $value The value previously returned by $this->execute(). + * @return boolean Whether the condition is fulfilled. + */ + public function evaluateCondition($value) + { + return is_object($value) || + !(is_null($value) || (is_string($value) && strlen($value) == 0)); + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/PHPCallback.php Sat Sep 29 23:14:23 2007 @@ -1,135 +1,137 @@ -<?php -/**This file contains the class XML_Query2XML_Command_PHPCallback. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: PHPCallback.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_PHPCallback extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that invokes a callback function, using the return value as the -* data source. -* -* This command class does not accept a pre-processor. -* -* usage: -* <code> -* function myFunction($record) { ... } -* $commandObject = new XML_Query2XML_Command_PHPCallback('myFunction'); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_PHPCallback extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource -{ - private $_callback = null; - private $_args = array(); - - /**Constructor - * - * The following formats are supported for $callback: - * - 'myFunction' - * - 'myFunction(arg1, arg2, ...)' - * - 'MyClass::myStaticMethod' - * - 'MyClass::myStaticMethod(arg1, arg2, ...)' - * You can also pass additional string arguments to the callback function by - * specifing them within the opening and closing brace; e.g. 'Utils::limit(12)' - * will result in Util::limit() being called by execute() with the $record as - * the first and '12' as the second argument. - * If you do not want to pass additional arguments to the callback function, - * the opening and closing brace are optional. - * - * @throws XML_Query2XML_ConfigException If $callback is not callable. - * @param mixed $callback - * @param string $configPath The configuration path within the $options array. - * This argument is optional. - */ - public function __construct($callback, $configPath) - { - $this->_configPath = $configPath; - if ($this->_configPath) { - $this->_configPath .= ': '; - } - - $braceOpen = strpos($callback, '('); - if ($braceOpen !== false) { - $braceClose = strpos($callback, ')'); - if ($braceOpen + 1 < $braceClose) { - $argsString = substr( - $callback, $braceOpen + 1, $braceClose - $braceOpen - 1 - ); - $this->_args = explode(',', str_replace(', ', ',', $argsString)); - } - if ($braceOpen < $braceClose) { - $callback = substr($callback, 0, $braceOpen); - } - } - if (strpos($callback, '::') !== false) { - $callback = split('::', $callback); - } - if (!is_callable($callback, false, $callableName)) { - /* - * unit tests: _applyColumnStringToRecord/ - * throwConfigException_callback_function1.phpt - * throwConfigException_callback_function2.phpt - * throwConfigException_callback_method1.phpt - * throwConfigException_callback_method2.phpt - */ - throw new XML_Query2XML_ConfigException( - $this->_configPath . 'The method/function "' . $callableName - . '" is not callable.' - ); - } - $this->_callback = $callback; - } - - /**Called by XML_Query2XML for every record in the result set. - * - * @param array $record An associative array. - * @return mixed Whatever the callback function returned. - */ - public function execute(array $record) - { - return call_user_func_array( - $this->_callback, - array_merge(array($record), $this->_args) - ); - } - - /**This method is called by XML_Query2XML in case the asterisk shortcut was used. - * - * The interface XML_Query2XML_Command_DataSource requires an implementation of - * this method. - * - * @param string $columnName The column name that is to replace every occurance - * of the asterisk character '*' in any of the arguments - * specified in the 'myFunction(arg1, arg2, ...)' or - * 'MyClass::myStaticMethod(arg1, arg2, ...)' notation. - */ - public function replaceAsterisks($columnName) - { - foreach ($this->_args as $key => $arg) { - $this->_args[$key] = str_replace('*', $columnName, $this->_args[$key]); - } - } -} +<?php +/**This file contains the class XML_Query2XML_Command_PHPCallback. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: PHPCallback.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_PHPCallback extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that invokes a callback function, using the return value as the +* data source. +* +* This command class does not accept a pre-processor. +* +* usage: +* <code> +* function myFunction($record) { ... } +* $commandObject = new XML_Query2XML_Command_PHPCallback('myFunction'); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_PHPCallback extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource +{ + private $_callback = null; + private $_args = array(); + + /**Constructor + * + * The following formats are supported for $callback: + * - 'myFunction' + * - 'myFunction(arg1, arg2, ...)' + * - 'MyClass::myStaticMethod' + * - 'MyClass::myStaticMethod(arg1, arg2, ...)' + * You can also pass additional string arguments to the callback function by + * specifing them within the opening and closing brace; e.g. 'Utils::limit(12)' + * will result in Util::limit() being called by execute() with the $record as + * the first and '12' as the second argument. + * If you do not want to pass additional arguments to the callback function, + * the opening and closing brace are optional. + * + * @throws XML_Query2XML_ConfigException If $callback is not callable. + * @param mixed $callback + * @param string $configPath The configuration path within the $options array. + * This argument is optional. + */ + public function __construct($callback, $configPath) + { + $this->configPath = $configPath; + if ($this->configPath) { + $this->configPath .= ': '; + } + + $braceOpen = strpos($callback, '('); + if ($braceOpen !== false) { + $braceClose = strpos($callback, ')'); + if ($braceOpen + 1 < $braceClose) { + $argsString = substr( + $callback, $braceOpen + 1, $braceClose - $braceOpen - 1 + ); + $this->_args = explode(',', str_replace(', ', ',', $argsString)); + } + if ($braceOpen < $braceClose) { + $callback = substr($callback, 0, $braceOpen); + } + } + if (strpos($callback, '::') !== false) { + $callback = split('::', $callback); + } + if (!is_callable($callback, false, $callableName)) { + /* + * unit tests: _applyColumnStringToRecord/ + * throwConfigException_callback_function1.phpt + * throwConfigException_callback_function2.phpt + * throwConfigException_callback_method1.phpt + * throwConfigException_callback_method2.phpt + */ + throw new XML_Query2XML_ConfigException( + $this->configPath . 'The method/function "' . $callableName + . '" is not callable.' + ); + } + $this->_callback = $callback; + } + + /**Called by XML_Query2XML for every record in the result set. + * + * @param array $record An associative array. + * @return mixed Whatever the callback function returned. + */ + public function execute(array $record) + { + return call_user_func_array( + $this->_callback, + array_merge(array($record), $this->_args) + ); + } + + /**This method is called by XML_Query2XML in case the asterisk shortcut was used. + * + * The interface XML_Query2XML_Command_DataSource requires an implementation of + * this method. + * + * @param string $columnName The column name that is to replace every occurance + * of the asterisk character '*' in any of the arguments + * specified in the 'myFunction(arg1, arg2, ...)' or + * 'MyClass::myStaticMethod(arg1, arg2, ...)' notation. + */ + public function replaceAsterisks($columnName) + { + foreach ($this->_args as $key => $arg) { + $this->_args[$key] = str_replace('*', $columnName, $this->_args[$key]); + } + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Static.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Static.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Static.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Static.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Static.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Static.php Sat Sep 29 23:14:23 2007 @@ -1,90 +1,92 @@ -<?php -/**This file contains the class XML_Query2XML_Command_Static. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: Static.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_Static extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command class that allows a static value to be used as the data source. -* -* This command class does not accept a pre-processor. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_Static('my static value'); -* </code> -* -* The static value can also be an instance of DOMNode or an array of DOMNode -* instances: -* <code> -* $commandObject = new XML_Query2XML_Command_Static(new DOMElement('test')); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_Static extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource -{ - /**The static data. - * @var mixed - */ - private $_data = null; - - /**Constructor - * @param mixed $data The static data. - */ - public function __construct($data) - { - if ($data === false) { - $data = ''; - } - $this->_data = $data; - } - - /**Called by XML_Query2XML for every record in the result set. - * - * @param array $record An associative array. - * @return mixed Whatever was passed as $data to the constructor. - */ - public function execute(array $record) - { - return $this->_data; - } - - /**This method is called by XML_Query2XML in case the asterisk shortcut was used. - * - * The interface XML_Query2XML_Command_DataSource requires an implementation of - * this method. - * - * @param string $columnName The column name that is to replace every occurance - * of the asterisk character '*' in the static value, - * in case it is a string. - */ - public function replaceAsterisks($columnName) - { - if (is_string($this->_data)) { - $this->_data = str_replace('*', $columnName, $this->_data); - } - } -} +<?php +/**This file contains the class XML_Query2XML_Command_Static. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: Static.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_Static extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command class that allows a static value to be used as the data source. +* +* This command class does not accept a pre-processor. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_Static('my static value'); +* </code> +* +* The static value can also be an instance of DOMNode or an array of DOMNode +* instances: +* <code> +* $commandObject = new XML_Query2XML_Command_Static(new DOMElement('test')); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_Static extends XML_Query2XML_Command_Chain implements XML_Query2XML_Command_DataSource +{ + /**The static data. + * @var mixed + */ + private $_data = null; + + /**Constructor + * @param mixed $data The static data. + */ + public function __construct($data) + { + if ($data === false) { + $data = ''; + } + $this->_data = $data; + } + + /**Called by XML_Query2XML for every record in the result set. + * + * @param array $record An associative array. + * @return mixed Whatever was passed as $data to the constructor. + */ + public function execute(array $record) + { + return $this->_data; + } + + /**This method is called by XML_Query2XML in case the asterisk shortcut was used. + * + * The interface XML_Query2XML_Command_DataSource requires an implementation of + * this method. + * + * @param string $columnName The column name that is to replace every occurance + * of the asterisk character '*' in the static value, + * in case it is a string. + */ + public function replaceAsterisks($columnName) + { + if (is_string($this->_data)) { + $this->_data = str_replace('*', $columnName, $this->_data); + } + } +} ?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php?r1=1.1&r2=1.2&diff_format=u Index: pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php diff -u pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php:1.1 pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php:1.2 --- pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php:1.1 Sun Sep 16 02:04:06 2007 +++ pear/XML_Query2XML/XML/Query2XML/Command/Unserialize.php Sat Sep 29 23:14:23 2007 @@ -1,82 +1,84 @@ -<?php -/**This file contains the class XML_Query2XML_Command_Unserialize. -* -* LICENSE: -* This source file is subject to version 2.1 of the LGPL -* that is bundled with this package in the file LICENSE. -* -* COPYRIGHT: -* Empowered Media -* http://www.empoweredmedia.com -* 481 Eighth Avenue Suite 1530 -* New York, NY 10001 -* -* @copyright Empowered Media 2006 -* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @package XML_Query2XML -* @version $Id: Unserialize.php,v 1.1 2007/09/16 02:04:06 lukasfeiler Exp $ -*/ - -/**XML_Query2XML_Command_Unserialize extends the class XML_Query2XML_Command_Chain. -*/ -require_once 'XML/Query2XML/Command/Chain.php'; - -/**Command object that allows unserialization of XML data returned by a pre-processor -* as a string. -* -* XML_Query2XML_Command_Unserialize only works with a pre-processor -* that returns a string. -* -* usage: -* <code> -* $commandObject = new XML_Query2XML_Command_Unserialize( -* new XML_Query2XML_Command_ColumnValue('xml_data') //pre-processor -* ); -* </code> -* -* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> -* @version Release: @package_version@ -* @copyright Empowered Media 2006 -* @package XML_Query2XML -* @since Interface available since Release 1.5.0RC1 -*/ -class XML_Query2XML_Command_Unserialize extends XML_Query2XML_Command_Chain -{ - /**Called by XML_Query2XML for every record in the result set. - * This method will return an instance of DOMElement or null - * if an empty string was returned by the pre-processor. - * - * @throws XML_Query2XML_ConfigException If the pre-processor returned - * something that cannot be converted to a string (i.e. an - * array or an object) or if that string could not be - * unserialized, i.e. was not corretly formatted XML. - * @param array $record An associative array. - * @return DOMElement - */ - public function execute(array $record) - { - $doc = new DOMDocument(); - $xml = $this->_runPreProcessor($record); - if (is_array($xml) || is_object($xml)) { - throw new XML_Query2XML_XMLException( - $this->_configPath . 'XML_Query2XML_Command_Unserialize: string ' - . 'expected from pre-processor, but ' . gettype($xml) . ' returned.' - ); - } else { - if (strlen($xml)) { - if (!@$doc->loadXML($xml)) { - throw new XML_Query2XML_XMLException( - $this->_configPath . 'XML_Query2XML_Command_Unserialize: ' - . 'Could not unserialize the following XML data: "' - . $xml . '"' - ); - } - return $doc->documentElement; - } else { - return null; - } - } - } -} +<?php +/**This file contains the class XML_Query2XML_Command_Unserialize. +* +* LICENSE: +* This source file is subject to version 2.1 of the LGPL +* that is bundled with this package in the file LICENSE. +* +* COPYRIGHT: +* Empowered Media +* http://www.empoweredmedia.com +* 481 Eighth Avenue Suite 1530 +* New York, NY 10001 +* +* @copyright Empowered Media 2006 +* @license http://www.gnu.org/copyleft/lesser.html LGPL Version 2.1 +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @package XML_Query2XML +* @version $Id: Unserialize.php,v 1.2 2007/09/29 23:14:23 lukasfeiler Exp $ +* @access private +*/ + +/**XML_Query2XML_Command_Unserialize extends the class XML_Query2XML_Command_Chain. +*/ +require_once 'XML/Query2XML/Command/Chain.php'; + +/**Command object that allows unserialization of XML data returned by a pre-processor +* as a string. +* +* XML_Query2XML_Command_Unserialize only works with a pre-processor +* that returns a string. +* +* usage: +* <code> +* $commandObject = new XML_Query2XML_Command_Unserialize( +* new XML_Query2XML_Command_ColumnValue('xml_data') //pre-processor +* ); +* </code> +* +* @access private +* @author Lukas Feiler <lukas.feiler@lukasfeiler.com> +* @version Release: @package_version@ +* @copyright Empowered Media 2006 +* @package XML_Query2XML +* @since Interface available since Release 1.5.0RC1 +*/ +class XML_Query2XML_Command_Unserialize extends XML_Query2XML_Command_Chain +{ + /**Called by XML_Query2XML for every record in the result set. + * This method will return an instance of DOMElement or null + * if an empty string was returned by the pre-processor. + * + * @throws XML_Query2XML_ConfigException If the pre-processor returned + * something that cannot be converted to a string (i.e. an + * array or an object) or if that string could not be + * unserialized, i.e. was not corretly formatted XML. + * @param array $record An associative array. + * @return DOMElement + */ + public function execute(array $record) + { + $doc = new DOMDocument(); + $xml = $this->runPreProcessor($record); + if (is_array($xml) || is_object($xml)) { + throw new XML_Query2XML_XMLException( + $this->configPath . 'XML_Query2XML_Command_Unserialize: string ' + . 'expected from pre-processor, but ' . gettype($xml) . ' returned.' + ); + } else { + if (strlen($xml)) { + if (!@$doc->loadXML($xml)) { + throw new XML_Query2XML_XMLException( + $this->configPath . 'XML_Query2XML_Command_Unserialize: ' + . 'Could not unserialize the following XML data: "' + . $xml . '"' + ); + } + return $doc->documentElement; + } else { + return null; + } + } + } +} ?> \ No newline at end of file