/** * Force download dialog * * @param String $bytes The bytes that are to be downloaded * @param String $filename The filename of the downloaded file * @param Zend_Controller_Response_Abstract $response The response object * @return Void */ public function force($bytes, $filename, Zend_Controller_Response_Abstract $response) { if (!strlen($bytes)) { $response->setBody('Sorry, we could not find the requested file.'); } else { // Disable view and layout rendering Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(); Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->disableLayout(); // Process the download $this->_setHeaders($bytes, $filename, $response); $response->setBody($bytes); } }
/** * Processes the requestStack and merges their responses into $response. * * @param Zend_Controller_Front $front * @param Zend_Controller_Response_Abstract $response * */ protected function _processRequestStack($front, Zend_Controller_Response_Abstract $response) { $stack =& $this->_requestStack; $config =& $this->_config; $i = count($stack) - 1; $responseStack = array(); $front->returnResponse(true); do { $myResponse = new Zend_Controller_Response_Http(); $nextRequest = array_pop($stack); $nextRequest->setParam($config['indexKey'], $i); $this->_resetHelper(); $this->_resetPlugins(); $this->_resetParams($nextRequest->getParams()); $front->setRequest($nextRequest); $front->setResponse($myResponse); $responseStack[] = $front->dispatch($nextRequest, $myResponse); } while ($i--); $front->returnResponse(false); $bodies = array(); for ($i = 0, $len = count($responseStack); $i < $len; $i++) { $bodies[] = $responseStack[$i]->getBody(); } $body = implode(',', $bodies); $response->setBody('[' . $body . ']'); }
/** * Add header text * * @param Zend_Controller_Response_Abstract $response */ protected function addHeader($response) { $config = Zend_Registry::get('config'); $homepage = T_("Homepage"); $identity = Zend_Auth::getInstance()->getIdentity(); $loggedAs = !($identity === null) ? T_("Logged as") . " " . $identity['username'] : ""; $menu = new USVN_Menu(USVN_MENUS_DIR, $this->getRequest(), $identity); $header = <<<EOF <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> \t<head> \t <title>{$config->site->title}</title> \t\t<meta http-equiv="Content-Type"\tcontent="text/html; charset=utf-8" /> \t\t<link rel="icon" href="{$config->url->base}/{$config->site->ico}" type="image/x-icon" /> \t\t<link type="text/css" rel="stylesheet" media="screen" href="{$config->url->base}/medias/usvn/stylesheets/new.css" /> \t\t<script type="text/javascript" src="{$config->url->base}/js/"></script> \t</head> \t<body> \t\t<div id="usvn_page"> \t\t\t<div id="usvn_header"> \t\t\t\t<a id="usvn_logo" href="{$config->url->base}/"> \t\t\t\t\t<img src="{$config->url->base}/{$config->site->logo}" alt="{$homepage}" /> \t\t\t\t</a> \t\t\t</div> \t\t\t<div id="menu"> EOF; $header .= $this->buildMenu($menu->getTopMenu(), 'usvn_menu'); $header .= $this->buildMenu($menu->getSubMenu(), 'usvn_submenu'); $header .= $this->buildMenu($menu->getSubSubMenu(), 'usvn_subsubmenu'); $header .= "</div><div id=\"usvn_content\">"; $body = $response->getBody(true); $response->setBody($header); foreach ($body as $text) { $response->appendBody($text); } }