Project

General

Profile

« Previous | Next » 

Revision 522

Added by Matthias almost 17 years ago

- Update codepress to Version 0.9.6
- Update phplib to Version 7.4a

View differences:

trunk/CHANGELOG
12 12

  
13 13
------------------------------------- 2.7.0 -------------------------------------
14 14
09-Jan-2008 Matthias Gallas
15
!	Update codepress to Version 0.9.6
16
!	Update phplib to Version 7.4a
17
09-Jan-2008 Matthias Gallas
15 18
!	Upgrade pclzip to the newer more php5 complaint version 2.6, see ticket #526
16
09-Jan-2008 Matthias Gallas
17 19
#	Fixed ticket #542 (Thanks to Thorn)
18 20
23-Dec-2007 Matthias Gallas
19 21
!	Changed all copyright notices to include now 2008
trunk/wb/include/codepress/codepress.js
18 18
	self.style.width = self.textarea.clientWidth +'px';
19 19
	self.textarea.style.overflow = 'auto';
20 20
	self.style.border = '1px solid gray';
21
	self.frameBorder = 0; // remove IE internal iframe border
21 22
	self.style.visibility = 'hidden';
22 23
	self.style.position = 'absolute';
23 24
	self.options = self.textarea.className;
......
34 35
		self.style.display = 'inline';
35 36
	}
36 37
	
