/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-02 08:46:00 UTC
  • mfrom: (50.1.2 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130502084600-vygqk8e0cv3mz40u
Merged the changes to the categories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
        public function index() {
10
10
                $this->load->model('admin/Admin_model');
11
11
                $courses = $this->Admin_model->getCourses();
 
12
                $menu = $this->Admin_model->getMenu();
12
13
                $this->load->view('admin/header', array("title" => "Index"));
 
14
                $this->load->view('admin/menu', array("menu" => $menu));
13
15
                $this->load->view('admin/index', array("courses" => $courses));
14
 
        }
 
16
        } 
15
17
 
16
 
        public function addCourse(){
17
 
                
 
18
        public function addCourse() {
 
19
                $this->load->model('admin/Admin_model');
18
20
                if(!isset($_POST['cid'])){
19
21
                        $this->load->helper('form');
20
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));
21
25
                        $this->load->view('admin/add_course');
22
26
                } else {
23
 
                        $this->load->model('admin/Admin_model');
 
27
                        
24
28
                        $this->Admin_model->addCourse($_POST['cid'], $_POST['name']);
25
29
                        redirect("admin/");
26
30
                }
27
31
        }
28
32
 
29
33
        public function manageCourse($cid) {
 
34
                $cid = urldecode($cid);
30
35
                $this->load->model('admin/Admin_model');
31
 
                $examples = $this->Admin_model->getExamples($cid);
 
36
                $categories = $this->Admin_model->getCategories($cid);
32
37
                $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){
 
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 {
37
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
                $this->load->view('admin/header', array("title" => "Manage category - ".$cid." - ". $categoryName));
 
94
                $menu = $this->Admin_model->getMenu();
 
95
                $this->load->view('admin/menu', array("menu" => $menu));
 
96
                $this->load->view('admin/manage_sub_category', array("examples" => $examples, "cid" => $cid, "categoryName" => $categoryName, "subCategoryName" => $subCategoryName));
 
97
        }
 
98
 
 
99
        public function addExample($cid, $categoryName, $subCategoryName){
 
100
                $cid = urldecode($cid);
 
101
                $categoryName = urldecode($categoryName);
 
102
                $subCategoryName = urldecode($subCategoryName);
 
103
                $this->load->model('admin/Admin_model');
38
104
                if(!isset($_POST['example'])){
39
105
                        $this->load->helper('form');
40
106
                        $this->load->view('admin/header', array("title" => "Add example"));
41
 
                        $this->load->view('admin/add_example', array("cid" => $cid));
 
107
                        $menu = $this->Admin_model->getMenu();
 
108
                        $this->load->view('admin/menu', array("menu" => $menu));
 
109
                        $this->load->view('admin/add_example', array("cid" => $cid, "categoryName" => $categoryName, "subCategoryName" => $subCategoryName));
42
110
                } else {
43
 
                        $this->load->model('admin/Admin_model');
44
 
                        $this->Admin_model->addExample($_POST['cid'], $_POST['example'], $_POST['description']);
 
111
                        
 
112
                        $this->Admin_model->addExample($_POST['cid'],  $_POST['categoryName'], $_POST['subCategoryName'], $_POST['example'], $_POST['description']);
45
113
                        redirect("admin/");
46
114
                }
47
115
        }
48
116
 
49
117
        public function manageExample($cid, $example) {
 
118
                $cid = urldecode($cid);
 
119
                $example = urldecode($example);
50
120
                $this->load->model('admin/Admin_model');
51
121
                $pages = $this->Admin_model->getPages($cid, $example);
52
122
                $this->load->view('admin/header', array("title" => "Manage example - ".$example." - ".$cid));
 
123
                $menu = $this->Admin_model->getMenu();
 
124
                $this->load->view('admin/menu', array("menu" => $menu));
53
125
                $this->load->view('admin/manage_example', array("pages" => $pages, "cid" => $cid, "example" => $example));
54
126
        }
55
127
 
56
128
        public function addPage($cid, $example){
57
 
                
58
 
                if(!isset($_POST['page'])){
 
129
                $cid = urldecode($cid);
 
130
                $example = urldecode($example);
 
131
                if(!isset($_POST['page'])) {
59
132
                        $this->load->helper('form');
60
133
                        $this->load->view('admin/header', array("title" => "Add page"));
 
134
                        $menu = $this->Admin_model->getMenu();
 
135
                        $this->load->view('admin/menu', array("menu" => $menu));
61
136
                        $this->load->view('admin/add_page', array("cid" => $cid, "example" => $example));
62
137
                } else {
63
138
                        $this->load->model('admin/Admin_model');
67
142
        }
68
143
 
69
144
        public function managePage($cid, $example, $page) {
 
145
                $cid = urldecode($cid);
 
146
                $example = urldecode($example);
 
147
                $page = urldecode($page);
70
148
                if(!isset($_POST['documentation'])){
71
149
                        $this->load->helper('form');
72
150
 
87
165
        }
88
166
 
89
167
        public function uploadFile($cid, $example, $page) {
 
168
                $cid = urldecode($cid);
 
169
                $example = urldecode($example);
 
170
                $page = urldecode($page);
90
171
                $this->load->model('admin/Admin_model');
91
172
                $this->Admin_model->uploadFile($_FILES['files'],$cid, $example, $page);
92
173
        }