1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
27: class cGuiFoldingRow extends cHTML {
28:
29: 30: 31: 32: 33:
34: protected ;
35:
36: 37: 38: 39: 40:
41: protected ;
42:
43: 44: 45: 46: 47:
48: protected $_contentRow;
49:
50: 51: 52: 53: 54:
55: protected $_linkId;
56:
57: 58: 59: 60: 61:
62: protected $_link;
63:
64: 65: 66: 67: 68:
69: protected $_contentData;
70:
71: 72: 73:
74: protected $_foldingImage;
75:
76: 77: 78:
79: protected $_hiddenField;
80:
81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91:
92: public function __construct($uuid, $caption = "", $linkId = "", $bExpanded = NULL) {
93: global $auth;
94:
95: $this->_uuid = $uuid;
96:
97: $this->setCaption($caption);
98:
99: $this->_headerRow = new cHTMLTableRow();
100:
101: $this->_headerData = new cHTMLTableHead();
102: $this->_headerData->setClass("foldingrow");
103:
104: $this->_contentRow = new cHTMLTableRow();
105: $this->_contentRow->updateAttributes(array("id" => $uuid));
106:
107: $this->_contentData = new cHTMLTableData();
108:
109: $this->_link = new cHTMLLink();
110:
111: $this->_linkId = $linkId;
112:
113: $this->_hiddenField = new cHTMLHiddenField("expandstate_" . $this->_contentRow->getID());
114:
115: $this->_foldingImage = new cHTMLImage();
116:
117: $this->setExpanded(false);
118:
119: $this->addRequiredScript("parameterCollector.js");
120: $this->addRequiredScript("cfoldingrow.js");
121:
122: $user = new cApiUser($auth->auth["uid"]);
123:
124: if ($bExpanded == NULL) {
125:
126: if ($user->isLoaded()) {
127: if ($user->getProperty("expandstate", $uuid) == "true") {
128: $this->setExpanded($user->getProperty("expandstate", $uuid));
129: }
130: }
131: } else {
132: if ($bExpanded) {
133: $this->setExpanded(true);
134: } else {
135: $this->setExpanded(false);
136: }
137: }
138: }
139:
140: 141: 142: 143:
144: public function setExpanded($expanded = false) {
145: if ($expanded == true) {
146: $this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif");
147: $this->_foldingImage->updateAttributes(array("data-state" => "expanded"));
148: $this->_contentRow->setStyle("display: ;");
149: $this->_hiddenField->setValue('expanded');
150: } else {
151: $this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif");
152: $this->_foldingImage->updateAttributes(array("data-state" => "collapsed"));
153: $this->_contentRow->setStyle("display: none;");
154: $this->_hiddenField->setValue('collapsed');
155: }
156: $this->_expanded = $expanded;
157: }
158:
159: 160: 161: 162:
163: public function setCaption($caption) {
164: $this->_caption = $caption;
165: }
166:
167: 168: 169: 170: 171:
172: public function setHelpContext($context = false) {
173: $this->_helpContext = $context;
174: }
175:
176: 177: 178: 179: 180:
181: public function setIndent($indent = 0) {
182: $this->_indent = $indent;
183: }
184:
185: 186: 187: 188:
189: function setContentData($content) {
190: $this->_contentData->setContent($content);
191: }
192:
193: 194: 195: 196: 197:
198: public function render() {
199:
200: $this->_link->setClass("foldingrow");
201: if ($this->_linkId != NULL) {
202: $this->_link->setID($this->_linkId);
203: }
204:
205: $imgid = $this->_foldingImage->getID();
206: $rowid = $this->_contentRow->getID();
207: $hiddenid = $this->_hiddenField->getID();
208: $uuid = $this->_uuid;
209:
210: $this->_link->setLink("javascript:void(0);");
211: $this->_link->setContent($this->_foldingImage->render() . $this->_caption);
212:
213: $this->_headerData->setContent(array($this->_hiddenField, $this->_link));
214: $this->_headerRow->setContent($this->_headerData);
215:
216: $this->_contentRow->setContent($this->_contentData);
217:
218: $output = $this->_headerRow->render();
219: $output .= $this->_contentRow->render();
220:
221: $output = <<<HTML
222: <!-- cGuiFoldingRow -->
223: {$output}
224: <script type="text/javascript">
225: (function(Con, $) {
226: $(function() {
227: $("#{$this->_linkId}").click(function() {
228: Con.FoldingRow.toggle("{$imgid}", "{$rowid}", "{$hiddenid}", "{$uuid}");
229: });
230: });
231: })(Con, Con.$);
232: </script>
233: <!-- /cGuiFoldingRow -->
234: HTML;
235:
236: return $output;
237: }
238:
239: }
240: