3
* Takes 6 arguments and outputs a HTML navigation menu
4
* $forwardLink = link to "next page", i.e. "nextPage.html"
5
* $backwardLink = 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"
10
function menulayout($forwardLink, $backwardLink, $downloadLink, $heading, $headingLink, $fileContent) {
11
if($backwardLink != "") {
12
$backwardButton = "<a href='".$backwardLink."'><img src='../media/codeviewer/CodeViewerLeftbutton.png'></a>";
14
$backwardButton = "<img src='../media/codeviewer/CodeViewerLeftbuttonGrayed.png'>";
17
if($forwardLink != "") {
18
$forwardButton = "<a href='".$forwardLink."'><img src='../media/codeviewer/CodeViewerRightbutton.png'></a>";
20
$forwardButton = "<img src='../media/codeviewer/CodeViewerLeftbuttonGrayed.png'>";
23
if($downloadLink != "") {
24
$downloadButton = "<a href='".$downloadLink."'><img src='../media/codeviewer/CodeViewerDownloadbutton.png'></a>";
26
$downloadButton = "<img src='../media/codeviewer/CodeViewerLeftbuttonGrayed.png'>";
29
echo '<body onload="resize();" onresize="resize();">
31
<table style="width:100%;height:100%;border:solid 1px;">
33
<td class="buttonstyle">
36
<td class="buttonstyle">
39
<td class="buttonstyle">
40
<a href="../Lindex.html"><img src="../media/codeviewer/CodeViewerRightbutton.png"></a>
42
<td class="verticalaligntext">
43
<a href="'. $headingLink .'" style="text-decoration: none">'. $heading .'</a>
45
<td class="buttonstyle">
51
<div id="bottom" class="restContainer">
52
<div style="float: left;">
53
<div id="panel" class="panel" onmousemove="resizepanel(event)" onmousedown="mdpanel(event)" onmouseup="mupanel(event)">';
54
include($fileContent);
57
<div class="codecontent">';
60
/* function menulayoutend
61
* Outputs ending tags in HTML
63
function menulayoutEnd() {
66
<div style="clear: both;">
72
* Outputs html with syntax highlighting.
74
* interestingRows: array containing arrays, each with 3 set values -- start line number, end line number, comment
75
* keywords: array containing keywords
76
* highlight: array containing arrays, each with two values - string to highlight, and HTML class to apply to highlight */
77
function showfile($interestingRows, $keywords, $highlight, $fileName) {
79
$handle = @fopen($fileName, "r");
86
while (($buffer = fgets($handle, 4096)) !== false) {
87
$buffer = str_replace("\n", "", $buffer);
88
$buffer = str_replace("\r", "", $buffer);
89
$buffer = str_pad($buffer, 150, " ", STR_PAD_RIGHT);
90
$buffer = str_replace("&", "&", $buffer);
91
$buffer = str_replace("<", "<", $buffer);
92
$buffer = str_replace(">", ">", $buffer);
93
$buffer = str_replace("\t", " ", $buffer);
97
foreach($interestingRows as $row) {
98
if($lineNumber >= $row[0] && $lineNumber <= $row[1]) {
103
foreach($keywords as $keyword) {
105
$buffer = str_replace($keyword,"<span class='keywordinteresting'>".$keyword."</span>", $buffer);
107
$buffer = str_replace($keyword,"<span class='keyword'>".$keyword."</span>", $buffer);
111
// Detect comments - 0 == No comment 1 == Line comment 2 == Start Comment 3 == End Comment
113
$commentPos = strpos($buffer,"/*");
115
if($commentPos >= 0) {
116
$subby = substr($buffer, $commentPos+2, 1);
121
if($commentPos && $subby != '"') {
126
$commentPos = strpos($buffer, "*/");
133
$commentPos=strpos($buffer, "//");
140
foreach($highlight as $highlightkeyword) {
141
$foundpos = strpos($buffer, $highlightkeyword[0]);
143
// If line comment and keyword before comment marker
144
if(($foundpos <= $commentPos && ($commentKind == 1 || $commentKind == 2)) || ($commentKind == 0) || ($foundpos > $commentPos && $commentKind == 3)) {
145
if(!($commentKind == 0 && $commentOn == 1)) {
146
$buffer = str_replace($highlightkeyword[0], "<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>", $buffer);
152
// echo $commentKind.$commentOn;
153
if($commentKind > 0) {
154
if($commentKind == 1) {
155
$buffer = str_replace("//","<span class='commented'>//", $buffer);
156
$buffer .= "</span>";
158
if($commentKind == 2) {
159
$buffer=str_replace("/*","<span class='commented'>/*", $buffer);
161
if($commentKind == 3) {
162
$buffer=str_replace("*/","*/</span>", $buffer);
166
$linenostr = $lineNumber;
167
$linenostr = str_pad($linenostr, 3, " ", STR_PAD_RIGHT);
170
echo "<span class='interesting'>";
171
echo "<span class='linenointeresting'>".$linenostr."</span> ";
174
echo "<span class='lineno'>".$linenostr."</span> ";
186
if (!feof($handle)) {
187
echo "Error: unexpected fgets() fail\n";
b'\\ No newline at end of file'