From 3e02d5aff85babc3ffbfcf52313f2108e313aa23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:46:43 +0200 Subject: Adding upstream version 2.12.1. Signed-off-by: Daniel Baumann --- .../library/Monitoring/Web/Widget/SelectBox.php | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Web/Widget/SelectBox.php (limited to 'modules/monitoring/library/Monitoring/Web/Widget/SelectBox.php') diff --git a/modules/monitoring/library/Monitoring/Web/Widget/SelectBox.php b/modules/monitoring/library/Monitoring/Web/Widget/SelectBox.php new file mode 100644 index 0000000..48b98ac --- /dev/null +++ b/modules/monitoring/library/Monitoring/Web/Widget/SelectBox.php @@ -0,0 +1,120 @@ +name = $name; + $this->values = $values; + $this->label = $label; + $this->parameter = $param; + } + + /** + * Apply the parameters from the given request on this widget + * + * @param Request $request The request to use for populating the form + */ + public function applyRequest(Request $request) + { + $this->request = $request; + } + + /** + * Return the chosen interval value or null + * + * @param Request $request The request to fetch the value from + * + * @return string|null + */ + public function getInterval(Request $request = null) + { + if ($request === null && $this->request) { + $request = $this->request; + } + + if ($request) { + return $request->getParam('interval'); + } + } + + /** + * Renders this widget and returns the HTML as a string + * + * @return string + */ + public function render() + { + $form = new Form(); + $form->setAttrib('class', Form::DEFAULT_CLASSES . ' inline'); + $form->setMethod('GET'); + $form->setUidDisabled(); + $form->setTokenDisabled(); + $form->setName($this->name); + $form->addElement( + 'select', + $this->parameter, + array( + 'label' => $this->label, + 'multiOptions' => $this->values, + 'autosubmit' => true + ) + ); + + if ($this->request) { + $form->populate($this->request->getParams()); + } + + return $form; + } +} -- cgit v1.2.3