1 | <?php |
||
17 | class ExportableButton extends ButtonDropdown |
||
18 | { |
||
19 | /** |
||
20 | * @var string the action to submit to download exported data |
||
21 | */ |
||
22 | public $url; |
||
23 | /** |
||
24 | * @var string the button label |
||
25 | */ |
||
26 | public $label = 'Export'; |
||
27 | /** |
||
28 | * @var array the export types available. You can modify the list to display only certain types. For example, |
||
29 | * |
||
30 | * ``` |
||
31 | * 'types' => [ 'xml' => 'As XML'] |
||
32 | * ``` |
||
33 | * |
||
34 | * Will display only XML as the unique type of exportation. Defaults to all possible options available. |
||
35 | * |
||
36 | * The items are a key => label structure. The types (keys) will be used as a post value that will define the type |
||
37 | * that needs to be exported whether by the ExportableAction or the ExportableBehavior when used with our |
||
38 | * GridView Library. |
||
39 | * |
||
40 | * @see https://github.com/2amigos/yii2-grid-view-library |
||
41 | */ |
||
42 | public $types = [ |
||
43 | TypeHelper::CSV => 'CSV <span class="label label-default">.csv</span>', |
||
44 | TypeHelper::XLSX => 'Excel 2007+ <span class="label label-default">.xlsx</span>', |
||
45 | TypeHelper::ODS => 'Open Document Spreadsheet <span class="label label-default">.ods</span>', |
||
46 | TypeHelper::JSON => 'JSON <span class="label label-default">.json</span>', |
||
47 | TypeHelper::XML => 'XML <span class="label label-default">.xml</span>', |
||
48 | TypeHelper::TXT => 'Text <span class="label label-default">.txt</span>', |
||
49 | TypeHelper::HTML => 'HTML <span class="label label-default">.html</span>' |
||
50 | ]; |
||
51 | |||
52 | /** |
||
53 | * @inheritdoc |
||
54 | */ |
||
55 | public function init() |
||
61 | |||
62 | /** |
||
63 | * @inheritdoc |
||
64 | */ |
||
65 | public function run() |
||
75 | |||
76 | /** |
||
77 | * Initializes the dropdown items |
||
78 | */ |
||
79 | public function initDropdownItems() |
||
96 | |||
97 | /** |
||
98 | * Registers client script for the plugin |
||
99 | */ |
||
100 | protected function registerClientScript() |
||
113 | } |
||
114 |