2015-07-23 14:29:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\PropertyModifier;
|
|
|
|
|
2016-02-17 11:11:05 +01:00
|
|
|
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
2016-02-18 23:21:28 +01:00
|
|
|
use Icinga\Module\Director\Web\Form\QuickForm;
|
2015-07-23 14:29:15 +02:00
|
|
|
|
|
|
|
class PropertyModifierSubstring extends PropertyModifierHook
|
|
|
|
{
|
2015-07-23 14:42:53 +02:00
|
|
|
public static function addSettingsFormFields(QuickForm $form)
|
|
|
|
{
|
2016-03-05 17:04:13 +01:00
|
|
|
$form->addElement('text', 'start', array(
|
|
|
|
'label' => 'Start',
|
|
|
|
'required' => true,
|
|
|
|
'description' => sprintf(
|
|
|
|
$form->translate(
|
2016-03-06 00:37:03 +01:00
|
|
|
'Please see %s for detailled instructions of how start and end work'
|
2016-03-05 17:04:13 +01:00
|
|
|
),
|
|
|
|
'http://php.net/manual/en/function.substr.php'
|
|
|
|
)
|
2015-07-23 14:42:53 +02:00
|
|
|
));
|
2016-02-18 23:21:28 +01:00
|
|
|
|
2016-03-05 17:04:13 +01:00
|
|
|
$form->addElement('text', 'length', array(
|
|
|
|
'label' => 'End',
|
2016-03-06 00:37:03 +01:00
|
|
|
'description' => sprintf(
|
|
|
|
$form->translate(
|
|
|
|
'Please see %s for detailled instructions of how start and end work'
|
|
|
|
),
|
|
|
|
'http://php.net/manual/en/function.substr.php'
|
|
|
|
)
|
2015-07-23 14:42:53 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2015-07-23 14:29:15 +02:00
|
|
|
public function transform($value)
|
|
|
|
{
|
2016-03-05 17:04:13 +01:00
|
|
|
return substr($value, $this->getSetting('start'), $this->getSetting('length'));
|
2015-07-23 14:29:15 +02:00
|
|
|
}
|
|
|
|
}
|