2014-09-02 09:39:21 -04:00
|
|
|
<?php
|
2015-02-03 09:49:34 -05:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt */
|
2014-09-02 09:39:21 -04:00
|
|
|
|
2014-11-14 04:57:14 -05:00
|
|
|
namespace Icinga\Forms\Config\Resource;
|
2014-09-02 09:39:21 -04:00
|
|
|
|
|
|
|
|
use Icinga\Web\Form;
|
|
|
|
|
use Icinga\Web\Form\Validator\ReadablePathValidator;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Form class for adding/modifying file resources
|
|
|
|
|
*/
|
|
|
|
|
class FileResourceForm extends Form
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Initialize this form
|
|
|
|
|
*/
|
|
|
|
|
public function init()
|
|
|
|
|
{
|
|
|
|
|
$this->setName('form_config_resource_file');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see Form::createElements()
|
|
|
|
|
*/
|
|
|
|
|
public function createElements(array $formData)
|
|
|
|
|
{
|
2014-09-29 05:20:39 -04:00
|
|
|
$this->addElement(
|
|
|
|
|
'text',
|
|
|
|
|
'name',
|
|
|
|
|
array(
|
|
|
|
|
'required' => true,
|
2015-01-19 05:26:23 -05:00
|
|
|
'label' => $this->translate('Resource Name'),
|
|
|
|
|
'description' => $this->translate('The unique name of this resource')
|
2014-09-29 05:20:39 -04:00
|
|
|
)
|
|
|
|
|
);
|
2014-09-03 06:21:31 -04:00
|
|
|
$this->addElement(
|
|
|
|
|
'text',
|
|
|
|
|
'filename',
|
|
|
|
|
array(
|
|
|
|
|
'required' => true,
|
2015-01-19 05:26:23 -05:00
|
|
|
'label' => $this->translate('Filepath'),
|
|
|
|
|
'description' => $this->translate('The filename to fetch information from'),
|
2014-09-03 06:21:31 -04:00
|
|
|
'validators' => array(new ReadablePathValidator())
|
2014-09-02 09:39:21 -04:00
|
|
|
)
|
|
|
|
|
);
|
2014-09-03 06:21:31 -04:00
|
|
|
$this->addElement(
|
|
|
|
|
'text',
|
|
|
|
|
'fields',
|
|
|
|
|
array(
|
|
|
|
|
'required' => true,
|
2015-01-19 05:26:23 -05:00
|
|
|
'label' => $this->translate('Pattern'),
|
|
|
|
|
'description' => $this->translate('The regular expression by which to identify columns')
|
2014-09-03 06:21:31 -04:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return $this;
|
2014-09-02 09:39:21 -04:00
|
|
|
}
|
|
|
|
|
}
|