1: <?php
2: 3: 4: 5: 6:
7:
8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
21: class QTreeNavItem extends QBaseClass {
22:
23:
24:
25: protected $strName = null;
26: protected $strValue = null;
27: protected $strItemId = null;
28: protected $blnSelected = false;
29: protected $blnExpanded = false;
30:
31: protected $objChildItemArray = array();
32: protected $objTreeNav;
33: protected $strParentItemId;
34: protected $blnHasChildren = false;
35:
36:
37:
38:
39: public function __construct($strName, $strValue, $blnExpanded, $objParentObject, $strItemId = null) {
40: if (strpos($strItemId, '_') !== false)
41: throw new QCallerException('Invalid Item Id: ' . $strItemId);
42:
43: $this->strName = $strName;
44: $this->strValue = $strValue;
45: $this->blnExpanded = $blnExpanded;
46: $this->strItemId = $strItemId;
47:
48:
49: if ($objParentObject instanceof QTreeNav)
50: $this->objTreeNav = $objParentObject;
51: else {
52: $this->objTreeNav = $objParentObject->objTreeNav;
53: $this->strParentItemId = $objParentObject->ItemId;
54: }
55:
56:
57: if (!$this->strItemId)
58: $this->strItemId = $this->objTreeNav->GenerateItemId();
59:
60: $objParentObject->AddChildItem($this);
61: $this->objTreeNav->AddItem($this);
62: }
63:
64: public function AddChildItem(QTreeNavItem $objItem) {
65: array_push($this->objChildItemArray, $objItem);
66: }
67:
68:
69:
70:
71: public function __get($strName) {
72: switch ($strName) {
73: case "Name": return $this->strName;
74: case "Value": return $this->strValue;
75: case "Selected": return $this->blnSelected;
76: case "Expanded": return $this->blnExpanded;
77: case "ChildItemArray": return (array) $this->objChildItemArray;
78: case "ItemId": return $this->strItemId;
79: case "TreeNav": return $this->objTreeNav;
80: case "ParentItemId": return $this->strParentItemId;
81: case "HasChildren": return $this->blnHasChildren;
82:
83: default:
84: try {
85: return parent::__get($strName);
86: } catch (QCallerException $objExc) {
87: $objExc->IncrementOffset();
88: throw $objExc;
89: }
90: }
91: }
92:
93:
94:
95:
96: public function __set($strName, $mixValue) {
97: switch ($strName) {
98: case "Name":
99: try {
100: $this->strName = QType::Cast($mixValue, QType::String);
101: break;
102: } catch (QInvalidCastException $objExc) {
103: $objExc->IncrementOffset();
104: throw $objExc;
105: }
106: case "Value":
107: try {
108: $this->strValue = QType::Cast($mixValue, QType::String);
109: break;
110: } catch (QInvalidCastException $objExc) {
111: $objExc->IncrementOffset();
112: throw $objExc;
113: }
114: case "Selected":
115: try {
116: $this->blnSelected = QType::Cast($mixValue, QType::Boolean);
117: break;
118: } catch (QInvalidCastException $objExc) {
119: $objExc->IncrementOffset();
120: throw $objExc;
121: }
122: case "Expanded":
123: try {
124: $this->blnExpanded = QType::Cast($mixValue, QType::Boolean);
125: break;
126: } catch (QInvalidCastException $objExc) {
127: $objExc->IncrementOffset();
128: throw $objExc;
129: }
130: case "HasChildren":
131: try {
132: $this->blnHasChildren = QType::Cast($mixValue, QType::Boolean);
133: break;
134: } catch (QInvalidCastException $objExc) {
135: $objExc->IncrementOffset();
136: throw $objExc;
137: }
138:
139: default:
140: try {
141: parent::__set($strName, $mixValue);
142: } catch (QCallerException $objExc) {
143: $objExc->IncrementOffset();
144: throw $objExc;
145: }
146: break;
147: }
148: }
149: }