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