/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/Code Viewer Alt/Codeviewer/showcode.php

  • Committer: gustav.hartvigsson at gmail
  • Date: 2013-04-02 12:13:01 UTC
  • mfrom: (4.2.7 hitlerhorabajs)
  • Revision ID: gustav.hartvigsson@gmail.com-20130402121301-ytfzuo7y6cku9s3o
Merge from implemenation group 2:s branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
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>";
 
3
        function menulayout($forward,$backward,$downloadlink,$heading,$headinglink,$filecontent) {
 
4
                echo "<body onload='resize();' onresize='resize();'>";
 
5
                echo "<script language=\"javascript\" src=\"../jquery/jquery-1.8.2.min.js\"></script>";
7
6
 
8
 
                        echo "<div class='Topmenu'>";
9
 
                                echo "<table style='width:100%;height:100%;border:solid 1px;'>";
10
 
                        echo "<tr>";
11
 
                                echo "<td class='buttonstyle'>";
 
7
                echo "<div class='Topmenu'>";
 
8
                        echo "<table style='width:100%;height:100%;border:solid 1px;'>";
 
9
                                echo "<tr>";
 
10
                                        echo "<td class='buttonstyle'>";
12
11
                                                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>";
 
12
                                        echo "</td>";
 
13
                                        
 
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
39
                        echo "</table>";
40
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'>";
 
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
                        include($filecontent);
 
48
                echo "</div>";
 
49
                echo "</div>";
 
50
                echo "<div class='codecontent'>";
53
51
        }
54
52
 
55
 
        function menulayoutend()
56
 
        {
 
53
        function menulayoutend() {
57
54
                echo "</div>";
58
55
                echo "</div>";
59
56
                echo "<div style='clear:both;'></div>";
60
57
                echo "</body>";
61
58
        }
62
59
 
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>";  
 
60
        function showfile($interestingrows,$keywords,$highlight,$filename) {
 
61
                echo "<pre>";
 
62
                $handle = @fopen($filename, "r");
 
63
                if ($handle) {
 
64
                        $lineno=1;
 
65
                        while (($buffer = fgets($handle, 4096)) !== false) {
 
66
                                $buffer = str_replace("\n","", $buffer);
 
67
                                $buffer = str_replace("\r","", $buffer);
 
68
                                $buffer=str_pad($buffer,150," ", STR_PAD_RIGHT);
 
69
                                $buffer=str_replace("<","&lt;",$buffer);
 
70
                                $buffer=str_replace(">","&gt;",$buffer);
 
71
                                $buffer=str_replace("\t","&nbsp;",$buffer);
 
72
 
 
73
                                $interesting=0;
 
74
                                $startspan=0;
 
75
                                foreach($interestingrows as $row) {
 
76
                                        if($lineno>=$row[0]&&$lineno <= $row[1]){
 
77
                                                $interesting = true;
 
78
                                        }
 
79
                                }
 
80
 
 
81
                                foreach($keywords as $keyword) {
 
82
                                        if($interesting){
 
83
                                                $buffer=str_replace($keyword,"<span class='keywordinteresting'>".$keyword."</span>",$buffer);
 
84
                                        } else {
 
85
                                                $buffer=str_replace($keyword,"<span class='keyword'>".$keyword."</span>",$buffer);
 
86
                                        }
 
87
                                }
 
88
 
 
89
                                $commentpos=strpos($buffer,"//");
 
90
                                if(!$commentpos) {
 
91
                                        $commentpos=5000;
 
92
                                }
 
93
                                foreach($highlight as $highlightkeyword) {
 
94
                                        $foundpos = strpos($buffer,$highlightkeyword[0]);
 
95
                                        if($foundpos <= $commentpos) {
 
96
                                                $buffer = str_replace($highlightkeyword[0],"<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>",$buffer);
 
97
                                        }
 
98
                                }
 
99
 
 
100
                                if($commentpos < 5000) {
 
101
                                        $buffer = str_replace("//","<span class='commented'>//",$buffer);
 
102
                                        $buffer.="</span>";
 
103
                                }
 
104
 
 
105
                                $linenostr = $lineno;
 
106
                                $linenostr = str_pad($linenostr,3," ",STR_PAD_RIGHT);
 
107
 
 
108
                                if($interesting) {
 
109
                                        echo "<span class='interesting'>";
 
110
                                        echo "<span class='linenointeresting'>".$linenostr."</span>&nbsp;";
 
111
                                        $startspan = 1;
 
112
                                } else {
 
113
                                        echo "<span class='lineno'>".$linenostr."</span>&nbsp;";                                
 
114
                                }
 
115
 
 
116
                                echo $buffer;
 
117
 
 
118
                                if($startspan) {
 
119
                                        echo "</span>";
 
120
                                }
 
121
                                $lineno++;
 
122
 
 
123
                                echo "<br>";
 
124
                        }
 
125
                        if (!feof($handle)) {
 
126
                                echo "Error: unexpected fgets() fail\n";
 
127
                        }
 
128
                        fclose($handle);
 
129
                }
 
130
                echo "</pre>";  
132
131
        }
133
132
?>