Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TPageStatePersister class file
4
 *
5
 * @author Qiang Xue <qiang.xue@gmail.com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TPageStatePersister.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Web.UI
11
 */
12
 
13
/**
14
 * TPageStatePersister class
15
 *
16
 * TPageStatePersister implements a page state persistent method based on
17
 * form hidden fields.
18
 *
19
 * Since page state can be very big for complex pages, consider using
20
 * alternative persisters, such as {@link TSessionPageStatePersister},
21
 * which store page state on the server side and thus reduce the network
22
 * traffic for transmitting bulky page state.
23
 *
24
 * @author Qiang Xue <qiang.xue@gmail.com>
25
 * @version $Id: TPageStatePersister.php 2541 2008-10-21 15:05:13Z qiang.xue $
26
 * @package System.Web.UI
27
 * @since 3.0
28
 */
29
class TPageStatePersister extends TComponent implements IPageStatePersister
30
{
31
	private $_page;
32
 
33
	/**
34
	 * @return TPage the page that this persister works for
35
	 */
36
	public function getPage()
37
	{
38
		return $this->_page;
39
	}
40
 
41
	/**
42
	 * @param TPage the page that this persister works for
43
	 */
44
	public function setPage(TPage $page)
45
	{
46
		$this->_page=$page;
47
	}
48
 
49
	/**
50
	 * Saves state in hidden fields.
51
	 * @param mixed state to be stored
52
	 */
53
	public function save($state)
54
	{
55
		$this->_page->setClientState(TPageStateFormatter::serialize($this->_page,$state));
56
	}
57
 
58
	/**
59
	 * Loads page state from hidden fields.
60
	 * @return mixed the restored state
61
	 * @throws THttpException if page state is corrupted
62
	 */
63
	public function load()
64
	{
65
		if(($data=TPageStateFormatter::unserialize($this->_page,$this->_page->getRequestClientState()))!==null)
66
			return $data;
67
		else
68
			throw new THttpException(400,'pagestatepersister_pagestate_corrupted');
69
	}
70
}
71