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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
<?php
namespace Icinga\Module\Graphite\Web\Controller;
use Icinga\Module\Graphite\Forms\TimeRangePicker\CommonForm;
use Icinga\Module\Graphite\Forms\TimeRangePicker\CustomForm;
use Icinga\Web\Request;
use Icinga\Web\Url;
use Icinga\Web\View;
trait TimeRangePickerTrait
{
/**
* @var CommonForm
*/
protected $timeRangePickerCommonForm;
/**
* @var CustomForm
*/
protected $timeRangePickerCustomForm;
/**
* Process the given request using the forms
*
* @param Request $request The request to be processed
*
* @return Request The request supposed to be processed
*/
protected function handleTimeRangePickerRequest(Request $request = null)
{
$this->getTimeRangePickerCommonForm()->handleRequest($request);
return $this->getTimeRangePickerCustomForm()->handleRequest($request);
}
/**
* Render all needed forms and links
*
* @param View $view
*
* @return string
*/
protected function renderTimeRangePicker(View $view)
{
$url = Url::fromRequest()->getAbsoluteUrl();
return '<div class="timerangepicker-container">'
. $this->getTimeRangePickerCommonForm()
. '<div class="flyover flyover-arrow-top" data-flyover-suspends-auto-refresh id="'
. $view->protectId('graphite-customrange')
. '">'
. $view->qlink(null, '#', null, [
'title' => $view->translate('Specify custom time range'),
'class' => 'button-link flyover-toggle',
'icon' => 'service'
])
. '<div class="flyover-content">' . $this->getTimeRangePickerCustomForm() . '</div>'
. '</div>'
. '</div>';
}
/**
* Get {@link timeRangePickerCommonForm}
*
* @return CommonForm
*/
public function getTimeRangePickerCommonForm()
{
if ($this->timeRangePickerCommonForm === null) {
$this->timeRangePickerCommonForm = new CommonForm();
}
return $this->timeRangePickerCommonForm;
}
/**
* Set {@link timeRangePickerCommonForm}
*
* @param CommonForm $timeRangePickerCommonForm
*
* @return $this
*/
public function setTimeRangePickerCommonForm(CommonForm $timeRangePickerCommonForm)
{
$this->timeRangePickerCommonForm = $timeRangePickerCommonForm;
return $this;
}
/**
* Get {@link timeRangePickerCustomForm}
*
* @return CustomForm
*/
public function getTimeRangePickerCustomForm()
{
if ($this->timeRangePickerCustomForm === null) {
$this->timeRangePickerCustomForm = new CustomForm();
}
return $this->timeRangePickerCustomForm;
}
/**
* Set {@link timeRangePickerCustomForm}
*
* @param CustomForm $timeRangePickerCustomForm
*
* @return $this
*/
public function setTimeRangePickerCustomForm(CustomForm $timeRangePickerCustomForm)
{
$this->timeRangePickerCustomForm = $timeRangePickerCustomForm;
return $this;
}
}
|