Documentation TYPO3 par Ameos

class.tx_rte_base.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2004 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 ***************************************************************/
00050 require_once(PATH_t3lib.'class.t3lib_rteapi.php');
00058 class tx_rte_base extends t3lib_rteapi {
00059 
00060                 // External:
00061         var $RTEdivStyle;                               // Alternative style for RTE <div> tag.
00062 
00063                 // Internal, static:
00064         var $ID = 'rte';                                // Identifies the RTE as being the one from the "rte" extension if any external code needs to know...
00065         var $debugMode = FALSE;                 // If set, the content goes into a regular TEXT area field - for developing testing of transformations. (Also any browser will load the field!)
00066 
00067 
00074         function isAvailable()  {
00075                 global $CLIENT;
00076 
00077                 if (TYPO3_DLOG) t3lib_div::devLog('Checking for availability...','rte');
00078 
00079                 $this->errorLog = array();
00080                 if (!$this->debugMode)  {       // If debug-mode, let any browser through
00081                         if ($CLIENT['BROWSER']!='msie')         $this->errorLog[] = '"rte": Browser is not MSIE';
00082                         if ($CLIENT['SYSTEM']!='win')           $this->errorLog[] = '"rte": Client system is not Windows';
00083                         if ($CLIENT['VERSION']<5)                       $this->errorLog[] = '"rte": Browser version below 5';
00084                 }
00085                 if (!count($this->errorLog))    return TRUE;
00086         }
00087 
00103         function drawRTE(&$pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue)      {
00104 
00105                         // Draw form element:
00106                 if ($this->debugMode)   {       // Draws regular text area (debug mode)
00107                         $item = parent::drawRTE($pObj,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
00108                 } else {        // Draw real RTE (MSIE 5+ only)
00109 
00110                                 // Adding needed code in top:
00111                         $pObj->additionalJS_pre['rte_loader_function'] = $this->loaderFunc($pObj->formName);
00112                         $pObj->additionalJS_submit[] = "
00113                                                         if(TBE_RTE_WINDOWS['".$PA['itemFormElName']."'])        { document.".$pObj->formName."['".$PA['itemFormElName']."'].value = TBE_RTE_WINDOWS['".$PA['itemFormElName']."'].getHTML(); } else { OK=0; }";
00114 
00115                                 // Setting style:
00116                         $RTEWidth = 460+($pObj->docLarge ? 150 : 0);
00117                         $RTEdivStyle = $this->RTEdivStyle ? $this->RTEdivStyle : 'position:relative; left:0px; top:0px; height:380px; width:'.$RTEWidth.'px; border:solid 0px;';
00118 
00119                                 // RTE url:
00120                         $rteURL = $pObj->backPath.'ext/rte/app/rte.php?'.
00121                                                         'elementId='.rawurlencode($PA['itemFormElName']).       // Form element name
00122                                                         '&pid='.$thePidValue.                                                           // PID for record being edited.
00123                                                         '&typeVal='.rawurlencode($RTEtypeVal).                          // TCA "types" value for record
00124                                                         '&bgColor='.rawurlencode($pObj->colorScheme[0]).        // Background color
00125                                                         '&sC='.rawurlencode($PA['extra']).                                      // Extra options; This is index 3 (part #4) of the TCA "types" configuration of the field. Can be parsed by
00126                                                         '&defaultExtras='.rawurlencode($PA['fieldConf']['defaultExtras']).      // Default Extra options
00127                                                         '&formName='.rawurlencode($pObj->formName);                     // Form name
00128 
00129                                 // Transform value:
00130                         $value = $this->transformContent('rte',$PA['itemFormElValue'],$table,$field,$row,$specConf,$thisConfig,$RTErelPath,$thePidValue);
00131 
00132                                 // Register RTE windows:
00133                         $pObj->RTEwindows[] = $PA['itemFormElName'];
00134                         $item = '
00135                                 '.$this->triggerField($PA['itemFormElName']).'
00136                                 <input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($value).'" />
00137                                 <div id="cdiv'.count($pObj->RTEwindows).'" style="'.htmlspecialchars($RTEdivStyle).'">
00138                                 <iframe
00139                                         src="'.htmlspecialchars($rteURL).'"
00140                                         id="'.$PA['itemFormElName'].'_RTE"
00141                                         style="visibility:visible; position:absolute; left:0px; top:0px; height:100%; width:100%;"></iframe>
00142                                 </div>';
00143                 }
00144 
00145                         // Return form item:
00146                 return $item;
00147         }
00148 
00155         function loaderFunc($formname)  {
00156                 return '
00157                                 var TBE_RTE_WINDOWS = new Array();
00158 
00159                                 function TBE_EDITOR_setRTEref(RTEobj,theField,loadContent)      {       //
00160                                         TBE_RTE_WINDOWS[theField] = RTEobj;
00161                                         if (loadContent)        {
00162                                                 RTEobj.setHTML(document.'.$formname.'[theField].value);
00163                                         }
00164                                 }
00165                 ';
00166         }
00167 }
00168 
00169 // Include extension?
00170 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/class.tx_rte_base.php'])   {
00171         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rte/class.tx_rte_base.php']);
00172 }
00173 ?>


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