<?php

class PreviewThemeAction extends CatalogAction {
	public function execute($request) {
		if ($theme = $request->getParameter('theme')) {
			$this->getUser()->setAttribute('theme', $request->getParameter('theme'));
		} else {
			$this->getUser()->setAttribute('theme', null);
		}
		sfContext::getInstance()->getConfiguration()->loadHelpers('BillingFormat');
		
		// set no cache and localtion headers manually, because simple $this->redirect call entail clear
		// of http headers, so some browsers may cache result of this action and prevent it execution
		$response = $this->getResponse();
		$response->addCacheControlHttpHeader('no-cache');
		$response->setHttpHeader('Location', formatContinueShoppingUrl($this->_container));
		
		// send only headers to perform redirect
		return sfView::HEADER_ONLY;
	}
}