mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 09:14:08 +02:00
parent
af3f80f873
commit
76cf01869e
@ -29,6 +29,22 @@ class NavigationItemForm extends Form
|
|||||||
*/
|
*/
|
||||||
public function createElements(array $formData)
|
public function createElements(array $formData)
|
||||||
{
|
{
|
||||||
|
$this->addElement(
|
||||||
|
'select',
|
||||||
|
'target',
|
||||||
|
array(
|
||||||
|
'allowEmpty' => true,
|
||||||
|
'label' => $this->translate('Target'),
|
||||||
|
'description' => $this->translate('The target where to open this navigation item\'s url'),
|
||||||
|
'multiOptions' => array(
|
||||||
|
'_blank' => $this->translate('New Window'),
|
||||||
|
'_next' => $this->translate('New Column'),
|
||||||
|
'_main' => $this->translate('Single Column'),
|
||||||
|
'_self' => $this->translate('Current Column')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$this->addElement(
|
$this->addElement(
|
||||||
'text',
|
'text',
|
||||||
'url',
|
'url',
|
||||||
@ -36,7 +52,7 @@ class NavigationItemForm extends Form
|
|||||||
'allowEmpty' => true,
|
'allowEmpty' => true,
|
||||||
'label' => $this->translate('Url'),
|
'label' => $this->translate('Url'),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'The url of this navigation item. Leave blank if you only want the name being displayed.'
|
'The url of this navigation item. Leave blank if you only want the name being displayed'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -48,7 +64,7 @@ class NavigationItemForm extends Form
|
|||||||
'allowEmpty' => true,
|
'allowEmpty' => true,
|
||||||
'label' => $this->translate('Icon'),
|
'label' => $this->translate('Icon'),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'The icon of this navigation item. Leave blank if you do not want a icon being displayed.'
|
'The icon of this navigation item. Leave blank if you do not want a icon being displayed'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -94,6 +94,13 @@ class NavigationItem implements IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This item's url target
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional parameters for this item's url
|
* Additional parameters for this item's url
|
||||||
*
|
*
|
||||||
@ -445,6 +452,29 @@ class NavigationItem implements IteratorAggregate
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set this item's url target
|
||||||
|
*
|
||||||
|
* @param string $target
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTarget($target)
|
||||||
|
{
|
||||||
|
$this->target = $target;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return this item's url target
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTarget()
|
||||||
|
{
|
||||||
|
return $this->target;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return this item's url
|
* Return this item's url
|
||||||
*
|
*
|
||||||
|
@ -28,13 +28,6 @@ class NavigationItemRenderer
|
|||||||
*/
|
*/
|
||||||
protected $item;
|
protected $item;
|
||||||
|
|
||||||
/**
|
|
||||||
* The link target
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $target;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new NavigationItemRenderer
|
* Create a new NavigationItemRenderer
|
||||||
*
|
*
|
||||||
@ -124,29 +117,6 @@ class NavigationItemRenderer
|
|||||||
return $this->item;
|
return $this->item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the link target
|
|
||||||
*
|
|
||||||
* @param string $target
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setTarget($target)
|
|
||||||
{
|
|
||||||
$this->target = $target;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the link target
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTarget()
|
|
||||||
{
|
|
||||||
return $this->target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the given navigation item as HTML anchor
|
* Render the given navigation item as HTML anchor
|
||||||
*
|
*
|
||||||
@ -175,7 +145,7 @@ class NavigationItemRenderer
|
|||||||
'<a%s href="%s"%s>%s</a>',
|
'<a%s href="%s"%s>%s</a>',
|
||||||
$this->view()->propertiesToString($item->getAttributes()),
|
$this->view()->propertiesToString($item->getAttributes()),
|
||||||
$this->view()->url($url, $item->getUrlParameters()),
|
$this->view()->url($url, $item->getUrlParameters()),
|
||||||
$this->target ? ' target="' . $this->view()->escape($this->target) . '"' : '',
|
$this->renderTargetAttribute(),
|
||||||
$label
|
$label
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -189,4 +159,23 @@ class NavigationItemRenderer
|
|||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render and return the attribute to provide a non-default target for the url
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function renderTargetAttribute()
|
||||||
|
{
|
||||||
|
$target = $this->getItem()->getTarget();
|
||||||
|
if ($target === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! in_array($target, array('_main', '_self', '_next'))) {
|
||||||
|
return ' target="' . $this->view()->escape($target) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ' data-base-target="' . $target . '"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user