37
	self.edit = function(id,language) {
38
		if(id) self.textarea.value = document.getElementById(id).value;
38
	// obj can by a textarea id or a string (code)
39
	self.edit = function(obj,language) {
40
		if(obj) self.textarea.value = document.getElementById(obj) ? document.getElementById(obj).value : obj;
39 41
		if(!self.textarea.disabled) return;
40
		self.language = language ? language : self.options.replace(/ ?codepress ?| ?readonly-on ?| ?autocomplete-off ?| ?linenumbers-off ?/g,'');
41
		if(!CodePress.languages[self.language]) self.language = 'generic';
42
		self.src = CodePress.path+'codepress.html?engine='+CodePress.engine+'&language='+self.language+'&ts='+(new Date).getTime();
42
		self.language = language ? language : self.getLanguage();
43
		self.src = CodePress.path+'codepress.html?language='+self.language+'&ts='+(new Date).getTime();
43 44
		if(self.attachEvent) self.attachEvent('onload',self.initialize);
44 45
		else self.addEventListener('load',self.initialize,false);
45 46
	}
46 47

  
48
	self.getLanguage = function() {
49
		for (language in CodePress.languages) 
50
			if(self.options.match('\\b'+language+'\\b')) 
51
				return CodePress.languages[language] ? language : 'generic';
52
	}
53
	
47 54
	self.setOptions = function() {
48 55
		if(self.options.match('autocomplete-off')) self.toggleAutoComplete();
49 56
		if(self.options.match('readonly-on')) self.toggleReadOnly();
......
63 70
	}
64 71
	
65 72
	self.toggleReadOnly = function() {
66
		self.textarea.readOnly = (self.textarea.readOnly) ? false : true;	
73
		self.textarea.readOnly = (self.textarea.readOnly) ? false : true;
67 74
		if(self.style.display != 'none') // prevent exception on FF + iframe with display:none
68 75
			self.editor.readOnly(self.textarea.readOnly ? true : false);
69 76
	}
......
94 101
}
95 102

  
96 103
CodePress.languages = {	
104
	csharp : 'C#', 
97 105
	css : 'CSS', 
98 106
	generic : 'Generic',
99 107
	html : 'HTML',
......
103 111
	ruby : 'Ruby',	
104 112
	php : 'PHP', 
105 113
	text : 'Text', 
106
	sql : 'SQL'
114
	sql : 'SQL',
115
	vbscript : 'VBScript'
107 116
}
108 117

  
109
CodePress.getEngine = function()	{
110
	var engine = 'older';
111
	var ua = navigator.userAgent;
112
	if(ua.match('MSIE')) engine = 'msie';
113
	else if(ua.match('KHTML')) engine = 'khtml'; 
114
	else if(ua.match('Opera')) engine = 'opera'; 
115
	else if(ua.match('Gecko')) engine = 'gecko';
116
	return engine;
117
}
118 118

  
119 119
CodePress.run = function() {
120
	CodePress.engine = CodePress.getEngine();
121 120
	s = document.getElementsByTagName('script');
122 121
	for(var i=0,n=s.length;i<n;i++) {
123 122
		if(s[i].src.match('codepress.js')) {
trunk/wb/include/codepress/codepress.html
3 3
<head>
4 4
	<title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
5 5
	<meta name="description" content="CodePress - source code editor window" />
6
	
6

  
7 7
	<script type="text/javascript">
8
	var L=location.href;
9
	var d=L.substring(L.indexOf("?")+1);
10
	var c=v=new Array(); c=d.split("&");
11
	for(i=0;i<c.length&&c.length>0;i++) {
12
	v=c[i].split("="); if(v.length>1)
13
	eval(v[0]+"=unescape('"+v[1].replace(/\+/g," ")+"')");} 
8
	var language = 'generic';
9
	var engine = 'older';
10
	var ua = navigator.userAgent;
11
	var ts = (new Date).getTime(); // timestamp to avoid cache
12
	var lh = location.href;
14 13
	
15
	if(language==null||language=='') language = 'generic';
16
	
17
	ts = (new Date).getTime(); // timestamp to avoid cache
14
	if(ua.match('MSIE')) engine = 'msie';
15
	else if(ua.match('KHTML')) engine = 'khtml'; 
16
	else if(ua.match('Opera')) engine = 'opera'; 
17
	else if(ua.match('Gecko')) engine = 'gecko';
18

  
19
	if(lh.match('language=')) language = lh.replace(/.*language=(.*?)(&.*)?$/,'$1');
20

  
18 21
	document.write('<link type="text/css" href="codepress.css?ts='+ts+'" rel="stylesheet" />');
19 22
	document.write('<link type="text/css" href="languages/'+language+'.css?ts='+ts+'" rel="stylesheet" id="cp-lang-style" />');
20 23
	document.write('<scr'+'ipt type="text/javascript" src="engines/'+engine+'.js?ts='+ts+'"></scr'+'ipt>');
......
24 27
</head>
25 28

  
26 29
<script type="text/javascript">
27
if (engine == "gecko") document.write('<body> </body>');
28
else if(engine == "msie") document.write('<body><pre></pre></body>');
30
if(engine == "msie" || engine == "gecko") document.write('<body><pre> </pre></body>');
31
else if(engine == "opera") document.write('<body></body>');
32
// else if(engine == "khtml") document.write('<body> </body>');
29 33
</script>
30 34

  
31 35
</html>
trunk/wb/include/codepress/codepress.css
1
html {border:none;} /*remove ie frameborder */
2
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;}
1
body {
2
	margin-top:13px;
3
	_margin-top:14px;
4
	background:white;
5
	margin-left:32px;
6
	font-family:monospace;
7
	font-size:13px;
8
	white-space:pre;
9
	background-image:url("images/line-numbers.png");
10
	background-repeat:repeat-y;
11
	background-position:0 3px;
12
	line-height:16px;
13
	height:100%;
14
}
15
pre {margin:0;}
3 16
html>body{background-position:0 2px;}
4 17
P {margin:0;padding:0;border:0;outline:0;display:block;white-space:pre;}
5
b, i, s, u, a, em, tt, ins, big, cite, strong {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;}
18
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;}
6 19

  
7 20
body.hide-line-numbers {background:white;margin-left:16px;}
8 21
body.show-line-numbers {background-image:url("images/line-numbers.png");margin-left:32px;}
trunk/wb/include/phplib/template.inc
5 5
 * (C) Copyright 1999-2000 NetUSE GmbH
6 6
 *                    Kristian Koehntopp
7 7
 *
8
 * $Id: template.inc,v 1.1.1.1 2005/01/30 10:32:06 rdjurovich Exp $
8
 * $Id: template.inc,v 1.15 2004/07/23 20:36:29 layne_weathers Exp $
9 9
 *
10 10
 */
11 11

  
......
32 32
 * loadfile would try to load a file if the varval had been set to "" (rha)
33 33
 * in get_undefined, only match non-whitespace in variable tags as in finish (Layne Weathers & rha)
34 34
 * more elegant fix to the problem of subst stripping '$n', '\n' and '\\' strings (rha)
35
 * parse uses get_var to obtain return value (Jordi via SF)
36
 * set_block reports an error if the block could not be extracted (rha)
37
 * filename is now windows-pathname aware (krabu @ SF)
35 38
 *
36 39
 *
37 40
 * Changes in functionality which go beyond bug fixes:
38 41
 *
42
 * added ability for filename comments to be output (from phplib-users layne)
39 43
 * changed debug handling so set, get and internals can be tracked separately (rha)
40 44
 * added debug statements throughout to track most function calls (rha)
41 45
 * debug output contained raw HTML -- is now escaped with htmlentities (rha)
......
85 89
  var $debug    = false;
86 90

  
87 91
 /**
92
  * Determines whether Template outputs filename comments.
93
  * false = no filename outputs
94
  * true = HTML comments (e.g. <!-- START FILE $filename -->) placed in output
95
  *
96
  * @var       int
97
  * @access    public
98
  */
99
  var $filename_comments = false;
100

  
101
 /**
102
  * Determines the regular expression used to find unknown variable tags.
103
  * "loose"  = traditional match all curly braces with no whitespace between
104
  * "strict" = adopts PHP's variable naming rules
105
  *              ("loose" has a nasty habit of deleting JavaScript RegEx components)
106
  *              (should future major version releases of PHPLib default this "strict"?)
107
  *
108
  * @var       string
109
  * @access    public
110
  */
111
  var $unknown_regexp = "loose";
112

  
113
 /**
88 114
  * The base directory from which template files are loaded.
89 115
  *
90 116
  * @var       string
......
194 220
  * @return    boolean
195 221
  */
196 222
  function set_root($root) {
223
    if(ereg('/$', $root)) {
224
      $root = substr($root, 0, -1);
225
    }
197 226
    if ($this->debug & 4) {
198 227
      echo "<p><b>set_root:</b> root = $root</p>\n";
199 228
    }
......
266 295
      $this->file[$varname] = $this->filename($filename);
267 296
    } else {
268 297
      reset($varname);
269
      while(list($v, $f) = each($varname)) {
298
      while (list($v, $f) = each($varname)) {
270 299
        if ($this->debug & 4) {
271 300
          echo "<p><b>set_file:</b> (with array) varname = $v, filename = $f</p>\n";
272 301
        }
......
316 345
    $str = $this->get_var($parent);
317 346
    $reg = "/[ \t]*<!--\s+BEGIN $varname\s+-->\s*?\n?(\s*.*?\n?)\s*<!--\s+END $varname\s+-->\s*?\n?/sm";
318 347
    preg_match_all($reg, $str, $m);
319
    $str = preg_replace($reg, "{" . "$name}", $str);
348
    if (!isset($m[1][0])) {
349
      $this->halt("set_block: unable to set block $varname.");
350
      return false;
351
    }
352
    $str = preg_replace($reg, "{" . $name . "}", $str);
320 353
    $this->set_var($varname, $m[1][0]);
321 354
    $this->set_var($parent, $str);
322 355
    return true;
......
364 397
      }
365 398
    } else {
366 399
      reset($varname);
367
      while(list($k, $v) = each($varname)) {
400
      while (list($k, $v) = each($varname)) {
368 401
        if (!empty($k)) {
369 402
          if ($this->debug & 1) {
370 403
            printf("<b>set_var:</b> (with array) <b>%s</b> = '%s'<br>\n", $k, htmlentities($v));
......
410 443
      }
411 444
    } else {
412 445
      reset($varname);
413
      while(list($k, $v) = each($varname)) {
446
      while (list($k, $v) = each($varname)) {
414 447
        if (!empty($v)) {
415 448
          if ($this->debug & 1) {
416 449
            printf("<b>clear_var:</b> (with array) <b>%s</b><br>\n", $v);
......
452 485
      }
453 486
    } else {
454 487
      reset($varname);
455
      while(list($k, $v) = each($varname)) {
488
      while (list($k, $v) = each($varname)) {
456 489
        if (!empty($v)) {
457 490
          if ($this->debug & 1) {
458 491
            printf("<b>unset_var:</b> (with array) <b>%s</b><br>\n", $v);
......
492 525

  
493 526
    // quote the replacement strings to prevent bogus stripping of special chars
494 527
    reset($this->varvals);
495
    while(list($k, $v) = each($this->varvals)) {
528
    while (list($k, $v) = each($this->varvals)) {
496 529
      $varvals_quoted[$k] = preg_replace(array('/\\\\/', '/\$/'), array('\\\\\\\\', '\\\\$'), $v);
497 530
    }
498 531

  
......
578 611
      }
579 612
    } else {
580 613
      reset($varname);
581
      while(list($i, $v) = each($varname)) {
614
      while (list($i, $v) = each($varname)) {
582 615
        if ($this->debug & 4) {
583 616
          echo "<p><b>parse:</b> (with array) target = $target, i = $i, varname = $v, append = $append</p>\n";
584 617
        }
......
594 627
    if ($this->debug & 4) {
595 628
      echo "<p><b>parse:</b> completed</p>\n";
596 629
    }
597
    return $str;
630
    return $this->get_var($target);
598 631
  }
599 632

  
600 633

  
......
644 677
      echo "<p><b>get_vars:</b> constructing array of vars...</p>\n";
645 678
    }
646 679
    reset($this->varkeys);
647
    while(list($k, $v) = each($this->varkeys)) {
680
    while (list($k, $v) = each($this->varkeys)) {
648 681
      $result[$k] = $this->get_var($k);
649 682
    }
650 683
    return $result;
......
682 715
      return $str;
683 716
    } else {
684 717
      reset($varname);
685
      while(list($k, $v) = each($varname)) {
718
      while (list($k, $v) = each($varname)) {
686 719
        if (isset($this->varvals[$v])) {
687 720
          $str = $this->varvals[$v];
688 721
        } else {
......
719 752
      return false;
720 753
    }
721 754

  
722
    preg_match_all("/{([^ \t\r\n}]+)}/", $this->get_var($varname), $m);
755
    preg_match_all(
756
        (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
757
        $this->get_var($varname),
758
        $m);
723 759
    $m = $m[1];
724 760
    if (!is_array($m)) {
725 761
      return false;
726 762
    }
727 763

  
728 764
    reset($m);
729
    while(list($k, $v) = each($m)) {
765
    while (list($k, $v) = each($m)) {
730 766
      if (!isset($this->varkeys[$v])) {
731 767
        if ($this->debug & 4) {
732 768
         echo "<p><b>get_undefined:</b> undefined: $v</p>\n";
......
762 798
      break;
763 799

  
764 800
      case "remove":
765
        $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
801
        $str = preg_replace(
802
            (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
803
            "",
804
            $str);
766 805
      break;
767 806

  
768 807
      case "comment":
769
        $str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template variable \\1 undefined -->", $str);
808
        $str = preg_replace(
809
             (("loose" == $this->unknown_regexp) ? "/{([^ \t\r\n}]+)}/" : "/{([_a-zA-Z]\\w+)}/"),
810
            "<!-- Template variable \\1 undefined -->",
811
            $str);
770 812
      break;
771 813
    }
772 814

  
......
829 871
    if ($this->debug & 4) {
830 872
      echo "<p><b>filename:</b> filename = $filename</p>\n";
831 873
    }
832
    if (substr($filename, 0, 1) != "/") {
874
    if (substr($filename, 0, 1) != "/" 
875
       && substr($filename, 0, 1) != "\\"
876
       && substr($filename, 1, 2) != ":\\"
877
       && substr($filename, 1, 2) != ":/"
878
    ) {
833 879
      $filename = $this->root."/".$filename;
834 880
    }
835 881

  
......
853 899
  * @return    string
854 900
  */
855 901
  function varname($varname) {
856
    return preg_quote("{".$varname."}");
902
    return preg_quote("{" . $varname . "}");
857 903
  }
858 904

  
859 905

  
......
907 953
      return false;
908 954
    }
909 955

  
956
    if ($this->filename_comments) {
957
      $str = "<!-- START FILE $filename -->\n$str<!-- END FILE $filename -->\n";
958
    }
910 959
    if ($this->debug & 4) {
911 960
      printf("<b>loadfile:</b> loaded $filename into $varname<br>\n");
912 961
    }

Also available in: Unified diff