bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
|
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
1 |
<?php
|
2 |
class Codeviewer_model extends CI_Model { |
|
3 |
||
4 |
function __construct(){ |
|
5 |
$this->load->database(); |
|
6 |
}
|
|
7 |
||
|
53.1.1
by galaxyAbstractor
fixed adminpanel and codeviewer a bit |
8 |
function getCode($cid, $category, $subcategory, $example) { |
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
9 |
|
|
39.2.1
by c11oscjo
Change attribute and table names according to the database. |
10 |
$this->db->from('Files'); |
|
53.1.1
by galaxyAbstractor
fixed adminpanel and codeviewer a bit |
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"); |
|
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
17 |
|
18 |
$query = $this->db->get(); |
|
|
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
19 |
$output = ""; |
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
20 |
foreach ($query->result() as $row) { |
|
53.1.1
by galaxyAbstractor
fixed adminpanel and codeviewer a bit |
21 |
$output .= '<div class="editorinfo">'.$row->codeLanguage.' '.$row->fileName.'</div>'; |
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
22 |
$output .= '<div id="ace_'.str_replace(".", "", $row->fileName).'" class="ace">'; |
23 |
$output .= $row->dataBlob; |
|
24 |
$output .= '</div>'; |
|
25 |
||
26 |
$output .= '<script type="text/javascript"> |
|
27 |
var Range = require("ace/range").Range;
|
|
28 |
var editor = ace.edit("ace_'.str_replace(".", "", $row->fileName).'"); |
|
29 |
editor.setTheme("ace/theme/merbivore");
|
|
|
53.1.1
by galaxyAbstractor
fixed adminpanel and codeviewer a bit |
30 |
editor.getSession().setMode("ace/mode/'.$row->codeLanguage.'"); |
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
31 |
editor.setReadOnly(true);
|
32 |
editor.setShowPrintMargin(false);
|
|
33 |
editor.setDisplayIndentGuides(false);
|
|
34 |
editor.setHighlightSelectedWord(true);
|
|
35 |
lines = editor.getSession().getLength();
|
|
36 |
$("#ace_'.str_replace(".", "", $row->fileName).'").height(Math.min(500,lines*16)); |
|
37 |
aceeditors.push("ace_'.str_replace(".", "", $row->fileName).'");'; |
|
38 |
||
39 |
/*
|
|
40 |
for($i = 0; $i < count($interestingrows); $i++) {
|
|
|
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
41 |
$output .= 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
|
42 |
.$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
|
|
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
43 |
}
|
44 |
*/
|
|
45 |
$output .= '</script>'; |
|
46 |
||
|
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
47 |
}
|
48 |
||
49 |
return $output; |
|
50 |
}
|
|
51 |
||
|
53.1.1
by galaxyAbstractor
fixed adminpanel and codeviewer a bit |
52 |
function getDoc($cid, $category, $subcategory, $example){ |
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
53 |
$this->db->select('dataBlob'); |
|
39.2.1
by c11oscjo
Change attribute and table names according to the database. |
54 |
$this->db->from('Files'); |
|
53.1.1
by galaxyAbstractor
fixed adminpanel and codeviewer a bit |
55 |
$this->db->join("Containers", "Containers.fileName = Files.fileName"); |
56 |
$this->db->where("Containers.categoryName", $category); |
|
57 |
$this->db->where("Containers.subcategoryName", $subcategory); |
|
58 |
$this->db->where("Containers.exampleName", $example); |
|
59 |
$this->db->where("Containers.courseID", $cid); |
|
60 |
$this->db->where("Containers.fileName", $cid."/".$category."/".$subcategory."/".$example."/"."documentation"); |
|
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
61 |
|
62 |
$query = $this->db->get(); |
|
|
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
63 |
$result = $query->result(); |
|
23.1.2
by galaxyAbstractor
Fixed database stuff, added files to database. |
64 |
return $result[0]->dataBlob; |
|
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
65 |
}
|
66 |
||
67 |
}
|