3
* Xibo - Digital Signage - http://www.xibo.org.uk
4
* Copyright (C) 2009-2013 Daniel Garner
6
* This file is part of Xibo.
8
* Xibo is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Affero General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
13
* Xibo is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
18
* You should have received a copy of the GNU Affero General Public License
19
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
21
defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
23
class helpDAO extends baseDAO {
27
* No display page functionaility
30
function displayPage()
32
// Configure the theme
34
Theme::Set('id', $id);
35
Theme::Set('form_meta', '<input type="hidden" name="p" value="help"><input type="hidden" name="q" value="Grid">');
36
Theme::Set('pager', ResponseManager::Pager($id));
38
// Call to render the template
39
Theme::Set('header_text', __('Help Links'));
40
Theme::Set('form_fields', array());
41
Theme::Render('grid_render');
44
function actionMenu() {
47
array('title' => __('Add Help Link'),
48
'class' => 'XiboFormButton',
50
'link' => 'index.php?p=help&q=AddForm',
51
'help' => __('Add a new Help page'),
57
public function Grid()
61
$response = new ResponseManager();
63
//display the display table
65
SELECT HelpID, Topic, Category, Link
67
ORDER BY Topic, Category
70
// Load results into an array
71
$helplinks = $db->GetArray($SQL);
73
if (!is_array($helplinks))
75
trigger_error($db->error());
76
trigger_error(__('Error getting list of helplinks'), E_USER_ERROR);
80
array('name' => 'topic', 'title' => __('Topic')),
81
array('name' => 'category', 'title' => __('Category')),
82
array('name' => 'link', 'title' => __('Link'))
84
Theme::Set('table_cols', $cols);
88
foreach ($helplinks as $row) {
90
$row['helpid'] = Kit::ValidateParam($row['HelpID'], _INT);
91
$row['topic'] = Kit::ValidateParam($row['Topic'], _STRING);
92
$row['category'] = Kit::ValidateParam($row['Category'], _STRING);
93
$row['link'] = Kit::ValidateParam($row['Link'], _STRING);
95
$row['buttons'] = array();
97
// we only want to show certain buttons, depending on the user logged in
98
if ($user->usertypeid == 1) {
101
$row['buttons'][] = array(
102
'id' => 'help_button_edit',
103
'url' => 'index.php?p=help&q=EditForm&HelpID=' . $row['helpid'],
108
$row['buttons'][] = array(
109
'id' => 'help_button_delete',
110
'url' => 'index.php?p=help&q=DeleteForm&HelpID=' . $row['helpid'],
111
'text' => __('Delete')
115
$row['buttons'][] = array(
116
'id' => 'help_button_test',
117
'url' => HelpManager::Link($row['topic'], $row['category']),
125
Theme::Set('table_rows', $rows);
127
$output = Theme::RenderReturn('table_render');
129
$response->SetGridResponse($output);
130
$response->Respond();
133
public function AddForm()
135
$response = new ResponseManager();
137
// Set some information about the form
138
Theme::Set('form_id', 'HelpAddForm');
139
Theme::Set('form_action', 'index.php?p=help&q=Add');
141
$formFields = array();
142
$formFields[] = FormManager::AddText('Topic', __('Topic'), NULL,
143
__('The Topic for this Help Link'), 't', 'maxlength="254" required');
145
$formFields[] = FormManager::AddText('Category', __('Category'), NULL,
146
__('The Category for this Help Link'), 'c', 'maxlength="254" required');
148
$formFields[] = FormManager::AddText('Link', __('Link'), NULL,
149
__('The Link to open for this help topic and category'), 'c', 'maxlength="254" required');
151
Theme::Set('form_fields', $formFields);
153
$response->SetFormRequestResponse(NULL, __('Add Help Link'), '350px', '325px');
154
$response->AddButton(__('Cancel'), 'XiboDialogClose()');
155
$response->AddButton(__('Save'), '$("#HelpAddForm").submit()');
156
$response->Respond();
162
public function EditForm()
165
$user =& $this->user;
166
$response = new ResponseManager();
168
$helpId = Kit::GetParam('HelpID', _REQUEST, _INT);
170
// Pull the currently known info from the DB
171
$SQL = "SELECT HelpID, Topic, Category, Link FROM `help` WHERE HelpID = %d ";
172
$SQL = sprintf($SQL, $helpId);
174
if (!$row = $db->GetSingleRow($SQL))
176
trigger_error($db->error());
177
trigger_error(__('Error getting Help Link'));
180
// Set some information about the form
181
Theme::Set('form_id', 'HelpEditForm');
182
Theme::Set('form_action', 'index.php?p=help&q=Edit');
183
Theme::Set('form_meta', '<input type="hidden" name="HelpID" value="' . $helpId . '" />');
185
$formFields = array();
186
$formFields[] = FormManager::AddText('Topic', __('Topic'), Kit::ValidateParam($row['Topic'], _STRING),
187
__('The Topic for this Help Link'), 't', 'maxlength="254" required');
189
$formFields[] = FormManager::AddText('Category', __('Category'), Kit::ValidateParam($row['Category'], _STRING),
190
__('The Category for this Help Link'), 'c', 'maxlength="254" required');
192
$formFields[] = FormManager::AddText('Link', __('Link'), Kit::ValidateParam($row['Link'], _STRING),
193
__('The Link to open for this help topic and category'), 'c', 'maxlength="254" required');
195
Theme::Set('form_fields', $formFields);
197
$response->SetFormRequestResponse(NULL, __('Edit Help Link'), '350px', '325px');
198
$response->AddButton(__('Cancel'), 'XiboDialogClose()');
199
$response->AddButton(__('Save'), '$("#HelpEditForm").submit()');
200
$response->Respond();
204
* Delete Help Link Form
206
public function DeleteForm()
209
$response = new ResponseManager();
210
$helpId = Kit::GetParam('HelpID', _REQUEST, _INT);
212
// Set some information about the form
213
Theme::Set('form_id', 'HelpDeleteForm');
214
Theme::Set('form_action', 'index.php?p=help&q=Delete');
215
Theme::Set('form_meta', '<input type="hidden" name="HelpID" value="' . $helpId . '" />');
217
Theme::Set('form_fields', array(FormManager::AddMessage(__('Are you sure you want to delete?'))));
219
$response->SetFormRequestResponse(NULL, __('Delete Help Link'), '350px', '175px');
220
$response->AddButton(__('No'), 'XiboDialogClose()');
221
$response->AddButton(__('Yes'), '$("#HelpDeleteForm").submit()');
222
$response->Respond();
228
public function Add()
231
if (!Kit::CheckToken())
232
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
235
$response = new ResponseManager();
237
$topic = Kit::GetParam('Topic', _POST, _STRING);
238
$category = Kit::GetParam('Category', _POST, _STRING);
239
$link = Kit::GetParam('Link', _POST, _STRING);
241
// Deal with the Edit
242
Kit::ClassLoader('help');
243
$helpObject = new Help($db);
245
if (!$helpObject->Add($topic, $category, $link))
246
trigger_error($helpObject->GetErrorMessage(), E_USER_ERROR);
248
$response->SetFormSubmitResponse(__('Help Link Added'), false);
249
$response->Respond();
255
public function Edit()
258
if (!Kit::CheckToken())
259
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
262
$response = new ResponseManager();
264
$helpId = Kit::GetParam('HelpID', _POST, _INT);
265
$topic = Kit::GetParam('Topic', _POST, _STRING);
266
$category = Kit::GetParam('Category', _POST, _STRING);
267
$link = Kit::GetParam('Link', _POST, _STRING);
269
// Deal with the Edit
270
Kit::ClassLoader('help');
271
$helpObject = new Help($db);
273
if (!$helpObject->Edit($helpId, $topic, $category, $link))
274
trigger_error($helpObject->GetErrorMessage(), E_USER_ERROR);
276
$response->SetFormSubmitResponse(__('Help Link Edited'), false);
277
$response->Respond();
280
public function Delete()
283
if (!Kit::CheckToken())
284
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
287
$response = new ResponseManager();
289
$helpId = Kit::GetParam('HelpID', _POST, _INT);
291
// Deal with the Edit
292
Kit::ClassLoader('help');
293
$helpObject = new Help($db);
295
if (!$helpObject->Delete($helpId))
296
trigger_error($helpObject->GetErrorMessage(), E_USER_ERROR);
298
$response->SetFormSubmitResponse(__('Help Link Deleted'), false);
299
$response->Respond();