|
From: Benjamin C. <bc...@us...> - 2001-09-29 14:50:29
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv10689
Modified Files:
CHANGELOG bug.php config.php
Log Message:
Added the ability to enter cvs:filename.ext or cvs:path/filename.ext:v.vv into the bug comments and have that linked to a CVS web interface.
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/phpbt/phpbt/CHANGELOG,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- CHANGELOG 2001/09/28 13:33:09 1.16
+++ CHANGELOG 2001/09/29 14:50:26 1.17
@@ -1,3 +1,7 @@
+-- 0.4.0 --
+: Added the ability to enter cvs:filename.ext or cvs:path/filename.ext:v.vv
+ into the bug comments and have that linked to a CVS web interface.
+
-- 0.3.2 -- 28 Sep 2001
: Added patch and patch instructions for page.inc (in PHPlib).
: Tried to make the configure script a little more portable.
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- bug.php 2001/09/24 12:57:03 1.46
+++ bug.php 2001/09/29 14:50:26 1.47
@@ -25,6 +25,24 @@
include 'include.php';
///
+/// Beautify the bug comments
+function format_comments($comments) {
+
+ // Set up the regex replacements
+ $patterns = array(
+ '/(bug)[[:space:]]*(#?)([0-9]+)/i', // matches bug #nn
+ '/cvs:([^\.\s:,\?!]+(\.[^\.\s:,\?!]+)*)(:)?(\d\.[\d\.]+)?([\W\s])?/i' // matches cvs:filename.php or cvs:filename.php:n.nn
+ );
+ $replacements = array(
+ "\1 <a href='$me?op=show&bugid=\3'>\2\3<\/a>", // internal link to bug
+ '<a href="'.CVS_WEB.'\1#rev\4" target="_new">\1</a>\5' // external link to cvs web interface
+ );
+
+ return preg_replace($patterns, $replacements,
+ stripslashes($comments));
+}
+
+///
/// Show the activity for a bug
function show_history($bugid) {
global $q, $t, $STRING;
@@ -136,7 +154,7 @@
'newpostedby' => $row['login'],
'newpostedon' => date(TIMEFORMAT, $row['created_date']).' on '.
date(DATEFORMAT, $row['created_date']),
- 'newcomments' => textwrap('+ '.stripslashes($row['comment_text']),72,"\n+ ")
+ 'newcomments' => textwrap('+ '.format_comments($row['comment_text']),72,"\n+ ")
));
// If this comment is the first additional comment after the creation of the
// bug then we need to grab the bug's description as the previous comment
@@ -147,7 +165,7 @@
$t->set_var(array(
'oldpostedby' => $by,
'oldpostedon' => date(TIMEFORMAT,$on).' on '.date(DATEFORMAT,$on),
- 'oldcomments' => textwrap(stripslashes($comments),72)
+ 'oldcomments' => textwrap(format_comments($comments),72)
));
} else {
$row = $q->grab();
@@ -155,7 +173,7 @@
'oldpostedby' => $row['login'],
'oldpostedon' => date(TIMEFORMAT,$row['created_date']).' on '.
date(DATEFORMAT,$row['created_date']),
- 'oldcomments' => textwrap(stripslashes($row['comment_text']),72)
+ 'oldcomments' => textwrap(format_comments($row['comment_text']),72)
));
}
$t->parse('cblock', 'commentblock', true);
@@ -314,7 +332,7 @@
$changedfields['resolution_id'] = $resolution_id;
}
if ($comments) {
- $comments = htmlspecialchars($comments);
+ $comments = $comments;
$q->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date)"
." values (".$q->nextid(TBL_COMMENT).", $bugid, '$comments', $u, $now)");
}
@@ -516,6 +534,7 @@
}
}
+ // Show the comments
$q->query('select comment_text, c.created_date, login'
.' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER
." where bug_id = $bugid and c.created_by = user_id order by c.created_date");
@@ -525,8 +544,8 @@
while ($row = $q->grab()) {
$t->set_var(array(
'bgcolor' => (++$i % 2 == 0) ? '#dddddd' : '#ffffff',
- 'rdescription' => eregi_replace('(bug)[[:space:]]*(#?)([0-9]+)',
- "\\1 <a href='$me?op=show&bugid=\\3'>\\2\\3</a>",nl2br($row['comment_text'])),
+ 'rdescription' => nl2br(format_comments(
+ htmlspecialchars($row['comment_text']))),
'rreporter' => maskemail($row['login']),
'rcreateddate' => date(TIMEFORMAT,$row['created_date']).' on '.
date(DATEFORMAT,$row['created_date'])
@@ -590,4 +609,4 @@
page_close();
-?>
\ No newline at end of file
+?>
Index: config.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/config.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- config.php 2001/09/22 16:55:33 1.11
+++ config.php 2001/09/29 14:50:26 1.12
@@ -28,6 +28,9 @@
define ('PHPLIBPATH', ''); // If not in the include path
define ('JPGRAPH_PATH', ''); // If not in the include path
+// Location of your cvs web interface (see format_comments() in bug.php)
+define ('CVS_WEB', 'http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpbt/phpbt/');
+
// Database Config
define ('DB_TYPE', 'mysql'); //using PHPlib file naming
define ('DB_HOST', 'localhost');
|