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:      * Constructor to create an instance of this class.
 27:      *
 28:      * Initialises class attributes and handles store events.
 29:      *
 30:      * @param string $rawSettings
 31:      *         the raw settings in an XML structure or as plaintext
 32:      * @param int $id
 33:      *         ID of the content type, e.g. 3 if CMS_DATE[3] is used
 34:      * @param array $contentTypes
 35:      *         array containing the values of all content types
 36:      */
 37:     public function __construct($rawSettings, $id, array $contentTypes) {
 38: 
 39:         $rawSettings = conHtmlSpecialChars($rawSettings);
 40: 
 41:         // call parent constructor
 42:         parent::__construct($rawSettings, $id, $contentTypes);
 43: 
 44:         // set props
 45:         $this->_type = 'CMS_TEXT';
 46:         $this->_prefix = 'text';
 47: 
 48:         // if form is submitted, store the current text
 49:         // notice: also check the ID of the content type (there could be more
 50:         // than one content type of the same type on the same page!)
 51:         if (isset($_POST[$this->_prefix . '_action']) && $_POST[$this->_prefix . '_action'] === 'store' && isset($_POST[$this->_prefix . '_id']) && (int) $_POST[$this->_prefix . '_id'] == $this->_id) {
 52:             $this->_settings = $_POST[$this->_prefix . '_text_' . $this->_id];
 53:             $this->_rawSettings = $this->_settings;
 54:             $this->_storeSettings();
 55: 
 56:             // make sure to escape variables before any output on page
 57:             $this->_settings = stripslashes($this->_settings);
 58:             $this->_settings = conHtmlSpecialChars($this->_settings);
 59:             $this->_rawSettings = stripslashes($this->_rawSettings);
 60:             $this->_rawSettings = conHtmlSpecialChars($this->_rawSettings);
 61: 
 62:             // input of text with paragraphs should print text with line breaks
 63:             $this->_rawSettings = nl2br($this->_rawSettings);
 64:         }
 65:     }
 66: 
 67:     /**
 68:      * Generates the code which should be shown if this content type is edited.
 69:      *
 70:      * @return string
 71:      *         escaped HTML code which should be shown if content type is edited
 72:      */
 73:     public function generateEditCode() {
 74:         $script = $this->_getEditJavaScript();
 75: 
 76:         $div = new cHTMLDiv($this->_rawSettings);
 77:         $div->setID($this->_prefix . '_text_' . $this->_id);
 78:         $div->appendStyleDefinition('display', 'inline');
 79: 
 80:         $editButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . $this->_cfg['path']['images'] . 'but_edithead.gif');
 81:         $editButton->setID($this->_prefix . '_editbutton_' . $this->_id);
 82:         $editButton->appendStyleDefinitions(array(
 83:             'margin-left' => '5px',
 84:             'cursor' => 'pointer'
 85:         ));
 86: 
 87:         return $this->_encodeForOutput($script . $div->render() . $editButton->render());
 88:     }
 89: 
 90:     /**
 91:      * Generates the JS code for this content type.
 92:      *
 93:      * @return string
 94:      *         the JS code for the content type
 95:      */
 96:     protected function _getEditJavaScript() {
 97:         $textbox = new cHTMLTextarea($this->_prefix . '_text_' . $this->_id, '', '', '', $this->_prefix . '_text_' . $this->_id, false, NULL, '', 'edit-textfield edit-' . $this->_prefix . '-textfield');
 98:         $textbox->setClass("$this->_id");
 99: 
100:         $saveButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/but_ok.gif');
101:         $saveButton->setID($this->_prefix . '_savebutton_' . $this->_id);
102:         $saveButton->appendStyleDefinitions(array(
103:             'margin-left' => '5px',
104:             'cursor' => 'pointer'
105:         ));
106: 
107:         $template = new cTemplate();
108:         $template->set('s', 'PREFIX', $this->_prefix);
109:         $template->set('s', 'ID', $this->_id);
110:         $template->set('s', 'TEXTBOX', $textbox->render());
111:         $template->set('s', 'SAVEBUTTON', $saveButton->render());
112:         $template->set('s', 'IDARTLANG', $this->_idArtLang);
113: 
114:         return $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_text_js.html', true);
115:     }
116: 
117:     /**
118:      * Generates the code which should be shown if this content type is shown in
119:      * the frontend.
120:      *
121:      * @return string
122:      *         escaped HTML code which should be shown if content type is shown in frontend
123:      */
124:     public function generateViewCode() {
125:         return $this->_encodeForOutput($this->_rawSettings);
126:     }
127: 
128: }
129: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0