summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2001-04-22 07:43:34 +0000
committerStig Bakken <ssb@php.net>2001-04-22 07:43:34 +0000
commit4d9660d3b940e2477dcbac033e5fda2b6254fe2f (patch)
tree9861aa954501b9c9b3fa014e2f67ea68104ad71d
parent39796b76138ae33f876ef011a75842082ac84c57 (diff)
downloadphp-git-4d9660d3b940e2477dcbac033e5fda2b6254fe2f.tar.gz
* fixed PEAR_Common::infoFromDescriptionFile
-rw-r--r--pear/PEAR/Common.php37
-rw-r--r--pear/PEAR/Uploader.php11
2 files changed, 35 insertions, 13 deletions
diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php
index 8741da751f..6b3bf3dc5a 100644
--- a/pear/PEAR/Common.php
+++ b/pear/PEAR/Common.php
@@ -20,7 +20,7 @@
require_once "PEAR.php";
-class PEAR_Common
+class PEAR_Common extends PEAR
{
// {{{ properties
@@ -73,6 +73,7 @@ class PEAR_Common
}
// }}}
+ // {{{ _element_start()
function _element_start($xp, $name, $attribs)
{
@@ -81,6 +82,8 @@ class PEAR_Common
$this->current_attributes = $attribs;
}
+ // }}}
+ // {{{ _element_end()
function _element_end($xp, $name)
{
@@ -88,6 +91,8 @@ class PEAR_Common
$this->current_element = $this->element_stack[sizeof($this->element_stack)-1];
}
+ // }}}
+ // {{{ _pkginfo_cdata()
function _pkginfo_cdata($xp, $data)
{
@@ -96,30 +101,30 @@ class PEAR_Common
case "Name":
switch ($next) {
case "Package":
- $this->pkginfo["package"] = trim($data);
+ $this->pkginfo["package"] .= $data;
break;
case "Maintainer":
- $this->pkginfo["maintainer_name"] = trim($data);
+ $this->pkginfo["maintainer_name"] .= $data;
break;
}
break;
case "Summary":
- $this->pkginfo["summary"] = trim($data);
+ $this->pkginfo["summary"] .= $data;
break;
case "Initials":
- $this->pkginfo["maintainer_handle"] = trim($data);
+ $this->pkginfo["maintainer_handle"] .= $data;
break;
case "Email":
- $this->pkginfo["maintainer_email"] = trim($data);
+ $this->pkginfo["maintainer_email"] .= $data;
break;
case "Version":
- $this->pkginfo["version"] = trim($data);
+ $this->pkginfo["version"] .= $data;
break;
case "Date":
- $this->pkginfo["release_date"] = trim($data);
+ $this->pkginfo["release_date"] .= $data;
break;
case "Notes":
- $this->pkginfo["release_notes"] = trim($data);
+ $this->pkginfo["release_notes"] .= $data;
break;
case "Dir":
if (!$this->phpdir) {
@@ -136,11 +141,13 @@ class PEAR_Common
}
}
+ // }}}
+ // {{{ infoFromDescriptionFile()
- function infoFromDescriptionFile($file)
+ function infoFromDescriptionFile($descfile)
{
$fp = fopen($descfile, "r");
- $xp = xml_parser_create();
+ $xp = @xml_parser_create();
if (!$xp) {
return $this->raiseError("Unable to create XML parser.");
}
@@ -157,7 +164,7 @@ class PEAR_Common
// read the whole thing so we only get one cdata callback
// for each block of cdata
$data = fread($fp, filesize($descfile));
- if (!xml_parse($xp, $data, 1)) {
+ if (!@xml_parse($xp, $data, 1)) {
$msg = sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xp)),
xml_get_current_line_number($xp));
@@ -167,8 +174,14 @@ class PEAR_Common
xml_parser_free($xp);
+ foreach ($this->pkginfo as $k => $v) {
+ $this->pkginfo[$k] = trim($v);
+ }
+
return $this->pkginfo;
}
+
+ // }}}
}
?>
diff --git a/pear/PEAR/Uploader.php b/pear/PEAR/Uploader.php
index 575e3edf99..1ed62a8a0d 100644
--- a/pear/PEAR/Uploader.php
+++ b/pear/PEAR/Uploader.php
@@ -44,8 +44,17 @@ class PEAR_Uploader extends PEAR_Common
// }}}
- function Upload($pkgfile, $infofile)
+ function upload($pkgfile, $infofile = null)
{
+ if ($infofile === null) {
+ $info = $this->infoFromTarBall($pkgfile);
+ } else {
+ $info = infoFromDescriptionFile($infofile);
+ }
+ if (PEAR::isError($info)) {
+ return $info;
+ }
+
}
}