"TYPO3 4.0.1: typo3_src-4.0.1/typo3/wizard_rte.php Source File", "datetime" => "Sat Dec 2 19:22:35 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

wizard_rte.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-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 ***************************************************************/
00054 $BACK_PATH='';
00055 require ('init.php');
00056 require ('template.php');
00057 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
00058 require_once (PATH_t3lib.'class.t3lib_tceforms.php');
00059 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00060 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
00061 
00062 t3lib_BEfunc::lockRecords();
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00081 class SC_wizard_rte {
00082 
00083                 // Internal, dynamic:
00084         var $doc;                                       // Document template object
00085         var $content;                           // Content accumulation for the module.
00086 
00087                 // Internal, static: GPvars
00088         var $P;                                         // Wizard parameters, coming from TCEforms linking to the wizard.
00089         var $popView;                           // If set, launch a new window with the current records pid.
00090 
00091 
00092 
00093 
00099         function init() {
00100                 global $BACK_PATH;
00101 
00102                         // Setting GPvars:
00103                 $this->P = t3lib_div::_GP('P');
00104                 $this->popView = t3lib_div::_GP('popView');
00105 
00106                         // "Module name":
00107                 $this->MCONF['name']='xMOD_wizard_rte.php';
00108 
00109                         // Starting the document template object:
00110                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00111                 $this->doc->docType = 'xhtml_trans';
00112                 $this->doc->divClass = '';      // Need to NOT have the page wrapped in DIV since if we do that we destroy the feature that the RTE spans the whole height of the page!!!
00113                 $this->doc->form='<form action="tce_db.php" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" name="editform" onsubmit="return TBE_EDITOR_checkSubmit(1);">';
00114                 $this->doc->backPath = $BACK_PATH;
00115 
00116         }
00117 
00123         function main() {
00124                 global $BE_USER,$LANG;
00125 
00126                         // translate id to the workspace version:
00127                 if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
00128                         $this->P['uid'] = $versionRec['uid'];
00129                 }
00130 
00131                         // If all parameters are available:
00132                 if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'],$this->P['uid']))     {
00133 
00134                                 // Getting the raw record (we need only the pid-value from here...)
00135                         $rawRec = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
00136                         t3lib_BEfunc::fixVersioningPid($this->P['table'], $rawRec);
00137 
00138                                 // Setting JavaScript, including the pid value for viewing:
00139                         $this->doc->JScode = $this->doc->wrapScriptTags('
00140                                         function jumpToUrl(URL,formEl)  {       //
00141                                                 if (document.editform)  {
00142                                                         if (!TBE_EDITOR_isFormChanged())        {
00143                                                                 window.location.href = URL;
00144                                                         } else if (formEl) {
00145                                                                 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
00146                                                         }
00147                                                 } else window.location.href = URL;
00148                                         }
00149                                 '.($this->popView ? t3lib_BEfunc::viewOnClick($rawRec['pid'],'',t3lib_BEfunc::BEgetRootLine($rawRec['pid'])) : '').'
00150                         ');
00151 
00152                                 // Create page HTML header:
00153                         $this->content.=$this->doc->startPage('');
00154 
00155 
00156                                 // Initialize TCeforms - for rendering the field:
00157                         $tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00158                         $tceforms->initDefaultBEMode(); // Init...
00159                         $tceforms->disableWizards = 1;  // SPECIAL: Disables all wizards - we are NOT going to need them.
00160                         $tceforms->colorScheme[0]=$this->doc->bgColor;  // SPECIAL: Setting background color of the RTE to ordinary background
00161 
00162                                 // Initialize style for RTE object:
00163                         $RTEobj = &t3lib_BEfunc::RTEgetObj();   // Getting reference to the RTE object used to render the field!
00164                         if ($RTEobj->ID == 'rte')       {
00165                                 $RTEobj->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border:solid 0px;';      // SPECIAL: Setting style for the RTE <DIV> layer containing the IFRAME
00166         #                       $RTEobj->RTEdivStyle = 'position:relative; left:0px; top:0px; height:600px; width:100%; border:solid 0px;';     // SPECIAL: Setting style for the RTE <DIV> layer containing the IFRAME
00167                         }
00168 
00169                                 // Fetching content of record:
00170                         $trData = t3lib_div::makeInstance('t3lib_transferData');
00171                         $trData->lockRecords=1;
00172                         $trData->fetchRecord($this->P['table'],$this->P['uid'],'');
00173 
00174                                 // Getting the processed record content out:
00175                         reset($trData->regTableItems_data);
00176                         $rec = current($trData->regTableItems_data);
00177                         $rec['uid'] = $this->P['uid'];
00178                         $rec['pid'] = $rawRec['pid'];
00179 
00180                                 // Making the toolbar:
00181                         $closeUrl = $this->P['returnUrl'];
00182                         $R_URI=t3lib_div::linkThisScript(array('popView'=>''));
00183 
00184                                 // Getting settings for the undo button:
00185                         $undoButton = 0;
00186                         $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->P['table'], 'sys_history').' AND recuid='.intval($this->P['uid']), '', 'tstamp DESC', '1');
00187                         if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes))     {
00188                                 $undoButton = 1;
00189                         }
00190 
00191                                 // ShortCut
00192                         if ($BE_USER->mayMakeShortcut())        {
00193                                 $sCut = $this->doc->makeShortcutIcon('P','',$this->MCONF['name'],1);
00194                         } else {
00195                                 $sCut ='';
00196                         }
00197 
00198 
00199                                 // Make Toolbar of buttons:
00200                         $toolBarButtons=array();
00201 
00202                                 // Save:
00203                         $toolBarButtons[]=
00204                                 '<a href="#" onclick="TBE_EDITOR_checkAndDoSubmit(1); return false;">'.
00205                                 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" alt="" />'.
00206                                 '</a>';
00207 
00208                                 // Save/View:
00209                         if (t3lib_extMgm::isLoaded('cms'))      {
00210                                 $toolBarButtons[]=
00211                                         '<a href="#" onclick="'.htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR_checkAndDoSubmit(1); return false;').'">'.
00212                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedokshow.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow',1).'" alt="" />'.
00213                                         '</a>';
00214                         }
00215                                 // Save/Close:
00216                         $toolBarButtons[] = '<input type="image" class="c-inputButton" onclick="'.htmlspecialchars('document.editform.redirect.value=\''.$closeUrl.'\'; TBE_EDITOR_checkAndDoSubmit(1); return false;').'" name="_saveandclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" />';
00217                                 // Close:
00218                         $toolBarButtons[]=
00219                                         '<a href="#" onclick="'.htmlspecialchars('jumpToUrl(unescape(\''.rawurlencode($closeUrl).'\')); return false;').'">'.
00220                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" alt="" />'.
00221                                         '</a>';
00222 
00223                                 // Undo/Revert:
00224                         if ($undoButton)        {
00225                                 $toolBarButtons[]=
00226                                         '<a href="#" onclick="'.htmlspecialchars('window.location.href=\'show_rechis.php?element='.rawurlencode($this->P['table'].':'.$this->P['uid']).'&revert='.rawurlencode('field:'.$this->P['field']).'&sumUp=-1&returnUrl='.rawurlencode($R_URI).'\'; return false;').'">'.
00227                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/undo.gif','width="21" height="16"').' class="c-inputButton" title="'.htmlspecialchars(sprintf($LANG->getLL('rte_undoLastChange'),t3lib_BEfunc::calcAge(time()-$undoButtonR['tstamp'],$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))).'" alt="" />'.
00228                                         '</a>';
00229                         }
00230 
00231                         $panel = '<span class="c-saveButtons">'.implode('',$toolBarButtons).'</span>';
00232 
00233 
00234                                 // TSconfig, setting width:
00235                         $fieldTSConfig = $tceforms->setTSconfig($this->P['table'],$rec,$this->P['field']);
00236                         if (strcmp($fieldTSConfig['RTEfullScreenWidth'],''))    {
00237                                 $width=$fieldTSConfig['RTEfullScreenWidth'];
00238                         } else {
00239                                 $width='500';
00240                         }
00241 
00242                                 // Get the form field and wrap it in the table with the buttons:
00243                         $formContent = $tceforms->getSoloField($this->P['table'],$rec,$this->P['field']);
00244                         $formContent = '
00245 
00246 
00247                         <!--
00248                                 RTE wizard:
00249                         -->
00250                                 <table border="0" cellpadding="0" cellspacing="0" width="'.$width.'" id="typo3-rtewizard">
00251                                         <tr>
00252                                                 <td>'.$panel.'</td>
00253                                                 <td align="right">'.$sCut.'</td>
00254                                                 <td></td>
00255                                         </tr>
00256                                         <tr>
00257                                                 <td width="'.$width.'" colspan="2" id="c-formContent">'.$formContent.'</td>
00258                                                 <td></td>
00259                                         </tr>
00260                                 </table>';
00261 
00262                                 // Adding hidden fields:
00263                         $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($R_URI).'" />
00264                                                 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00265 
00266 
00267                                 // Finally, add the whole setup:
00268                         $this->content.=
00269                                 $tceforms->printNeededJSFunctions_top().
00270                                 $formContent.
00271                                 $tceforms->printNeededJSFunctions();
00272                 } else {
00273                                 // ERROR:
00274                         $this->content.=$this->doc->startPage('');
00275                         $this->content.=$this->doc->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1);
00276                 }
00277 
00278         }
00279 
00285         function printContent() {
00286                 $this->content.= $this->doc->endPage();
00287                 $this->content = $this->doc->insertStylesAndJS($this->content);
00288                 echo $this->content;
00289         }
00290 
00298         function checkEditAccess($table,$uid)   {
00299                 global $BE_USER;
00300 
00301                 $calcPRec = t3lib_BEfunc::getRecord($table,$uid);
00302                 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
00303                 if (is_array($calcPRec))        {
00304                         if ($table=='pages')    {       // If pages:
00305                                 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00306                                 $hasAccess = $CALC_PERMS&2 ? TRUE : FALSE;
00307                         } else {
00308                                 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));   // Fetching pid-record first.
00309                                 $hasAccess = $CALC_PERMS&16 ? TRUE : FALSE;
00310                         }
00311 
00312                                 // Check internals regarding access:
00313                         if ($hasAccess) {
00314                                 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
00315                         }
00316                 } else $hasAccess = FALSE;
00317 
00318                 return $hasAccess;
00319         }
00320 }
00321 
00322 // Include extension?
00323 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php'])    {
00324         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']);
00325 }
00326 
00327 
00328 
00329 
00330 
00331 
00332 
00333 
00334 
00335 
00336 
00337 
00338 // Make instance:
00339 $SOBE = t3lib_div::makeInstance('SC_wizard_rte');
00340 $SOBE->init();
00341 $SOBE->main();
00342 $SOBE->printContent();
00343 ?>