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
|
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
2 |
/* function menulayout
|
3 |
* Takes 6 arguments and outputs a HTML navigation menu
|
|
4 |
* $forward = link to "next page", i.e. "nextPage.html"
|
|
5 |
* $backward = link to "previous page", i.e. "previousPage.html"
|
|
6 |
* $downloadlink = link to download source file, on download button, i.e. "sourceFile.txt"
|
|
7 |
* headinglink = link in heading, i.e. "sourceFile.txt"
|
|
8 |
* filecontent = file containing info in the left panel, i.e. "panelContent.txt"
|
|
9 |
*/
|
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
10 |
function menulayout($forward,$backward,$downloadlink,$heading,$headinglink,$filecontent) { |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
11 |
if($backward != ""){ |
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
12 |
$backwardButton = "<a href='".$backward."'><img src='CodeViewerLeftbutton.png'></a>"; |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
13 |
}else{ |
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
14 |
$backwardButton = "<img src='CodeViewerLeftbuttonGrayed.png'>"; |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
15 |
}
|
16 |
||
4.9.6
by elof.bigestans at gmail
Cleaned up showcode.php, function menulayout() |
17 |
if($forward != ""){ |
18 |
$forwardButton = "<a href='".$forward."'><img src='CodeViewerRightbutton.png'></a>"; |
|
19 |
}else{ |
|
20 |
$forwardButton = "<img src='CodeViewerLeftbuttonGrayed.png'>"; |
|
21 |
}
|
|
22 |
||
23 |
if($downloadlink != ""){ |
|
24 |
$downloadButton = "<a href='".$downloadlink."'><img src='CodeViewerDownloadbutton.png'></a>"; |
|
25 |
}else{ |
|
26 |
$downloadButton = "<img src='CodeViewerLeftbuttonGrayed.png'>"; |
|
27 |
}
|
|
28 |
||
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
29 |
?>
|
30 |
<body onload='resize();' onresize='resize();'> |
|
31 |
<div class='Topmenu'> |
|
32 |
<table style='width:100%;height:100%;border:solid 1px;'> |
|
33 |
<tr> |
|
34 |
<td class="buttonstyle"> |
|
35 |
<?=$backwardButton;?> |
|
36 |
</td> |
|
4.9.6
by elof.bigestans at gmail
Cleaned up showcode.php, function menulayout() |
37 |
<td class='buttonstyle'> |
38 |
<?=$forwardButton;?> |
|
39 |
</td> |
|
40 |
<td class="buttonstyle"> |
|
41 |
<a href='../Lindex.html'><img src='CodeViewerRightbutton.png'></a> |
|
42 |
</td> |
|
43 |
<td class="verticalaligntext"> |
|
44 |
<a href="<?=$headinglink;?>" style="text-decoration: none"><?=$heading;?></a> |
|
45 |
</td> |
|
46 |
<td class='buttonstyle'> |
|
47 |
<?=$downloadButton;?> |
|
48 |
</td> |
|
49 |
</tr> |
|
50 |
</table> |
|
51 |
</div> |
|
52 |
<div id="bottom" class="restContainer"> |
|
53 |
<div style="float: left;"> |
|
54 |
<div id="panel" class="panel" onmousemove='resizepanel(event)' onmousedown='mdpanel(event)' onmouseup='mupanel(event)'> |
|
55 |
<?php include($filecontent); ?> |
|
56 |
</div> |
|
57 |
</div> |
|
58 |
<div class="codecontent"> |
|
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
59 |
<?php |
1
by Henrik G.
First seed of Lenasys ... Needs to be Organized Further |
60 |
}
|
61 |
||
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
62 |
/* function menulayoutend
|
63 |
* Outputs ending tags in HTML
|
|
64 |
*/
|
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
65 |
function menulayoutend() { |
4.9.7
by elof.bigestans at gmail
Cleaned up showcode.js -- Fixed indentation, spacing |
66 |
?>
|
67 |
</div> |
|
68 |
</div> |
|
69 |
<div style="clear: both;"></div> |
|
70 |
</body> |
|
71 |
<?php |
|
1
by Henrik G.
First seed of Lenasys ... Needs to be Organized Further |
72 |
}
|
73 |
||
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
74 |
/* function showfile
|
75 |
* Outputs html with syntax highlighting.
|
|
76 |
* Takes 4 arguments_
|
|
77 |
* interestingrows: array containing arrays, each with 3 set values -- start line number, end line number, comment
|
|
78 |
* keywords: array containing keywords
|
|
79 |
* highlight: array containing arrays, each with two values - string to highlight, and HTML class to apply to highlight */
|
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
80 |
function showfile($interestingrows,$keywords,$highlight,$filename) { |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
81 |
echo "<pre>"; |
82 |
$handle = @fopen($filename, "r"); |
|
83 |
if ($handle) { |
|
84 |
||
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
85 |
$lineno = 1; |
86 |
$commentkind = 0; |
|
87 |
$commenton = 0; |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
88 |
|
89 |
while (($buffer = fgets($handle, 4096)) !== false) { |
|
90 |
$buffer = str_replace("\n","", $buffer); |
|
91 |
$buffer = str_replace("\r","", $buffer); |
|
92 |
$buffer=str_pad($buffer,150," ", STR_PAD_RIGHT); |
|
93 |
$buffer=str_replace("&","&",$buffer); |
|
94 |
$buffer=str_replace("<","<",$buffer); |
|
95 |
$buffer=str_replace(">",">",$buffer); |
|
96 |
$buffer=str_replace("\t"," ",$buffer); |
|
97 |
||
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
98 |
$interesting = 0; |
99 |
$startspan = 0; |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
100 |
foreach($interestingrows as $row){ |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
101 |
if($lineno >= $row[0] && $lineno <= $row[1]){ |
102 |
$interesting = true; |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
103 |
}
|
104 |
}
|
|
105 |
||
106 |
foreach($keywords as $keyword){ |
|
107 |
if($interesting){ |
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
108 |
$buffer = str_replace($keyword,"<span class='keywordinteresting'>".$keyword."</span>", $buffer); |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
109 |
}else{ |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
110 |
$buffer = str_replace($keyword,"<span class='keyword'>".$keyword."</span>", $buffer); |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
111 |
}
|
112 |
}
|
|
113 |
||
114 |
// Detect comments - 0 == No comment 1 == Line comment 2 == Start Comment 3 == End Comment
|
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
115 |
$commentkind = 0; |
116 |
$commentpos = strpos($buffer,"/*"); |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
117 |
|
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
118 |
if($commentpos >= 0){ |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
119 |
$subby = substr($buffer,$commentpos+2,1); |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
120 |
}else{ |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
121 |
$subby = "Foo"; |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
122 |
}
|
123 |
||
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
124 |
if($commentpos && $subby != '"'){ |
125 |
$commentkind = 2; |
|
126 |
$commenton = 1; |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
127 |
}
|
128 |
||
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
129 |
$commentpos = strpos($buffer,"*/"); |
130 |
||
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
131 |
if($commentpos){ |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
132 |
$commentkind = 3; |
133 |
$commenton = 0; |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
134 |
}
|
135 |
||
136 |
$commentpos=strpos($buffer,"//"); |
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
137 |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
138 |
if($commentpos){ |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
139 |
$commentkind = 1; |
140 |
$commenton = 0; |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
141 |
}
|
142 |
||
143 |
foreach($highlight as $highlightkeyword){ |
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
144 |
$foundpos = strpos($buffer, $highlightkeyword[0]); |
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
145 |
|
146 |
// If line comment and keyword before comment marker
|
|
4.9.5
by elof.bigestans at gmail
Added comments to functions in showcode.php |
147 |
if(($foundpos <= $commentpos && ($commentkind == 1 || $commentkind == 2)) || ($commentkind == 0) || ($foundpos > $commentpos && $commentkind == 3)) { |
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
148 |
if(!($commentkind==0&&$commenton==1)) { |
149 |
$buffer = str_replace($highlightkeyword[0],"<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>",$buffer); |
|
150 |
}
|
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
151 |
}
|
152 |
||
153 |
}
|
|
154 |
||
155 |
// echo $commentkind.$commenton;
|
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
156 |
if($commentkind > 0){ |
157 |
if($commentkind == 1){ |
|
158 |
$buffer = str_replace("//","<span class='commented'>//",$buffer); |
|
159 |
$buffer .= "</span>"; |
|
160 |
}
|
|
161 |
if($commentkind==2) { |
|
162 |
$buffer=str_replace("/*","<span class='commented'>/*",$buffer); |
|
163 |
}
|
|
164 |
if($commentkind==3) { |
|
165 |
$buffer=str_replace("*/","*/</span>",$buffer); |
|
166 |
}
|
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
167 |
}
|
168 |
||
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
169 |
$linenostr = $lineno; |
170 |
$linenostr = str_pad($linenostr,3," ",STR_PAD_RIGHT); |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
171 |
|
172 |
if($interesting){ |
|
173 |
echo "<span class='interesting'>"; |
|
174 |
echo "<span class='linenointeresting'>".$linenostr."</span> "; |
|
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
175 |
$startspan = 1; |
176 |
} else { |
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
177 |
echo "<span class='lineno'>".$linenostr."</span> "; |
178 |
}
|
|
179 |
||
180 |
echo $buffer; |
|
181 |
||
4.9.4
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed spacing between operators and variable declarations |
182 |
if($startspan) { |
183 |
echo "</span>"; |
|
184 |
}
|
|
4.9.3
by elof.bigestans at gmail
Cleaned up showcode.php -- Fixed indendation, spacing |
185 |
|
186 |
$lineno++; |
|
187 |
echo "<br>"; |
|
188 |
}
|
|
189 |
if (!feof($handle)) { |
|
190 |
echo "Error: unexpected fgets() fail\n"; |
|
191 |
}
|
|
192 |
fclose($handle); |
|
193 |
}
|
|
194 |
echo "</pre>"; |
|
1
by Henrik G.
First seed of Lenasys ... Needs to be Organized Further |
195 |
}
|
196 |
?>
|