summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php
blob: d1ec67ade4cc8ebffacdbcaee5b5e3d911b608df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

/**
 * 
 */
class TCallbackResponseAdapter extends THttpResponseAdapter
{
	private $_writers=array();
	
	private $_data;
	
	public function createNewHtmlWriter($type,$response)
	{
		$writer = new TCallbackResponseWriter();
		$this->_writers[] = $writer;
		return parent::createNewHtmlWriter($type,$writer);
	}
	
	public function flushContent()
	{
		foreach($this->_writers as $writer)
			echo $writer->flush();
		parent::flushContent();
	}
	
	public function setResponseData($data)
	{
		$this->_data = $data;
	}
	
	public function getResponseData()
	{
		return $this->_data;
	}
}

class TCallbackResponseWriter extends TTextWriter
{
	private $_boundary;
	
	public function __construct()
	{
		$this->_boundary = sprintf('%x',crc32((string)$this));
	}
		
	public function getBoundary()
	{
		return $this->_boundary;
	}
	
	public function setBoundary($value)
	{
		$this->_boundary = $value;
	}
	
	public function flush()
	{
		$content = '<!--'.$this->getBoundary().'-->';
		$content .= parent::flush();
		$content .= '<!--//'.$this->getBoundary().'-->';
		return $content;
	}
}

?>