[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_rteapi.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 2004-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6  *  All rights reserved
   7  *
   8  *  This script is part of the TYPO3 project. The TYPO3 project is
   9  *  free software; you can redistribute it and/or modify
  10  *  it under the terms of the GNU General Public License as published by
  11  *  the Free Software Foundation; either version 2 of the License, or
  12  *  (at your option) any later version.
  13  *
  14  *  The GNU General Public License can be found at
  15  *  http://www.gnu.org/copyleft/gpl.html.
  16  *  A copy is found in the textfile GPL.txt and important notices to the license
  17  *  from the author is found in LICENSE.txt distributed with these scripts.
  18  *
  19  *
  20  *  This script is distributed in the hope that it will be useful,
  21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23  *  GNU General Public License for more details.
  24  *
  25  *  This copyright notice MUST APPEAR in all copies of the script!
  26  ***************************************************************/
  27  /**
  28   * RTE API parent class.
  29   *
  30   * @author    Kasper Skårhøj <kasperYYYY@typo3.com>
  31   */
  32  /**
  33   * [CLASS/FUNCTION INDEX of SCRIPT]
  34   *
  35   *
  36   *
  37   *   64: class t3lib_rteapi
  38   *
  39   *              SECTION: Main API functions;
  40   *   93:     function isAvailable()
  41   *  118:     function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue)
  42   *  151:     function transformContent($dirRTE,$value,$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$pid)
  43   *
  44   *              SECTION: Helper functions
  45   *  197:     function triggerField($fieldName)
  46   *
  47   * TOTAL FUNCTIONS: 4
  48   * (This index is automatically created/updated by the extension "extdeveval")
  49   *
  50   */
  51  
  52  
  53  
  54  
  55  
  56  /**
  57   * RTE base class: Delivers browser-detection, TCEforms binding and transformation routines for the "rte" extension, registering it with the RTE API in TYPO3 3.6.0
  58   * See "rte" extension for usage.
  59   *
  60   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  61   * @package TYPO3
  62   * @subpackage t3lib
  63   */
  64  class t3lib_rteapi {
  65  
  66          // Internal, dynamic:
  67      var $errorLog = array();        // Error messages regarding non-availability is collected here.
  68  
  69          // Internal, static:
  70      var $ID = '';                    // Set this to the extension key of the RTE so it can identify itself.
  71  
  72  
  73  
  74  
  75  
  76  
  77  
  78  
  79      /***********************************
  80       *
  81       * Main API functions;
  82       * When you create alternative RTEs, simply override these functions in your parent class.
  83       * See the "rte" or "rtehtmlarea" extension as an example!
  84       *
  85       **********************************/
  86  
  87      /**
  88       * Returns true if the RTE is available. Here you check if the browser requirements are met.
  89       * If there are reasons why the RTE cannot be displayed you simply enter them as text in ->errorLog
  90       *
  91       * @return    boolean        TRUE if this RTE object offers an RTE in the current browser environment
  92       */
  93  	function isAvailable()    {
  94          global $CLIENT;
  95  
  96          $this->errorLog = array();
  97          if (!$CLIENT['FORMSTYLE'])     $this->errorLog[] = 'RTE API: Browser didn\'t support styles';
  98  
  99          if (!count($this->errorLog))    return TRUE;
 100      }
 101  
 102      /**
 103       * Draws the RTE as a form field or whatever is needed (inserts JavaApplet, creates iframe, renders ....)
 104       * Default is to output the transformed content in a plain textarea field. This mode is great for debugging transformations!
 105       *
 106       * @param    object        Reference to parent object, which is an instance of the TCEforms.
 107       * @param    string        The table name
 108       * @param    string        The field name
 109       * @param    array        The current row from which field is being rendered
 110       * @param    array        Array of standard content for rendering form fields from TCEforms. See TCEforms for details on this. Includes for instance the value and the form field name, java script actions and more.
 111       * @param    array        "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
 112       * @param    array        Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
 113       * @param    string        Record "type" field value.
 114       * @param    string        Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
 115       * @param    integer        PID value of record (true parent page id)
 116       * @return    string        HTML code for RTE!
 117       */
 118  	function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue)    {
 119  
 120              // Transform value:
 121          $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
 122  
 123              // Create item:
 124          $item = '
 125              '.$this->triggerField($PA['itemFormElName']).'
 126              <textarea name="'.htmlspecialchars($PA['itemFormElName']).'"'.$pObj->formWidthText('48','off').' rows="20" wrap="off" style="background-color: #99eebb;">'.
 127              t3lib_div::formatForTextarea($value).
 128              '</textarea>';
 129  
 130              // Return form item:
 131          return $item;
 132      }
 133  
 134      /**
 135       * Performs transformation of content to/from RTE. The keyword $dirRTE determines the direction.
 136       * This function is called in two situations:
 137       * a) Right before content from database is sent to the RTE (see ->drawRTE()) it might need transformation
 138       * b) When content is sent from the RTE and into the database it might need transformation back again (going on in TCEmain class; You can't affect that.)
 139       *
 140       * @param    string        Keyword: "rte" means direction from db to rte, "db" means direction from Rte to DB
 141       * @param    string        Value to transform.
 142       * @param    string        The table name
 143       * @param    string        The field name
 144       * @param    array        The current row from which field is being rendered
 145       * @param    array        "special" configuration - what is found at position 4 in the types configuration of a field from record, parsed into an array.
 146       * @param    array        Configuration for RTEs; A mix between TSconfig and otherwise. Contains configuration for display, which buttons are enabled, additional transformation information etc.
 147       * @param    string        Relative path for images/links in RTE; this is used when the RTE edits content from static files where the path of such media has to be transformed forth and back!
 148       * @param    integer        PID value of record (true parent page id)
 149       * @return    string        Transformed content
 150       */
 151  	function transformContent($dirRTE,$value,$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$pid)    {
 152  
 153  #debug(array($dirRTE,$value,$table,$field,array(),$specConf,$thisConfig,$RTErelPath,$pid));
 154  
 155          if ($specConf['rte_transform'])    {
 156              $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
 157              if ($p['mode'])    {    // There must be a mode set for transformation
 158  #debug($p['mode'],'MODE');
 159  
 160                      // Initialize transformation:
 161                  $parseHTML = t3lib_div::makeInstance('t3lib_parsehtml_proc');
 162                  $parseHTML->init($table.':'.$field, $pid);
 163                  $parseHTML->setRelPath($RTErelPath);
 164  
 165                      // Perform transformation:
 166                  $value = $parseHTML->RTE_transform($value, $specConf, $dirRTE, $thisConfig);
 167              }
 168          }
 169  
 170  #debug(array($dirRTE,$value),'OUT: '.$dirRTE);
 171          return $value;
 172      }
 173  
 174  
 175  
 176  
 177  
 178  
 179  
 180  
 181  
 182  
 183  
 184  
 185      /***********************************
 186       *
 187       * Helper functions
 188       *
 189       **********************************/
 190  
 191      /**
 192       * Trigger field - this field tells the TCEmain that processing should be done on this value!
 193       *
 194       * @param    string        Field name of the RTE field.
 195       * @return    string        <input> field of type "hidden" with a flag telling the TCEmain that this fields content should be traansformed back to database state.
 196       */
 197  	function triggerField($fieldName)    {
 198  
 199          $triggerFieldName = ereg_replace('\[([^]]+)\]$','[_TRANSFORM_\1]', $fieldName);
 200          return '<input type="hidden" name="'.htmlspecialchars($triggerFieldName).'" value="RTE" />';
 201      }
 202  }
 203  
 204  // Include extension?
 205  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/class.tx_rte_base.php'])    {
 206      include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/class.tx_rte_base.php']);
 207  }
 208  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics