filemanager 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. data/CHANGELOG +3 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +32 -0
  4. data/Rakefile +30 -0
  5. data/lib/filemanager.rb +59 -0
  6. data/lib/filemanager/controller.rb +197 -0
  7. data/lib/locale.rb +183 -0
  8. data/lib/locale/base.rb +60 -0
  9. data/lib/locale/cgi.rb +103 -0
  10. data/lib/locale/jruby.rb +36 -0
  11. data/lib/locale/object.rb +233 -0
  12. data/lib/locale/posix.rb +22 -0
  13. data/lib/locale/win32.rb +49 -0
  14. data/lib/locale/win32_table.rb +235 -0
  15. data/rails/app/controllers/fm/filemanager_controller.rb +23 -0
  16. data/rails/app/helpers/fm/filemanager_helper.rb +61 -0
  17. data/rails/app/views/fm/filemanager/index.html.erb +509 -0
  18. data/rails/app/views/fm/filemanager/view.html.erb +67 -0
  19. data/rails/config/filemanager.yml +16 -0
  20. data/rails/fm_temp/temp +0 -0
  21. data/rails/public/filemanager/images/avi.gif +0 -0
  22. data/rails/public/filemanager/images/box.gif +0 -0
  23. data/rails/public/filemanager/images/bullet.gif +0 -0
  24. data/rails/public/filemanager/images/close.gif +0 -0
  25. data/rails/public/filemanager/images/closelabel.gif +0 -0
  26. data/rails/public/filemanager/images/doc.gif +0 -0
  27. data/rails/public/filemanager/images/donate-button.gif +0 -0
  28. data/rails/public/filemanager/images/download-icon.gif +0 -0
  29. data/rails/public/filemanager/images/folder.gif +0 -0
  30. data/rails/public/filemanager/images/gif.gif +0 -0
  31. data/rails/public/filemanager/images/htm.gif +0 -0
  32. data/rails/public/filemanager/images/html.gif +0 -0
  33. data/rails/public/filemanager/images/image-1.jpg +0 -0
  34. data/rails/public/filemanager/images/image.gif +0 -0
  35. data/rails/public/filemanager/images/jpg.gif +0 -0
  36. data/rails/public/filemanager/images/loading.gif +0 -0
  37. data/rails/public/filemanager/images/mov.gif +0 -0
  38. data/rails/public/filemanager/images/nextlabel.gif +0 -0
  39. data/rails/public/filemanager/images/pdf.gif +0 -0
  40. data/rails/public/filemanager/images/png.gif +0 -0
  41. data/rails/public/filemanager/images/ppt.gif +0 -0
  42. data/rails/public/filemanager/images/prevlabel.gif +0 -0
  43. data/rails/public/filemanager/images/rar.gif +0 -0
  44. data/rails/public/filemanager/images/rm.gif +0 -0
  45. data/rails/public/filemanager/images/rmvb.gif +0 -0
  46. data/rails/public/filemanager/images/separator.gif +0 -0
  47. data/rails/public/filemanager/images/spacer.gif +0 -0
  48. data/rails/public/filemanager/images/swf.gif +0 -0
  49. data/rails/public/filemanager/images/thumb-1.jpg +0 -0
  50. data/rails/public/filemanager/images/tool_copy.gif +0 -0
  51. data/rails/public/filemanager/images/tool_cut.gif +0 -0
  52. data/rails/public/filemanager/images/tool_del.gif +0 -0
  53. data/rails/public/filemanager/images/tool_folder.gif +0 -0
  54. data/rails/public/filemanager/images/tool_imagemanager.gif +0 -0
  55. data/rails/public/filemanager/images/tool_new.gif +0 -0
  56. data/rails/public/filemanager/images/tool_paste.gif +0 -0
  57. data/rails/public/filemanager/images/tool_props.gif +0 -0
  58. data/rails/public/filemanager/images/tool_refresh.gif +0 -0
  59. data/rails/public/filemanager/images/tool_unzip.gif +0 -0
  60. data/rails/public/filemanager/images/tool_upload.gif +0 -0
  61. data/rails/public/filemanager/images/tool_zip.gif +0 -0
  62. data/rails/public/filemanager/images/txt.gif +0 -0
  63. data/rails/public/filemanager/images/unknown.gif +0 -0
  64. data/rails/public/filemanager/images/wmv.gif +0 -0
  65. data/rails/public/filemanager/images/xls.gif +0 -0
  66. data/rails/public/filemanager/images/zip.gif +0 -0
  67. data/rails/public/filemanager/javascripts/builder.js +136 -0
  68. data/rails/public/filemanager/javascripts/effects.js +1122 -0
  69. data/rails/public/filemanager/javascripts/filemanager.js +6 -0
  70. data/rails/public/filemanager/javascripts/lang/en.js +31 -0
  71. data/rails/public/filemanager/javascripts/lang/zh_CN.js +31 -0
  72. data/rails/public/filemanager/javascripts/lightbox.js +497 -0
  73. data/rails/public/filemanager/javascripts/prototype.js +4221 -0
  74. data/rails/public/filemanager/javascripts/prototype_ext.js +117 -0
  75. data/rails/public/filemanager/javascripts/scriptaculous.js +58 -0
  76. data/rails/public/filemanager/javascripts/translate.js +42 -0
  77. data/rails/public/filemanager/stylesheets/filelist.css +147 -0
  78. data/rails/public/filemanager/stylesheets/general.css +135 -0
  79. data/rails/public/filemanager/stylesheets/lightbox.css +27 -0
  80. data/rails/public/fm_resources/resources.txt +1 -0
  81. metadata +147 -0
