本文整理汇总了PHP中Zend_Controller_Response_Http::appendBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Response_Http::appendBody方法的具体用法?PHP Zend_Controller_Response_Http::appendBody怎么用?PHP Zend_Controller_Response_Http::appendBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Response_Http
的用法示例。
在下文中一共展示了Zend_Controller_Response_Http::appendBody方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendCsv
protected function sendCsv($filename, array $rows, Zend_Controller_Response_Http $response, $delimiter = "\t")
{
$response->setHeader('Cache-Control', 'maxage=3600')->setHeader('Pragma', 'no-cache')->setHeader('Content-type', 'text/csv')->setHeader('Content-Disposition', 'attachment; filename=' . $filename);
foreach ($rows as &$r) {
if (is_array($r)) {
$out = "";
foreach ($r as $s) {
$out .= ($out ? $delimiter : "") . '"' . str_replace('"', "'", $s) . '"';
}
$out .= "\r\n";
$r = $out;
}
}
$response->appendBody(implode("", $rows));
}
示例2: render
function render($path, Am_View $view)
{
$urlPath = $this->request->get('path', 'upload::');
$list = array();
foreach ($this->plugins as $pl) {
$o = new stdclass();
$o->title = $pl->getTitle();
$o->link = $this->getUrl($pl->getPath(null));
$list[$pl->getId()] = $o;
}
$view->plugins = $list;
$view->description = $this->storage->getDescription();
$view->active_plugin = $this->storage->getId();
$view->path = $path;
$view->currentUrl = $this->getUrl($path);
$items = $actions = array();
foreach ($this->storage->getItems($path, $actions) as $item) {
switch (true) {
case $item instanceof Am_Storage_File:
$item->_data_info = $item->info($this->secure);
$item->_link = $this->getUrl($this->storage->getPath($item->getPath()));
$items[] = $item;
break;
case $item instanceof Am_Storage_Folder:
$item->_link = $this->getUrl($this->storage->getPath($item->getPath()));
$items[] = $item;
break;
}
}
foreach ($actions as $item) {
switch (true) {
case $item instanceof Am_Storage_Action_Upload:
$item->_link = $this->getUrl($urlPath . '?action=upload');
$view->upload = $item;
break;
case $item instanceof Am_Storage_Action_CreateFolder:
$item->_link = $this->getUrl($urlPath . '?action=create-folder');
$view->createfolder = $item;
break;
case $item instanceof Am_Storage_Action_Refresh:
$item->_link = $this->getUrl($urlPath . '?action=refresh');
$view->refresh = $item;
break;
case $item instanceof Am_Storage_Action_DeleteFile:
$item->_link = $this->getUrl($urlPath . '?action=delete-file&path=__PATH__');
$view->deletefile = $item;
break;
default:
$actions[] = $item;
}
}
$view->actions = $actions;
$view->items = $items;
$output = $view->render('admin/_storage-grid.phtml');
$this->response->appendBody($output);
}
示例3: run
public function run(Zend_Controller_Response_Abstract $response = null)
{
$args = array($this);
$this->runCallback(self::CB_BEFORE_RUN, $args);
if ($response === null) {
$response = new Zend_Controller_Response_Http();
}
$this->response = $response;
$action = $this->getCurrentAction();
$this->request->setActionName($action);
ob_start();
$this->actionRun($action);
if ($this->response->isRedirect() && $this->completeRequest->isXmlHttpRequest()) {
$url = null;
foreach ($response->getHeaders() as $header) {
if ($header['name'] == 'Location') {
$url = $header['value'];
}
}
$code = $response->getHttpResponseCode();
// change request to ajax response
$response->clearAllHeaders();
$response->clearBody();
$response->setHttpResponseCode(200);
$response->setHeader("Content-Type", "application/json; charset=UTF-8", true);
$response->setBody(Am_Controller::getJson(array('ngrid-redirect' => $url, 'status' => $code)));
//throw new Am_Exception_Redirect($url);
} else {
$response->appendBody(ob_get_clean());
}
unset($this->response);
return $response;
}
示例4: sendPackage
/**
* @see AM_Handler_Export_Storage_Interface::sendPackage()
* @throws AM_Handler_Export_Storage_Exception
*/
public function sendPackage()
{
$sFilePath = $this->_buildPackagePath() . DIRECTORY_SEPARATOR . $this->getPackage()->getPackageName();
$sFileName = $this->getPackage()->getPackageDownloadName();
if (!file_exists($sFilePath)) {
throw new AM_Handler_Export_Storage_Exception(sprintf('File "%s" not found', $sFilePath));
}
$oResponse = new Zend_Controller_Response_Http();
$oResponse->setHttpResponseCode(200);
$oRequest = new Zend_Controller_Request_Http();
$iFileSize = filesize($sFilePath);
$sFileMtime = @gmdate("D, d M Y H:i:s", @filemtime($sFilePath)) . " GMT";
$rFile = @fopen($sFilePath, 'rb');
$sRange = $oRequest->get('HTTP_RANGE');
//Trying to resume download according to the HTTP_RANGE header
if (preg_match('/bytes=(\\d+)-(\\d*)/i', $sRange, $matches)) {
$sRange = $matches[1];
} else {
$sRange = false;
}
if ($sRange) {
fseek($rFile, $sRange);
$oResponse->setHttpResponseCode(206);
$oResponse->setHeader('Content-Range', sprintf('bytes %d-%d/%d', $sRange, $iFileSize - 1, $iFileSize));
}
$oResponse->setHeader('Content-Disposition', 'attachment; filename=' . $sFileName)->setHeader('Content-Length', $iFileSize - $sRange)->setHeader('Content-Type', 'application/octet-stream')->setHeader('Accept-Ranges', 'bytes')->setHeader('Last-Modified', $sFileMtime);
while (!feof($rFile)) {
$sBuffer = fread($rFile, 2048);
$oResponse->appendBody($sBuffer);
}
fclose($rFile);
$oResponse->sendResponse();
}