/** * Klasa generująca przeglądarkę plików znajdujących się na serwerze. * * (c) 2008 by Marcin Wrzyciel **/ var fb = null; var FileBrowserEx = new Class({ options:{ path: "", base_path: "", // musi kończyć się slashem write_dir: "", type: "list", allowFolderSelect: false, showFoldersOnly: false, multipleSelect: false, onSelect: Class.empty(), access_rights: 0 }, initialize: function(options){ this.setOptions(options) this.dialog = new MooDialog() this.dialog.setWidth('812px') this.dialog.setHeight('544px') }, show: function(){ /* wyświetla filebrowsera wraz z całą zawartością */ this.dialog.getHandle().innerHTML = this.__headerAndFooter() var top=window.getScrollTop()+350; this.dialog.getHandle().setStyle( 'top',top+'px'); $('fb_close_btn').addEvent('click', this.hide.bind(this)) $('fb_change_view').addEvent('click', this.change_view.bind(this)) if((this.options.access_rights&2)>0){ $('fb_add_folder').addEvent('click', this.add_folder.bind(this)) $('fb_add_file').addEvent('click', this.add_file.bind(this)) } if(this.options.multipleSelect) $('fb-btn-wstaw-zaznaczone').addEvent('click', this.insert_selected.bind(this)) this.fc_iframe = new Element( 'iframe', { 'styles' :{ 'display' : 'none'}, 'src' : 'js/explorer/addFile.php?path='+this.options.base_path+this.options.path, 'frameborder': "no", 'scroling': 'no' }) //$('fb-file-folder').appendChild(this.fc_iframe); this.fc_iframe.setStyle('display', '') this.dialog.show() this.update() }, hide: function(){ this.dialog.hide() }, go: function(folder){ if(folder == ".."){ for (var pI = this.options.path.length - 1; pI >= 0; pI--) { if((this.options.path.charAt(pI) == '/') || (this.options.path.charAt(pI) == '\\')) break; } this.options.path = this.options.path.substring(0, pI); }else{ if(folder != '.') this.options.path += '/' + folder; } this.update() }, update: function(){ /* aktualizuje zawartośc filebrowsera */ url = 'js/explorer/explorer.php?path='+this.options.base_path+this.options.path; $('fb_path').innerHTML = this.options.path; o = this $('fb-file-folder').empty(); $('fb-content').empty().addClass('fex-load') new Ajax(url, { method: 'get', onSuccess: function(response){ eval("objects = ("+response+")"); o.is_writable = (o.options.base_path+o.options.path.substr(1)).indexOf(o.options.write_dir); if(0 != o.is_writable && ((this.options.access_rights&2)>0)){ $('fb_add_folder').setStyle('display', 'none'); $('fb_add_file').setStyle('display', 'none'); }else{ $('fb_add_folder').setStyle('display', ''); $('fb_add_file').setStyle('display', ''); } if(o.options.type == 'thumb'){ o._showThumb(objects) }else{ o._showList(objects) } } }).request(); }, change_view: function() { if(this.options.type == 'list') this.options.type = "thumb"; else this.options.type = "list" this.update() }, add_folder: function(){ $('fb-file-folder').innerHTML = '
' }, add_file : function(){ $('fb-file-folder').empty() $('fb-file-folder').innerHTML=''; }, uploadFile: function(){ alert('aaa'); $('btn_add_file_fire').send({onComplete:function(){this.update();}}); }, insert_selected: function(){ $$('input.mftp_chx').filterByAttribute("checked").each(function(e,i){ this.options.onSelect(e.value) }.bind(this)) this.hide() }, /** metody prywatne **/ __headerAndFooter: function(){ html = '
' +
'MENADŻER PLIKÓW
' + '' html += '' html += '
';
html +='';
if((this.options.access_rights&2)>0){
html +='
'
}
html += ' '
if((this.options.access_rights&2)>0){
html += '
'
}
html += ''
html+= '
tutaj jesteś: '+this.options.path+ '
'//'kat. główna » folder » folder » podfolder' if(this.type == 'list'){ html+= '| ' html+= ' | typ | ' html+= 'nazwa | ' //html+= 'opis | ' html+= 'rozmiar | ' html+= 'data | ' html+= 'akcja | ' html+= '
![]() | '
code_2ln+= '.. | '
last = i%5
if(last == 4) {code+= '|
![]() | '
code_2ln+= '+ ' if(this.options.multipleSelect) code_2ln+= ' ' code_2ln+= ((objects.folders[i].name.length > 15) ? objects.folders[i].name.substring(0,12)+'...' : objects.folders[i].name)+' | '
last = i%5
if(last == 4) {code+= '|
![]() | '
}else{
code+= ' + ' if(this.options.multipleSelect) code_2ln+= '' code_2ln+=((objects.files[i].name.length > 15) ? objects.files[i].name.substring(0,12)+'...':objects.files[i].name)+' | '
if(last == 4) {code+= '' code_2ln+= ' | '; } code+= ''; code_2ln+= '' code+= code_2ln; } code += " |