/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 Hatvigsson
  • Date: 2013-05-31 06:15:46 UTC
  • mfrom: (90.1.20 lenasys2)
  • Revision ID: gustav.hartvigsson@gmail.com-20130531061546-vj8z28sq375kvghq
Merged Jonsson:s changes:
Fixed the layout on cms index so the arrows and dots marks expanded objects.
Fixed so the course content is sorted by course occasion and not by name

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
class Admin extends CI_Controller {
4
4
 
5
 
 
 
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
        */
6
9
        public function index() {
7
10
                $this->load->model('admin/Admin_model');
8
11
                $courses = $this->Admin_model->getCourses();
 
12
                $menu = $this->Admin_model->getMenu();
9
13
                $this->load->view('admin/header', array("title" => "Index"));
 
14
                $this->load->view('admin/menu', array("menu" => $menu));
10
15
                $this->load->view('admin/index', array("courses" => $courses));
11
 
        }
 
16
        } 
12
17
 
13
 
        public function addCourse(){
14
 
                
 
18
        public function addCourse() {
 
19
                $this->load->model('admin/Admin_model');
15
20
                if(!isset($_POST['cid'])){
16
21
                        $this->load->helper('form');
17
22
                        $this->load->view('admin/header', array("title" => "Add course"));
 
23
                        $menu = $this->Admin_model->getMenu();
 
24
                        $this->load->view('admin/menu', array("menu" => $menu));
18
25
                        $this->load->view('admin/add_course');
19
26
                } else {
20
 
                        $this->load->model('admin/Admin_model');
 
27
                        
21
28
                        $this->Admin_model->addCourse($_POST['cid'], $_POST['name']);
22
29
                        redirect("admin/");
23
30
                }
24
31
        }
25
32
 
26
33
        public function manageCourse($cid) {
 
34
                $cid = urldecode($cid);
27
35
                $this->load->model('admin/Admin_model');
28
 
                $examples = $this->Admin_model->getExamples($cid);
 
36
                $categories = $this->Admin_model->getCategories($cid);
29
37
                $this->load->view('admin/header', array("title" => "Manage course - ".$cid));
30
 
                $this->load->view('admin/manage_course', array("examples" => $examples, "cid" => $cid));
31
 
        }
32
 
 
33
 
        public function addExample($cid){
 
38
                $menu = $this->Admin_model->getMenu();
 
39
                $this->load->view('admin/menu', array("menu" => $menu));
 
40
                $this->load->view('admin/manage_course', array("categories" => $categories, "cid" => $cid));
 
41
        }
 
42
 
 
43
        public function addCategory($cid){
 
44
                $cid = urldecode($cid);
 
45
                $this->load->model('admin/Admin_model');
 
46
                if(!isset($_POST['categoryName'])){
 
47
                        $this->load->helper('form');
 
48
                        $this->load->view('admin/header', array("title" => "Add category"));
 
49
                        $menu = $this->Admin_model->getMenu();
 
50
                        $this->load->view('admin/menu', array("menu" => $menu));
 
51
                        $this->load->view('admin/add_category', array("cid" => $cid));
 
52
                } else {
 
53
                        
 
54
                        $this->Admin_model->addCategory($_POST['cid'], $_POST['categoryName']);
 
55
                        redirect("admin/");
 
56
                }
 
57
        }
 
58
 
 
59
        public function manageCategory($cid, $categoryName) {
 
60
                $cid = urldecode($cid);
 
61
                $categoryName = urldecode($categoryName);
 
62
                $this->load->model('admin/Admin_model');
 
63
                $subcategories = $this->Admin_model->getSubCategories($cid,  $categoryName);
 
64
                $this->load->view('admin/header', array("title" => "Manage category - ".$cid." - ". $categoryName));
 
65
                $menu = $this->Admin_model->getMenu();
 
66
                $this->load->view('admin/menu', array("menu" => $menu));
 
67
                $this->load->view('admin/manage_category', array("subcategories" => $subcategories, "cid" => $cid, "categoryName" => $categoryName));
 
68
        }
 
69
 
 
70
        public function addSubCategory($cid, $categoryName){
 
71
                $cid = urldecode($cid);
 
72
                $categoryName = urldecode($categoryName);
 
73
                $this->load->model('admin/Admin_model');
 
74
                if(!isset($_POST['subcategoryname'])){
 
75
                        $this->load->helper('form');
 
76
                        $this->load->view('admin/header', array("title" => "Add subcategory"));
 
77
                        $menu = $this->Admin_model->getMenu();
 
78
                        $this->load->view('admin/menu', array("menu" => $menu));
 
79
                        $this->load->view('admin/add_sub_category', array("cid" => $cid, "category" => $categoryName));
 
80
                } else {
34
81
                
 
82
                        $this->Admin_model->addSubCategory($_POST['cid'], $_POST['category'], $_POST['subcategoryname']);
 
83
                        redirect("admin/");
 
84
                }
 
85
        }
 
86
 
 
87
        public function manageSubCategory($cid, $categoryName, $subCategoryName) {
 
88
                $cid = urldecode($cid);
 
89
                $categoryName = urldecode($categoryName);
 
90
                $subCategoryName = urldecode($subCategoryName);
 
91
                $this->load->model('admin/Admin_model');
 
92
                $examples = $this->Admin_model->getExamples($cid,  $categoryName, $subCategoryName);
 
93
                $quizzes = $this->Admin_model->getQuizzes($cid,  $categoryName, $subCategoryName);
 
94
                $this->load->view('admin/header', array("title" => "Manage category - ".$cid." - ". $categoryName));
 
95
                $menu = $this->Admin_model->getMenu();
 
96
                $this->load->view('admin/menu', array("menu" => $menu));
 
97
                $this->load->view('admin/manage_sub_category', array("examples" => $examples, "quizzes" => $quizzes , "cid" => $cid, "categoryName" => $categoryName, "subCategoryName" => $subCategoryName));
 
98
        }
 
99
 
 
100
        public function addExample($cid, $categoryName, $subCategoryName){
 
101
                $cid = urldecode($cid);
 
102
                $categoryName = urldecode($categoryName);
 
103
                $subCategoryName = urldecode($subCategoryName);
 
104
                $this->load->model('admin/Admin_model');
35
105
                if(!isset($_POST['example'])){
36
106
                        $this->load->helper('form');
37
107
                        $this->load->view('admin/header', array("title" => "Add example"));
38
 
                        $this->load->view('admin/add_example', array("cid" => $cid));
39
 
                } else {
40
 
                        $this->load->model('admin/Admin_model');
41
 
                        $this->Admin_model->addExample($_POST['cid'], $_POST['example']);
42
 
                        redirect("admin/");
43
 
                }
44
 
        }
45
 
 
46
 
        public function manageExample($cid, $example) {
47
 
                $this->load->model('admin/Admin_model');
48
 
                $pages = $this->Admin_model->getPages($cid, $example);
49
 
                $this->load->view('admin/header', array("title" => "Manage example - ".$example." - ".$cid));
50
 
                $this->load->view('admin/manage_example', array("pages" => $pages, "cid" => $cid, "example" => $example));
51
 
        }
52
 
 
53
 
        public function addPage($cid, $example){
54
 
                
55
 
                if(!isset($_POST['page'])){
56
 
                        $this->load->helper('form');
57
 
                        $this->load->view('admin/header', array("title" => "Add page"));
58
 
                        $this->load->view('admin/add_page', array("cid" => $cid, "example" => $example));
59
 
                } else {
60
 
                        $this->load->model('admin/Admin_model');
61
 
                        $this->Admin_model->addPage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation']);
62
 
                        redirect("admin/");
63
 
                }
64
 
        }
65
 
 
66
 
        public function managePage($cid, $example, $page) {
 
108
                        $menu = $this->Admin_model->getMenu();
 
109
                        $this->load->view('admin/menu', array("menu" => $menu));
 
110
                        $this->load->view('admin/add_example', array("cid" => $cid, "categoryName" => $categoryName, "subCategoryName" => $subCategoryName));
 
111
                } else {
 
112
                        
 
113
                        $this->Admin_model->addExample($_POST['cid'],  $_POST['categoryName'], $_POST['subCategoryName'], $_POST['example'], $_POST['description']);
 
114
                        redirect("admin/");
 
115
                }
 
116
        }
 
