1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3
class ExamplesController extends CI_Controller {
5
public function index()
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
11
$this->load->library('session');
13
'cssFiles' => array('header', 'examplesMenu', 'examplesBody'),
14
'jsFiles' => array('header', 'examplesMenu', 'examplesBody', 'userControls')
16
$this->load->view('headTag', array('headTagData' => $headTagData));
18
$this->load->helper('form');
20
// Loading model to retrieve login data
21
$this->load->model('user');
23
'userType' => $this->user->getUserType(), // Loads different header for teacher/student
24
'userName' => $this->user->getUserName()
27
$this->load->view('header', $userInfo);
29
/* Loads used models */
30
$this->load->model('ExamplesModel');
32
// menuData loads items to the menu.
35
/* Loads categorydata into array */
36
$query = $this->ExamplesModel->getTitles($userInfo['userName']);
37
foreach ($query as $category)
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)
47
$query3 = $this->ExamplesModel->getExamples($subCategory->subCategoryName);
48
$allTitles[$category->categoryName][$subCategory->subCategoryName] = array();
49
foreach ($query3 as $examples)
52
$allTitles[$category->categoryName][$subCategory->subCategoryName][] = $examples->exampleName;
57
/* Menu for examples page showing categories */
58
$this->load->view('examplesMenu', array('titles' => $allTitles));
60
/* Loads body for examples page */
61
$this->load->view('examplesBody', array('titles' => $allTitles));
65
public function validate() {
66
//Load required library
67
$this->load->library('form_validation');
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');
74
if($this->form_validation->run() == FALSE) {
75
//Field validation failed. Display login form (with error message).
76
$this->drawLoginForm(validation_errors());
78
$username = $this->input->post('username');
79
$password = $this->input->post('password');
82
if ($this->user->login($username, $password)) {
83
redirect(base_url().'home', 'refresh');
85
$this->drawLoginForm('Access denied!');
92
/* End of file ExamplesController.php */
93
/* Location: ./application/controllers/ExamplesController.php */
b'\\ No newline at end of file'