. */ class AjaxResponse { private $closePopup; private $refresh; private $focusElement; private $scrollToTopElement; public function __construct($closePopup=false) { $this->closePopup = $closePopup; $this->refresh = array(); $this->focusElement = null; $this->scrollToTopElement = null; } public function __destruct() { } public function createResponse() { $data = ""; $data .= ""; $data .= "".($this->closePopup?1:0).""; foreach( $this->refresh as $field ) { $data .= "".$field['element'].""; } if( $this->focusElement!=null ) { $data .= "".$this->focusElement.""; } if( $this->scrollToTopElement!=null ) { $data .= "".$this->scrollToTopElement.""; } $data .= ""; return $data; } public function sendResponse() { header("Content-type: text/xml; charset=utf-8"); echo $this->createResponse(); } public function getClosePopup() { return $this->closePopup; } public function setClosePopup($closePopup) { $this->closePopup = $closePopup; return $this; } public function addRefresh($element, $data) { $this->refresh[] = array('element'=>$element, 'data'=>$data); return $this; } public function setFocus($focusElement) { $this->focusElement = $focusElement; return $this; } public function getFocus($focusElement) { return $this->focusElement; } public function setScrollToTop($scrollToTopElement) { $this->scrollToTopElement = $scrollToTopElement; return $this; } public function getScrollToTop() { return $this->scrollToTopElement; } } ?>