* Fixed bug #6961: Errors in link creation popup window
[Packages/TYPO3.CMS.git] / typo3 / alt_doc_ajax.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2006 Oliver Hader <oh@inpublica.de>
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 * Main form rendering script for AJAX calls only.
29 *
30 * $Id$
31 *
32 * @author Oliver Hader <oh@inpublica.de>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 65: class SC_alt_doc_ajax
40 * 75: function init()
41 * 118: function main()
42 * 145: function printContent()
43 *
44 * TOTAL FUNCTIONS: 3
45 * (This index is automatically created/updated by the extension "extdeveval")
46 *
47 */
48
49
50
51 require('init.php');
52 require('template.php');
53 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml');
54 require_once (PATH_t3lib.'class.t3lib_tceforms.php');
55 // @TODO: Do we really need this here?
56 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
57
58 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
59 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
60 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
61
62
63 t3lib_BEfunc::lockRecords();
64
65
66
67 class SC_alt_doc_ajax {
68 var $content; // Content accumulation
69 var $retUrl; // Return URL script, processed. This contains the script (if any) that we should RETURN TO from the alt_doc.php script IF we press the close button. Thus this variable is normally passed along from the calling script so we can properly return if needed.
70 var $R_URL_parts; // Contains the parts of the REQUEST_URI (current url). By parts we mean the result of resolving REQUEST_URI (current url) by the parse_url() function. The result is an array where eg. "path" is the script path and "query" is the parameters...
71 var $R_URL_getvars; // Contains the current GET vars array; More specifically this array is the foundation for creating the R_URI internal var (which becomes the "url of this script" to which we submit the forms etc.)
72 var $R_URI; // Set to the URL of this script including variables which is needed to re-display the form. See main()
73
74 /**
75 * instance of TCEforms class
76 *
77 * @var t3lib_TCEforms
78 */
79 var $tceforms;
80 var $localizationMode; // GP var, localization mode for TCEforms (eg. "text")
81 var $ajax = array(); // the AJAX paramerts from get/post
82
83 var $doc; // Document template object
84
85 function init() {
86 global $BE_USER;
87
88 // get AJAX parameters
89 $this->ajax = t3lib_div::_GP('ajax');
90
91 // MENU-ITEMS:
92 // If array, then it's a selector box menu
93 // If empty string it's just a variable, that'll be saved.
94 // Values NOT in this array will not be saved in the settings-array for the module.
95 // @TODO: showPalettes etc. should be stored on client side and submitted via each ajax call
96 $this->MOD_MENU = array(
97 'showPalettes' => '',
98 'showDescriptions' => '',
99 'disableRTE' => ''
100 );
101 // Setting virtual document name
102 $this->MCONF['name']='xMOD_alt_doc.php';
103 // CLEANSE SETTINGS
104 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
105
106 // Create an instance of the document template object
107 $this->doc = t3lib_div::makeInstance('template');
108 $this->doc->backPath = $GLOBALS['BACK_PATH'];
109 $this->doc->docType = 'xhtml_trans';
110
111 // Initialize TCEforms (rendering the forms)
112 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
113 $this->tceforms->initDefaultBEMode();
114 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
115 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
116 $this->tceforms->enableClickMenu = TRUE;
117 $this->tceforms->enableTabMenu = TRUE;
118
119 // Clipboard is initialized:
120 $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
121 $this->tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
122
123 // Setting external variables:
124 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text';
125 }
126
127 /**
128 * The main function for the AJAX call.
129 * Checks if the requested function call is valid and forwards the request to t3lib_TCEforms_inline.
130 * The out is written to $this->content
131 *
132 * @return void
133 */
134 function main() {
135 header('Expires: Fri, 27 Nov 1981 09:04:00 GMT');
136 header('Last-Modified: '.gmdate("D, d M Y H:i:s").' GMT');
137 header('Cache-Control: no-cache, must-revalidate');
138 header('Pragma: no-cache');
139 header('Content-type: text/javascript; charset=utf-8');
140
141 $this->content = '';
142
143 if (is_array($this->ajax) && count($this->ajax)) {
144 // the first argument is the method that should handle the AJAX call
145 $method = array_shift($this->ajax);
146
147 // Security check
148 if (!in_array($method, array('createNewRecord', 'setExpandedCollapsedState'))) {
149 return false;
150 }
151
152 // Perform the requested action:
153 $this->tceforms->inline->initForAJAX($method, $this->ajax);
154 $this->content = call_user_func_array(
155 array(&$this->tceforms->inline, $method),
156 $this->ajax
157 );
158 }
159 }
160
161 /**
162 * Performs the output of $this->content.
163 *
164 * @return void
165 */
166 function printContent() {
167 echo $this->content;
168 }
169 }
170
171 // Include extension?
172 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc_ajax.php']) {
173 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc_ajax.php']);
174 }
175
176
177
178
179
180
181 // Make instance:
182 $SOBE = t3lib_div::makeInstance('SC_alt_doc_ajax');
183
184 // Main:
185 $SOBE->init();
186 $SOBE->main();
187 $SOBE->printContent();
188
189 ?>