/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1
1 by Henrik G.
First seed of Lenasys ... Needs to be Organized Further
1
<?php
2
3
	function menulayout($forward,$backward,$downloadlink,$heading,$headinglink,$filecontent)
4
	{
5
			echo "<body onload='resize();' onresize='resize();'>";
6
7
echo "<div class='Topmenu'>";
8
			echo "<table style='width:100%;height:100%;border:solid 1px;'>";
9
			echo "<tr>";
10
11
			echo "<td class='buttonstyle'>";
12
			if($backward!=""){
13
					echo "<a href='".$backward."'><img src='CodeViewerLeftbutton.png'></a>";
14
			}else{
15
					echo "<img src='CodeViewerLeftbuttonGrayed.png'>";
16
			}
17
			echo "</td>";
18
19
			echo "<td class='buttonstyle'>";
20
			if($forward!=""){
21
					echo "<a href='".$forward."'><img src='CodeViewerRightbutton.png'></a>";
22
			}else{
23
					echo "<img src='CodeViewerLeftbuttonGrayed.png'>";
24
			}
25
			echo "</td>";
26
27
			echo "<td class='verticalaligntext'>";
28
			echo "<a STYLE='text-decoration:none' href='".$headinglink."'>".$heading."</a>";
29
			echo "</td>";
30
31
			echo "<td class='buttonstyle'>";
32
			if($downloadlink!=""){
33
					echo "<a href='".$downloadlink."'><img src='CodeViewerDownloadbutton.png'></a>";
34
			}else{
35
					echo "<img src='CodeViewerLeftbuttonGrayed.png'>";
36
			}
37
			echo "</td>";
38
39
			echo "</tr>";
40
			echo "</table>";
41
42
echo "</div>";
43
44
echo "<div id='bottom' class='RestContainer'>";
45
46
			echo "<div style='float:left;'>";
47
					echo "<div id='panel' class='panel' onmousemove='resizepanel(event)' onmousedown='mdpanel(event)' onmouseup='mupanel(event)'>";
48
49
					include($filecontent);
50
			
51
					echo "</div>";
52
			echo "</div>";
53
			echo "<div class='codecontent'>";
54
	}
55
56
	function menulayoutend()
57
	{
58
		echo "</div>";
59
		echo "</div>";
60
		echo "<div style='clear:both;'></div>";
61
		echo "</body>";
62
	}
63
64
	function showfile($interestingrows,$keywords,$highlight,$filename)
65
	{
66
			echo "<pre>";
67
			$handle = @fopen($filename, "r");
68
			if ($handle) {
69
					$lineno=1;
70
					
71
					$commentkind=0;
72
					$commenton=0;
73
					
74
			    while (($buffer = fgets($handle, 4096)) !== false) {
75
							$buffer = str_replace("\n","", $buffer);
76
							$buffer = str_replace("\r","", $buffer);
77
							$buffer=str_pad($buffer,150," ", STR_PAD_RIGHT);
78
			        $buffer=str_replace("<","&lt;",$buffer);
79
			        $buffer=str_replace(">","&gt;",$buffer);
80
			        $buffer=str_replace("\t","&nbsp;",$buffer);
81
							        
82
							$interesting=0;
83
			        $startspan=0;
84
			        foreach($interestingrows as $row){
85
			        		if($lineno>=$row[0]&&$lineno<=$row[1]){
86
												$interesting=true;
87
			        		}
88
			        }
89
90
			        foreach($keywords as $keyword){
91
									if($interesting){
92
											$buffer=str_replace($keyword,"<span class='keywordinteresting'>".$keyword."</span>",$buffer);
93
									}else{
94
											$buffer=str_replace($keyword,"<span class='keyword'>".$keyword."</span>",$buffer);
95
									}
96
			        }
97
			        
98
							// Detect comments - 0 == No comment 1 == Line comment 2 == Start Comment 3 == End Comment
99
							$commentkind=0;
100
101
							$commentpos=strpos($buffer,"/*");
102
							if($commentpos){
103
									$commentkind=2;
104
									$commenton=1;
105
							}							
106
107
							$commentpos=strpos($buffer,"*/");
108
							if($commentpos){
109
									$commentkind=3;
110
									$commenton=0;
111
							}							
112
113
							$commentpos=strpos($buffer,"//");
114
							if($commentpos){
115
									$commentkind=1;
116
									$commenton=0;
117
							}							
118
119
			        foreach($highlight as $highlightkeyword){
120
										$foundpos=strpos($buffer,$highlightkeyword[0]);
121
										
122
										// If line comment and keyword before comment marker
123
										if(($foundpos<=$commentpos&&($commentkind==1||$commentkind==2))||($commentkind==0)||($foundpos>$commentpos&&$commentkind==3)){
124
											if(!($commentkind==0&&$commenton==1)) $buffer=str_replace($highlightkeyword[0],"<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>",$buffer);
125
										}
126
127
			        }
128
129
							echo $commentkind.$commenton;
130
			       
131
			        if($commentkind>0){
132
									if($commentkind==1){
133
											$buffer=str_replace("//","<span class='commented'>//",$buffer);
134
											$buffer.="</span>";
135
									}
136
									if($commentkind==2) $buffer=str_replace("/*","<span class='commented'>/*",$buffer);
137
									if($commentkind==3) $buffer=str_replace("*/","*/</span>",$buffer);
138
			        }
139
140
			
141
							$linenostr=$lineno;
142
							$linenostr=str_pad($linenostr,3," ",STR_PAD_RIGHT);
143
			
144
							if($interesting){
145
			      			echo "<span class='interesting'>";
146
			        		echo "<span class='linenointeresting'>".$linenostr."</span>&nbsp;";
147
			    				$startspan=1;
148
							}else{
149
			        		echo "<span class='lineno'>".$linenostr."</span>&nbsp;";				
150
							}
151
			
152
			        echo $buffer;
153
			
154
							if($startspan) echo "</span>";
155
			
156
			        $lineno++;
157
158
			        echo "<br>";
159
			    }
160
			    if (!feof($handle)) {
161
			        echo "Error: unexpected fgets() fail\n";
162
			    }
163
			    fclose($handle);
164
			}
165
			echo "</pre>";	
166
	}
167
?>