Initial revision
[Packages/TYPO3.CMS.git] / typo3 / wizard_rte.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (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 * @author Kasper Skårhøj <kasper@typo3.com>
31 * @package TYPO3
32 * @subpackage core
33 *
34 */
35
36
37
38 $BACK_PATH="";
39 require ("init.php");
40 require ("template.php");
41 include ("sysext/lang/locallang_wizards.php");
42 require_once (PATH_t3lib."class.t3lib_tceforms.php");
43 require_once (PATH_t3lib."class.t3lib_loaddbgroup.php");
44 require_once (PATH_t3lib."class.t3lib_transferdata.php");
45
46 t3lib_BEfunc::lockRecords();
47
48
49 // ***************************
50 // Script Classes
51 // ***************************
52 class SC_wizard_rte {
53 var $content;
54 var $P;
55 var $doc;
56
57 function init() {
58 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
59
60 $this->P = t3lib_div::GPvar("P",1);
61
62 $this->doc = t3lib_div::makeInstance("mediumDoc");
63 $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!!!
64 $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">';
65 $this->doc->backPath = $BACK_PATH;
66 }
67 function main() {
68 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
69
70 if ($this->P["table"] && $this->P["field"] && $this->P["uid"]) {
71 // Getting the raw record (we need only the pid-value from here...)
72 $rawRec = t3lib_BEfunc::getRecord($this->P["table"],$this->P["uid"]);
73
74 $this->doc->JScode = '
75 <script language="javascript" type="text/javascript">
76 function jumpToUrl(URL,formEl) {
77 if (document.editform) {
78 if (!TBE_EDITOR_isFormChanged()) {
79 document.location = URL;
80 } else if (formEl) {
81 if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
82 }
83 } else document.location = URL;
84 }
85 '.(t3lib_div::GPVar("popView") ? t3lib_BEfunc::viewOnClick($rawRec["pid"],"",t3lib_BEfunc::BEgetRootLine($rawRec["pid"])) : '').'
86 </script>
87 ';
88
89 $this->content.=$this->doc->startPage("");
90
91
92 $tceforms = t3lib_div::makeInstance("t3lib_TCEforms");
93 $tceforms->initDefaultBEMode(); // Init...
94 $tceforms->disableWizards = 1; // SPECIAL: Disables all wizards - we are NOT going to need them.
95 $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
96 $tceforms->colorScheme[0]=$this->doc->bgColor; // SPECIAL: Setting background color of the RTE to ordinary background
97
98 // Fetching content of record
99 $trData = t3lib_div::makeInstance("t3lib_transferData");
100 $trData->lockRecords=1;
101 $trData->fetchRecord($this->P["table"],$this->P["uid"],"");
102
103 // Getting the processed record content out:
104 reset($trData->regTableItems_data);
105 $rec = current($trData->regTableItems_data);
106 $rec["uid"] = $this->P["uid"];
107 $rec["pid"] = $rawRec["pid"];
108
109
110 // Making the toolbar:
111 $closeUrl = $this->P["returnUrl"];
112 // $R_URI=t3lib_div::getIndpEnv("REQUEST_URI");
113 $R_URI=t3lib_div::linkThisScript(array("popView"=>""));
114
115 $undoButton=0;
116 $undoQuery="SELECT tstamp FROM sys_history WHERE tablename='".$this->P["table"]."' AND recuid='".$this->P["uid"]."' ORDER BY tstamp DESC LIMIT 1";
117 $undoRes = mysql(TYPO3_db,$undoQuery);
118 if ($undoButtonR = mysql_fetch_assoc($undoRes)) {
119 $undoButton=1;
120 }
121
122
123 // ShortCut
124 if ($BE_USER->mayMakeShortcut()) {
125 $this->MCONF["name"]="xMOD_wizard_rte.php";
126 $sCut = $this->doc->makeShortcutIcon("P","",$this->MCONF["name"],1);
127 } else $sCut ="";
128
129 $toolBar=''.
130 // '<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>'.
131 '<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>'.
132 (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>':'').
133 '<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>'.
134 ($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>' : '').
135 '';
136
137 $panel = $toolBar;
138
139 $fieldTSConfig = $tceforms->setTSconfig($this->P["table"],$rec,$this->P["field"]);
140 if (strcmp($fieldTSConfig["RTEfullScreenWidth"],"")) {
141 $width=$fieldTSConfig["RTEfullScreenWidth"];
142 } else $width="500"; //$width="100%";
143
144 $formContent = $tceforms->getSoloField($this->P["table"],$rec,$this->P["field"]);
145 $formContent = '<table border=0 cellpadding=0 cellspacing=0 width="'.$width.'" height="98%">
146 <tr><td>'.$panel.'</td><td align="right">'.$sCut.'</td><td></td></tr>
147 <tr height="98%"><td width="'.$width.'" colspan=2>'.$formContent.'</td><td></td></tr>
148 </table>';
149
150 $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($R_URI).'">
151 <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'">';
152
153 // debug(array($formContent));
154
155 $this->content.=$tceforms->printNeededJSFunctions_top().$formContent.$tceforms->printNeededJSFunctions();
156 } else {
157 $this->content.=$this->doc->startPage("");
158 $this->content.=$this->doc->section($LANG->getLL("forms_title"),$GLOBALS["TBE_TEMPLATE"]->rfw($LANG->getLL("table_noData")),0,1);
159 }
160 }
161 function printContent() {
162 global $SOBE;
163 $this->content.=$this->doc->endPage();
164 echo $this->content;
165 }
166 }
167
168 // Include extension?
169 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/wizard_rte.php"]) {
170 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/wizard_rte.php"]);
171 }
172
173
174
175
176
177
178
179
180
181
182
183
184 // Make instance:
185 $SOBE = t3lib_div::makeInstance("SC_wizard_rte");
186 $SOBE->init();
187 $SOBE->main();
188 $SOBE->printContent();
189 ?>