/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
class Codeviewer_model extends CI_Model {

	function __construct(){
		$this->load->database();
	}

	function getCode($cid, $example, $page) {

		$this->db->from('Files');
		$this->db->join("PageFiles", "Pagefiles.fileName = Files.fileName");
		$this->db->where("PageFiles.pagesName", $page);
		$this->db->where("PageFiles.exampleName", $example);
		$this->db->where("PageFiles.courseID", $cid);
		$this->db->not_like("PageFiles.fileName", $cid."/".$example."/".$page."/"."documentation");

		$query = $this->db->get();
		$output = "";
		foreach ($query->result() as $row) {
			$output .= '<div class="editorinfo">'.$row->language.'&nbsp;&nbsp;&nbsp;&nbsp;'.$row->fileName.'</div>';
			$output .= '<div id="ace_'.str_replace(".", "", $row->fileName).'" class="ace">';
			$output .= $row->dataBlob;
			$output .= '</div>';

			$output .=  '<script type="text/javascript">
			var Range = require("ace/range").Range;
			var editor = ace.edit("ace_'.str_replace(".", "", $row->fileName).'");
			editor.setTheme("ace/theme/merbivore");
			editor.getSession().setMode("ace/mode/'.$row->language.'");
			editor.setReadOnly(true);
			editor.setShowPrintMargin(false);
			editor.setDisplayIndentGuides(false);
			editor.setHighlightSelectedWord(true);
			lines = editor.getSession().getLength();
			$("#ace_'.str_replace(".", "", $row->fileName).'").height(Math.min(500,lines*16));
			aceeditors.push("ace_'.str_replace(".", "", $row->fileName).'");';

			/*
			for($i = 0; $i < count($interestingrows); $i++) {
			$output .= 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
				.$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
			}
			*/
			$output .= '</script>';

		}

		return $output;
	}

	function getDoc($cid, $example, $page){
		$this->db->select('dataBlob');
		$this->db->from('Files');
		$this->db->join("PageFiles", "PageFiles.fileName = Files.fileName");
		$this->db->where("PageFiles.pageName", $page);
		$this->db->where("PageFiles.exampleName", $example);
		$this->db->where("PageFiles.courseID", $cid);
		$this->db->where("PageFiles.fileName", $cid."/".$example."/".$page."/"."documentation");

		$query = $this->db->get();
		$result = $query->result();
		return $result[0]->dataBlob;
	}

}