-
Notifications
You must be signed in to change notification settings - Fork 0
/
LabTool.php
70 lines (64 loc) · 1.76 KB
/
LabTool.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
<?php
/**
* Infinity Fab Lab Charge Class
*
* Developed for the Infinity Fab Lab at the University of Florida.
* Defines a Lab Charge page type which holds data and behaviors relevant to an
* individual charge.
*
* Thomas R Storey, 2016
* Licensed under MIT License, see LICENSE.TXT
*
* http://fablab.arts.ufl.edu
* https://github.com/UF-Asq-Fab-Lab
*/
class LabTool extends Page {
/**
* Create a new Lab Charge page in memory.
*
* @param Template $tpl Template object this page should use.
*
*/
public function __construct(Template $tpl = null) {
if(is_null($tpl)) $tpl = $this->wire('templates')->get('lab_tool');
if(!$this->parent_id) $this->set('parent_id', $this->wire('modules')->getModuleConfigData("LabScheduler")['lab_tools_id']);
parent::__construct($tpl);
}
/**
* Returns the URL where this page can be edited
*
* In this case we adjust the default page editor URL to ensure lab charges
* are edited only from the Charger section.
*
* @return string
*
*/
public function editUrl() {
return str_replace('/page/edit/',
'/lab_scheduler/lab_tools/edit/',
parent::editUrl());
}
/**
* Set the Process module (WirePageEditor) that is editing this User
*
* We use this to detect when the Lab Charge is being edited somewhere outside
* of /charger/lab_charges/
*
* @param WirePageEditor $editor
*
*/
public function ___setEditor(WirePageEditor $editor) {
parent::___setEditor($editor);
if(!$editor instanceof ProcessLabTool) $this->wire('session')->redirect($this->editUrl());
}
/**
* Return the API variable used for managing pages of this type
*
* @return Pages|PagesType
*
*/
public function getPagesManager() {
return $this->wire('lab_tools');
}
}
?>