/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/admin.php

  • Committer: gustav.hartvigsson at gmail
  • Date: 2013-04-03 11:52:56 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20130403115256-sz6zermzoom4lifc
Ignored .DS_Store files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
class Admin extends CI_Controller {
4
 
 
5
 
        /*
6
 
        * This is the index function. It will be the one called if you do not specify a
7
 
        * function in the url, example: /admin/
8
 
        */
9
 
        public function index() {
10
 
                $this->load->model('admin/Admin_model');
11
 
                $courses = $this->Admin_model->getCourses();
12
 
                $this->load->view('admin/header', array("title" => "Index"));
13
 
                $this->load->view('admin/index', array("courses" => $courses));
14
 
        }
15
 
 
16
 
        public function addCourse(){
17
 
                
18
 
                if(!isset($_POST['cid'])){
19
 
                        $this->load->helper('form');
20
 
                        $this->load->view('admin/header', array("title" => "Add course"));
21
 
                        $this->load->view('admin/add_course');
22
 
                } else {
23
 
                        $this->load->model('admin/Admin_model');
24
 
                        $this->Admin_model->addCourse($_POST['cid'], $_POST['name']);
25
 
                        redirect("admin/");
26
 
                }
27
 
        }
28
 
 
29
 
        public function manageCourse($cid) {
30
 
                $this->load->model('admin/Admin_model');
31
 
                $examples = $this->Admin_model->getExamples($cid);
32
 
                $this->load->view('admin/header', array("title" => "Manage course - ".$cid));
33
 
                $this->load->view('admin/manage_course', array("examples" => $examples, "cid" => $cid));
34
 
        }
35
 
 
36
 
        public function addExample($cid){
37
 
                
38
 
                if(!isset($_POST['example'])){
39
 
                        $this->load->helper('form');
40
 
                        $this->load->view('admin/header', array("title" => "Add example"));
41
 
                        $this->load->view('admin/add_example', array("cid" => $cid));
42
 
                } else {
43
 
                        $this->load->model('admin/Admin_model');
44
 
                        $this->Admin_model->addExample($_POST['cid'], $_POST['example'], $_POST['description']);
45
 
                        redirect("admin/");
46
 
                }
47
 
        }
48
 
 
49
 
        public function manageExample($cid, $example) {
50
 
                $this->load->model('admin/Admin_model');
51
 
                $pages = $this->Admin_model->getPages($cid, $example);
52
 
                $this->load->view('admin/header', array("title" => "Manage example - ".$example." - ".$cid));
53
 
                $this->load->view('admin/manage_example', array("pages" => $pages, "cid" => $cid, "example" => $example));
54
 
        }
55
 
 
56
 
        public function addPage($cid, $example){
57
 
                
58
 
                if(!isset($_POST['page'])){
59
 
                        $this->load->helper('form');
60
 
                        $this->load->view('admin/header', array("title" => "Add page"));
61
 
                        $this->load->view('admin/add_page', array("cid" => $cid, "example" => $example));
62
 
                } else {
63
 
                        $this->load->model('admin/Admin_model');
64
 
                        $this->Admin_model->addPage($_POST['cid'], $_POST['example'],$_POST['page']);
65
 
                        redirect("admin/");
66
 
                }
67
 
        }
68
 
 
69
 
        public function managePage($cid, $example, $page) {
70
 
                if(!isset($_POST['documentation'])){
71
 
                        $this->load->helper('form');
72
 
 
73
 
                        $this->load->model('codeviewer/Codeviewer_model');
74
 
 
75
 
                        
76
 
                        $editorHTML = $this->Codeviewer_model->getCode($cid, $example, $page);
77
 
 
78
 
                        //$doc = $this->Codeviewer_model->getDoc($cid, $example, $page);
79
 
 
80
 
                        $this->load->view('admin/header', array("editors" => $editorHTML, "title" => "Manage page - ".$page." - ".$example." - ".$cid));
81
 
                        $this->load->view('admin/manage_page', array("cid" => $cid, "example" => $example, "page" => $page /*,"documentation" => $doc*/));
82
 
                } else {
83
 
                        $this->load->model('admin/Admin_model');
84
 
                        $this->Admin_model->updatePage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation'], $_POST['files']);
85
 
                        redirect("admin/");
86
 
                }
87
 
        }
88
 
 
89
 
        public function uploadFile($cid, $example, $page) {
90
 
                $this->load->model('admin/Admin_model');
91
 
                $this->Admin_model->uploadFile($_FILES['files'],$cid, $example, $page);
92
 
        }
93
 
 
94
 
}
 
 
b'\\ No newline at end of file'