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:
25: class cContentTypeUserForum extends cContentTypeAbstractTabbed {
26:
27:
28:
29:
30:
31:
32: 33: 34: 35: 36: 37: 38: 39: 40: 41:
42: function __construct($rawSettings, $id, array $contentTypes) {
43:
44:
45: $this->_type = 'CMS_USERFORUM';
46: $this->_prefix = 'userforum';
47: $this->_settingsType = self::SETTINGS_TYPE_XML;
48: $this->_formFields = array(
49: 'userforum_email',
50: 'userforum_subcomments',
51: 'userforum_modactive'
52: );
53:
54:
55: $rawSettings = conHtmlEntityDecode($rawSettings);
56: $rawSettings = utf8_encode($rawSettings);
57:
58: parent::__construct($rawSettings, $id, $contentTypes);
59:
60:
61:
62:
63: $action = isset($_POST['userforum_action']) ? $_POST['userforum_action'] : NULL;
64: $id = isset($_POST['userforum_id']) ? $_POST['userforum_id'] : NULL;
65: if ('store' === $action && $this->_id == $id) {
66: $this->_storeSettings();
67: }
68: }
69:
70: 71: 72: 73: 74:
75: public function generateEditCode() {
76: $cfg = cRegistry::getConfig();
77:
78: $tplTop = new cTemplate();
79: $tplTop->set('s', 'ICON', 'plugins/user_forum/images/con_button.gif');
80: $tplTop->set('s', 'ID', $this->_id);
81: $tplTop->set('s', 'PREFIX', $this->_prefix);
82: $tplTop->set('s', 'HEADLINE', UserForum::i18n('ADMINISTRATION'));
83: $codeTop = $tplTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
84:
85:
86:
87:
88:
89:
90:
91: $tplPanel = new cTemplate();
92: $tplPanel->set('s', 'PREFIX', $this->_prefix);
93: $tplPanel->set('d', 'TAB_ID', 'base');
94: $tplPanel->set('d', 'TAB_CLASS', 'base');
95: $tplPanel->set('d', 'TAB_CONTENT', $this->_getPanel());
96: $tplPanel->next();
97: $codePanel = $tplPanel->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
98:
99:
100: $tplBottom = new cTemplate();
101: $tplBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
102: $tplBottom->set('s', 'ID', $this->_id);
103: $tplBottom->set('s', 'PREFIX', $this->_prefix);
104: $tplBottom->set('s', 'IDARTLANG', $this->_idArtLang);
105: $tplBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
106: $tplBottom->set('s', 'SETTINGS', json_encode($this->_settings));
107: $tplBottom->set('s', 'JS_CLASS_SCRIPT', UserForum::getUrl() . 'scripts/cmsUserforum.js');
108: $tplBottom->set('s', 'JS_CLASS_NAME', get_class($this));
109: $codeBottom = $tplBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
110:
111:
112: $code = $this->_encodeForOutput($codeTop);
113:
114: $code .= $this->_encodeForOutput($codePanel);
115: $code .= $this->_generateActionCode();
116: $code .= $this->_encodeForOutput($codeBottom);
117: $code .= $this->generateViewCode();
118:
119: $code = "\n\n<!-- CODE (class.content.type.user_forum.php) -->
120: $code
121: <!-- /CODE -->\n\n";
122:
123: return $code;
124: }
125:
126: 127: 128: 129: 130:
131: private function _getPanel() {
132: $wrapper = new cHTMLDiv(array(
133: $this->_getModEmail(),
134: $this->_getModMode(),
135: $this->_getEditMode()
136: ), $this->_prefix . '_panel_base', $this->_prefix . '_panel_base_' . $this->_id);
137: $wrapper->setStyle('clear:both');
138:
139: return $wrapper->render();
140: }
141:
142: private function _getModMode() {
143: $id = 'userforum_modactive_' . $this->_id;
144:
145:
146: $labelModMode = new cHTMLLabel(UserForum::i18n('ACTIVATEMOD'), $id);
147: $checkBoxMod = new cHTMLCheckbox($id, '', $id);
148: $checkBoxMod->setID($id);
149:
150:
151: ($this->_settings['userforum_modactive'] === 'false') ? $checkBoxMod->setChecked(false) : $checkBoxMod->setChecked(true);
152:
153:
154: $div = new cHTMLDiv(array(
155: '<br />',
156: $labelModMode,
157: $checkBoxMod
158: ));
159: $div->setClass('modMode');
160:
161:
162: return $div;
163: }
164:
165: private function _getEditMode() {
166: $id = 'userforum_subcomments_' . $this->_id;
167:
168:
169: $labelModMode = new cHTMLLabel(UserForum::i18n('EDITABLE'), $id);
170: $checkBoxMod = new cHTMLCheckbox($id, '', $id);
171: $checkBoxMod->setID($id);
172:
173:
174: ($this->_settings['userforum_subcomments'] === 'false') ? $checkBoxMod->setChecked(false) : $checkBoxMod->setChecked(true);
175:
176:
177: $div = new cHTMLDiv(array(
178: $labelModMode,
179: $checkBoxMod
180: ));
181: $div->setClass('editMode');
182:
183:
184: return $div;
185: }
186:
187: 188: 189: 190: 191: 192:
193: private function _getModEmail() {
194: $id = 'userforum_email_' . $this->_id;
195:
196:
197: $infoLabel = new cHTMLLabel(UserForum::i18n('MODSETTINGS'), $id);
198: $labelEmail = new cHTMLLabel(UserForum::i18n('MODEMAIL'), $id);
199:
200: $inputEmail = new cHTMLTextbox($id);
201: $inputEmail->setID($id);
202: $inputEmail->setValue($this->_settings['userforum_email']);
203:
204:
205: $div = new cHTMLDiv(array(
206: $labelEmail,
207: $inputEmail
208: ));
209: $div->setClass('mail');
210:
211: return $div;
212: }
213:
214: 215: 216: 217: 218: 219: 220: 221: 222: 223:
224: public function generateViewCode() {
225: $code = '";?' . '><' . '?php $form = new %s(\'%s\', %s, %s); echo $form->buildCode(); ?' . '><' . '?php echo "';
226: $code = sprintf($code, get_class($this), $this->_rawSettings, $this->_id, 'array()');
227:
228: return $code;
229: }
230:
231: 232: 233: 234: 235: 236:
237: public function buildCode() {
238: $out = '';
239: return $out;
240: }
241:
242: }
243: