Overview

Packages

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