/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: galaxyAbstractor
  • Date: 2013-04-11 13:59:06 UTC
  • mto: (23.2.1 lenasys)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: galaxyabstractor@gmail.com-20130411135906-tohvazsxmw77otid
Removed codeigniter user guide, shouldn't be in the repo
Added and implemented CKEditor Wysiwyg editor for editing of pages
Made already uploaded code files visible as you edit a page
Implemented Adams dropdown menu in codeviewer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class Admin extends CI_Controller {
 
4
 
 
5
 
 
6
        public function index() {
 
7
                $this->load->model('admin/Admin_model');
 
8
                $courses = $this->Admin_model->getCourses();
 
9
                $this->load->view('admin/header', array("title" => "Index"));
 
10
                $this->load->view('admin/index', array("courses" => $courses));
 
11
        }
 
12
 
 
13
        public function addCourse(){
 
14
                
 
15
                if(!isset($_POST['cid'])){
 
16
                        $this->load->helper('form');
 
17
                        $this->load->view('admin/header', array("title" => "Add course"));
 
18
                        $this->load->view('admin/add_course');
 
19
                } else {
 
20
                        $this->load->model('admin/Admin_model');
 
21
                        $this->Admin_model->addCourse($_POST['cid'], $_POST['name']);
 
22
                        redirect("admin/");
 
23
                }
 
24
        }
 
25
 
 
26
        public function manageCourse($cid) {
 
27
                $this->load->model('admin/Admin_model');
 
28
                $examples = $this->Admin_model->getExamples($cid);
 
29
                $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){
 
34
                
 
35
                if(!isset($_POST['example'])){
 
36
                        $this->load->helper('form');
 
37
                        $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) {
 
67
                if(!isset($_POST['documentation'])){
 
68
                        $this->load->helper('form');
 
69
 
 
70
                        $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));
 
82
                } else {
 
83
                        $this->load->model('admin/Admin_model');
 
84
                        $this->Admin_model->updatePage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation']);
 
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'