/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 15:01:26 UTC
  • mto: (4.7.4 GammaBear)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: elof.bigestans@gmail.com-20130328150126-o79po5zzefzxvcxy
Added comments to functions in showcode.php

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
 
2
        /* function menulayout
 
3
         * Takes 6 arguments and outputs a HTML navigation menu 
 
4
         * $forward = link to "next page", i.e. "nextPage.html"
 
5
         * $backward = 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"
 
9
        */
2
10
        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
11
                if($backward != ""){
10
 
                        echo "<a href='".$backward."'><img src='CodeViewerLeftbutton.png'></a>";
 
12
                        $backwardButton = "<a href='".$backward."'><img src='CodeViewerLeftbutton.png'></a>";
11
13
                }else{
12
 
                        echo "<img src='CodeViewerLeftbuttonGrayed.png'>";
 
14
                        $backwardButton = "<img src='CodeViewerLeftbuttonGrayed.png'>";
13
15
                }
14
16
 
 
17
                ?>
 
18
                <body onload='resize();' onresize='resize();'>
 
19
                        <div class='Topmenu'>
 
20
                                <table style='width:100%;height:100%;border:solid 1px;'>
 
21
                                        <tr>
 
22
                                                <td class="buttonstyle">
 
23
                                                        <?=$backwardButton;?>
 
24
                                                </td>
 
25
                <?php
15
26
                echo "</td>";
16
27
                echo "<td class='buttonstyle'>";
17
28
 
50
61
                echo "<div class='codecontent'>";
51
62
        }
52
63
 
 
64
        /* function menulayoutend
 
65
         * Outputs ending tags in HTML
 
66
         */
53
67
        function menulayoutend() {
54
68
                echo "</div>";
55
69
                echo "</div>";
57
71
                echo "</body>";
58
72
        }
59
73
 
 
74
        /* function showfile 
 
75
         * Outputs html with syntax highlighting.
 
76
         * Takes 4 arguments_
 
77
         * interestingrows: array containing arrays, each with 3 set values -- start line number, end line number, comment
 
78
         * keywords: array containing keywords 
 
79
         * highlight: array containing arrays, each with two values - string to highlight, and HTML class to apply to highlight */
60
80
        function showfile($interestingrows,$keywords,$highlight,$filename) {
61
81
                echo "<pre>";
62
82
                $handle = @fopen($filename, "r");
95
115
                                $commentkind = 0;
96
116
                                $commentpos = strpos($buffer,"/*");
97
117
 
98
 
                                if($commentpos>=0){
 
118
                                if($commentpos >= 0){
99
119
                                        $subby = substr($buffer,$commentpos+2,1);
100
120
                                }else{
101
121
                                        $subby = "Foo";
124
144
                                        $foundpos = strpos($buffer, $highlightkeyword[0]);
125
145
 
126
146
                                        // If line comment and keyword before comment marker
127
 
                                        if(($foundpos<=$commentpos&&($commentkind==1||$commentkind==2))||($commentkind==0)||($foundpos>$commentpos&&$commentkind==3)){
 
147
                                        if(($foundpos <= $commentpos && ($commentkind == 1 || $commentkind == 2)) || ($commentkind == 0) || ($foundpos > $commentpos && $commentkind == 3)) {
128
148
                                                if(!($commentkind==0&&$commenton==1)) {
129
149
                                                        $buffer = str_replace($highlightkeyword[0],"<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>",$buffer);
130
150
                                                }