From b43b8ee5e3b90348e2a659f466618e92b45a7309 Mon Sep 17 00:00:00 2001 From: Stefan Scheungrab Date: Thu, 23 Jul 2015 14:42:53 +0200 Subject: [PATCH] PropertyModifier: renamed function for adding new fields to a Form --- .../PropertyModifierRegexReplace.php | 15 +++++++++++++++ .../PropertyModifier/PropertyModifierReplace.php | 13 +++++++++++++ .../PropertyModifierStripDomain.php | 10 ++++++++++ .../PropertyModifierSubstring.php | 13 +++++++++++++ .../Director/Web/Hook/PropertyModifierHook.php | 2 +- 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/library/Director/PropertyModifier/PropertyModifierRegexReplace.php b/library/Director/PropertyModifier/PropertyModifierRegexReplace.php index d1610bfe..3b8ebee7 100644 --- a/library/Director/PropertyModifier/PropertyModifierRegexReplace.php +++ b/library/Director/PropertyModifier/PropertyModifierRegexReplace.php @@ -7,6 +7,21 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook; class PropertyModifierRegexReplace extends PropertyModifierHook { + + public static function addSettingsFormFields(QuickForm $form) + { + $form->addElement('text', 'start', array( + 'label' => 'Start index', + 'required' => true, + )); + $form->addElement('text', 'start', array( + 'label' => 'End index', + 'required' => true, + )); + return $form; + } + + public function transform($value) { return preg_replace($this->settings['pattern'], $this->settings['replacement'], $value); diff --git a/library/Director/PropertyModifier/PropertyModifierReplace.php b/library/Director/PropertyModifier/PropertyModifierReplace.php index c96b682c..02fb903d 100644 --- a/library/Director/PropertyModifier/PropertyModifierReplace.php +++ b/library/Director/PropertyModifier/PropertyModifierReplace.php @@ -7,6 +7,19 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook; class PropertyModifierReplace PropertyModifierHook { + public static function addSettingsFormFields(QuickForm $form) + { + $form->addElement('text', 'string', array( + 'label' => 'Search string', + 'required' => true, + )); + $form->addElement('text', 'replacement', array( + 'label' => 'Replacement', + 'required' => true, + )); + return $form; + } + public function transform($value) { return str_replace($this->settings['string'], $this->settings['replacement'], $value); diff --git a/library/Director/PropertyModifier/PropertyModifierStripDomain.php b/library/Director/PropertyModifier/PropertyModifierStripDomain.php index c778fd19..b39df21d 100644 --- a/library/Director/PropertyModifier/PropertyModifierStripDomain.php +++ b/library/Director/PropertyModifier/PropertyModifierStripDomain.php @@ -7,6 +7,16 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook; class PropertyModifierStripDomain extends PropertyModifierHook { + public static function addSettingsFormFields(QuickForm $form) + { + $form->addElement('text', 'domain', array( + 'label' => 'Domain name', + 'description' => 'Domain to be replaced', + 'required' => true, + )); + return $form; + } + public function transform($value) { return preg_replace($this->settings['domain'], "", $value); diff --git a/library/Director/PropertyModifier/PropertyModifierSubstring.php b/library/Director/PropertyModifier/PropertyModifierSubstring.php index 2bb34a34..321da760 100644 --- a/library/Director/PropertyModifier/PropertyModifierSubstring.php +++ b/library/Director/PropertyModifier/PropertyModifierSubstring.php @@ -7,6 +7,19 @@ use Icinga\Module\Director\Web\Hook\PropertyModifierHook; class PropertyModifierSubstring extends PropertyModifierHook { + public static function addSettingsFormFields(QuickForm $form) + { + $form->addElement('text', 'pattern', array( + 'label' => 'Regex pattern', + 'required' => true, + )); + $form->addElement('text', 'replacement', array( + 'label' => 'Replacement', + 'required' => true, + )); + return $form; + } + public function transform($value) { return substr($value, $this->settings['start'], $this->settings['end'] - $this->settings['start']); diff --git a/library/Director/Web/Hook/PropertyModifierHook.php b/library/Director/Web/Hook/PropertyModifierHook.php index d2b32837..e9edd681 100644 --- a/library/Director/Web/Hook/PropertyModifierHook.php +++ b/library/Director/Web/Hook/PropertyModifierHook.php @@ -81,7 +81,7 @@ abstract class PropertyModifierHook * @param QuickForm $form QuickForm that should be extended * @return QuickForm */ - public static function addPropertiesFormFields(QuickForm $form) + public static function addSettingsFormFields(QuickForm $form) { return $form; }