X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fpear%2FPEAR%2FTask%2FReplace.php;h=7483282bb77b39ac5ab2d3539c4feb2b0d96cb6f;hb=699d174c8cd3dd88265826a6b69c7fae3b62e0a8;hp=376df64df65c9e48c99904e63d6412d55a797925;hpb=9a23a8c0a51b7ec38a96f525484134f3cb85dc7e;p=timetracker.git diff --git a/WEB-INF/lib/pear/PEAR/Task/Replace.php b/WEB-INF/lib/pear/PEAR/Task/Replace.php index 376df64d..7483282b 100644 --- a/WEB-INF/lib/pear/PEAR/Task/Replace.php +++ b/WEB-INF/lib/pear/PEAR/Task/Replace.php @@ -4,14 +4,13 @@ * * PHP versions 4 and 5 * - * @category pear - * @package PEAR - * @author Greg Beaver - * @copyright 1997-2009 The Authors - * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Replace.php 313023 2011-07-06 19:17:11Z dufuz $ - * @link http://pear.php.net/package/PEAR - * @since File available since Release 1.4.0a1 + * @category pear + * @package PEAR + * @author Greg Beaver + * @copyright 1997-2009 The Authors + * @license http://opensource.org/licenses/bsd-license.php New BSD License + * @link http://pear.php.net/package/PEAR + * @since File available since Release 1.4.0a1 */ /** * Base class @@ -24,24 +23,24 @@ require_once 'PEAR/Task/Common.php'; * @author Greg Beaver * @copyright 1997-2009 The Authors * @license http://opensource.org/licenses/bsd-license.php New BSD License - * @version Release: 1.9.4 + * @version Release: 1.10.1 * @link http://pear.php.net/package/PEAR * @since Class available since Release 1.4.0a1 */ class PEAR_Task_Replace extends PEAR_Task_Common { - var $type = 'simple'; - var $phase = PEAR_TASK_PACKAGEANDINSTALL; - var $_replacements; + public $type = 'simple'; + public $phase = PEAR_TASK_PACKAGEANDINSTALL; + public $_replacements; /** * Validate the raw xml at parsing-time. - * @param PEAR_PackageFile_v2 - * @param array raw, parsed xml - * @param PEAR_Config - * @static + * + * @param PEAR_PackageFile_v2 + * @param array raw, parsed xml + * @param PEAR_Config */ - function validateXml($pkg, $xml, $config, $fileXml) + public static function validateXml($pkg, $xml, $config, $fileXml) { if (!isset($xml['attribs'])) { return array(PEAR_TASK_ERROR_NOATTRIBS); @@ -58,33 +57,36 @@ class PEAR_Task_Replace extends PEAR_Task_Common if ($xml['attribs']['type'] == 'pear-config') { if (!in_array($xml['attribs']['to'], $config->getKeys())) { return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'], - $config->getKeys()); + $config->getKeys(), ); } } elseif ($xml['attribs']['type'] == 'php-const') { if (defined($xml['attribs']['to'])) { return true; } else { return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'], - array('valid PHP constant')); + array('valid PHP constant'), ); } } elseif ($xml['attribs']['type'] == 'package-info') { - if (in_array($xml['attribs']['to'], + if (in_array( + $xml['attribs']['to'], array('name', 'summary', 'channel', 'notes', 'extends', 'description', 'release_notes', 'license', 'release-license', 'license-uri', 'version', 'api-version', 'state', 'api-state', 'release_date', - 'date', 'time'))) { + 'date', 'time', ) + )) { return true; } else { return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'to', $xml['attribs']['to'], array('name', 'summary', 'channel', 'notes', 'extends', 'description', 'release_notes', 'license', 'release-license', 'license-uri', 'version', 'api-version', 'state', 'api-state', 'release_date', - 'date', 'time')); + 'date', 'time', ), ); } } else { return array(PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, 'type', $xml['attribs']['type'], - array('pear-config', 'package-info', 'php-const')); + array('pear-config', 'package-info', 'php-const'), ); } + return true; } @@ -92,8 +94,9 @@ class PEAR_Task_Replace extends PEAR_Task_Common * Initialize a task instance with the parameters * @param array raw, parsed xml * @param unused + * @param unused */ - function init($xml, $attribs) + public function init($xml, $attribs, $lastVersion = null) { $this->_replacements = isset($xml['attribs']) ? array($xml) : $xml; } @@ -102,13 +105,14 @@ class PEAR_Task_Replace extends PEAR_Task_Common * Do a package.xml 1.0 replacement, with additional package-info fields available * * See validateXml() source for the complete list of allowed fields - * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 - * @param string file contents - * @param string the eventual final file location (informational only) + * + * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 + * @param string file contents + * @param string the eventual final file location (informational only) * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail - * (use $this->throwError), otherwise return the new contents + * (use $this->throwError), otherwise return the new contents */ - function startSession($pkg, $contents, $dest) + public function startSession($pkg, $contents, $dest) { $subst_from = $subst_to = array(); foreach ($this->_replacements as $a) { @@ -124,6 +128,7 @@ class PEAR_Task_Replace extends PEAR_Task_Common $to = $chan->getServer(); } else { $this->logger->log(0, "$dest: invalid pear-config replacement: $a[to]"); + return false; } } else { @@ -140,6 +145,7 @@ class PEAR_Task_Replace extends PEAR_Task_Common } if (is_null($to)) { $this->logger->log(0, "$dest: invalid pear-config replacement: $a[to]"); + return false; } } elseif ($a['type'] == 'php-const') { @@ -150,6 +156,7 @@ class PEAR_Task_Replace extends PEAR_Task_Common $to = constant($a['to']); } else { $this->logger->log(0, "$dest: invalid php-const replacement: $a[to]"); + return false; } } else { @@ -157,6 +164,7 @@ class PEAR_Task_Replace extends PEAR_Task_Common $to = $t; } else { $this->logger->log(0, "$dest: invalid package-info replacement: $a[to]"); + return false; } } @@ -165,12 +173,14 @@ class PEAR_Task_Replace extends PEAR_Task_Common $subst_to[] = $to; } } - $this->logger->log(3, "doing " . sizeof($subst_from) . - " substitution(s) for $dest"); + $this->logger->log( + 3, "doing ".sizeof($subst_from). + " substitution(s) for $dest" + ); if (sizeof($subst_from)) { $contents = str_replace($subst_from, $subst_to, $contents); } + return $contents; } } -?> \ No newline at end of file