/lenasys/trunk

To get this branch, use:
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
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
8
	function getCode($cid, $example, $page) {
9
10
		$this->db->from('files');
11
		$this->db->join("pagesfiles", "pagesfiles.Files_fileName = files.fileName");
12
		$this->db->where("pagesfiles.Pages_name", $page);
13
		$this->db->where("pagesfiles.Pages_Examples_Name", $example);
14
		$this->db->where("pagesfiles.Pages_Examples_Courses_courseID", $cid);
15
		$this->db->not_like("pagesfiles.Files_fileName", $cid."/".$example."/".$page."/"."documentation");
16
17
		$query = $this->db->get();
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
18
		$output = "";
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
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++) {
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
40
			$output .= 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
41
				.$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
42
			}
43
			*/
44
			$output .= '</script>';
45
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
46
		}
47
48
		return $output;
49
	}
50
51
	function getDoc($cid, $example, $page){
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
52
		$this->db->select('dataBlob');
53
		$this->db->from('files');
54
		$this->db->join("pagesfiles", "pagesfiles.Files_fileName = files.fileName");
55
		$this->db->where("pagesfiles.Pages_name", $page);
56
		$this->db->where("pagesfiles.Pages_Examples_Name", $example);
57
		$this->db->where("pagesfiles.Pages_Examples_Courses_courseID", $cid);
58
		$this->db->where("pagesfiles.Files_fileName", $cid."/".$example."/".$page."/"."documentation");
59
60
		$query = $this->db->get();
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
61
		$result = $query->result();
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
62
		return $result[0]->dataBlob;
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
63
	}
64
65
}