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

  • Committer: c11emian
  • Date: 2013-04-03 12:27:12 UTC
  • mfrom: (9 lenasys)
  • mto: (9.2.2 lenasys)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: c11emian@student.his.se-20130403122712-ha93wrxm4isfv16h
Adjusted the file showcode.php so that it conforms to our code standard.

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) {
 
3
        function menulayout($forward, $backward, $downloadlink, $heading, $headinglink, $filecontent) {
4
4
                echo "<body onload='resize();' onresize='resize();'>";
5
5
                echo "<script language=\"javascript\" src=\"../jquery/jquery-1.8.2.min.js\"></script>";
6
6
 
17
17
                                                echo "</td>";
18
18
                                        }
19
19
                                        
20
 
                                        if($forward!="") {
 
20
                                        if($forward != "") {
21
21
                                                echo "<td class='buttonstyle'>";
22
22
                                                        echo "<a href='".$forward."'><img src='../img/next.png'></a>";
23
23
                                                echo "</td>";
57
57
                echo "</body>";
58
58
        }
59
59
 
60
 
        function showfile($interestingrows,$keywords,$highlight,$filename) {
 
60
        function showfile($interestingrows, $keywords, $highlight, $filename) {
61
61
                echo "<pre>";
62
62
                $handle = @fopen($filename, "r");
63
63
                if ($handle) {
64
 
                        $lineno=1;
 
64
                        $lineno = 1;
65
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);
 
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
72
 
73
 
                                $interesting=0;
74
 
                                $startspan=0;
 
73
                                $interesting = 0;
 
74
                                $startspan = 0;
75
75
                                foreach($interestingrows as $row) {
76
 
                                        if($lineno>=$row[0]&&$lineno <= $row[1]){
 
76
                                        if($lineno >= $row[0] && $lineno <= $row[1]){
77
77
                                                $interesting = true;
78
78
                                        }
79
79
                                }
80
80
 
81
81
                                foreach($keywords as $keyword) {
82
 
                                        if($interesting){
83
 
                                                $buffer=str_replace($keyword,"<span class='keywordinteresting'>".$keyword."</span>",$buffer);
 
82
                                        if($interesting) {
 
83
                                                $buffer = str_replace($keyword, "<span class='keywordinteresting'>".$keyword."</span>", $buffer);
84
84
                                        } else {
85
 
                                                $buffer=str_replace($keyword,"<span class='keyword'>".$keyword."</span>",$buffer);
 
85
                                                $buffer = str_replace($keyword, "<span class='keyword'>".$keyword."</span>", $buffer);
86
86
                                        }
87
87
                                }
88
88
 
89
 
                                $commentpos=strpos($buffer,"//");
 
89
                                $commentpos = strpos($buffer, "//");
90
90
                                if(!$commentpos) {
91
 
                                        $commentpos=5000;
 
91
                                        $commentpos = 5000;
92
92
                                }
93
93
                                foreach($highlight as $highlightkeyword) {
94
 
                                        $foundpos = strpos($buffer,$highlightkeyword[0]);
 
94
                                        $foundpos = strpos($buffer, $highlightkeyword[0]);
95
95
                                        if($foundpos <= $commentpos) {
96
 
                                                $buffer = str_replace($highlightkeyword[0],"<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>",$buffer);
 
96
                                                $buffer = str_replace($highlightkeyword[0], "<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>", $buffer);
97
97
                                        }
98
98
                                }
99
99
 
100
100
                                if($commentpos < 5000) {
101
 
                                        $buffer = str_replace("//","<span class='commented'>//",$buffer);
102
 
                                        $buffer.="</span>";
 
101
                                        $buffer = str_replace("//","<span class='commented'>//", $buffer);
 
102
                                        $buffer .= "</span>";
103
103
                                }
104
104
 
105
105
                                $linenostr = $lineno;
106
 
                                $linenostr = str_pad($linenostr,3," ",STR_PAD_RIGHT);
 
106
                                $linenostr = str_pad($linenostr, 3, " ", STR_PAD_RIGHT);
107
107
 
108
108
                                if($interesting) {
109
109
                                        echo "<span class='interesting'>";