/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
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);
58.1.2 by a11patfr at his
First steps to working codeviewer, can now show all files.
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();
58.1.2 by a11patfr at his
First steps to working codeviewer, can now show all files.
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).'");
62.3.1 by a11patfr at his
Codeviewer work underway.
31
				editor.setTheme("ace/theme/eclipse");
58.1.2 by a11patfr at his
First steps to working codeviewer, can now show all files.
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);
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
52
			}
53
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
54
		}
55
58.1.2 by a11patfr at his
First steps to working codeviewer, can now show all files.
56
		return $outarr;
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
57
	}
58
58.1.2 by a11patfr at his
First steps to working codeviewer, can now show all files.
59
	/*
53.1.1 by galaxyAbstractor
fixed adminpanel and codeviewer a bit
60
	function getDoc($cid, $category, $subcategory, $example){
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
61
		$this->db->select('dataBlob');
39.2.1 by c11oscjo
Change attribute and table names according to the database.
62
		$this->db->from('Files');
53.1.1 by galaxyAbstractor
fixed adminpanel and codeviewer a bit
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");
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
69
70
		$query = $this->db->get();
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
71
		$result = $query->result();
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
72
		return $result[0]->dataBlob;
58.1.2 by a11patfr at his
First steps to working codeviewer, can now show all files.
73
	}*/
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
74
}