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

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