Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / wizard_rte.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Wizard to display the RTE in "full screen" mode
29 *
30 * $Id$
31 *
32 * @author Kasper Skaarhoj <kasper@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 79: class SC_wizard_rte
40 * 87: function init()
41 * 103: function main()
42 * 112: function jumpToUrl(URL,formEl)
43 * 203: function printContent()
44 *
45 * TOTAL FUNCTIONS: 4
46 * (This index is automatically created/updated by the extension "extdeveval")
47 *
48 */
49
50
51
52 $BACK_PATH='';
53 require ('init.php');
54 require ('template.php');
55 include ('sysext/lang/locallang_wizards.php');
56 require_once (PATH_t3lib.'class.t3lib_tceforms.php');
57 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
58 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
59
60 t3lib_BEfunc::lockRecords();
61
62
63
64
65
66
67
68
69
70
71
72 /**
73 * Script Class
74 *
75 * @author Kasper Skaarhoj <kasper@typo3.com>
76 * @package TYPO3
77 * @subpackage core
78 */
79 class SC_wizard_rte {
80 var $content;
81 var $P;
82 var $doc;
83
84 /**
85 * @return [type] ...
86 */
87 function init() {
88 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
89
90 $this->P = t3lib_div::GPvar('P',1);
91
92 $this->doc = t3lib_div::makeInstance("mediumDoc");
93 $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!!!
94 $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);" autocomplete="off">';
95 $this->doc->backPath = $BACK_PATH;
96 }
97
98 /**
99 * [Describe function...]
100 *
101 * @return [type] ...
102 */
103 function main() {
104 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
105
106 if ($this->P["table"] && $this->P["field"] && $this->P["uid"]) {
107 // Getting the raw record (we need only the pid-value from here...)
108 $rawRec = t3lib_BEfunc::getRecord($this->P["table"],$this->P["uid"]);
109
110 $this->doc->JScode = '
111 <script language="javascript" type="text/javascript">
112 function jumpToUrl(URL,formEl) {
113 if (document.editform) {
114 if (!TBE_EDITOR_isFormChanged()) {
115 document.location = URL;
116 } else if (formEl) {
117 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
118 }
119 } else document.location = URL;
120 }
121 '.(t3lib_div::GPVar("popView") ? t3lib_BEfunc::viewOnClick($rawRec["pid"],"",t3lib_BEfunc::BEgetRootLine($rawRec["pid"])) : '').'
122 </script>
123 ';
124
125 $this->content.=$this->doc->startPage("");
126
127
128 $tceforms = t3lib_div::makeInstance("t3lib_TCEforms");
129 $tceforms->initDefaultBEMode(); // Init...
130 $tceforms->disableWizards = 1; // SPECIAL: Disables all wizards - we are NOT going to need them.
131 $tceforms->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
132 $tceforms->colorScheme[0]=$this->doc->bgColor; // SPECIAL: Setting background color of the RTE to ordinary background
133
134 // Fetching content of record
135 $trData = t3lib_div::makeInstance("t3lib_transferData");
136 $trData->lockRecords=1;
137 $trData->fetchRecord($this->P["table"],$this->P["uid"],"");
138
139 // Getting the processed record content out:
140 reset($trData->regTableItems_data);
141 $rec = current($trData->regTableItems_data);
142 $rec["uid"] = $this->P["uid"];
143 $rec["pid"] = $rawRec["pid"];
144
145
146 // Making the toolbar:
147 $closeUrl = $this->P["returnUrl"];
148 // $R_URI=t3lib_div::getIndpEnv("REQUEST_URI");
149 $R_URI=t3lib_div::linkThisScript(array("popView"=>""));
150
151 $undoButton=0;
152 $undoQuery="SELECT tstamp FROM sys_history WHERE tablename='".$this->P["table"]."' AND recuid='".$this->P["uid"]."' ORDER BY tstamp DESC LIMIT 1";
153 $undoRes = mysql(TYPO3_db,$undoQuery);
154 if ($undoButtonR = mysql_fetch_assoc($undoRes)) {
155 $undoButton=1;
156 }
157
158
159 // ShortCut
160 if ($BE_USER->mayMakeShortcut()) {
161 $this->MCONF["name"]="xMOD_wizard_rte.php";
162 $sCut = $this->doc->makeShortcutIcon("P","",$this->MCONF["name"],1);
163 } else $sCut ="";
164
165 $toolBar=''.
166 // '<input type="image" border=0 name="savedok" src="gfx/savedok.gif" hspace=2 width="21" height="16"'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:rm.saveDoc"),1).' align=top>'.
167 '<a href="#" onClick="TBE_EDITOR_checkAndDoSubmit(1); return false;"><img border=0 src="gfx/savedok.gif" hspace=2 width="21" height="16"'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:rm.saveDoc"),1).' align=top></a>'.
168 (t3lib_extMgm::isLoaded("cms")?'<a href="#" onClick="document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR_checkAndDoSubmit(1); return false;"><img border=0 src="gfx/savedokshow.gif" hspace=2 width="21" height="16"'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:rm.saveDocShow"),1).' align=top></a>':'').
169 '<a href="#" onClick="jumpToUrl(unescape(\''.rawurlencode($closeUrl).'\')); return false;"><img border=0 src="gfx/closedok.gif" hspace=2 width="21" height="16"'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:rm.closeDoc"),1).' align=top></a>'.
170 ($undoButton ? '<a href="#" onClick="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;"><img border=0 src="gfx/undo.gif" hspace=2 width="21" height="16"'.t3lib_BEfunc::titleAttrib(sprintf($LANG->getLL("rte_undoLastChange"),t3lib_BEfunc::calcAge(time()-$undoButtonR["tstamp"],$LANG->sL("LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears"))),1).'" align=top></a>' : '').
171 '';
172
173 $panel = $toolBar;
174
175 $fieldTSConfig = $tceforms->setTSconfig($this->P["table"],$rec,$this->P["field"]);
176 if (strcmp($fieldTSConfig["RTEfullScreenWidth"],"")) {
177 $width=$fieldTSConfig["RTEfullScreenWidth"];
178 } else $width="500"; //$width="100%";
179
180 $formContent = $tceforms->getSoloField($this->P["table"],$rec,$this->P["field"]);
181 $formContent = '<table border=0 cellpadding=0 cellspacing=0 width="'.$width.'" height="98%">
182 <tr><td>'.$panel.'</td><td align="right">'.$sCut.'</td><td></td></tr>
183 <tr height="98%"><td width="'.$width.'" colspan=2>'.$formContent.'</td><td></td></tr>
184 </table>';
185
186 $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($R_URI).'">
187 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'">';
188
189 // debug(array($formContent));
190
191 $this->content.=$tceforms->printNeededJSFunctions_top().$formContent.$tceforms->printNeededJSFunctions();
192 } else {
193 $this->content.=$this->doc->startPage("");
194 $this->content.=$this->doc->section($LANG->getLL("forms_title"),$GLOBALS["TBE_TEMPLATE"]->rfw($LANG->getLL("table_noData")),0,1);
195 }
196 }
197
198 /**
199 * [Describe function...]
200 *
201 * @return [type] ...
202 */
203 function printContent() {
204 $this->content.=$this->doc->endPage();
205 echo $this->content;
206 }
207 }
208
209 // Include extension?
210 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']) {
211 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']);
212 }
213
214
215
216
217
218
219
220
221
222
223
224
225 // Make instance:
226 $SOBE = t3lib_div::makeInstance('SC_wizard_rte');
227 $SOBE->init();
228 $SOBE->main();
229 $SOBE->printContent();
230 ?>