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:
43: function __construct($rawSettings, $id, array $contentTypes) {
44:
45:
46: $this->_type = 'CMS_USERFORUM';
47: $this->_prefix = 'userforum';
48: $this->_settingsType = self::SETTINGS_TYPE_XML;
49: $this->_formFields = array(
50: 'userforum_email',
51: 'userforum_subcomments',
52: 'userforum_modactive'
53: );
54:
55:
56: $rawSettings = conHtmlEntityDecode($rawSettings);
57: $rawSettings = utf8_encode($rawSettings);
58:
59: parent::__construct($rawSettings, $id, $contentTypes);
60:
61:
62:
63:
64: $action = isset($_POST['userforum_action']) ? $_POST['userforum_action'] : NULL;
65: $id = isset($_POST['userforum_id']) ? $_POST['userforum_id'] : NULL;
66: if ('store' === $action && $this->_id == $id) {
67: $this->_storeSettings();
68: }
69: }
70:
71: 72: 73: 74: 75:
76: public function generateEditCode() {
77: $cfg = cRegistry::getConfig();
78:
79: $tplTop = new cTemplate();
80: $tplTop->set('s', 'PATH_BACKEND', $this->_cfg['path']['contenido_fullhtml']);
81: $tplTop->set('s', 'ICON', 'plugins/user_forum/images/con_button.gif');
82: $tplTop->set('s', 'ID', $this->_id);
83: $tplTop->set('s', 'PREFIX', $this->_prefix);
84: $tplTop->set('s', 'HEADLINE', UserForum::i18n('ADMINISTRATION'));
85: $codeTop = $tplTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
86:
87:
88:
89:
90:
91:
92:
93: $tplPanel = new cTemplate();
94: $tplPanel->set('s', 'PREFIX', $this->_prefix);
95: $tplPanel->set('d', 'TAB_ID', 'base');
96: $tplPanel->set('d', 'TAB_CLASS', 'base');
97: $tplPanel->set('d', 'TAB_CONTENT', $this->_getPanel());
98: $tplPanel->next();
99: $codePanel = $tplPanel->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
100:
101:
102: $tplBottom = new cTemplate();
103: $tplBottom->set('s', 'PATH_BACKEND', $this->_cfg['path']['contenido_fullhtml']);
104: $tplBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
105: $tplBottom->set('s', 'ID', $this->_id);
106: $tplBottom->set('s', 'PREFIX', $this->_prefix);
107: $tplBottom->set('s', 'IDARTLANG', $this->_idArtLang);
108: $tplBottom->set('s', 'CONTENIDO', $_REQUEST['contenido']);
109: $tplBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
110: $tplBottom->set('s', 'SETTINGS', json_encode($this->_settings));
111: $tplBottom->set('s', 'JS_CLASS_SCRIPT', UserForum::getUrl() . 'scripts/cmsUserforum.js');
112: $tplBottom->set('s', 'JS_CLASS_NAME', get_class($this));
113: $codeBottom = $tplBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
114:
115:
116: $code = $this->_encodeForOutput($codeTop);
117:
118: $code .= $this->_encodeForOutput($codePanel);
119: $code .= $this->_generateActionCode();
120: $code .= $this->_encodeForOutput($codeBottom);
121: $code .= $this->generateViewCode();
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: