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
    • SIWECOS
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • ArticleForum
  • 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:      * Initialize class attributes and handles store events.
 26:      *
 27:      * @param string $rawSettings  the raw settings in an XML structure or as
 28:      *                             plaintext
 29:      * @param int    $id           ID of the content type, e.g. 3 if CMS_DATE[3] is
 30:      *                             used
 31:      * @param array  $contentTypes array containing the values of all content
 32:      *                             types
 33:      *
 34:      * @throws cDbException
 35:      */
 36:     function __construct($rawSettings, $id, array $contentTypes) {
 37: 
 38:         // set attributes of the parent class and call the parent constructor
 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:         // encoding conversions to avoid problems with umlauts
 49:         $rawSettings = conHtmlEntityDecode($rawSettings);
 50:         $rawSettings = utf8_encode($rawSettings);
 51: 
 52:         parent::__construct($rawSettings, $id, $contentTypes);
 53: 
 54:         // if form is submitted, store the current settings
 55:         // notice: also check the ID of the content type (there could be more
 56:         // than one content type of the same type on the same page!)
 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:      * Generate the escaped HTML code for editor.
 66:      *
 67:      * @return string escaped HTML code for editor
 68:      * @throws cInvalidArgumentException
 69:      */
 70:     public function generateEditCode() {
 71:         $cfg = cRegistry::getConfig();
 72: 
 73:         // build top code
 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:         // available tabs
 82:         // $tabMenu = array('base' => Pifa::i18n('form'));
 83: 
 84:         // build tab code
 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:         // build bottom code
 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:         // build template code
106:         $code = $this->_encodeForOutput($codeTop);
107:         // $code .= $this->_generateTabMenuCode($tabMenu);
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:      * Generates code for the base panel in which all data can be specified.
122:      *
123:      * @return string  The code for the base panel
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:      * @return cHTMLDiv
138:      */
139:     private function _getModMode() {
140:         $id = 'userforum_modactive_' . $this->_id;
141: 
142:         // build html elements
143:         $labelModMode = new cHTMLLabel(UserForum::i18n('ACTIVATEMOD'), $id);
144:         $checkBoxMod = new cHTMLCheckbox($id, '', $id);
145:         $checkBoxMod->setID($id);
146: 
147:         // check state
148:         ($this->_settings['userforum_modactive'] === 'false') ? $checkBoxMod->setChecked(false) : $checkBoxMod->setChecked(true);
149: 
150:         // build div element as wrapper
151:         $div = new cHTMLDiv(array(
152:             '<br />',
153:             $labelModMode,
154:             $checkBoxMod
155:         ));
156:         $div->setClass('modMode');
157: 
158:         // return div element
159:         return $div;
160:     }
161: 
162:     /**
163:      * @return cHTMLDiv
164:      */
165:     private function _getEditMode() {
166:         $id = 'userforum_subcomments_' . $this->_id;
167: 
168:         // build html elements
169:         $labelModMode = new cHTMLLabel(UserForum::i18n('EDITABLE'), $id);
170:         $checkBoxMod = new cHTMLCheckbox($id, '', $id);
171:         $checkBoxMod->setID($id);
172: 
173:         // check state
174:         ($this->_settings['userforum_subcomments'] === 'false') ? $checkBoxMod->setChecked(false) : $checkBoxMod->setChecked(true);
175: 
176:         // build div element as wrapper
177:         $div = new cHTMLDiv(array(
178:             $labelModMode,
179:             $checkBoxMod
180:         ));
181:         $div->setClass('editMode');
182: 
183:         // return div element
184:         return $div;
185:     }
186: 
187:     /**
188:      * Builds a select element allowing to choose a single form that was created
189:      * for the current client.
190:      *
191:      * @return cHTMLDiv
192:      */
193:     private function _getModEmail() {
194:         $id = 'userforum_email_' . $this->_id;
195: 
196:         // build html elements
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:         // build div element as wrapper
205:         $div = new cHTMLDiv(array(
206:             $labelEmail,
207:             $inputEmail
208:         ));
209:         $div->setClass('mail');
210: 
211:         // return div element
212:         return $div;
213:     }
214: 
215:     /**
216:      * Generates the code which should be shown if this content type is shown in
217:      * the frontend.
218:      * This code is cached. Thatfor ist no more than the initialisation of this
219:      * class and the call of its method buildCode(). Otherwise the generated
220:      * HTML would have been cached.
221:      *
222:      * @return string escaped HTML code which sould be shown if content type is
223:      *         shown in frontend
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:      * Get code of form (either GET or POST request).
234:      *
235:      * @return string escaped HTML code which sould be shown if content type is
236:      *         shown in frontend
237:      */
238:     public function buildCode() {
239:         $out = '';
240:         return $out;
241:     }
242: 
243: }
244: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0