PHPExcel
10 years ago
PHPExcel.php
10 years ago
api.php
10 years ago
arraytoxml.php
10 years ago
chunk.php
10 years ago
config.php
10 years ago
download.php
10 years ago
handler.php
10 years ago
helper.php
10 years ago
input.php
10 years ago
render.php
10 years ago
session.php
10 years ago
upload.php
10 years ago
session.php
96 lines
| 1 | <?php |
| 2 | |
| 3 | abstract class PMXI_Session { |
| 4 | |
| 5 | /** @var int $_customer_id */ |
| 6 | protected $_import_id; |
| 7 | |
| 8 | /** @var array $_data */ |
| 9 | protected $_data = array(); |
| 10 | |
| 11 | /** @var bool $_dirty When something changes */ |
| 12 | protected $_dirty = false; |
| 13 | |
| 14 | /** |
| 15 | * __get function. |
| 16 | * |
| 17 | * @access public |
| 18 | * @param mixed $key |
| 19 | * @return mixed |
| 20 | */ |
| 21 | public function __get( $key ) { |
| 22 | return $this->get( $key ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * __set function. |
| 27 | * |
| 28 | * @access public |
| 29 | * @param mixed $key |
| 30 | * @param mixed $value |
| 31 | * @return void |
| 32 | */ |
| 33 | public function __set( $key, $value ) { |
| 34 | $this->set( $key, $value ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * __isset function. |
| 39 | * |
| 40 | * @access public |
| 41 | * @param mixed $key |
| 42 | * @return bool |
| 43 | */ |
| 44 | public function __isset( $key ) { |
| 45 | return isset( $this->_data[ sanitize_title( $key ) ] ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * __unset function. |
| 50 | * |
| 51 | * @access public |
| 52 | * @param mixed $key |
| 53 | * @return void |
| 54 | */ |
| 55 | public function __unset( $key ) { |
| 56 | |
| 57 | if ( isset( $this->_data[ $key ] ) ) { |
| 58 | unset( $this->_data[ $key ] ); |
| 59 | $this->_dirty = true; |
| 60 | } |
| 61 | |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get a session variable |
| 66 | * |
| 67 | * @param string $key |
| 68 | * @param mixed $default used if the session variable isn't set |
| 69 | * @return mixed value of session variable |
| 70 | */ |
| 71 | public function get( $key, $default = null ) { |
| 72 | $key = sanitize_key( $key ); |
| 73 | return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Set a session variable |
| 78 | * |
| 79 | * @param string $key |
| 80 | * @param mixed $value |
| 81 | */ |
| 82 | public function set( $key, $value ) { |
| 83 | $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
| 84 | $this->_dirty = true; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * get_import_id function. |
| 89 | * |
| 90 | * @access public |
| 91 | * @return int |
| 92 | */ |
| 93 | public function get_import_id() { |
| 94 | return $this->_import_id; |
| 95 | } |
| 96 | } |