/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
1
<?php
2
3
class Admin extends CI_Controller {
4
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
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
	*/
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
9
	public function index() {
10
		$this->load->model('admin/Admin_model');
11
		$courses = $this->Admin_model->getCourses();
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
12
		$this->load->view('admin/header', array("title" => "Index"));
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
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');
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
20
			$this->load->view('admin/header', array("title" => "Add course"));
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
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);
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
32
		$this->load->view('admin/header', array("title" => "Manage course - ".$cid));
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
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');
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
40
			$this->load->view('admin/header', array("title" => "Add example"));
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
41
			$this->load->view('admin/add_example', array("cid" => $cid));
42
		} else {
43
			$this->load->model('admin/Admin_model');
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
44
			$this->Admin_model->addExample($_POST['cid'], $_POST['example'], $_POST['description']);
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
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);
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
52
		$this->load->view('admin/header', array("title" => "Manage example - ".$example." - ".$cid));
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
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');
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
60
			$this->load->view('admin/header', array("title" => "Add page"));
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
61
			$this->load->view('admin/add_page', array("cid" => $cid, "example" => $example));
62
		} else {
63
			$this->load->model('admin/Admin_model');
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
64
			$this->Admin_model->addPage($_POST['cid'], $_POST['example'],$_POST['page']);
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
65
			redirect("admin/");
66
		}
67
	}
68
69
	public function managePage($cid, $example, $page) {
70
		if(!isset($_POST['documentation'])){
71
			$this->load->helper('form');
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
72
73
			$this->load->model('codeviewer/Codeviewer_model');
74
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
75
			
76
			$editorHTML = $this->Codeviewer_model->getCode($cid, $example, $page);
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
77
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
78
			//$doc = $this->Codeviewer_model->getDoc($cid, $example, $page);
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
79
80
			$this->load->view('admin/header', array("editors" => $editorHTML, "title" => "Manage page - ".$page." - ".$example." - ".$cid));
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
81
			$this->load->view('admin/manage_page', array("cid" => $cid, "example" => $example, "page" => $page /*,"documentation" => $doc*/));
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
82
		} else {
83
			$this->load->model('admin/Admin_model');
23.1.2 by galaxyAbstractor
Fixed database stuff, added files to database.
84
			$this->Admin_model->updatePage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation'], $_POST['files']);
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
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
}