当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP::sendFileToBrowser方法代码示例

本文整理汇总了PHP中HTTP::sendFileToBrowser方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::sendFileToBrowser方法的具体用法?PHP HTTP::sendFileToBrowser怎么用?PHP HTTP::sendFileToBrowser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTP的用法示例。


在下文中一共展示了HTTP::sendFileToBrowser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: export

 function export()
 {
     if ($_REQUEST['baseurl']) {
         $base = $_REQUEST['baseurl'];
         if (substr($base, -1) != '/') {
             $base .= '/';
         }
         Director::setBaseURL($base);
     }
     $folder = '/tmp/static-export/' . project();
     if (!project()) {
         $folder .= 'site';
     }
     if (!file_exists($folder)) {
         mkdir($folder, Filesystem::$folder_create_mask, true);
     }
     $f1 = Director::baseFolder() . '/assets';
     $f2 = Director::baseFolder() . '/' . project();
     `cd {$folder}; ln -s {$f1}; ln -s {$f2}`;
     $baseFolder = basename($folder);
     if ($folder && file_exists($folder)) {
         $pages = DataObject::get("SiteTree");
         foreach ($pages as $page) {
             $subfolder = "{$folder}/{$page->URLSegment}";
             $contentfile = "{$folder}/{$page->URLSegment}/index.html";
             // Make the folder
             if (!file_exists($subfolder)) {
                 mkdir($subfolder, Filesystem::$folder_create_mask);
             }
             // Run the page
             Requirements::clear();
             $controllerClass = "{$page->class}_Controller";
             if (class_exists($controllerClass)) {
                 $controller = new $controllerClass($page);
                 $pageContent = $controller->run(array());
                 // Write to file
                 if ($fh = fopen($contentfile, 'w')) {
                     fwrite($fh, $pageContent->getBody());
                     fclose($fh);
                 }
             }
         }
         copy("{$folder}/home/index.html", "{$folder}/index.html");
         `cd /tmp/static-export; tar -czhf {$baseFolder}.tar.gz {$baseFolder}`;
         $content = file_get_contents("/tmp/static-export/{$baseFolder}.tar.gz");
         Filesystem::removeFolder('/tmp/static-export');
         HTTP::sendFileToBrowser($content, "{$baseFolder}.tar.gz");
         return null;
     } else {
         echo _t('StaticExporter.ONETHATEXISTS', "Please specify a folder that exists");
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:52,代码来源:StaticExporter.php

示例2: export

 /**
  * Exports a given set of comma-separated IDs (from a previous search-query, stored in a HiddenField).
  * Uses {$csv_columns} if present, and falls back to {$result_columns}.
  * 
  * @todo Make relation-syntax available (at the moment you'll have to use custom sql) 
  */
 function export()
 {
     $now = Date("d-m-Y-H-i");
     $fileName = "export-{$now}.csv";
     $separator = $this->csvSeparator;
     $csvColumns = $this->fieldListCsv ? $this->fieldListCsv : $this->fieldList;
     $fileData = "";
     if ($this->csvHasHeader) {
         $fileData .= "\"" . implode("\"{$separator}\"", array_values($csvColumns)) . "\"";
         $fileData .= "\n";
     }
     // get data
     $dataQuery = $this->getCsvQuery();
     $records = $dataQuery->execute();
     $sourceClass = $this->sourceClass;
     $dataobject = new $sourceClass();
     $items = $dataobject->buildDataObjectSet($records, 'DataObjectSet');
     if ($items) {
         foreach ($items as $item) {
             $columnData = array();
             foreach ($csvColumns as $columnName => $columnTitle) {
                 $tmpColumnData = "\"" . str_replace("\"", "\"\"", $item->{$columnName}) . "\"";
                 $tmpColumnData = str_replace(array("\r", "\n"), "", $tmpColumnData);
                 $columnData[] = $tmpColumnData;
             }
             $fileData .= implode($separator, $columnData);
             $fileData .= "\n";
         }
         HTTP::sendFileToBrowser($fileData, $fileName);
     } else {
         user_error("No records found", E_USER_ERROR);
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:39,代码来源:TableListField.php

示例3: export

 /**
  * Exports a given set of comma-separated IDs (from a previous search-query, stored in a HiddenField).
  * Uses {$csv_columns} if present, and falls back to {$result_columns}.
  */
 function export()
 {
     $now = Date("s-i-H");
     $fileName = "export-{$now}.csv";
     $csv_columns = $this->stat('csv_columns') ? array_values($this->stat('csv_columns')) : array_values($this->stat('result_columns'));
     $fileData = "";
     $fileData .= "\"" . implode("\",\"", $csv_columns) . "\"";
     $fileData .= "\n";
     $records = $this->performSearch();
     if ($records) {
         foreach ($records as $record) {
             $columnData = array();
             foreach ($csv_columns as $column) {
                 $tmpColumnData = "\"" . str_replace("\"", "\"\"", $record->{$column}) . "\"";
                 $tmpColumnData = str_replace(array("\r", "\n"), "", $tmpColumnData);
                 $columnData[] = $tmpColumnData;
             }
             $fileData .= implode(",", $columnData);
             $fileData .= "\n";
         }
         HTTP::sendFileToBrowser($fileData, $fileName);
     } else {
         user_error("No records found", E_USER_ERROR);
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:29,代码来源:GenericDataAdmin.php

示例4: exportToCSV

 /**
  *	Todo: to export the reported table as a CSV
  */
 function exportToCSV($fileName)
 {
     $fileData = $this->columnheaders('csvRow', 'csvHeadCell') . $this->datacells('csvRow', 'csvDataCell');
     HTTP::sendFileToBrowser($fileData, $fileName);
 }
开发者ID:ramziammar,项目名称:websites,代码行数:8,代码来源:DataReport.php


注:本文中的HTTP::sendFileToBrowser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。