create a new module called IVAOFlightPlan (so create a module in core/modules called that), then inside that create IVAOFlightPlan.php, then inside that, paste this:
<?php
class IVAOFlightPlan extends CodonModule
{
public function download_ivao($schedule_id='')
{
// Make sure they specified a schedule
if($schedule_id == '')
{
$this->set('message', 'No Schedule specified');
$this->render('core_error.tpl');
return;
}
$schedule = SchedulesData::findSchedules(array('s.id'=>$schedule_id), 1);
// Make sure the schedule was valid/exists
if(!$schedule)
{
$this->set('message', 'The schedule doesn't exist!');
$this->render('core_error.tpl');
return;
}
// Now write out our template file
$this->set('schedule', $schedule[0]);
$file = $this->get('ivao_flightplan.tpl');
// And send it to the browser to download
Util::downloadFile($file, 'ivao_flightplan.fpl');
}
}
The Util::downloadFile() function will be available after tonight’s commit. If you don’t want ot wait, replace that line with:
# Set the headers so the browser things a file is being sent
$filename = 'ivao_flightplan.fpl';
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Length: ' . strlen($file));
echo $file;
You can change the filename to what you want it to be, I’ll let you figure that out
Create in core/templates a file called ‘ivao_flightplan.tpl’, and paste your flightplan code into it
Then you should be all set. You can add different flight plan types the same way (adding a public function download_XXXX($schedule_id) and then you can have different flight plan types within the same module.
Hope that helps, it might not work exactly, but should be the general gist of it
i installed the latest beta and the download works, but now i got the first lines of the header.tpl ;D
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Sorry for popping up an old topic but i receive this error:
Parse error: syntax error, unexpected T_STRING in /home/aireu/domains/aireuropa-virtual.com/public_html/core/modules/IVAOFlightPlan/IVAOFlightPlan.php on line 19