Index: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	(revision 521)
+++ trunk/CHANGELOG	(revision 522)
@@ -12,8 +12,10 @@
 
 ------------------------------------- 2.7.0 -------------------------------------
 09-Jan-2008 Matthias Gallas
+!	Update codepress to Version 0.9.6
+!	Update phplib to Version 7.4a
+09-Jan-2008 Matthias Gallas
 !	Upgrade pclzip to the newer more php5 complaint version 2.6, see ticket #526
-09-Jan-2008 Matthias Gallas
 #	Fixed ticket #542 (Thanks to Thorn)
 23-Dec-2007 Matthias Gallas
 !	Changed all copyright notices to include now 2008
Index: trunk/wb/include/codepress/codepress.js
===================================================================
--- trunk/wb/include/codepress/codepress.js	(revision 521)
+++ trunk/wb/include/codepress/codepress.js	(revision 522)
@@ -18,6 +18,7 @@
 	self.style.width = self.textarea.clientWidth +'px';
 	self.textarea.style.overflow = 'auto';
 	self.style.border = '1px solid gray';
+	self.frameBorder = 0; // remove IE internal iframe border
 	self.style.visibility = 'hidden';
 	self.style.position = 'absolute';
 	self.options = self.textarea.className;
@@ -34,16 +35,22 @@
 		self.style.display = 'inline';
 	}
 	
-	self.edit = function(id,language) {
-		if(id) self.textarea.value = document.getElementById(id).value;
+	// obj can by a textarea id or a string (code)
+	self.edit = function(obj,language) {
+		if(obj) self.textarea.value = document.getElementById(obj) ? document.getElementById(obj).value : obj;
 		if(!self.textarea.disabled) return;
-		self.language = language ? language : self.options.replace(/ ?codepress ?| ?readonly-on ?| ?autocomplete-off ?| ?linenumbers-off ?/g,'');
-		if(!CodePress.languages[self.language]) self.language = 'generic';
-		self.src = CodePress.path+'codepress.html?engine='+CodePress.engine+'&language='+self.language+'&ts='+(new Date).getTime();
+		self.language = language ? language : self.getLanguage();
+		self.src = CodePress.path+'codepress.html?language='+self.language+'&ts='+(new Date).getTime();
 		if(self.attachEvent) self.attachEvent('onload',self.initialize);
 		else self.addEventListener('load',self.initialize,false);
 	}
 
+	self.getLanguage = function() {
+		for (language in CodePress.languages) 
+			if(self.options.match('\\b'+language+'\\b')) 
+				return CodePress.languages[language] ? language : 'generic';
+	}
+	
 	self.setOptions = function() {
 		if(self.options.match('autocomplete-off')) self.toggleAutoComplete();
 		if(self.options.match('readonly-on')) self.toggleReadOnly();
@@ -63,7 +70,7 @@
 	}
 	
 	self.toggleReadOnly = function() {
-		self.textarea.readOnly = (self.textarea.readOnly) ? false : true;	
+		self.textarea.readOnly = (self.textarea.readOnly) ? false : true;
 		if(self.style.display != 'none') // prevent exception on FF + iframe with display:none
 			self.editor.readOnly(self.textarea.readOnly ? true : false);
 	}
@@ -94,6 +101,7 @@
 }
 
 CodePress.languages = {	
+	csharp : 'C#', 
 	css : 'CSS', 
 	generic : 'Generic',
 	html : 'HTML',
@@ -103,21 +111,12 @@
 	ruby : 'Ruby',	
 	php : 'PHP', 
 	text : 'Text', 
-	sql : 'SQL'
+	sql : 'SQL',
+	vbscript : 'VBScript'
 }
 
