/lenasys/trunk

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

« back to all changes in this revision

Viewing changes to trunk/Code Viewer Alt/Codeviewer/showcode.php

  • Committer: elof.bigestans at gmail
  • Date: 2013-05-28 11:41:24 UTC
  • mto: This revision was merged to the branch mainline in revision 113.
  • Revision ID: elof.bigestans@gmail.com-20130528114124-d2x7abitteuess49
Reverted to old config files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
        function menulayout($forward,$backward,$downloadlink,$heading,$headinglink,$filecontent)
4
 
        {
5
 
                        echo "<body onload='resize();' onresize='resize();'>";
6
 
                        echo "<script language=\"javascript\" src=\"../jquery/jquery-1.8.2.min.js\"></script>";
7
 
 
8
 
                        echo "<div class='Topmenu'>";
9
 
                                echo "<table style='width:100%;height:100%;border:solid 1px;'>";
10
 
                        echo "<tr>";
11
 
                                echo "<td class='buttonstyle'>";
12
 
                                                echo "<a href='http://wwwlab.iki.his.se/~gush/Webbprogrammering/' title='Back to examples page'><img src='../img/back.png'></a>";
13
 
                                echo "</td>";
14
 
                        if($backward!=""){
15
 
                                echo "<td class='buttonstyle'>";
16
 
                                                echo "<a href='".$backward."'><img src='../img/prev.png'></a>";
17
 
                                echo "</td>";
18
 
                        }
19
 
 
20
 
                        if($forward!=""){
21
 
                                echo "<td class='buttonstyle'>";
22
 
                                                echo "<a href='".$forward."'><img src='../img/next.png'></a>";
23
 
                                echo "</td>";
24
 
                        }
25
 
 
26
 
                        echo "<td class='verticalaligntext'>";
27
 
                                echo "<a STYLE='text-decoration:none'>".$heading."</a>";
28
 
                        echo "</td>";
29
 
 
30
 
                        echo "<td class='buttonstyle'>";
31
 
                                echo "<a href=\"$headinglink\"><img src='../img/play.png'></a>";
32
 
                        echo "</td>";
33
 
 
34
 
                        echo "<td class='buttonstyle'>";
35
 
                                echo "<img src='../img/code.png' onclick=\"$('.lineno').toggle();$('.linenointeresting').toggle();$('.panel').toggle();\">";
36
 
                        echo "</td>";
37
 
 
38
 
                        echo "</tr>";
39
 
                        echo "</table>";
40
 
 
41
 
                        echo "</div>";
42
 
 
43
 
                        echo "<div id='bottom' class='RestContainer'>";
44
 
 
45
 
                        echo "<div style='float:left;'>";
46
 
                                        echo "<div id='panel' class='panel' onmousemove='resizepanel(event)' onmousedown='mdpanel(event)' onmouseup='mupanel(event)'>";
47
 
 
48
 
                                        include($filecontent);
49
 
                        
50
 
                                        echo "</div>";
51
 
                        echo "</div>";
52
 
                        echo "<div class='codecontent'>";
53
 
        }
54
 
 
55
 
        function menulayoutend()
56
 
        {
57
 
                echo "</div>";
58
 
                echo "</div>";
59
 
                echo "<div style='clear:both;'></div>";
60
 
                echo "</body>";
61
 
        }
62
 
 
63
 
        function showfile($interestingrows,$keywords,$highlight,$filename)
64
 
        {
65
 
                        echo "<pre>";
66
 
                        $handle = @fopen($filename, "r");
67
 
                        if ($handle) {
68
 
                                        $lineno=1;
69
 
                            while (($buffer = fgets($handle, 4096)) !== false) {
70
 
                                                        $buffer = str_replace("\n","", $buffer);
71
 
                                                        $buffer = str_replace("\r","", $buffer);
72
 
                                                        $buffer=str_pad($buffer,150," ", STR_PAD_RIGHT);
73
 
                                $buffer=str_replace("<","&lt;",$buffer);
74
 
                                $buffer=str_replace(">","&gt;",$buffer);
75
 
                                $buffer=str_replace("\t","&nbsp;",$buffer);
76
 
                                                                
77
 
                                                        $interesting=0;
78
 
                                $startspan=0;
79
 
                                foreach($interestingrows as $row){
80
 
                                                if($lineno>=$row[0]&&$lineno<=$row[1]){
81
 
                                                                                                $interesting=true;
82
 
                                                }
83
 
                                }
84
 
 
85
 
                                foreach($keywords as $keyword){
86
 
                                                                        if($interesting){
87
 
                                                                                        $buffer=str_replace($keyword,"<span class='keywordinteresting'>".$keyword."</span>",$buffer);
88
 
                                                                        }else{
89
 
                                                                                        $buffer=str_replace($keyword,"<span class='keyword'>".$keyword."</span>",$buffer);
90
 
                                                                        }
91
 
                                }
92
 
                                
93
 
                                                        $commentpos=strpos($buffer,"//");
94
 
                                                        if(!$commentpos) $commentpos=5000;
95
 
                                foreach($highlight as $highlightkeyword){
96
 
                                                                                $foundpos=strpos($buffer,$highlightkeyword[0]);
97
 
                                                                                if($foundpos<=$commentpos){
98
 
                                                                                         $buffer=str_replace($highlightkeyword[0],"<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>",$buffer);
99
 
                                                                                }
100
 
                                }
101
 
                                
102
 
                                if($commentpos<5000){
103
 
                                                                        $buffer=str_replace("//","<span class='commented'>//",$buffer);
104
 
                                                                        $buffer.="</span>";
105
 
                                }
106
 
                        
107
 
                                                        $linenostr=$lineno;
108
 
                                                        $linenostr=str_pad($linenostr,3," ",STR_PAD_RIGHT);
109
 
                        
110
 
                                                        if($interesting){
111
 
                                                    echo "<span class='interesting'>";
112
 
                                                    echo "<span class='linenointeresting'>".$linenostr."</span>&nbsp;";
113
 
                                                        $startspan=1;
114
 
                                                        }else{
115
 
                                                    echo "<span class='lineno'>".$linenostr."</span>&nbsp;";                            
116
 
                                                        }
117
 
                        
118
 
                                        echo $buffer;
119
 
                        
120
 
                                                        if($startspan) echo "</span>";
121
 
                        
122
 
                                $lineno++;
123
 
 
124
 
                                echo "<br>";
125
 
                            }
126
 
                            if (!feof($handle)) {
127
 
                                echo "Error: unexpected fgets() fail\n";
128
 
                            }
129
 
                            fclose($handle);
130
 
                        }
131
 
                        echo "</pre>";  
132
 
        }
133
 
?>