/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1

« back to all changes in this revision

Viewing changes to trunk/CodeViewer/Codeviewer/showcode.php

  • Committer: elof.bigestans at gmail
  • Date: 2013-03-28 13:42:03 UTC
  • mto: (4.7.4 GammaBear)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: elof.bigestans@gmail.com-20130328134203-3mk8qf61nam823hi
Cleaned up showcode.php -- Fixed indendation, spacing

Show diffs side-by-side

added added

removed removed

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