/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 codeigniter/application/models/codeviewer/codeviewer_model.php

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-30 12:08:07 UTC
  • mfrom: (129 lenasys_b)
  • mto: This revision was merged to the branch mainline in revision 131.
  • Revision ID: gustav.hartvigsson@gmail.com-20130530120807-q2mad1xrq003ss2n
mergedĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
                $this->load->database();
6
6
        }
7
7
 
8
 
        function getCode($cid, $example, $page) {
 
8
        function getCode($cid, $category, $subcategory, $example) {
9
9
 
10
10
                $this->db->from('Files');
11
 
                $this->db->join("PageFiles", "Pagefiles.fileName = Files.fileName");
12
 
                $this->db->where("PageFiles.pagesName", $page);
13
 
                $this->db->where("PageFiles.exampleName", $example);
14
 
                $this->db->where("PageFiles.courseID", $cid);
15
 
                $this->db->not_like("PageFiles.fileName", $cid."/".$example."/".$page."/"."documentation");
 
11
                $this->db->join("Containers", "Containers.fileName = Files.fileName");
 
12
                $this->db->where("Containers.categoryName", $category);
 
13
                $this->db->where("Containers.subcategoryName", $subcategory);
 
14
                $this->db->where("Containers.exampleName", $example);
 
15
                $this->db->where("Containers.courseID", $cid);
 
16
                //$this->db->not_like("Containers.fileName", $cid."/".$category."/".$subcategory."/".$example."/documentation");
16
17
 
17
18
                $query = $this->db->get();
18
 
                $output = "";
 
19
                $outarr = array();
 
20
                $column1 = 0;
 
21
                $column2 = 0;
19
22
                foreach ($query->result() as $row) {
20
 
                        $output .= '<div class="editorinfo">'.$row->language.'&nbsp;&nbsp;&nbsp;&nbsp;'.$row->fileName.'</div>';
21
 
                        $output .= '<div id="ace_'.str_replace(".", "", $row->fileName).'" class="ace">';
22
 
                        $output .= $row->dataBlob;
 
23
                        if ($row->columnNr == 1) $column1++;            
 
24
                        if ($row->columnNr == 2) $column2++;            
 
25
                }
 
26
                foreach ($query->result() as $row) { //creats array with array consisting of columnNr and code file.
 
27
                        $output = "";
 
28
                        if($row->columnNr == 1 && $column1 == 1 ) {
 
29
                                $output .= '<div class="singleColumn1">';
 
30
                        } else if($row->columnNr == 1 && $column1 == 2) {
 
31
                                $output .= '<div class="doubleColumn1">';
 
32
                        } else if($row->columnNr == 2 && $column2 == 1) {
 
33
                                $output .= '<div class="singleColumn2">';
 
34
                        } else if($row->columnNr == 2 && $column2 == 2) {
 
35
                                $output .= '<div class="doubleColumn2">';
 
36
                        } else if($row->columnNr == 2 && $column2 == 3) {
 
37
                                $output .= '<div class="tripleColumn2">';
 
38
                        } else {
 
39
                                $output .= '<div class="tripleColumn2">';
 
40
                        }
 
41
 
 
42
                        if($row->fileType == 'Code') {
 
43
                                $filename = $row->fileName;
 
44
                                $pieces = explode("/", $filename);
 
45
                                $filename = $pieces[4];
 
46
                                $output .= '<div class="editorinfo"><span class="codeLanguage">'.$row->codeLanguage.'</span><span class="codeFilename">'.$filename.'</span></div>';
 
47
                                $output .= '<div id="ace_'.str_replace(".", "", $row->fileName).'" class="ace">';
 
48
                                $output .= $row->dataBlob;
 
49
                                $output .= '</div>';
 
50
 
 
51
                                $output .= '<script type="text/javascript">
 
52
                                var Range = require("ace/range").Range;
 
53
                                var editor = ace.edit("ace_'.str_replace(".", "", $row->fileName).'");
 
54
                                editor.setTheme("ace/theme/eclipse");
 
55
                                editor.getSession().setMode("ace/mode/'.$row->codeLanguage.'");
 
56
                                editor.setReadOnly(true);
 
57
                                editor.setShowPrintMargin(false);
 
58
                                editor.setDisplayIndentGuides(false);
 
59
                                editor.setHighlightSelectedWord(true);
 
60
                                lines = editor.getSession().getLength();
 
61
                                $("#ace_'.str_replace(".", "", $row->fileName).'").height(Math.min(500,lines*16));
 
62
                                aceeditors.push("ace_'.str_replace(".", "", $row->fileName).'");';
 
63
 
 
64
                                /*
 
65
                                for($i = 0; $i < count($interestingrows); $i++) {
 
66
                                $output .= 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
 
67
                                        .$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
 
68
                                }
 
69
                                */
 
70
                                $output .= '</script>';
 
71
                        } else if($row->fileType == 'Text') {
 
72
                                $output .= '<div class="editorinfo"><span class="codeFilename">Description</span></div>';
 
73
                                $output .= '<div class="textContainer">';
 
74
                                $output .= $row->dataBlob;
 
75
                                $output .= '</div>';
 
76
                        }
23
77
                        $output .= '</div>';
24
 
 
25
 
                        $output .=  '<script type="text/javascript">
26
 
                        var Range = require("ace/range").Range;
27
 
                        var editor = ace.edit("ace_'.str_replace(".", "", $row->fileName).'");
28
 
                        editor.setTheme("ace/theme/merbivore");
29
 
                        editor.getSession().setMode("ace/mode/'.$row->language.'");
30
 
                        editor.setReadOnly(true);
31
 
                        editor.setShowPrintMargin(false);
32
 
                        editor.setDisplayIndentGuides(false);
33
 
                        editor.setHighlightSelectedWord(true);
34
 
                        lines = editor.getSession().getLength();
35
 
                        $("#ace_'.str_replace(".", "", $row->fileName).'").height(Math.min(500,lines*16));
36
 
                        aceeditors.push("ace_'.str_replace(".", "", $row->fileName).'");';
37
 
 
38
 
                        /*
39
 
                        for($i = 0; $i < count($interestingrows); $i++) {
40
 
                        $output .= 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
41
 
                                .$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
42
 
                        }
43
 
                        */
44
 
                        $output .= '</script>';
 
78
                        $outarr[] = array($row->columnNr,$output);
45
79
 
46
80
                }
47
81
 
48
 
                return $output;
 
82
                return $outarr;
49
83
        }
50
84
 
51
 
        function getDoc($cid, $example, $page){
 
85
        /*
 
86
        function getDoc($cid, $category, $subcategory, $example){
52
87
                $this->db->select('dataBlob');
53
88
                $this->db->from('Files');
54
 
                $this->db->join("PageFiles", "PageFiles.fileName = Files.fileName");
55
 
                $this->db->where("PageFiles.pageName", $page);
56
 
                $this->db->where("PageFiles.exampleName", $example);
57
 
                $this->db->where("PageFiles.courseID", $cid);
58
 
                $this->db->where("PageFiles.fileName", $cid."/".$example."/".$page."/"."documentation");
 
89
                $this->db->join("Containers", "Containers.fileName = Files.fileName");
 
90
                $this->db->where("Containers.categoryName", $category);
 
91
                $this->db->where("Containers.subcategoryName", $subcategory);
 
92
                $this->db->where("Containers.exampleName", $example);
 
93
                $this->db->where("Containers.courseID", $cid);
 
94
                $this->db->where("Containers.fileName", $cid."/".$category."/".$subcategory."/".$example."/"."documentation");
59
95
 
60
96
                $query = $this->db->get();
61
97
                $result = $query->result();
62
98
                return $result[0]->dataBlob;
63
 
        }
64
 
 
 
99
        }*/
65
100
}