-CodePress.getEngine = function()	{
-	var engine = 'older';
-	var ua = navigator.userAgent;
-	if(ua.match('MSIE')) engine = 'msie';
-	else if(ua.match('KHTML')) engine = 'khtml'; 
-	else if(ua.match('Opera')) engine = 'opera'; 
-	else if(ua.match('Gecko')) engine = 'gecko';
-	return engine;
-}
 
 CodePress.run = function() {
-	CodePress.engine = CodePress.getEngine();
 	s = document.getElementsByTagName('script');
 	for(var i=0,n=s.length;i<n;i++) {
 		if(s[i].src.match('codepress.js')) {
Index: trunk/wb/include/codepress/codepress.html
===================================================================
--- trunk/wb/include/codepress/codepress.html	(revision 521)
+++ trunk/wb/include/codepress/codepress.html	(revision 522)
@@ -3,18 +3,21 @@
 <head>
 	<title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
 	<meta name="description" content="CodePress - source code editor window" />
-	
+
 	<script type="text/javascript">
-	var L=location.href;
-	var d=L.substring(L.indexOf("?")+1);
-	var c=v=new Array(); c=d.split("&");
-	for(i=0;i<c.length&&c.length>0;i++) {
-	v=c[i].split("="); if(v.length>1)
-	eval(v[0]+"=unescape('"+v[1].replace(/\+/g," ")+"')");} 
+	var language = 'generic';
+	var engine = 'older';
+	var ua = navigator.userAgent;
+	var ts = (new Date).getTime(); // timestamp to avoid cache
+	var lh = location.href;
 	
-	if(language==null||language=='') language = 'generic';
-	
-	ts = (new Date).getTime(); // timestamp to avoid cache
+	if(ua.match('MSIE')) engine = 'msie';
+	else if(ua.match('KHTML')) engine = 'khtml'; 
+	else if(ua.match('Opera')) engine = 'opera'; 
+	else if(ua.match('Gecko')) engine = 'gecko';
+
+	if(lh.match('language=')) language = lh.replace(/.*language=(.*?)(&.*)?$/,'$1');
+
 	document.write('<link type="text/css" href="codepress.css?ts='+ts+'" rel="stylesheet" />');
 	document.write('<link type="text/css" href="languages/'+language+'.css?ts='+ts+'" rel="stylesheet" id="cp-lang-style" />');
 	document.write('<scr'+'ipt type="text/javascript" src="engines/'+engine+'.js?ts='+ts+'"></scr'+'ipt>');
@@ -24,8 +27,9 @@
 </head>
 
 <script type="text/javascript">
-if (engine == "gecko") document.write('<body> </body>');
-else if(engine == "msie") document.write('<body><pre></pre></body>');
+if(engine == "msie" || engine == "gecko") document.write('<body><pre> </pre></body>');
+else if(engine == "opera") document.write('<body></body>');
+// else if(engine == "khtml") document.write('<body> </body>');
 </script>
 
 </html>
Index: trunk/wb/include/codepress/codepress.css
===================================================================
--- trunk/wb/include/codepress/codepress.css	(revision 521)
+++ trunk/wb/include/codepress/codepress.css	(revision 522)
@@ -1,8 +1,21 @@
-html {border:none;} /*remove ie frameborder */
-body {margin-top:13px;_margin-top:14px;background:white;font-family:monospace;font-size:13px;margin-left:32px;white-space:pre;background-image:url("images/line-numbers.png");background-repeat:repeat-y;background-position:0 3px;line-height:16px;}
+body {
+	margin-top:13px;
+	_margin-top:14px;
+	background:white;
+	margin-left:32px;
+	font-family:monospace;
+	font-size:13px;
+	white-space:pre;
+	background-image:url("images/line-numbers.png");
+	background-repeat:repeat-y;
+	background-position:0 3px;
+	line-height:16px;
+	height:100%;
+}
+pre {margin:0;}
 html>body{background-position:0 2px;}
 P {margin:0;padding:0;border:0;outline:0;display:block;white-space:pre;}
-b, i, s, u, a, em, tt, ins, big, cite, strong {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;}
+b, i, s, u, a, em, tt, ins, big, cite, strong, var, dfn {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;}
 
 body.hide-line-numbers {background:white;margin-left:16px;}
 body.show-line-numbers {background-image:url("images/line-numbers.png");margin-left:32px;}
\ No newline at end of file
Index: trunk/wb/include/phplib/template.inc
===================================================================
--- trunk/wb/include/phplib/template.inc	(revision 521)
+++ trunk/wb/include/phplib/template.inc	(revision 522)
@@ -5,7 +5,7 @@
  * (C) Copyright 1999-2000 NetUSE GmbH
  *                    Kristian Koehntopp
  *
- * $Id: template.inc,v 1.1.1.1 2005/01/30 10:32:06 rdjurovich Exp $
+ * $Id: template.inc,v 1.15 2004/07/23 20:36:29 layne_weathers Exp $
  *
  */
 
@@ -32,10 +32,14 @@
  * loadfile would try to load a file if the varval had been set to "" (rha)
  * in get_undefined, only match non-whitespace in variable tags as in finish (Layne Weathers & rha)
  * more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings (rha)
+ * parse uses get_var to obtain return value (Jordi via SF)
+ * set_block reports an error if the block could not be extracted (rha)
+ * filename is now windows-pathname aware (krabu @ SF)
  *
  *
  * Changes in functionality which go beyond bug fixes:
  *
+ * added ability for filename comments to be output (from phplib-users layne)
  * changed debug handling so set, get and internals can be tracked separately (rha)
  * added debug statements throughout to track most function calls (rha)
  * debug output contained raw HTML -- is now escaped with htmlentities (rha)
@@ -85,6 +89,28 @@
   var $debug    = false;
 
  /**
+  * Determines whether Template outputs filename comments.
+  * false = no filename outputs
+  * true = HTML comments (e.g. <!-- START FILE $filename -->) placed in output
+  *
+  * @var       int
+  * @access    public
+  */
+  var $filename_comments = false;
+
+ /**
+  * Determines the regular expression used to find unknown variable tags.
+  * "loose"  = traditional match all curly braces with no whitespace between
+  * "strict" = adopts PHP's variable naming rules
+  *              ("loose" has a nasty habit of deleting JavaScript RegEx components)
+  *              (should future major version releases of PHPLib default this "strict"?)
+  *
+  * @var       string
+  * @access    public
+  */
+  var $unknown_regexp = "loose";
+
+ /**
   * The base directory from which template files are loaded.
   *
   * @var       string
@@ -194,6 +220,9 @@
   * @return    boolean
   */
   function set_root($root) {
+    if(ereg('/$', $root)) {
+      $root = substr($root, 0, -1);
+    }
     if ($this->debug & 4) {
       echo "<p><b>set_root:</b> root = $root</p>\n";
     }
@@ -266,7 +295,7 @@
       $this->file[$varname] = $this->filename($filename);
     } else {
       reset($varname);
-      while(list($v, $f) = each($varname)) {
+      while (list($v, $f) = each($varname)) {
         if ($this->debug & 4) {
           echo "<p><b>set_file:</b> (with array) varname = $v, filename = $f</p>\n";
         }
@@ -316,7 +345,11 @@
     $str = $this->get_var($parent);
     $reg = "/[ \t]*<!--\s+BEGIN $varname\s+-->\s*?\n?(\s*.*?\n?)\s*<!--\s+END $varname\s+-->\s*?\n?/sm";
     preg_match_all($reg, $str, $m);
-    $str = preg_replace($reg, "{" . "$name}", $str);
+    if (!isset($m[1][0])) {
+      $this->halt("set_block: unable to set block $varname.");
+      return false;
+    }
+    $str = preg_replace($reg, "{" . $name . "}", $str);
     $this->set_var($varname, $m[1][0]);
     $this->set_var($parent, $str);
     return true;
@@ -364,7 +397,7 @@
       }
     } else {
       reset($varname);
-      while(list($k, $v) = each($varname)) {
+      while (list($k, $v) = each($varname)) {
         if (!empty($k)) {
           if ($this->debug & 1) {
             printf("<b>set_var:</b> (with array) <b>%s</b> = '%s'<br>\n", $k, htmlentities($v));
@@ -410,7 +443,7 @@
       }
     } else {
       reset($varname);
-      while(list($k, $v) = each($varname)) {
+      while (list($k, $v) = each($varname)) {
         if (!empty($v)) {
           if ($this->debug & 1) {
             printf("<b>clear_var:</b> (with array) <b>%s</b><br>\n", $v);
@@ -452,7 +485,7 @@
       }
     } else {
       reset($varname);
-      while(list($k, $v) = each($varname)) {
+      while (list($k, $v) = each($varname)) {
         if (!empty($v)) {
           if ($this->debug & 1) {
             printf("<b>unset_var:</b> (with array) <b>%s</b><br>\n", $v);
@@ -492,7 +525,7 @@
 
     // quote the replacement strings to prevent bogus stripping of special chars
     reset($this->varvals);
-    while(list($k, $v) = each($this->varvals)) {
+    while (list($k, $v) = each($this->varvals)) {
       $varvals_quoted[$k] = preg_replace(array('/\\\\/', '/\$/'), array('\\\\\\\\', '\\\\$'), $v);
     }
 
@@ -578,7 +611,7 @@
       }
     } else {
       reset($varname);
-      while(list($i, $v) = each($varname)) {
+      while (list($i, $v) = each($varname)) {
         if ($this->debug & 4) {
           echo "<p><b>parse:</b> (with array) target = $target, i = $i, varname = $v, append = $append</p>\n";
         }
@@ -594,7 +627,7 @@
     if ($this->debug & 4) {
       echo "<p><b>parse:</b> completed</p>\n";
     }
-    return $str;
+    return $this->get_var($target);
   }
 
 
@@ -644,7 +677,7 @@
       echo "<p><b>get_vars:</b> constructing array of vars...</p>\n";
     }
     reset($this->varkeys);
-    while(list($k, $v) = each($this->varkeys)) {
+    while (list($k, $v) = each($this->varkeys)) {
       $result[$k] = $this->get_var($k);
     }
     return $result;
@@ -682,7 +715,7 @@
       return $str;
     } else {
       reset($varname);
-      while(list($k, $v) = each($varname)) {
+      while (list($k, $v) = each($varname)) {
         if (isset($this->varvals[$v])) {
           $str = $this->varvals[$v];
         } else {
@@ -719,7 +752,10 @@
       return false;
     }
 
-    preg_match_all("/{([^ \t\r\n}]+)}/", $this->get_var($varname), $m);
+    preg_match_all(
+        (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
+        $this->get_var($varname),
+        $m);
     $m = $m[1];
     if (!is_array($m)) {
       return false;
@@ -726,7 +762,7 @@
     }
 
     reset($m);
-    while(list($k, $v) = each($m)) {
+    while (list($k, $v) = each($m)) {
       if (!isset($this->varkeys[$v])) {
         if ($this->debug & 4) {
          echo "<p><b>get_undefined:</b> undefined: $v</p>\n";
@@ -762,11 +798,17 @@
       break;
 
       case "remove":
-        $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
+        $str = preg_replace(
+            (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
+            "",
+            $str);
       break;
 
       case "comment":
-        $str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template variable \\1 undefined -->", $str);
+        $str = preg_replace(
+             (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
+            "<!-- Template variable \\1 undefined -->",
+            $str);
       break;
     }
 
@@ -829,7 +871,11 @@
     if ($this->debug & 4) {
       echo "<p><b>filename:</b> filename = $filename</p>\n";
     }
-    if (substr($filename, 0, 1) != "/") {
+    if (substr($filename, 0, 1) != "/" 
+       && substr($filename, 0, 1) != "\\"
+       && substr($filename, 1, 2) != ":\\"
+       && substr($filename, 1, 2) != ":/"
+    ) {
       $filename = $this->root."/".$filename;
     }
 
@@ -853,7 +899,7 @@
   * @return    string
   */
   function varname($varname) {
-    return preg_quote("{".$varname."}");
+    return preg_quote("{" . $varname . "}");
   }
 
 
@@ -907,6 +953,9 @@
       return false;
     }
 
+    if ($this->filename_comments) {
+      $str = "<!-- START FILE $filename -->\n$str<!-- END FILE $filename -->\n";
+    }
     if ($this->debug & 4) {
       printf("<b>loadfile:</b> loaded $filename into $varname<br>\n");
     }
