/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: b11johgu
  • Date: 2013-05-14 12:30:38 UTC
  • mto: This revision was merged to the branch mainline in revision 65.
  • Revision ID: b11johgu@student.his.se-20130514123038-rthxj3f34o32gpxy
ExamplesController:
- Added expand/collapse arrows for categories/subcategories.
- Added category positioning (incomplete).

more general changes made.

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, $category, $subcategory, $example) {
 
8
        function getCode($cid, $example, $page) {
9
9
 
10
10
                $this->db->from('Files');
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");
 
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");
17
16
 
18
17
                $query = $this->db->get();
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/merbivore");
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);
 
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);';
52
42
                        }
 
43
                        */
 
44
                        $output .= '</script>';
53
45
 
54
46
                }
55
47
 
56
 
                return $outarr;
 
48
                return $output;
57
49
        }
58
50
 
59
 
        /*
60
 
        function getDoc($cid, $category, $subcategory, $example){
 
51
        function getDoc($cid, $example, $page){
61
52
                $this->db->select('dataBlob');
62
53
                $this->db->from('Files');
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");
 
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");
69
59
 
70
60
                $query = $this->db->get();
71
61
                $result = $query->result();
72
62
                return $result[0]->dataBlob;
73
 
        }*/
 
63
        }
 
64
 
74
65
}