117
 
 
118
        public function manageExample($cid, $categoryName, $subCategoryName, $example) {
 
119
                $cid = urldecode($cid);
 
120
                $example = urldecode($example);
 
121
                $categoryName = urldecode($categoryName);
 
122
                $subCategoryName = urldecode($subCategoryName);
67
123
                if(!isset($_POST['documentation'])){
68
124
                        $this->load->helper('form');
69
125
 
70
126
                        $this->load->model('codeviewer/Codeviewer_model');
71
 
 
72
 
                        $files = $this->Codeviewer_model->getFiles($cid, $example,$page);
73
 
                        $editorHTML = "";
74
 
                        foreach ($files as $file) {
75
 
                                $editorHTML .= $this->Codeviewer_model->showFile($file, "html");
76
 
                        }
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));
 
127
                        
 
128
                        $editorHTML = $this->Codeviewer_model->getCode($cid, $categoryName, $subCategoryName, $example);
 
129
 
 
130
                        //$doc = $this->Codeviewer_model->getDoc($cid, $example, $page);
 
131
 
 
132
                        $this->load->view('admin/header', array("editors" => $editorHTML, "title" => "Manage example - ".$categoryName." - ".$subCategoryName." - ".$example." - ".$cid));
 
133
                        $this->load->view('admin/manage_example', array("cid" => $cid, "example" => $example, "category" => $categoryName, "subcategory" => $subCategoryName /*,"documentation" => $doc*/));
82
134
                } else {
83
135
                        $this->load->model('admin/Admin_model');
84
 
                        $this->Admin_model->updatePage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation']);
 
136
                        $this->Admin_model->updateExample($_POST['cid'], $_POST['example'],$_POST['category'], $_POST['subcategory'], $_POST['documentation'], $_POST['files']);
85
137
                        redirect("admin/");
86
138
                }
87
139
        }
88
140
 
89
 
        public function uploadFile($cid, $example, $page) {
 
141
        public function uploadFile($cid, $categoryName, $subCategoryName, $example) {
 
142
                $cid = urldecode($cid);
 
143
                $example = urldecode($example);
 
144
                $categoryName = urldecode($categoryName);
 
145
                $subCategoryName = urldecode($subCategoryName);
90
146
                $this->load->model('admin/Admin_model');
91
 
                $this->Admin_model->uploadFile($_FILES['files'],$cid, $example, $page);
 
147
                $this->Admin_model->uploadFile($_FILES['files'],$cid, $categoryName, $subCategoryName, $example);
92
148
        }
93
149
 
94
150
}
 
 
b'\\ No newline at end of file'