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