mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 13:54:26 +02:00
NavigationConfigForm: Provide proper labels for navigation item types
refs #5600
This commit is contained in:
parent
ffb54e0ecb
commit
2cd774018c
@ -22,10 +22,7 @@ class NavigationConfigForm extends ConfigForm
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $defaultItemTypes = array(
|
protected $defaultItemTypes;
|
||||||
'menu-item',
|
|
||||||
'dashlet'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The secondary configuration to write
|
* The secondary configuration to write
|
||||||
@ -72,6 +69,11 @@ class NavigationConfigForm extends ConfigForm
|
|||||||
{
|
{
|
||||||
$this->setName('form_config_navigation');
|
$this->setName('form_config_navigation');
|
||||||
$this->setSubmitLabel($this->translate('Save Changes'));
|
$this->setSubmitLabel($this->translate('Save Changes'));
|
||||||
|
|
||||||
|
$this->defaultItemTypes = array(
|
||||||
|
'menu-item' => $this->translate('Menu Entry'),
|
||||||
|
'dashlet' => 'Dashlet'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -328,7 +330,7 @@ class NavigationConfigForm extends ConfigForm
|
|||||||
public function createElements(array $formData)
|
public function createElements(array $formData)
|
||||||
{
|
{
|
||||||
$itemTypes = $this->listItemTypes();
|
$itemTypes = $this->listItemTypes();
|
||||||
$itemType = isset($formData['type']) ? $formData['type'] : reset($itemTypes);
|
$itemType = isset($formData['type']) ? $formData['type'] : key($itemTypes);
|
||||||
|
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
@ -389,7 +391,7 @@ class NavigationConfigForm extends ConfigForm
|
|||||||
'autosubmit' => true,
|
'autosubmit' => true,
|
||||||
'label' => $this->translate('Type'),
|
'label' => $this->translate('Type'),
|
||||||
'description' => $this->translate('The type of this navigation item'),
|
'description' => $this->translate('The type of this navigation item'),
|
||||||
'multiOptions' => array_combine($itemTypes, $itemTypes)
|
'multiOptions' => $itemTypes
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -440,10 +442,9 @@ class NavigationConfigForm extends ConfigForm
|
|||||||
protected function listItemTypes()
|
protected function listItemTypes()
|
||||||
{
|
{
|
||||||
$types = $this->defaultItemTypes;
|
$types = $this->defaultItemTypes;
|
||||||
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $module) {
|
foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $moduleName => $module) {
|
||||||
$moduleItems = $module->getNavigationItems();
|
foreach ($module->getNavigationItems() as $type => $label) {
|
||||||
if (! empty($moduleItems)) {
|
$types[$type] = mt($moduleName, $label);
|
||||||
$types = array_merge($types, $moduleItems);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user