Documentation TYPO3 par Ameos |
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 // If all parameters are available: 00127 if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'],$this->P['uid'])) { 00128 00129 // Getting the raw record (we need only the pid-value from here...) 00130 $rawRec = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']); 00131 00132 // Setting JavaScript, including the pid value for viewing: 00133 $this->doc->JScode = $this->doc->wrapScriptTags(' 00134 function jumpToUrl(URL,formEl) { // 00135 if (document.editform) { 00136 if (!TBE_EDITOR_isFormChanged()) { 00137 document.location = URL; 00138 } else if (formEl) { 00139 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1; 00140 } 00141 } else document.location = URL; 00142 } 00143 '.($this->popView ? t3lib_BEfunc::viewOnClick($rawRec['pid'],'',t3lib_BEfunc::BEgetRootLine($rawRec['pid'])) : '').' 00144 '); 00145 00146 // Create page HTML header: 00147 $this->content.=$this->doc->startPage(''); 00148 00149 00150 // Initialize TCeforms - for rendering the field: 00151 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms'); 00152 $tceforms->initDefaultBEMode(); // Init... 00153 $tceforms->disableWizards = 1; // SPECIAL: Disables all wizards - we are NOT going to need them. 00154 $tceforms->colorScheme[0]=$this->doc->bgColor; // SPECIAL: Setting background color of the RTE to ordinary background 00155 00156 // Initialize style for RTE object: 00157 $RTEobj = &t3lib_BEfunc::RTEgetObj(); // Getting reference to the RTE object used to render the field! 00158 if ($RTEobj->ID == 'rte') { 00159 $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 00160 # $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 00161 } 00162 00163 // Fetching content of record: 00164 $trData = t3lib_div::makeInstance('t3lib_transferData'); 00165 $trData->lockRecords=1; 00166 $trData->fetchRecord($this->P['table'],$this->P['uid'],''); 00167 00168 // Getting the processed record content out: 00169 reset($trData->regTableItems_data); 00170 $rec = current($trData->regTableItems_data); 00171 $rec['uid'] = $this->P['uid']; 00172 $rec['pid'] = $rawRec['pid']; 00173 00174 // Making the toolbar: 00175 $closeUrl = $this->P['returnUrl']; 00176 $R_URI=t3lib_div::linkThisScript(array('popView'=>'')); 00177 00178 // Getting settings for the undo button: 00179 $undoButton = 0; 00180 $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'); 00181 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) { 00182 $undoButton = 1; 00183 } 00184 00185 // ShortCut 00186 if ($BE_USER->mayMakeShortcut()) { 00187 $sCut = $this->doc->makeShortcutIcon('P','',$this->MCONF['name'],1); 00188 } else { 00189 $sCut =''; 00190 } 00191 00192 00193 // Make Toolbar of buttons: 00194 $toolBarButtons=array(); 00195 00196 // Save: 00197 $toolBarButtons[]= 00198 '<a href="#" onclick="TBE_EDITOR_checkAndDoSubmit(1); return false;">'. 00199 '<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="" />'. 00200 '</a>'; 00201 00202 // Save/View: 00203 if (t3lib_extMgm::isLoaded('cms')) { 00204 $toolBarButtons[]= 00205 '<a href="#" onclick="'.htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR_checkAndDoSubmit(1); return false;').'">'. 00206 '<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="" />'. 00207 '</a>'; 00208 } 00209 // Close: 00210 $toolBarButtons[]= 00211 '<a href="#" onclick="'.htmlspecialchars('jumpToUrl(unescape(\''.rawurlencode($closeUrl).'\')); return false;').'">'. 00212 '<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="" />'. 00213 '</a>'; 00214 00215 // Undo/Revert: 00216 if ($undoButton) { 00217 $toolBarButtons[]= 00218 '<a href="#" onclick="'.htmlspecialchars('document.location=\'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;').'">'. 00219 '<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="" />'. 00220 '</a>'; 00221 } 00222 00223 $panel = '<span class="c-saveButtons">'.implode('',$toolBarButtons).'</span>'; 00224 00225 00226 // TSconfig, setting width: 00227 $fieldTSConfig = $tceforms->setTSconfig($this->P['table'],$rec,$this->P['field']); 00228 if (strcmp($fieldTSConfig['RTEfullScreenWidth'],'')) { 00229 $width=$fieldTSConfig['RTEfullScreenWidth']; 00230 } else { 00231 $width='500'; 00232 } 00233 00234 // Get the form field and wrap it in the table with the buttons: 00235 $formContent = $tceforms->getSoloField($this->P['table'],$rec,$this->P['field']); 00236 $formContent = ' 00237 00238 00239 <!-- 00240 RTE wizard: 00241 --> 00242 <table border="0" cellpadding="0" cellspacing="0" width="'.$width.'" id="typo3-rtewizard"> 00243 <tr> 00244 <td>'.$panel.'</td> 00245 <td align="right">'.$sCut.'</td> 00246 <td></td> 00247 </tr> 00248 <tr> 00249 <td width="'.$width.'" colspan="2" id="c-formContent">'.$formContent.'</td> 00250 <td></td> 00251 </tr> 00252 </table>'; 00253 00254 // Adding hidden fields: 00255 $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($R_URI).'" /> 00256 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />'; 00257 00258 00259 // Finally, add the whole setup: 00260 $this->content.= 00261 $tceforms->printNeededJSFunctions_top(). 00262 $formContent. 00263 $tceforms->printNeededJSFunctions(); 00264 } else { 00265 // ERROR: 00266 $this->content.=$this->doc->startPage(''); 00267 $this->content.=$this->doc->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1); 00268 } 00269 00270 // Ending page: 00271 $this->content.=$this->doc->endPage(); 00272 } 00273 00279 function printContent() { 00280 echo $this->content; 00281 } 00282 00290 function checkEditAccess($table,$uid) { 00291 global $BE_USER; 00292 00293 $calcPRec = t3lib_BEfunc::getRecord($table,$uid); 00294 t3lib_BEfunc::fixVersioningPid($table,$uid); 00295 if (is_array($calcPRec)) { 00296 if ($table=='pages') { // If pages: 00297 $CALC_PERMS = $BE_USER->calcPerms($calcPRec); 00298 $hasAccess = $CALC_PERMS&2 ? TRUE : FALSE; 00299 } else { 00300 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid'])); // Fetching pid-record first. 00301 $hasAccess = $CALC_PERMS&16 ? TRUE : FALSE; 00302 } 00303 00304 // Check internals regarding access: 00305 if ($hasAccess) { 00306 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec); 00307 } 00308 } else $hasAccess = FALSE; 00309 00310 return $hasAccess; 00311 } 00312 } 00313 00314 // Include extension? 00315 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']) { 00316 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']); 00317 } 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 // Make instance: 00331 $SOBE = t3lib_div::makeInstance('SC_wizard_rte'); 00332 $SOBE->init(); 00333 $SOBE->main(); 00334 $SOBE->printContent(); 00335 ?>