summaryrefslogtreecommitdiffstats
path: root/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php')
-rw-r--r--modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php
new file mode 100644
index 00000000..2e2e5009
--- /dev/null
+++ b/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php
@@ -0,0 +1,91 @@
+<?php
+
+abstract class BootEntryHook
+{
+
+ /**
+ * @var string -- set by ipxe, not module implementing hook
+ */
+ public $moduleId;
+ /**
+ * @var string -- set by ipxe, not module implementing hook
+ */
+ public $checked;
+
+ private $selectedId;
+
+ public abstract function name();
+
+ /**
+ * @return HookEntryGroup[]
+ */
+ protected abstract function groupsInternal();
+
+ /**
+ * @param $id
+ * @return BootEntry|null the actual boot entry instance for given entry, null if invalid id
+ */
+ public abstract function getBootEntry($id);
+
+ /**
+ * @return HookEntryGroup[]
+ */
+ public final function groups()
+ {
+ $groups = $this->groupsInternal();
+ foreach ($groups as $group) {
+ foreach ($group->entries as $entry) {
+ if ($entry->id === $this->selectedId) {
+ $entry->selected = 'selected';
+ }
+ }
+ }
+ return $groups;
+ }
+
+ public function setSelected($id)
+ {
+ $this->selectedId = $id;
+ }
+
+}
+
+class HookEntryGroup
+{
+ /**
+ * @var string
+ */
+ public $groupName;
+ /**
+ * @var HookEntry[]
+ */
+ public $entries;
+
+ public function __construct($groupName, $entries)
+ {
+ $this->groupName = $groupName;
+ $this->entries = $entries;
+ }
+}
+
+class HookEntry
+{
+ /**
+ * @var string
+ */
+ public $id;
+ /**
+ * @var string
+ */
+ public $name;
+ /**
+ * @var string internal - to be set by ipxe module
+ */
+ public $selected;
+
+ public function __construct($id, $name)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ }
+} \ No newline at end of file