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
    • 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 int $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:      */
 36:     public function __construct($rawSettings, $id, array $contentTypes) {
 37:         $rawSettings = conHtmlSpecialChars($rawSettings);
 38:         // change attributes from the parent class and call the parent
 39:         // constructor
 40:         parent::__construct($rawSettings, $id, $contentTypes);
 41:         $this->_type = 'CMS_TEXT';
 42:         $this->_prefix = 'text';
 43: 
 44:         // if form is submitted, store the current text
 45:         // notice: also check the ID of the content type (there could be more
 46:         // than one content type of the same type on the same page!)
 47:         if (isset($_POST[$this->_prefix . '_action']) && $_POST[$this->_prefix . '_action'] === 'store' && isset($_POST[$this->_prefix . '_id']) && (int) $_POST[$this->_prefix . '_id'] == $this->_id) {
 48:             $this->_settings = $_POST[$this->_prefix . '_text_' . $this->_id];
 49:             $this->_rawSettings = $this->_settings;
 50:             $this->_storeSettings();
 51:             $this->_settings = stripslashes($this->_settings);
 52:             $this->_rawSettings = stripslashes($this->_rawSettings);
 53:         }
 54:     }
 55: 
 56:     /**
 57:      * Generates the code which should be shown if this content type is edited.
 58:      *
 59:      * @return string escaped HTML code which should be shown if content type is
 60:      *         edited
 61:      */
 62:     public function generateEditCode() {
 63:         $script = $this->_getEditJavaScript();
 64: 
 65:         $div = new cHTMLDiv($this->_rawSettings);
 66:         $div->setID($this->_prefix . '_text_' . $this->_id);
 67:         $div->appendStyleDefinition('display', 'inline');
 68: 
 69:         $editButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . $this->_cfg['path']['images'] . 'but_edithead.gif');
 70:         $editButton->setID($this->_prefix . '_editbutton_' . $this->_id);
 71:         $editButton->appendStyleDefinitions(array(
 72:             'margin-left' => '5px',
 73:             'cursor' => 'pointer'
 74:         ));
 75: 
 76:         return $this->_encodeForOutput($script . $div->render() . $editButton->render());
 77:     }
 78: 
 79:     /**
 80:      * Generates the JS code for this content type.
 81:      *
 82:      * @return string the JS code for the content type
 83:      */
 84:     protected function _getEditJavaScript() {
 85:         $textbox = new cHTMLTextbox($this->_prefix . '_text_' . $this->_id, '', '', '', $this->_prefix . '_text_' . $this->_id, false, NULL, '', 'edit-textfield edit-' . $this->_prefix . '-textfield');
 86: 
 87:         $saveButton = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/but_ok.gif');
 88:         $saveButton->setID($this->_prefix . '_savebutton_' . $this->_id);
 89:         $saveButton->appendStyleDefinitions(array(
 90:             'margin-left' => '5px',
 91:             'cursor' => 'pointer'
 92:         ));
 93: 
 94:         $template = new cTemplate();
 95:         $template->set('s', 'PREFIX', $this->_prefix);
 96:         $template->set('s', 'ID', $this->_id);
 97:         $template->set('s', 'TEXTBOX', $textbox->render());
 98:         $template->set('s', 'SAVEBUTTON', $saveButton->render());
 99:         $template->set('s', 'IDARTLANG', $this->_idArtLang);
100: 
101:         return $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_text_js.html', true);
102:     }
103: 
104:     /**
105:      * Generates the code which should be shown if this content type is shown in
106:      * the frontend.
107:      *
108:      * @return string escaped HTML code which sould be shown if content type is
109:      *         shown in frontend
110:      */
111:     public function generateViewCode() {
112:         return $this->_encodeForOutput($this->_rawSettings);
113:     }
114: 
115: }
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0