CVS commit by dkite:
Bug references added and working.
M +44 -32 enzyme_bugdata.php 1.2
M +13 -10 enzyme_format.php 1.8
--- www/areas/cvs-digest/enzyme/enzyme_bugdata.php #1.1:1.2
@@ -29,19 +29,20 @@
var $cachelocation = "cache/buglist.dat";
var $bugdesc;
+var $bugnum;
function enzyme_bugdata($bugnum) {
- $this->bugdesc = $this->check_cache($bugnum);
+ $this->bugnum = $bugnum;
+ $this->get_bug();
}
-function check_cache ($bugnum) {
+function check_cache () {
if (file_exists($this->cachelocation)) {
- $res = `grep $bugnum $this->cachelocation`;
+ $res = `grep $this->bugnum $this->cachelocation`;
if ($res == "")
return false;
- array_pop($res);
- return $res[0];
+ return $res;
}
return false;
@@ -49,39 +50,50 @@
-function fetch_bug($bugnum) {
- $url = "$this->bugzilla$this->bugzillaquery$bugnum";
- $cs = curl_init($url);
- $str = curl_exec($cs);
- echo $str;
+function fetch_bug() {
+ $url = "$this->bugzilla$this->bugzillaquery$this->bugnum";
+ $bugxml = `wget -O- $url`;
+ $p = xml_parser_create();
+ xml_parse_into_struct($p, $bugxml, $vals, $index);
+ xml_parser_free($p);
+ foreach ($vals as $key=>$arr) {
+ if ($arr["tag"] == "BUG_ID") {
+ $bugid = $arr["value"];
+ continue;
+ }
+ if ($arr["tag"] == "SHORT_DESC") {
+ $this->bugdesc = $arr["value"];
+ break;
+ }
+ }
}
+function save_cache() {
+ if ($fp = fopen("$this->cachelocation","a")) {
+ fwrite($fp,"$this->bugnum $this->bugdesc\n");
+ fclose($fp);
+ }
+}
+function get_bug() {
+ $res = $this->check_cache();
+ if ($res === false) {
+ $this->fetch_bug();
+ $this->save_cache();
+ }
+ else
+ $this->bugdesc = $res;
+}
-
-
-
-/*61467
- RESOLVED
- konqueror
- NOR
- unspecified
- Compiled Sources
- konq-bugs@kde.org
- 20040209155307
- kjs
- kdebugs@ralfhoelzer.com
- ---
- crash
- 2003-07-20 19:19
- Linux
- FIXED
- KJ*/
+function get_bugdesc() {
+ return $this->bugdesc;
+}
+
}
-$i = new enzyme_bugdata("61467");
-$i->fetch_bug("61467");
-
+// $i = new enzyme_bugdata("69760");
+// $i->fetch_bug();
+// echo $i->get_bugdesc()
--- www/areas/cvs-digest/enzyme/enzyme_format.php #1.7:1.8
@@ -24,5 +24,5 @@
include_once("enzyme_cvsindex.php");
-include_once("enzyme_ugdata.php");
+include_once("enzyme_bugdata.php");
@@ -49,15 +49,18 @@
function build_bugref($str) {
- $str = preg_replace_callback("/([\d]{5})/",array($this,bug_callback),$str);
- foreach ($this->buglist as $bug) {
- $b = new enzyme_bugdata($bug);
- $str .= "\nRefer to: $b->get_bugdesc()"
+ $str = preg_replace_callback("/([\d]{5})/",array(&$this,bug_callback),$str);
+ if (is_array($this->buglist)) {
+ $this->buglist = array_unique($this->buglist);
+ $str .= "\n";
+ foreach ($this->buglist as $bug) {
+ $b = new enzyme_bugdata($bug);
+ $bugdesc = $b->get_bugdesc();
+ $bugdesc = wordwrap($bugdesc,$this->width);
+ $str .= "Refer to: $bugdesc";
+ }
}
+ return $str;
}
-function get_bug_header($bugnum) {
-
-
-}
function escape_tags($str) {
@@ -157,5 +160,5 @@
$t = "Source Code";
-return "$c $pl View $t";
+return "\n$c $pl View $t";
}