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