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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
<?php
class Admin extends CI_Controller {
/*
* This is the index function. It will be the one called if you do not specify a
* function in the url, example: /admin/
*/
public function index() {
$this->load->model('admin/Admin_model');
$courses = $this->Admin_model->getCourses();
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/header', array("title" => "Index"));
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/index', array("courses" => $courses));
}
public function addCourse() {
$this->load->model('admin/Admin_model');
if(!isset($_POST['cid'])){
$this->load->helper('form');
$this->load->view('admin/header', array("title" => "Add course"));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/add_course');
} else {
$this->Admin_model->addCourse($_POST['cid'], $_POST['name']);
redirect("admin/");
}
}
public function manageCourse($cid) {
$cid = urldecode($cid);
$this->load->model('admin/Admin_model');
$categories = $this->Admin_model->getCategories($cid);
$this->load->view('admin/header', array("title" => "Manage course - ".$cid));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/manage_course', array("categories" => $categories, "cid" => $cid));
}
public function addCategory($cid){
$cid = urldecode($cid);
$this->load->model('admin/Admin_model');
if(!isset($_POST['categoryName'])){
$this->load->helper('form');
$this->load->view('admin/header', array("title" => "Add category"));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/add_category', array("cid" => $cid));
} else {
$this->Admin_model->addCategory($_POST['cid'], $_POST['categoryName']);
redirect("admin/");
}
}
public function manageCategory($cid, $categoryName) {
$cid = urldecode($cid);
$categoryName = urldecode($categoryName);
$this->load->model('admin/Admin_model');
$subcategories = $this->Admin_model->getSubCategories($cid, $categoryName);
$this->load->view('admin/header', array("title" => "Manage category - ".$cid." - ". $categoryName));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/manage_category', array("subcategories" => $subcategories, "cid" => $cid, "categoryName" => $categoryName));
}
public function addSubCategory($cid, $categoryName){
$cid = urldecode($cid);
$categoryName = urldecode($categoryName);
$this->load->model('admin/Admin_model');
if(!isset($_POST['subcategoryname'])){
$this->load->helper('form');
$this->load->view('admin/header', array("title" => "Add subcategory"));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/add_sub_category', array("cid" => $cid, "category" => $categoryName));
} else {
$this->Admin_model->addSubCategory($_POST['cid'], $_POST['category'], $_POST['subcategoryname']);
redirect("admin/");
}
}
public function manageSubCategory($cid, $categoryName, $subCategoryName) {
$cid = urldecode($cid);
$categoryName = urldecode($categoryName);
$subCategoryName = urldecode($subCategoryName);
$this->load->model('admin/Admin_model');
$examples = $this->Admin_model->getExamples($cid, $categoryName, $subCategoryName);
$this->load->view('admin/header', array("title" => "Manage category - ".$cid." - ". $categoryName));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/manage_sub_category', array("examples" => $examples, "cid" => $cid, "categoryName" => $categoryName, "subCategoryName" => $subCategoryName));
}
public function addExample($cid, $categoryName, $subCategoryName){
$cid = urldecode($cid);
$categoryName = urldecode($categoryName);
$subCategoryName = urldecode($subCategoryName);
$this->load->model('admin/Admin_model');
if(!isset($_POST['example'])){
$this->load->helper('form');
$this->load->view('admin/header', array("title" => "Add example"));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/add_example', array("cid" => $cid, "categoryName" => $categoryName, "subCategoryName" => $subCategoryName));
} else {
$this->Admin_model->addExample($_POST['cid'], $_POST['categoryName'], $_POST['subCategoryName'], $_POST['example'], $_POST['description']);
redirect("admin/");
}
}
public function manageExample($cid, $example) {
$cid = urldecode($cid);
$example = urldecode($example);
$this->load->model('admin/Admin_model');
$pages = $this->Admin_model->getPages($cid, $example);
$this->load->view('admin/header', array("title" => "Manage example - ".$example." - ".$cid));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/manage_example', array("pages" => $pages, "cid" => $cid, "example" => $example));
}
public function addPage($cid, $example){
$cid = urldecode($cid);
$example = urldecode($example);
if(!isset($_POST['page'])) {
$this->load->helper('form');
$this->load->view('admin/header', array("title" => "Add page"));
$menu = $this->Admin_model->getMenu();
$this->load->view('admin/menu', array("menu" => $menu));
$this->load->view('admin/add_page', array("cid" => $cid, "example" => $example));
} else {
$this->load->model('admin/Admin_model');
$this->Admin_model->addPage($_POST['cid'], $_POST['example'],$_POST['page']);
redirect("admin/");
}
}
public function managePage($cid, $example, $page) {
$cid = urldecode($cid);
$example = urldecode($example);
$page = urldecode($page);
if(!isset($_POST['documentation'])){
$this->load->helper('form');
$this->load->model('codeviewer/Codeviewer_model');
$editorHTML = $this->Codeviewer_model->getCode($cid, $example, $page);
//$doc = $this->Codeviewer_model->getDoc($cid, $example, $page);
$this->load->view('admin/header', array("editors" => $editorHTML, "title" => "Manage page - ".$page." - ".$example." - ".$cid));
$this->load->view('admin/manage_page', array("cid" => $cid, "example" => $example, "page" => $page /*,"documentation" => $doc*/));
} else {
$this->load->model('admin/Admin_model');
$this->Admin_model->updatePage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation'], $_POST['files']);
redirect("admin/");
}
}
public function uploadFile($cid, $example, $page) {
$cid = urldecode($cid);
$example = urldecode($example);
$page = urldecode($page);
$this->load->model('admin/Admin_model');
$this->Admin_model->uploadFile($_FILES['files'],$cid, $example, $page);
}
}
|