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: $this->_foldingImage->setStyle("margin-right: 4px;");
82:
83: $this->setExpanded(false);
84:
85: $this->addRequiredScript("parameterCollector.js");
86: $this->addRequiredScript("cfoldingrow.js");
87:
88: $user = new cApiUser($auth->auth["uid"]);
89:
90: if ($bExpanded == null) {
91:
92: if (!$user->virgin) {
93: if ($user->getProperty("expandstate", $uuid) == "true") {
94: $this->setExpanded($user->getProperty("expandstate", $uuid));
95: }
96: }
97: } else {
98: if ($bExpanded) {
99: $this->setExpanded(true);
100: } else {
101: $this->setExpanded(false);
102: }
103: }
104: }
105:
106: public function setExpanded($expanded = false) {
107: if ($expanded == true) {
108: $this->_foldingImage->setSrc("images/widgets/foldingrow/expanded.gif");
109: $this->_foldingImage->updateAttributes(array("data" => "expanded"));
110: $this->_contentRow->setStyle("display: ;");
111: $this->_hiddenField->setValue('expanded');
112: } else {
113: $this->_foldingImage->setSrc("images/widgets/foldingrow/collapsed.gif");
114: $this->_foldingImage->updateAttributes(array("data" => "collapsed"));
115: $this->_contentRow->setStyle("display: none;");
116: $this->_hiddenField->setValue('collapsed');
117: }
118: $this->_expanded = $expanded;
119: }
120:
121: public function setCaption($caption) {
122: $this->_caption = $caption;
123: }
124:
125: public function setHelpContext($context = false) {
126: $this->_helpContext = $context;
127: }
128:
129: public function setIndent($indent = 0) {
130: $this->_indent = $indent;
131: }
132:
133: function setContentData($content) {
134: $this->_contentData->setContent($content);
135: }
136:
137: public function render() {
138:
139: $this->_link->setClass("foldingrow");
140: if ($this->_linkId != NULL) {
141: $this->_link->setID($this->_linkId);
142: }
143:
144: $imgid = $this->_foldingImage->getID();
145: $rowid = $this->_contentRow->getID();
146: $hiddenid = $this->_hiddenField->getID();
147: $uuid = $this->_uuid;
148:
149: $this->_link->setLink("javascript:cGuiFoldingRow_expandCollapse('$imgid', '$rowid', '$hiddenid', '$uuid');");
150: $this->_link->setContent($this->_foldingImage->render() . $this->_caption);
151:
152: $this->_headerData->setContent(array($this->_hiddenField, $this->_link));
153: $this->_headerRow->setContent($this->_headerData);
154:
155: $this->_contentRow->setContent($this->_contentData);
156:
157: $output = $this->_headerRow->render();
158: $output .= $this->_contentRow->render();
159:
160: return ($output);
161: }
162:
163: }
164:
165: ?>