5
5
$this->load->database();
8
function getCode($cid, $example, $page) {
8
function getCode($cid, $category, $subcategory, $example) {
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");
17
18
$query = $this->db->get();
19
22
foreach ($query->result() as $row) {
20
$output .= '<div class="editorinfo">'.$row->language.' '.$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++;
26
foreach ($query->result() as $row) { //creats array with array consisting of columnNr and code file.
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">';
39
$output .= '<div class="tripleColumn2">';
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;
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).'");';
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);';
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;
23
77
$output .= '</div>';
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).'");';
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);';
44
$output .= '</script>';
78
$outarr[] = array($row->columnNr,$output);
51
function getDoc($cid, $example, $page){
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");
60
96
$query = $this->db->get();
61
97
$result = $query->result();
62
98
return $result[0]->dataBlob;