  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: object_info.php 1498 2007-03-29 14:04:50Z hpdl $ |
| |
| 3 | + | $Id: object_info.php 1863 2009-03-06 23:53:49Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
7 | 7 | | |
  |
8 | | - | Copyright (c) 2007 osCommerce |
| |
| 8 | + | Copyright (c) 2009 osCommerce |
|
9 | 9 | | |
| |
10 | 10 | | This program is free software; you can redistribute it and/or modify |
| |
11 | 11 | | it under the terms of the GNU General Public License v2 (1991) |
| |
12 | 12 | | as published by the Free Software Foundation. |
| |
13 | 13 | | */ |
| |
14 | 14 | | |
  |
| 15 | + | /** |
| |
| 16 | + | * The osC_ObjectInfo class wraps an object instance around an array data set |
| |
| 17 | + | */ |
| |
| 18 | + | |
|
15 | 19 | | class osC_ObjectInfo { |
  |
16 | | - | var $_keys = array(); |
|
17 | 20 | | |
  |
18 | | - | function osC_ObjectInfo($array) { |
| |
19 | | - | foreach ($array as $key => $value) { |
| |
20 | | - | $this->_keys[$key] = $value; |
| |
21 | | - | } |
| |
| 21 | + | /** |
| |
| 22 | + | * Holds the array data set values |
| |
| 23 | + | * |
| |
| 24 | + | * @var array |
| |
| 25 | + | * @access private |
| |
| 26 | + | */ |
| |
| 27 | + | |
| |
| 28 | + | private $_data = array(); |
| |
| 29 | + | |
| |
| 30 | + | /** |
| |
| 31 | + | * Constructor, loads the array data set into the object instance |
| |
| 32 | + | * |
| |
| 33 | + | * @param array $data The array data set to insert into the object instance |
| |
| 34 | + | * @access public |
| |
| 35 | + | */ |
| |
| 36 | + | |
| |
| 37 | + | public function __construct($data) { |
| |
| 38 | + | $this->_data = $data; |
|
22 | 39 | | } |
| |
23 | 40 | | |
  |
24 | | - | function get($key) { |
| |
25 | | - | return $this->_keys[$key]; |
| |
| 41 | + | /** |
| |
| 42 | + | * Get the value of a key element in the array data set |
| |
| 43 | + | * |
| |
| 44 | + | * @param string $key The name of the array key |
| |
| 45 | + | * @access public |
| |
| 46 | + | */ |
| |
| 47 | + | |
| |
| 48 | + | public function get($key) { |
| |
| 49 | + | return $this->_data[$key]; |
|
26 | 50 | | } |
| |
27 | 51 | | |
  |
28 | | - | function getAll() { |
| |
29 | | - | return $this->_keys; |
| |
| 52 | + | /** |
| |
| 53 | + | * Get the value of a key element in the array data set and protect the output value |
| |
| 54 | + | * |
| |
| 55 | + | * @param string $key The name of the array key |
| |
| 56 | + | * @access public |
| |
| 57 | + | */ |
| |
| 58 | + | |
| |
| 59 | + | public function getProtected($key) { |
| |
| 60 | + | return osc_output_string_protected($this->_data[$key]); |
|
30 | 61 | | } |
  |
31 | | - | |
| |
32 | | - | function set($key, $value) { |
| |
33 | | - | $this->_keys[$key] = $value; |
| |
| 62 | + | |
| |
| 63 | + | /** |
| |
| 64 | + | * Get the integer value of a key element in the array data set |
| |
| 65 | + | * |
| |
| 66 | + | * @param string $key The name of the array key |
| |
| 67 | + | * @access public |
| |
| 68 | + | */ |
| |
| 69 | + | |
| |
| 70 | + | public function getInt($key) { |
| |
| 71 | + | return (int)$this->_data[$key]; |
|
34 | 72 | | } |
  |
| 73 | + | |
| |
| 74 | + | /** |
| |
| 75 | + | * Get the whole array data set |
| |
| 76 | + | * |
| |
| 77 | + | * @access public |
| |
| 78 | + | */ |
| |
| 79 | + | |
| |
| 80 | + | public function getAll() { |
| |
| 81 | + | return $this->_data; |
| |
| 82 | + | } |
| |
| 83 | + | |
| |
| 84 | + | /** |
| |
| 85 | + | * Set a value in the array data set |
| |
| 86 | + | * |
| |
| 87 | + | * @param string $key The name of the array key |
| |
| 88 | + | * @param string $value The value of the array key |
| |
| 89 | + | * @access public |
| |
| 90 | + | */ |
| |
| 91 | + | |
| |
| 92 | + | public function set($key, $value) { |
| |
| 93 | + | $this->_data[$key] = $value; |
| |
| 94 | + | } |
| |
| 95 | + | |
| |
| 96 | + | /** |
| |
| 97 | + | * Checks the existance of a key in the array data set |
| |
| 98 | + | * |
| |
| 99 | + | * @param string $key The name of the array key |
| |
| 100 | + | * @access public |
| |
| 101 | + | */ |
| |
| 102 | + | |
| |
| 103 | + | public function exists($key) { |
| |
| 104 | + | return isset($this->_data[$key]); |
| |
| 105 | + | } |
  |
35 | 106 | | } |
| |
36 | 107 | | ?> |