1: <?php
2: /**
3: *
4: * @package XCube
5: * @version $Id: XCube_Object.class.php,v 1.3 2008/10/12 04:30:27 minahito Exp $
6: * @copyright Copyright 2005-2007 XOOPS Cube Project <https://github.com/xoopscube/legacy>
7: * @license https://github.com/xoopscube/legacy/blob/master/docs/bsd_licenses.txt Modified BSD license
8: *
9: */
10:
11: function S_PUBLIC_VAR($definition)
12: {
13: $t_str = explode(' ', trim($definition));
14: return array('name' => trim($t_str[1]), 'type' => trim($t_str[0]));
15: }
16:
17: class XCube_Object
18: {
19: /**
20: * Member property
21: */
22: var $mProperty = array();
23:
24: /**
25: * @static
26: * @return array
27: */
28: function isArray()
29: {
30: return false;
31: }
32:
33: /**
34: * Return member property information. This member function is called in
35: * the initialize of object and service. This member function has to be
36: * a static function.
37: *
38: * @static
39: * @return array
40: */
41: function getPropertyDefinition()
42: {
43: }
44:
45: function XCube_Object()
46: {
47: $fileds = $this->getPropertyDefinition();
48: foreach ($fileds as $t_field) {
49: $this->mProperty[$t_field['name']] = array(
50: 'type' => $t_field['type'],
51: 'value' => null
52: );
53: }
54: }
55:
56: /**
57: * Initialize. If the exception raises, return false.
58: */
59: function prepare()
60: {
61: }
62:
63: function toArray()
64: {
65: $retArray = array();
66:
67: foreach ($this->mProperty as $t_key => $t_value) {
68: $retArray[$t_key] = $t_value['value'];
69: }
70:
71: return $retArray;
72: }
73:
74: function loadByArray($vars)
75: {
76: foreach ($vars as $t_key => $t_value) {
77: if (isset($this->mProperty[$t_key])) {
78: $this->mProperty[$t_key]['value'] = $t_value;
79: }
80: }
81: }
82: }
83:
84: class XCube_ObjectArray
85: {
86: function isArray()
87: {
88: return true;
89: }
90:
91: /**
92: * @static
93: * @return string
94: */
95: function getClassName()
96: {
97: }
98: }
99:
100: ?>