1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!--
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
5 *
6 * == BEGIN LICENSE ==
7 *
8 * Licensed under the terms of any of the following licenses at your
9 * choice:
10 *
11 *  - GNU General Public License Version 2 or later (the "GPL")
12 *    http://www.gnu.org/licenses/gpl.html
13 *
14 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15 *    http://www.gnu.org/licenses/lgpl.html
16 *
17 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18 *    http://www.mozilla.org/MPL/MPL-1.1.html
19 *
20 * == END LICENSE ==
21 *
22 * Page used to upload new files in the current folder.
23-->
24<html>
25	<head>
26		<title>File Upload</title>
27		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
28		<link href="browser.css" type="text/css" rel="stylesheet" >
29		<script type="text/javascript" src="js/common.js"></script>
30		<script type="text/javascript" src="js/language.js"></script>
31		<script type="text/javascript" src="js/safeFN_class.js"></script>
32		<script type="text/javascript">
33
34/* requires safe_ascii */
35
36var CurrentDWikiUser = parent.CurrentDWikiUser;
37var isLocalDwikiBrowser = parent.isLocalDwikiBrowser;
38var CreateDwikiFolder = parent.CreateDwikiFolder;
39var DwikiFNencode = parent.DwikiFNencode;
40
41function SetCurrentFolder( resourceType, folderPath )
42{
43	var sUrl = oConnector.ConnectorUrl + 'Command=FileUpload' ;
44	sUrl += '&Type=' + resourceType ;
45  	sUrl += '&CurrentFolder=' + dwikiUTF8_encodeFN(folderPath,DwikiFNencode) ;
46//	sUrl += '&CurrentFolder=' + encodeURIComponent( folderPath ) ;
47
48	document.getElementById('frmUpload').action = sUrl ;
49}
50
51function OnSubmit()
52{
53	if ( document.getElementById('NewFile').value.length == 0 )
54	{
55                alert(translateItem('FileBrowserError_File_Submit','Please select a file from your computer'));
56
57		return false ;
58	}
59
60
61	// Set the interface elements.
62    var progress_msg = translateItem('DlgFileBrowserUpPrg','Upload a new file in this folder (Upload in progress, please wait...)');
63	document.getElementById('eUploadMessage').innerHTML = progress_msg ;
64	document.getElementById('btnUpload').disabled = true ;
65
66	return true ;
67}
68
69function OnUploadCompleted( errorNumber, data )
70{
71	// Reset the Upload Worker Frame.
72	window.parent.frames['frmUploadWorker'].location = 'javascript:void(0)' ;
73// alert('completed: ' + data + "\nerr=" + errorNumber);
74	// Reset the upload form (On IE we must do a little trick to avoid problems).
75	if ( document.all )
76		document.getElementById('NewFile').outerHTML = '<input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file">' ;
77	else
78		document.getElementById('frmUpload').reset() ;
79
80	// Reset the interface elements.
81    if(!errorNumber) {
82        var upload_msg = translateItem('DlgFileBrowserUpMsg','Upload a new file in this folder (Upload in progress, please wait...)');
83	document.getElementById('eUploadMessage').innerHTML = upload_msg ;
84    }
85    else document.getElementById('eUploadMessage').innerHTML = ""; ;
86	document.getElementById('btnUpload').disabled = false ;
87
88	switch ( errorNumber )
89	{
90		case 0 :
91			window.parent.frames['frmResourcesList'].Refresh() ;
92			break ;
93		case 1 :	// Custom error.
94			alert( data ) ;
95			break ;
96		case 201 :
97			window.parent.frames['frmResourcesList'].Refresh() ;
98                        var file_rename = translateItem('FileBrowserError_201','A file with the same name is already available. The uploaded file has been renamed to: ');
99                        alert(file_rename + data);
100			break ;
101		case 202 :
102                        alert(translateItem('FileBrowserError_202', 'Invalid file'));
103			break ;
104                case 203:
105                       alert(translateItem('FileBrowserError_203','You do not have permission to upload files to this folder. If you think this is incorrect please notify your administrator.'));
106                       break;
107         case 301:
108         case 302:
109         case 303:
110         case 304:
111         case 306:
112         case 307:
113         case 308:
114                 var uploadError = 'FileBrowserError_' + errorNumber;
115                 alert(translateItem(uploadError,data));
116                break;
117		default :
118
119                        var default_err = translateItem('FileBrowserError_default', 'Error on file upload. Error number: ');
120                        alert(default_err + errorNumber);
121			break ;
122	}
123}
124
125window.onload = function()
126{
127    window.top.IsLoadedUpload = true ;
128    setupLanguage();
129
130    if(CurrentDWikiUser == 'visitor' || isLocalDwikiBrowser || !CurrentDWikiUser) {
131       document.getElementById('btnUpload').disabled = true ;
132       document.getElementById('btnUpload_div').innerHTML = "";
133       document.getElementById("frmUpload").style.display="none";
134    }
135
136    if(CreateDwikiFolder == 'n') {
137           document.getElementById('folder_hints').style.display='none';
138    }
139
140   if(navigator.userAgent.match(/macintosh/i)) {
141       document.getElementById('is_mac').innerHTML = 'Cmd';
142   }
143
144}
145		</script>
146	</head>
147	<body>
148		<form id="frmUpload" action="" target="frmUploadWorker" method="post" enctype="multipart/form-data" onsubmit="return OnSubmit();">
149			<table class="fullHeight" cellspacing="0" cellpadding="0" width="100%" border="0">
150				<tr>
151					<td nowrap="nowrap">
152						<span id="eUploadMessage" fckLang="DlgFileBrowserUpMsg">upload a new file in this folder</span><br>
153						<table cellspacing="0" cellpadding="0" width="100%" border="0">
154							<tr>
155								<td width="100%"><input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file"></td>
156								<td nowrap="nowrap" id="buttonUpL_td"><div id="btnUpload_div">&nbsp;<input id="btnUpload" type="submit" fckLang="DlgLnkUpload" value="upload"></div></td>
157							</tr>
158						</table>
159					</td>
160<td align='right'>
161<div id ='folder_hints'>
162<table>
163<tr>
164<td rowspan='3'>
165<span fckLang="DlgFileBrowserMove">Move</span><br />
166<span id='is_mac'>Ctrl</span>+<img alt="trash" src="images/trash.png">&nbsp;
167</td>
168</tr>
169
170<tr>
171<td align='right'>
172<img height="16" alt="" src="images/FolderOpenedRO.gif" width="15"><span fckLang="DlgFileBrowserRead">read-only</span>
173</td>
174</tr>
175
176<tr>
177<td align='right'>
178&nbsp;&nbsp;&nbsp;<img height="16" alt="" src="images/FolderOpened.gif" width="16"><span fckLang="DlgFileBrowserWrite">uploadable</span>
179</td>
180</tr>
181</table>
182</div>
183
184				</tr>
185			</table>
186		</form>
187	</body>
188</html>
189