Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.

Removed PHP_Compat, and references to it.
Removed ionCube/Zend/mmCache compatibility checks in test.php script.
Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
anubis
2009-01-04 19:22:54 -05:00
parent 60b674c776
commit fae6352bf2
384 changed files with 34150 additions and 44524 deletions

View File

@@ -13,9 +13,9 @@
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: v1.php,v 1.69 2005/09/25 03:48:59 cellog Exp $
* @version CVS: $Id: v1.php,v 1.74 2008/01/03 20:26:37 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
@@ -33,9 +33,9 @@ require_once 'PEAR/PackageFile/v2.php';
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.4.5
* @version Release: 1.7.2
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
@@ -52,7 +52,7 @@ class PEAR_PackageFile_Generator_v1
function getPackagerVersion()
{
return '1.4.5';
return '1.7.2';
}
/**
@@ -206,7 +206,7 @@ class PEAR_PackageFile_Generator_v1
);
$ret = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
$ret .= "<!DOCTYPE package SYSTEM \"http://pear.php.net/dtd/package-1.0\">\n";
$ret .= "<package version=\"1.0\" packagerversion=\"1.4.5\">\n" .
$ret .= "<package version=\"1.0\" packagerversion=\"1.7.2\">\n" .
" <name>$pkginfo[package]</name>";
if (isset($pkginfo['extends'])) {
$ret .= "\n<extends>$pkginfo[extends]</extends>";
@@ -321,7 +321,10 @@ class PEAR_PackageFile_Generator_v1
$ret .= $this->recursiveXmlFilelist($pkginfo['filelist']);
} else {
foreach ($pkginfo['filelist'] as $file => $fa) {
@$ret .= "$indent <file role=\"$fa[role]\"";
if (!isset($fa['role'])) {
$fa['role'] = '';
}
$ret .= "$indent <file role=\"$fa[role]\"";
if (isset($fa['baseinstalldir'])) {
$ret .= ' baseinstalldir="' .
$this->_fixXmlEncoding($fa['baseinstalldir']) . '"';
@@ -348,7 +351,7 @@ class PEAR_PackageFile_Generator_v1
}
$ret .= "/>\n";
}
@$ret .= "$indent </file>\n";
$ret .= "$indent </file>\n";
}
}
}
@@ -680,7 +683,9 @@ class PEAR_PackageFile_Generator_v1
}
$ret = new $class;
$ret->setConfig($this->_packagefile->_config);
$ret->setLogger($this->_packagefile->_logger);
if (isset($this->_packagefile->_logger) && is_object($this->_packagefile->_logger)) {
$ret->setLogger($this->_packagefile->_logger);
}
$ret->fromArray($arr);
return $ret;
}
@@ -695,7 +700,7 @@ class PEAR_PackageFile_Generator_v1
$peardep = array('pearinstaller' =>
array('min' => '1.4.0b1')); // this is a lot safer
$required = $optional = array();
$release['dependencies'] = array();
$release['dependencies'] = array('required' => array());
if ($this->_packagefile->hasDeps()) {
foreach ($this->_packagefile->getDeps() as $dep) {
if (!isset($dep['optional']) || $dep['optional'] == 'no') {

View File

@@ -14,9 +14,9 @@
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @author Stephan Schmidt (original XML_Serializer code)
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: v2.php,v 1.32 2005/10/02 06:29:24 cellog Exp $
* @version CVS: $Id: v2.php,v 1.39 2008/05/13 05:29:24 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
@@ -33,9 +33,9 @@ require_once 'System.php';
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @author Stephan Schmidt (original XML_Serializer code)
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.4.5
* @version Release: 1.7.2
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
@@ -61,7 +61,7 @@ class PEAR_PackageFile_Generator_v2
'indentAttributes' => false, // indent the attributes, if set to '_auto', it will indent attributes so they all start at the same column
'mode' => 'simplexml', // use 'simplexml' to use parent name as tagname if transforming an indexed array
'addDoctype' => false, // add a doctype declaration
'doctype' => null, // supply a string or an array with id and uri ({@see XML_Util::getDoctypeDeclaration()}
'doctype' => null, // supply a string or an array with id and uri ({@see PEAR_PackageFile_Generator_v2_PEAR_PackageFile_Generator_v2_XML_Util::getDoctypeDeclaration()}
'rootName' => 'package', // name of the root tag
'rootAttributes' => array(
'version' => '2.0',
@@ -114,7 +114,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
*/
function getPackagerVersion()
{
return '1.4.5';
return '1.7.2';
}
/**
@@ -213,19 +213,16 @@ http://pear.php.net/dtd/package-2.0.xsd',
if (!file_exists($file)) {
return $packager->raiseError("File does not exist: $fname");
} else {
$origperms = fileperms($file);
$tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
unset($orig['attribs']);
if (count($orig)) { // file with tasks
// run any package-time tasks
if (function_exists('file_get_contents')) {
$contents = file_get_contents($file);
} else {
$fp = fopen($file, "r");
$contents = @fread($fp, filesize($file));
fclose($fp);
}
$contents = file_get_contents($file);
foreach ($orig as $tag => $raw) {
$tag = str_replace($this->_packagefile->getTasksNs() . ':', '', $tag);
$tag = str_replace(
array($this->_packagefile->getTasksNs() . ':', '-'),
array('', '_'), $tag);
$task = "PEAR_Task_$tag";
$task = &new $task($this->_packagefile->_config,
$this->_packagefile->_logger,
@@ -249,6 +246,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
System::mkdir(array('-p', dirname($tfile)));
copy($file, $tfile);
}
chmod($tfile, $origperms);
$filelist[$i++] = $tfile;
$this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($tfile), $i - 1);
$packager->log(2, "Adding file $fname");
@@ -358,7 +356,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
}
$this->options['beautifyFilelist'] = true;
}
$arr['attribs']['packagerversion'] = '1.4.5';
$arr['attribs']['packagerversion'] = '1.7.2';
if ($this->serialize($arr, $options)) {
return $this->_serializedData . "\n";
}
@@ -537,7 +535,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
// add doctype declaration
if ($this->options['addDoctype'] === true) {
$this->_serializedData = XML_Util::getDoctypeDeclaration($tagName, $this->options['doctype'])
$this->_serializedData = PEAR_PackageFile_Generator_v2_XML_Util::getDoctypeDeclaration($tagName, $this->options['doctype'])
. $this->options['linebreak']
. $this->_serializedData;
}
@@ -550,7 +548,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
} else {
$encoding = null;
}
$this->_serializedData = XML_Util::getXMLDeclaration('1.0', $encoding)
$this->_serializedData = PEAR_PackageFile_Generator_v2_XML_Util::getXMLDeclaration('1.0', $encoding)
. $this->options['linebreak']
. $this->_serializedData;
}
@@ -613,7 +611,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
* @param string $tagName name of the root tag
* @param array $attributes attributes for the root tag
* @return string $string serialized data
* @uses XML_Util::isValidName() to check, whether key has to be substituted
* @uses PEAR_PackageFile_Generator_v2_XML_Util::isValidName() to check, whether key has to be substituted
*/
function _serializeArray(&$array, $tagName = null, $attributes = array())
{
@@ -695,7 +693,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
if ($this->options['scalarAsAttributes'] === true) {
foreach ($array as $key => $value) {
if (is_scalar($value) && (XML_Util::isValidName($key) === true)) {
if (is_scalar($value) && (PEAR_PackageFile_Generator_v2_XML_Util::isValidName($key) === true)) {
unset($array[$key]);
$attributes[$this->options['prependAttributes'].$key] = $value;
}
@@ -722,7 +720,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
// copy key
$origKey = $key;
// key cannot be used as tagname => use default tag
$valid = XML_Util::isValidName($key);
$valid = PEAR_PackageFile_Generator_v2_XML_Util::isValidName($key);
if (PEAR::isError($valid)) {
if ($this->options['classAsTagName'] && is_object($value)) {
$key = get_class($value);
@@ -842,31 +840,23 @@ http://pear.php.net/dtd/package-2.0.xsd',
if (is_scalar($tag['content']) || is_null($tag['content'])) {
if ($this->options['encoding'] == 'UTF-8' &&
version_compare(phpversion(), '5.0.0', 'lt')) {
$encoding = XML_UTIL_ENTITIES_UTF8_XML;
$encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_UTF8_XML;
} else {
$encoding = XML_UTIL_ENTITIES_XML;
$encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML;
}
$tag = XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $this->options['linebreak'], $encoding);
$tag = PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $this->options['linebreak'], $encoding);
} elseif (is_array($tag['content'])) {
$tag = $this->_serializeArray($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_object($tag['content'])) {
$tag = $this->_serializeObject($tag['content'], $tag['qname'], $tag['attributes']);
} elseif (is_resource($tag['content'])) {
settype($tag['content'], 'string');
$tag = XML_Util::createTagFromArray($tag, $replaceEntities);
$tag = PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray($tag, $replaceEntities);
}
return $tag;
}
}
//foreach (explode(PATH_SEPARATOR, ini_get('include_path')) as $path) {
// $t = $path . DIRECTORY_SEPARATOR . 'XML' . DIRECTORY_SEPARATOR .
// 'Util';
// if (file_exists($t) && is_readable($t)) {
// include_once 'XML/Util';
// }
//}
//if (!class_exists('XML_Util')) {
// well, it's one way to do things without extra deps ...
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
@@ -885,76 +875,79 @@ http://pear.php.net/dtd/package-2.0.xsd',
// | Authors: Stephan Schmidt <schst@php-tools.net> |
// +----------------------------------------------------------------------+
//
// $Id: v2.php,v 1.32 2005/10/02 06:29:24 cellog Exp $
// $Id: v2.php,v 1.39 2008/05/13 05:29:24 cellog Exp $
/**
* error code for invalid chars in XML name
*/
define("XML_UTIL_ERROR_INVALID_CHARS", 51);
define("PEAR_PackageFile_Generator_v2_XML_Util_ERROR_INVALID_CHARS", 51);
/**
* error code for invalid chars in XML name
*/
define("XML_UTIL_ERROR_INVALID_START", 52);
define("PEAR_PackageFile_Generator_v2_XML_Util_ERROR_INVALID_START", 52);
/**
* error code for non-scalar tag content
*/
define("XML_UTIL_ERROR_NON_SCALAR_CONTENT", 60);
define("PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NON_SCALAR_CONTENT", 60);
/**
* error code for missing tag name
*/
define("XML_UTIL_ERROR_NO_TAG_NAME", 61);
define("PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NO_TAG_NAME", 61);
/**
* replace XML entities
*/
define("XML_UTIL_REPLACE_ENTITIES", 1);
define("PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES", 1);
/**
* embedd content in a CData Section
*/
define("XML_UTIL_CDATA_SECTION", 2);
define("PEAR_PackageFile_Generator_v2_XML_Util_CDATA_SECTION", 2);
/**
* do not replace entitites
*/
define("XML_UTIL_ENTITIES_NONE", 0);
define("PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_NONE", 0);
/**
* replace all XML entitites
* This setting will replace <, >, ", ' and &
*/
define("XML_UTIL_ENTITIES_XML", 1);
define("PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML", 1);
/**
* replace only required XML entitites
* This setting will replace <, " and &
*/
define("XML_UTIL_ENTITIES_XML_REQUIRED", 2);
define("PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML_REQUIRED", 2);
/**
* replace HTML entitites
* @link http://www.php.net/htmlentities
*/
define("XML_UTIL_ENTITIES_HTML", 3);
define("PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_HTML", 3);
/**
* replace all XML entitites, and encode from ISO-8859-1 to UTF-8
* This setting will replace <, >, ", ' and &
*/
define("XML_UTIL_ENTITIES_UTF8_XML", 4);
define("PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_UTF8_XML", 4);
/**
* utility class for working with XML documents
*
* customized version of XML_Util 0.6.0
*
* @category XML
* @package XML_Util
* @package PEAR
* @version 0.6.0
* @author Stephan Schmidt <schst@php.net>
* @author Gregory Beaver <cellog@php.net>
*/
class XML_Util {
class PEAR_PackageFile_Generator_v2_XML_Util {
/**
* return API version
@@ -978,19 +971,19 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // replace XML entites:
* $string = XML_Util::replaceEntities("This string contains < & >.");
* $string = PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities("This string contains < & >.");
* </code>
*
* @access public
* @static
* @param string string where XML special chars should be replaced
* @param integer setting for entities in attribute values (one of XML_UTIL_ENTITIES_XML, XML_UTIL_ENTITIES_XML_REQUIRED, XML_UTIL_ENTITIES_HTML)
* @param integer setting for entities in attribute values (one of PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML_REQUIRED, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_HTML)
* @return string string with replaced chars
*/
function replaceEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML)
function replaceEntities($string, $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)
{
switch ($replaceEntities) {
case XML_UTIL_ENTITIES_UTF8_XML:
case PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_UTF8_XML:
return strtr(utf8_encode($string),array(
'&' => '&amp;',
'>' => '&gt;',
@@ -998,7 +991,7 @@ class XML_Util {
'"' => '&quot;',
'\'' => '&apos;' ));
break;
case XML_UTIL_ENTITIES_XML:
case PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML:
return strtr($string,array(
'&' => '&amp;',
'>' => '&gt;',
@@ -1006,13 +999,13 @@ class XML_Util {
'"' => '&quot;',
'\'' => '&apos;' ));
break;
case XML_UTIL_ENTITIES_XML_REQUIRED:
case PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML_REQUIRED:
return strtr($string,array(
'&' => '&amp;',
'<' => '&lt;',
'"' => '&quot;' ));
break;
case XML_UTIL_ENTITIES_HTML:
case PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_HTML:
return htmlspecialchars($string);
break;
}
@@ -1026,7 +1019,7 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // get an XML declaration:
* $xmlDecl = XML_Util::getXMLDeclaration("1.0", "UTF-8", true);
* $xmlDecl = PEAR_PackageFile_Generator_v2_XML_Util::getXMLDeclaration("1.0", "UTF-8", true);
* </code>
*
* @access public
@@ -1035,7 +1028,7 @@ class XML_Util {
* @param string $encoding character encoding
* @param boolean $standAlone document is standalone (or not)
* @return string $decl xml declaration
* @uses XML_Util::attributesToString() to serialize the attributes of the XML declaration
* @uses PEAR_PackageFile_Generator_v2_XML_Util::attributesToString() to serialize the attributes of the XML declaration
*/
function getXMLDeclaration($version = "1.0", $encoding = null, $standalone = null)
{
@@ -1051,7 +1044,7 @@ class XML_Util {
$attributes["standalone"] = $standalone ? "yes" : "no";
}
return sprintf("<?xml%s?>", XML_Util::attributesToString($attributes, false));
return sprintf("<?xml%s?>", PEAR_PackageFile_Generator_v2_XML_Util::attributesToString($attributes, false));
}
/**
@@ -1061,7 +1054,7 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // get a doctype declaration:
* $xmlDecl = XML_Util::getDocTypeDeclaration("rootTag","myDocType.dtd");
* $xmlDecl = PEAR_PackageFile_Generator_v2_XML_Util::getDocTypeDeclaration("rootTag","myDocType.dtd");
* </code>
*
* @access public
@@ -1101,7 +1094,7 @@ class XML_Util {
* "argh" => "tomato"
* );
*
* $attList = XML_Util::attributesToString($att);
* $attList = PEAR_PackageFile_Generator_v2_XML_Util::attributesToString($att);
* </code>
*
* @access public
@@ -1111,12 +1104,12 @@ class XML_Util {
* @param boolean $multiline use linebreaks, if more than one attribute is given
* @param string $indent string used for indentation of multiline attributes
* @param string $linebreak string used for linebreaks of multiline attributes
* @param integer $entities setting for entities in attribute values (one of XML_UTIL_ENTITIES_NONE, XML_UTIL_ENTITIES_XML, XML_UTIL_ENTITIES_XML_REQUIRED, XML_UTIL_ENTITIES_HTML)
* @param integer $entities setting for entities in attribute values (one of PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_NONE, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML_REQUIRED, PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_HTML)
* @return string string representation of the attributes
* @uses XML_Util::replaceEntities() to replace XML entities in attribute values
* @uses PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities() to replace XML entities in attribute values
* @todo allow sort also to be an options array
*/
function attributesToString($attributes, $sort = true, $multiline = false, $indent = ' ', $linebreak = "\n", $entities = XML_UTIL_ENTITIES_XML)
function attributesToString($attributes, $sort = true, $multiline = false, $indent = ' ', $linebreak = "\n", $entities = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)
{
/**
* second parameter may be an array
@@ -1147,16 +1140,16 @@ class XML_Util {
}
if( !$multiline || count($attributes) == 1) {
foreach ($attributes as $key => $value) {
if ($entities != XML_UTIL_ENTITIES_NONE) {
$value = XML_Util::replaceEntities($value, $entities);
if ($entities != PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_NONE) {
$value = PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities($value, $entities);
}
$string .= ' '.$key.'="'.$value.'"';
}
} else {
$first = true;
foreach ($attributes as $key => $value) {
if ($entities != XML_UTIL_ENTITIES_NONE) {
$value = XML_Util::replaceEntities($value, $entities);
if ($entities != PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_NONE) {
$value = PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities($value, $entities);
}
if ($first) {
$string .= " ".$key.'="'.$value.'"';
@@ -1173,14 +1166,14 @@ class XML_Util {
/**
* create a tag
*
* This method will call XML_Util::createTagFromArray(), which
* This method will call PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray(), which
* is more flexible.
*
* <code>
* require_once 'XML/Util.php';
*
* // create an XML tag:
* $tag = XML_Util::createTag("myNs:myTag", array("foo" => "bar"), "This is inside the tag", "http://www.w3c.org/myNs#");
* $tag = PEAR_PackageFile_Generator_v2_XML_Util::createTag("myNs:myTag", array("foo" => "bar"), "This is inside the tag", "http://www.w3c.org/myNs#");
* </code>
*
* @access public
@@ -1195,10 +1188,10 @@ class XML_Util {
* @param string $linebreak string used for linebreaks
* @param string $encoding encoding that should be used to translate content
* @return string $string XML tag
* @see XML_Util::createTagFromArray()
* @uses XML_Util::createTagFromArray() to create the tag
* @see PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray()
* @uses PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray() to create the tag
*/
function createTag($qname, $attributes = array(), $content = null, $namespaceUri = null, $replaceEntities = XML_UTIL_REPLACE_ENTITIES, $multiline = false, $indent = "_auto", $linebreak = "\n", $encoding = XML_UTIL_ENTITIES_XML)
function createTag($qname, $attributes = array(), $content = null, $namespaceUri = null, $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES, $multiline = false, $indent = "_auto", $linebreak = "\n", $encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)
{
$tag = array(
"qname" => $qname,
@@ -1215,7 +1208,7 @@ class XML_Util {
$tag["namespaceUri"] = $namespaceUri;
}
return XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $linebreak, $encoding);
return PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, $indent, $linebreak, $encoding);
}
/**
@@ -1242,7 +1235,7 @@ class XML_Util {
* "content" => "I'm inside the tag",
* );
* // creating a tag with qualified name and namespaceUri
* $string = XML_Util::createTagFromArray($tag);
* $string = PEAR_PackageFile_Generator_v2_XML_Util::createTagFromArray($tag);
* </code>
*
* @access public
@@ -1253,18 +1246,18 @@ class XML_Util {
* @param string $indent string used to indent attributes (_auto indents attributes so they start at the same column)
* @param string $linebreak string used for linebreaks
* @return string $string XML tag
* @see XML_Util::createTag()
* @uses XML_Util::attributesToString() to serialize the attributes of the tag
* @uses XML_Util::splitQualifiedName() to get local part and namespace of a qualified name
* @see PEAR_PackageFile_Generator_v2_XML_Util::createTag()
* @uses PEAR_PackageFile_Generator_v2_XML_Util::attributesToString() to serialize the attributes of the tag
* @uses PEAR_PackageFile_Generator_v2_XML_Util::splitQualifiedName() to get local part and namespace of a qualified name
*/
function createTagFromArray($tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES, $multiline = false, $indent = "_auto", $linebreak = "\n", $encoding = XML_UTIL_ENTITIES_XML)
function createTagFromArray($tag, $replaceEntities = PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES, $multiline = false, $indent = "_auto", $linebreak = "\n", $encoding = PEAR_PackageFile_Generator_v2_XML_Util_ENTITIES_XML)
{
if (isset($tag["content"]) && !is_scalar($tag["content"])) {
return XML_Util::raiseError( "Supplied non-scalar value as tag content", XML_UTIL_ERROR_NON_SCALAR_CONTENT );
return PEAR_PackageFile_Generator_v2_XML_Util::raiseError( "Supplied non-scalar value as tag content", PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NON_SCALAR_CONTENT );
}
if (!isset($tag['qname']) && !isset($tag['localPart'])) {
return XML_Util::raiseError( 'You must either supply a qualified name (qname) or local tag name (localPart).', XML_UTIL_ERROR_NO_TAG_NAME );
return PEAR_PackageFile_Generator_v2_XML_Util::raiseError( 'You must either supply a qualified name (qname) or local tag name (localPart).', PEAR_PackageFile_Generator_v2_XML_Util_ERROR_NO_TAG_NAME );
}
// if no attributes hav been set, use empty attributes
@@ -1282,7 +1275,7 @@ class XML_Util {
}
// namespace URI is set, but no namespace
} elseif (isset($tag["namespaceUri"]) && !isset($tag["namespace"])) {
$parts = XML_Util::splitQualifiedName($tag["qname"]);
$parts = PEAR_PackageFile_Generator_v2_XML_Util::splitQualifiedName($tag["qname"]);
$tag["localPart"] = $parts["localPart"];
if (isset($parts["namespace"])) {
$tag["namespace"] = $parts["namespace"];
@@ -1307,14 +1300,14 @@ class XML_Util {
}
// create attribute list
$attList = XML_Util::attributesToString($tag["attributes"], true, $multiline, $indent, $linebreak );
$attList = PEAR_PackageFile_Generator_v2_XML_Util::attributesToString($tag["attributes"], true, $multiline, $indent, $linebreak );
if (!isset($tag["content"]) || (string)$tag["content"] == '') {
$tag = sprintf("<%s%s />", $tag["qname"], $attList);
} else {
if ($replaceEntities == XML_UTIL_REPLACE_ENTITIES) {
$tag["content"] = XML_Util::replaceEntities($tag["content"], $encoding);
} elseif ($replaceEntities == XML_UTIL_CDATA_SECTION) {
$tag["content"] = XML_Util::createCDataSection($tag["content"]);
if ($replaceEntities == PEAR_PackageFile_Generator_v2_XML_Util_REPLACE_ENTITIES) {
$tag["content"] = PEAR_PackageFile_Generator_v2_XML_Util::replaceEntities($tag["content"], $encoding);
} elseif ($replaceEntities == PEAR_PackageFile_Generator_v2_XML_Util_CDATA_SECTION) {
$tag["content"] = PEAR_PackageFile_Generator_v2_XML_Util::createCDataSection($tag["content"]);
}
$tag = sprintf("<%s%s>%s</%s>", $tag["qname"], $attList, $tag["content"], $tag["qname"] );
}
@@ -1328,7 +1321,7 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // create an XML start element:
* $tag = XML_Util::createStartElement("myNs:myTag", array("foo" => "bar") ,"http://www.w3c.org/myNs#");
* $tag = PEAR_PackageFile_Generator_v2_XML_Util::createStartElement("myNs:myTag", array("foo" => "bar") ,"http://www.w3c.org/myNs#");
* </code>
*
* @access public
@@ -1340,7 +1333,7 @@ class XML_Util {
* @param string $indent string used to indent attributes (_auto indents attributes so they start at the same column)
* @param string $linebreak string used for linebreaks
* @return string $string XML start element
* @see XML_Util::createEndElement(), XML_Util::createTag()
* @see PEAR_PackageFile_Generator_v2_XML_Util::createEndElement(), PEAR_PackageFile_Generator_v2_XML_Util::createTag()
*/
function createStartElement($qname, $attributes = array(), $namespaceUri = null, $multiline = false, $indent = '_auto', $linebreak = "\n")
{
@@ -1350,7 +1343,7 @@ class XML_Util {
}
if ($namespaceUri != null) {
$parts = XML_Util::splitQualifiedName($qname);
$parts = PEAR_PackageFile_Generator_v2_XML_Util::splitQualifiedName($qname);
}
// check for multiline attributes
@@ -1371,7 +1364,7 @@ class XML_Util {
}
// create attribute list
$attList = XML_Util::attributesToString($attributes, true, $multiline, $indent, $linebreak);
$attList = PEAR_PackageFile_Generator_v2_XML_Util::attributesToString($attributes, true, $multiline, $indent, $linebreak);
$element = sprintf("<%s%s>", $qname, $attList);
return $element;
}
@@ -1383,14 +1376,14 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // create an XML start element:
* $tag = XML_Util::createEndElement("myNs:myTag");
* $tag = PEAR_PackageFile_Generator_v2_XML_Util::createEndElement("myNs:myTag");
* </code>
*
* @access public
* @static
* @param string $qname qualified tagname (including namespace)
* @return string $string XML end element
* @see XML_Util::createStartElement(), XML_Util::createTag()
* @see PEAR_PackageFile_Generator_v2_XML_Util::createStartElement(), PEAR_PackageFile_Generator_v2_XML_Util::createTag()
*/
function createEndElement($qname)
{
@@ -1405,7 +1398,7 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // create an XML start element:
* $tag = XML_Util::createComment("I am a comment");
* $tag = PEAR_PackageFile_Generator_v2_XML_Util::createComment("I am a comment");
* </code>
*
* @access public
@@ -1426,7 +1419,7 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // create a CData section
* $tag = XML_Util::createCDataSection("I am content.");
* $tag = PEAR_PackageFile_Generator_v2_XML_Util::createCDataSection("I am content.");
* </code>
*
* @access public
@@ -1446,7 +1439,7 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // split qualified tag
* $parts = XML_Util::splitQualifiedName("xslt:stylesheet");
* $parts = PEAR_PackageFile_Generator_v2_XML_Util::splitQualifiedName("xslt:stylesheet");
* </code>
* the returned array will contain two elements:
* <pre>
@@ -1491,8 +1484,8 @@ class XML_Util {
* require_once 'XML/Util.php';
*
* // verify tag name
* $result = XML_Util::isValidName("invalidTag?");
* if (XML_Util::isError($result)) {
* $result = PEAR_PackageFile_Generator_v2_XML_Util::isValidName("invalidTag?");
* if (PEAR_PackageFile_Generator_v2_XML_Util::isError($result)) {
* print "Invalid XML name: " . $result->getMessage();
* }
* </code>
@@ -1506,20 +1499,20 @@ class XML_Util {
function isValidName($string)
{
// check for invalid chars
if (!preg_match("/^[[:alnum:]_\-.]$/", $string{0})) {
return XML_Util::raiseError( "XML names may only start with letter or underscore", XML_UTIL_ERROR_INVALID_START );
if (!preg_match("/^[[:alnum:]_\-.]\\z/", $string{0})) {
return PEAR_PackageFile_Generator_v2_XML_Util::raiseError( "XML names may only start with letter or underscore", PEAR_PackageFile_Generator_v2_XML_Util_ERROR_INVALID_START );
}
// check for invalid chars
if (!preg_match("/^([a-zA-Z_]([a-zA-Z0-9_\-\.]*)?:)?[a-zA-Z_]([a-zA-Z0-9_\-\.]+)?$/", $string)) {
return XML_Util::raiseError( "XML names may only contain alphanumeric chars, period, hyphen, colon and underscores", XML_UTIL_ERROR_INVALID_CHARS );
if (!preg_match("/^([a-zA-Z_]([a-zA-Z0-9_\-\.]*)?:)?[a-zA-Z_]([a-zA-Z0-9_\-\.]+)?\\z/", $string)) {
return PEAR_PackageFile_Generator_v2_XML_Util::raiseError( "XML names may only contain alphanumeric chars, period, hyphen, colon and underscores", PEAR_PackageFile_Generator_v2_XML_Util_ERROR_INVALID_CHARS );
}
// XML name is valid
return true;
}
/**
* replacement for XML_Util::raiseError
* replacement for PEAR_PackageFile_Generator_v2_XML_Util::raiseError
*
* Avoids the necessity to always require
* PEAR.php
@@ -1535,5 +1528,4 @@ class XML_Util {
return PEAR::raiseError($msg, $code);
}
}
//} // if (!class_exists('XML_Util'))
?>

View File

@@ -13,9 +13,9 @@
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: v1.php,v 1.20 2005/09/25 03:49:00 cellog Exp $
* @version CVS: $Id: v1.php,v 1.27 2008/01/03 20:55:16 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
@@ -28,7 +28,7 @@ require_once 'PEAR/PackageFile/v1.php';
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @PEAR-VER@
* @link http://pear.php.net/package/PEAR
@@ -66,14 +66,15 @@ class PEAR_PackageFile_Parser_v1
* @param string contents of package.xml file, version 1.0
* @return bool success of parsing
*/
function parse($data, $file, $archive = false)
function &parse($data, $file, $archive = false)
{
if (!extension_loaded('xml')) {
return PEAR::raiseError('Cannot create xml parser for parsing package.xml, no xml extension');
}
$xp = @xml_parser_create();
$xp = xml_parser_create();
if (!$xp) {
return PEAR::raiseError('Cannot create xml parser for parsing package.xml');
$a = &PEAR::raiseError('Cannot create xml parser for parsing package.xml');
return $a;
}
xml_set_object($xp, $this);
xml_set_element_handler($xp, '_element_start_1_0', '_element_end_1_0');
@@ -96,8 +97,9 @@ class PEAR_PackageFile_Parser_v1
$code = xml_get_error_code($xp);
$line = xml_get_current_line_number($xp);
xml_parser_free($xp);
return PEAR::raiseError(sprintf("XML error: %s at line %d",
$a = &PEAR::raiseError(sprintf("XML error: %s at line %d",
$str = xml_error_string($code), $line), 2);
return $a;
}
xml_parser_free($xp);
@@ -132,6 +134,8 @@ class PEAR_PackageFile_Parser_v1
foreach (explode("\n", $str) as $line) {
if (substr($line, 0, $indent_len) == $indent) {
$data .= substr($line, $indent_len) . "\n";
} elseif (trim(substr($line, 0, $indent_len))) {
$data .= ltrim($line);
}
}
return $data;
@@ -167,7 +171,7 @@ class PEAR_PackageFile_Parser_v1
if (array_key_exists('name', $attribs) && $attribs['name'] != '/') {
$attribs['name'] = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'),
$attribs['name']);
if (strrpos($attribs['name'], '/') == strlen($attribs['name']) - 1) {
if (strrpos($attribs['name'], '/') === strlen($attribs['name']) - 1) {
$attribs['name'] = substr($attribs['name'], 0,
strlen($attribs['name']) - 1);
}

View File

@@ -13,9 +13,9 @@
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: v2.php,v 1.17 2005/09/25 03:49:00 cellog Exp $
* @version CVS: $Id: v2.php,v 1.21 2008/01/03 20:26:37 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
@@ -29,7 +29,7 @@ require_once 'PEAR/PackageFile/v2.php';
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: @PEAR-VER@
* @link http://pear.php.net/package/PEAR
@@ -70,6 +70,8 @@ class PEAR_PackageFile_Parser_v2 extends PEAR_XMLParser
foreach (explode("\n", $str) as $line) {
if (substr($line, 0, $indent_len) == $indent) {
$data .= substr($line, $indent_len) . "\n";
} else {
$data .= $line . "\n";
}
}
return $data;
@@ -97,7 +99,7 @@ class PEAR_PackageFile_Parser_v2 extends PEAR_XMLParser
* a subclass
* @return PEAR_PackageFile_v2
*/
function parse($data, $file, $archive = false, $class = 'PEAR_PackageFile_v2')
function &parse($data, $file, $archive = false, $class = 'PEAR_PackageFile_v2')
{
if (PEAR::isError($err = parent::parse($data, $file))) {
return $err;

View File

@@ -13,9 +13,9 @@
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: v1.php,v 1.67 2005/10/27 05:07:24 cellog Exp $
* @version CVS: $Id: v1.php,v 1.74 2008/01/03 20:26:36 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
@@ -279,9 +279,9 @@ define('PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME', 52);
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.4.5
* @version Release: 1.7.2
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
@@ -457,6 +457,9 @@ class PEAR_PackageFile_v1
function setDirtree($path)
{
if (!isset($this->_packageInfo['dirtree'])) {
$this->_packageInfo['dirtree'] = array();
}
$this->_packageInfo['dirtree'][$path] = true;
}
@@ -858,6 +861,11 @@ class PEAR_PackageFile_v1
return false;
}
function getProvidesExtension()
{
return false;
}
function addFile($dir, $file, $attrs)
{
$dir = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'), $dir);
@@ -1192,14 +1200,33 @@ class PEAR_PackageFile_v1
$this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILEROLE,
array('file' => $file, 'role' => $fa['role'], 'roles' => PEAR_Common::getFileRoles()));
}
if ($file{0} == '.' && $file{1} == '/') {
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~', str_replace('\\', '/', $file))) {
// file contains .. parent directory or . cur directory references
$this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME,
array('file' => $file));
}
if (isset($fa['install-as']) &&
preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
str_replace('\\', '/', $fa['install-as']))) {
// install-as contains .. parent directory or . cur directory references
$this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME,
array('file' => $file . ' [installed as ' . $fa['install-as'] . ']'));
}
if (isset($fa['baseinstalldir']) &&
preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
str_replace('\\', '/', $fa['baseinstalldir']))) {
// install-as contains .. parent directory or . cur directory references
$this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME,
array('file' => $file . ' [baseinstalldir ' . $fa['baseinstalldir'] . ']'));
}
}
}
if (isset($this->_registry) && $this->_isValid) {
$chan = $this->_registry->getChannel('pear.php.net');
if (PEAR::isError($chan)) {
$this->_validateError(PEAR_PACKAGEFILE_ERROR_CHANNELVAL, $chan->getMessage());
return $this->_isValid = 0;
}
$validator = $chan->getValidationObject();
$validator->setPackageFile($this);
$validator->validate($state);
@@ -1349,13 +1376,8 @@ class PEAR_PackageFile_v1
if (!$fp = @fopen($file, "r")) {
return false;
}
if (function_exists('file_get_contents')) {
fclose($fp);
$contents = file_get_contents($file);
} else {
$contents = @fread($fp, filesize($file));
fclose($fp);
}
fclose($fp);
$contents = file_get_contents($file);
$tokens = token_get_all($contents);
/*
for ($i = 0; $i < sizeof($tokens); $i++) {

View File

@@ -13,9 +13,9 @@
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: v2.php,v 1.120 2005/11/14 14:06:17 cellog Exp $
* @version CVS: $Id: v2.php,v 1.143 2008/05/13 05:28:51 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
@@ -27,9 +27,9 @@ require_once 'PEAR/ErrorStack.php';
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.4.5
* @version Release: 1.7.2
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
@@ -121,12 +121,17 @@ class PEAR_PackageFile_v2
*
* - package name
* - channel name
* - dependencies
* - dependencies
* @var boolean
* @access private
*/
var $_incomplete = true;
/**
* @var PEAR_PackageFile_v2_Validator
*/
var $_v2Validator;
/**
* The constructor merely sets up the private error stack
*/
@@ -186,23 +191,24 @@ class PEAR_PackageFile_v2
$a = false;
return $a;
}
if ($this->getPackageType() == 'extsrc') {
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$releasetype = $this->getPackageType() . 'release';
if (!is_array($installer->getInstallPackages())) {
$a = false;
return $a;
}
foreach ($installer->getInstallPackages() as $p) {
if ($p->isExtension($this->_packageInfo['providesextension'])) {
if ($p->getPackageType() != 'extsrc') {
if ($p->getPackageType() != 'extsrc' && $p->getPackageType() != 'zendextsrc') {
$a = false;
return $a; // the user probably downloaded it separately
}
}
}
if (isset($this->_packageInfo['extsrcrelease']['binarypackage'])) {
if (isset($this->_packageInfo[$releasetype]['binarypackage'])) {
$installer->log(0, 'Attempting to download binary version of extension "' .
$this->_packageInfo['providesextension'] . '"');
$params = $this->_packageInfo['extsrcrelease']['binarypackage'];
$params = $this->_packageInfo[$releasetype]['binarypackage'];
if (!is_array($params) || !isset($params[0])) {
$params = array($params);
}
@@ -259,7 +265,8 @@ class PEAR_PackageFile_v2
*/
function getProvidesExtension()
{
if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) {
if (in_array($this->getPackageType(),
array('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
if (isset($this->_packageInfo['providesextension'])) {
return $this->_packageInfo['providesextension'];
}
@@ -273,7 +280,8 @@ class PEAR_PackageFile_v2
*/
function isExtension($extension)
{
if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) {
if (in_array($this->getPackageType(),
array('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
return $this->_packageInfo['providesextension'] == $extension;
}
return false;
@@ -465,6 +473,9 @@ class PEAR_PackageFile_v2
*/
function setRawState($state)
{
if (!isset($this->_packageInfo['stability'])) {
$this->_packageInfo['stability'] = array();
}
$this->_packageInfo['stability']['release'] = $state;
}
@@ -598,6 +609,10 @@ class PEAR_PackageFile_v2
$common->debug = $this->_config->get('verbose');
$this->_scripts = array();
foreach ($taskfiles as $name => $tasks) {
if (!isset($filelist[$name])) {
// file was not installed due to installconditions
continue;
}
$atts = $filelist[$name];
foreach ($tasks as $tag => $raw) {
$taskname = $this->getTask($tag);
@@ -658,12 +673,17 @@ class PEAR_PackageFile_v2
if (isset($this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'])) {
if (isset($this->_packageInfo['contents']['dir']['file'][0])) {
foreach ($this->_packageInfo['contents']['dir']['file'] as $i => $file) {
if (isset($file['attribs']['baseinstalldir'])) {
continue;
}
$this->_packageInfo['contents']['dir']['file'][$i]['attribs']['baseinstalldir']
= $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'];
}
} else {
$this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir']
= $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'];
if (!isset($this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir'])) {
$this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir']
= $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'];
}
}
}
}
@@ -705,7 +725,7 @@ class PEAR_PackageFile_v2
foreach ($dir['file'] as $file) {
$attrs = $file['attribs'];
$name = $attrs['name'];
if ($baseinstall) {
if ($baseinstall && !isset($attrs['baseinstalldir'])) {
$attrs['baseinstalldir'] = $baseinstall;
}
$attrs['name'] = empty($path) ? $name : $path . '/' . $name;
@@ -725,7 +745,7 @@ class PEAR_PackageFile_v2
function setLogger(&$logger)
{
if ($logger && (!is_object($logger) || !method_exists($logger, 'log'))) {
if (!is_object($logger) || !method_exists($logger, 'log')) {
return PEAR::raiseError('Logger must be compatible with PEAR_Common::log');
}
$this->_logger = &$logger;
@@ -739,6 +759,14 @@ class PEAR_PackageFile_v2
$this->_packageInfo['dependencies'] = $deps;
}
/**
* WARNING - do not use this function directly unless you know what you're doing
*/
function setCompatible($compat)
{
$this->_packageInfo['compatible'] = $compat;
}
function setPackagefile($file, $archive = false)
{
$this->_packageFile = $file;
@@ -909,7 +937,7 @@ class PEAR_PackageFile_v2
function getMaintainers($raw = false)
{
if (!$this->_isValid && !$this->validate()) {
if (!isset($this->_packageInfo['lead'])) {
return false;
}
if ($raw) {
@@ -1013,8 +1041,8 @@ class PEAR_PackageFile_v2
array('time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'extbinrelease', 'bundle', 'changelog'), array(), 'date');
'phprelease', 'extsrcrelease', 'extbinrelease', 'zendextsrcrelease',
'zendextbinrelease', 'bundle', 'changelog'), array(), 'date');
}
$this->_packageInfo['date'] = $date;
$this->_isValid = 0;
@@ -1029,8 +1057,8 @@ class PEAR_PackageFile_v2
array('version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'extbinrelease', 'bundle', 'changelog'), $time, 'time');
'phprelease', 'extsrcrelease', 'extbinrelease', 'zendextsrcrelease',
'zendextbinrelease', 'bundle', 'changelog'), $time, 'time');
}
$this->_packageInfo['time'] = $time;
}
@@ -1144,6 +1172,9 @@ class PEAR_PackageFile_v2
$this->flattenFilelist();
if ($contents = $this->getContents()) {
$ret = array();
if (!isset($contents['dir'])) {
return false;
}
if (!isset($contents['dir']['file'][0])) {
$contents['dir']['file'] = array($contents['dir']['file']);
}
@@ -1169,12 +1200,12 @@ class PEAR_PackageFile_v2
*/
function getConfigureOptions()
{
if ($this->getPackageType() != 'extsrc') {
if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
return false;
}
$releases = $this->getReleases();
if (isset($releases[0])) {
$releases = $release[0];
$releases = $releases[0];
}
if (isset($releases['configureoption'])) {
if (!isset($releases['configureoption'][0])) {
@@ -1378,6 +1409,9 @@ class PEAR_PackageFile_v2
function setDirtree($path)
{
if (!isset($this->_packageInfo['dirtree'])) {
$this->_packageInfo['dirtree'] = array();
}
$this->_packageInfo['dirtree'][$path] = true;
}
@@ -1535,7 +1569,7 @@ class PEAR_PackageFile_v2
if (strtolower($dep['name']) == strtolower($package) &&
$depchannel == $channel) {
return true;
}
}
}
}
}
@@ -1553,7 +1587,7 @@ class PEAR_PackageFile_v2
if (strtolower($dep['name']) == strtolower($package) &&
$depchannel == $channel) {
return true;
}
}
}
}
}
@@ -1613,7 +1647,8 @@ class PEAR_PackageFile_v2
);
foreach (array('required', 'optional') as $type) {
$optional = ($type == 'optional') ? 'yes' : 'no';
if (!isset($this->_packageInfo['dependencies'][$type])) {
if (!isset($this->_packageInfo['dependencies'][$type])
|| empty($this->_packageInfo['dependencies'][$type])) {
continue;
}
foreach ($this->_packageInfo['dependencies'][$type] as $dtype => $deps) {
@@ -1648,6 +1683,7 @@ class PEAR_PackageFile_v2
if (!isset($dep['min']) &&
!isset($dep['max'])) {
$s['rel'] = 'has';
$s['optional'] = $optional;
} elseif (isset($dep['min']) &&
isset($dep['max'])) {
$s['rel'] = 'ge';
@@ -1666,14 +1702,24 @@ class PEAR_PackageFile_v2
$s1['optional'] = $optional;
$ret[] = $s1;
} elseif (isset($dep['min'])) {
$s['rel'] = 'ge';
if (isset($dep['exclude']) &&
$dep['exclude'] == $dep['min']) {
$s['rel'] = 'gt';
} else {
$s['rel'] = 'ge';
}
$s['version'] = $dep['min'];
$s['optional'] = $optional;
if ($dtype != 'php') {
$s['name'] = $dep['name'];
}
} elseif (isset($dep['max'])) {
$s['rel'] = 'le';
if (isset($dep['exclude']) &&
$dep['exclude'] == $dep['max']) {
$s['rel'] = 'lt';
} else {
$s['rel'] = 'le';
}
$s['version'] = $dep['max'];
$s['optional'] = $optional;
if ($dtype != 'php') {
@@ -1693,7 +1739,7 @@ class PEAR_PackageFile_v2
}
/**
* @return php|extsrc|extbin|bundle|false
* @return php|extsrc|extbin|zendextsrc|zendextbin|bundle|false
*/
function getPackageType()
{
@@ -1706,6 +1752,12 @@ class PEAR_PackageFile_v2
if (isset($this->_packageInfo['extbinrelease'])) {
return 'extbin';
}
if (isset($this->_packageInfo['zendextsrcrelease'])) {
return 'zendextsrc';
}
if (isset($this->_packageInfo['zendextbinrelease'])) {
return 'zendextbin';
}
if (isset($this->_packageInfo['bundle'])) {
return 'bundle';
}
@@ -1745,6 +1797,12 @@ class PEAR_PackageFile_v2
function getPackagexmlVersion()
{
if (isset($this->_packageInfo['zendextsrcrelease'])) {
return '2.1';
}
if (isset($this->_packageInfo['zendextbinrelease'])) {
return '2.1';
}
return '2.0';
}
@@ -1753,7 +1811,8 @@ class PEAR_PackageFile_v2
*/
function getSourcePackage()
{
if (isset($this->_packageInfo['extbinrelease'])) {
if (isset($this->_packageInfo['extbinrelease']) ||
isset($this->_packageInfo['zendextbinrelease'])) {
return array('channel' => $this->_packageInfo['srcchannel'],
'package' => $this->_packageInfo['srcpackage']);
}
@@ -1837,7 +1896,8 @@ class PEAR_PackageFile_v2
function analyzeSourceCode($file, $string = false)
{
if (!isset($this->_v2Validator)) {
if (!isset($this->_v2Validator) ||
!is_a($this->_v2Validator, 'PEAR_PackageFile_v2_Validator')) {
if (!class_exists('PEAR_PackageFile_v2_Validator')) {
require_once 'PEAR/PackageFile/v2/Validator.php';
}
@@ -1851,7 +1911,8 @@ class PEAR_PackageFile_v2
if (!isset($this->_packageInfo) || !is_array($this->_packageInfo)) {
return false;
}
if (!isset($this->_v2Validator)) {
if (!isset($this->_v2Validator) ||
!is_a($this->_v2Validator, 'PEAR_PackageFile_v2_Validator')) {
if (!class_exists('PEAR_PackageFile_v2_Validator')) {
require_once 'PEAR/PackageFile/v2/Validator.php';
}
@@ -1893,16 +1954,16 @@ class PEAR_PackageFile_v2
$this->getTasksNs();
// transform all '-' to '/' and 'tasks:' to '' so tasks:replace becomes replace
$task = str_replace(array($this->_tasksNs . ':', '-'), array('', ' '), $task);
$task = str_replace(' ', '/', ucwords($task));
$ps = (strtolower(substr(PHP_OS, 0, 3)) == 'win') ? ';' : ':';
foreach (explode($ps, ini_get('include_path')) as $path) {
if (file_exists($path . "/PEAR/Task/$task.php")) {
include_once "PEAR/Task/$task.php";
$task = str_replace('/', '_', $task);
if (class_exists("PEAR_Task_$task")) {
return "PEAR_Task_$task";
}
}
$taskfile = str_replace(' ', '/', ucwords($task));
$task = str_replace(array(' ', '/'), '_', ucwords($task));
if (class_exists("PEAR_Task_$task")) {
return "PEAR_Task_$task";
}
$fp = @fopen("PEAR/Task/$taskfile.php", 'r', true);
if ($fp) {
fclose($fp);
require_once "PEAR/Task/$taskfile.php";
return "PEAR_Task_$task";
}
return false;
}

View File

@@ -1,27 +1,35 @@
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Greg Beaver <cellog@php.net> |
// | |
// +----------------------------------------------------------------------+
//
// $Id: Validator.php,v 1.82 2005/10/27 05:07:24 cellog Exp $
/**
* PEAR_PackageFile_v2, package.xml version 2.0, read/write version
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: Validator.php,v 1.106 2008/03/28 22:23:41 dufuz Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a8
*/
/**
* Private validation class used by PEAR_PackageFile_v2 - do not use directly, its
* sole purpose is to split up the PEAR/PackageFile/v2.php file to make it smaller
* @author Greg Beaver <cellog@php.net>
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.7.2
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a8
* @access private
*/
class PEAR_PackageFile_v2_Validator
@@ -42,6 +50,10 @@ class PEAR_PackageFile_v2_Validator
* @var int
*/
var $_isValid = 0;
/**
* @var int
*/
var $_filesValid = 0;
/**
* @var int
*/
@@ -66,7 +78,9 @@ class PEAR_PackageFile_v2_Validator
return false;
}
if (!isset($this->_packageInfo['attribs']['version']) ||
$this->_packageInfo['attribs']['version'] != '2.0') {
($this->_packageInfo['attribs']['version'] != '2.0' &&
$this->_packageInfo['attribs']['version'] != '2.1')
) {
$this->_noPackageVersion();
}
$structure =
@@ -95,10 +109,21 @@ class PEAR_PackageFile_v2_Validator
// needs a certain package installed in order to implement a role or task
'*providesextension',
'*srcpackage|*srcuri',
'+phprelease|+extsrcrelease|+extbinrelease|bundle', //special validation needed
'+phprelease|+extsrcrelease|+extbinrelease|' .
'+zendextsrcrelease|+zendextbinrelease|bundle', //special validation needed
'*changelog',
);
$test = $this->_packageInfo;
if (isset($test['dependencies']) &&
isset($test['dependencies']['required']) &&
isset($test['dependencies']['required']['pearinstaller']) &&
isset($test['dependencies']['required']['pearinstaller']['min']) &&
version_compare('1.7.2',
$test['dependencies']['required']['pearinstaller']['min'], '<')
) {
$this->_pearVersionTooLow($test['dependencies']['required']['pearinstaller']['min']);
return false;
}
// ignore post-installation array fields
if (array_key_exists('filelist', $test)) {
unset($test['filelist']);
@@ -115,18 +140,13 @@ class PEAR_PackageFile_v2_Validator
if (array_key_exists('_lastversion', $test)) {
unset($test['_lastversion']);
}
if (!$this->_stupidSchemaValidate($structure,
$test, '<package>')) {
if (!$this->_stupidSchemaValidate($structure, $test, '<package>')) {
return false;
}
if (empty($this->_packageInfo['name'])) {
$this->_tagCannotBeEmpty('name');
}
if (isset($this->_packageInfo['uri'])) {
$test = 'uri';
} else {
$test = 'channel';
}
$test = isset($this->_packageInfo['uri']) ? 'uri' :'channel';
if (empty($this->_packageInfo[$test])) {
$this->_tagCannotBeEmpty($test);
}
@@ -159,6 +179,9 @@ class PEAR_PackageFile_v2_Validator
$this->_validateCompatible();
}
if (!isset($this->_packageInfo['bundle'])) {
if (empty($this->_packageInfo['contents'])) {
$this->_tagCannotBeEmpty('contents');
}
if (!isset($this->_packageInfo['contents']['dir'])) {
$this->_filelistMustContainDir('contents');
return false;
@@ -218,11 +241,16 @@ class PEAR_PackageFile_v2_Validator
if ($fail) {
return false;
}
$list = $this->_packageInfo['contents'];
if (isset($list['dir']) && is_array($list['dir']) && isset($list['dir'][0])) {
$this->_multipleToplevelDirNotAllowed();
return $this->_isValid = 0;
}
$this->_validateFilelist();
$this->_validateRelease();
if (!$this->_stack->hasErrors()) {
$chan = $this->_pf->_registry->getChannel($this->_pf->getChannel(), true);
if (!$chan) {
if (PEAR::isError($chan)) {
$this->_unknownChannel($this->_pf->getChannel());
} else {
$valpack = $chan->getValidationPackage();
@@ -417,6 +445,7 @@ class PEAR_PackageFile_v2_Validator
{
$ret = array();
if (count($pieces = explode('|', $key)) > 1) {
$ret['choices'] = array();
foreach ($pieces as $piece) {
$ret['choices'][] = $this->_processStructure($piece);
}
@@ -442,21 +471,21 @@ class PEAR_PackageFile_v2_Validator
$a = $this->_stupidSchemaValidate($structure, $this->_packageInfo['version'], '<version>');
$a &= $this->_stupidSchemaValidate($structure, $this->_packageInfo['stability'], '<stability>');
if ($a) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$this->_packageInfo['version']['release'])) {
$this->_invalidVersion('release', $this->_packageInfo['version']['release']);
}
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$this->_packageInfo['version']['api'])) {
$this->_invalidVersion('api', $this->_packageInfo['version']['api']);
}
if (!in_array($this->_packageInfo['stability']['release'],
array('snapshot', 'devel', 'alpha', 'beta', 'stable'))) {
$this->_invalidState('release', $this->_packageinfo['stability']['release']);
$this->_invalidState('release', $this->_packageInfo['stability']['release']);
}
if (!in_array($this->_packageInfo['stability']['api'],
array('devel', 'alpha', 'beta', 'stable'))) {
$this->_invalidState('api', $this->_packageinfo['stability']['api']);
$this->_invalidState('api', $this->_packageInfo['stability']['api']);
}
}
}
@@ -495,17 +524,29 @@ class PEAR_PackageFile_v2_Validator
$type = $installcondition ? '<installcondition><php>' : '<dependencies><required><php>';
$this->_stupidSchemaValidate($structure, $dep, $type);
if (isset($dep['min'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/',
$dep['min'])) {
$this->_invalidVersion($type . '<min>', $dep['min']);
}
}
if (isset($dep['max'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/',
$dep['max'])) {
$this->_invalidVersion($type . '<max>', $dep['max']);
}
}
if (isset($dep['exclude'])) {
if (!is_array($dep['exclude'])) {
$dep['exclude'] = array($dep['exclude']);
}
foreach ($dep['exclude'] as $exclude) {
if (!preg_match(
'/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/',
$exclude)) {
$this->_invalidVersion($type . '<exclude>', $exclude);
}
}
}
}
function _validatePearinstallerDep($dep)
@@ -518,21 +559,21 @@ class PEAR_PackageFile_v2_Validator
);
$this->_stupidSchemaValidate($structure, $dep, '<dependencies><required><pearinstaller>');
if (isset($dep['min'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['min'])) {
$this->_invalidVersion('<dependencies><required><pearinstaller><min>',
$dep['min']);
}
}
if (isset($dep['max'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['max'])) {
$this->_invalidVersion('<dependencies><required><pearinstaller><max>',
$dep['max']);
}
}
if (isset($dep['recommended'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['recommended'])) {
$this->_invalidVersion('<dependencies><required><pearinstaller><recommended>',
$dep['recommended']);
@@ -543,7 +584,7 @@ class PEAR_PackageFile_v2_Validator
$dep['exclude'] = array($dep['exclude']);
}
foreach ($dep['exclude'] as $exclude) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$exclude)) {
$this->_invalidVersion('<dependencies><required><pearinstaller><exclude>',
$exclude);
@@ -605,19 +646,19 @@ class PEAR_PackageFile_v2_Validator
$this->_DepchannelCannotBeUri('<dependencies>' . $group . $type);
}
if (isset($dep['min'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['min'])) {
$this->_invalidVersion('<dependencies>' . $group . $type . '<min>', $dep['min']);
}
}
if (isset($dep['max'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['max'])) {
$this->_invalidVersion('<dependencies>' . $group . $type . '<max>', $dep['max']);
}
}
if (isset($dep['recommended'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['recommended'])) {
$this->_invalidVersion('<dependencies>' . $group . $type . '<recommended>',
$dep['recommended']);
@@ -628,7 +669,7 @@ class PEAR_PackageFile_v2_Validator
$dep['exclude'] = array($dep['exclude']);
}
foreach ($dep['exclude'] as $exclude) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$exclude)) {
$this->_invalidVersion('<dependencies>' . $group . $type . '<exclude>',
$exclude);
@@ -641,10 +682,10 @@ class PEAR_PackageFile_v2_Validator
{
$this->_validatePackageDep($dep, $group, '<subpackage>');
if (isset($dep['providesextension'])) {
$this->_subpackageCannotProvideExtension(@$dep['name']);
$this->_subpackageCannotProvideExtension(isset($dep['name']) ? $dep['name'] : '');
}
if (isset($dep['conflicts'])) {
$this->_subpackagesCannotConflict(@$dep['name']);
$this->_subpackagesCannotConflict(isset($dep['name']) ? $dep['name'] : '');
}
}
@@ -677,19 +718,19 @@ class PEAR_PackageFile_v2_Validator
}
$this->_stupidSchemaValidate($structure, $dep, $type);
if (isset($dep['min'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['min'])) {
$this->_invalidVersion(substr($type, 1) . '<min', $dep['min']);
}
}
if (isset($dep['max'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['max'])) {
$this->_invalidVersion(substr($type, 1) . '<max', $dep['max']);
}
}
if (isset($dep['recommended'])) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$dep['recommended'])) {
$this->_invalidVersion(substr($type, 1) . '<recommended', $dep['recommended']);
}
@@ -699,7 +740,7 @@ class PEAR_PackageFile_v2_Validator
$dep['exclude'] = array($dep['exclude']);
}
foreach ($dep['exclude'] as $exclude) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$exclude)) {
$this->_invalidVersion(substr($type, 1) . '<exclude', $exclude);
}
@@ -896,13 +937,13 @@ class PEAR_PackageFile_v2_Validator
}
$this->_stupidSchemaValidate($required, $package, $type);
if (is_array($package) && array_key_exists('min', $package)) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$package['min'])) {
$this->_invalidVersion(substr($type, 1) . '<min', $package['min']);
}
}
if (is_array($package) && array_key_exists('max', $package)) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$package['max'])) {
$this->_invalidVersion(substr($type, 1) . '<max', $package['max']);
}
@@ -912,7 +953,7 @@ class PEAR_PackageFile_v2_Validator
$package['exclude'] = array($package['exclude']);
}
foreach ($package['exclude'] as $exclude) {
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
$exclude)) {
$this->_invalidVersion(substr($type, 1) . '<exclude', $exclude);
}
@@ -971,9 +1012,15 @@ class PEAR_PackageFile_v2_Validator
$dirname = $iscontents ? '<contents>' : $unknown;
} else {
$dirname = '<dir name="' . $list['attribs']['name'] . '">';
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
str_replace('\\', '/', $list['attribs']['name']))) {
// file contains .. parent directory or . cur directory
$this->_invalidDirName($list['attribs']['name']);
}
}
$res = $this->_stupidSchemaValidate($struc, $list, $dirname);
if ($allowignore && $res) {
$ignored_or_installed = array();
$this->_pf->getFilelist();
$fcontents = $this->_pf->getContents();
$filelist = array();
@@ -990,6 +1037,20 @@ class PEAR_PackageFile_v2_Validator
foreach ($list['install'] as $file) {
if (!isset($filelist[$file['attribs']['name']])) {
$this->_notInContents($file['attribs']['name'], 'install');
continue;
}
if (array_key_exists($file['attribs']['name'], $ignored_or_installed)) {
$this->_multipleInstallAs($file['attribs']['name']);
}
if (!isset($ignored_or_installed[$file['attribs']['name']])) {
$ignored_or_installed[$file['attribs']['name']] = array();
}
$ignored_or_installed[$file['attribs']['name']][] = 1;
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
str_replace('\\', '/', $file['attribs']['as']))) {
// file contains .. parent directory or . cur directory references
$this->_invalidFileInstallAs($file['attribs']['name'],
$file['attribs']['as']);
}
}
}
@@ -1000,22 +1061,36 @@ class PEAR_PackageFile_v2_Validator
foreach ($list['ignore'] as $file) {
if (!isset($filelist[$file['attribs']['name']])) {
$this->_notInContents($file['attribs']['name'], 'ignore');
continue;
}
if (array_key_exists($file['attribs']['name'], $ignored_or_installed)) {
$this->_ignoreAndInstallAs($file['attribs']['name']);
}
}
}
}
if (!$allowignore && isset($list['file'])) {
if (is_string($list['file'])) {
$this->_oldStyleFileNotAllowed();
return false;
}
if (!isset($list['file'][0])) {
// single file
$list['file'] = array($list['file']);
}
foreach ($list['file'] as $i => $file)
{
if (isset($file['attribs']) && isset($file['attribs']['name']) &&
$file['attribs']['name']{0} == '.' &&
$file['attribs']['name']{1} == '/') {
// name is something like "./doc/whatever.txt"
$this->_invalidFileName($file['attribs']['name']);
if (isset($file['attribs']) && isset($file['attribs']['name'])) {
if ($file['attribs']['name']{0} == '.' &&
$file['attribs']['name']{1} == '/') {
// name is something like "./doc/whatever.txt"
$this->_invalidFileName($file['attribs']['name'], $dirname);
}
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
str_replace('\\', '/', $file['attribs']['name']))) {
// file contains .. parent directory or . cur directory
$this->_invalidFileName($file['attribs']['name'], $dirname);
}
}
if (isset($file['attribs']) && isset($file['attribs']['role'])) {
if (!$this->_validateRole($file['attribs']['role'])) {
@@ -1064,7 +1139,8 @@ class PEAR_PackageFile_v2_Validator
$ret = call_user_func(array($tagClass, 'validateXml'),
$this->_pf, $v, $this->_pf->_config, $save);
if (is_array($ret)) {
$this->_invalidTask($task, $ret, @$save['name']);
$this->_invalidTask($task, $ret, isset($save['name']) ?
$save['name'] : '');
}
}
} else {
@@ -1164,64 +1240,68 @@ class PEAR_PackageFile_v2_Validator
), $rel, '<phprelease>');
}
}
if (isset($this->_packageInfo['extsrcrelease'])) {
$release = 'extsrcrelease';
if (!isset($this->_packageInfo['providesextension'])) {
$this->_mustProvideExtension($release);
}
if (isset($this->_packageInfo['srcpackage']) || isset($this->_packageInfo['srcuri'])) {
$this->_cannotHaveSrcpackage($release);
}
$releases = $this->_packageInfo['extsrcrelease'];
if (!is_array($releases)) {
return true;
}
if (!isset($releases[0])) {
$releases = array($releases);
}
foreach ($releases as $rel) {
$this->_stupidSchemaValidate(array(
'*installconditions',
'*configureoption->name->prompt->?default',
'*binarypackage',
'*filelist',
), $rel, '<extsrcrelease>');
if (isset($rel['binarypackage'])) {
if (!is_array($rel['binarypackage']) || !isset($rel['binarypackage'][0])) {
$rel['binarypackage'] = array($rel['binarypackage']);
}
foreach ($rel['binarypackage'] as $bin) {
if (!is_string($bin)) {
$this->_binaryPackageMustBePackagename();
foreach (array('', 'zend') as $prefix) {
$releasetype = $prefix . 'extsrcrelease';
if (isset($this->_packageInfo[$releasetype])) {
$release = $releasetype;
if (!isset($this->_packageInfo['providesextension'])) {
$this->_mustProvideExtension($release);
}
if (isset($this->_packageInfo['srcpackage']) || isset($this->_packageInfo['srcuri'])) {
$this->_cannotHaveSrcpackage($release);
}
$releases = $this->_packageInfo[$releasetype];
if (!is_array($releases)) {
return true;
}
if (!isset($releases[0])) {
$releases = array($releases);
}
foreach ($releases as $rel) {
$this->_stupidSchemaValidate(array(
'*installconditions',
'*configureoption->name->prompt->?default',
'*binarypackage',
'*filelist',
), $rel, '<' . $releasetype . '>');
if (isset($rel['binarypackage'])) {
if (!is_array($rel['binarypackage']) || !isset($rel['binarypackage'][0])) {
$rel['binarypackage'] = array($rel['binarypackage']);
}
foreach ($rel['binarypackage'] as $bin) {
if (!is_string($bin)) {
$this->_binaryPackageMustBePackagename();
}
}
}
}
}
}
if (isset($this->_packageInfo['extbinrelease'])) {
$release = 'extbinrelease';
if (!isset($this->_packageInfo['providesextension'])) {
$this->_mustProvideExtension($release);
}
if (isset($this->_packageInfo['channel']) &&
!isset($this->_packageInfo['srcpackage'])) {
$this->_mustSrcPackage($release);
}
if (isset($this->_packageInfo['uri']) && !isset($this->_packageInfo['srcuri'])) {
$this->_mustSrcuri($release);
}
$releases = $this->_packageInfo['extbinrelease'];
if (!is_array($releases)) {
return true;
}
if (!isset($releases[0])) {
$releases = array($releases);
}
foreach ($releases as $rel) {
$this->_stupidSchemaValidate(array(
'*installconditions',
'*filelist',
), $rel, '<extbinrelease>');
$releasetype = 'extbinrelease';
if (isset($this->_packageInfo[$releasetype])) {
$release = $releasetype;
if (!isset($this->_packageInfo['providesextension'])) {
$this->_mustProvideExtension($release);
}
if (isset($this->_packageInfo['channel']) &&
!isset($this->_packageInfo['srcpackage'])) {
$this->_mustSrcPackage($release);
}
if (isset($this->_packageInfo['uri']) && !isset($this->_packageInfo['srcuri'])) {
$this->_mustSrcuri($release);
}
$releases = $this->_packageInfo[$releasetype];
if (!is_array($releases)) {
return true;
}
if (!isset($releases[0])) {
$releases = array($releases);
}
foreach ($releases as $rel) {
$this->_stupidSchemaValidate(array(
'*installconditions',
'*filelist',
), $rel, '<' . $releasetype . '>');
}
}
}
if (isset($this->_packageInfo['bundle'])) {
@@ -1250,7 +1330,7 @@ class PEAR_PackageFile_v2_Validator
}
if (is_array($rel) && array_key_exists('filelist', $rel)) {
if ($rel['filelist']) {
$this->_validateFilelist($rel['filelist'], true);
}
}
@@ -1266,6 +1346,14 @@ class PEAR_PackageFile_v2_Validator
return in_array($role, PEAR_Installer_Role::getValidRoles($this->_pf->getPackageType()));
}
function _pearVersionTooLow($version)
{
$this->_stack->push(__FUNCTION__, 'error',
array('version' => $version),
'This package.xml requires PEAR version %version% to parse properly, we are ' .
'version 1.7.2');
}
function _invalidTagOrder($oktags, $actual, $root)
{
$this->_stack->push(__FUNCTION__, 'error',
@@ -1277,7 +1365,7 @@ class PEAR_PackageFile_v2_Validator
{
$this->_stack->push(__FUNCTION__, 'error', array('type' => $type),
'<%type%> is not allowed inside global <contents>, only inside ' .
'<phprelease>/<extbinrelease>, use <dir> and <file> only');
'<phprelease>/<extbinrelease>/<zendextbinrelease>, use <dir> and <file> only');
}
function _fileNotAllowed($type)
@@ -1287,6 +1375,13 @@ class PEAR_PackageFile_v2_Validator
'<contents>, use <ignore> and <install> only');
}
function _oldStyleFileNotAllowed()
{
$this->_stack->push(__FUNCTION__, 'error', array(),
'Old-style <file>name</file> is not allowed. Use' .
'<file name="name" role="role"/>');
}
function _tagMissingAttribute($tag, $attr, $context)
{
$this->_stack->push(__FUNCTION__, 'error', array('tag' => $tag,
@@ -1319,7 +1414,21 @@ class PEAR_PackageFile_v2_Validator
{
$this->_stack->push(__FUNCTION__, 'error', array(
'file' => $file),
'File "%file%" cannot begin with "."');
'File "%file%" in directory "%dir%" cannot begin with "./" or contain ".."');
}
function _invalidFileInstallAs($file, $as)
{
$this->_stack->push(__FUNCTION__, 'error', array(
'file' => $file, 'as' => $as),
'File "%file%" <install as="%as%"/> cannot contain "./" or contain ".."');
}
function _invalidDirName($dir)
{
$this->_stack->push(__FUNCTION__, 'error', array(
'dir' => $file),
'Directory "%dir%" cannot begin with "./" or contain ".."');
}
function _filelistCannotContainFile($filelist)
@@ -1481,7 +1590,7 @@ class PEAR_PackageFile_v2_Validator
function _cannotProvideExtension($release)
{
$this->_stack->push(__FUNCTION__, 'error', array('release' => $release),
'<%release%> packages cannot use <providesextension>, only extbinrelease and extsrcrelease can provide a PHP extension');
'<%release%> packages cannot use <providesextension>, only extbinrelease, extsrcrelease, zendextsrcrelease, and zendextbinrelease can provide a PHP extension');
}
function _mustProvideExtension($release)
@@ -1499,13 +1608,13 @@ class PEAR_PackageFile_v2_Validator
function _mustSrcPackage($release)
{
$this->_stack->push(__FUNCTION__, 'error', array('release' => $release),
'<extbinrelease> packages must specify a source code package with <srcpackage>');
'<extbinrelease>/<zendextbinrelease> packages must specify a source code package with <srcpackage>');
}
function _mustSrcuri($release)
{
$this->_stack->push(__FUNCTION__, 'error', array('release' => $release),
'<extbinrelease> packages must specify a source code package with <srcuri>');
'<extbinrelease>/<zendextbinrelease> packages must specify a source code package with <srcuri>');
}
function _uriDepsCannotHaveVersioning($type)
@@ -1539,7 +1648,7 @@ class PEAR_PackageFile_v2_Validator
{
$this->_stack->push(__FUNCTION__, 'error', array(),
'<binarypackage> tags must contain the name of a package that is ' .
'a compiled version of this extsrc package');
'a compiled version of this extsrc/zendextsrc package');
}
function _fileNotFound($file)
@@ -1563,13 +1672,13 @@ class PEAR_PackageFile_v2_Validator
function _usesroletaskMustHaveChannelOrUri($role, $tag)
{
$this->_stack->push(__FUNCTION__, 'error', array('role' => $role, 'tag' => $tag),
'<%tag%> must contain either <uri>, or <channel> and <package>');
'<%tag%> for role "%role%" must contain either <uri>, or <channel> and <package>');
}
function _usesroletaskMustHavePackage($role, $tag)
{
$this->_stack->push(__FUNCTION__, 'error', array('role' => $role, 'tag' => $tag),
'<%tag%> must contain <package>');
'<%tag%> for role "%role%" must contain <package>');
}
function _usesroletaskMustHaveRoleTask($tag, $type)
@@ -1586,10 +1695,29 @@ class PEAR_PackageFile_v2_Validator
function _invalidDepGroupName($name)
{
$this->_stack->push(__FUNCTION__, 'error', array('group' => $name),
$this->_stack->push(__FUNCTION__, 'error', array('name' => $name),
'Invalid dependency group name "%name%"');
}
function _multipleToplevelDirNotAllowed()
{
$this->_stack->push(__FUNCTION__, 'error', array(),
'Multiple top-level <dir> tags are not allowed. Enclose them ' .
'in a <dir name="/">');
}
function _multipleInstallAs($file)
{
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
'Only one <install> tag is allowed for file "%file%"');
}
function _ignoreAndInstallAs($file)
{
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
'Cannot have both <ignore> and <install> tags for file "%file%"');
}
function _analyzeBundledPackages()
{
if (!$this->_isValid) {
@@ -1602,8 +1730,9 @@ class PEAR_PackageFile_v2_Validator
return false;
}
$dir_prefix = dirname($this->_pf->_packageFile);
$common = new PEAR_Common;
$log = isset($this->_pf->_logger) ? array(&$this->_pf->_logger, 'log') :
array('PEAR_Common', 'log');
array($common, 'log');
$info = $this->_pf->getContents();
$info = $info['bundledpackage'];
if (!is_array($info)) {
@@ -1650,6 +1779,10 @@ class PEAR_PackageFile_v2_Validator
$log = isset($this->_pf->_logger) ? array(&$this->_pf->_logger, 'log') :
array(&$common, 'log');
$info = $this->_pf->getContents();
if (!$info || !isset($info['dir']['file'])) {
$this->_tagCannotBeEmpty('contents><dir');
return false;
}
$info = $info['dir']['file'];
if (isset($info['attribs'])) {
$info = array($info);
@@ -1709,6 +1842,8 @@ class PEAR_PackageFile_v2_Validator
function analyzeSourceCode($file, $string = false)
{
if (!function_exists("token_get_all")) {
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
'Parser error: token_get_all() function must exist to analyze source code, PHP may have been compiled with --disable-tokenizer');
return false;
}
if (!defined('T_DOC_COMMENT')) {
@@ -1726,15 +1861,20 @@ class PEAR_PackageFile_v2_Validator
if (!$fp = @fopen($file, "r")) {
return false;
}
if (function_exists('file_get_contents')) {
fclose($fp);
$contents = file_get_contents($file);
} else {
$contents = @fread($fp, filesize($file));
fclose($fp);
}
fclose($fp);
$contents = file_get_contents($file);
}
// Silence this function so we can catch PHP Warnings and show our own custom message
$tokens = @token_get_all($contents);
if (isset($php_errormsg)) {
$pn = $this->_pf->getPackage();
$this->_stack->push(__FUNCTION__, 'warning',
array('file' => $file, 'package' => $pn),
'in %file%: Could not process file for unkown reasons,' .
' possibly a PHP parse error in %file% from %package%');
}
$tokens = token_get_all($contents);
/*
for ($i = 0; $i < sizeof($tokens); $i++) {
@list($token, $data) = $tokens[$i];
@@ -1831,7 +1971,7 @@ class PEAR_PackageFile_v2_Validator
if (version_compare(zend_version(), '2.0', '<')) {
if (in_array(strtolower($data),
array('public', 'private', 'protected', 'abstract',
'interface', 'implements', 'throw')
'interface', 'implements', 'throw')
)) {
$this->_stack->push(__FUNCTION__, 'warning', array(
'file' => $file),

View File

@@ -13,9 +13,9 @@
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: rw.php,v 1.12 2005/09/27 03:34:02 cellog Exp $
* @version CVS: $Id: rw.php,v 1.22 2008/01/18 22:47:49 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a8
*/
@@ -27,9 +27,9 @@ require_once 'PEAR/PackageFile/v2.php';
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.4.5
* @version Release: 1.7.2
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a8
*/
@@ -41,12 +41,14 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
*/
function setProvidesExtension($extension)
{
if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) {
if (in_array($this->getPackageType(),
array('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
if (!isset($this->_packageInfo['providesextension'])) {
// ensure that the channel tag is set up in the right location
$this->_packageInfo = $this->_insertBefore($this->_packageInfo,
array('usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
'extsrcrelease', 'extbinrelease', 'bundle', 'changelog'),
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'),
$extension, 'providesextension');
}
$this->_packageInfo['providesextension'] = $extension;
@@ -77,6 +79,29 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo['name'] = $package;
}
/**
* set this as a package.xml version 2.1
* @access private
*/
function _setPackageVersion2_1()
{
$info = array(
'version' => '2.1',
'xmlns' => 'http://pear.php.net/dtd/package-2.1',
'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.1
http://pear.php.net/dtd/package-2.1.xsd',
);
if (!isset($this->_packageInfo['attribs'])) {
$this->_packageInfo = array_merge(array('attribs' => $info), $this->_packageInfo);
} else {
$this->_packageInfo['attribs'] = $info;
}
}
function setUri($uri)
{
unset($this->_packageInfo['channel']);
@@ -88,7 +113,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $uri, 'uri');
}
$this->_packageInfo['uri'] = $uri;
@@ -105,7 +130,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $channel, 'channel');
}
$this->_packageInfo['channel'] = $channel;
@@ -121,7 +146,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $extends, 'extends');
}
$this->_packageInfo['extends'] = $extends;
@@ -137,7 +162,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $summary, 'summary');
}
$this->_packageInfo['summary'] = $summary;
@@ -153,7 +178,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
'developer', 'contributor', 'helper', 'date', 'time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $desc, 'description');
}
$this->_packageInfo['description'] = $desc;
@@ -185,7 +210,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
'extbinrelease', 'bundle', 'changelog');
'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog');
foreach (array('lead', 'developer', 'contributor', 'helper') as $testrole) {
array_shift($testarr);
if ($role == $testrole) {
@@ -240,7 +265,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo[$role] = array_values($this->_packageInfo[$role]);
}
}
$this->addMaintainer($newrole, $handle, $name, $email);
$this->addMaintainer($newrole, $handle, $name, $email, $active);
$this->_isValid = 0;
}
@@ -292,7 +317,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(
'version' => array('stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
'release' => array('api')));
$this->_isValid = 0;
@@ -307,7 +332,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(
'version' => array('stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
'api' => array()));
$this->_isValid = 0;
@@ -325,7 +350,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(
'stability' => array('license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
'release' => array('api')));
$this->_isValid = 0;
@@ -343,7 +368,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(
'stability' => array('license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'),
'api' => array()));
$this->_isValid = 0;
@@ -356,7 +381,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_insertBefore($this->_packageInfo,
array('notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), 0, 'license');
}
if ($uri || $filesource) {
@@ -382,7 +407,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_insertBefore($this->_packageInfo,
array('contents', 'compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'phprelease', 'extsrcrelease', 'zendextsrcrelease', 'zendextbinrelease',
'extbinrelease', 'bundle', 'changelog'), $notes, 'notes');
}
$this->_packageInfo['notes'] = $notes;
@@ -429,7 +454,8 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array('compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
'extbinrelease', 'bundle', 'changelog'), array(), 'contents');
'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'), array(), 'contents');
}
if ($this->getPackageType() != 'bundle') {
$this->_packageInfo['contents'] =
@@ -437,6 +463,8 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
if ($baseinstall) {
$this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'] = $baseinstall;
}
} else {
$this->_packageInfo['contents'] = array('bundledpackage' => array());
}
}
@@ -453,7 +481,8 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $path, array(
'contents' => array('compatible', 'dependencies', 'providesextension',
'usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',
'extsrcrelease', 'extbinrelease', 'bundle', 'changelog'),
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'),
'bundledpackage' => array()));
}
@@ -546,7 +575,8 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_insertBefore($this->_packageInfo,
array('compatible', 'dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
'extbinrelease', 'bundle', 'changelog'), array(), 'contents');
'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'), array(), 'contents');
}
if (isset($this->_packageInfo['contents']['dir']['file'])) {
if (!isset($this->_packageInfo['contents']['dir']['file'][0])) {
@@ -584,7 +614,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
'compatible' => array('dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog')
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
));
}
@@ -614,7 +644,8 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_isValid = 0;
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
'usesrole' => array('usestask', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'extbinrelease', 'bundle', 'changelog')
'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
));
}
@@ -645,7 +676,8 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$this->_isValid = 0;
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $set, array(
'usestask' => array('srcpackage', 'srcuri',
'phprelease', 'extsrcrelease', 'extbinrelease', 'bundle', 'changelog')
'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')
));
}
@@ -667,7 +699,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog')));
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')));
}
$this->_packageInfo['dependencies'] = array();
}
@@ -703,7 +735,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array('optional', 'group'),
'php' => array('pearinstaller', 'package', 'subpackage', 'extension', 'os', 'arch')
));
@@ -745,7 +777,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array('optional', 'group'),
'pearinstaller' => array('package', 'subpackage', 'extension', 'os', 'arch')
));
@@ -756,24 +788,21 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
* @param string package name
* @param string package channel
* @param string extension this package provides, if any
* @param string|false minimum version required
* @param string|false maximum version allowed
* @param array|false versions to exclude from installation
*/
function addConflictingPackageDepWithChannel($name, $channel, $providesextension = false)
function addConflictingPackageDepWithChannel($name, $channel,
$providesextension = false, $min = false, $max = false, $exclude = false)
{
$this->_isValid = 0;
$dep =
array(
'name' => $name,
'channel' => $channel,
'conflicts' => '',
);
if ($providesextension) {
$dep['providesextension'] = $providesextension;
}
$dep = $this->_constructDep($name, $channel, false, $min, $max, false,
$exclude, $providesextension, false, true);
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, $dep,
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array('optional', 'group'),
'package' => array('subpackage', 'extension', 'os', 'arch')
));
@@ -801,7 +830,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array('optional', 'group'),
'package' => array('subpackage', 'extension', 'os', 'arch')
));
@@ -815,7 +844,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'group' => array(),
));
}
@@ -831,11 +860,13 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
* @param string extension this package provides, if any
* @param bool if true, tells the installer to ignore the default optional dependency group
* when installing this package
* @param bool if true, tells the installer to negate this dependency (conflicts)
* @return array
* @access private
*/
function _constructDep($name, $channel, $uri, $min, $max, $recommended, $exclude,
$providesextension = false, $nodefault = false)
$providesextension = false, $nodefault = false,
$conflicts = false)
{
$dep =
array(
@@ -861,6 +892,9 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
}
$dep['exclude'] = $exclude;
}
if ($conflicts) {
$dep['conflicts'] = '';
}
if ($nodefault) {
$dep['nodefault'] = '';
}
@@ -1000,6 +1034,9 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
$recommended = false, $exclude = false,
$providesextension = false, $nodefault = false)
{
if (!in_array($type, array('optional', 'required'), true)) {
$type = 'required';
}
$this->_isValid = 0;
$arr = array('optional', 'group');
if ($type != 'required') {
@@ -1011,7 +1048,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
$type => $arr,
'package' => array('subpackage', 'extension', 'os', 'arch')
));
@@ -1039,7 +1076,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
$type => $arr,
'package' => array('subpackage', 'extension', 'os', 'arch')
));
@@ -1071,7 +1108,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
$type => $arr,
'subpackage' => array('extension', 'os', 'arch')
));
@@ -1096,7 +1133,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
$type => $arr,
'subpackage' => array('extension', 'os', 'arch')
));
@@ -1123,7 +1160,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
$type => $arr,
'extension' => array('os', 'arch')
));
@@ -1144,7 +1181,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array('optional', 'group'),
'os' => array('arch')
));
@@ -1165,7 +1202,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'bundle', 'changelog'),
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog'),
'required' => array('optional', 'group'),
'arch' => array()
));
@@ -1177,20 +1214,27 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
* - a php package is a PEAR-style package
* - an extbin package is a PECL-style extension binary
* - an extsrc package is a PECL-style source for a binary
* - an zendextbin package is a PECL-style zend extension binary
* - an zendextsrc package is a PECL-style source for a zend extension binary
* - a bundle package is a collection of other pre-packaged packages
* @param php|extbin|extsrc|bundle
* @param php|extbin|extsrc|zendextsrc|zendextbin|bundle
* @return bool success
*/
function setPackageType($type)
{
$this->_isValid = 0;
if (!in_array($type, array('php', 'extbin', 'extsrc', 'bundle'))) {
if (!in_array($type, array('php', 'extbin', 'extsrc', 'zendextsrc',
'zendextbin', 'bundle'))) {
return false;
}
if (in_array($type, array('zendextsrc', 'zendextbin'))) {
$this->_setPackageVersion2_1();
}
if ($type != 'bundle') {
$type .= 'release';
}
foreach (array('phprelease', 'extbinrelease', 'extsrcrelease', 'bundle') as $test) {
foreach (array('phprelease', 'extbinrelease', 'extsrcrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle') as $test) {
unset($this->_packageInfo[$test]);
}
if (!isset($this->_packageInfo[$type])) {
@@ -1227,7 +1271,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
{
if ($p = $this->getPackageType()) {
if ($strict) {
if ($p == 'extsrc') {
if ($p == 'extsrc' || $p == 'zendextsrc') {
$a = null;
return $a;
}
@@ -1292,7 +1336,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
*/
function addBinarypackage($package)
{
if ($this->getPackageType() != 'extsrc') {
if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
return false;
}
$r = &$this->_getCurrentRelease(false);
@@ -1314,7 +1358,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
*/
function addConfigureOption($name, $prompt, $default = null)
{
if ($this->getPackageType() != 'extsrc') {
if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
return false;
}
$r = &$this->_getCurrentRelease(false);
@@ -1323,7 +1367,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
}
$opt = array('attribs' => array('name' => $name, 'prompt' => $prompt));
if ($default !== null) {
$opt['default'] = $default;
$opt['attribs']['default'] = $default;
}
$this->_isValid = 0;
$r = $this->_mergeTag($r, $opt,
@@ -1355,7 +1399,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
}
$dep['exclude'] = $exclude;
}
if ($this->getPackageType() == 'extsrc') {
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('configureoption', 'binarypackage',
@@ -1388,7 +1432,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
}
$this->_isValid = 0;
$dep = $this->_constructDep($name, false, false, $min, $max, $recommended, $exclude);
if ($this->getPackageType() == 'extsrc') {
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('configureoption', 'binarypackage',
@@ -1423,7 +1467,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
if ($conflicts) {
$dep['conflicts'] = '';
}
if ($this->getPackageType() == 'extsrc') {
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('configureoption', 'binarypackage',
@@ -1458,7 +1502,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
if ($conflicts) {
$dep['conflicts'] = '';
}
if ($this->getPackageType() == 'extsrc') {
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('configureoption', 'binarypackage',
@@ -1476,20 +1520,22 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
/**
* For extension binary releases, this is used to specify either the
* static URI to a source package, or the package name and channel of the extsrc
* static URI to a source package, or the package name and channel of the extsrc/zendextsrc
* package it is based on.
* @param string Package name, or full URI to source package (extsrc type)
* @param string Package name, or full URI to source package (extsrc/zendextsrc type)
*/
function setSourcePackage($packageOrUri)
{
$this->_isValid = 0;
if (isset($this->_packageInfo['channel'])) {
$this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('phprelease',
'extsrcrelease', 'extbinrelease', 'bundle', 'changelog'),
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'),
$packageOrUri, 'srcpackage');
} else {
$this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('phprelease',
'extsrcrelease', 'extbinrelease', 'bundle', 'changelog'), $packageOrUri, 'srcuri');
'extsrcrelease', 'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'), $packageOrUri, 'srcuri');
}
}
@@ -1508,7 +1554,7 @@ class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2
'stability' =>
$this->getStability(),
'date' => $this->getDate(),
'license' => $this->getLicense(),
'license' => $this->getLicense(true),
'notes' => $notes ? $notes : $this->getNotes()
);
}