2 /***************************************************************
5 * (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Wizard to display the RTE in "full screen" mode
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
41 * 81: class SC_wizard_rte
43 * 123: function main()
44 * 285: function printContent()
45 * 298: function checkEditAccess($table,$uid)
48 * (This index is automatically created/updated by the extension "extdeveval")
56 require ('template.php');
57 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
58 require_once (PATH_t3lib
.'class.t3lib_tceforms.php');
59 require_once (PATH_t3lib
.'class.t3lib_loaddbgroup.php');
60 require_once (PATH_t3lib
.'class.t3lib_transferdata.php');
62 t3lib_BEfunc
::lockRecords();
75 * Script Class for rendering the full screen RTE display
77 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
85 * document template object
90 var $content; // Content accumulation for the module.
92 // Internal, static: GPvars
93 var $P; // Wizard parameters, coming from TCEforms linking to the wizard.
94 var $popView; // If set, launch a new window with the current records pid.
100 * Initialization of the class
106 $this->P
= t3lib_div
::_GP('P');
107 $this->popView
= t3lib_div
::_GP('popView');
110 $this->MCONF
['name']='xMOD_wizard_rte.php';
112 // Starting the document template object:
113 $this->doc
= t3lib_div
::makeInstance('template');
114 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
115 $this->doc
->setModuleTemplate('templates/wizard_rte.html');
116 $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!!!
117 $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);">';
121 * Main function, rendering the document with the iframe with the RTE in.
126 global $BE_USER,$LANG;
128 // translate id to the workspace version:
129 if ($versionRec = t3lib_BEfunc
::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace
, $this->P
['table'], $this->P
['uid'], 'uid')) {
130 $this->P
['uid'] = $versionRec['uid'];
133 // If all parameters are available:
134 if ($this->P
['table'] && $this->P
['field'] && $this->P
['uid'] && $this->checkEditAccess($this->P
['table'],$this->P
['uid'])) {
136 // Getting the raw record (we need only the pid-value from here...)
137 $rawRec = t3lib_BEfunc
::getRecord($this->P
['table'],$this->P
['uid']);
138 t3lib_BEfunc
::fixVersioningPid($this->P
['table'], $rawRec);
140 // Setting JavaScript, including the pid value for viewing:
141 $this->doc
->JScode
= $this->doc
->wrapScriptTags('
142 function jumpToUrl(URL,formEl) { //
143 if (document.editform) {
144 if (!TBE_EDITOR.isFormChanged()) {
145 window.location.href = URL;
147 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
149 } else window.location.href = URL;
151 '.($this->popView ? t3lib_BEfunc
::viewOnClick($rawRec['pid'],'',t3lib_BEfunc
::BEgetRootLine($rawRec['pid'])) : '').'
154 // Initialize TCeforms - for rendering the field:
155 $tceforms = t3lib_div
::makeInstance('t3lib_TCEforms');
156 $tceforms->initDefaultBEMode(); // Init...
157 $tceforms->disableWizards
= 1; // SPECIAL: Disables all wizards - we are NOT going to need them.
158 $tceforms->colorScheme
[0]=$this->doc
->bgColor
; // SPECIAL: Setting background color of the RTE to ordinary background
160 // Initialize style for RTE object:
161 $RTEobj = &t3lib_BEfunc
::RTEgetObj(); // Getting reference to the RTE object used to render the field!
162 if ($RTEobj->ID
== 'rte') {
163 $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
166 // Fetching content of record:
167 $trData = t3lib_div
::makeInstance('t3lib_transferData');
168 $trData->lockRecords
=1;
169 $trData->fetchRecord($this->P
['table'],$this->P
['uid'],'');
171 // Getting the processed record content out:
172 reset($trData->regTableItems_data
);
173 $rec = current($trData->regTableItems_data
);
174 $rec['uid'] = $this->P
['uid'];
175 $rec['pid'] = $rawRec['pid'];
177 // TSconfig, setting width:
178 $fieldTSConfig = $tceforms->setTSconfig($this->P
['table'],$rec,$this->P
['field']);
179 if (strcmp($fieldTSConfig['RTEfullScreenWidth'],'')) {
180 $width=$fieldTSConfig['RTEfullScreenWidth'];
185 // Get the form field and wrap it in the table with the buttons:
186 $formContent = $tceforms->getSoloField($this->P
['table'],$rec,$this->P
['field']);
193 <table border="0" cellpadding="0" cellspacing="0" width="'.$width.'" id="typo3-rtewizard">
195 <td width="'.$width.'" colspan="2" id="c-formContent">'.$formContent.'</td>
200 // Adding hidden fields:
201 $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($R_URI).'" />
202 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
205 // Finally, add the whole setup:
207 $tceforms->printNeededJSFunctions_top().
209 $tceforms->printNeededJSFunctions();
212 $this->content
.=$this->doc
->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1);
215 // Setting up the buttons and markers for docheader
216 $docHeaderButtons = $this->getButtons();
217 $markers['CONTENT'] = $this->content
;
219 // Build the <body> for the module
220 $this->content
= $this->doc
->startPage('');
221 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
222 $this->content
.= $this->doc
->endPage();
223 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
228 * Outputting the accumulated content to screen
232 function printContent() {
233 $this->content
.= $this->doc
->endPage();
234 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
239 * Create the panel of buttons for submitting the form or otherwise perform operations.
241 * @return array all available buttons as an assoc. array
243 protected function getButtons() {
253 if ($this->P
['table'] && $this->P
['field'] && $this->P
['uid'] && $this->checkEditAccess($this->P
['table'],$this->P
['uid'])) {
254 $closeUrl = $this->P
['returnUrl'];
255 $R_URI=t3lib_div
::linkThisScript(array('popView' => ''));
257 // Getting settings for the undo button:
259 $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');
260 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
265 $buttons['close'] = '<a href="#" onclick="' . htmlspecialchars('jumpToUrl(unescape(\'' . rawurlencode($closeUrl) . '\')); return false;') . '">' .
266 '<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="" />' .
270 $buttons['save'] = '<a href="#" onclick="TBE_EDITOR.checkAndDoSubmit(1); return false;">' .
271 '<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="" />' .
275 if (t3lib_extMgm
::isLoaded('cms')) {
276 $buttons['save_view'] = '<a href="#" onclick="' . htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;') . '">' .
277 '<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="" />' .
282 $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) . '" />';
286 $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($R_URI) . '\'; return false;') . '">' .
287 '<img' . t3lib_iconWorks
::skinImg($this->doc
->backPath
, 'gfx/undo.gif') . ' class="c-inputButton" title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('rte_undoLastChange'), t3lib_BEfunc
::calcAge(time() - $undoButtonR['tstamp'], $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '" alt="" />' .
292 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
293 $buttons['shortcut'] = $this->doc
->makeShortcutIcon('P', '', $this->MCONF
['name'], 1);
301 * Checks access for element
303 * @param string Table name
304 * @param integer Record uid
307 function checkEditAccess($table,$uid) {
310 $calcPRec = t3lib_BEfunc
::getRecord($table,$uid);
311 t3lib_BEfunc
::fixVersioningPid($table,$calcPRec);
312 if (is_array($calcPRec)) {
313 if ($table=='pages') { // If pages:
314 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
315 $hasAccess = $CALC_PERMS&2 ? TRUE
: FALSE
;
317 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc
::getRecord('pages',$calcPRec['pid'])); // Fetching pid-record first.
318 $hasAccess = $CALC_PERMS&16 ? TRUE
: FALSE
;
321 // Check internals regarding access:
323 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
325 } else $hasAccess = FALSE
;
332 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/wizard_rte.php']) {
333 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/wizard_rte.php']);
339 $SOBE = t3lib_div
::makeInstance('SC_wizard_rte');
342 $SOBE->printContent();