summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TPageStatePersister.php
diff options
context:
space:
mode:
authorxue <>2006-04-11 00:58:46 +0000
committerxue <>2006-04-11 00:58:46 +0000
commit37f4d81a1ce6bdea84b00a38b0c8fc32f82f9e5d (patch)
tree21fefb880ab617aa2f5440494143d23f9fb68520 /framework/Web/UI/TPageStatePersister.php
parent00d32ec019a329a84190b7938cbf48f9e9494874 (diff)
Refactored page state persister.
Diffstat (limited to 'framework/Web/UI/TPageStatePersister.php')
-rw-r--r--framework/Web/UI/TPageStatePersister.php44
1 files changed, 9 insertions, 35 deletions
diff --git a/framework/Web/UI/TPageStatePersister.php b/framework/Web/UI/TPageStatePersister.php
index 3551b5f6..ff5b088b 100644
--- a/framework/Web/UI/TPageStatePersister.php
+++ b/framework/Web/UI/TPageStatePersister.php
@@ -16,19 +16,17 @@
* TPageStatePersister implements a page state persistent method based on
* form hidden fields.
*
- * Depending on the {@link TPage::getEnableStateValidation() EnableStateValidation}
- * and {@link TPage::getEnableStateEncryption() EnableStateEncryption},
- * TPageStatePersister may do HMAC validation and encryption to prevent
- * the state data from being tampered or viewed.
- * The private keys and hashing/encryption methods are determined by
- * {@link TApplication::getSecurityManager() SecurityManager}.
+ * Since page state can be very big for complex pages, consider using
+ * alternative persisters, such as {@link TSessionPageStatePersister},
+ * which store page state on the server side and thus reduce the network
+ * traffic for transmitting bulky page state.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI
* @since 3.0
*/
-class TPageStatePersister extends TApplicationComponent implements IPageStatePersister
+class TPageStatePersister extends TComponent implements IPageStatePersister
{
private $_page;
@@ -54,15 +52,7 @@ class TPageStatePersister extends TApplicationComponent implements IPageStatePer
*/
public function save($state)
{
- if($this->_page->getEnableStateValidation())
- $data=$this->getApplication()->getSecurityManager()->hashData(Prado::serialize($state));
- else
- $data=Prado::serialize($state);
- if($this->_page->getEnableStateEncryption())
- $data=$this->getApplication()->getSecurityManager()->encrypt($data);
- if(extension_loaded('zlib'))
- $data=gzcompress($data);
- $this->_page->getClientScript()->registerHiddenField(TPage::FIELD_PAGESTATE,base64_encode($data));
+ $this->_page->setClientState(TPageStateFormatter::serialize($this->_page,$state));
}
/**
@@ -72,26 +62,10 @@ class TPageStatePersister extends TApplicationComponent implements IPageStatePer
*/
public function load()
{
- $str=base64_decode($this->getRequest()->itemAt(TPage::FIELD_PAGESTATE));
- if($str==='')
- return null;
- if(extension_loaded('zlib'))
- $data=gzuncompress($str);
+ if(($data=TPageStateFormatter::unserialize($this->_page,$this->_page->getRequestClientState()))!==null)
+ return $data;
else
- $data=$str;
- if($data!==false)
- {
- if($this->_page->getEnableStateEncryption())
- $data=$this->getApplication()->getSecurityManager()->decrypt($data);
- if($this->_page->getEnableStateValidation())
- {
- if(($data=$this->getApplication()->getSecurityManager()->validateData($data))!==false)
- return Prado::unserialize($data);
- }
- else
- return $data;
- }
- throw new THttpException(400,'pagestatepersister_pagestate_corrupted');
+ throw new THttpException(400,'pagestatepersister_pagestate_corrupted');
}
}