cvs: php-master-web / style.css /manage user-notes.php
| From: | Gabor Hojtsy | Date: | Mon, 02 Feb 2004 09:44:53 +0000 |
| Subject: | cvs: php-master-web / style.css /manage user-notes.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-23294@lists.php.net to get a copy of this message | ||
goba Mon Feb 2 04:44:53 2004 EDT
Modified files:
/php-master-web style.css
/php-master-web/manage user-notes.php
Log:
support highlighted note (pre)viewing on the master server too
http://cvs.php.net/diff.php/php-master-web/style.css?r1=1.20&r2=1.21&ty=u
Index: php-master-web/style.css
diff -u php-master-web/style.css:1.20 php-master-web/style.css:1.21
--- php-master-web/style.css:1.20 Fri Dec 26 07:09:03 2003
+++ php-master-web/style.css Mon Feb 2 04:44:53 2004
@@ -71,3 +71,25 @@
border: 0px;
vertical-align: middle;
}
+
+/* PHP source code highlighting (from php.net CSS) ------------------------ */
+div.phpcode span.html {
+ color: black;
+ background-color: transparent;
+}
+div.phpcode span.comment {
+ color: #FF8000;
+ background-color: transparent;
+}
+div.phpcode span.default {
+ color: #0000BB;
+ background-color: transparent;
+}
+div.phpcode span.keyword {
+ color: #007700;
+ background-color: transparent;
+}
+div.phpcode span.string {
+ color: #DD0000;
+ background-color: transparent;
+}
http://cvs.php.net/diff.php/php-master-web/manage/user-notes.php?r1=1.35&r2=1.36&ty=u
Index: php-master-web/manage/user-notes.php
diff -u php-master-web/manage/user-notes.php:1.35 php-master-web/manage/user-notes.php:1.36
--- php-master-web/manage/user-notes.php:1.35 Mon Feb 2 04:33:43 2004
+++ php-master-web/manage/user-notes.php Mon Feb 2 04:44:53 2004
@@ -298,14 +298,60 @@
foot();
}
-function clean_note($text) {
- $text = htmlspecialchars($text);
- $fixes = array('<br>','<p>','</p>');
- reset($fixes);
- while (list(,$f)=each($fixes)) {
- $text=str_replace(htmlspecialchars($f), $f, $text);
- $text=str_replace(htmlspecialchars(strtoupper($f)), $f, $text);
- }
- $text = "<tt><pre>".$text."</pre></tt>";
+// Copied over from phpweb (should be syncronised if changed)
+function clean_note($text)
+{
+ // Highlight PHP source
+ $text = highlight_php(trim($text), TRUE);
+
+ // Turn urls into links
+ $text = preg_replace(
+ '!((mailto:|(http|ftp|nntp|news):\/\/).*?)(\s|<|\)|"|\\|\'|$)!',
+ '<a href="\1" target="_blank">\1</a>\4',
+ $text
+ );
+
return $text;
}
+
+// Use class names instead of colors
+ini_set('highlight.comment', 'comment');
+ini_set('highlight.default', 'default');
+ini_set('highlight.keyword', 'keyword');
+ini_set('highlight.string', 'string');
+ini_set('highlight.html', 'html');
+
+// Highlight PHP code
+function highlight_php($code, $return = FALSE)
+{
+ // Using OB, as highlight_string() only supports
+ // returning the result from 4.2.0
+ ob_start();
+ highlight_string($code);
+ $highlighted = ob_get_contents();
+ ob_end_clean();
+
+ // Fix output to use CSS classes and wrap well
+ $highlighted = '<div class="phpcode">' . str_replace(
+ array(
+ ' ',
+ '<br />',
+ '<font color="',
+ '</font>',
+ "\n ",
+ ' '
+ ),
+ array(
+ ' ',
+ "<br />\n",
+ '<span class="',
+ '</span>',
+ "\n ",
+ ' '
+ ),
+ $highlighted
+ ) . '</div>';
+
+ if ($return) { return $highlighted; }
+ else { echo $highlighted; }
+}