mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
commit
d04aa787c4
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Web\Widget\Tabextension;
|
namespace Icinga\Web\Widget\Tabextension;
|
||||||
|
|
||||||
|
use Icinga\Application\Platform;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use Icinga\Web\Widget\Tab;
|
use Icinga\Web\Widget\Tab;
|
||||||
use Icinga\Web\Widget\Tabs;
|
use Icinga\Web\Widget\Tabs;
|
||||||
@ -28,35 +29,6 @@ class OutputFormat implements Tabextension
|
|||||||
*/
|
*/
|
||||||
const TYPE_CSV = 'csv';
|
const TYPE_CSV = 'csv';
|
||||||
|
|
||||||
/**
|
|
||||||
* An array containing the tab definitions for all supported types
|
|
||||||
*
|
|
||||||
* Using array_keys on this array or isset allows to check whether a
|
|
||||||
* requested type is supported
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $supportedTypes = array(
|
|
||||||
self::TYPE_PDF => array(
|
|
||||||
'name' => 'pdf',
|
|
||||||
'title' => 'PDF',
|
|
||||||
'icon' => 'file-pdf',
|
|
||||||
'urlParams' => array('format' => 'pdf'),
|
|
||||||
),
|
|
||||||
self::TYPE_CSV => array(
|
|
||||||
'name' => 'csv',
|
|
||||||
'title' => 'CSV',
|
|
||||||
'icon' => 'file-excel',
|
|
||||||
'urlParams' => array('format' => 'csv')
|
|
||||||
),
|
|
||||||
self::TYPE_JSON => array(
|
|
||||||
'name' => 'json',
|
|
||||||
'title' => 'JSON',
|
|
||||||
'icon' => 'img/icons/json.png',
|
|
||||||
'urlParams' => array('format' => 'json')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of tabs to be added to the dropdown area
|
* An array of tabs to be added to the dropdown area
|
||||||
*
|
*
|
||||||
@ -74,7 +46,7 @@ class OutputFormat implements Tabextension
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $disabled = array())
|
public function __construct(array $disabled = array())
|
||||||
{
|
{
|
||||||
foreach ($this->supportedTypes as $type => $tabConfig) {
|
foreach ($this->getSupportedTypes() as $type => $tabConfig) {
|
||||||
if (!in_array($type, $disabled)) {
|
if (!in_array($type, $disabled)) {
|
||||||
$tabConfig['url'] = Url::fromRequest();
|
$tabConfig['url'] = Url::fromRequest();
|
||||||
$tabConfig['tagParams'] = array(
|
$tabConfig['tagParams'] = array(
|
||||||
@ -98,4 +70,44 @@ class OutputFormat implements Tabextension
|
|||||||
$tabs->addAsDropdown($tab->getName(), $tab);
|
$tabs->addAsDropdown($tab->getName(), $tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array containing the tab definitions for all supported types
|
||||||
|
*
|
||||||
|
* Using array_keys on this array or isset allows to check whether a
|
||||||
|
* requested type is supported
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getSupportedTypes()
|
||||||
|
{
|
||||||
|
$supportedTypes = array();
|
||||||
|
|
||||||
|
if (Platform::extensionLoaded('gd')) {
|
||||||
|
$supportedTypes[self::TYPE_PDF] = array(
|
||||||
|
'name' => 'pdf',
|
||||||
|
'title' => 'PDF',
|
||||||
|
'icon' => 'file-pdf',
|
||||||
|
'urlParams' => array('format' => 'pdf'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$supportedTypes[self::TYPE_CSV] = array(
|
||||||
|
'name' => 'csv',
|
||||||
|
'title' => 'CSV',
|
||||||
|
'icon' => 'file-excel',
|
||||||
|
'urlParams' => array('format' => 'csv')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Platform::extensionLoaded('json')) {
|
||||||
|
$supportedTypes[self::TYPE_JSON] = array(
|
||||||
|
'name' => 'json',
|
||||||
|
'title' => 'JSON',
|
||||||
|
'icon' => 'img/icons/json.png',
|
||||||
|
'urlParams' => array('format' => 'json')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $supportedTypes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,8 +461,8 @@ class WebWizard extends Wizard implements SetupWizard
|
|||||||
mt('setup', 'PHP Module: GD'),
|
mt('setup', 'PHP Module: GD'),
|
||||||
mt(
|
mt(
|
||||||
'setup',
|
'setup',
|
||||||
'In case you want icons being exported to PDF as'
|
'In case you want views being exported to PDF,'
|
||||||
. ' well, you\'ll need the GD extension for PHP.'
|
. ' you\'ll need the GD extension for PHP.'
|
||||||
),
|
),
|
||||||
Platform::extensionLoaded('gd'),
|
Platform::extensionLoaded('gd'),
|
||||||
Platform::extensionLoaded('gd') ? mt('setup', 'The PHP module GD is available') : (
|
Platform::extensionLoaded('gd') ? mt('setup', 'The PHP module GD is available') : (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user