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