@@ -0,0 +1,49 @@
1
+ =begin
2
+ locale/win32.rb
3
+
4
+ Copyright (C) 2002-2008 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: win32.rb,v 1.5 2008/03/21 06:28:10 mutoh Exp $
10
+ =end
11
+
12
+ require 'locale/base'
13
+ require 'locale/win32_table'
14
+ require 'dl/win32'
15
+
16
+ module Locale
17
+ # Locale::SystemWin32 module for win32.
18
+ # This is a low-level class. Application shouldn't use this directly.
19
+ module SystemWin32
20
+ extend SystemBase
21
+ include SystemWin32Table
22
+
23
+ @@default_locale = Locale::Object.new("en", nil, "CP1252")
24
+ @@win32 = Win32API.new("kernel32.dll", "GetUserDefaultLangID", nil, "i")
25
+
26
+ module_function
27
+
28
+ # Gets the Win32 charset of the locale.
29
+ # * locale: Locale::Object
30
+ # * Returns the charset of the locale
31
+ def get_charset(locale)
32
+ loc = LocaleTable.find{|v| v[1] == locale.to_win}
33
+ loc = LocaleTable.find{|v| v[1] =~ /^#{locale.language}-/} unless loc
34
+ loc ? loc[2] : "CP1252"
35
+ end
36
+
37
+ def default_locale #:nodoc:
38
+ lang = LocaleTable.assoc(@@win32.call)
39
+ if lang
40
+ ret = Locale::Object.new(lang[1], nil, lang[2])
41
+ else
42
+ ret = @@default_locale
43
+ end
44
+ ret
45
+ end
46
+ end
47
+ @@locale_system_module = SystemWin32
48
+ end
49
+
@@ -0,0 +1,235 @@
1
+ =begin
2
+ locale_table_win32.rb - Locale table for win32
3
+
4
+ Copyright (C) 2002-2008 Masao Mutoh <mutoh@highway.ne.jp>
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: win32_table.rb,v 1.4 2008/03/21 06:28:10 mutoh Exp $
10
+ =end
11
+
12
+ module Locale
13
+ module SystemWin32Table
14
+
15
+ #LangID, locale name, code page
16
+ LocaleTable = [
17
+ [0x0000, "en", "CP1252"],
18
+ [0x007f, "invariant", "CP1252"],
19
+ [0x0400, "invalid", "CP1252"],
20
+ [0x0800, "system", "CP1252"],
21
+ [0x0436, "af-ZA", "CP1252"],
22
+ [0x041c, "sq-AL", "CP1252"],
23
+ [0x0484, "gsw-FR", "CP1252"],
24
+ [0x045e, "am-ET", "UNICODE"],
25
+ [0x0401, "ar-SA", "CP1256"],
26
+ [0x0801, "ar-IQ", "CP1256"],
27
+ [0x0c01, "ar-EG", "CP1256"],
28
+ [0x1001, "ar-LY", "CP1256"],
29
+ [0x1401, "ar-DZ", "CP1256"],
30
+ [0x1801, "ar-MA", "CP1256"],
31
+ [0x1c01, "ar-TN", "CP1256"],
32
+ [0x2001, "ar-OM", "CP1256"],
33
+ [0x2401, "ar-YE", "CP1256"],
34
+ [0x2801, "ar-SY", "CP1256"],
35
+ [0x2c01, "ar-JO", "CP1256"],
36
+ [0x3001, "ar-LB", "CP1256"],
37
+ [0x3401, "ar-KW", "CP1256"],
38
+ [0x3801, "ar-AE", "CP1256"],
39
+ [0x3c01, "ar-BH", "CP1256"],
40
+ [0x4001, "ar-QA", "CP1256"],
41
+ [0x042b, "hy-AM", "UNICODE"],
42
+ [0x044d, "as-IN", "UNICODE"],
43
+ [0x042c, "az-AZ-Latn", "CP1254"],
44
+ [0x082c, "az-AZ-Cyrl", "CP1251"],
45
+ [0x046d, "ba-RU", "UNICODE"],
46
+ [0x042d, "eu-ES", "CP1252"],
47
+ [0x0423, "be-BY", "CP1251"],
48
+ [0x0445, "bn-IN", "UNICODE"],
49
+ [0x201a, "bs-BA-Cyrl", "CP1251"],
50
+ [0x141a, "bs-BA-Latn", "CP1250"],
51
+ [0x047e, "br-FR", "CP1251"],
52
+ [0x0402, "bg-BG", "CP1251"],
53
+ [0x0455, "my-MM", "UNICODE"],
54
+ [0x0403, "ca-ES", "CP1252"],
55
+ [0x0004, "zh-CHS", "CP936"],
56
+ [0x0404, "zh-TW", "CP950"],
57
+ [0x0804, "zh-CN", "CP936"],
58
+ [0x0c04, "zh-HK", "CP950"],
59
+ [0x1004, "zh-SG", "CP936"],
60
+ [0x1404, "zh-MO", "CP950"],
61
+ [0x7c04, "zh-CHT", "CP950"],
62
+ [0x0483, "co-FR", "CP1252"],
63
+ [0x041a, "hr-HR", "CP1250"],
64
+ [0x101a, "hr-BA", "CP1250"],
65
+ [0x0405, "cs-CZ", "CP1250"],
66
+ [0x0406, "da-DK", "CP1252"],
67
+ [0x048c, "gbz-AF", "CP1256"],
68
+ [0x0465, "dv-MV", "UNICODE"],
69
+ [0x0413, "nl-NL", "CP1252"],
70
+ [0x0813, "nl-BE", "CP1252"],
71
+ [0x0409, "en-US", "CP1252"],
72
+ [0x0809, "en-GB", "CP1252"],
73
+ [0x0c09, "en-AU", "CP1252"],
74
+ [0x1009, "en-CA", "CP1252"],
75
+ [0x1409, "en-NZ", "CP1252"],
76
+ [0x1809, "en-IE", "CP1252"],
77
+ [0x1c09, "en-ZA", "CP1252"],
78
+ [0x2009, "en-JA", "CP1252"],
79
+ [0x2409, "en-CB", "CP1252"],
80
+ [0x2809, "en-BZ", "CP1252"],
81
+ [0x2c09, "en-TT", "CP1252"],
82
+ [0x3009, "en-ZW", "CP1252"],
83
+ [0x3409, "en-PH", "CP1252"],
84
+ [0x4009, "en-IN", "CP1252"],
85
+ [0x4409, "en-MY", "CP1252"],
86
+ [0x4809, "en-SG", "CP1252"],
87
+ [0x0425, "et-EE", "CP1257"],
88
+ [0x0438, "fo-FO", "CP1252"],
89
+ [0x464, "fil-PH", "CP1252"],
90
+ [0x040b, "fi-FI", "CP1252"],
91
+ [0x040c, "fr-FR", "CP1252"],
92
+ [0x080c, "fr-BE", "CP1252"],
93
+ [0x0c0c, "fr-CA", "CP1252"],
94
+ [0x100c, "fr-CH", "CP1252"],
95
+ [0x140c, "fr-LU", "CP1252"],
96
+ [0x180c, "fr-MC", "CP1252"],
97
+ [0x0462, "fy-NL", "CP1252"],
98
+ [0x0456, "gl-ES", "CP1252"],
99
+ [0x0437, "ka-GE", "UNICODE"],
100
+ [0x0407, "de-DE", "CP1252"],
101
+ [0x0807, "de-CH", "CP1252"],
102
+ [0x0c07, "de-AT", "CP1252"],
103
+ [0x1007, "de-LU", "CP1252"],
104
+ [0x1407, "de-LI", "CP1252"],
105
+ [0x0408, "el-GR", "CP1253"],
106
+ [0x046f, "kl-GL", "CP1252"],
107
+ [0x0447, "gu-IN", "UNICODE"],
108
+ [0x0468, "ha-NG-Latn", "CP1252"],
109
+ [0x040d, "he-IL", "CP1255"],
110
+ [0x0439, "hi-IN", "UNICODE"],
111
+ [0x040e, "hu-HU", "CP1250"],
112
+ [0x040f, "is-IS", "CP1252"],
113
+ [0x0421, "id-ID", "CP1252"],
114
+ [0x045d, "iu-CA-Cans", "UNICODE"],
115
+ [0x085d, "iu-CA-Latn", "CP1252"],
116
+ [0x083c, "ga-IE", "CP1252"],
117
+ [0x0434, "xh-ZA", "CP1252"],
118
+ [0x0435, "zu-ZA", "CP1252"],
119
+ [0x0410, "it-IT", "CP1252"],
120
+ [0x0810, "it-CH", "CP1252"],
121
+ [0x0411, "ja-JP", "CP932"],
122
+ [0x044b, "kn-IN", "UNICODE"],
123
+ [0x043f, "kk-KZ", "CP1251"],
124
+ [0x0453, "kh-KH", "UNICODE"],
125
+ [0x0486, "qut-GT", "CP1252"],
126
+ [0x0487, "rw-RW", "CP1252"],
127
+ [0x0457, "kok-IN", "UNICODE"],
128
+ [0x0412, "ko-KR", "CP949"],
129
+ [0x0812, "ko-KR@win95", "CP949"],
130
+ [0x0440, "ky-KG", "CP1251"],
131
+ [0x0454, "lo-LA", "UNICODE"],
132
+ [0x0426, "lv-LV", "CP1257"],
133
+ [0x0427, "lt-LT", "CP1257"],
134
+ [0x0827, "lt-LT@win98", "CP1257"],
135
+ [0x082e, "wee-DE", "CP1252"],
136
+ [0x046e, "lb-LU", "CP1252"],
137
+ [0x042f, "mk-MK", "CP1251"],
138
+ [0x043e, "ms-MY", "CP1252"],
139
+ [0x083e, "ms-BN", "CP1252"],
140
+ [0x044c, "ml-IN", "UNICODE"],
141
+ [0x043a, "mt-MT", "CP1252"],
142
+ [0x0481, "mi-NZ", "CP1252"],
143
+ [0x047a, "arn-CL", "CP1252"],
144
+ [0x044e, "mr-IN", "UNICODE"],
145
+ [0x047c, "moh-CA", "CP1252"],
146
+ [0x0450, "mn-MN", "CP1251"],
147
+ [0x0850, "mn-CN", "UNICODE"],
148
+ [0x0461, "ne-NP", "UNICODE"],
149
+ [0x0414, "nb-NO", "CP1252"],
150
+ [0x0814, "nn-NO", "CP1252"],
151
+ [0x0482, "oc-FR", "CP1252"],
152
+ [0x0448, "or-IN", "UNICODE"],
153
+ [0x0463, "ps-AF", "UNICODE"],
154
+ [0x0429, "fa-IR", "CP1256"],
155
+ [0x0415, "pl-PL", "CP1250"],
156
+ [0x0416, "pt-BR", "CP1252"],
157
+ [0x0816, "pt-PT", "CP1252"],
158
+ [0x0446, "pa-IN", "UNICODE"],
159
+ [0x046b, "quz-BO", "CP1252"],
160
+ [0x086b, "quz-EC", "CP1252"],
161
+ [0x0c6b, "quz-PE", "CP1252"],
162
+ [0x0418, "ro-RO", "CP1250"],
163
+ [0x0417, "rm-CH", "CP1252"],
164
+ [0x0419, "ru-RU", "CP1251"],
165
+ [0x243b, "smn-FI", "CP1252"],
166
+ [0x103b, "smj-NO", "CP1252"],
167
+ [0x143b, "smj-SE", "CP1252"],
168
+ [0x043b, "se-NO", "CP1252"],
169
+ [0x083b, "se-SE", "CP1252"],
170
+ [0x0c3b, "se-FI", "CP1252"],
171
+ [0x203b, "sms-FI", "CP1252"],
172
+ [0x183b, "sma-NO", "CP1252"],
173
+ [0x1c3b, "sma-SE", "CP1252"],
174
+ [0x044f, "sa-IN", "UNICODE"],
175
+ [0x0c1a, "sr-SP-Cyrl", "CP1251"],
176
+ [0x1c1a, "sr-BA-Cyrl", "CP1251"],
177
+ [0x081a, "sr-SP-Latn", "CP1250"],
178
+ [0x181a, "sr-BA-Latn", "CP1250"],
179
+ [0x046c, "ns-ZA", "CP1252"],
180
+ [0x0432, "tn-ZA", "CP1252"],
181
+ [0x045b, "si-LK", "UNICODE"],
182
+ [0x041b, "sk-SK", "CP1250"],
183
+ [0x0424, "sl-SI", "CP1250"],
184
+ [0x040a, "es-ES-ts", "CP1252"],
185
+ [0x080a, "es-MX", "CP1252"],
186
+ [0x0c0a, "es-ES", "CP1252"],
187
+ [0x100a, "es-GT", "CP1252"],
188
+ [0x140a, "es-CR", "CP1252"],
189
+ [0x180a, "es-PA", "CP1252"],
190
+ [0x1c0a, "es-DO", "CP1252"],
191
+ [0x200a, "es-VE", "CP1252"],
192
+ [0x240a, "es-CO", "CP1252"],
193
+ [0x280a, "es-PE", "CP1252"],
194
+ [0x2c0a, "es-AR", "CP1252"],
195
+ [0x300a, "es-EC", "CP1252"],
196
+ [0x340a, "es-CL", "CP1252"],
197
+ [0x380a, "es-UY", "CP1252"],
198
+ [0x3c0a, "es-PY", "CP1252"],
199
+ [0x400a, "es-BO", "CP1252"],
200
+ [0x440a, "es-SV", "CP1252"],
201
+ [0x480a, "es-HN", "CP1252"],
202
+ [0x4c0a, "es-NI", "CP1252"],
203
+ [0x500a, "es-PR", "CP1252"],
204
+ [0x540a, "es-US", "CP1252"],
205
+ [0x0430, "sutu", "UNICODE"],
206
+ [0x0441, "sw-KE", "CP1252"],
207
+ [0x041d, "sv-SE", "CP1252"],
208
+ [0x081d, "sv-FI", "CP1252"],
209
+ [0x045a, "syr-SY", "UNICODE"],
210
+ [0x0428, "tg-TJ-Cyrl", "CP1251"],
211
+ [0x085f, "ber-DZ", "CP1252"],
212
+ [0x0449, "ta-IN", "UNICODE"],
213
+ [0x0444, "tt-RU", "CP1251"],
214
+ [0x044a, "te-IN", "UNICODE"],
215
+ [0x041e, "th-TH", "CP874"],
216
+ [0x0451, "bo-CN", "UNICODE"],
217
+ [0x0851, "bo-BT", "UNICODE"],
218
+ [0x041f, "tr-TR", "CP1254"],
219
+ [0x0442, "tk-TM", "CP1251"],
220
+ [0x0480, "ug-CN", "CP1256"],
221
+ [0x0422, "uk-UA", "CP1251"],
222
+ [0x042e, "wen-DE", "CP1252"],
223
+ [0x0420, "ur-PK", "CP1256"],
224
+ [0x0820, "tr-IN", "CP1256"],
225
+ [0x0443, "uz-UZ-Latn", "CP1254"],
226
+ [0x0843, "uz-UZ-Cyrl", "CP1251"],
227
+ [0x042a, "vi-VN", "CP1252"],
228
+ [0x0452, "cy-GB", "CP1252"],
229
+ [0x0488, "wo-SN", "CP1252"],
230
+ [0x0485, "sah-RU", "CP1251"],
231
+ [0x0478, "ii-CN", "UNICODE"],
232
+ [0x046a, "yo-NG", "UNICODE"],
233
+ ]
234
+ end
235
+ end
@@ -0,0 +1,23 @@
1
+ =begin
2
+ filemanager_controller.rb
3
+ Copyright (C) 2008 Leon Li
4
+
5
+ You may redistribute it and/or modify it under the same
6
+ license terms as Ruby.
7
+ =end
8
+
9
+ require 'iconv'
10
+ require 'fileutils'
11
+ require 'locale'
12
+ require 'filemanager/controller'
13
+
14
+ class Fm::FilemanagerController < ApplicationController
15
+
16
+ include Filemanager::Controller
17
+
18
+ layout false
19
+ before_filter :set_up
20
+ after_filter :tear_off
21
+ skip_before_filter :verify_authenticity_token
22
+
23
+ end
@@ -0,0 +1,61 @@
1
+ =begin
2
+ filemanager_helper.rb
3
+ Copyright (C) 2008 Leon Li
4
+
5
+ You may redistribute it and/or modify it under the same
6
+ license terms as Ruby.
7
+ =end
8
+
9
+ module Fm
10
+ module FilemanagerHelper
11
+
12
+ def get_file_type(file)
13
+ type = File.extname(file)
14
+
15
+ unless type.blank?
16
+ type = type.downcase[1..-1]
17
+ return type if FM_SUPPORT_TYPES.include?(type)
18
+ end
19
+ FM_UNKNOWN_TYPE
20
+ end
21
+
22
+ def get_file_content(path, to=FM_ENCODING_TO, from=FM_ENCODING_FROM)
23
+ if File.new(path).size > 1000000
24
+ 'File too big'
25
+ else
26
+ str = File.read(path)
27
+ to.nil? ? str : Iconv.conv(to, from, str)
28
+ end
29
+ end
30
+
31
+ def transfer(from, to, target)
32
+ if FM_ENCODING_TO.nil?
33
+ target
34
+ else
35
+ if target.is_a?(Array)
36
+ target.map{|i| to.nil? ? i : Iconv.conv(to, from, i)}
37
+ else
38
+ Iconv.conv(to, from, target)
39
+ end
40
+ end
41
+ end
42
+
43
+ def encode(target)
44
+ transfer(FM_ENCODING_FROM, FM_ENCODING_TO, target);
45
+ end
46
+
47
+ def decode(target)
48
+ transfer(FM_ENCODING_TO, FM_ENCODING_FROM, target);
49
+ end
50
+
51
+ def hsize(size)
52
+ size = size/1024
53
+ if size > 1024
54
+ size = size/1024
55
+ size = format('%0.2f',(size)) + ' mb'
56
+ else
57
+ size = format('%0.2f', size) + ' kb'
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,509 @@
1
+ <html>
2
+ <head>
3
+ <title>Filemanager</title>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
+ <script src="/filemanager/javascripts/prototype.js" type="text/javascript"></script>
6
+ <script src="/filemanager/javascripts/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
7
+ <script src="/filemanager/javascripts/lightbox.js" type="text/javascript"></script>
8
+ <script src="/filemanager/javascripts/prototype_ext.js" type="text/javascript"></script>
9
+ <script src="/filemanager/javascripts/lang/<%= Locale.current %>.js" type="text/javascript"></script>
10
+ <script src="/filemanager/javascripts/translate.js" type="text/javascript"></script>
11
+ <script src="/filemanager/javascripts/filemanager.js" type="text/javascript"></script>
12
+ <script language=javascript type=text/javascript>
13
+ var currentFile = null;
14
+ function showControl(file) {
15
+ setCssClass($('imageControl'), "hidelayer");
16
+ setCssClass($('viewControl'), "showlayer");
17
+ currentFile = file;
18
+ if(file.length > 4) {
19
+ var suffix = file.substring(file.length -3).toLowerCase();
20
+ if (suffix == 'jpg' || suffix == 'gif' || suffix == 'png') {
21
+ setCssClass($('imageControl'), "showlayer");
22
+ }
23
+ }
24
+ }
25
+ </script>
26
+ <link href="/filemanager/stylesheets/general.css" media="screen" rel="stylesheet" type="text/css" />
27
+ <link href="/filemanager/stylesheets/filelist.css" media="screen" rel="stylesheet" type="text/css" />
28
+ <link href="/filemanager/stylesheets/lightbox.css" media="screen" rel="stylesheet" type="text/css" />
29
+ <style type="text/css">
30
+ body, select, textarea, div {
31
+ margin:0;
32
+ padding:0;
33
+ font-family: "Arial";
34
+ font-size: 9pt;
35
+ line-height:1.5em;
36
+ }
37
+ input{
38
+ margin:0;
39
+ padding:0;
40
+ font-family: "Arial";
41
+ font-size:9pt;
42
+ line-height: 1.5em;
43
+ vertical-align:middle;
44
+ }
45
+
46
+
47
+ img {
48
+ border:0px;
49
+ vertical-align:middle;
50
+ }
51
+ form {
52
+ margin:0px;
53
+ padding:0px;
54
+ }
55
+ a {
56
+ color:#000000;
57
+ text-decoration: none;
58
+ }
59
+ a:hover {
60
+ color:#FF0000
61
+ }
62
+
63
+ .hidelayer {
64
+ display:none;
65
+ visibility:hidden;
66
+ }
67
+ .showlayer {
68
+ display:block;
69
+ visibility:visible;
70
+ }
71
+ .hideMenu {
72
+ position:absolute;
73
+ list-style:none;
74
+ margin:0;
75
+ padding:0;
76
+ display:none;
77
+ border:1px solid #DDDDDD;
78
+ background-color:#EEEEEE;
79
+ }
80
+ .hideMenu li{
81
+ padding:1px;
82
+ }
83
+ .hideMenu li a{
84
+ padding:3px;
85
+ display:block;
86
+ text-decoration:none;
87
+ cursor:default;
88
+ }
89
+ .hideMenu li a:link, a:visited{
90
+ color:black;
91
+ }
92
+ .hideMenu li a:hover{
93
+ color:white;
94
+ background-color:#039;
95
+ }
96
+ </style>
97
+ </head>
98
+ <body >
99
+ <div id="loading" style="display:none">Loading...</div>
100
+ <ul id='foldMenu' class="hideMenu">
101
+ <li><a href="javascript:rename()"><span fmLang="rename">Rename</span></a></li>
102
+ <li><a href="javascript:copyFile()"><span fmLang="copy">Copy</span></a></li>
103
+ <li><a href="javascript:cutFile()"><span fmLang="cut">Cut</span></a></li>
104
+ <li><a href="javascript:pasteFile()"><span fmLang="paste">Paste</span></a></li>
105
+ <li><a href="javascript:removeFile()"><span fmLang="remove">Remove</span></a></li>
106
+ <li><a href="javascript:zipDownload();"><span fmLang="download">Download</span></a></li>
107
+ </ul>
108
+ <ul id='fileMenu' class="hideMenu">
109
+ <li><a href="javascript:selectFile()"><span fmLang="selectFile">Select File</span></a></li>
110
+ <li id="unzip"><a href="javascript:unzipFile()"><span fmLang="unzipFile">Unzip File</span></a></li>
111
+ <li><a href="javascript:rename()"><span fmLang="rename">Rename</span></a></li>
112
+ <li><a href="javascript:copyFile()"><span fmLang="copy">Copy</span></a></li>
113
+ <li><a href="javascript:cutFile()"><span fmLang="cut">Cut</span></a></li>
114
+ <li><a href="javascript:removeFile()"><span fmLang="remove">Remove</span></a></li>
115
+ <li><a href="javascript:zipDownload();"><span fmLang="download">Download</span></a></li>
116
+ </ul>
117
+ <ul id='blankMenu' class="hideMenu">
118
+ <li><a href="javascript:newFolder()"><span fmLang="new_folder">New Folder</span></a></li>
119
+ <li><a href="javascript:newFile()"><span fmLang="new_file">New File</span></a></li>
120
+ <li><a href="javascript:pasteFile()"><span fmLang="paste">Paste</span></a></li>
121
+ <li><a href="javascript:;" onmouseover="setCssClass($('uploadForm'), 'showlayer');"><span fmLang="upload_file">Upload File</span></a>
122
+ <div id="uploadForm" align="right" class="hidelayer">
123
+ <form id="fileForm" method="post" enctype="multipart/form-data">
124
+ <input type="file" name="upload" class="file" />
125
+ <input type="button" fmLang="upload" value="Upload" onclick="uploadFile();"/>
126
+ </form>
127
+ </div>
128
+ </li>
129
+ </ul>
130
+ <div id=filelist>
131
+ <table cellspacing=0 cellpadding=3 width="100%" height="100%" border=0>
132
+ <tr>
133
+ <td valign="top">
134
+ <hr style="height:1px">
135
+ <form name=filelistform action=filelist.php method=post>
136
+ <table cellspacing=0 cellpadding=2 width="100%" border=0>
137
+ <tbody>
138
+ <tr height=0>
139
+ <td nowrap width=1></td>
140
+ <td nowrap width=1></td>
141
+ <td nowrap width="100%"></td>
142
+ <td nowrap width=1></td>
143
+ <td nowrap width="1%"></td>
144
+ <td id=spacercol width=0></td>
145
+ </tr>
146
+ <tr class=filelistheadrow id=filelistheadreal>
147
+ <td id=selectcol1 valign=center nowrap align=middle width=1><a onmousedown="return false;" title="toggle all" href="javascript:checkAll();"><img id=toggleall height=10 alt="toggle all" hspace=3 src="/filemanager/images/box.gif" width=10 border=0></a></td>
148
+ <td id=iconcol1 nowrap width=20><img height=1 src="/filemanager/images/spacer.gif" width=10></td>
149
+ <td class=filelistheadcol id=fnamecol1 nowrap width="100%"> <span fmLang="file_name">File Name</span> </td>
150
+ <td class=filelistheadcol id=fsizecol1 nowrap width="2%"> <span fmLang="file_size">File Size</span> </td>
151
+ <td class=filelistheadcol id=fmodcol1 nowrap width="2%" align="center"> <span fmLang="modification_date">Modification Date</span> </td>
152
+ </tr>
153
+ <%
154
+ path = encode(@path)
155
+ unless @parent_path.nil?
156
+ %>
157
+ <tr class=filelistroweven>
158
+ <td width=1></td>
159
+ <td><a onmousedown="return false;" href="#"><img class="" title=directory height=16 alt=directory src="/filemanager/images/folder.gif" width=16 border=0></a></td>
160
+ <td class=filelistfilename><a onmousedown="return false;" href="?path=<%= encode(@parent_path) %>">..</a></td>
161
+ <td nowrap></td>
162
+ <td nowrap><%= File.ctime(@resource_path + @parent_path).strftime("%Y-%m-%d %H:%M:%S") %></td>
163
+ </tr>
164
+ <%
165
+ end
166
+ unless @directories.nil?
167
+ @directories.each do |i|
168
+ next if i == '.' || i == '..'
169
+ old_i = i
170
+ i = encode(i)
171
+ %>
172
+ <tr class=filelistroweven id="tr_<%= i %>">
173
+ <td width=1><input onclick="triggerselect(this)" type="checkbox" name="fileCheck" value="<%= i %>"></td>
174
+ <td><a onmousedown="return false;" href="#"><img class="" title=directory height=16 alt=directory src="/filemanager/images/folder.gif" width=16 border=0></a></td>
175
+ <td class=filelistfilename>
176
+ <a id="context_fold_<%= i %>" onmousedown="return false;" title="<%= path + '/' + i %>" href="?path=<%= path + '/' + i %>"><%= i %></a>
177
+ </td>
178
+ <td nowrap>
179
+ </td>
180
+ <td nowrap><%= File.ctime(@current_path + '/' + old_i).strftime("%Y-%m-%d %H:%M:%S") %></td>
181
+ </tr>
182
+ <%
183
+ end
184
+ end
185
+ unless @files.nil?
186
+ @files.each do |i|
187
+ old_i = i
188
+ i = encode(i)
189
+ %>
190
+ <tr class=filelistroweven id="tr_<%= i %>">
191
+ <td width=1><input onclick="triggerselect(this)" type="checkbox" name="fileCheck" value="<%= i %>"></td>
192
+ <td><a onmousedown="return false;" name="<%= i %>"></a><a href="#"><img class="" height=16 src="/filemanager/images/<%= get_file_type(i) %>.gif" width=16 border=0></a></td>
193
+ <td class=filelistfilename>
194
+ <a id="context_file_<%= i %>" title="<%= path + '/' + i %>" href="javascript:ajaxLink('/fm/filemanager/view?path=<%= path + '/' + i %>', 'view', 'none');" onmousedown="hideMenu();" onclick="showControl('<%= path + '/' + i %>')" ><%= i %></a>
195
+ </td>
196
+ <td nowrap><%= hsize(File.size(@current_path + '/' + old_i).to_f) %></td>
197
+ <td nowrap><%= File.ctime(@current_path + '/' + old_i).strftime("%Y-%m-%d %H:%M:%S") %></td>
198
+ </tr>
199
+ <%
200
+ end
201
+ end
202
+ %>
203
+ </tbody>
204
+ </table>
205
+ </form>
206
+ </td>
207
+ <td width="300" valign="top">
208
+ <fieldset style="margin:0px">
209
+ <legend align=left><span fmLang="directory_information">Directory Information</span></legend>
210
+ <div style="margin: 2px; overflow: hidden; width: 100%">
211
+ <div class=previewsubtitle><span fmLang="directory_name">Directory Name</span></div>
212
+ <div class=previewtext><%= encode(File.basename(@current_path)) %></div>
213
+ </div>
214
+ <div style="float: left; margin: 2px; width: 45%">
215
+ <div class=previewsubtitle><span fmLang="sub_directories">Sub-directories</span>:</div>
216
+ <div class=previewtext><%= @directories.size %></div>
217
+ <div class=previewsubtitle><span fmLang="modification_date">Modification Date</span>:</div>
218
+ <div class=previewtext><%= File.ctime(@current_path).strftime("%Y-%m-%d %H:%M:%S") %></div>
219
+ </div>
220
+ <div style="float: right; margin: 2px; width: 45%">
221
+ <div class=previewsubtitle><span fmLang="files">Files</span>:</div>
222
+ <div class=previewtext><%= @files.size %></div>
223
+ <div class=previewsubtitle><span fmLang="file_total_size">File Total Size</span>:</div>
224
+ <div class=previewtext><%= hsize(@file_total_size) %></div>
225
+
226
+ </div>
227
+ <br style="clear: both">
228
+ </fieldset>
229
+
230
+ <div id="view" style="width:300px; height:300px;overflow:auto;border:1px solid #aaaaaa">
231
+ <div align="center">
232
+ <br><br>
233
+ <span fmLang="preview_area">Preview Area</span>
234
+ </div>
235
+ </div>
236
+
237
+ <div id="viewControl" align="right" class="hidelayer">
238
+
239
+ <div id="imageControl" class="hidelayer">
240
+ <!--
241
+ <form id="sizeForm" >
242
+ <span fmLang="width">Width</span>:<input type="text" name="width" value="" size="3" maxlength="4"/> * <span fmLang="height">Height</span>:<input type="text" name="height" value="" size="3" maxlength="4"/>
243
+ <br>
244
+ <input type="checkbox" name="keepRadioFlag" value="true"/><span fmLang="keep_radio">Keep Radio</span>
245
+ <input type="checkbox" name="thumbFlag" value="true"/><span fmLang="thumb">Thumb</span>
246
+ <input type="button" class="button" fmLang="submit" value="Submit" onclick="adjustSize(currentFile);"/>
247
+ </form>
248
+ <form id="rotateForm" >
249
+ <span fmLang="angle">Angle</span>:<input type="text" name="rotateNum" value="" size="4" maxlength="4"/>
250
+ <input type="button" class="button" fmLang="submit" value="Submit" onclick="rotate(currentFile);"/>
251
+ </form>
252
+ -->
253
+ </div>
254
+ <div>
255
+
256
+ <input type="button" class="button" fmLang="view" value="View" onclick="window.open('<%= @lock_path %>'+currentFile,'','')"/>
257
+ </div>
258
+ </div>
259
+ </td>
260
+ </tr>
261
+ </table>
262
+ </div>
263
+ <script language="javascript">
264
+
265
+ var foldMenu = $("foldMenu");
266
+ var fileMenu = $("fileMenu");
267
+ var blankMenu = $("blankMenu");
268
+ var selectedName = "";
269
+ var lastObject = false;
270
+ var old_name = "";
271
+ var lastMenu = false;
272
+ function hideMenu() {
273
+ if (lastMenu) {
274
+ lastMenu.style.visibility = "hidden";
275
+ lastMenu.style.display = "none";
276
+ }
277
+ setCssClass($('uploadForm'), 'hidelayer');
278
+ }
279
+ function showMenu(obj) {
280
+ obj.style.visibility = "visible";
281
+ obj.style.display = "block";
282
+ }
283
+ document.oncontextmenu = function(e){
284
+ hideMenu();
285
+ lastObject = false;
286
+ e = window.event || e;
287
+ var target = (e.target) ? e.target : e.srcElement;
288
+ var menu = false;
289
+ if (target && target.id.length > 8 && target.id.substring(0,8) == 'context_') {
290
+ old_name = target.innerHTML;
291
+ lastObject = target;
292
+ if (target.id.substring(8, 12) == 'fold') {
293
+ menu = foldMenu;
294
+ } else if (target.id.substring(8, 12) == 'file') {
295
+ var upzipStr = target.id.substring(target.id.length-3, target.id.length);
296
+ if (upzipStr == 'zip') {
297
+ $('unzip').show();
298
+ } else {
299
+ $('unzip').hide();
300
+ }
301
+ menu = fileMenu;
302
+ }
303
+ currentFile = target.title;
304
+ } else {
305
+ menu = blankMenu;
306
+ }
307
+ lastMenu = menu;
308
+ x = e.x || e.layerX;
309
+ y = e.y || e.layerY;
310
+ menu.style.left = x + "px";
311
+ menu.style.top = y + "px";
312
+ showMenu(menu) ;
313
+ return false;
314
+ }
315
+ document.onclick = function(e){
316
+ e = window.event || e;
317
+ var target = (e.target) ? e.target : e.srcElement;
318
+
319
+ if (target) {
320
+ try {
321
+ if (target.type == 'undefined' || target.type == null) {
322
+ hideMenu();
323
+ } else if (target.type == "file") {
324
+ } else {
325
+ hideMenu();
326
+ }
327
+ } catch(e1) {
328
+ hideMenu();
329
+ }
330
+ } else {
331
+ hideMenu();
332
+ }
333
+ }
334
+ var refreshLink;
335
+ function refreshPage() {
336
+ refreshLink = '/fm/filemanager?path=<%= path %>' + "&randomid=" + new Date().toJSON();
337
+ setTimeout(waitFefresh, 500);
338
+ }
339
+ function waitFefresh() {
340
+ location.href = refreshLink;
341
+ }
342
+ function gotoPage(link) {
343
+ location.href = link;
344
+ }
345
+ function updateHtml(obj, content) {
346
+ obj.innerHTML = content;
347
+ }
348
+ function rename() {
349
+ var new_name = prompt(getText("prompt_input_new_name", "Please input new name"), old_name);
350
+ if (new_name != null && new_name != "" && new_name != old_name) {
351
+ ajaxLink("/fm/filemanager/rename?path=<%= path %>&old_name=" + old_name + "&new_name=" + new_name, $("view"), null, refreshPage());
352
+ }
353
+ }
354
+ function markObject(obj) {obj.style.color='#aaaaaa';};
355
+ function unmarkObject(obj) {obj.style.color='#000000';};
356
+ function unzipFile() {
357
+ ajaxLink("/fm/filemanager/unzip?path=<%= path %>&old_name=" + old_name, $("view"), null, refreshPage());
358
+ }
359
+ function removeFile() {
360
+ if (selectedName.length == 0) {
361
+ if (confirm(getText("remove", "Remove") + ' ' + old_name)) {
362
+ ajaxLink("/fm/filemanager/remove?path=<%= path %>&source[]=" + old_name, $("view"), null, refreshPage());
363
+ }
364
+ } else {
365
+ if (confirm(getText("remove", "Remove"))) {
366
+ var nameArray = new Array();
367
+ nameArray = selectedName.split('*');
368
+ var parameter = "";
369
+ for (var i = 0; i < nameArray.length; i++) {
370
+ parameter += "&source[]=" + nameArray[i];
371
+ }
372
+ ajaxLink("/fm/filemanager/remove?path=<%= path %>" + parameter, $("view"), null, refreshPage());
373
+ }
374
+ }
375
+ }
376
+ function copyFile() {
377
+ if (selectedName.length == 0) {
378
+ ajaxLink("/fm/filemanager/copy?path=<%= path %>&source[]=" + old_name, $("view"), null);
379
+ } else {
380
+ var nameArray=new Array();
381
+ nameArray = selectedName.split('*');
382
+ var parameter = "";
383
+ for (var i = 0; i < nameArray.length; i++) {
384
+ parameter += "&source[]=" + nameArray[i];
385
+ }
386
+ ajaxLink("/fm/filemanager/copy?path=<%= path %>" + parameter, $("view"), null);
387
+ }
388
+ }
389
+ function cutFile() {
390
+ if (selectedName.length == 0) {
391
+ ajaxLink("/fm/filemanager/cut?path=<%= path %>&source[]=" + old_name, $("view"), null, markObject(lastObject));
392
+ } else {
393
+ var nameArray=new Array();
394
+ nameArray = selectedName.split('*');
395
+ var parameter = "";
396
+ for (var i = 0; i < nameArray.length; i++) {
397
+ parameter += "&source[]=" + nameArray[i];
398
+ }
399
+ ajaxLink("/fm/filemanager/cut?path=<%= path %>" + parameter, $("view"), null);
400
+ }
401
+ }
402
+ function checkAll() {
403
+ var inputs=document.getElementsByTagName("input");
404
+ if (selectedName.length != 0) {
405
+ for(var i=0;i<inputs.length;i++){
406
+ var input=inputs[i];
407
+ if("checkbox" == input.type && input.name == "fileCheck") {
408
+ input.checked = false;
409
+ }
410
+ }
411
+ selectedName = "";
412
+ } else {
413
+ for(var i=0;i<inputs.length;i++){
414
+ var input=inputs[i];
415
+ if("checkbox" == input.type && input.name == "fileCheck") {
416
+ input.checked = true;
417
+ if (selectedName.length == 0) {
418
+ selectedName = input.value;
419
+ } else {
420
+ selectedName += "*" + input.value;
421
+ }
422
+ }
423
+ }
424
+ }
425
+ }
426
+ function pasteFile() {
427
+ if (lastObject) {
428
+ if (confirm(getText("prompt_pasteTo", "Paste to") + ' ' + old_name)) {
429
+ ajaxLink("/fm/filemanager/paste?path=<%= path %>/" + old_name, $("view"), null, refreshPage());
430
+ }
431
+ } else {
432
+ if (confirm(getText("prompt_pasteToCurrent", "Paste to current"))) {
433
+ ajaxLink("/fm/filemanager/paste?path=<%= path %>", $("view"), null, refreshPage());
434
+ }
435
+ }
436
+ }
437
+ function newFile() {
438
+ var new_name = prompt(getText("prompt_input_name", "Please input name"), "");
439
+ if (new_name != null && new_name.length > 0) {
440
+ ajaxLink("/fm/filemanager/new_file?path=<%= path %>&new_name=" + new_name, $("view"), null, refreshPage());
441
+ }
442
+ }
443
+ function newFolder() {
444
+ var new_name = prompt(getText("prompt_input_name", "Please input name"), "");
445
+ if (new_name != null && new_name.length > 0) {
446
+ ajaxLink("/fm/filemanager/new_folder?path=<%= path %>&new_name=" + new_name, $("view"), null, refreshPage());
447
+ }
448
+ }
449
+ function zipDownload(){
450
+ if(confirm(getText("prompt_zip_download", "Zip and download") + ' ' + old_name))
451
+ if (selectedName.length == 0) {
452
+ window.location.href = "/fm/filemanager/download?path=<%= path %>&source[]=" + old_name;
453
+ } else {
454
+ var nameArray=new Array();
455
+ nameArray = selectedName.split('*');
456
+ var parameter = "";
457
+ for (var i = 0; i < nameArray.length; i++) {
458
+ parameter += "&source[]=" + nameArray[i];
459
+ }
460
+ window.location.href = "/fm/filemanager/download?path=<%= path %>" + parameter;
461
+ }
462
+ }
463
+ function triggerselect(obj) {
464
+ var name = "*" + obj.value;
465
+ if (selectedName.indexOf(name) == -1 && (selectedName.length < obj.value.length || selectedName.substring(0, obj.value.length) != obj.value)) {
466
+ if (obj.checked) {
467
+ if (selectedName.length == 0) {
468
+ selectedName += obj.value;
469
+ } else {
470
+ selectedName += name;
471
+ }
472
+ }
473
+ } else if (!obj.checked) {
474
+ var pos = selectedName.indexOf(obj.value);
475
+ if (pos == 0) {
476
+ if (selectedName.length > obj.value.length) {
477
+ selectedName = selectedName.substring(obj.value.length + 1);
478
+ } else {
479
+ selectedName = "";
480
+ }
481
+ } else {
482
+ if (selectedName.length > (pos + obj.value.length)) {
483
+ selectedName = selectedName.substring(0, pos-1) + selectedName.substring(pos + obj.value.length);
484
+ } else {
485
+ selectedName = selectedName.substring(0, pos-1);
486
+ }
487
+ }
488
+ }
489
+ }
490
+
491
+ function selectFile() {
492
+ if (opener) {
493
+ opener.fileBrowserReturn('<%= @lock_path %>' + currentFile);
494
+ window.close();
495
+ }
496
+ }
497
+ function uploadFile() {
498
+ $("fileForm").action = "/fm/filemanager/upload?path=<%= path %>";
499
+ $("fileForm").submit();
500
+ }
501
+ function adjustSize(file) {
502
+ ajaxPost("/fm/filemanager/adjust_size?path=" + file, $("sizeForm"), $("view"), null, refreshPage());
503
+ }
504
+ function rotate(file) {
505
+ ajaxPost("/fm/filemanager/rotate?path=" + file, $("rotateForm"), $("view"), null, refreshPage());
506
+ }
507
+ </script>
508
+ </body>
509
+ </html>