/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
<?php
/**
* This is a controller. It links the views related to the codeviewer together with the model, which holds
* the logic.  
*
* Function names equals path. Example: codeviewer/show in the url calls the function show in the controller
* codeviewer (this file below).
*
* The params after the url equals the input arguments of the function. Function show() has 3 arguments
* and therefore requires 3 arguments to be given in the url, like so: codeviewer/show/courseid/exampleid/pageid
*/
class Codeviewer extends CI_Controller {

	/**
	* This shows the codeviewer page
	*/
	public function show($cid, $category, $subcategory, $example){
		$headTagData['cssFiles'] = array('headTag', 'header', 'codeviewer');
		$headTagData['jsFiles'] = array('ace/ace', 'header');
	
		$this->load->model('codeviewer/Codeviewer_model');

		$editorHTML = $this->Codeviewer_model->getCode($cid, $category, $subcategory, $example);
	
		$this->load->model('user');
		
		$userInfo = array(
			'userType' => $this->user->getUserType(),
			'userName' => $this->user->getUserName()
		);
		
		$this->load->helper('form');
		
		// $doc = $this->Codeviewer_model->getDoc($cid, $category, $subcategory, $example);

		// This loads the view. It's stored in application/views/codeviewer/codeviewer.php
		// Do note that application/views should not be in the first argument of view()
		// The second argument is data to be shown in the view. "editors" => "test" would
		// generate an $editors variable in the view containing "test"
		$this->load->view('headTag', array('headTagData' => $headTagData));
		$this->load->view('header', $userInfo);
		$this->load->view('codeviewer/codeviewer', array("editors" => $editorHTML));
	}
}