adminBoxDownload()
public function adminBoxDownload($path, $settingGroup, &$box, &$fields, &$values, $changes) { //...your PHP code...// }
Use this method to serve file downloads when saving Admin Boxes.
This Method is run when an Admin saves an Admin Box with the confirm/download set, e.g.:
confirm: download: true
It's run after your saveAdminBox() method.
From Zenario 7.0.0 onwards.
$path
The path of the Admin Box opened.
$settingGroup
When showing an Admin Box for Plugin Settings or Site Settings, this variable will contain the name of the Module or Settings Group.
$box
The TUIX that defines your Admin Box, in the form of a PHP array.
You should make changes to this array as needed.
$fields
Shortcuts to the field definitions in your Admin Box.
E.g. $fields['tab_name/field_name'] references $box['tabs']['tab_name']['fields']['field_name']
$values
Shortcuts to the field values in your Admin Box.
E.g. $values['tab_name/field_name'] references $box['tabs']['tab_name']['fields']['field_name']['current_value']
$changes
This parameter currently deprecated and should not be used. In the future it may be replaced by something more useful.
No return value is needed.
public function adminBoxDownload($path, $settingGroup, &$box, &$fields, &$values, $changes) {
$contents = 'Hello World';
header('Content-Type: text/plain; charset=UTF-8');
header('Content-Disposition: attachment; filename="hello_world.txt"');
header('Content-Length: '. strlen($contents));
echo $contents;
}
This is a simple "Hello World" example; this offers a file called hello_world.txt
which contains the text "Hello World".
In a real life case the content would most likely be dynamically generated.
Note that the Content-Length
header is optional, but we recommend that you include it if you can.