本文整理匯總了PHP中It::downloadFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP It::downloadFile方法的具體用法?PHP It::downloadFile怎麽用?PHP It::downloadFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類It
的用法示例。
在下文中一共展示了It::downloadFile方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionScheduleTypeDownload
public function actionScheduleTypeDownload()
{
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
if ((int) $id) {
$report = new ScheduleTypeReportProcessed();
$reportResult = $report->with('ex_schedule_report')->findByPk($id);
$reportResult->file_content;
$extension = $reportResult->ex_schedule_report->report_format;
$file_name = $reportResult->check_period_start . ' - ' . $reportResult->check_period_end;
$report_string = !empty($reportResult->file_content) ? $reportResult->file_content : '';
$file_name .= '.' . $extension;
It::downloadFile($report_string, $file_name);
} else {
$this->redirect($_SERVER['HTTP_REFERER']);
}
}
示例2: createExport
//.........這裏部分代碼省略.........
ssf.has_filters,
ssf.has_filter_min,
ssf.has_filter_max,
ssf.has_filter_diff,
ssf.is_constant,
ssf.is_cumulative,
ssf.created,
ssf.updated
')->from('station_sensor_feature ssf')->queryAll();
$tablesArray['station_sensor_feature'] = $station_sensor_featureTable;
$sensor_handler_defaultTable = Yii::app()->db->createCommand()->select('
sh.handler_id,
sh.handler_id_code,
sh.display_name,
sh.handler_default_display_name,
sh.default_prefix,
sh.aws_panel_display_position,
sh.aws_panel_show,
sh.aws_single_display_position,
sh.aws_single_group,
sh.aws_station_uses,
sh.rain_station_uses,
sh.awa_station_uses,
sh.flags,
sh.start_time,
sh.created,
sh.updated
')->from('sensor_handler sh')->queryAll();
$tablesArray['sensor_handler'] = $sensor_handler_defaultTable;
$sensor_handler_default_featureTable = Yii::app()->db->createCommand()->select('
shdf.handler_feature_id,
shdf.handler_id,
shdf.feature_code,
shdf.aws_panel_show,
shdf.feature_constant_value,
shdf.metric_id,
shdf.filter_max,
shdf.filter_min,
shdf.filter_diff,
shdf.created,
shdf.updated
')->from('sensor_handler_default_feature shdf')->queryAll();
$tablesArray['sensor_handler_default_feature'] = $sensor_handler_default_featureTable;
$schedule_reportTable = Yii::app()->db->createCommand()->select('
sr.schedule_id,
sr.report_type,
sr.station_id,
sr.send_like_attach,
sr.send_email_together,
sr.period,
sr.report_format,
sr.last_scheduled_run_fact,
sr.last_scheduled_run_planned,
sr.created,
sr.updated
')->from('schedule_report sr')->queryAll();
$tablesArray['schedule_report'] = $schedule_reportTable;
$schedule_report_to_stationTable = Yii::app()->db->createCommand()->select('
srts.id,
srts.schedule_id,
srts.station_id
')->from('schedule_report_to_station srts')->queryAll();
$tablesArray['schedule_report_to_station'] = $schedule_report_to_stationTable;
$schedule_report_destinationTable = Yii::app()->db->createCommand()->select('
srd.schedule_destination_id,
srd.schedule_id,
srd.method,
srd.destination_email,
srd.destination_local_folder,
srd.destination_ip,
srd.destination_ip_port,
srd.destination_ip_folder,
srd.destination_ip_user,
srd.destination_ip_password
')->from('schedule_report_destination srd')->queryAll();
$tablesArray['schedule_report_destination'] = $schedule_report_destinationTable;
$ex_schedule_reportTable = Yii::app()->db->createCommand()->from('ex_schedule_report esr')->queryAll();
$tablesArray['ex_schedule_report'] = $ex_schedule_reportTable;
$ex_schedule_report_destinationTable = Yii::app()->db->createCommand()->from('ex_schedule_report_destination esrd')->queryAll();
$tablesArray['ex_schedule_report_destination'] = $ex_schedule_report_destinationTable;
// $ex_schedule_report_processedTable = Yii::app()->db->createCommand()
// ->from('ex_schedule_report_processed esrp')
// ->queryAll();
// $tablesArray['ex_schedule_report_processed'] = $ex_schedule_report_processedTable;
// $ex_schedule_send_logTable = Yii::app()->db->createCommand()
//
// ->from('ex_schedule_send_log essl')
// ->queryAll();
// $tablesArray['ex_schedule_send_log'] = $ex_schedule_send_logTable;
$settingsArray['common_settings'] = true;
$resultArray['config'] = $settingsArray;
$resultArray['data'] = $tablesArray;
$result = serialize($resultArray);
$additional = "";
if ($settingsArray['user_settings']) {
$additional = "_users";
}
$fileName = 'settings_export' . $additional . '_' . date('Y_m_d_H_i_s') . '.conf';
It::downloadFile($result, $fileName, 'text/conf');
}
示例3: actionScheduleDownload
public function actionScheduleDownload()
{
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
$process = ScheduleReportProcessed::model()->with('ScheduleReportToStation.realStation')->with('ScheduleReportToStation.schedule_report')->findByPk($id);
if (!$process) {
$this->redirect($_SERVER['HTTP_REFERER']);
}
$station = $process->ScheduleReportToStation->realStation;
$schedule = $process->ScheduleReportToStation->schedule_report;
$file_name = $station->station_id_code . '_' . strtoupper($schedule->report_type) . '_' . gmdate('Y-m-d_Hi', strtotime($process->check_period_end ? $process->check_period_end : $process->created)) . '.' . $schedule->report_format;
$file_path = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . "schedule_reports" . DIRECTORY_SEPARATOR . $id;
$report_string = file_exists($file_path) ? file_get_contents($file_path) : ($report_string = '');
It::downloadFile($report_string, $file_name);
}
示例4: createExport
public function createExport()
{
$return_string = "";
$sql = "SELECT\n `t1`.`measuring_timestamp` AS `TxDateTime`,\n `t4`.`station_id_code` AS `StationId`, \n `t4`.`display_name` AS `StationDisplayName`,\n `t3`.`sensor_id_code` AS `SensorId`, \n `t3`.`display_name` AS `SensorDisplayName`, \n \n `t1`.`period` AS `MeasurementPeriod`,\n `t1`.`sensor_feature_value` AS `Value`,\n `t5`.`short_name` AS `Metric`,\n `t8`.`value` AS `DewPoint`,\n `t11`.`value` AS `PressureMSL`,\n \n `t12`.`handler_id_code`,\n `t4`.`magnetic_north_offset`\n\n FROM `" . SensorData::model()->tableName() . "` t1\n LEFT JOIN `" . StationSensorFeature::model()->tableName() . "` `t2` ON `t2`.`sensor_feature_id` = `t1`.`sensor_feature_id`\n LEFT JOIN `" . StationSensor::model()->tableName() . "` `t3` ON `t3`.`station_sensor_id` = `t2`.`sensor_id`\n LEFT JOIN `" . Station::model()->tableName() . "` `t4` ON `t4`.`station_id` = `t1`.`station_id`\n LEFT JOIN `" . RefbookMetric::model()->tableName() . "` `t5` ON `t5`.`metric_id` = `t2`.`metric_id`\n\n LEFT JOIN `" . StationCalculation::model()->tableName() . "` `t6` ON (`t6`.`station_id` = `t1`.`station_id` AND `t6`.`handler_id` = 1)\n LEFT JOIN `" . StationCalculationVariable::model()->tableName() . "` `t7` ON (`t7`.`sensor_feature_id` = `t2`.`sensor_feature_id` AND `t7`.`calculation_id` = `t6`.`calculation_id`)\n LEFT JOIN `" . StationCalculationData::model()->tableName() . "` `t8` ON (`t8`.`calculation_id` = `t7`.`calculation_id` AND `t8`.`listener_log_id` = `t1`.`listener_log_id`)\n\n LEFT JOIN `" . StationCalculation::model()->tableName() . "` `t9` ON (`t9`.`station_id` = `t1`.`station_id` AND `t9`.`handler_id` = 2)\n LEFT JOIN `" . StationCalculationVariable::model()->tableName() . "` `t10` ON (`t10`.`sensor_feature_id` = `t2`.`sensor_feature_id` AND `t10`.`calculation_id` = `t9`.`calculation_id`)\n LEFT JOIN `" . StationCalculationData::model()->tableName() . "` `t11` ON (`t11`.`calculation_id` = `t10`.`calculation_id` AND `t11`.`listener_log_id` = `t1`.`listener_log_id`)\n\n LEFT JOIN `" . SensorDBHandler::model()->tableName() . "` `t12` ON `t12`.`handler_id` = `t3`.`handler_id`\n\n WHERE `t1`.`station_id` IN (" . implode(',', $this->station_id) . ")\n AND `t1`.`measuring_timestamp` >= FROM_UNIXTIME(" . $this->start_timestamp . ") \n AND `t1`.`measuring_timestamp` <= FROM_UNIXTIME(" . $this->end_timestamp . ")\n AND `t2`.`is_main` = 1\n AND `t1`.`is_m` = '0'\n ORDER BY `t1`.`measuring_timestamp` DESC, `t4`.`station_id_code`, `t3`.`sensor_id_code`";
$res = CStubActiveRecord::getDbConnect(true)->createCommand($sql)->queryAll();
if ($res) {
foreach ($res as $key => $value) {
$handler_obj = SensorHandler::create($value['handler_id_code']);
$res[$key]['Value'] = $handler_obj->applyOffset($res[$key]['Value'], $res[$key]['magnetic_north_offset']);
$res[$key]['Value'] = $handler_obj->formatValue($res[$key]['Value'], $res[$key]['feature_code']);
unset($res[$key]['magnetic_north_offset']);
unset($value['handler_id_code']);
unset($res[$key]['feature_code']);
}
$return_string .= "\"AWS Stations:\"\n" . It::prepareStringCSV($res);
}
$sql = "SELECT\n `t1`.`measuring_timestamp` AS `TxDateTime`,\n `t3`.`station_id_code` AS `StationId`, \n `t3`.`display_name` AS `StationDisplayName`,\n `t2`.`sensor_id_code` AS `SensorId`, \n `t2`.`display_name` AS `SensorDisplayName`, \n (`t1`.`sensor_value` * `t1`.`bucket_size`) AS `Value`,\n `t4`.`short_name` AS `Metric` \n FROM `" . SensorDataMinute::model()->tableName() . "` t1\n LEFT JOIN `" . StationSensor::model()->tableName() . "` t2 ON t2.station_sensor_id = t1.sensor_id\n LEFT JOIN `" . Station::model()->tableName() . "` t3 ON t3.station_id = t1.station_id\n LEFT JOIN `" . RefbookMetric::model()->tableName() . "` t4 ON t4.metric_id = t1.metric_id\n \n WHERE `t1`.`station_id` IN (" . implode(',', $this->station_id) . ")\n AND `t1`.`measuring_timestamp` >= FROM_UNIXTIME(" . $this->start_timestamp . ") \n AND `t1`.`measuring_timestamp` <= FROM_UNIXTIME(" . $this->end_timestamp . ")\n AND `t1`.`is_tmp` = 0\n ORDER BY t1.measuring_timestamp DESC, t3.station_id_code, t2.sensor_id_code\n ";
$res = CStubActiveRecord::getDbConnect(true)->createCommand($sql)->queryAll();
if ($res) {
$return_string .= "\n\n\"RG Stations:\"\n" . It::prepareStringCSV($res);
}
It::downloadFile($return_string, 'export__' . date('Y-m-d_Hi') . '.csv', 'text/csv');
}
示例5: makeExport
public function makeExport()
{
$return_string = "\"Messages History\"\n\nChoosed filters:\n\n";
if ($this->types) {
$subtypes = array();
if (in_array('failed', $this->types)) {
$subtypes[] = "Failed";
}
if (in_array('warning', $this->types)) {
$subtypes[] = "Warning";
}
if (in_array('successfull', $this->types)) {
$subtypes[] = "Successfull";
}
if ($this->types && in_array('not_processed_yet', $this->types)) {
$subtypes[] = "Not procecessed yet";
}
$return_string .= "* Types " . implode(' OR ', $subtypes);
}
if ($this->date_from || $this->date_to) {
$return_string .= "\n* Message was added into DB in period ";
if ($this->date_from) {
$return_string .= " from: " . date('Y-m-d H:i:s', strtotime($this->date_from . ' ' . $this->time_from));
}
if ($this->date_to) {
if ($this->date_from) {
$return_string .= ' and';
}
$return_string .= ' Before ' . date('Y-m-d H:i:s', strtotime($this->date_to . ' ' . $this->time_to));
}
}
$res = $this->prepareList(0);
if (!$res['list']) {
$return_string .= "\n\nList is empty";
} else {
$prepared_res = array();
foreach ($res['list'] as $key => $value) {
$prepared_res[] = array('Message' => $value['message'], 'Added' => $value['created'], 'St Id' => $value['station_id_code'] ? $value['station_id_code'] : 'Unknown', 'St Name' => $value['station_id_code'] ? $value['display_name'] : 'Unknown', 'St Type' => $value['station_id_code'] ? $value['station_type'] : 'No', 'Has Errors?' => $value['errors'] ? 'Fatal errors. Was not processed.' : 'No', 'Has Warnings?' => $value['warnings'] ? 'Data from some sensors were not processed.' : 'No', 'Errors Description' => addslashes($value['errors'] ? implode(' ; ', $value['errors']) : 'No'), 'Warnings Description' => addslashes($value['warnings'] ? implode(' ; ', $value['warnings']) : 'No'));
}
$return_string .= "\n\n" . It::prepareStringCSV($prepared_res);
}
It::downloadFile($return_string, 'export_history__' . date('Y-m-d_Hi') . '.csv', 'text/csv');
}
示例6: actionSendSMSCommand
/**
* Send command on station by SMS
*/
public function actionSendSMSCommand()
{
$form = new SMSCommandSendForm();
/**
* Update sms status
*/
if (isset($_GET['view_id']) || isset($_GET['sms_command_id'])) {
if (isset($_GET['view_id'])) {
$form->setSMS(SMSCommand::model()->findByPk($_GET['view_id']));
}
if (isset($_GET['sms_command_id'])) {
$form->setSMS(SMSCommand::model()->findByPk($_GET['sms_command_id']));
}
if (Yii::app()->request->isAjaxRequest) {
return $this->renderPartial('__sms_command_status', ['sms' => $form->getSMS()]);
}
}
/**
* Delete sms
*/
if (isset($_GET['delete_id'])) {
SMSCommand::model()->deleteByPk($_GET['delete_id']);
}
/**
* Create sms
*/
if (isset($_POST['SMSCommandSendForm'])) {
if ($_POST['send']) {
$form->setScenario($form::SCENARIO_SEND);
$form->setAttributes($_POST['SMSCommandSendForm']);
if ($form->validate()) {
$form->getSMS()->setAttributes($form->getAttributes());
if ($form->getSMS()->save()) {
$form = (new SMSCommandSendForm())->setSMS(SMSCommand::model()->findByPk($form->getSMS()->sms_command_id));
Yii::app()->user->setFlash('SendSMSCommandForm_success', "Command send!");
}
}
}
}
/**
* Grid
*/
if (isset($_POST['date_range'])) {
if (preg_match("/([\\d]{1,2})\\/([\\d]{1,2})\\/([\\d]{2,4})/i", $_POST['SMSCommand']['updated_from'], $matches1)) {
$dateFromViewFormat = $matches1[0];
$dateFrom = $matches1[3] . '-' . $matches1[1] . '-' . $matches1[2] . ' 00:00:00';
Yii::app()->request->cookies['dateFrom'] = new CHttpCookie('dateFrom', $dateFromViewFormat);
Yii::app()->request->cookies['from_date'] = new CHttpCookie('from_date', $dateFrom);
} else {
unset(Yii::app()->request->cookies['dateFrom']);
unset(Yii::app()->request->cookies['from_date']);
}
if (preg_match("/([\\d]{1,2})\\/([\\d]{1,2})\\/([\\d]{2,4})/i", $_POST['SMSCommand']['updated_to'], $matches2)) {
$dateToViewFormat = $matches2[0];
$dateTo = $matches2[3] . '-' . $matches2[1] . '-' . $matches2[2] . ' 23:59:59';
Yii::app()->request->cookies['dateTo'] = new CHttpCookie('dateTo', $dateToViewFormat);
Yii::app()->request->cookies['to_date'] = new CHttpCookie('to_date', $dateTo);
} else {
unset(Yii::app()->request->cookies['dateTo']);
unset(Yii::app()->request->cookies['to_date']);
}
}
if (isset($_GET['reset'])) {
unset(Yii::app()->request->cookies['dateFrom']);
unset(Yii::app()->request->cookies['dateTo']);
unset(Yii::app()->request->cookies['from_date']);
unset(Yii::app()->request->cookies['to_date']);
}
$SMSCommand = new SMSCommand();
$SMSCommand->unsetAttributes();
$SMSCommand->from_date = Yii::app()->request->cookies['from_date'];
$SMSCommand->to_date = Yii::app()->request->cookies['to_date'];
if ($_GET['SMSCommand']) {
$SMSCommand->attributes = $_GET['SMSCommand'];
}
$dataProvider = $SMSCommand->search();
//csv
if ($_GET['getcsv']) {
$items = $dataProvider->model->findAll($dataProvider->criteria);
if (!is_null($items)) {
$data = array();
foreach ($items as $item) {
$dataItem = $item->getAttributes();
$data[] = $dataItem;
}
$ECSVExporter = new ECSVExporter($data);
It::downloadFile($ECSVExporter->getString(), 'csv.csv', 'text/csv');
exit;
}
}
return $this->render('send_sms_command', ['form' => $form, 'dataProvider' => $dataProvider, 'dateFrom' => Yii::app()->request->cookies['dateFrom'], 'dateTo' => Yii::app()->request->cookies['dateTo']]);
}