bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
28.2.3
by a10rolch
Added files: |
1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
2 |
||
3 |
class ExamplesController extends CI_Controller { |
|
4 |
||
5 |
public function index() |
|
6 |
{
|
|
7 |
/* headData manages the <head>-tag and loads corresponding CSS.
|
|
8 |
* The views that are entered will load CSS with same name.
|
|
9 |
* Ex. test_header will load test_header.css
|
|
10 |
*/
|
|
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
11 |
$this->load->library('session'); |
64.1.1
by b11johgu
ExamplesController: |
12 |
$headTagData = array( |
13 |
'cssFiles' => array('header', 'examplesMenu', 'examplesBody'), |
|
14 |
'jsFiles' => array('header', 'examplesMenu', 'examplesBody', 'userControls') |
|
15 |
);
|
|
16 |
$this->load->view('headTag', array('headTagData' => $headTagData)); |
|
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
17 |
|
18 |
$this->load->helper('form'); |
|
19 |
||
20 |
// Loading model to retrieve login data
|
|
21 |
$this->load->model('user'); |
|
22 |
$userInfo = array( |
|
64.1.1
by b11johgu
ExamplesController: |
23 |
'userType' => $this->user->getUserType(), // Loads different header for teacher/student |
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
24 |
'userName' => $this->user->getUserName() |
25 |
);
|
|
26 |
||
27 |
$this->load->view('header', $userInfo); |
|
28 |
||
29 |
/* Loads used models */
|
|
30 |
$this->load->model('ExamplesModel'); |
|
31 |
||
32 |
// menuData loads items to the menu.
|
|
33 |
$allTitles = array(); |
|
34 |
||
35 |
/* Loads categorydata into array */
|
|
36 |
$query = $this->ExamplesModel->getTitles($userInfo['userName']); |
|
64.1.1
by b11johgu
ExamplesController: |
37 |
foreach ($query as $category) |
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
38 |
{
|
39 |
// Category
|
|
64.1.1
by b11johgu
ExamplesController: |
40 |
$query2 = $this->ExamplesModel->getBody($category->categoryName); |
41 |
$allTitles[$category->categoryName.",".$category->courseID] = array(); |
|
42 |
// $allTitles[$category->categoryName] = array();
|
|
43 |
// $allTitles[$category->courseID] = array();
|
|
44 |
foreach ($query2 as $subCategory) |
|
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
45 |
{
|
46 |
// Subcategory
|
|
64.1.1
by b11johgu
ExamplesController: |
47 |
$query3 = $this->ExamplesModel->getExamples($subCategory->subCategoryName); |
48 |
$allTitles[$category->categoryName][$subCategory->subCategoryName] = array(); |
|
49 |
foreach ($query3 as $examples) |
|
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
50 |
{
|
51 |
//Examples
|
|
64.1.1
by b11johgu
ExamplesController: |
52 |
$allTitles[$category->categoryName][$subCategory->subCategoryName][] = $examples->exampleName; |
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
53 |
}
|
54 |
||
55 |
}
|
|
56 |
}
|
|
57 |
/* Menu for examples page showing categories */
|
|
58 |
$this->load->view('examplesMenu', array('titles' => $allTitles)); |
|
59 |
||
60 |
/* Loads body for examples page */
|
|
61 |
$this->load->view('examplesBody', array('titles' => $allTitles)); |
|
62 |
||
63 |
}
|
|
64 |
||
65 |
public function validate() { |
|
66 |
//Load required library
|
|
67 |
$this->load->library('form_validation'); |
|
68 |
||
69 |
//Sets validation rules
|
|
70 |
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean'); |
|
71 |
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean'); |
|
72 |
||
73 |
//Run validation
|
|
74 |
if($this->form_validation->run() == FALSE) { |
|
75 |
//Field validation failed. Display login form (with error message).
|
|
76 |
$this->drawLoginForm(validation_errors()); |
|
77 |
} else { |
|
78 |
$username = $this->input->post('username'); |
|
79 |
$password = $this->input->post('password'); |
|
80 |
||
81 |
//Try to login
|
|
82 |
if ($this->user->login($username, $password)) { |
|
83 |
redirect(base_url().'home', 'refresh'); |
|
84 |
} else { |
|
85 |
$this->drawLoginForm('Access denied!'); |
|
86 |
}
|
|
87 |
}
|
|
88 |
}
|
|
89 |
||
28.2.3
by a10rolch
Added files: |
90 |
}
|
91 |
||
52.1.1
by b11johgu
Added controllers for examplepage, templatelayout. |
92 |
/* End of file ExamplesController.php */
|
93 |
/* Location: ./application/controllers/ExamplesController.php */
|