/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/application/controllers/codeviewer.php

  • Committer: a11andoh
  • Date: 2013-05-28 09:50:55 UTC
  • mfrom: (112 lenasys_b)
  • mto: This revision was merged to the branch mainline in revision 115.
  • Revision ID: a11andoh@student.his.se-20130528095055-3ig3yvqebh08vmgz
blurp

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
* This is a controller. It links the views related to the codeviewer together with the model, which holds
 
4
* the logic.  
 
5
*
 
6
* Function names equals path. Example: codeviewer/show in the url calls the function show in the controller
 
7
* codeviewer (this file below).
 
8
*
 
9
* The params after the url equals the input arguments of the function. Function show() has 3 arguments
 
10
* and therefore requires 3 arguments to be given in the url, like so: codeviewer/show/courseid/exampleid/pageid
 
11
*/
 
12
class Codeviewer extends CI_Controller {
 
13
 
 
14
        /*Temporarily redirects the user to the startpage*/
 
15
        public function index(){
 
16
                redirect('/');
 
17
        }
 
18
 
 
19
        /**
 
20
        * This shows the codeviewer page
 
21
        */
 
22
        public function show($cid, $category, $subcategory, $example){
 
23
                $headTagData['cssFiles'] = array('headTag', 'header', 'codeviewer');
 
24
                $headTagData['jsFiles'] = array('ace/ace', 'header');
 
25
        
 
26
                $this->load->model('codeviewer/Codeviewer_model');
 
27
 
 
28
                $editorHTML = $this->Codeviewer_model->getCode($cid, $category, $subcategory, $example);
 
29
        
 
30
                $this->load->model('user');
 
31
                
 
32
                $userInfo = array(
 
33
                        'userType' => $this->user->getUserType(),
 
34
                        'userName' => $this->user->getUserName()
 
35
                );
 
36
                
 
37
                $this->load->helper('form');
 
38
                
 
39
                // $doc = $this->Codeviewer_model->getDoc($cid, $category, $subcategory, $example);
 
40
 
 
41
                // This loads the view. It's stored in application/views/codeviewer/codeviewer.php
 
42
                // Do note that application/views should not be in the first argument of view()
 
43
                // The second argument is data to be shown in the view. "editors" => "test" would
 
44
                // generate an $editors variable in the view containing "test"
 
45
                $this->load->view('headTag', array('headTagData' => $headTagData));
 
46
                $this->load->view('header', $userInfo);
 
47
                $this->load->view('codeviewer/codeviewer', array("editors" => $editorHTML));
 
48
        }
 
49
}