|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (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 ***************************************************************/ 00027 /** 00028 * Wizard to display the RTE in "full screen" mode 00029 * 00030 * $Id: wizard_rte.php 10295 2011-01-25 09:33:06Z baschny $ 00031 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj 00032 * XHTML compliant 00033 * 00034 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00035 */ 00036 /** 00037 * [CLASS/FUNCTION INDEX of SCRIPT] 00038 * 00039 * 00040 * 00041 * 81: class SC_wizard_rte 00042 * 99: function init() 00043 * 123: function main() 00044 * 285: function printContent() 00045 * 298: function checkEditAccess($table,$uid) 00046 * 00047 * TOTAL FUNCTIONS: 4 00048 * (This index is automatically created/updated by the extension "extdeveval") 00049 * 00050 */ 00051 00052 00053 00054 $BACK_PATH=''; 00055 require ('init.php'); 00056 require ('template.php'); 00057 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml'); 00058 00059 t3lib_BEfunc::lockRecords(); 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 /** 00072 * Script Class for rendering the full screen RTE display 00073 * 00074 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00075 * @package TYPO3 00076 * @subpackage core 00077 */ 00078 class SC_wizard_rte { 00079 00080 // Internal, dynamic: 00081 /** 00082 * document template object 00083 * 00084 * @var mediumDoc 00085 */ 00086 var $doc; 00087 var $content; // Content accumulation for the module. 00088 00089 // Internal, static: GPvars 00090 var $P; // Wizard parameters, coming from TCEforms linking to the wizard. 00091 var $popView; // If set, launch a new window with the current records pid. 00092 var $R_URI; // Set to the URL of this script including variables which is needed to re-display the form. See main() 00093 00094 00095 00096 00097 /** 00098 * Initialization of the class 00099 * 00100 * @return void 00101 */ 00102 function init() { 00103 // Setting GPvars: 00104 $this->P = t3lib_div::_GP('P'); 00105 $this->popView = t3lib_div::_GP('popView'); 00106 $this->R_URI = t3lib_div::linkThisScript(array('popView' => '')); 00107 00108 // "Module name": 00109 $this->MCONF['name']='xMOD_wizard_rte.php'; 00110 00111 // Starting the document template object: 00112 $this->doc = t3lib_div::makeInstance('template'); 00113 $this->doc->backPath = $GLOBALS['BACK_PATH']; 00114 $this->doc->setModuleTemplate('templates/wizard_rte.html'); 00115 $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!!! 00116 $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);">'; 00117 } 00118 00119 /** 00120 * Main function, rendering the document with the iframe with the RTE in. 00121 * 00122 * @return void 00123 */ 00124 function main() { 00125 global $BE_USER,$LANG; 00126 00127 // translate id to the workspace version: 00128 if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->P['table'], $this->P['uid'], 'uid')) { 00129 $this->P['uid'] = $versionRec['uid']; 00130 } 00131 00132 // If all parameters are available: 00133 if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'],$this->P['uid'])) { 00134 00135 // Getting the raw record (we need only the pid-value from here...) 00136 $rawRec = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']); 00137 t3lib_BEfunc::fixVersioningPid($this->P['table'], $rawRec); 00138 00139 // Setting JavaScript, including the pid value for viewing: 00140 $this->doc->JScode = $this->doc->wrapScriptTags(' 00141 function jumpToUrl(URL,formEl) { // 00142 if (document.editform) { 00143 if (!TBE_EDITOR.isFormChanged()) { 00144 window.location.href = URL; 00145 } else if (formEl) { 00146 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1; 00147 } 00148 } else window.location.href = URL; 00149 } 00150 '.($this->popView ? t3lib_BEfunc::viewOnClick($rawRec['pid'],'',t3lib_BEfunc::BEgetRootLine($rawRec['pid'])) : '').' 00151 '); 00152 00153 // Initialize TCeforms - for rendering the field: 00154 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms'); 00155 $tceforms->initDefaultBEMode(); // Init... 00156 $tceforms->disableWizards = 1; // SPECIAL: Disables all wizards - we are NOT going to need them. 00157 $tceforms->colorScheme[0]=$this->doc->bgColor; // SPECIAL: Setting background color of the RTE to ordinary background 00158 00159 // Initialize style for RTE object: 00160 $RTEobj = t3lib_BEfunc::RTEgetObj(); // Getting reference to the RTE object used to render the field! 00161 if ($RTEobj->ID == 'rte') { 00162 $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 00163 } 00164 00165 // Fetching content of record: 00166 $trData = t3lib_div::makeInstance('t3lib_transferData'); 00167 $trData->lockRecords=1; 00168 $trData->fetchRecord($this->P['table'],$this->P['uid'],''); 00169 00170 // Getting the processed record content out: 00171 reset($trData->regTableItems_data); 00172 $rec = current($trData->regTableItems_data); 00173 $rec['uid'] = $this->P['uid']; 00174 $rec['pid'] = $rawRec['pid']; 00175 00176 // TSconfig, setting width: 00177 $fieldTSConfig = $tceforms->setTSconfig($this->P['table'],$rec,$this->P['field']); 00178 if (strcmp($fieldTSConfig['RTEfullScreenWidth'],'')) { 00179 $width=$fieldTSConfig['RTEfullScreenWidth']; 00180 } else { 00181 $width='100%'; 00182 } 00183 00184 // Get the form field and wrap it in the table with the buttons: 00185 $formContent = $tceforms->getSoloField($this->P['table'],$rec,$this->P['field']); 00186 $formContent = ' 00187 00188 00189 <!-- 00190 RTE wizard: 00191 --> 00192 <table border="0" cellpadding="0" cellspacing="0" width="'.$width.'" id="typo3-rtewizard"> 00193 <tr> 00194 <td width="'.$width.'" colspan="2" id="c-formContent">'.$formContent.'</td> 00195 <td></td> 00196 </tr> 00197 </table>'; 00198 00199 // Adding hidden fields: 00200 $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($this->R_URI).'" /> 00201 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />' . 00202 t3lib_TCEforms::getHiddenTokenField('tceAction'); 00203 00204 00205 // Finally, add the whole setup: 00206 $this->content.= 00207 $tceforms->printNeededJSFunctions_top(). 00208 $formContent. 00209 $tceforms->printNeededJSFunctions(); 00210 } else { 00211 // ERROR: 00212 $this->content.=$this->doc->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1); 00213 } 00214 00215 // Setting up the buttons and markers for docheader 00216 $docHeaderButtons = $this->getButtons(); 00217 $markers['CONTENT'] = $this->content; 00218 00219 // Build the <body> for the module 00220 $this->content = $this->doc->startPage(''); 00221 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); 00222 $this->content.= $this->doc->endPage(); 00223 $this->content = $this->doc->insertStylesAndJS($this->content); 00224 00225 } 00226 00227 /** 00228 * Outputting the accumulated content to screen 00229 * 00230 * @return void 00231 */ 00232 function printContent() { 00233 $this->content.= $this->doc->endPage(); 00234 $this->content = $this->doc->insertStylesAndJS($this->content); 00235 echo $this->content; 00236 } 00237 00238 /** 00239 * Create the panel of buttons for submitting the form or otherwise perform operations. 00240 * 00241 * @return array all available buttons as an assoc. array 00242 */ 00243 protected function getButtons() { 00244 $buttons = array( 00245 'close' => '', 00246 'save' => '', 00247 'save_view' => '', 00248 'save_close' => '', 00249 'shortcut' => '', 00250 'undo' => '', 00251 ); 00252 00253 if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'],$this->P['uid'])) { 00254 $closeUrl = t3lib_div::sanitizeLocalUrl($this->P['returnUrl']); 00255 00256 // Getting settings for the undo button: 00257 $undoButton = 0; 00258 $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'); 00259 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) { 00260 $undoButton = 1; 00261 } 00262 00263 // Close 00264 $buttons['close'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(unescape(\'' . rawurlencode($closeUrl) . '\')); return false;') . '">' . 00265 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/closedok.gif') . ' class="c-inputButton" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', 1) . '" alt="" />' . 00266 '</a>'; 00267 00268 // Save 00269 $buttons['save'] = '<a href="#" onclick="TBE_EDITOR.checkAndDoSubmit(1); return false;">' . 00270 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/savedok.gif') . ' class="c-inputButton" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" alt="" />' . 00271 '</a>'; 00272 00273 // Save & View 00274 if (t3lib_extMgm::isLoaded('cms')) { 00275 $buttons['save_view'] = '<a href="#" onclick="' . htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;') . '">' . 00276 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/savedokshow.gif') . ' class="c-inputButton" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow', 1) . '" alt="" />' . 00277 '</a>'; 00278 } 00279 00280 // Save & Close 00281 $buttons['save_close'] = '<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="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', 1) . '" />'; 00282 00283 // Undo/Revert: 00284 if ($undoButton) { 00285 $buttons['undo'] = '<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($this->R_URI) . '\'; return false;') . '">' . 00286 '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/undo.gif') . ' class="c-inputButton" title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('rte_undoLastChange'), t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp'], $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '" alt="" />' . 00287 '</a>'; 00288 } 00289 00290 // Shortcut 00291 if ($GLOBALS['BE_USER']->mayMakeShortcut()) { 00292 $buttons['shortcut'] = $this->doc->makeShortcutIcon('P', '', $this->MCONF['name'], 1); 00293 } 00294 } 00295 00296 return $buttons; 00297 } 00298 00299 /** 00300 * Checks access for element 00301 * 00302 * @param string Table name 00303 * @param integer Record uid 00304 * @return void 00305 */ 00306 function checkEditAccess($table,$uid) { 00307 global $BE_USER; 00308 00309 $calcPRec = t3lib_BEfunc::getRecord($table,$uid); 00310 t3lib_BEfunc::fixVersioningPid($table,$calcPRec); 00311 if (is_array($calcPRec)) { 00312 if ($table=='pages') { // If pages: 00313 $CALC_PERMS = $BE_USER->calcPerms($calcPRec); 00314 $hasAccess = $CALC_PERMS&2 ? TRUE : FALSE; 00315 } else { 00316 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid'])); // Fetching pid-record first. 00317 $hasAccess = $CALC_PERMS&16 ? TRUE : FALSE; 00318 } 00319 00320 // Check internals regarding access: 00321 if ($hasAccess) { 00322 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec); 00323 } 00324 } else $hasAccess = FALSE; 00325 00326 return $hasAccess; 00327 } 00328 } 00329 00330 00331 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php'])) { 00332 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']); 00333 } 00334 00335 00336 00337 // Make instance: 00338 $SOBE = t3lib_div::makeInstance('SC_wizard_rte'); 00339 $SOBE->init(); 00340 $SOBE->main(); 00341 $SOBE->printContent(); 00342 00343 ?>
1.8.0