Documentation TYPO3 par Ameos

class.t3lib_rteapi.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2004-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00064 class t3lib_rteapi {
00065 
00066                 // Internal, dynamic:
00067         var $errorLog = array();                // Error messages regarding non-availability is collected here.
00068 
00069                 // Internal, static:
00070         var $ID = '';                                   // Set this to the extension key of the RTE so it can identify itself.
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079         /***********************************
00080          *
00081          * Main API functions;
00082          * When you create alternative RTEs, simply override these functions in your parent class.
00083          * See the "rte" or "rtehtmlarea" extension as an example!
00084          *
00085          **********************************/
00086 
00093         function isAvailable()  {
00094                 global $CLIENT;
00095 
00096                 $this->errorLog = array();
00097                 if (!$CLIENT['FORMSTYLE'])      $this->errorLog[] = 'RTE API: Browser didn\'t support styles';
00098 
00099                 if (!count($this->errorLog))    return TRUE;
00100         }
00101 
00118         function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue)      {
00119 
00120                         // Transform value:
00121                 $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
00122 
00123                         // Create item:
00124                 $item = '
00125                         '.$this->triggerField($PA['itemFormElName']).'
00126                         <textarea name="'.htmlspecialchars($PA['itemFormElName']).'"'.$pObj->formWidthText('48','off').' rows="20" wrap="off" style="background-color: #99eebb;">'.
00127                         t3lib_div::formatForTextarea($value).
00128                         '</textarea>';
00129 
00130                         // Return form item:
00131                 return $item;
00132         }
00133 
00151         function transformContent($dirRTE,$value,$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$pid)     {
00152 
00153 #debug(array($dirRTE,$value,$table,$field,array(),$specConf,$thisConfig,$RTErelPath,$pid));
00154 
00155                 if ($specConf['rte_transform']) {
00156                         $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
00157                         if ($p['mode']) {       // There must be a mode set for transformation
00158 #debug($p['mode'],'MODE');
00159 
00160                                         // Initialize transformation:
00161                                 $parseHTML = t3lib_div::makeInstance('t3lib_parsehtml_proc');
00162                                 $parseHTML->init($table.':'.$field, $pid);
00163                                 $parseHTML->setRelPath($RTErelPath);
00164 
00165                                         // Perform transformation:
00166                                 $value = $parseHTML->RTE_transform($value, $specConf, $dirRTE, $thisConfig);
00167                         }
00168                 }
00169 
00170 #debug(array($dirRTE,$value),'OUT: '.$dirRTE);
00171                 return $value;
00172         }
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185         /***********************************
00186          *
00187          * Helper functions
00188          *
00189          **********************************/
00190 
00197         function triggerField($fieldName)       {
00198 
00199                 $triggerFieldName = ereg_replace('\[([^]]+)\]$','[_TRANSFORM_\1]', $fieldName);
00200                 return '<input type="hidden" name="'.htmlspecialchars($triggerFieldName).'" value="RTE" />';
00201         }
00202 }
00203 
00204 // Include extension?
00205 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/class.tx_rte_base.php'])   {
00206         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/class.tx_rte_base.php']);
00207 }
00208 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6