39 $this->name =
'Task Type Management';
42 parent::__construct($this->name);
43 $this->menu[
'list'] = sprintf(
self::$foglang[
'ListAll'], _(
'Task Types'));
44 $this->menu[
'add'] = sprintf(
self::$foglang[
'CreateNew'], _(
'Task Type'));
48 $this->subMenu = array(
53 _(
'Name') => $this->obj->get(
'name'),
55 '<i class="fa fa-%s"></i>',
56 $this->obj->get(
'icon')
58 _(
'Type') => $this->obj->get(
'type'),
61 $this->headerData = array(
62 '<input type="checkbox" name="toggle-checkbox" class='
63 .
'"toggle-checkboxAction"/>',
68 $this->templates = array(
69 '<input type="checkbox" name="tasktypeedit[]" value='
70 .
'"${id}" class="toggle-action"/>',
72 '<a href="?node=%s&sub=edit&id=${id}" title='
73 .
'"Edit"><i class="fa fa-${icon} fa-1x"> ${name}</i></a>',
79 $this->attributes = array(
82 'class' =>
'filter-false'
95 self::$returnData =
function (&
$TaskType) {
96 $this->data[] = array(
113 $this->title = _(
'New Task Type');
114 unset($this->headerData);
115 $this->attributes = array(
116 array(
'class' =>
'col-xs-4'),
117 array(
'class' =>
'col-xs-8 form-group'),
119 $this->templates = array(
123 $name = filter_input(
127 $description = filter_input(
131 $icon = filter_input(
135 $kernel = filter_input(
139 $kernelargs = filter_input(
143 $initrd = filter_input(
147 $type = filter_input(
151 $access = filter_input(
155 $advanced = isset($_POST[
'advanced']);
161 $accessTypes = array(
175 .
'</label>' =>
'<div class="input-group">'
176 .
'<input type="text" name="name" id="name" value="'
178 .
'" class="form-control" autocomplete="off" '
181 '<label for="description">'
183 .
'</label>' =>
'<div class="input-group">'
184 .
'<textarea name="description" id="description" class="form-control">'
190 .
'</label>' => self::getClass(
'TaskType')->iconlist($icon),
191 '<label for="kernel">'
193 .
'</label>' =>
'<div class="input-group">'
194 .
'<input class="form-control" type="text" name="kernel" id="kernel" '
199 '<label for="kernargs">'
200 . _(
'Kernel Arguments')
201 .
'</label>' =>
'<div class="input-group">'
202 .
'<input class="form-control" type="text" name="kernelargs" id='
203 .
'"kernargs" value="'
207 '<label for="initrd">'
209 .
'</label>' =>
'<div class="input-group">'
210 .
'<textarea name="initrd" class='
211 .
'"form-control" id="initrd">'
217 .
'</label>' =>
'<div class="input-group">'
218 .
'<input class="form-control" type="text" name="type" id='
225 .
'</label>' =>
'<input type="checkbox" name="advanced" id='
229 '<label for="access">'
231 .
'</label>' => $accessSel,
233 . _(
'Create Task type')
234 .
'</label>' =>
'<button class="btn btn-info btn-block" type="submit" '
235 .
'id="add" name="add">'
243 'fields' => &$fields,
244 'TaskType' => self::getClass(
'TaskType')
247 array_walk($fields, $this->fieldsToData);
252 'headerData' => &$this->headerData,
253 'data' => &$this->data,
254 'templates' => &$this->templates,
255 'attributes' => &$this->attributes
258 echo
'<div class="col-xs-9">';
259 echo
'<div class="panel panel-info">';
260 echo
'<div class="panel-heading text-center">';
261 echo
'<h4 class="title">';
265 echo
'<div class="panel-body">';
266 echo
'<form class="form-horizontal" method="post" action="'
282 $name = filter_input(
286 $description = filter_input(
290 $icon = filter_input(
294 $kernel = filter_input(
298 $kernelargs = filter_input(
302 $initrd = filter_input(
306 $type = filter_input(
310 $access = filter_input(
314 $advanced = isset($_POST[
'advanced']);
316 if (self::getClass(
'TaskTypeManager')->exists(
$name)) {
318 _(
'A task type already exists with this name!')
323 ->set(
'description', $description)
325 ->set(
'kernel', $kernel)
326 ->set(
'kernelArgs', $kernelargs)
327 ->set(
'initrd', $initrd)
329 ->set(
'isAdvanced', $advanced)
330 ->set(
'access', $access);
332 throw new Exception(_(
'Add task type failed!'));
334 $hook =
'TASK_TYPE_ADD_SUCCESS';
337 'msg' => _(
'Task Type added!'),
338 'title' => _(
'Task Type Create Success')
341 }
catch (Exception $e) {
342 $hook =
'TASK_TYPE_ADD_FAIL';
345 'error' => $e->getMessage(),
346 'title' => _(
'Task Type Create Fail')
377 ) ?: $this->obj->get(
'name')
383 ) ?: $this->obj->get(
'description')
389 ) ?: $this->obj->get(
'icon')
395 ) ?: $this->obj->get(
'kernel')
401 ) ?: $this->obj->get(
'kernelargs')
407 ) ?: $this->obj->get(
'initrd')
413 ) ?: $this->obj->get(
'type')
419 ) ?: $this->obj->get(
'access')
422 isset($_POST[
'advanced']) ?: $this->obj->get(
'advanced')
429 $accessTypes = array(
440 $this->attributes = array(
441 array(
'class' =>
'col-xs-4'),
442 array(
'class' =>
'col-xs-8 form-group'),
444 $this->templates = array(
451 .
'</label>' =>
'<div class="input-group">'
452 .
'<input type="text" name="name" id="name" value="'
454 .
'" class="form-control" autocomplete="off" '
457 '<label for="description">'
459 .
'</label>' =>
'<div class="input-group">'
460 .
'<textarea name="description" id="description" class="form-control">'
466 .
'</label>' => self::getClass(
'TaskType')->iconlist($icon),
467 '<label for="kernel">'
469 .
'</label>' =>
'<div class="input-group">'
470 .
'<input class="form-control" type="text" name="kernel" id="kernel" '
475 '<label for="kernargs">'
476 . _(
'Kernel Arguments')
477 .
'</label>' =>
'<div class="input-group">'
478 .
'<input class="form-control" type="text" name="kernelargs" id='
479 .
'"kernargs" value="'
483 '<label for="initrd">'
485 .
'</label>' =>
'<div class="input-group">'
486 .
'<textarea name="initrd" class='
487 .
'"form-control" id="initrd">'
493 .
'</label>' =>
'<div class="input-group">'
494 .
'<input class="form-control" type="text" name="type" id='
501 .
'</label>' =>
'<input type="checkbox" name="advanced" id='
505 '<label for="access">'
507 .
'</label>' => $accessSel,
508 '<label for="update">'
510 .
'</label>' =>
'<button class="btn btn-info btn-block" type="submit" '
511 .
'id="update" name="update">'
519 'fields' => &$fields,
520 'TaskType' => self::getClass(
'TaskState')
523 array_walk($fields, $this->fieldsToData);
528 'data' => &$this->data,
529 'templates' => &$this->templates,
530 'attributes' => &$this->attributes,
531 'headerData' => &$this->headerData
534 echo
'<!-- General -->';
535 echo
'<div class="tab-pane fade in active" id="tasktype-gen">';
536 echo
'<div class="panel panel-info">';
537 echo
'<div class="panel-heading text-center">';
538 echo
'<h4 class="title">';
539 echo _(
'Task Type General');
542 echo
'<div class="panel-body">';
543 echo
'<form class="form-horizontal" method="post" action="'
545 .
'&tab="taskstate-gen">';
566 echo
'<div class="col-xs-9 tab-content">';
579 'TASKTYPE_EDIT_POST',
580 array(
'TaskType' => &$this->obj)
582 $name = filter_input(
586 $description = filter_input(
590 $icon = filter_input(
594 $kernel = filter_input(
598 $kernelargs = filter_input(
602 $initrd = filter_input(
606 $type = filter_input(
610 $access = filter_input(
614 $advanced = isset($_POST[
'advanced']);
616 if ($this->obj->get(
'name') !=
$name
617 && self::getClass(
'TaskTypeManager')->exists(
$name)
620 _(
'A task type already exists with this name!')
625 ->set(
'description', $description)
627 ->set(
'kernel', $kernel)
628 ->set(
'kernelArgs', $kernelargs)
629 ->set(
'initrd', $initrd)
631 ->set(
'isAdvanced', $advanced)
632 ->set(
'access', $access);
633 if (!$this->obj->save()) {
634 throw new Exception(_(
'Update task state failed!'));
636 $hook =
'TASK_TYPE_EDIT_SUCCESS';
639 'msg' => _(
'Task Type Updated!'),
640 'title' => _(
'Task Type Update Success')
643 }
catch (Exception $e) {
644 $hook =
'TASK_TYPE_EDIT_FAIL';
647 'error' => $e->getMessage(),
648 'title' => _(
'Task Type Update Fail')
655 array(
'TaskType' => &$this->obj)