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: public function __construct($uuid, $caption = "", $linkId = "", $bExpanded = NULL) {
90: global $auth;
91:
92: $this->_uuid = $uuid;
93:
94: $this->setCaption($caption);
95:
96: $this->_headerRow = new cHTMLTableRow();
97:
98: $this->_headerData = new cHTMLTableHead();
99: $this->_headerData->setClass("foldingrow");
100:
101: $this->_contentRow = new cHTMLTableRow();
102: $this->_contentRow->updateAttributes(array("id" => $uuid));
103:
104: $this->_contentData = new cHTMLTableData();
105:
106: $this->_link = new cHTMLLink();
107:
108: $this->_linkId = $linkId;
109:
110: $this->_hiddenField = new cHTMLHiddenField("expandstate_" . $this->_contentRow->getID());
111:
112: $this->_foldingImage = new cHTMLImage();
113:
114: $this->setExpanded(false);
115:
116: $this->addRequiredScript("parameterCollector.js");
117: $this->addRequiredScript("cfoldingrow.js");
118:
119: $user = new cApiUser($auth->auth["uid"]);
120:
121: if ($bExpanded == NULL) {
122:
123: if ($user->isLoaded()) {
124: if ($user->getProperty("expandstate", $uuid) == "true") {
125: $this->setExpanded($user->getProperty("expandstate", $uuid));
126: }
127: }
128: } else {
129: if ($bExpanded) {
130: $this->setExpanded(true);
131: } else {
132: $this->setExpanded(false);
133: }
134: }
135: }
136:
137: 138: 139: 140:
141: public function setExpanded($expanded = false) {
142: if ($expanded == true) {
143: $this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif");
144: $this->_foldingImage->updateAttributes(array("data-state" => "expanded"));
145: $this->_contentRow->setStyle("display: ;");
146: $this->_hiddenField->setValue('expanded');
147: } else {
148: $this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif");
149: $this->_foldingImage->updateAttributes(array("data-state" => "collapsed"));
150: $this->_contentRow->setStyle("display: none;");
151: $this->_hiddenField->setValue('collapsed');
152: }
153: $this->_expanded = $expanded;
154: }
155:
156: 157: 158: 159:
160: public function setCaption($caption) {
161: $this->_caption = $caption;
162: }
163:
164: 165: 166: 167: 168:
169: public function setHelpContext($context = false) {
170: $this->_helpContext = $context;
171: }
172:
173: 174: 175: 176: 177:
178: public function setIndent($indent = 0) {
179: $this->_indent = $indent;
180: }
181:
182: 183: 184: 185:
186: function setContentData($content) {
187: $this->_contentData->setContent($content);
188: }
189:
190: 191: 192: 193: 194:
195: public function render() {
196:
197: $this->_link->setClass("foldingrow");
198: if ($this->_linkId != NULL) {
199: $this->_link->setID($this->_linkId);
200: }
201:
202: $imgid = $this->_foldingImage->getID();
203: $rowid = $this->_contentRow->getID();
204: $hiddenid = $this->_hiddenField->getID();
205: $uuid = $this->_uuid;
206:
207: $this->_link->setLink("javascript:void(0);");
208: $this->_link->setContent($this->_foldingImage->render() . $this->_caption);
209:
210: $this->_headerData->setContent(array($this->_hiddenField, $this->_link));
211: $this->_headerRow->setContent($this->_headerData);
212:
213: $this->_contentRow->setContent($this->_contentData);
214:
215: $output = $this->_headerRow->render();
216: $output .= $this->_contentRow->render();
217:
218: $output = <<<HTML
219: <!-- cGuiFoldingRow -->
220: {$output}
221: <script type="text/javascript">
222: (function(Con, $) {
223: $(function() {
224: $("#{$this->_linkId}").click(function() {
225: Con.FoldingRow.toggle("{$imgid}", "{$rowid}", "{$hiddenid}", "{$uuid}");
226: });
227: });
228: })(Con, Con.$);
229: </script>
230: <!-- /cGuiFoldingRow -->
231: HTML;
232:
233: return $output;
234: }
235:
236: }
237: