b477e6818482c3dfa8f276cdde9bdde4ea02ec1a
[Packages/TYPO3.CMS.git] / typo3 / js / backend.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2007-2011 Ingo Renner <ingo@typo3.org>
5 * All rights reserved
6 *
7 * This script is part of the TYPO3 project. The TYPO3 project is
8 * free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The GNU General Public License can be found at
14 * http://www.gnu.org/copyleft/gpl.html.
15 * A copy is found in the textfile GPL.txt and important notices to the license
16 * from the author is found in LICENSE.txt distributed with these scripts.
17 *
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * general backend javascript functions
29 */
30
31 Ext.ns('TYPO3.configuration');
32
33 /**
34 * jump the backend to a module
35 */
36 function jump(url, modName, mainModName) {
37 // clear information about which entry in nav. tree that might have been highlighted.
38 top.fsMod.navFrameHighlightedID = [];
39 top.fsMod.recentIds['web'] = -1;
40
41 if (top.TYPO3.Backend.NavigationContainer.PageTree) {
42 top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
43 }
44
45 top.nextLoadModuleUrl = url;
46 top.TYPO3.ModuleMenu.App.showModule(modName);
47
48 }
49
50 /**
51 * shortcut manager to delegate the action of creating shortcuts to the new
52 * backend.php shortcut menu or the old shortcut frame depending on what is available
53 */
54 var ShortcutManager = {
55
56 /**
57 * central entry point to create a shortcut, delegates the call to correct endpoint
58 */
59 createShortcut: function(confirmQuestion, backPath, moduleName, url) {
60 if(confirm(confirmQuestion)) {
61 if (typeof TYPO3BackendShortcutMenu !== undefined) {
62 // backend.php
63 TYPO3BackendShortcutMenu.createShortcut('', moduleName, url);
64 }
65 }
66 }
67 }
68
69
70 /**
71 * Function similar to PHPs rawurlencode();
72 */
73 function rawurlencode(str) {
74 var output = escape(str);
75 output = str_replace("*","%2A", output);
76 output = str_replace("+","%2B", output);
77 output = str_replace("/","%2F", output);
78 output = str_replace("@","%40", output);
79 return output;
80 }
81
82 /**
83 * Function to similar to PHPs rawurlencode() which removes TYPO3_SITE_URL;
84 */
85 function rawurlencodeAndRemoveSiteUrl(str) { //
86 var siteUrl = TYPO3.configuration.siteUrl;
87 return rawurlencode(str_replace(siteUrl, "", str));
88 }
89
90 /**
91 * String-replace function
92 */
93 function str_replace(match,replace,string) { //
94 var input = ""+string;
95 var matchStr = ""+match;
96 if (!matchStr) {return string;}
97 var output = "";
98 var pointer=0;
99 var pos = input.indexOf(matchStr);
100 while (pos !== -1) {
101 output+=""+input.substr(pointer, pos-pointer)+replace;
102 pointer=pos+matchStr.length;
103 pos = input.indexOf(match,pos+1);
104 }
105 output+=""+input.substr(pointer);
106 return output;
107 }
108
109
110
111 /**
112 * Launcing information window for records/files (fileref as "table" argument)
113 */
114 function launchView(table,uid,bP) { //
115 var backPath= bP ? bP : "";
116 var thePreviewWindow="";
117 thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=400,width=550,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
118 if (thePreviewWindow && thePreviewWindow.focus) {
119 thePreviewWindow.focus();
120 }
121 }
122
123 /**
124 * Opens plain window with url
125 */
126 function openUrlInWindow(url,windowName) { //
127 regularWindow = window.open(
128 url,
129 windowName,
130 "status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
131 regularWindow.focus();
132 return false;
133 }
134
135 /**
136 * Loads a page id for editing in the page edit module:
137 */
138 function loadEditId(id,addGetVars) { //
139 top.fsMod.recentIds.web = id;
140 top.fsMod.navFrameHighlightedID.web = "pages" + id + "_0"; // For highlighting
141
142 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
143 top.content.nav_frame.refresh_nav();
144 }
145 if (TYPO3.configuration.pageModule) {
146 top.goToModule(TYPO3.configuration.pageModule, 0, addGetVars?addGetVars:"");
147 }
148 }
149
150 /**
151 * Returns incoming URL (to a module) unless nextLoadModuleUrl is set. If that is the case nextLoadModuleUrl is returned (and cleared)
152 * Used by the shortcut frame to set a "intermediate URL"
153 */
154 var nextLoadModuleUrl="";
155 function getModuleUrl(inUrl) { //
156 var nMU;
157 if (top.nextLoadModuleUrl) {
158 nMU=top.nextLoadModuleUrl;
159 top.nextLoadModuleUrl="";
160 return nMU;
161 } else {
162 return inUrl;
163 }
164 }
165
166 /**
167 * Print properties of an object
168 */
169 function debugObj(obj,name) { //
170 var acc;
171 for (var i in obj) {
172 if (obj[i]) {
173 acc+=i+": "+obj[i]+"\n";
174 }
175 }
176 alert("Object: "+name+"\n\n"+acc);
177 }
178
179
180
181 // Used by Frameset Modules
182 var condensedMode = TYPO3.configuration.condensedMode;
183 var currentSubScript = "";
184 var currentSubNavScript = "";
185
186 // Used for tab-panels:
187 var DTM_currentTabs = [];
188
189 // status of WS FE preview
190 var WorkspaceFrontendPreviewEnabled = TYPO3.configuration.workspaceFrontendPreviewEnabled;