PropertyModifier: add capitalize

fixes #427
This commit is contained in:
Dirk Goetz 2017-11-24 10:58:09 +01:00 committed by Thomas Gelf
parent 777f5ff71a
commit 7fb216db4c
5 changed files with 57 additions and 5 deletions

View File

@ -2,22 +2,22 @@
# Copyright (C) 2017 Icinga Development Team # Copyright (C) 2017 Icinga Development Team
# This file is distributed under the same license as Director Module. # This file is distributed under the same license as Director Module.
# Thomas Widhalm <widhalmt@widhalm.or.at>, 2016. # Thomas Widhalm <widhalmt@widhalm.or.at>, 2016.
# #
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Director Module (master)\n" "Project-Id-Version: Director Module (master)\n"
"Report-Msgid-Bugs-To: dev@icinga.com\n" "Report-Msgid-Bugs-To: dev@icinga.com\n"
"POT-Creation-Date: 2017-10-09 15:26+0200\n" "POT-Creation-Date: 2017-11-24 10:52+0100\n"
"PO-Revision-Date: 2017-10-09 15:42+0200\n" "PO-Revision-Date: 2017-11-24 10:49+0100\n"
"Last-Translator: Thomas Gelf <thomas@gelf.net>\n" "Last-Translator: Thomas Gelf <thomas@gelf.net>\n"
"Language: de_DE\n" "Language: de_DE\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-Basepath: .\n" "X-Poedit-Basepath: .\n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.7.1\n"
"X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPath-0: .\n"
#: library/Director/Web/Form/DirectorObjectForm.php:588 #: library/Director/Web/Form/DirectorObjectForm.php:588
@ -3950,6 +3950,11 @@ msgstr "Für die Selbstbedienungs-API freigeben"
msgid "Shared for Self Service API" msgid "Shared for Self Service API"
msgstr "Für die Selbstbedienungs-API freigegeben" msgstr "Für die Selbstbedienungs-API freigegeben"
#: library/Director/PropertyModifier/PropertyModifierUpperCaseFirst.php:21
msgid "Should all the other characters be lowercased first?"
msgstr ""
"Sollen alle anderen Zeichen zuvor in Kleinbuchstaben umgewandelt werden?"
#: application/controllers/HostController.php:351 #: application/controllers/HostController.php:351
msgid "Show" msgid "Show"
msgstr "Zeigen" msgstr "Zeigen"
@ -5181,6 +5186,10 @@ msgstr "Benutzung"
msgid "Use a local file or network share" msgid "Use a local file or network share"
msgstr "Benutze eine lokales Verzeichnis oder eine Netzwerkfreigabe" msgstr "Benutze eine lokales Verzeichnis oder eine Netzwerkfreigabe"
#: library/Director/PropertyModifier/PropertyModifierUpperCaseFirst.php:18
msgid "Use lowercase first"
msgstr "Erst in Kleinbuchstaben umwandeln"
#: application/forms/SyncPropertyForm.php:244 #: application/forms/SyncPropertyForm.php:244
msgid "Used sources" msgid "Used sources"
msgstr "Verwendete Quellen" msgstr "Verwendete Quellen"

View File

@ -27,6 +27,8 @@ before switching to a new version.
however allowed to store invalid single Service Objects with no Host. This is however allowed to store invalid single Service Objects with no Host. This is
now illegal, as it never makes any sense now illegal, as it never makes any sense
* FEATURE: new Property Modifier for IPs formatted as number in Excel files (#1296) * FEATURE: new Property Modifier for IPs formatted as number in Excel files (#1296)
* FEATURE: new Property Modifier to url-encode values
* FEATURE: new Property Modifier: uppercase the first character of each word
1.4.2 1.4.2
----- -----

View File

@ -0,0 +1,40 @@
<?php
namespace Icinga\Module\Director\PropertyModifier;
use Icinga\Module\Director\Hook\PropertyModifierHook;
use Icinga\Module\Director\Web\Form\QuickForm;
class PropertyModifierUpperCaseFirst extends PropertyModifierHook
{
public function getName()
{
return 'Uppercase the first character of each word in a string';
}
public static function addSettingsFormFields(QuickForm $form)
{
$form->addElement('select', 'lowerfirst', array(
'label' => $form->translate('Use lowercase first'),
'required' => true,
'description' => $form->translate(
'Should all the other characters be lowercased first?'
),
'value' => 'y',
'multiOptions' => array(
'y' => $form->translate('Yes'),
'n' => $form->translate('No'),
),
));
}
public function transform($value)
{
if ($this->getSetting('lowerfirst', 'y') === 'y') {
return ucwords(strtolower($value));
} else {
return ucwords($value);
}
}
}

View File

@ -50,6 +50,7 @@ $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\Pro
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierCombine'); $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierCombine');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierXlsNumericIp'); $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierXlsNumericIp');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierURLEncode'); $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierURLEncode');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierUpperCaseFirst');
$this->provideHook('director/Job', $prefix . 'Job\\HousekeepingJob'); $this->provideHook('director/Job', $prefix . 'Job\\HousekeepingJob');
$this->provideHook('director/Job', $prefix . 'Job\\ConfigJob'); $this->provideHook('director/Job', $prefix . 'Job\\ConfigJob');