<?php

/**
 * Response context setup
 *
 * @version DR1.7
 */
class ResponseSetupFilter implements InterceptingFilter {



	protected $requireRootView;



	/**
	 * Constructor for ResponseSetupFilter
	 *
	 * Defines whether root views should be required in HTML response or not.
	 * For better security it is advised to keep this feature turned on on production server.
	 *
	 * @param boolean, require root views in HTML response
	 */
	public function __construct($requireRootView) {
		$this->requireRootView = $requireRootView;
	}



	public function preProcess(RequestContext $request, ResponseContext $response) {
		if (RequestSetupFilter::isAjaxCall()) {
			$response->setBackend(new ResponseAjaxBackend());
		} else {
			require_once 'lib/http/ResponseHTMLBackend.class.php';
			$response->setBackend($b = new ResponseHTMLBackend());
			$b->requireRootView = $this->requireRootView;
		}
	}



	public function postProcess(RequestContext $request, ResponseContext $response) {

	}



} // class ResponseSetupFilter

?>