本文整理匯總了PHP中sfWebResponse::setHttpHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfWebResponse::setHttpHeader方法的具體用法?PHP sfWebResponse::setHttpHeader怎麽用?PHP sfWebResponse::setHttpHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfWebResponse
的用法示例。
在下文中一共展示了sfWebResponse::setHttpHeader方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderReport
/**
* This is the final Step in this 3 steps process:
* <ol>
* <li>Step 1 consists in generating the XML bsaed raw data for the report. </li>
* <li>Step 2 consists in merging this raw data with a XSL-FO template to give it
* the presentation information. XSL-FO acts as an intermediate language used
* to render the final repor in any format with a last transformation. </li>
* <li>Step 3 consists on rendering the XSL-FO representtion (the intermediate
* language) of the report to the PDF output fromat.</li>
* <ol>
*
* @param DOMDocument $xslFo The XSL-FO representation of the processed
* report, as we get it just after step 2 in this 3 steps process.
* @param sfWebResponse $response The Response Object, should be passed all
* the way down from the action. So we can change some headers', ContentType
* to 'application/pdf'.
*
* @see %sf_plugins_dir%/NeatReports/config/sfExportGlobals.yml
* @return String With the rendered report content. PDF Binary stream returned
* by ApacheFop.
*/
public function renderReport(DOMDocument $xslFo, sfWebResponse $response = null)
{
$response->setContentType('application/pdf');
$response->setHttpHeader('Content-Disposition', "attachment; filename=report.pdf");
$tStamp = microtime(true);
$executable = stristr(PHP_OS, "WIN") ? 'fop.cmd' : 'fop';
$output = array();
$returnVar = 0;
$foPath = __DIR__ . '/RenderPDF/tmp/report.fo.' . $tStamp;
$pdfPath = __DIR__ . '/RenderPDF/tmp/report.pdf.' . $tStamp;
try {
file_put_contents($foPath, $xslFo->saveXML());
$command = $this->_fopPath . $executable . ' -fo ' . $foPath . ' -pdf ' . $pdfPath;
exec($command, $output, $returnVar);
if ((bool) $returnVar) {
throw new Exception(implode(PHP_EOL, $output), $returnVar);
}
} catch (Exception $e) {
$ex = new Exception('Error executing Apache FOP, return value is pased to Exception Code.' . ' Command execution output follows:' . PHP_EOL . implode(PHP_EOL, $output), $returnVar, $e);
throw $ex;
}
$out = file_get_contents($pdfPath);
unlink($foPath);
unlink($pdfPath);
return $out;
}
示例2: renderReport
/**
* This is the final Step in this 3 steps process:
* <ol>
* <li>Step 1 consists in generating the XML bsaed raw data for the report. </li>
* <li>Step 2 consists in merging this raw data with a XSL-FO template to give it
* the presentation information. XSL-FO acts as an intermediate language used
* to render the final repor in any format with a last transformation. </li>
* <li>Step 3 consists on rendering the XSL-FO representtion (the intermediate
* language) of the report to the PDF output fromat.</li>
* <ol>
* Note that the PDF, will force download. You can override this.
*
* @param DOMDocument $xslFo The XSL-FO representation of the processed
* report, as we get it just after step 2 in this 3 steps process.
* @param sfWebResponse $response The Response Object, should be passed all
* the way down from the action. So we can change some headers', ContentType
* to 'application/pdf'.
*
* @see %sf_plugins_dir%/NeatReports/config/sfExportGlobals.yml
* @return String With the rendered report content. PDF Binary stream returned
* by ApacheFop.
*/
public function renderReport(DOMDocument $xslFo, sfWebResponse $response = null)
{
$response->setContentType('application/pdf');
$response->setHttpHeader('Content-Disposition', "attachment; filename=report.pdf");
$this->_pdfRenderer = new RenderPDFConsummer($xslFo->saveXML());
return $this->_pdfRenderer->getPdfStream();
}