Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • ArticleForumCollection
  • ArticleForumItem
  • ArticleForumLeftBottom
  • ArticleForumRightBottom
  • cContentTypeUserForum
  • UserForum
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the class for contenttype CMS_USERFORUM
  4:  *
  5:  * @package Plugin
  6:  * @subpackage UserForum
  7:  * @author Claus Schunk
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * This class contains the features of the contenttype CMS_USERFORUM.
 18:  *
 19:  *
 20:  * @package Plugin
 21:  * @subpackage UserForum
 22:  */
 23: class cContentTypeUserForum extends cContentTypeAbstractTabbed {
 24: 
 25:     // Width from Container set in file cms/css/contenido_backend.css
 26:     // .cms_userforum label {
 27:     // width: 210px !important;
 28:     // }
 29: 
 30:     /**
 31:      * Initialize class attributes and handles store events.
 32:      *
 33:      * @param string $rawSettings the raw settings in an XML structure or as
 34:      *        plaintext
 35:      * @param int $id ID of the content type, e.g. 3 if CMS_DATE[3] is
 36:      *        used
 37:      * @param array $contentTypes array containing the values of all content
 38:      *        types
 39:      */
 40:     function __construct($rawSettings, $id, array $contentTypes) {
 41: 
 42:         // set attributes of the parent class and call the parent constructor
 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:         // encoding conversions to avoid problems with umlauts
 53:         $rawSettings = conHtmlEntityDecode($rawSettings);
 54:         $rawSettings = utf8_encode($rawSettings);
 55: 
 56:         parent::__construct($rawSettings, $id, $contentTypes);
 57: 
 58:         // if form is submitted, store the current settings
 59:         // notice: also check the ID of the content type (there could be more
 60:         // than one content type of the same type on the same page!)
 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:      * Generate the escaped HTML code for editor.
 70:      *
 71:      * @return string escaped HTML code for editor
 72:      */
 73:     public function generateEditCode() {
 74:         $cfg = cRegistry::getConfig();
 75:         // build top code
 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:         // available tabs
 84:         // $tabMenu = array(
 85:         // 'base' => Pifa::i18n('form')
 86:         // );
 87: 
 88:         // build tab code
 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:         // build bottom code
 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:         // build template code
110:         $code = $this->_encodeForOutput($codeTop);
111:         // $code .= $this->_generateTabMenuCode($tabMenu);
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:      * Generates code for the base panel in which all data can be specified.
126:      *
127:      * @return string  The code for the base panel
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:         // build html elements
144:         $labelModMode = new cHTMLLabel(UserForum::i18n('ACTIVATEMOD'), $id);
145:         $checkBoxMod = new cHTMLCheckbox($id, '', $id);
146:         $checkBoxMod->setID($id);
147: 
148:         // check state
149:         ($this->_settings['userforum_modactive'] === 'false') ? $checkBoxMod->setChecked(false) : $checkBoxMod->setChecked(true);
150: 
151:         // build div element as wrapper
152:         $div = new cHTMLDiv(array(
153:             '<br />',
154:             $labelModMode,
155:             $checkBoxMod
156:         ));
157:         $div->setClass('modMode');
158: 
159:         // return div element
160:         return $div;
161:     }
162: 
163:     private function _getEditMode() {
164:         $id = 'userforum_subcomments_' . $this->_id;
165: 
166:         // build html elements
167:         $labelModMode = new cHTMLLabel(UserForum::i18n('EDITABLE'), $id);
168:         $checkBoxMod = new cHTMLCheckbox($id, '', $id);
169:         $checkBoxMod->setID($id);
170: 
171:         // check state
172:         ($this->_settings['userforum_subcomments'] === 'false') ? $checkBoxMod->setChecked(false) : $checkBoxMod->setChecked(true);
173: 
174:         // build div element as wrapper
175:         $div = new cHTMLDiv(array(
176:             $labelModMode,
177:             $checkBoxMod
178:         ));
179:         $div->setClass('editMode');
180: 
181:         // return div element
182:         return $div;
183:     }
184: 
185:     /**
186:      * Builds a select element allowing to choose a single form that was created
187:      * for the current client.
188:      *
189:      * @return cHTMLDiv
190:      */
191:     private function _getModEmail() {
192:         $id = 'userforum_email_' . $this->_id;
193: 
194:         // build html elements
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:         // build div element as wrapper
203:         $div = new cHTMLDiv(array(
204:             $labelEmail,
205:             $inputEmail
206:         ));
207:         $div->setClass('mail');
208:         // return div element
209:         return $div;
210:     }
211: 
212:     /**
213:      * Generates the code which should be shown if this content type is shown in
214:      * the frontend.
215:      * This code is cached. Thatfor ist no more than the initialisation of this
216:      * class and the call of its method buildCode(). Otherwise the generated
217:      * HTML would have been cached.
218:      *
219:      * @return string escaped HTML code which sould be shown if content type is
220:      *         shown in frontend
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:      * Get code of form (either GET or POST request).
231:      *
232:      * @return string escaped HTML code which sould be shown if content type is
233:      *         shown in frontend
234:      */
235:     public function buildCode() {
236:         $out = '';
237:         return $out;
238:     }
239: 
240: }
241: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0