array( 'name' => 'pdf', 'title' => 'PDF', 'icon' => 'img/icons/pdf.png', 'urlParams' => array('format' => 'pdf'), ), self::TYPE_CSV => array( 'name' => 'csv', 'title' => 'CSV', 'icon' => 'img/icons/csv.png', '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 * * @var array */ private $tabs = array(); /** * Create a new OutputFormat extender * * In general, it's assumed that all types are supported when an outputFormat extension * is added, so this class offers to remove specific types instead of adding ones * * @param array $disabled An array of output types to not show. */ public function __construct(array $disabled = array()) { foreach ($this->supportedTypes as $type => $tabConfig) { if (!in_array($type, $disabled)) { $tabConfig['url'] = Url::fromRequest(); $tabConfig['tagParams'] = array( 'target' => '_blank' ); $this->tabs[] = new Tab($tabConfig); } } } /** * Applies the format selectio to the provided tabset * * @param Tabs $tabs The tabs object to extend with * * @see Tabextension::apply() */ public function apply(Tabs $tabs) { foreach ($this->tabs as $tab) { $tabs->addAsDropdown($tab->getName(), $tab); } } }