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