Регистр файлов
This commit is contained in:
parent
4fd0187ea6
commit
c8958cbee0
83 changed files with 25 additions and 53 deletions
43
src/Form/ViewState.php
Normal file
43
src/Form/ViewState.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* http://www.alternateinterior.com/2006/09/a-viewstate-for-php.html
|
||||
* Управление состоянием между страницами
|
||||
*/
|
||||
class ViewState // extends Collection
|
||||
{
|
||||
private $values = array();
|
||||
|
||||
function set($name, $value)
|
||||
{
|
||||
$this->values[$name] = $value;
|
||||
}
|
||||
|
||||
function get()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$result = $this->values;
|
||||
foreach ($args as $name) {
|
||||
if (!isset($result[$name])) {
|
||||
return null;
|
||||
}
|
||||
$result = $result[$name];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function saveState()
|
||||
{
|
||||
return base64_encode(serialize($this->values));
|
||||
}
|
||||
|
||||
function restoreState($value)
|
||||
{
|
||||
$this->values = unserialize(base64_decode($value));
|
||||
}
|
||||
|
||||
function export()
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue