-
Notifications
You must be signed in to change notification settings - Fork 72
/
links.php
executable file
·96 lines (71 loc) · 2.94 KB
/
links.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
class Links extends Controller
{
// Protected or private properties
protected $_template;
// Constructor
public function __construct()
{
parent::Controller();
// Check if the logged user is an administrator
$this->access_library->check_access();
// Load needed models, libraries, helpers and language files
$this->load->module_model('admin', 'links_model', 'links');
$this->load->module_language('admin', 'general');
$this->load->module_language('admin', 'links');
}
// Public methods
public function index()
{
$data['links'] = $this->links->get_links();
$this->_template['page'] = 'links/list';
$this->system_library->load($this->_template['page'], $data, TRUE);
}
public function create()
{
$this->form_validation->set_rules('name', 'lang:form_name', 'required|max_length[50]|xss_clean');
$this->form_validation->set_rules('url', 'lang:form_url', 'required|xss_clean');
$this->form_validation->set_rules('target', 'lang:form_target', 'required|xss_clean');
$this->form_validation->set_rules('description', 'lang:form_description', 'required|max_length[100]|xss_clean');
$this->form_validation->set_rules('visible', 'lang:form_visible', 'required|xss_clean');
$this->form_validation->set_error_delimiters('', '<br />');
if ($this->form_validation->run() == TRUE)
{
$this->links->create_link();
$this->session->set_flashdata('message', lang('successfully_created'));
redirect('admin/links', 'refresh');
}
$this->_template['page'] = 'links/create';
$this->system_library->load($this->_template['page'], null, TRUE);
}
public function edit($id = null)
{
if ($id == null)
{
$id = $this->input->post('id');
}
$this->form_validation->set_rules('name', 'lang:form_name', 'required|max_length[50]|xss_clean');
$this->form_validation->set_rules('url', 'lang:form_url', 'required|xss_clean');
$this->form_validation->set_rules('target', 'lang:form_target', 'required|xss_clean');
$this->form_validation->set_rules('description', 'lang:form_description', 'required|max_length[100]|xss_clean');
$this->form_validation->set_rules('visible', 'lang:form_visible', 'required|xss_clean');
$this->form_validation->set_error_delimiters('', '<br />');
$data['link'] = $this->links->get_link($id);
if ($this->form_validation->run() == TRUE)
{
$this->links->edit_link($id);
$this->session->set_flashdata('message', lang('successfully_edited'));
redirect('admin/links', 'refresh');
}
$this->_template['page'] = 'links/edit';
$this->system_library->load($this->_template['page'], $data, TRUE);
}
public function delete($id)
{
$this->links->delete_link($id);
$this->session->set_flashdata('message', lang('successfully_deleted'));
redirect('admin/links', 'refresh');
}
}
/* End of file links.php */
/* Location: ./application/modules/admin/controllers/links.php */