bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
85.1.8
by a11andoh
added the cms controller to load all content pages. |
1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
2 |
||
3 |
class Cms extends CI_Controller { |
|
4 |
||
5 |
/*
|
|
6 |
* Constructor
|
|
7 |
*/
|
|
8 |
function __construct() { |
|
9 |
parent::__construct(); |
|
10 |
//Load required library
|
|
11 |
$this->load->model('user', '', TRUE); |
|
12 |
$this->load->model('admin/admin_model', '', TRUE); |
|
90.1.13
by a11emmjo
Changed so that cms-controller loads filetree (before known as examplesController, examplesBody, examplesMenu). |
13 |
$this->load->model('filetree'); |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
14 |
}
|
90.1.10
by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu. |
15 |
|
16 |
/*
|
|
17 |
*Temporary function to be able to be logged in to reach the page
|
|
18 |
*/
|
|
85.1.8
by a11andoh
added the cms controller to load all content pages. |
19 |
public function tempLogin() { |
20 |
$this->load->model('user'); |
|
21 |
$loginDetails = array( |
|
22 |
'username' => 'tempTeacher', |
|
23 |
'name' => 'tempFoo', |
|
24 |
'usertype' => 'Teacher', |
|
25 |
'ssn' => '0000', |
|
26 |
'activeCourse' => 'DA525G'); |
|
27 |
$this->session->set_userdata('authenticated', $loginDetails); |
|
90.1.8
by a11emmjo
Fixed some redirect-links. |
28 |
redirect(base_url().'cms', 'refresh'); |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
29 |
}
|
30 |
public function tempLogout() { |
|
31 |
$this->load->model('user'); |
|
32 |
$this->session->unset_userdata('authenticated'); |
|
90.1.8
by a11emmjo
Fixed some redirect-links. |
33 |
redirect(base_url().'home', 'refresh'); |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
34 |
}
|
90.1.10
by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu. |
35 |
|
85.1.8
by a11andoh
added the cms controller to load all content pages. |
36 |
/*
|
37 |
* This function runs when the user navigates directly to this controller
|
|
38 |
*/
|
|
39 |
public function index() { |
|
40 |
if($this->user->isLoggedIn()) { |
|
41 |
//User already logged in
|
|
42 |
$this->drawCmsPage(''); |
|
43 |
} else { |
|
44 |
//Display the start page
|
|
45 |
redirect(base_url().'home', 'refresh'); |
|
46 |
}
|
|
47 |
}
|
|
48 |
||
109.1.2
by c11emian
Added the functions getPublicCourses(), getPrivateCourses() and getStudentCourses(). |
49 |
public function test(){ |
50 |
||
51 |
$result = $this->admin_model->getStudentCourses("student"); |
|
52 |
foreach($result as $res) { |
|
53 |
echo $res->courseID. ' - '; |
|
54 |
echo $res->name; |
|
55 |
echo "<br>"; |
|
56 |
||
57 |
}
|
|
58 |
||
59 |
//var_dump($result);
|
|
60 |
}
|
|
61 |
||
62 |
||
85.1.8
by a11andoh
added the cms controller to load all content pages. |
63 |
/*
|
64 |
* This function draws the cms page.
|
|
65 |
*/
|
|
66 |
private function drawCmsPage() { |
|
67 |
$userName = $this->user->getUserName(); |
|
68 |
$userType = $this->user->getUserType(); |
|
69 |
$activeCourse = $this->user->getActiveCourse(); |
|
70 |
//Creates an array with all courses.
|
|
71 |
$courses = $this->admin_model->getCourses(); |
|
90.1.10
by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu. |
72 |
//Creates an array with all categories for active course
|
73 |
$categories = $this->admin_model->getCategories($activeCourse['courseID']); |
|
74 |
||
85.1.8
by a11andoh
added the cms controller to load all content pages. |
75 |
//Creates an array with the variables that the bannermenu-view is expecting.
|
76 |
$data = array( |
|
77 |
'userType' => $userType, |
|
78 |
'userName' => $userName, |
|
79 |
'courses' => $courses, |
|
80 |
'categories' => $categories, |
|
81 |
'activeCourse' => $activeCourse |
|
82 |
);
|
|
83 |
||
90.1.13
by a11emmjo
Changed so that cms-controller loads filetree (before known as examplesController, examplesBody, examplesMenu). |
84 |
//Creates an array with the variables that the cmsindex-view is expecting.
|
85 |
$filetree = array(); |
|
86 |
||
87 |
//Categories
|
|
88 |
$categories = $this->filetree->getCategories($data['activeCourse']['courseID']); |
|
89 |
foreach ($categories as $category) { |
|
90 |
$filetree[$category->categoryName] = array(); |
|
91 |
||
92 |
//Sub categories
|
|
93 |
$subcategories = $this->filetree->getSubCategories($category->categoryName, $data['activeCourse']['courseID']); |
|
94 |
foreach ($subcategories as $subcategory) { |
|
95 |
$filetree[$category->categoryName][$subcategory->subCategoryName] = array(); |
|
96 |
||
97 |
//Examples
|
|
98 |
$filetree[$category->categoryName][$subcategory->subCategoryName]['examples'] = array(); |
|
99 |
$examples = $this->filetree->getExamples($subcategory->subCategoryName, $category->categoryName, $data['activeCourse']['courseID']); |
|
100 |
foreach ($examples as $example) { |
|
101 |
$filetree[$category->categoryName][$subcategory->subCategoryName]['examples'][] = $example->exampleName; |
|
102 |
}
|
|
103 |
||
104 |
//Quizzes
|
|
105 |
$filetree[$category->categoryName][$subcategory->subCategoryName]['quizzes'] = array(); |
|
106 |
$quizzes = $this->filetree->getQuizzes($subcategory->subCategoryName, $category->categoryName, $data['activeCourse']['courseID']); |
|
107 |
foreach ($quizzes as $quiz) { |
|
108 |
$filetree[$category->categoryName][$subcategory->subCategoryName]['quizzes'][] = $quiz->quizNr; |
|
109 |
}
|
|
110 |
}
|
|
111 |
}
|
|
112 |
||
85.1.8
by a11andoh
added the cms controller to load all content pages. |
113 |
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
|
114 |
$headTagData = array( |
|
90.1.13
by a11emmjo
Changed so that cms-controller loads filetree (before known as examplesController, examplesBody, examplesMenu). |
115 |
'cssFiles' => array('bannermenu', 'sidemenu', 'cmsindex'), |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
116 |
'jsFiles' => array('bannermenu') |
117 |
);
|
|
118 |
||
119 |
//Puts the array above in <head></head>
|
|
120 |
$this->load->view('headTag', array('headTagData' => $headTagData)); |
|
121 |
||
122 |
$this->load->view('bannermenu', $data); |
|
90.1.10
by a11emmjo
Removed coursemenu and statsmenu and replaced it with new combined sidemenu. |
123 |
$this->load->view('sidemenu', $data); |
90.1.13
by a11emmjo
Changed so that cms-controller loads filetree (before known as examplesController, examplesBody, examplesMenu). |
124 |
$this->load->view('cmsindex', array('filetree' => $filetree)); |
85.1.8
by a11andoh
added the cms controller to load all content pages. |
125 |
}
|
126 |
}
|
|
127 |
?>
|