/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-14 13:35:58 UTC
  • mfrom: (62.3.1 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130514133558-2d4q9xzjvt8uay6h
Merged Franssons changes to the codeviewer.
And Resolved some wierd conflicts that chould not have been there....

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
 
                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
 
                        $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);';
 
19
                $outarr = array();
 
20
                foreach ($query->result() as $row) { //creats array with array consisting of columnNr and code file.
 
21
                        $output = "";
 
22
                        if($row->fileType == 'Code') {
 
23
                                $output .= '<div class="editorinfo">'.$row->codeLanguage.'&nbsp;&nbsp;&nbsp;&nbsp;'.$row->fileName.'</div>';
 
24
                                $output .= '<div id="ace_'.str_replace(".", "", $row->fileName).'" class="ace">';
 
25
                                $output .= $row->dataBlob;
 
26
                                $output .= '</div>';
 
27
 
 
28
                                $output .=  '<script type="text/javascript">
 
29
                                var Range = require("ace/range").Range;
 
30
                                var editor = ace.edit("ace_'.str_replace(".", "", $row->fileName).'");
 
31
                                editor.setTheme("ace/theme/eclipse");
 
32
                                editor.getSession().setMode("ace/mode/'.$row->codeLanguage.'");
 
33
                                editor.setReadOnly(true);
 
34
                                editor.setShowPrintMargin(false);
 
35
                                editor.setDisplayIndentGuides(false);
 
36
                                editor.setHighlightSelectedWord(true);
 
37
                                lines = editor.getSession().getLength();
 
38
                                $("#ace_'.str_replace(".", "", $row->fileName).'").height(Math.min(500,lines*16));
 
39
                                aceeditors.push("ace_'.str_replace(".", "", $row->fileName).'");';
 
40
 
 
41
                                /*
 
42
                                for($i = 0; $i < count($interestingrows); $i++) {
 
43
                                $output .= 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
 
44
                                        .$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
 
45
                                }
 
46
                                */
 
47
                                $output .= '</script>';
 
48
                                $outarr[] = array($row->columnNr,$output);
 
49
                        } else if($row->fileType == 'Text') {
 
50
                                $output .= $row->dataBlob;
 
51
                                $outarr[] = array($row->columnNr,$output);
42
52
                        }
43
 
                        */
44
 
                        $output .= '</script>';
45
53
 
46
54
                }
47
55
 
48
 
                return $output;
 
56
                return $outarr;
49
57
        }
50
58
 
51
 
        function getDoc($cid, $example, $page){
 
59
        /*
 
60
        function getDoc($cid, $category, $subcategory, $example){
52
61
                $this->db->select('dataBlob');
53
62
                $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");
 
63
                $this->db->join("Containers", "Containers.fileName = Files.fileName");
 
64
                $this->db->where("Containers.categoryName", $category);
 
65
                $this->db->where("Containers.subcategoryName", $subcategory);
 
66
                $this->db->where("Containers.exampleName", $example);
 
67
                $this->db->where("Containers.courseID", $cid);
 
68
                $this->db->where("Containers.fileName", $cid."/".$category."/".$subcategory."/".$example."/"."documentation");
59
69
 
60
70
                $query = $this->db->get();
61
71
                $result = $query->result();
62
72
                return $result[0]->dataBlob;
63
 
        }
64
 
 
 
73
        }*/
65
74
}