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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cCodeGeneratorAbstract
  • cCodeGeneratorFactory
  • cCodeGeneratorStandard
  • cContentTypeAbstract
  • cContentTypeAbstractTabbed
  • cContentTypeDate
  • cContentTypeFilelist
  • cContentTypeHead
  • cContentTypeHtml
  • cContentTypeHtmlhead
  • cContentTypeImg
  • cContentTypeImgdescr
  • cContentTypeImgeditor
  • cContentTypeLink
  • cContentTypeLinkdescr
  • cContentTypeLinkeditor
  • cContentTypeLinktarget
  • cContentTypeRaw
  • cContentTypeTeaser
  • cContentTypeText
  • cTypeGenerator
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the cContentTypeText class.
  5:  *
  6:  * @package Core
  7:  * @subpackage ContentType
  8:  * @author Simon Sprankel
  9:  * @copyright four for business AG <www.4fb.de>
 10:  * @license http://www.contenido.org/license/LIZENZ.txt
 11:  * @link http://www.4fb.de
 12:  * @link http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * Content type CMS_TEXT which lets the editor enter a single-line text.
 19:  *
 20:  * @package Core
 21:  * @subpackage ContentType
 22:  */
 23: class cContentTypeText extends cContentTypeAbstract {
 24: 
 25:     /**
 26:      * Initialises class attributes and handles store events.
 27:      *
 28:      * @param string $rawSettings
 29:      *         the raw settings in an XML structure or as plaintext
 30:      * @param int $id
 31:      *         ID of the content type, e.g. 3 if CMS_DATE[3] is used
 32:      * @param array $contentTypes
 33:      *         array containing the values of all content types
 34:      */
 35:     public function __construct($rawSettings, $id, array $contentTypes) {
 36: 
 37:         $rawSettings = conHtmlSpecialChars($rawSettings);
 38: 
 39:         // call parent constructor
 40:         parent::__construct($rawSettings, $id, $contentTypes);
 41: 
 42:         // set props
 43:         $this->_type = 'CMS_TEXT';
 44:         $this->_prefix = 'text';
 45: 
 46:         // if form is submitted, store the current text
 47:         // notice: also check the ID of the content type (there could be more
 48:         // than one content type of the same type on the same page!)
 49:         if (isset($_POST[$this->_prefix . '_action']) && $_POST[$this->_prefix . '_action'] === 'store' && isset($_POST[$this->_prefix . '_id']) && (int) $_POST[$this->_prefix . '_id'] == $this->_id) {
 50:             $this->_settings = $_POST[$this->_prefix . '_text_' . $this->_id];
 51:             $this->_rawSettings = $this->_settings;
 52:             $this->_storeSettings();
 53: 
 54:             // make sure to escape variables before any output on page
 55:             $this->_settings = stripslashes($this->_settings);
 56:             $this->_settings = conHtmlSpecialChars($this->_settings);
 57:             $this->_rawSettings = stripslashes($this->_rawSettings);
 58:             $this->_rawSettings = conHtmlSpecialChars($this->_rawSettings);
 59:         }
 60:     }
 61: 
 62:     /**
 63:      * Generates the code which should be shown if this content type is edited.
 64:      *
 65:      * @return string
 66:      *         escaped HTML code which should be shown if content type is edited
 67:      */
 68:     public function generateEditCode() {
 69:         $script = $this->_getEditJavaScript();
 70: 
 71:         $div = new cHTMLDiv($this->_rawSettings);
 72:         $div->setID($this->_prefix . '_text_' . $this->_id);
 73:         $div->appendStyleDefinition('display', 'inline');
 74: 
 75:         $editButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . $this->_cfg['path']['images'] . 'but_edithead.gif');
 76:         $editButton->setID($this->_prefix . '_editbutton_' . $this->_id);
 77:         $editButton->appendStyleDefinitions(array(
 78:             'margin-left' => '5px',
 79:             'cursor' => 'pointer'
 80:         ));
 81: 
 82:         return $this->_encodeForOutput($script . $div->render() . $editButton->render());
 83:     }
 84: 
 85:     /**
 86:      * Generates the JS code for this content type.
 87:      *
 88:      * @return string
 89:      *         the JS code for the content type
 90:      */
 91:     protected function _getEditJavaScript() {
 92:         $textbox = new cHTMLTextarea($this->_prefix . '_text_' . $this->_id, '', '', '', $this->_prefix . '_text_' . $this->_id, false, NULL, '', 'edit-textfield edit-' . $this->_prefix . '-textfield');
 93:         $textbox->setClass("$this->_id");
 94: 
 95:         $saveButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/but_ok.gif');
 96:         $saveButton->setID($this->_prefix . '_savebutton_' . $this->_id);
 97:         $saveButton->appendStyleDefinitions(array(
 98:             'margin-left' => '5px',
 99:             'cursor' => 'pointer'
100:         ));
101: 
102:         $template = new cTemplate();
103:         $template->set('s', 'PREFIX', $this->_prefix);
104:         $template->set('s', 'ID', $this->_id);
105:         $template->set('s', 'TEXTBOX', $textbox->render());
106:         $template->set('s', 'SAVEBUTTON', $saveButton->render());
107:         $template->set('s', 'IDARTLANG', $this->_idArtLang);
108: 
109:         return $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_text_js.html', true);
110:     }
111: 
112:     /**
113:      * Generates the code which should be shown if this content type is shown in
114:      * the frontend.
115:      *
116:      * @return string
117:      *         escaped HTML code which should be shown if content type is shown in frontend
118:      */
119:     public function generateViewCode() {
120:         return $this->_encodeForOutput($this->_rawSettings);
121:     }
122: 
123: }
124: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0