Index: openacs-4/packages/ajax-filestorage-ui/ajax-filestorage-ui.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/ajax-filestorage-ui.info,v diff -u -r1.4 -r1.5 --- openacs-4/packages/ajax-filestorage-ui/ajax-filestorage-ui.info 14 Nov 2007 04:19:52 -0000 1.4 +++ openacs-4/packages/ajax-filestorage-ui/ajax-filestorage-ui.info 26 Nov 2007 12:52:42 -0000 1.5 @@ -6,15 +6,15 @@ Ajax File Storage UIs f f - ajaxfs2 + ajaxfs - + Hamilton Chua - 2006-06-01 + 2007-11-25 Solutiongrove - 0 + 1 - + @@ -24,7 +24,6 @@ - Index: openacs-4/packages/ajax-filestorage-ui/catalog/ajax-filestorage-ui.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/catalog/ajax-filestorage-ui.en_US.ISO-8859-1.xml,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/catalog/ajax-filestorage-ui.en_US.ISO-8859-1.xml 14 Nov 2007 04:19:53 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/catalog/ajax-filestorage-ui.en_US.ISO-8859-1.xml 26 Nov 2007 12:52:43 -0000 1.3 @@ -1,5 +1,5 @@ - + Alert Browse @@ -12,6 +12,7 @@ Confirm Are you sure you want to delete Copy the highlighted text to your clipboard. + Copy Link Sorry, there was an error trying to create your new folder. Create URL failed, please try again later. Sorry, there was an error trying to delete this item. @@ -24,6 +25,7 @@ An error occurred Sorry, we encountered an error rendering the tree panel An error occurred. Your changes have been reverted + File File List File to upload This folder contains @@ -34,7 +36,7 @@ Multiple Files Sorry, you do not have permission to rename this folder OK - One moment. This may take a while depending on how large your upload is. + One moment. <br>This may take a while depending on how large your upload is. Permission Denied Properties Your session has expired. You need to login again. <br>You will be redirected to a login page shortly Index: openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.adp 14 Nov 2007 04:19:53 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.adp 26 Nov 2007 12:52:43 -0000 1.3 @@ -1,27 +1,24 @@ - + - + + - - - + + + + - - - - - - + - - -
\ No newline at end of file + \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.tcl 14 Nov 2007 04:19:53 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/lib/ajaxfs-include.tcl 26 Nov 2007 12:52:43 -0000 1.3 @@ -11,46 +11,85 @@ # - gray # - vista -if { [exists_and_not_null theme] } { +if { ![exists_and_not_null theme] } { set theme "gray" } -set compressjs [parameter::get -package_id [ajaxfs::get_package_id] -parameter "compressjs" -default 0] set debug [parameter::get -package_id [ajaxfs::get_package_id] -parameter "debug" -default 1] - -set user_id [ad_conn user_id] set create_url_p [parameter::get -package_id $package_id -parameter "EnableCreateUrl" -default 1] +set multi_file_upload_p [parameter::get -package_id $package_id -parameter "EnableMultiUpload" -default 1] +set max_file_size [parameter::get -package_id $package_id -parameter "MaximumFileSize" -default 2000000] +set user_id [ad_conn user_id] -if { [exists_and_not_null root_folder_id] } { - if { ![db_0or1row "get_folder_name" "select name as instance_name from fs_folders where folder_id = :root_folder_id"] } { - ad_return_complaint 1 "Root folder does not exist." - ad_script_abort +# ** autosuggest *** +set tree_id [parameter::get -package_id [ajaxfs::get_package_id] -parameter "CategoryTreeId"] +if { [exists_and_not_null tree_id] } { + set locale [ad_conn locale] + set sql_query "select t.name, t.name + from categories c, category_translations t + where c.category_id = t.category_id + and c.tree_id = $tree_id + and t.locale = 'en_US' + order by lower(t.name) + " + set suggestion_list [db_list_of_lists get_array_list $sql_query] + set suggestion_formatted_list {} + foreach suggestion $suggestion_list { + lappend suggestion_formatted_list "\[\"[lindex $suggestion 0]\",\"[lindex $suggestion 1]\"\]" } - set package_id [ajaxfs::get_root_folder -folder_id $root_folder_id] + append suggestions_stub [join $suggestion_formatted_list ","] +} else { + set suggetsions_stub "" } +# ******************** if { [exists_and_not_null package_id] } { - append options "package_id:$package_id" - append options ",package_url:\"[apm_package_url_from_id $package_id]\"" - if { [exists_and_not_null root_folder_id] } { - append options ",rootfolder:$root_folder_id" + + set options [list] + + # get the root folder + set rootfolder_id [fs_get_root_folder -package_id $package_id] + set instance_name [db_string "get_folder_name" "select name as instance_name from fs_folders where folder_id = :rootfolder_id"] + set roottext [db_string "get_folder_name" "select name from fs_folders where folder_id = :rootfolder_id"] + + set write_p [permission::permission_p -no_cache \ + -party_id [ad_conn user_id] \ + -object_id ${rootfolder_id} \ + -privilege "write"] + if { $write_p } { set rootwrite_p "t" } else { set rootwrite_p "f" } + + lappend options "treerootnode:{text:\"$roottext\", id:\"$rootfolder_id\",\"attributes\":{\"write_p\":\"$rootwrite_p\"}}" + + lappend options "package_id:$package_id" + lappend options "package_url:\"[apm_package_url_from_id $package_id]\"" + lappend options "xmlhttpurl:\"[ajaxfs::get_url]\xmlhttp/\"" + + lappend options "rootfolder:$rootfolder_id" + lappend options "rootfoldername:\"$instance_name\"" + + if { [exists_and_not_null folder_id] && $folder_id != $rootfolder_id } { + lappend options "initOpenFolder:$folder_id" + lappend options "pathToFolder: new Array([ajaxfs::generate_path -folder_id $folder_id])" } - if { [exists_and_not_null folder_id] } { - append options ",initOpenFolder:$folder_id" - append options ",pathToFolder: new Array([ajaxfs::generate_path -folder_id $folder_id])" - } + if { [exists_and_not_null public] } { - append options ",ispublic:$public" + lappend options "ispublic:$public" } + if { [exists_and_not_null layoutdiv] } { - append options ",layoutdiv:\"$layoutdiv\"" - } else { - set layoutdiv "fscontainer" + lappend options "layoutdiv:\"$layoutdiv\"" } - set max_file_size [parameter::get -package_id $package_id -parameter "MaximumFileSize"] - append options ",max_file_size:\"$max_file_size\"" - append options ",user_id:\"$user_id\"" + + lappend options "max_file_size:\"$max_file_size\"" + lappend options "create_url:$create_url_p" + lappend options "multi_file_upload:$multi_file_upload_p" + lappend options "user_id:\"$user_id\"" + + set options [join $options ","] + } else { + ad_return_complaint 1 "Package id is required." ad_script_abort + } \ No newline at end of file Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/lib/folder-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/lib/folder.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/lib/folder.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/tcl/ajax-filestorage-ui-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/tcl/ajax-filestorage-ui-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/tcl/ajax-filestorage-ui-procs.tcl 8 Sep 2007 14:32:51 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/tcl/ajax-filestorage-ui-procs.tcl 26 Nov 2007 12:52:43 -0000 1.3 @@ -90,7 +90,7 @@ -folder_id:required } { - Generates a comma separated list of folder_id's that start from the root folder to the give folder_id + Generates a comma separated list of folder_id's that start from the root folder to the given folder_id @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2007-07-07 Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/index-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.6 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/index.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.5 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/index.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/doc/index.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/doc/index.html,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/www/doc/index.html 14 Nov 2007 04:19:53 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/www/doc/index.html 26 Nov 2007 12:52:43 -0000 1.3 @@ -12,9 +12,16 @@

Ajax File Storage User Interface

Hamilton G. Chua (ham@solutiongrove.com)
- October 2007
- v0.81d

+ November 2007
+ v1.0 Beta

What's New :

+

v1.0 Beta

+

v0.81d

  • context menu adds links to file properties and permissions @@ -47,5 +54,6 @@ <div style="clear:both"></div> <p>@notification_chunk;noquote@</p> + Index: openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs-min.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs-min.js,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs-min.js 14 Nov 2007 04:19:54 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs-min.js 26 Nov 2007 12:52:43 -0000 1.3 @@ -1,1066 +1,955 @@ -function readCookie(_1){ -var ca=document.cookie.split(";"); -var _3=_1+"="; -for(var i=0;iYou will be redirected to a login page shortly"); +var _5=""; +if(this.currentfolder!=null){ +var _5="?folder_id="+this.currentfolder; +} +window.location="/register/?return_url="+this.config.package_url+_5; +} +},asyncExpand:function(x){ +var _7=this.layout.findById("treepanel"); +var _8=_7.getNodeById(this.config.initOpenFolder); +if(!_8){ +var x=x+1; +var _9=this.config.pathToFolder[x]; +var _a=_7.getNodeById(_9); +_a.on("expand",asyncExpand.createDelegate(this,[x]),this,{single:true}); +_a.expand(true); }else{ -var _a=""; +_8.select(); +_8.fireEvent("click",_8); } -document.cookie=_6+"="+_7+_a+"; path=/"; +},selectInitFolder:function(){ +var _b=this.layout.findById("treepanel"); +if(this.config.initOpenFolder){ +var _c=_b.getNodeById(this.config.initOpenFolder); +if(_c){ +_c.expand(); +_c.fireEvent("click",_c); +}else{ +var x=1; +var _e=_b.getNodeById(this.config.pathToFolder[x]); +_e.on("expand",this.asyncExpand.createDelegate(this,[x]),this,{single:true}); +_e.expand(true); } -function readQs(q){ -var _c=window.location.search.substring(1); -var _d=_c.split("&"); -for(var i=0;i<_d.length;i++){ -var _f=_d[i].indexOf("="); -if(_f>0){ -var key=_d[i].substring(0,_f); -var val=_d[i].substring(_f+1); -if(key==q){ -return val; +}else{ +_b.fireEvent("click",_b.getRootNode()); } +},initLayout:function(){ +var _f=[this.createLeft(),this.createRight()]; +if(this.config!=null&&this.config.layoutdiv){ +this.layout=new Ext.Panel({id:"fs-ui",layout:"border",applyTo:this.config.layoutdiv,tbar:this.createToolbar(),items:_f}); +}else{ +this.layout=new Ext.Viewport({id:"fs-ui",layout:"border",tbar:this.createToolbar(),items:_f}); } +},createToolbar:function(){ +var _10=this.config.treerootnode; +var _11=[]; +if(_10.attributes["write_p"]=="t"){ +var _11=[" ",{text:acs_lang_text.newfolder||"New Folder",tooltip:acs_lang_text.newfolder||"New Folder",icon:"/resources/ajaxhelper/icons/folder_add.png",cls:"x-btn-text-icon",handler:this.addFolder.createDelegate(this)},{text:acs_lang_text.uploadfile||"Upload Files",tooltip:acs_lang_text.uploadfile||"Upload Files",icon:"/resources/ajaxhelper/icons/page_add.png",cls:"x-btn-text-icon",handler:this.addFile.createDelegate(this)}]; +if(this.create_url_p){ +_11.push({text:acs_lang_text.createurl||"Create Url",tooltip:acs_lang_text.createurl||"Create Url",icon:"/resources/ajaxhelper/icons/page_link.png",cls:"x-btn-text-icon",handler:this.addUrl.createDelegate(this)}); } -return null; +_11.push({text:acs_lang_text.deletefs||"Delete",tooltip:acs_lang_text.deletefs||"Delete",icon:"/resources/ajaxhelper/icons/delete.png",cls:"x-btn-text-icon",handler:this.delItem.createDelegate(this)}); +_11.push("->"); } -function checkFlashVersion(){ -var x; -var _13; -if(navigator.plugins&&navigator.mimeTypes.length){ -x=navigator.plugins["Shockwave Flash"]; -if(x&&x.description){ -x=x.description; +_11.push({tooltip:"This may take a few minutes if you have a lot of files",text:acs_lang_text.download_archive||"Download Archive",icon:"/resources/ajaxhelper/icons/arrow_down.png",cls:"x-btn-text-icon",handler:this.downloadArchive.createDelegate(this,[_10.id],false)}); +return _11; +},createLeft:function(){ +var _12=new Ext.Panel({id:"leftpanel",region:"west",collapsible:true,titlebar:true,title:" ",layout:"accordion",split:true,width:300,items:[this.createTreePanel(),this.createTagPanel()]}); +return _12; +},createTreePanel:function(){ +var _13=new Ext.tree.AsyncTreeNode({text:this.config.treerootnode.text,draggable:false,id:this.config.treerootnode.id,singeClickExpand:true,expanded:true,attributes:this.config.treerootnode.attributes}); +var _14=new Ext.tree.TreeLoader({dataUrl:this.xmlhttpurl+"load-treenodes",baseParams:{package_id:this.config.package_id}}); +var _15=new Ext.tree.TreePanel({id:"treepanel",title:"Folders",autoScroll:true,animate:true,enableDrag:false,enableDrop:true,loadMask:true,loader:_14,root:_13,ddAppendOnly:true,containerScroll:true,dropConfig:{dropAllowed:true,ddGroup:"fileDD",onNodeOver:function(_16,_17,e,_19){ +if(_16.node.id==_16.node.ownerTree.getSelectionModel().getSelectedNode().id){ +return false; } -}else{ -if(Ext.isIE){ -try{ -x=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); -x=x.GetVariable("$version"); +if(_17.dragData.selections){ +for(var x=0;x<_17.dragData.selections.length;x++){ +if(_16.node.id==_17.dragData.selections[x].data.id){ +return false; } -catch(e){ } } +return true; +},onNodeDrop:function(_1b,_1c,e,_1e){ +var _1f=this.layout.findById("filepanel"); +var _20=_1b.node.id; +var _21=[]; +for(var x=0;x<_1e.selections.length;x++){ +_21[x]=_1e.selections[x].data.id; } -pluginVersion=(typeof (x)=="string")?parseInt(x.match(/\d+/)[0]):0; -return pluginVersion; +var _23=acs_lang_text.an_error_occurred||"An error occurred"; +var _24=acs_lang_text.reverted||"Your changes have been reverted"; +var _25=function(_26){ +var _27=Ext.decode(_26.responseText); +if(_27.success){ +var dm=_1f.store; +var _29=_1f.getSelectionModel().getSelections(); +var _2a=false; +for(var x=0;x<_29.length;x++){ +dm.remove(_29[x]); +if(_29[x].data.type=="folder"){ +_2a=true; +if(_1b.node.ownerTree.getNodeById(_29[x].data.id)){ +var _2c=_1b.node.ownerTree.getNodeById(_29[x].data.id).parentNode; +_2c.loaded=false; +_2c.removeChild(_1b.node.ownerTree.getNodeById(_29[x].data.id)); } -function isURL(_14){ -if(_14.indexOf(" ")!=-1){ -return false; +} +} +if(_2a){ +var _2d=_1b.node.ownerTree.getRootNode(); +if(_2d.id==_1b.node.id){ +_2d.fireEvent("click",_2d); +} +_1b.node.loaded=false; +_1b.node.expand(); +} }else{ -if(_14.indexOf("http://")==-1){ -return false; +Ext.Msg.alert(acs_lang_text.error||"Error",_23+"
    "+_24); +} +}; +Ext.Ajax.request({url:this.xmlhttpurl+"move-fsitem",success:_25,failure:function(){ +Ext.Msg.alert(acs_lang_text.error||"Error",_23+"
    "+_24); +},params:{folder_target_id:_20,file_ids:_21}}); +return true; +}.createDelegate(this)}}); +this.enableTreeFolderRename(_15); +_13.on("expand",this.selectInitFolder,this,{single:true}); +_15.on("click",this.loadFoldercontents,this); +return _15; +},enableTreeFolderRename:function(_2e){ +this.te=new Ext.tree.TreeEditor(_2e,{allowBlank:false,blankText:acs_lang_text.folder_name_required||"A folder name is required",editDelay:20,ignoreNoChange:true}); +this.te.on("beforestartedit",function(_2f,el,_31){ +if(_2f.editNode.attributes.attributes.write_p=="t"){ +return true; }else{ -if(_14=="http://"){ +Ext.Msg.alert(acs_lang_text.permission_denied||"Permission Denied",acs_lang_text.permission_denied||"Sorry, you do not have permission to rename this folder"); return false; -}else{ -if(_14.indexOf("http://")>0){ +} +},this,true); +this.te.on("beforecomplete",function(_32,_33,_34){ +var _35=_32.editNode.parentNode; +if(_35){ +var _36=_35.childNodes; +for(x=0;x<_36.length;x++){ +if(_36[x].text==_33&&_36[x].id!=_32.editNode.id){ +Ext.Msg.alert(acs_lang_text.duplicate_name||"Duplicate Name",acs_lang_text.duplicate_name_error||"Please enter a different name. The name you entered is already being used."); return false; } } } +return true; +},this,true); +this.te.on("complete",function(_37,_38,_39){ +var _3a=acs_lang_text.an_error_occurred||"An error occurred"; +var _3b=acs_lang_text.reverted||"Your changes have been reverted"; +Ext.Ajax.request({url:this.xmlhttpurl+"rename-fsitem",success:function(_3c){ +var _3d=Ext.decode(_3c.responseText); +if(!_3d.success){ +Ext.Msg.alert(acs_lang_text.error||"Error",_3a+":

    "+_3d.error+"

    "+_3b); +_37.editNode.setText(_39); } -_14=_14.substring(7,_14.length); -if(_14.indexOf(".")==-1){ -return false; +},failure:function(){ +Ext.Msg.alert(acs_lang_text.error||"Error",_3a+"
    "+_3b); +_37.editNode.setText(_39); +},params:{newname:_38,object_id:_37.editNode.id,type:"folder"}}); +},this,true); +},createTagPanel:function(){ +var _3e=new Ext.Panel({id:"tagcloudpanel",title:"Tags",frame:false,loadMask:true,autoLoad:{url:this.xmlhttpurl+"get-tagcloud",params:{package_id:this.config.package_id}}}); +var _3f=function(){ +var _40=this; +var _41=_40.currenttag; +_3e.body.on("click",function(obj,el){ +if(el.tagName=="A"){ +if(_41!=null){ +Ext.get(_41).setStyle("font-weight","normal"); +} +Ext.get(el).setStyle("font-weight","bold"); +_41=el.id; +this.loadTaggedFiles(el.id); +} +},this); +}; +_3e.on("render",_3f,this); +return _3e; +},loadTaggedFiles:function(_44){ +this.layout.findById("treepanel").getSelectionModel().clearSelections(); +var id=_44.substring(3,_44.length); +this.layout.findById("filepanel").store.baseParams["tag_id"]=id; +this.layout.findById("filepanel").store.load(); +this.layout.findById("filepanel").store.baseParams["tag_id"]=""; +},createRight:function(){ +var _46=[{header:"",width:30,sortable:true,dataIndex:"icon"},{header:acs_lang_text.filename||"Filename",id:"filename",sortable:true,dataIndex:"title"},{header:acs_lang_text.size||"Size",sortable:true,dataIndex:"size"},{header:acs_lang_text.lastmodified||"Last Modified",sortable:true,dataIndex:"lastmodified"}]; +var _47=new Ext.data.JsonReader({totalProperty:"total",root:"foldercontents",id:"id"},[{name:"id",type:"int"},{name:"icon"},{name:"title"},{name:"filename"},{name:"type"},{name:"tags"},{name:"url"},{name:"write_p"},{name:"size"},{name:"lastmodified"}]); +var _48=new Ext.data.HttpProxy({url:this.xmlhttpurl+"get-foldercontents"}); +var _49=new Ext.grid.ColumnModel(_46); +var _4a=new Ext.data.Store({proxy:_48,reader:_47,remoteSort:true}); +var _4b=new Ext.grid.GridPanel({store:_4a,cm:_49,id:"filepanel",ddGroup:"fileDD",region:"center",split:true,autoScroll:true,autoExpandColumn:"filename",collapsible:true,enableDragDrop:true,width:250,loadMask:true,frame:false,viewConfig:{forceFit:false,enableRowBody:true,showPreview:true,getRowClass:function(_4c,_4d,p,ds){ +var xf=Ext.util.Format; +if(_4c.data.tags!=""){ +p.body="
    Tags: "+xf.ellipsis(xf.stripTags(_4c.data.tags),200)+"
    "; }else{ -if(_14.indexOf(".")==0){ -return false; +p.body="
    "; +} +return "x-grid3-row-expanded"; +}}}); +_4b.on("rowdblclick",this.openItem,this,true); +_4b.on("rowcontextmenu",this.showRowContext,this,true); +return _4b; +},showRowContext:function(_51,i,e){ +e.stopEvent(); +var dm=_51.store; +var _55=dm.getAt(i); +var _56=_55.get("type"); +var _57=_55.get("id"); +if(_56=="folder"){ +var _58="Open"; }else{ -if(_14.charAt(_14.length-1)=="."){ -return false; +var _58="Download"; } +this.contextmenu=new Ext.menu.Menu({id:"rightclickmenu",items:[new Ext.menu.Item({text:_58,icon:"/resources/ajaxhelper/icons/page_white.png",handler:this.openItem.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:"Tag",icon:"/resources/ajaxhelper/icons/tag_blue.png",handler:this.tagFsitem.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:"Views",icon:"/resources/ajaxhelper/icons/camera.png",handler:this.redirectViews.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:acs_lang_text.deletefs||"Delete",icon:"/resources/ajaxhelper/icons/delete.png",handler:this.delItem.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:acs_lang_text.rename||"Rename",icon:"/resources/ajaxhelper/icons/page_edit.png",handler:this.renameItem.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:acs_lang_text.linkaddress||"Copy Link Address",icon:"/resources/ajaxhelper/icons/page_copy.png",handler:this.copyLink.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:acs_lang_text.permissions||"Permissions",icon:"/resources/ajaxhelper/icons/group_key.png",handler:this.redirectPerms.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:acs_lang_text.properties||"Properties",icon:"/resources/ajaxhelper/icons/page_edit.png",handler:this.redirectProperties.createDelegate(this,[_51,i,e],false)}),new Ext.menu.Item({text:acs_lang_text.download_archive||"Download archive",icon:"/resources/ajaxhelper/icons/arrow_down.png",handler:this.downloadArchive.createDelegate(this,[_57],false)})]}); +if(_51.getSelectionModel().getCount()>1){ +this.contextmenu.items.items[0].hide(); +this.contextmenu.items.items[1].hide(); +this.contextmenu.items.items[2].hide(); +this.contextmenu.items.items[3].show(); +this.contextmenu.items.items[4].hide(); +this.contextmenu.items.items[5].hide(); +this.contextmenu.items.items[6].hide(); +this.contextmenu.items.items[7].hide(); +this.contextmenu.items.items[8].hide(); +}else{ +this.contextmenu.items.items[0].show(); +this.contextmenu.items.items[2].show(); +this.contextmenu.items.items[3].show(); +this.contextmenu.items.items[4].show(); +this.contextmenu.items.items[5].show(); +this.contextmenu.items.items[6].show(); +if(_56=="folder"){ +this.contextmenu.items.items[1].hide(); +this.contextmenu.items.items[7].hide(); +this.contextmenu.items.items[8].show(); +}else{ +this.contextmenu.items.items[1].show(); +this.contextmenu.items.items[7].show(); +this.contextmenu.items.items[8].hide(); } } -if(_14.indexOf("/")!=-1){ -_14=_14.substring(0,_14.indexOf("/")); -if(_14.charAt(_14.length-1)=="."){ -return false; +var _59=e.getXY(); +this.contextmenu.rowid=i; +this.contextmenu.showAt([_59[0],_59[1]]); +},loadFoldercontents:function(_5a,e){ +this.currentfolder=_5a.id; +var _5c=this.layout.findById("filepanel"); +_5c.store.baseParams["folder_id"]=_5a.id; +if(_5a.loading){ +_5a.on("expand",function(){ +this.store.load(); +},_5c,{single:true}); +}else{ +_5c.store.load(); } +},openItem:function(_5d,i,e){ +var _60=this.layout.findById("treepanel"); +var dm=_5d.store; +var _62=dm.getAt(i); +if(_62.get("type")=="folder"){ +var _63=_60.getNodeById(_62.get("id")); +if(!_63.parentNode.isExpanded()){ +_63.parentNode.expand(); } -if(_14.indexOf(":")!=-1){ -if(_14.indexOf(":")==(_14.length-1)){ -return false; +_63.fireEvent("click",_63); +_63.expand(); }else{ -if(_14.charAt(_14.indexOf(":")+1)=="."){ -return false; +window.open(_62.get("url")); +window.focus(); } +},delItem:function(_64,i,e){ +var _67=acs_lang_text.confirm_delete||"Are you sure you want to delete "; +var _68=acs_lang_text.foldercontains||"This folder contains"; +var _69=this.layout.findById("treepanel"); +if(_64.id=="filepanel"){ +var _6a=_64; +if(_6a.getSelectionModel().getCount()<=1){ +_6a.getSelectionModel().selectRow(i); } -_14=_14.substring(0,_14.indexOf(":")); -if(_14.charAt(_14.length-1)=="."){ -return false; +}else{ +var _6a=this.layout.findById("filepanel"); } +var _6b=_6a.getSelectionModel().getSelections(); +var _6c=true; +if(_6b.length>0){ +_6c=false; +if(_6b.length==1){ +var _6d=_6b[0].get("title"); +if(_6b[0].get("type")==="folder"){ +var msg=_68+" "+_6b[0].get("size")+".
    "; +}else{ +var msg=""; } -return true; -} -function FileProgress(_15,_16){ -this.file_progress_id=_15.id; -this.opacity=100; -this.height=0; -this.fileProgressWrapper=document.getElementById(this.file_progress_id); -if(!this.fileProgressWrapper){ -this.fileProgressWrapper=document.createElement("div"); -this.fileProgressWrapper.className="progressWrapper"; -this.fileProgressWrapper.id=this.file_progress_id; -this.fileProgressElement=document.createElement("div"); -this.fileProgressElement.className="progressContainer"; -var _17=document.createElement("a"); -_17.className="progressCancel"; -_17.href="#"; -_17.style.visibility="hidden"; -_17.appendChild(document.createTextNode(" ")); -var _18=document.createElement("div"); -_18.className="progressName"; -_18.appendChild(document.createTextNode(_15.name)); -var _19=document.createElement("div"); -_19.className="progressBarInProgress"; -var _1a=document.createElement("div"); -_1a.className="progressBarStatus"; -_1a.innerHTML=" "; -this.fileProgressElement.appendChild(_17); -this.fileProgressElement.appendChild(_18); -this.fileProgressElement.appendChild(_1a); -this.fileProgressElement.appendChild(_19); -this.fileProgressWrapper.appendChild(this.fileProgressElement); -document.getElementById(_16).appendChild(this.fileProgressWrapper); +var msg=msg+_67+" "+_6d+" ?"; +var _6f=_6b[0].get("id"); }else{ -this.fileProgressElement=this.fileProgressWrapper.firstChild; +var msg=_67+":

    "; +var _6f=[]; +for(var x=0;x<_6b.length;x++){ +msg=msg+""+_6b[x].get("title")+" "; +if(_6b[x].get("type")==="folder"){ +msg=msg+"("+_6b[x].get("size")+")"; } -this.height=this.fileProgressWrapper.offsetHeight; +msg=msg+"
    "; +_6f[x]=_6b[x].get("id"); } -FileProgress.prototype.SetProgress=function(_1b){ -this.fileProgressElement.className="progressContainer green"; -this.fileProgressElement.childNodes[3].className="progressBarInProgress"; -this.fileProgressElement.childNodes[3].style.width=_1b+"%"; -}; -FileProgress.prototype.SetComplete=function(){ -this.fileProgressElement.className="progressContainer blue"; -this.fileProgressElement.childNodes[3].className="progressBarComplete"; -this.fileProgressElement.childNodes[3].style.width=""; -var _1c=this; -setTimeout(function(){ -_1c.Disappear(); -},10000); -}; -FileProgress.prototype.SetError=function(){ -this.fileProgressElement.className="progressContainer red"; -this.fileProgressElement.childNodes[3].className="progressBarError"; -this.fileProgressElement.childNodes[3].style.width=""; -var _1d=this; -setTimeout(function(){ -_1d.Disappear(); -},5000); -}; -FileProgress.prototype.SetCancelled=function(){ -this.fileProgressElement.className="progressContainer"; -this.fileProgressElement.childNodes[3].className="progressBarError"; -this.fileProgressElement.childNodes[3].style.width=""; -var _1e=this; -setTimeout(function(){ -_1e.Disappear(); -},2000); -}; -FileProgress.prototype.SetStatus=function(_1f){ -this.fileProgressElement.childNodes[2].innerHTML=_1f; -}; -FileProgress.prototype.ToggleCancel=function(_20,_21){ -this.fileProgressElement.childNodes[0].style.visibility=_20?"visible":"hidden"; -if(_21){ -var _22=this.file_progress_id; -this.fileProgressElement.childNodes[0].onclick=function(){ -_21.cancelUpload(_22); -return false; -}; } -}; -FileProgress.prototype.Disappear=function(){ -var _23=15; -var _24=4; -var _25=30; -if(this.opacity>0){ -this.opacity-=_23; -if(this.opacity<0){ -this.opacity=0; +}else{ +_6c=true; +var _71=_69.getSelectionModel().getSelectedNode(); +var _6f=_71.attributes["id"]; +var _72=_69.getRootNode(); +if(_71.attributes["id"]==_72.attributes["id"]){ +Ext.Msg.alert(acs_lang_text.alert||"Alert",acs_lang_text.cant_del_root||"The root folder can not be deleted."); +return; +}else{ +var msg=_67+" "+_71.attributes["text"]+"?"; } -if(this.fileProgressWrapper.filters){ -try{ -this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity=this.opacity; } -catch(e){ -this.fileProgressWrapper.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+this.opacity+")"; -} +var _73=function(_74){ +if(_74==="yes"){ +Ext.Ajax.request({url:this.xmlhttpurl+"delete-fsitem",success:function(_75){ +var _76=Ext.decode(_75.responseText); +if(_76.success){ +if(_6c){ +var _77=_69.getSelectionModel().getSelectedNode(); +var _78=_77.parentNode; +_78.fireEvent("click",_78); +_78.removeChild(_77); }else{ -this.fileProgressWrapper.style.opacity=this.opacity/100; +for(var x=0;x<_6b.length;x++){ +_6a.store.remove(_6b[x]); +var _7a=_6b[x].get("id"); +var _77=_69.getNodeById(_7a); +if(_77){ +_77.parentNode.fireEvent("click",_77.parentNode); +_77.parentNode.removeChild(_77); } } -if(this.height>0){ -this.height-=_24; -if(this.height<0){ -this.height=0; } -this.fileProgressWrapper.style.height=this.height+"px"; +}else{ +Ext.Msg.alert(acs_lang_text.error||"Error","Sorry, we encountered an error."); } -if(this.height>0||this.opacity>0){ -var _26=this; +},failure:function(){ +Ext.Msg.alert(acs_lang_text.error||"Error",error_msg_txt+"

    "+resultObj.error+""); +},params:{object_id:_6f}}); +} +}; +Ext.MessageBox.confirm(acs_lang_text.confirm||"Confirm",msg,_73,this); +},addFolder:function(){ +var te=this.te; +var _7c=this.layout.findById("treepanel"); +var _7d=_7c.getSelectionModel().getSelectedNode(); +_7d.expand(); +var _7e=acs_lang_text.new_folder_error||"Sorry, there was an error trying to create your new folder."; +Ext.Ajax.request({url:this.xmlhttpurl+"add-blankfolder",success:function(_7f){ +var _80=Ext.decode(_7f.responseText); +if(_80.success){ +var _81=_7d.appendChild(new Ext.tree.TreeNode({text:_80.pretty_folder_name,id:_80.id,iconCls:"folder",singleClickExpand:true,attributes:{write_p:"t"}})); +_7c.getSelectionModel().select(_81); +_81.loaded=true; +_81.fireEvent("click",_81); setTimeout(function(){ -_26.Disappear(); -},_25); +te.editNode=_81; +te.startEdit(_81.ui.textNode); +},10); }else{ -this.fileProgressWrapper.style.display="none"; +Ext.Msg.alert(acs_lang_text.error||"Error",_7e+"

    "+_80.error+""); } -}; -function uploadStart(_27,_28){ -var _29=acs_lang_text.for_upload_to||"for upload to"; -var _2a=acs_lang_text.zip_extracted||"Zip File (Will be extracted after upload)"; +},failure:function(_82){ +var _83=Ext.decode(_82.responseText); +Ext.Msg.alert(acs_lang_text.error||"Error",_7e+"

    "+_83.error+""); +},params:{folder_id:_7d.attributes["id"]}}); +},createSwfObj:function(){ +var _84=this; +var _85=_84.layout.findById("treepanel"); +var _86=_84.currentfolder; +if(this.swfu==null){ +var _87=String(this.config.package_id); +var _88=String(this.config.user_id); +var _89=String(this.currentfolder); +var _8a=String(this.config.max_file_size); +var _8b=function(_8c,_8d){ try{ -var _2b=_28.currentfolder; -var _2c=_28.treepanel.getNodeById(_2b).text; -var _2d=new FileProgress(_27,this.getSetting("progress_target")); -_2d.SetStatus(_29+""+_2c+"
    Title: (optional)
    "+_2a); -_2d.ToggleCancel(true,this); -this.addFileParam(_27.id,"folder_id",_2b); -_28.upldDialog.buttons[0].enable(); +var _8e=Math.ceil((_8d/_8c.size)*100); +var _8f=new FileProgress(_8c,this.getSetting("progress_target")); +_8f.SetProgress(_8e); +_8f.SetStatus(acs_lang_text.uploading||"Uploading..."); } catch(ex){ this.debugMessage(ex); } -} -function uploadProgress(_2e,_2f){ +}; +var _90=function(_91){ try{ -var _30=Math.ceil((_2f/_2e.size)*100); -var _31=new FileProgress(_2e,this.getSetting("progress_target")); -_31.SetProgress(_30); -_31.SetStatus(acs_lang_text.uploading||"Uploading..."); +var _92=new FileProgress(_91,this.getSetting("progress_target")); +_92.SetCancelled(); +_92.SetStatus(acs_lang_text.uploadcancel||"Cancelled (This item will be removed shortly)"); +_92.ToggleCancel(false); } catch(ex){ this.debugMessage(ex); } -} -function uploadFileComplete(_32){ +}; +var _93=function(_94){ try{ -var _33=new FileProgress(_32,this.getSetting("progress_target")); -_33.SetComplete(); -_33.SetStatus(acs_lang_text.complete||"Complete."); -_33.ToggleCancel(false); +var _95=new FileProgress(_94,this.getSetting("progress_target")); +_95.SetComplete(); +_95.SetStatus(acs_lang_text.complete||"Complete."); +_95.ToggleCancel(false); } catch(ex){ this.debugMessage(ex); } -} -function uploadComplete(_34){ +}; +var _96=function(_97){ +var _98=_85.getNodeById(_84.currentfolder); +_98.fireEvent("click",_98); +}; +var _99=function(_9a,_9b,_9c){ try{ -var _35=new FileProgress(_34,this.getSetting("progress_target")); -_35.SetComplete(); -_35.SetStatus(acs_lang_text.complete||"Complete."); -_35.ToggleCancel(false); -} -catch(ex){ -this.debugMessage(ex); -} -} -function uploadQueueComplete(_36,_37){ -_37.upldDialog.buttons[0].disable(); -var _38=_37.treepanel.getNodeById(_37.currentfolder); -_38.fireEvent("click",_38); -} -function uploadError(_39,_3a,_3b){ -try{ -if(_39==SWFUpload.ERROR_CODE_QUEUE_LIMIT_EXCEEDED){ -Ext.Msg.alert(acs_lang_text.alert||"Alert","You have attempted to queue too many files.\n"+(_3b==0?"You have reached the upload limit.":"You may select "+(_3b>1?"up to "+_3b+" files.":"one file."))); +if(_9a==SWFUpload.ERROR_CODE_QUEUE_LIMIT_EXCEEDED){ +Ext.Msg.alert(acs_lang_text.alert||"Alert","You have attempted to queue too many files.\n"+(_9c==0?"You have reached the upload limit.":"You may select "+(_9c>1?"up to "+_9c+" files.":"one file."))); return; } -var _3c=new FileProgress(_3a,this.getSetting("progress_target")); -_3c.SetError(); -_3c.ToggleCancel(false); -switch(_39){ +var _9d=new FileProgress(_9b,this.getSetting("progress_target")); +_9d.SetError(); +_9d.ToggleCancel(false); +switch(_9a){ case SWFUpload.ERROR_CODE_HTTP_ERROR: -_3c.SetStatus("Upload Error"); -this.debugMessage("Error Code: HTTP Error, File name: "+file.name+", Message: "+_3b); +_9d.SetStatus("Upload Error"); +this.debugMessage("Error Code: HTTP Error, File name: "+file.name+", Message: "+_9c); break; case SWFUpload.ERROR_CODE_MISSING_UPLOAD_TARGET: -_3c.SetStatus("Configuration Error"); -this.debugMessage("Error Code: No backend file, File name: "+file.name+", Message: "+_3b); +_9d.SetStatus("Configuration Error"); +this.debugMessage("Error Code: No backend file, File name: "+file.name+", Message: "+_9c); break; case SWFUpload.ERROR_CODE_UPLOAD_FAILED: -_3c.SetStatus("Upload Failed."); -this.debugMessage("Error Code: Upload Failed, File name: "+file.name+", File size: "+file.size+", Message: "+_3b); +_9d.SetStatus("Upload Failed."); +this.debugMessage("Error Code: Upload Failed, File name: "+file.name+", File size: "+file.size+", Message: "+_9c); break; case SWFUpload.ERROR_CODE_IO_ERROR: -_3c.SetStatus("Server (IO) Error"); -this.debugMessage("Error Code: IO Error, File name: "+file.name+", Message: "+_3b); +_9d.SetStatus("Server (IO) Error"); +this.debugMessage("Error Code: IO Error, File name: "+file.name+", Message: "+_9c); break; case SWFUpload.ERROR_CODE_SECURITY_ERROR: -_3c.SetStatus("Security Error"); -this.debugMessage("Error Code: Security Error, File name: "+file.name+", Message: "+_3b); +_9d.SetStatus("Security Error"); +this.debugMessage("Error Code: Security Error, File name: "+file.name+", Message: "+_9c); break; case SWFUpload.ERROR_CODE_FILE_EXCEEDS_SIZE_LIMIT: -_3c.SetStatus("File is too big."); -this.debugMessage("Error Code: File too big, File name: "+file.name+", File size: "+file.size+", Message: "+_3b); +_9d.SetStatus("File is too big."); +this.debugMessage("Error Code: File too big, File name: "+file.name+", File size: "+file.size+", Message: "+_9c); break; case SWFUpload.ERROR_CODE_ZERO_BYTE_FILE: -_3c.SetStatus("Cannot upload Zero Byte files."); -this.debugMessage("Error Code: Zero byte file, File name: "+file.name+", File size: "+file.size+", Message: "+_3b); +_9d.SetStatus("Cannot upload Zero Byte files."); +this.debugMessage("Error Code: Zero byte file, File name: "+file.name+", File size: "+file.size+", Message: "+_9c); break; case SWFUpload.ERROR_CODE_UPLOAD_LIMIT_EXCEEDED: -_3c.SetStatus("Upload limit exceeded."); -this.debugMessage("Error Code: Upload Limit Exceeded, File name: "+file.name+", File size: "+file.size+", Message: "+_3b); +_9d.SetStatus("Upload limit exceeded."); +this.debugMessage("Error Code: Upload Limit Exceeded, File name: "+file.name+", File size: "+file.size+", Message: "+_9c); break; default: -_3c.SetStatus("Unhandled Error"); -this.debugMessage("Error Code: "+_39+", File name: "+file.name+", File size: "+file.size+", Message: "+_3b); +_9d.SetStatus("Unhandled Error"); +this.debugMessage("Error Code: "+_9a+", File name: "+file.name+", File size: "+file.size+", Message: "+_9c); break; } } catch(ex){ this.debugMessage(ex); } -} -function uploadCancel(_3d){ +}; +var _9e=function(_9f){ +var _a0=acs_lang_text.for_upload_to||"for upload to"; +var _a1=acs_lang_text.zip_extracted||"Zip File (Will be extracted after upload)"; try{ -var _3e=new FileProgress(_3d,this.getSetting("progress_target")); -_3e.SetCancelled(); -_3e.SetStatus(acs_lang_text.uploadcancel||"Cancelled (This item will be removed shortly)"); -_3e.ToggleCancel(false); +var _a2=_84.currentfolder; +var _a3=_85.getNodeById(_a2).text; +var _a4=new FileProgress(_9f,this.getSetting("progress_target")); +_a4.SetStatus(_a0+" "+_a3+"
    Title: (optional)
    "+_a1); +_a4.ToggleCancel(true,this); +this.addFileParam(_9f.id,"folder_id",_a2); } catch(ex){ this.debugMessage(ex); } +}; +this.swfu=new SWFUpload({debug:false,upload_target_url:this.xmlhttpurl+"add-file-flash",upload_params:{user_id:_88,package_id:_87},file_types:"*.*",file_size_limit:_8a,file_queue_limit:0,file_upload_limit:10,begin_upload_on_queue:false,file_queued_handler:_9e,file_progress_handler:_8b,file_cancelled_handler:_90,file_complete_handler:_93,queue_complete_handler:_96,error_handler:_99,flash_url:"/resources/ajax-filestorage-ui/swfupload/swfupload.swf"}); } -function ajaxfs(_3f){ -this.xmlhttpurl="/ajaxfs2/xmlhttp/"; -this.config=null; -this.layout=null; -this.treepanel=null; -this.tagcloudpanel=null; -this.te=null; -this.rootfolder=null; -this.filegrid=null; -this.toolbar=null; -this.currentfolder=null; -this.currenttag=null; -this.asyncCon=new Ext.data.Connection(); -this.msgbox=Ext.MessageBox; -this.upldDialog=null; -this.createurlDialog=null; -this.permsDialog=null; -this.revisionsDialog=null; -this.contextmenu=null; -this.swfu=null; -this.isSessionExpired=function(){ -if(readCookie("ad_user_login")==null){ -Ext.get(document.body).mask(acs_lang_text.sessionexpired||"Your session has expired. You need to login again.
    You will be redirected to a login page shortly"); -var _40="package_id="+this.config.package_id; -if(this.currentfolder!=null){ -_40=_40+"&folder_id="+this.currentfolder; +},addFile:function(){ +if(this.upldWindow==null){ +if(!this.config.multi_file_upload||checkFlashVersion()<9||Ext.isLinux){ +var _a5=acs_lang_text.file_to_upload||"File to upload"; +var _a6=acs_lang_text.file_title||"Title"; +var _a7=acs_lang_text.file_description||"Description"; +var _a8=acs_lang_text.multiple_files||"Multiple Files"; +var _a9=acs_lang_text.multiple_files_msg||"This is a ZIPfile containing multiple files."; +var _aa=true; +var _ab="Upload a File"; +var _ac=new Ext.Panel({id:"form_addfile",align:"left",frame:true,html:"

    "+_a5+"


    "+_a6+"


    "+_a7+" :

    "+_a8+" :

    "+_a9+"

    "}); +var _ad=[{text:"Upload",handler:this.uploadOneFile.createDelegate(this),icon:"/resources/ajaxhelper/icons/arrow_up.png",cls:"x-btn-text-icon"},{text:"Close",handler:function(){ +this.upldWindow.hide(); +}.createDelegate(this),icon:"/resources/ajaxhelper/icons/cross.png",cls:"x-btn-text-icon"}]; +}else{ +this.createSwfObj(); +var _ae=acs_lang_text.upload_intro||"Click Browse to select a file to upload to the selected folder on the tree."; +var _aa=false; +var _ab="Upload Files"; +var _ac=new Ext.Panel({id:"form_multi_addfile",autoScroll:true,frame:true,html:"
    "+_ae+"
    "}); +_ac.on("render",function(){ +this.swfu.addSetting("progress_target","fsuploadprogress"); +},this); +var _ad=[{text:"Browse",handler:this.swfu.browse.createDelegate(this.swfu),icon:"/resources/ajaxhelper/icons/page_add.png",cls:"x-btn-text-icon"},{text:"Upload",handler:this.swfu.startUpload.createDelegate(this.swfu,[null,this],false),icon:"/resources/ajaxhelper/icons/arrow_up.png",cls:"x-btn-text-icon"},{text:"Hide",handler:function(){ +this.upldWindow.hide(); +}.createDelegate(this),icon:"/resources/ajaxhelper/icons/cross.png",cls:"x-btn-text-icon"}]; } -window.location="/register/?return_url="+window.location; -return 1; +this.upldWindow=new Ext.Window({id:"upload-win",layout:"fit",width:400,height:300,title:_ab,closeAction:"hide",modal:_aa,plain:true,resizable:false,items:_ac,buttons:_ad}); } -return 0; -}; -this.isPermitted=function(_41,_42){ -var _43=function(_44,_45,_46){ -if(_45){ -return _46.responseText; +this.upldWindow.show(); +},uploadOneFile:function(){ +if(Ext.get("upload_file").getValue()!=""&&Ext.get("filetitle").getValue()!=""){ +var _af=this.layout.findById("treepanel"); +var _b0={success:function(){ +},upload:function(){ +_af.getSelectionModel().getSelectedNode().loaded=false; +_af.getSelectionModel().getSelectedNode().fireEvent("click",_af.getSelectionModel().getSelectedNode()); +this.upldWindow.body.unmask(); +this.upldWindow.hide(); +},failure:function(){ +Ext.Msg.alert(acs_lang_text.error||"Error",acs_lang_text.upload_failed||"Upload failed, please try again later."); +},scope:this}; +var _b1=acs_lang_text.loading||"One moment. This may take a while depending on how large your upload is."; +this.upldWindow.body.mask("
    "+_b1); +YAHOO.util.Connect.setForm("newfileform",true,true); +var _b2=YAHOO.util.Connect.asyncRequest("POST",this.xmlhttpurl+"add-file",_b0); }else{ -return 0; +Ext.Msg.alert(acs_lang_text.alert||"Alert",acs_lang_text.file_required||"Title and File to upload are required."); } -}; -this.asyncCon.request({url:this.xmlhttpurl+"checkperms",params:"object_id="+_41+"&perm="+_42,method:"POST",callback:_43,scope:this}); -}; -this.createGridPanel=function(_47,_48,_49){ -gridPanel=new Ext.GridPanel(_47,_49); -this.layout.add(_48,gridPanel); -}; -this.linkCopy=function(){ -var _4a=this.filegrid.getSelectionModel().getSelected(); -var _4b=_4a.get("type"); -if(_4b==="folder"){ -var _4c=window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"?package_id="+this.config.package_id+"&folder_id="+_4a.get("id"); +},addUrl:function(){ +if(this.createurlWindow==null){ +this.createurlWindow=new Ext.Window({id:"createurl-win",layout:"fit",width:400,height:180,title:"Create URL",closeAction:"hide",modal:true,plain:true,resizable:false,items:new Ext.FormPanel({id:"form_create_url",align:"left",autoScroll:true,closable:true,layout:"form",defaults:{width:230},frame:true,buttonAlign:"left",items:[{xtype:"textfield",fieldLabel:"Title",allowBlank:false,name:"fstitle",tabIndex:1},{xtype:"textfield",fieldLabel:"URL",allowBlank:false,name:"fsurl",tabIndex:2},{xtype:"textfield",fieldLabel:"Description",name:"fsdescription",tabIndex:3}]}),buttons:[{text:"Submit",handler:function(){ +this.createurlWindow.findById("form_create_url").getForm().submit({url:this.xmlhttpurl+"add-url",waitMsg:"One moment ....",params:{package_id:this.config.package_id,folder_id:this.currentfolder},reset:true,scope:this,success:function(_b3,_b4){ +if(_b4.result){ +this.createurlWindow.hide(); }else{ -if(_4b==="url"){ -var _4c=_4a.get("url"); -}else{ -var _4c=window.location.protocol+"//"+window.location.hostname+_4a.get("url"); +Ext.MessageBox.alert("Error","Sorry an error occured.
    "+_b4.result.error); } +},failure:function(_b5,_b6){ +if(_b6.result){ +Ext.MessageBox.alert("Error",_b6.result.error); } -if(Ext.isIE){ -window.clipboardData.setData("text",_4c); +}}); +}.createDelegate(this),icon:"/resources/ajaxhelper/icons/disk.png",cls:"x-btn-text-icon"},{text:"Close",handler:function(){ +this.createurlWindow.hide(); +}.createDelegate(this),icon:"/resources/ajaxhelper/icons/cross.png",cls:"x-btn-text-icon"}]}); +} +this.createurlWindow.show(); +},renameItem:function(_b7,i,e){ +var _ba=_b7; +var _bb=this.layout.findById("treepanel"); +var _bc=_ba.store.getAt(i); +var _bd=_bc.get("url"); +var _be=_bc.get("type"); +var _bf=_bc.get("id"); +var _c0=_bc.get("filename"); +var _c1=function(_c2){ +var _c3=acs_lang_text.an_error_occurred||"An error occurred"; +var _c4=acs_lang_text.reverted||"Your changes have been reverted"; +var _c5=Ext.decode(_c2.responseText); +if(!_c5.success){ +Ext.Msg.alert(acs_lang_text.error||"Error",_c3+":

    "+_c5.error+"

    "+_c4); }else{ -var _4d=Ext.Msg.show({title:acs_lang_text.linkaddress||"Copy Link Address",prompt:true,msg:acs_lang_text.copyhighlighted||"Copy the highlighted text to your clipboard.",value:_4c,buttons:Ext.Msg.OK}); -var _4e=YAHOO.util.Dom.getElementsByClassName("ext-mb-input","input","x-msg-box"); -_4e[0].select(); +if(_be=="folder"){ +_bb.getNodeById(_bf).setText(_c5.newname); } +if(_be!="folder"&&_c0===" "){ +_c0=_bc.get("title"); +_bc.set("filename",_c0); +} +_bc.set("title",_c5.newname); +_bc.commit(); +} }; -this.fileRename=function(){ -var _4f=this.filegrid.getSelectionModel().getSelected(); -var _50=_4f.get("url"); -var _51=_4f.get("type"); -var _52=_4f.get("id"); -var _53=_4f.get("filename"); -var _54=function(btn,_56){ +var _c6=function(btn,_c8){ if(btn=="ok"){ -if(_56!=""){ -if(_56.length>100){ +if(_c8!=""){ +if(_c8.length>100){ Ext.Msg.alert(acs_lang_text.alert||"Alert",acs_lang_text.limitto100||"Please limit your name to 100 characters or less."); return false; }else{ -var _57=function(_58,_59,_5a){ -var _5b=acs_lang_text.an_error_occurred||"An error occurred"; -var _5c=acs_lang_text.reverted||"Your changes have been reverted"; -if(_59){ -if(_5a.responseText!=1){ -Ext.Msg.alert(acs_lang_text.error||"Error",_5b+":

    "+_5a.responseText+"

    "+_5c); -}else{ -if(_51!="folder"&&_53===" "){ -_53=_4f.get("title"); -_4f.set("filename",_53); +Ext.Ajax.request({url:this.xmlhttpurl+"edit-name",success:_c1,failure:function(_c9){ +var _ca=Ext.decode(_c9.responseText); +Ext.Msg.alert(acs_lang_text.error||"Error",error_msg_txt+"

    "+_ca.error+""); +},params:{newname:_c8,object_id:_bf,type:_be,url:_bd}}); } -if(_51=="folder"){ -this.treepanel.getNodeById(_52).setText(_56); -} -nodetags=_4f.get("tags"); -if(nodetags!=""){ -var _5d="
    Tags:
    "+nodetags+"
    "; }else{ -var _5d="
    "; -} -_4f.set("title",_56); -_4f.set("title_and_name",""+_56+"
    "+_53+""+_5d); -_4f.commit(); -} -}else{ -Ext.Msg.alert(acs_lang_text.error||"Error",_5b+":

    "+_5a.responseText+"

    "+_5c); -} -}; -this.asyncCon.request({url:this.xmlhttpurl+"editname",params:"newname="+_56+"&object_id="+_52+"&type="+_51+"&url="+_50,method:"POST",callback:_57,scope:this}); -} -}else{ Ext.Msg.alert(acs_lang_text.alert||"Alert",acs_lang_text.enter_new_name||"Please enter a new name."); return false; } } }; -Ext.Msg.show({title:acs_lang_text.rename||"Rename",prompt:true,msg:acs_lang_text.enter_new_name||"Please enter a new name for ... ",value:_4f.get("title"),buttons:Ext.Msg.OKCANCEL,fn:_54.createDelegate(this)}); -var _5e=YAHOO.util.Dom.getElementsByClassName("ext-mb-input","input","x-msg-box"); -_5e[0].select(); +Ext.Msg.show({title:acs_lang_text.rename||"Rename",prompt:true,msg:acs_lang_text.enter_new_name||"Please enter a new name for ... ",value:_bc.get("title"),buttons:Ext.Msg.OKCANCEL,fn:_c6.createDelegate(this)}); +var _cb=YAHOO.util.Dom.getElementsByClassName("ext-mb-input","input"); +_cb[0].select(); +},tagFsitem:function(_cc,i,e){ +var _cf=_cc; +var _d0=_cf.store.getAt(i); +var _d1=_d0.get("id"); +var _d2=_d0.get("tags"); +var _d3=this.config.package_id; +var _d4=this.layout.findById("tagcloudpanel"); +var _d5=this.xmlhttpurl; +var _d6=this.tagWindow; +var _d7=function(){ +Ext.Ajax.request({url:this.xmlhttpurl+"add-tag",success:function(){ +_d0.data.tags=Ext.get("fstags").getValue(); +_d0.commit(); +_d4.load({url:_d5+"get-tagcloud",params:{package_id:_d3}}); +_d6.hide(); +},failure:function(_d8){ +Ext.Msg.alert(acs_lang_text.error||"Error","Sorry, we encountered an error."); +},params:{object_id:_d0.id,package_id:_d3,tags:Ext.get("fstags").getValue()}}); }; -this.permsRedirect=function(){ -var _5f=this.filegrid.getSelectionModel().getSelected(); -var _60=_5f.get("id"); -var _61=window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"permissions?object_id="+_60+"&return_url="+window.location.pathname+"?package_id="+this.config.package_id+"&folder_id="+this.currentfolder); -_61.focus(); -}; -this.propertiesRedirect=function(){ -var _62=this.filegrid.getSelectionModel().getSelected(); -var _63=_62.get("id"); -var _64=window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"file?file_id="+_63); -_64.focus(); -}; -this.viewsRedirect=function(){ -var _65=this.filegrid.getSelectionModel().getSelected(); -var _66=_65.get("id"); -window.open(window.location.protocol+"//"+window.location.hostname+"/o/"+_66+"/info"); -window.focus(); -}; -this.promptTag=function(){ -var _67=this; -var _68=_67.filegrid.getSelectionModel().getSelected(); -var _69=_68.get("id"); -Ext.Msg.prompt("Tag","Enter or edit one or more tags. Seperate tags with commas (,):",function(btn,_6b){ -if(btn=="ok"){ -var _6c=function(_6d,_6e,_6f){ -if(_6e){ -_68.set("tags",_6b); -Ext.get("tagscontainer_"+_69).update("Tag:"+_6b+""); -this.tagcloudpanel.load("/ajaxfs2/xmlhttp/tagcloud?package_id="+this.config.package_id); +if(_d6==null){ +var _d9=new Ext.Panel({id:"form_addtag",autoScroll:true,frame:true,html:"

    Enter or edit one or more tags. Use commas (,) to separate the tags:

    "}); +var _da=[{text:"Ok",icon:"/resources/ajaxhelper/icons/disk.png",cls:"x-btn-text-icon",handler:_d7.createDelegate(this)},{text:"Cancel",icon:"/resources/ajaxhelper/icons/cross.png",cls:"x-btn-text-icon",handler:function(){ +_d6.hide(); +}.createDelegate(this)}]; +_d6=new Ext.Window({id:"tag-win",layout:"fit",width:450,height:300,title:"Tags",closeAction:"hide",modal:true,plain:true,autoScroll:false,resizable:false,items:_d9,buttons:_da}); +}else{ } +_d6.show(); +this.initTagAutoComplete(); +},initTagAutoComplete:function(){ +var _db=new YAHOO.widget.DS_JSArray(oAutoCompArr); +if(document.getElementById("fstags")){ +var _dc=new YAHOO.widget.AutoComplete("fstags","oAutoCompContainer1",_db); +_dc.animHoriz=false; +_dc.animVert=false; +_dc.queryDelay=0; +_dc.maxResultsDisplayed=10; +_dc.useIFrame=true; +_dc.delimChar=","; +_dc.allowBrowserAutocomplete=false; +_dc.typeAhead=true; +_dc.formatResult=function(_dd,_de){ +var _df=_dd[0]; +return _df; }; -_67.asyncCon.request({url:_67.xmlhttpurl+"addtag",params:"object_id="+_69+"&tags="+_6b+"&package_id="+_67.config.package_id,method:"POST",callback:_6c,scope:_67}); } -}); -if(document.getElementById("tagslist_"+_69)){ -var _70=YAHOO.util.Dom.getElementsByClassName("ext-mb-input","input","x-msg-box"); -_70[0].value=document.getElementById("tagslist_"+_69).innerHTML; -_70[0].select(); +},downloadArchive:function(_e0){ +if(_e0){ +top.location.href="download-archive/?object_id="+_e0; } -}; -this.downloadArchive=function(){ -var _71=this.filegrid.getSelectionModel().getSelected(); -var _72=_71.get("id"); -top.location.href="download-archive/?object_id="+_72; -}; -this.showContext=function(_73,i,e){ -e.stopEvent(); -var dm=_73.getDataSource(); -var _77=dm.getAt(i); -var _78=_77.get("type"); -var _79=_77.get("id"); -if(_78=="folder"){ -var _7a="Open"; +},redirectViews:function(_e1,i,e){ +var _e4=_e1; +var _e5=_e4.store.getAt(i); +var _e6=_e5.get("id"); +window.open(window.location.protocol+"//"+window.location.hostname+"/o/"+_e6+"/info"); +window.focus(); +},redirectPerms:function(_e7,i,e){ +var _ea=_e7; +var _eb=_ea.store.getAt(i); +var _ec=_eb.get("id"); +var _ed=window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"permissions?object_id="+_ec+"&return_url="+window.location.pathname+"?package_id="+this.config.package_id+"&folder_id="+this.currentfolder); +_ed.focus(); +},redirectProperties:function(_ee,i,e){ +var _f1=_ee; +var _f2=_f1.store.getAt(i); +var _f3=_f2.get("id"); +var _f4=window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"file?file_id="+_f3); +_f4.focus(); +},copyLink:function(_f5,i,e){ +var _f8=_f5; +var _f9=_f8.store.getAt(i); +var _fa=_f9.get("type"); +if(_fa==="folder"){ +var _fb=window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"?package_id="+this.config.package_id+"&folder_id="+_f9.get("id"); }else{ -var _7a="Download"; -} -if(this.contextmenu==null){ -this.contextmenu=new Ext.menu.Menu({id:"rightclickmenu",items:[new Ext.menu.Item({text:_7a,icon:"/resources/ajax-filestorage-ui/icons/page_white.png",handler:this.itemDblClick.createDelegate(this,[_73,i,e],false)}),new Ext.menu.Item({text:"Tag",icon:"/resources/ajax-filestorage-ui/icons/tag_blue.png",handler:this.promptTag.createDelegate(this)}),new Ext.menu.Item({text:"Views",icon:"/resources/ajax-filestorage-ui/icons/camera.png",handler:this.viewsRedirect.createDelegate(this)}),new Ext.menu.Item({text:acs_lang_text.deletefs||"Delete",icon:"/resources/ajax-filestorage-ui/icons/delete.png",handler:this.confirmDel.createDelegate(this)}),new Ext.menu.Item({text:acs_lang_text.rename||"Rename",icon:"/resources/ajax-filestorage-ui/icons/page_edit.png",handler:this.fileRename.createDelegate(this)}),new Ext.menu.Item({text:acs_lang_text.linkaddress||"Copy Link Address",icon:"/resources/ajax-filestorage-ui/icons/page_copy.png",handler:this.linkCopy.createDelegate(this)}),new Ext.menu.Item({text:acs_lang_text.permissions||"Permissions",icon:"/resources/ajax-filestorage-ui/icons/group_key.png",handler:this.permsRedirect.createDelegate(this)}),new Ext.menu.Item({text:acs_lang_text.properties||"Properties",icon:"/resources/ajax-filestorage-ui/icons/page_edit.png",handler:this.propertiesRedirect.createDelegate(this)}),new Ext.menu.Item({text:acs_lang_text.download_archive||"Download archive",icon:"/resources/ajax-filestorage-ui/icons/arrow_down.png",handler:this.downloadArchive.createDelegate(this)})]}); +if(_fa==="url"){ +var _fb=_f9.get("url"); }else{ -this.contextmenu.items.items[0].setText(_7a); +var _fb=window.location.protocol+"//"+window.location.hostname+_f9.get("url"); } -if(_73.getSelectionModel().getCount()>1){ -this.contextmenu.items.items[0].hide(); -this.contextmenu.items.items[1].hide(); -this.contextmenu.items.items[2].hide(); -this.contextmenu.items.items[3].show(); -this.contextmenu.items.items[4].hide(); -this.contextmenu.items.items[5].hide(); -this.contextmenu.items.items[6].hide(); -this.contextmenu.items.items[7].hide(); -this.contextmenu.items.items[8].hide(); -}else{ -this.contextmenu.items.items[0].show(); -this.contextmenu.items.items[2].show(); -this.contextmenu.items.items[3].show(); -this.contextmenu.items.items[4].show(); -this.contextmenu.items.items[5].show(); -this.contextmenu.items.items[6].show(); -if(_78=="folder"){ -this.contextmenu.items.items[1].hide(); -this.contextmenu.items.items[7].hide(); -this.contextmenu.items.items[8].show(); -}else{ -this.contextmenu.items.items[1].show(); -this.contextmenu.items.items[7].show(); -this.contextmenu.items.items[8].hide(); } -} -var _7b=e.getXY(); -this.contextmenu.rowid=i; -this.contextmenu.showAt([_7b[0],_7b[1]]); -}; -this.uploadFile=function(e){ -if(document.getElementById("upload_file").value!=""&&document.getElementById("filetitle").value!=""){ -var _7d={success:function(){ -},upload:function(){ -this.treepanel.getSelectionModel().getSelectedNode().loaded=false; -this.treepanel.getSelectionModel().getSelectedNode().fireEvent("click",this.treepanel.getSelectionModel().getSelectedNode()); -this.upldDialog.getEl().unmask(); -this.upldDialog.hide(); -},failure:function(){ -Ext.Msg.alert(acs_lang_text.error||"Error",acs_lang_text.upload_failed||"Upload failed, please try again later."); -},scope:this}; -var _7e=acs_lang_text.loading||"One moment. This may take a while depending on how large your upload is."; -this.upldDialog.getEl().mask(" "+_7e); -YAHOO.util.Connect.setForm("newfileform",true,true); -var _7f=YAHOO.util.Connect.asyncRequest("POST",this.xmlhttpurl+"file-add",_7d); +if(Ext.isIE){ +window.clipboardData.setData("text",_fb); }else{ -Ext.Msg.alert(acs_lang_text.alert||"Alert",acs_lang_text.file_required||"Title and File to upload are required."); +var _fc=Ext.Msg.show({title:acs_lang_text.linkaddress||"Copy Link Address",prompt:true,msg:acs_lang_text.copyhighlighted||"Copy the highlighted text to your clipboard.",value:_fb,buttons:Ext.Msg.OK}); +var _fd=YAHOO.util.Dom.getElementsByClassName("ext-mb-input","input"); +_fd[0].select(); } -}; -this.createUrl=function(e){ -if(document.getElementById("fsurl").value!=""&&document.getElementById("fstitle").value!=""){ -if(isURL(document.getElementById("fsurl").value)){ -var _81={success:function(){ -this.treepanel.getSelectionModel().getSelectedNode().loaded=false; -this.treepanel.getSelectionModel().getSelectedNode().fireEvent("click",this.treepanel.getSelectionModel().getSelectedNode()); -this.createurlDialog.getEl().unmask(); -this.createurlDialog.hide(); -},failure:function(){ -this.createurlDialog.getEl().unmask(); -Ext.Msg.alert(acs_lang_text.error||"Error",acs_lang_text.createurl_failed||"Create URL failed, please try again later."); -},scope:this}; -this.createurlDialog.getEl().mask(" One moment."); -YAHOO.util.Connect.setForm("simple-add"); -var _82=YAHOO.util.Connect.asyncRequest("POST",this.xmlhttpurl+"url-add",_81); -}else{ -Ext.Msg.alert(acs_lang_text.alert||"Alert",acs_lang_text.invalid_url||"URL is not a valid url."); +}}; +function readCookie(_fe){ +var ca=document.cookie.split(";"); +var _100=_fe+"="; +for(var i=0;iTitle and URL are required."); +if(c.indexOf(_100)==0){ +return c.substring(_100.length,c.length); } -}; -this.showCreateUrldialog=function(){ -if(!this.createurlDialog.buttons){ -this.createurlDialog.addButton({text:acs_lang_text.ok||"Ok",icon:"/resources/ajax-filestorage-ui/icons/page_add.png",cls:"x-btn-text-icon"},this.createUrl,this); -this.createurlDialog.addButton({text:acs_lang_text.cancel||"Cancel",icon:"/resources/ajax-filestorage-ui/icons/cancel.png",cls:"x-btn-text-icon"},this.createurlDialog.hide,this.createurlDialog); } -this.createurlDialog.setTitle(acs_lang_text.createurl||"Create URL"); -this.createurlDialog.body.update("

    Title


    URL


    Description :

    "); -this.createurlDialog.body.setStyle("font","normal 12px tahoma, arial, helvetica, sans-serif"); -this.createurlDialog.body.setStyle("background-color","#ffffff"); -this.createurlDialog.body.setStyle("border","1px solid #e2e2e2"); -this.createurlDialog.body.setStyle("padding","3px"); -this.createurlDialog.show(); -}; -this.showUplddialog=function(){ -this.upldDialog.setTitle(acs_lang_text.uploadfile||"Upload Files"); -if(checkFlashVersion()<8){ -var _83=acs_lang_text.file_to_upload||"File to upload"; -var _84=acs_lang_text.file_title||"Title"; -var _85=acs_lang_text.file_description||"Description"; -var _86=acs_lang_text.multiple_files||"Multiple Files"; -var _87=acs_lang_text.multiple_files_msg||"This is a ZIPfile containing multiple files."; -this.upldDialog.body.update("

    "+_83+"


    "+_84+"


    "+_85+" :

    "+_86+" :

    "+_87+"

    "); -if(!this.upldDialog.buttons){ -this.upldDialog.addButton({text:acs_lang_text.upload||"Upload",icon:"/resources/ajax-filestorage-ui/icons/page_add.png",cls:"x-btn-text-icon"},this.uploadFile,this); -this.upldDialog.addButton({text:acs_lang_text.cancel||"Cancel",icon:"/resources/ajax-filestorage-ui/icons/cancel.png",cls:"x-btn-text-icon"},this.upldDialog.hide,this.upldDialog); +return null; } +function createCookie(name,_104,days){ +if(days){ +var date=new Date(); +date.setTime(date.getTime()+(days*24*60*60*1000)); +var _107="; expires="+date.toGMTString(); }else{ -if(this.swfu==null){ -var _88=acs_lang_text.upload_intro||"Click Browse to select a file to upload to the selected folder."; -this.upldDialog.body.update("
    "+_88+"
    "); -var _89=String(this.config.package_id); -var _8a=String(this.config.user_id); -var _8b=String(this.currentfolder); -var _8c=String(this.config.max_file_size)||5000000; -this.swfu=new SWFUpload({debug:false,upload_target_url:"/ajaxfs2/xmlhttp/file-add-flash",upload_params:{user_id:_8a,package_id:_89},file_types:"*.*",file_size_limit:_8c,file_queue_limit:3,begin_upload_on_queue:false,file_progress_handler:uploadProgress,file_cancelled_handler:uploadCancel,file_complete_handler:uploadComplete,queue_complete_handler:uploadQueueComplete,error_handler:uploadError,flash_url:"/resources/ajax-filestorage-ui/swfupload/swfupload.swf"}); -this.swfu.fileQueued=uploadStart.createDelegate(this.swfu,[this],true); -this.swfu.fileProgress=uploadProgress.createDelegate(this.swfu,[this],true); -this.swfu.fileComplete=uploadComplete.createDelegate(this.swfu,[this],true); -this.swfu.fileCancelled=uploadCancel.createDelegate(this.swfu,[this],true); -this.swfu.queueComplete=uploadQueueComplete.createDelegate(this.swfu,[this],true); -this.swfu.addSetting("progress_target","fsuploadprogress"); -this.upldDialog.addButton({text:acs_lang_text.upload||"Upload",disabled:true,icon:"/resources/ajax-filestorage-ui/icons/arrow_up.png",cls:"x-btn-text-icon"},this.swfu.startUpload.createDelegate(this.swfu,[null,this],false),this); -this.upldDialog.addButton({text:acs_lang_text.browse||"Browse",icon:"/resources/ajax-filestorage-ui/icons/page_add.png",cls:"x-btn-text-icon"},this.swfu.browse,this.swfu); -this.upldDialog.addButton({text:acs_lang_text.close||"Close",icon:"/resources/ajax-filestorage-ui/icons/cross.png",cls:"x-btn-text-icon"},this.upldDialog.hide,this.upldDialog); +var _107=""; } +document.cookie=name+"="+_104+_107+"; path=/"; } -this.upldDialog.body.setStyle("font","normal 12px tahoma, arial, helvetica, sans-serif"); -this.upldDialog.body.setStyle("background-color","#ffffff"); -this.upldDialog.body.setStyle("border","1px solid #e2e2e2"); -this.upldDialog.body.setStyle("padding","3px"); -this.upldDialog.show(); -}; -this.confirmDel=function(){ -var _8d=acs_lang_text.confirm_delete||"Are you sure you want to delete"; -var _8e=acs_lang_text.foldercontains||"This folder contains"; -var _8f=this.filegrid.getSelectionModel().getSelections(); -if(_8f.length>0){ -if(_8f.length==1){ -var _90=_8f[0].get("title"); -if(_8f[0].get("type")==="folder"){ -var msg=_8e+" "+_8f[0].get("size")+".
    "; -}else{ -var msg=""; +function readQs(q){ +var _109=window.location.search.substring(1); +var _10a=_109.split("&"); +for(var i=0;i<_10a.length;i++){ +var pos=_10a[i].indexOf("="); +if(pos>0){ +var key=_10a[i].substring(0,pos); +var val=_10a[i].substring(pos+1); +if(key==q){ +return val; } -var msg=msg+_8d+" "+_90+" ?"; -}else{ -var msg=_8d+":

    "; -for(var x=0;x<_8f.length;x++){ -msg=msg+""+_8f[x].get("title")+" "; -if(_8f[x].get("type")==="folder"){ -msg=msg+"("+_8f[x].get("size")+")"; } -msg=msg+"
    "; } +return null; } -this.msgbox.confirm(acs_lang_text.confirm||"Confirm",msg,this.delFsitems,this); +function checkFlashVersion(){ +var x; +var _110; +if(navigator.plugins&&navigator.mimeTypes.length){ +x=navigator.plugins["Shockwave Flash"]; +if(x&&x.description){ +x=x.description; +} }else{ -var _93=this.treepanel.getSelectionModel().getSelectedNode(); -var _94=this.treepanel.getRootNode(); -if(_93.attributes["id"]==_94.attributes["id"]){ -Ext.Msg.alert(acs_lang_text.alert||"Alert",acs_lang_text.cant_del_root||"The root folder can not be deleted."); -}else{ -this.msgbox.confirm(acs_lang_text.confirm||"Confirm",_8d+" "+_93.attributes["text"]+"?",this.delFolder,this); +if(Ext.isIE){ +try{ +x=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); +x=x.GetVariable("$version"); } +catch(e){ } -}; -this.delFsitems=function(_95){ -var _96=this.filegrid.getSelectionModel().getSelections(); -var _97=[]; -for(var x=0;x<_96.length;x++){ -_97[x]=_96[x].get("id"); } -var _99=function(_9a,_9b,_9c){ -var _9d=acs_lang_text.delete_error||"Sorry, there was an error trying to delete this item."; -if(_9b&&_9c.responseText==1){ -for(var x=0;x<_96.length;x++){ -this.filegrid.getDataSource().remove(_96[x]); -var _9f=_96[x].get("id"); -var _a0=this.treepanel.getNodeById(_9f); -if(_a0){ -_a0.parentNode.fireEvent("click",_a0.parentNode); -_a0.parentNode.removeChild(_a0); } +pluginVersion=(typeof (x)=="string")?parseInt(x.match(/\d+/)[0]):0; +return pluginVersion; } -this.filegrid.getSelectionModel().clearSelections(); +function isURL(_111){ +if(_111.indexOf(" ")!=-1){ +return false; }else{ -Ext.Msg.alert(acs_lang_text.error||"Error",_9d+"

    "+_9c.responseText+""); -} -this.filegrid.container.unmask(); -}; -var _a1="object_id="+_97; -var url=this.xmlhttpurl+"delete"; -if(_95==="yes"){ -this.filegrid.container.mask("Deleting"); -this.asyncCon.request({url:url,params:_a1,method:"POST",callback:_99,scope:this}); -} -}; -this.delFolder=function(_a3){ -var _a4=this.treepanel.getSelectionModel().getSelectedNode(); -var _a5=_a4.parentNode; -var id=_a4.attributes["id"]; -var _a7=function(_a8,_a9,_aa){ -var _ab=acs_lang_text.delete_error||"Sorry, there was an error trying to delete this item."; -if(_a9){ -if(_aa.responseText!="1"){ -Ext.Msg.alert(acs_lang_text.error||"Error",_ab+"

    "+_aa.responseText+""); +if(_111.indexOf("http://")==-1){ +return false; }else{ -_a5.fireEvent("click",_a5); -_a5.removeChild(_a4); -} +if(_111=="http://"){ +return false; }else{ -Ext.Msg.alert(acs_lang_text.error||"Error",_ab+"

    "+_aa.responseText+""); +if(_111.indexOf("http://")>0){ +return false; } -}; -if(_a3==="yes"){ -this.asyncCon.request({url:this.xmlhttpurl+"delete",params:"object_id="+id,method:"POST",callback:_a7,scope:this}); } -}; -this.newFolder=function(){ -var te=this.te; -var _ad=this.treepanel; -var _ae=_ad.getSelectionModel().getSelectedNode(); -_ae.expand(); -var _af=function(_b0,_b1,_b2){ -var _b3=acs_lang_text.new_folder_error||"Sorry, there was an error trying to create your new folder."; -if(_b1){ -if(_b2.responseText){ -var _b4=eval(_b2.responseText); -if(parseInt(_b4[0].id)!=0){ -var _b5=_ae.appendChild(new Ext.tree.TreeNode({text:_b4[0].pretty_folder_name,id:_b4[0].id,iconCls:"folder",singleClickExpand:true,attributes:{write_p:"t"}})); -_ad.getSelectionModel().select(_b5); -_b5.loaded=true; -_b5.fireEvent("click",_b5); -setTimeout(function(){ -te.editNode=_b5; -te.startEdit(_b5.ui.textNode); -},10); -}else{ -Ext.Msg.alert(acs_lang_text.error||"Error",_b3+"

    "+_b2.responseText+""); } } +_111=_111.substring(7,_111.length); +if(_111.indexOf(".")==-1){ +return false; }else{ -Ext.Msg.alert(acs_lang_text.error||"Error",_b3+"

    "+_b2.responseText+""); -} -}; -this.asyncCon.request({url:this.xmlhttpurl+"newblankfolder",params:"folder_id="+_ae.attributes["id"],method:"POST",callback:_af,scope:this}); -}; -this.itemDblClick=function(_b6,i,e){ -var dm=_b6.getDataSource(); -var _ba=dm.getAt(i); -if(_ba.get("type")=="folder"){ -var _bb=this.treepanel.getNodeById(_ba.get("id")); -if(!_bb.parentNode.isExpanded()){ -_bb.parentNode.expand(); -} -_bb.fireEvent("click",_bb); -_bb.expand(); +if(_111.indexOf(".")==0){ +return false; }else{ -window.open(_ba.get("url")); -window.focus(); +if(_111.charAt(_111.length-1)=="."){ +return false; } -}; -this.createFileGrid=function(){ -var _bc=[{header:"",width:50,sortable:true,dataIndex:"icon"},{header:acs_lang_text.filename||"Filename",id:"filename",width:200,sortable:true,dataIndex:"title_and_name"},{header:acs_lang_text.size||"Size",sortable:true,dataIndex:"size"},{header:acs_lang_text.lastmodified||"Last Modified",sortable:true,dataIndex:"lastmodified"}]; -var _bd=new Ext.grid.ColumnModel(_bc); -_bd.defaultSortable=true; -var _be=new Ext.data.JsonReader({totalProperty:"total",root:"foldercontents",id:"id"},[{name:"id",type:"int"},{name:"icon"},{name:"title"},{name:"filename"},{name:"type"},{name:"tags"},{name:"url"},{name:"write_p"},{name:"title_and_name"},{name:"size"},{name:"lastmodified"}]); -var _bf=new Ext.data.HttpProxy({url:this.xmlhttpurl+"foldercontents"}); -var _c0=new Ext.data.Store({proxy:_bf,reader:_be,remoteSort:true}); -this.filegrid=new Ext.grid.Grid("files",{ds:_c0,cm:_bd,autoHeight:false,autoWidth:true,autoSizeColumns:false,trackMouseOver:true,autoExpandColumn:"filename",enableColumnMove:false,enableColLock:false,enableColumnHide:false,loadMask:true,monitorWindowResize:true,enableDragDrop:true,ddGroup:"fileDD"}); -this.filegrid.on("rowclick",function(){ -this.treepanel.getSelectionModel().getSelectedNode().getUI().removeClass("x-tree-selected"); -this.treepanel.getSelectionModel().getSelectedNode().getUI().addClass("x-tree-grayselected"); -},this,true); -this.filegrid.on("rowdblclick",this.itemDblClick,this,true); -this.filegrid.on("rowcontextmenu",this.showContext,this,true); -var _c1=this.filegrid; -var _c2=this; -var _c3=new Ext.dd.DropTarget(_c1.container,{ddGroup:"fileDD",copy:false,notifyDrop:function(dd,e,_c6){ -var ds=_c1.getDataSource(); -var sm=_c1.getSelectionModel(); -var _c9=sm.getSelections(); -if(dd.getDragData(e)){ -var _ca=dd.getDragData(e).rowIndex; -if(typeof (_ca)!="undefined"){ -if(!this.copy){ -for(i=0;i<_c9.length;i++){ -ds.remove(ds.getById(_c9[i].id)); } } -ds.insert(_ca,_c6.selections); -sm.clearSelections(); +if(_111.indexOf("/")!=-1){ +_111=_111.substring(0,_111.indexOf("/")); +if(_111.charAt(_111.length-1)=="."){ +return false; } } -}}); -this.filegrid.render(); -this.createGridPanel(this.filegrid,"center",{title:acs_lang_text.file_list||"File List",closable:false}); -}; -this.loadTagObjects=function(_cb){ -if(this.filegrid==null){ -this.createFileGrid(); -} -this.treepanel.getSelectionModel().clearSelections(); -var id=_cb.substring(3,_cb.length); -this.filegrid.getDataSource().baseParams["tag_id"]=id; -this.filegrid.getDataSource().load(); -}; -this.loadFoldercontents=function(_cd,e){ -if(this.currentfolder!=null){ -this.treepanel.getNodeById(this.currentfolder).getUI().removeClass("x-tree-grayselected"); -} -if(this.currenttag!=null){ -Ext.get(this.currenttag).setStyle("font-weight","normal"); -} -this.currentfolder=_cd.id; -if(this.filegrid==null){ -this.createFileGrid(); -} -this.filegrid.getDataSource().baseParams["folder_id"]=_cd.id; -this.filegrid.getDataSource().baseParams["tag_id"]=""; -if(_cd.loading){ -_cd.on("expand",function(){ -this.filegrid.getDataSource().load(); -}.createDelegate(this),true,{single:true}); +if(_111.indexOf(":")!=-1){ +if(_111.indexOf(":")==(_111.length-1)){ +return false; }else{ -this.filegrid.getDataSource().load(); +if(_111.charAt(_111.indexOf(":")+1)=="."){ +return false; } -}; -this.renderTree=function(){ -var _cf=function(_d0,_d1,_d2){ -if(_d1){ -rootfolderobj=eval("("+_d2.responseText+")"); -this.rootfolder=new Ext.tree.AsyncTreeNode({text:rootfolderobj.text,draggable:false,id:rootfolderobj.id,singeClickExpand:true,attributes:rootfolderobj.attributes}); -if(rootfolderobj.attributes["write_p"]=="t"){ -this.toolbar=new Ext.Toolbar("headerpanel"); -this.toolbar.addButton({text:acs_lang_text.newfolder||"New Folder",icon:"/resources/ajax-filestorage-ui/icons/folder_add.png",cls:"x-btn-text-icon",handler:this.newFolder.createDelegate(this),scope:this}); -this.toolbar.addButton({text:acs_lang_text.uploadfile||"Upload Files",icon:"/resources/ajax-filestorage-ui/icons/add.png",cls:"x-btn-text-icon",handler:this.showUplddialog.createDelegate(this),scope:this}); -if(create_url_p){ -this.toolbar.addButton({text:acs_lang_text.createurl||"Create Url",icon:"/resources/ajax-filestorage-ui/icons/page_link.png",cls:"x-btn-text-icon",handler:this.showCreateUrldialog.createDelegate(this),scope:this}); } -this.toolbar.addButton({text:acs_lang_text.deletefs||"Delete",icon:"/resources/ajax-filestorage-ui/icons/delete.png",cls:"x-btn-text-icon",handler:this.confirmDel.createDelegate(this),scope:this}); +_111=_111.substring(0,_111.indexOf(":")); +if(_111.charAt(_111.length-1)=="."){ +return false; } -this.toolbar.addButton({text:acs_lang_text.download_archive||"Download Archive",icon:"/resources/ajax-filestorage-ui/icons/arrow_down.png",cls:"x-btn-text-icon",handler:function(){ -top.location.href="download-archive/index?object_id="+rootfolderobj.id; -}.createDelegate(this),scrope:this}); -this.treepanel.setRootNode(this.rootfolder); -this.treepanel.render(); -var _d3=function(x){ -var _d5=this.treepanel.getNodeById(this.config.initOpenFolder); -if(!_d5){ -var x=x+1; -var _d6=this.config.pathToFolder[x]; -var _d7=this.treepanel.getNodeById(_d6); -_d7.on("expand",_d3.createDelegate(this,[x]),this,{single:true}); -_d7.expand(true); -}else{ -_d5.select(); -_d5.fireEvent("click",_d5); } -}; -var _d8=function(){ -if(this.config.initOpenFolder){ -var _d9=this.treepanel.getNodeById(this.config.initOpenFolder); -if(_d9){ -_d9.expand(); -_d9.fireEvent("click",_d9); -}else{ -var x=1; -var _db=this.treepanel.getNodeById(this.config.pathToFolder[x]); -_db.on("expand",_d3.createDelegate(this,[x]),this,{single:true}); -_db.expand(true); +return true; } +function FileProgress(_112,_113){ +this.file_progress_id=_112.id; +this.opacity=100; +this.height=0; +this.fileProgressWrapper=document.getElementById(this.file_progress_id); +if(!this.fileProgressWrapper){ +this.fileProgressWrapper=document.createElement("div"); +this.fileProgressWrapper.className="progressWrapper"; +this.fileProgressWrapper.id=this.file_progress_id; +this.fileProgressElement=document.createElement("div"); +this.fileProgressElement.className="progressContainer"; +var _114=document.createElement("a"); +_114.className="progressCancel"; +_114.href="#"; +_114.style.visibility="hidden"; +_114.appendChild(document.createTextNode(" ")); +var _115=document.createElement("div"); +_115.className="progressName"; +_115.appendChild(document.createTextNode(_112.name)); +var _116=document.createElement("div"); +_116.className="progressBarInProgress"; +var _117=document.createElement("div"); +_117.className="progressBarStatus"; +_117.innerHTML=" "; +this.fileProgressElement.appendChild(_114); +this.fileProgressElement.appendChild(_115); +this.fileProgressElement.appendChild(_117); +this.fileProgressElement.appendChild(_116); +this.fileProgressWrapper.appendChild(this.fileProgressElement); +document.getElementById(_113).appendChild(this.fileProgressWrapper); }else{ -this.treepanel.fireEvent("click",this.rootfolder); +this.fileProgressElement=this.fileProgressWrapper.firstChild; } -}; -this.rootfolder.on("expand",_d8,this,{single:true}); -this.rootfolder.expand(); -}else{ -Ext.Msg.alert(acs_lang_text.error||"Error",acs_lang_text.tree_render_error||"Sorry, we encountered an error rendering the tree panel"); +this.height=this.fileProgressWrapper.offsetHeight; } +FileProgress.prototype.SetProgress=function(_118){ +this.fileProgressElement.className="progressContainer green"; +this.fileProgressElement.childNodes[3].className="progressBarInProgress"; +this.fileProgressElement.childNodes[3].style.width=_118+"%"; }; -var _dc="package_id="+this.config.package_id; -if(this.config.rootfolder){ -_dc=_dc+"&root_folder_id="+this.config.rootfolder; -} -this.asyncCon.request({url:this.xmlhttpurl+"getrootfolder",params:_dc,method:"POST",callback:_cf,scope:this}); +FileProgress.prototype.SetComplete=function(){ +this.fileProgressElement.className="progressContainer blue"; +this.fileProgressElement.childNodes[3].className="progressBarComplete"; +this.fileProgressElement.childNodes[3].style.width=""; +var _119=this; +setTimeout(function(){ +_119.Disappear(); +},10000); }; -this.loadTreepanel=function(){ -var _dd=Ext.get("folderpanel").createChild({tag:"div",id:"folders"}); -this.treepanel=new Ext.tree.TreePanel("folders",{animate:true,loader:new Ext.tree.TreeLoader({dataUrl:this.xmlhttpurl+"loadnodes",baseParams:{package_id:this.config.package_id}}),enableDD:true,ddGroup:"fileDD",ddAppendOnly:true,containerScroll:true,rootVisible:true}); -this.te=new Ext.tree.TreeEditor(this.treepanel,{allowBlank:false,blankText:acs_lang_text.folder_name_required||"A folder name is required",selectOnFocus:true}); -this.te.on("beforestartedit",function(_de,el,_e0){ -if(_de.editNode.attributes.attributes.write_p=="t"){ -return true; -}else{ -Ext.Msg.alert(acs_lang_text.permission_denied||"Permission Denied",acs_lang_text.permission_denied||"Sorry, you do not have permission to rename this folder"); +FileProgress.prototype.SetError=function(){ +this.fileProgressElement.className="progressContainer red"; +this.fileProgressElement.childNodes[3].className="progressBarError"; +this.fileProgressElement.childNodes[3].style.width=""; +var _11a=this; +setTimeout(function(){ +_11a.Disappear(); +},5000); +}; +FileProgress.prototype.SetCancelled=function(){ +this.fileProgressElement.className="progressContainer"; +this.fileProgressElement.childNodes[3].className="progressBarError"; +this.fileProgressElement.childNodes[3].style.width=""; +var _11b=this; +setTimeout(function(){ +_11b.Disappear(); +},2000); +}; +FileProgress.prototype.SetStatus=function(_11c){ +this.fileProgressElement.childNodes[2].innerHTML=_11c; +}; +FileProgress.prototype.ToggleCancel=function(show,_11e){ +this.fileProgressElement.childNodes[0].style.visibility=show?"visible":"hidden"; +if(_11e){ +var _11f=this.file_progress_id; +this.fileProgressElement.childNodes[0].onclick=function(){ +_11e.cancelUpload(_11f); return false; +}; } -},this,true); -this.te.on("beforecomplete",function(_e1,_e2,_e3){ -var _e4=_e1.editNode.parentNode; -var _e5=_e4.childNodes; -for(x=0;x<_e5.length;x++){ -if(_e5[x].text==_e2&&_e5[x].id!=_e1.editNode.id){ -Ext.Msg.alert(acs_lang_text.duplicate_name||"Duplicate Name",acs_lang_text.duplicate_name_error||"Please enter a different name. The name you entered is already being used."); -return false; -} -} -return true; -},this,true); -this.te.on("complete",function(_e6,_e7,_e8){ -var _e9=function(_ea,_eb,_ec){ -var _ed=acs_lang_text.an_error_occurred||"An error occurred"; -var _ee=acs_lang_text.reverted||"Your changes have been reverted"; -if(_eb){ -if(_ec.responseText!=1){ -Ext.Msg.alert(acs_lang_text.error||"Error",_ed+":

    "+_ec.responseText+"

    "+_ee); -_e6.editNode.setText(_e8); -} -}else{ -Ext.Msg.alert(acs_lang_text.error||"Error",_ed+":

    "+_ec.responseText+"

    "+_ee); -_e6.editNode.setText(_e8); -} }; -this.asyncCon.request({url:this.xmlhttpurl+"editname",params:"newname="+_e7+"&object_id="+_e6.editNode.id+"&type=folder",method:"POST",callback:_e9,scope:this}); -},this,true); -this.treepanel.on("click",this.loadFoldercontents,this,true); -this.treepanel.on("nodedragover",function(e){ -if(e.target.id==this.treepanel.getSelectionModel().getSelectedNode().id){ -return false; +FileProgress.prototype.Disappear=function(){ +var _120=15; +var _121=4; +var rate=30; +if(this.opacity>0){ +this.opacity-=_120; +if(this.opacity<0){ +this.opacity=0; } -if(e.source.dragData.selections){ -for(var x=0;x
    "+_fa.responseText+"

    "+_fd); -_fb=true; -} }else{ -Ext.Msg.alert(acs_lang_text.error||"Error",acs_lang_text.error_and_reverted||"An error occurred. Your changes have been reverted"); -_fb=true; +this.fileProgressWrapper.style.opacity=this.opacity/100; } -if(_fb){ -_f8.target.removeChild(_f8.thenode); -_f8.parent.appendChild(_f8.thenode); -_f8.parent.loaded=false; -_f8.parent.expand(); -}else{ -_f8.target.loaded=false; -_f8.target.fireEvent("click",_f8.target); -_f8.target.expand(); } -}; -var _fe="file_ids="+_f5+"&folder_target_id="+_f6; -var url=this.xmlhttpurl+"move"; -this.asyncCon.request({url:url,params:_fe,method:"POST",callback:_f7,scope:this,target:t,parent:p,thenode:n}); -}else{ -var _100=_f1.target.id; -var _101=[]; -for(var x=0;x<_f1.data.selections.length;x++){ -_101[x]=_f1.data.selections[x].data.id; -if(_f1.data.selections[x].data.type=="folder"){ -if(this.treepanel.getNodeById(_f1.data.selections[x].data.id)){ -var _103=this.treepanel.getNodeById(_f1.data.selections[x].data.id).parentNode; -_103.loaded=false; -_103.removeChild(this.treepanel.getNodeById(_f1.data.selections[x].data.id)); +if(this.height>0){ +this.height-=_121; +if(this.height<0){ +this.height=0; } +this.fileProgressWrapper.style.height=this.height+"px"; } -} -var _f7=function(_104,_105,_106){ -if(_105&&_106.responseText==1){ -var dm=this.filegrid.getDataSource(); -var _108=this.filegrid.getSelectionModel().getSelections(); -for(var x=0;x<_108.length;x++){ -dm.remove(_108[x]); -} -_104.target.loaded=false; +if(this.height>0||this.opacity>0){ +var _123=this; +setTimeout(function(){ +_123.Disappear(); +},rate); }else{ -Ext.Msg.alert(acs_lang_text.error||"Error",acs_lang_text.error_move||"Sorry, an error occurred moving this item. A file with the same name may already exist in the target folder."); +this.fileProgressWrapper.style.display="none"; } }; -var _fe="folder_target_id="+_100+"&file_ids="+_101; -var url=this.xmlhttpurl+"move"; -var _10a=new Ext.data.Connection(); -_10a.request({url:url,params:_fe,method:"POST",callback:_f7,scope:this,target:t}); -} -},this,true); -this.renderTree(); -}; -this.initLayout=function(){ -var _10b=document.body; -if(this.config!=null&&this.config.layoutdiv){ -_10b=this.config.layoutdiv; -} -this.layout=new Ext.BorderLayout(_10b,{north:{split:false,titlebar:false,autoScroll:false,initialSize:25},west:{autoScroll:true,split:true,initialSize:350,titlebar:true,collapsible:true,minSize:200,maxSize:500},center:{autoScroll:true}}); -this.innerlayout=new Ext.BorderLayout("leftpanel",{center:{split:true,titlebar:false,autoScroll:true},south:{split:true,titlebar:true,title:"Tags",autoScroll:true,initialSize:130}}); -this.layout.beginUpdate(); -this.layout.add("north",new Ext.ContentPanel("headerpanel",{autoCreate:true})); -this.layout.add("west",new Ext.NestedLayoutPanel(this.innerlayout)); -this.innerlayout.add("center",new Ext.ContentPanel("folderpanel",{autoCreate:true,autoScroll:true,fitToFrame:true,fitContainer:true})); -this.tagcloudpanel=new Ext.ContentPanel("tagpanel",{autoCreate:true,autoScroll:true,fitToFrame:true,fitContainer:true}); -this.innerlayout.add("south",this.tagcloudpanel); -this.tagcloudpanel.load("/ajaxfs2/xmlhttp/tagcloud?package_id="+this.config.package_id); -this.tagcloudpanel.getEl().on("click",function(obj,el){ -if(el.tagName=="A"){ -if(this.currenttag!=null){ -Ext.get(this.currenttag).setStyle("font-weight","normal"); -} -Ext.get(el).setStyle("font-weight","bold"); -this.currenttag=el.id; -this.loadTagObjects(el.id); -} -},this); -this.layout.endUpdate(); -var _10e={autoCreate:true,autoScroll:true,modal:false,autoTabs:true,width:300,height:300,shadow:false,shim:false,minWidth:300,minHeight:300,proxyDrag:true,fixedcenter:true}; -this.upldDialog=new Ext.BasicDialog("uploadDlg",_10e); -this.createurlDialog=new Ext.BasicDialog("urlDlg",_10e); -Ext.get(document.body).createChild({tag:"div",id:"files"}); -}; -this.initObj=function(){ -if(typeof (Ext.DomHelper)!="undefined"){ -if(_3f){ -this.config=_3f; -if(!this.config.ispublic){ -this.asyncCon.on("requestcomplete",this.isSessionExpired,this); -} -} -this.initLayout(); -this.loadTreepanel(); -} -}; -Ext.EventManager.onDocumentReady(this.initObj,this,true); -} Index: openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.css =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.css,v diff -u -r1.3 -r1.4 --- openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.css 8 Sep 2007 14:32:55 -0000 1.3 +++ openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.css 26 Nov 2007 12:52:43 -0000 1.4 @@ -1,84 +1,67 @@ - .x-tree-node img.folder, .x-tree-node-collapsed img.folder{ - background: url(/resources/ajaxhelper/ext/resources/images/default/tree/folder.gif) - } - .x-tree-node-expanded img.folder { - background: url(/resources/ajaxhelper/ext/resources/images/default/tree/folder-open.gif) - } - .x-tree-grayselected a span{ - background:#e2e2e2; - } - .onerow { - padding:5px; - vertical-align: middle; - cursor:pointer; - } - .onerow td a { - text-decoration: none; - color:#000000; - } - #filepanel { - font-family: arial,tahoma,helvetica,sans-serif; - font-size: 11px; - } - #filepanel .x-view-selected { - background-color: #C3DAF9; - } - div.flash - { - width: 80%; - margin: 10px 0px 10px 0px; - border-color: #D9E4FF; - } - .progressName { - font-size: 8pt; - font-weight: bold; - color: #555555; - - width: 80%; - height: 14px; - text-align: left; - white-space: nowrap; - overflow: hidden; - } - .progressBarInProgress, - .progressBarComplete, - .progressBarError { - font-size: 0px; - width: 0%; - height: 2px; - background-color: blue; - margin-top: 2px; - } - .progressBarComplete { - width: 100%; - background-color: green; - visibility: hidden; - } - .progressBarError { - width: 100%; - background-color: red; - visibility: hidden; - } - .progressBarStatus { - margin-top: 2px; - width: 80%; - font-size: 7pt; - font-family: Verdana; - text-align: left; - white-space: nowrap; - } - a.progressCancel, - a.progressCancel:link, - a.progressCancel:active, - a.progressCancel:visited, - a.progressCancel:hover - { - font-size: 0px; - display: block; - height: 20px; - width: 20px; - - background-image: url(/resources/ajax-filestorage-ui/icons/delete.png); - background-repeat: no-repeat; - float: right; - } \ No newline at end of file +.x-tree-node img.folder, .x-tree-node-collapsed img.folder { + background-image:url(/resources/ajaxhelper/ext/resources/images/default/tree/folder.gif); +} +div.flash { + width: 80%; + margin: 10px 0px 10px 0px; + border-color: #D9E4FF; +} +.progressContainer { + margin:5px; +} +.progressName { + font-size: 8pt; + font-weight: bold; + color: #555555; + + width: 80%; + height: 14px; + text-align: left; + white-space: nowrap; + overflow: hidden; +} +.progressBarInProgress, +.progressBarComplete, +.progressBarError { + font-size: 0px; + width: 0%; + height: 2px; + background-color: blue; + margin-top: 2px; +} +.progressBarComplete { + width: 100%; + background-color: green; + visibility: hidden; +} +.progressBarError { + width: 100%; + background-color: red; + visibility: hidden; +} +.progressBarStatus { + margin-top: 2px; + width: 80%; + font-size: 7pt; + font-family: Verdana; + text-align: left; + white-space: nowrap; +} +a.progressCancel, +a.progressCancel:link, +a.progressCancel:active, +a.progressCancel:visited, +a.progressCancel:hover { + font-size: 0px; + display: block; + height: 20px; + width: 20px; + background-image: url(/resources/ajaxhelper/icons/delete.png); + background-repeat: no-repeat; + float: right; +} + +.yui-skin-sam .yui-ac-input { + position:absolute; + width:80%; +} \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.js,v diff -u -r1.5 -r1.6 --- openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.js 14 Nov 2007 04:19:54 -0000 1.5 +++ openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.js 26 Nov 2007 12:52:43 -0000 1.6 @@ -1,650 +1,562 @@ /* - Ajax File Storage + Ajax File Storage 1.0 @author Hamilton Chua (ham@solutiongrove.com) - @creation-date 2007-06-03 + @creation-date 2007-11-18 + */ -/********** UTILS *********************/ +/********** AJAXFS Class ***********/ -/* readCookie -read value of a cookie */ -function readCookie(name) { - var ca = document.cookie.split(';'); - var nameEQ = name + "="; - for(var i=0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces - if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); - } - return null; -} +Ext.namespace('ajaxfs'); +Ext.BLANK_IMAGE_URL = '/resources/ajaxhelper/ext2/resources/images/default/s.gif'; -/* createCookie -used to maintain state, e.g. when login expires */ -function createCookie(name, value, days){ - if (days) { - var date = new Date(); - date.setTime(date.getTime()+(days*24*60*60*1000)); - var expires = "; expires="+date.toGMTString(); - } - else var expires = ""; - document.cookie = name+"="+value+expires+"; path=/"; -} +ajaxfs = function(configObj) { -/* read query string -read the value of a querystring */ -function readQs(q) { - var query = window.location.search.substring(1); - var parms = query.split('&'); - for (var i=0; i 0) { - var key = parms[i].substring(0,pos); - var val = parms[i].substring(pos+1); - if (key == q) { - return val; - } - } - } - return null; -} + // ******** properties ********* -/* check Flash Version */ -function checkFlashVersion() { + // ** configObj ** + // ajaxFs expects a config object that may have the following properites + // - configObj.package_ids : the package_id or a comma separated list of package_ids of the current ajaxFs Instance + // - configObj.initOpenFolder : if this value is not null, it should contain the folder id to open when object is instantiated + // - configObj.layoutdiv : the div container where we put the layout, if none is provided then document.body is used + // - configObj.xmlhttpurl : just in case ajaxfs is mounted elsewhere other than /ajaxfs + // - configObj.createUrl : do we show the createurl button in the toolbar - var x; - var pluginversion; + // ** properties ** - if(navigator.plugins && navigator.mimeTypes.length){ - x = navigator.plugins["Shockwave Flash"]; - if(x && x.description) x = x.description; - } else if (Ext.isIE){ - try { - x = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); - x = x.GetVariable("$version"); - } catch(e){} - } + // url of xmlhttp files from ajaxfs, defaults to /ajaxfs/xmlhttp + this.xmlhttpurl = '/ajaxfs/xmlhttp/'; - pluginVersion = (typeof(x) == 'string') ? parseInt(x.match(/\d+/)[0]) : 0; + // do we or do we not allow creating url's in fs, defaults to true + this.create_url_p = true; - return pluginVersion; -} + // holds an object with configruation settings for this instance + // of ajaxfs, this variable is set only if configObj exists and is passed + this.config = null; -// check if the string argument is a url -function isURL(argvalue) { + // holds a reference to the layout for the center page + this.layout = null; + + // reference to the tree edito for the treepanel + this.te = null; - if (argvalue.indexOf(" ") != -1) - return false; - else if (argvalue.indexOf("http://") == -1) - return false; - else if (argvalue == "http://") - return false; - else if (argvalue.indexOf("http://") > 0) - return false; + // holds the id of the currently selected node in the tree + this.currentfolder = null; - argvalue = argvalue.substring(7, argvalue.length); - if (argvalue.indexOf(".") == -1) - return false; - else if (argvalue.indexOf(".") == 0) - return false; - else if (argvalue.charAt(argvalue.length - 1) == ".") - return false; + // currently selected tag + this.currenttag = null; - if (argvalue.indexOf("/") != -1) { - argvalue = argvalue.substring(0, argvalue.indexOf("/")); - if (argvalue.charAt(argvalue.length - 1) == ".") - return false; - } + // reusable aync data connection + this.asyncCon = new Ext.data.Connection(); - if (argvalue.indexOf(":") != -1) { - if (argvalue.indexOf(":") == (argvalue.length - 1)) - return false; - else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".") - return false; - argvalue = argvalue.substring(0, argvalue.indexOf(":")); - if (argvalue.charAt(argvalue.length - 1) == ".") - return false; - } + // reference to messagebox + this.msgbox = Ext.MessageBox; - return true; + // create upload dialog + this.upldWindow = null; -} + // tagdialog + this.tagWindow = null; -/********** FLASH UPLOAD *********/ + // create ur dialog + this.createurlWindow = null; + // reference to contextmenu + this.contextmenu = null; -function FileProgress(fileObj, target_id) { - this.file_progress_id = fileObj.id; + // reference to an instance of the swfuploader + // used for ajaxfs + this.swfu = null; - this.opacity = 100; - this.height = 0; - this.fileProgressWrapper = document.getElementById(this.file_progress_id); - if (!this.fileProgressWrapper) { - this.fileProgressWrapper = document.createElement("div"); - this.fileProgressWrapper.className = "progressWrapper"; - this.fileProgressWrapper.id = this.file_progress_id; + //********* initialize ********* - this.fileProgressElement = document.createElement("div"); - this.fileProgressElement.className = "progressContainer"; + this.initObj = function() { - var progressCancel = document.createElement("a"); - progressCancel.className = "progressCancel"; - progressCancel.href = "#"; - progressCancel.style.visibility = "hidden"; - progressCancel.appendChild(document.createTextNode(" ")); + // check if ExtJs is loaded before anything else - var progressText = document.createElement("div"); - progressText.className = "progressName"; - progressText.appendChild(document.createTextNode(fileObj.name)); + if (typeof(Ext.DomHelper) != "undefined") { - var progressBar = document.createElement("div"); - progressBar.className = "progressBarInProgress"; + // ExtJs is loaded + // check for config + if (configObj) { - var progressStatus = document.createElement("div"); - progressStatus.className = "progressBarStatus"; - progressStatus.innerHTML = " "; + this.config = configObj; + if(this.config.xmlhttpurl) { this.xmlhttpurl = this.config.xmlhttpurl } + if(this.config.create_url && this.config.create_url == 0) { this.create_url_p = false } - this.fileProgressElement.appendChild(progressCancel); - this.fileProgressElement.appendChild(progressText); - this.fileProgressElement.appendChild(progressStatus); - this.fileProgressElement.appendChild(progressBar); + // generic listener to check if + // the connection has returned a login form + // in which case we need to redirect the user + // to a login form + // this listener is activated only if the fs instance + // is not a public instance - this.fileProgressWrapper.appendChild(this.fileProgressElement); + if(!this.config.ispublic) { + Ext.Ajax.on("requestcomplete", this.isSessionExpired, this); + } + + } - document.getElementById(target_id).appendChild(this.fileProgressWrapper); - } else { - this.fileProgressElement = this.fileProgressWrapper.firstChild; - } + // initialize tooltips + Ext.QuickTips.init(); - this.height = this.fileProgressWrapper.offsetHeight; + // setup the layout and panels + this.initLayout(); -} -FileProgress.prototype.SetProgress = function(percentage) { - this.fileProgressElement.className = "progressContainer green"; - this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; - this.fileProgressElement.childNodes[3].style.width = percentage + "%"; -} -FileProgress.prototype.SetComplete = function() { - this.fileProgressElement.className = "progressContainer blue"; - this.fileProgressElement.childNodes[3].className = "progressBarComplete"; - this.fileProgressElement.childNodes[3].style.width = ""; + } - var oSelf = this; - setTimeout(function() { oSelf.Disappear(); }, 10000); -} -FileProgress.prototype.SetError = function() { - this.fileProgressElement.className = "progressContainer red"; - this.fileProgressElement.childNodes[3].className = "progressBarError"; - this.fileProgressElement.childNodes[3].style.width = ""; + } - var oSelf = this; - setTimeout(function() { oSelf.Disappear(); }, 5000); -} -FileProgress.prototype.SetCancelled = function() { - this.fileProgressElement.className = "progressContainer"; - this.fileProgressElement.childNodes[3].className = "progressBarError"; - this.fileProgressElement.childNodes[3].style.width = ""; + Ext.onReady(this.initObj,this,true); - var oSelf = this; - setTimeout(function() { oSelf.Disappear(); }, 2000); } -FileProgress.prototype.SetStatus = function(status) { - this.fileProgressElement.childNodes[2].innerHTML = status; -} -FileProgress.prototype.ToggleCancel = function(show, upload_obj) { - this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden"; - if (upload_obj) { - var file_id = this.file_progress_id; - this.fileProgressElement.childNodes[0].onclick = function() { upload_obj.cancelUpload(file_id); return false; }; - } -} +ajaxfs.prototype = { -FileProgress.prototype.Disappear = function() { + // check if login has expired - var reduce_opacity_by = 15; - var reduce_height_by = 4; - var rate = 30; // 15 fps + isSessionExpired : function(conn,response,options) { - if (this.opacity > 0) { - this.opacity -= reduce_opacity_by; - if (this.opacity < 0) this.opacity = 0; - - if (this.fileProgressWrapper.filters) { - try { - this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity; - } catch (e) { - // If it is not set initially, the browser will throw an error. This will set it if it is not set yet. - this.fileProgressWrapper.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + this.opacity + ')'; + // check if we are still logged in + if ( readCookie("ad_user_login") == null ) { + Ext.get(document.body).mask(acs_lang_text.sessionexpired || "Your session has expired. You need to login again.
    You will be redirected to a login page shortly"); + var params = ''; + if(this.currentfolder != null) { + var params = "?folder_id="+this.currentfolder; } - } else { - this.fileProgressWrapper.style.opacity = this.opacity / 100; + window.location="/register/?return_url="+this.config.package_url+params; } - } - if (this.height > 0) { - this.height -= reduce_height_by; - if (this.height < 0) this.height = 0; + }, - this.fileProgressWrapper.style.height = this.height + "px"; - } + // recursive expand in case folder id is not on the first level + asyncExpand : function(x) { + var treepanel = this.layout.findById('treepanel'); + var node = treepanel.getNodeById(this.config.initOpenFolder); + if(!node) { + var x = x+1; + var nextnodeid = this.config.pathToFolder[x]; + var nextnode = treepanel.getNodeById(nextnodeid); + nextnode.on("expand",asyncExpand.createDelegate(this,[x]), this, {single:true}); + nextnode.expand(true); + } else { + node.select() + node.fireEvent("click",node); + } + }, - if (this.height > 0 || this.opacity > 0) { - var oSelf = this; - setTimeout(function() { oSelf.Disappear(); }, rate); - } else { - this.fileProgressWrapper.style.display = "none"; - } -} + // if we get an initOpenFolder config, + // expand the provided initOpenFolder id + selectInitFolder : function() { + var treepanel = this.layout.findById('treepanel'); + if(this.config.initOpenFolder) { + var initNode = treepanel.getNodeById(this.config.initOpenFolder); + if(initNode) { + initNode.expand(); + initNode.fireEvent("click",initNode) + } else { + // recursively expand based on the list of folder_ids in pathToFolder + var x = 1; + var nextnode = treepanel.getNodeById(this.config.pathToFolder[x]); + nextnode.on("expand",this.asyncExpand.createDelegate(this,[x]), this, {single:true}); + nextnode.expand(true); + } + } else { + treepanel.fireEvent("click",treepanel.getRootNode()); + } + }, -function uploadStart(fileObj,ajaxfsobj) { - var upload_txt = acs_lang_text.for_upload_to || "for upload to"; - var zip_txt = acs_lang_text.zip_extracted || "Zip File (Will be extracted after upload)"; - try { - // You might include code here that prevents the form from being submitted while the upload is in - // progress. Then you'll want to put code in the Queue Complete handler to "unblock" the form - var folderid = ajaxfsobj.currentfolder; - var foldername = ajaxfsobj.treepanel.getNodeById(folderid).text; - var progress = new FileProgress(fileObj, this.getSetting("progress_target")); - progress.SetStatus( upload_txt + ""+foldername+"
    Title: (optional)
    "+ zip_txt); - progress.ToggleCancel(true, this); - this.addFileParam(fileObj.id, "folder_id", folderid); - ajaxfsobj.upldDialog.buttons[0].enable(); - } catch (ex) { this.debugMessage(ex); } -} + // creates the main layout for ajaxfs -function uploadProgress(fileObj, bytesLoaded) { - try { - var percent = Math.ceil((bytesLoaded / fileObj.size) * 100) - var progress = new FileProgress(fileObj, this.getSetting("progress_target")); - progress.SetProgress(percent); - progress.SetStatus(acs_lang_text.uploading || "Uploading..."); - } catch (ex) { this.debugMessage(ex); } -} + initLayout : function() { -function uploadFileComplete(fileObj) { - try { - var progress = new FileProgress(fileObj, this.getSetting("progress_target")); - progress.SetComplete(); - progress.SetStatus(acs_lang_text.complete || "Complete."); - progress.ToggleCancel(false); + /* Load the UI in document.body if a layoutdiv is not provided */ - } catch (ex) { this.debugMessage(ex); } -} + var layoutitems = [this.createLeft(),this.createRight()] -function uploadComplete(fileObj) { - try { - var progress = new FileProgress(fileObj, this.getSetting("progress_target")); - progress.SetComplete(); - progress.SetStatus(acs_lang_text.complete || "Complete."); - progress.ToggleCancel(false); + if (this.config != null && this.config.layoutdiv) { - } catch (ex) { this.debugMessage(ex); } -} + this.layout = new Ext.Panel({ + id:"fs-ui", + layout:'border', + applyTo:this.config.layoutdiv, + tbar:this.createToolbar(), + items: layoutitems + }) -function uploadQueueComplete(fileidx,ajaxfsobj) { - ajaxfsobj.upldDialog.buttons[0].disable(); - var currentTreeNode = ajaxfsobj.treepanel.getNodeById(ajaxfsobj.currentfolder); - currentTreeNode.fireEvent("click",currentTreeNode); -} + } else { -function uploadError(error_code, fileObj, message) { - try { - if (error_code == SWFUpload.ERROR_CODE_QUEUE_LIMIT_EXCEEDED) { - Ext.Msg.alert(acs_lang_text.alert || "Alert","You have attempted to queue too many files.\n" + (message == 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file."))); - return; + this.layout = new Ext.Viewport({ + id:"fs-ui", + layout:'border', + tbar:this.createToolbar(), + items: layoutitems + }); + } - var progress = new FileProgress(fileObj, this.getSetting("progress_target")); - progress.SetError(); - progress.ToggleCancel(false); + }, - switch(error_code) { - case SWFUpload.ERROR_CODE_HTTP_ERROR: - progress.SetStatus("Upload Error"); - this.debugMessage("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message); - break; - case SWFUpload.ERROR_CODE_MISSING_UPLOAD_TARGET: - progress.SetStatus("Configuration Error"); - this.debugMessage("Error Code: No backend file, File name: " + file.name + ", Message: " + message); - break; - case SWFUpload.ERROR_CODE_UPLOAD_FAILED: - progress.SetStatus("Upload Failed."); - this.debugMessage("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); - break; - case SWFUpload.ERROR_CODE_IO_ERROR: - progress.SetStatus("Server (IO) Error"); - this.debugMessage("Error Code: IO Error, File name: " + file.name + ", Message: " + message); - break; - case SWFUpload.ERROR_CODE_SECURITY_ERROR: - progress.SetStatus("Security Error"); - this.debugMessage("Error Code: Security Error, File name: " + file.name + ", Message: " + message); - break; - case SWFUpload.ERROR_CODE_FILE_EXCEEDS_SIZE_LIMIT: - progress.SetStatus("File is too big."); - this.debugMessage("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); - break; - case SWFUpload.ERROR_CODE_ZERO_BYTE_FILE: - progress.SetStatus("Cannot upload Zero Byte files."); - this.debugMessage("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); - break; - case SWFUpload.ERROR_CODE_UPLOAD_LIMIT_EXCEEDED: - progress.SetStatus("Upload limit exceeded."); - this.debugMessage("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); - break; - default: - progress.SetStatus("Unhandled Error"); - this.debugMessage("Error Code: " + error_code + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); - break; + // create the toolbar for this instance of ajaxfs + + createToolbar : function() { + var rootnode = this.config.treerootnode; + var toolbar = []; + if(rootnode.attributes["write_p"] == 't') { + var toolbar = [ + ' ', + {text: acs_lang_text.newfolder || 'New Folder', tooltip: acs_lang_text.newfolder || 'New Folder', icon: '/resources/ajaxhelper/icons/folder_add.png', cls : 'x-btn-text-icon', handler: this.addFolder.createDelegate(this)}, + {text: acs_lang_text.uploadfile || 'Upload Files', tooltip: acs_lang_text.uploadfile || 'Upload Files', icon: '/resources/ajaxhelper/icons/page_add.png', cls : 'x-btn-text-icon', handler: this.addFile.createDelegate(this)} + ]; + if(this.create_url_p) { + toolbar.push({text: acs_lang_text.createurl || 'Create Url',tooltip: acs_lang_text.createurl || 'Create Url', icon: '/resources/ajaxhelper/icons/page_link.png', cls : 'x-btn-text-icon', handler: this.addUrl.createDelegate(this)}); + } + toolbar.push({text: acs_lang_text.deletefs || 'Delete', tooltip: acs_lang_text.deletefs || 'Delete', icon: '/resources/ajaxhelper/icons/delete.png', cls : 'x-btn-text-icon', handler: this.delItem.createDelegate(this)}); + toolbar.push('->'); } - } catch (ex) { - this.debugMessage(ex); - } -} + toolbar.push({tooltip: 'This may take a few minutes if you have a lot of files', text: acs_lang_text.download_archive || 'Download Archive', icon: '/resources/ajaxhelper/icons/arrow_down.png', cls : 'x-btn-text-icon', handler: this.downloadArchive.createDelegate(this,[rootnode.id],false)}); + return toolbar; + }, -function uploadCancel(fileObj) { - try { - var progress = new FileProgress(fileObj, this.getSetting("progress_target")); - progress.SetCancelled(); - progress.SetStatus(acs_lang_text.uploadcancel || "Cancelled (This item will be removed shortly)"); - progress.ToggleCancel(false); + // creates the left panel as an accordon, top panel has the folders, bottom panel has the tags - } - catch (ex) { - this.debugMessage(ex); - } -} + createLeft : function() { + var panel = new Ext.Panel ({ + id:'leftpanel', + region:'west', + collapsible:true, + titlebar:true, + title:' ', + layout:'accordion', + split:true, + width:300, + items:[this.createTreePanel(),this.createTagPanel()] + }); + return panel; + }, -/********** AjaxFS Objects ***********/ + // creates the right panel which lists the files inside a folder -function ajaxfs(configObj) { + createTreePanel : function() { - // ** configObj ** - // ajaxFs expects a config object that may have the following properites - // configObj.package_ids : the package_id or a comma separated list of package_ids of the current ajaxFs Instance - // configObj.initOpenFolder : if this value is not null, it should contain the folder id to open when object is instantiated - // configOjb.layoutdiv : the div container where we put the layout, if none is provided then document.body is used + // build the tree - // ** properties ** + var rootnode = new Ext.tree.AsyncTreeNode({ + text: this.config.treerootnode.text, + draggable:false, + id:this.config.treerootnode.id, + singeClickExpand: true, + expanded:true, + attributes: this.config.treerootnode.attributes + }); - // where to get + var loader = new Ext.tree.TreeLoader({ + dataUrl:this.xmlhttpurl+'load-treenodes', + baseParams: { package_id:this.config.package_id } + }); - // url of xmlhttp files from ajaxfs - this.xmlhttpurl = '/ajaxfs2/xmlhttp/'; + var treepanel = new Ext.tree.TreePanel({ + id:'treepanel', + title:'Folders', + autoScroll:true, + animate:true, + enableDrag:false, + enableDrop:true, + loadMask:true, + loader: loader, + root: rootnode, + ddAppendOnly: true, + containerScroll: true, + dropConfig: { + dropAllowed: true, + ddGroup:'fileDD', + onNodeOver : function(treenode,source,e,data) { - // holds an object with configruation settings for this instance - // of ajaxfs, this variable is set only if configObj exists and is passed - this.config = null; + // DO NOT ALLOW DROP TO CURRENT FOLDER + // check if the id of target node to be dropped + // is the same as the currently selected tree node + if (treenode.node.id == treenode.node.ownerTree.getSelectionModel().getSelectedNode().id) { + return false; + } - // holds a reference to the layout for the center page - this.layout = null; + // DO NOT ALLOW TO DROP A FOLDER TO ITSELF IN THE TREE + // check if the id of any of the nodes to be dropped + // is the same as the id on the tree + if(source.dragData.selections) { + for (var x=0; x"+err_msg_txt2); + } + } + + Ext.Ajax.request({ + url:this.xmlhttpurl+"move-fsitem", + success: moveSuccess, failure: function() { + // ajax failed, revert value + Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt+"
    "+err_msg_txt2); + }, params: { folder_target_id:folder_target_id,file_ids:file_ids } + }); - // currently selected tag - this.currenttag = null; + return true; - // reusable aync data connection - this.asyncCon = new Ext.data.Connection(); + }.createDelegate(this) + } + }); - // reference to messagebox - this.msgbox = Ext.MessageBox; + // ** allow renaming folders on tree ** - // create upload dialog - this.upldDialog = null; + this.enableTreeFolderRename(treepanel); - // create ur dialog - this.createurlDialog = null; + // ** listeners ** - // permissions dialog - this.permsDialog = null; + rootnode.on("expand",this.selectInitFolder,this,{single:true}); - /// revisions dialog - this.revisionsDialog = null; + treepanel.on("click",this.loadFoldercontents,this); - // reference to contextmenu - this.contextmenu = null; + return treepanel; + }, - // reference to an instance of the swfuploader - // used for ajaxfs - this.swfu = null; + // enable renaming of tree folder + enableTreeFolderRename : function(treepanel) { - // ** methods ** + // ** create editor *** - // check if the string has the login form - // redirects to login form if true, does nothing if not - this.isSessionExpired = function() { - // check if the string has method="post" name="login" - if ( readCookie("ad_user_login") == null ) { - Ext.get(document.body).mask(acs_lang_text.sessionexpired || "Your session has expired. You need to login again.
    You will be redirected to a login page shortly"); - var params = "package_id="+this.config.package_id; - if(this.currentfolder != null) { - params = params + "&folder_id="+this.currentfolder; - } - window.location="/register/?return_url="+window.location; - return 1 - } - return 0 - } + this.te = new Ext.tree.TreeEditor(treepanel, { + allowBlank:false, + blankText: acs_lang_text.folder_name_required || 'A folder name is required', + editDelay:20, + ignoreNoChange:true + }); - // check the permissions, returns either true or false - this.isPermitted = function(objid,perm) { - - var callback = function(option,success,response) { - if(success) { - return response.responseText; + // ** listeners ** + + // check if user has premission to rename + // permissions are checked again on the server when request is submitted + this.te.on("beforestartedit", function(node,el,oldname) { + if (node.editNode.attributes.attributes.write_p == "t") { + return true; } else { - return 0; + Ext.Msg.alert(acs_lang_text.permission_denied || "Permission Denied", acs_lang_text.permission_denied || "Sorry, you do not have permission to rename this folder"); + return false; } - } + }, this, true); - this.asyncCon.request({url:this.xmlhttpurl+"checkperms", - params: "object_id="+objid+"&perm="+perm, - method:"POST", - callback: callback, - scope: this - }); + // reject if the folder name is already being used by a sibling + this.te.on("beforecomplete",function(node,newval,oldval) { + var parent = node.editNode.parentNode; + if(parent) { + var children = parent.childNodes; + for(x=0;x
    "+resultObj.error+"

    "+err_msg_txt2); + node.editNode.setText(oldval); + } + }, failure: function() { + // ajax failed, revert value + Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt+"
    "+err_msg_txt2); + node.editNode.setText(oldval); + }, params: { newname:newval, object_id:node.editNode.id, type:"folder" } }); - var prompt_text_el = YAHOO.util.Dom.getElementsByClassName('ext-mb-input', 'input','x-msg-box'); - prompt_text_el[0].select(); - } - } + + }, this, true); - // rename a file or folder in the right panel - this.fileRename = function() { + }, - var node = this.filegrid.getSelectionModel().getSelected(); - var nodeurl = node.get("url"); - var nodetype = node.get("type"); - var nodeid = node.get("id"); - var nodesubtitle = node.get("filename"); + // creates the right panel which lists the files inside a folder - var handleRename = function(btn, text) { - if(btn=='ok') { - if(text != '') { - if(text.length > 100) { - Ext.Msg.alert(acs_lang_text.alert || "Alert",acs_lang_text.limitto100 || "Please limit your name to 100 characters or less."); - return false; - } else { - var callback = function(option,success,response) { - var err_msg_txt = acs_lang_text.an_error_occurred || "An error occurred"; - var err_msg_txt2 = acs_lang_text.reverted || "Your changes have been reverted"; - if (success) { - if (response.responseText != 1) { - Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt + ":

    "+response.responseText+"

    "+err_msg_txt2); - } else { - if(nodetype!="folder"&&nodesubtitle===" ") { - nodesubtitle = node.get("title"); - node.set("filename",nodesubtitle); - } - if(nodetype=="folder") { this.treepanel.getNodeById(nodeid).setText(text) } - nodetags = node.get("tags"); - if(nodetags != "") { - var taghtml = "
    Tags:
    "+nodetags+"
    "; - } else { - var taghtml = "
    ";; - } - node.set("title",text); - node.set("title_and_name",""+text+"
    "+nodesubtitle+""+taghtml) - node.commit(); - } - } else { - Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt+":

    "+response.responseText+"

    "+err_msg_txt2); - } - } - - this.asyncCon.request({url:this.xmlhttpurl+"editname", - params: "newname="+text+"&object_id="+nodeid+"&type="+nodetype+"&url="+nodeurl, - method:"POST", - callback: callback, - scope: this - }); - } - } else { - Ext.Msg.alert(acs_lang_text.alert || "Alert",acs_lang_text.enter_new_name || "Please enter a new name."); - return false; + createTagPanel : function() { + + var panel = new Ext.Panel({ + id:'tagcloudpanel', + title:'Tags', + frame:false, + loadMask:true, + autoLoad:{url:this.xmlhttpurl+'get-tagcloud',params:{package_id:this.config.package_id}} + }); + + var listenTagClick = function() { + + var ajaxfsObj = this; + var currenttag = ajaxfsObj.currenttag; + + panel.body.on("click",function(obj,el) { + if(el.tagName == "A") { + if (currenttag != null) { Ext.get(currenttag).setStyle('font-weight','normal') } + Ext.get(el).setStyle('font-weight','bold'); + currenttag = el.id; + this.loadTaggedFiles(el.id); } - } + },this); + } - // Ext.MessageBox.prompt('Rename', 'Please enter a new name for
    '+view.jsonData[node.nodeIndex].title+':', handleRename.createDelegate(this)); - Ext.Msg.show({ - title: acs_lang_text.rename || 'Rename', - prompt: true, - msg: acs_lang_text.enter_new_name || 'Please enter a new name for ... ', - value: node.get("title"), - buttons: Ext.Msg.OKCANCEL, - fn: handleRename.createDelegate(this) - }); - var prompt_text_el = YAHOO.util.Dom.getElementsByClassName('ext-mb-input', 'input','x-msg-box'); - prompt_text_el[0].select(); - } + panel.on("render", listenTagClick,this); - // permissions dialog - this.permsRedirect = function() { - var node = this.filegrid.getSelectionModel().getSelected(); - var object_id = node.get("id"); - var newwindow = window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"permissions?object_id="+object_id+"&return_url="+window.location.pathname+"?package_id="+this.config.package_id+"&folder_id="+this.currentfolder); - newwindow.focus(); - } + return panel; + }, - // redirect to file properties - this.propertiesRedirect = function() { - var node = this.filegrid.getSelectionModel().getSelected(); - var object_id = node.get("id"); - var newwindow = window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"file?file_id="+object_id); - newwindow.focus(); - } + // loads the objects associted with a tag + loadTaggedFiles : function (tagid) { - // redirect to object views for a file - this.viewsRedirect = function() { - var node = this.filegrid.getSelectionModel().getSelected(); - var object_id = node.get("id"); - window.open(window.location.protocol+"//"+window.location.hostname+"/o/"+object_id+"/info"); - window.focus(); - } + this.layout.findById("treepanel").getSelectionModel().clearSelections(); + var id = tagid.substring(3,tagid.length); + this.layout.findById("filepanel").store.baseParams['tag_id'] = id; + this.layout.findById("filepanel").store.load(); + this.layout.findById("filepanel").store.baseParams['tag_id'] = ''; + }, - // prompt to enter a tag for the selected fs element - this.promptTag = function() { - var ajaxfsobj = this; - var node = ajaxfsobj.filegrid.getSelectionModel().getSelected(); - var object_id = node.get("id"); + // creates the right panel which lists the files inside a folder + createRight : function() { - Ext.Msg.prompt('Tag', 'Enter or edit one or more tags. Seperate tags with commas (,):', function(btn, text) { - if (btn == 'ok') { - // process text value ... - var callback = function(option,success,response) { - if(success) { - node.set('tags',text); - Ext.get("tagscontainer_"+object_id).update("Tag:"+text+""); - this.tagcloudpanel.load("/ajaxfs2/xmlhttp/tagcloud?package_id="+this.config.package_id); + var cols = [{header: "", width: 30,sortable: true, dataIndex: 'icon'}, + {header: acs_lang_text.filename || "Filename", id:'filename', sortable: true, dataIndex: 'title'}, + {header: acs_lang_text.size || "Size", sortable: true, dataIndex: 'size'}, + {header: acs_lang_text.lastmodified || "Last Modified", sortable: true, dataIndex: 'lastmodified'}]; + + var reader = new Ext.data.JsonReader( + {totalProperty: 'total', root: 'foldercontents', id: 'id'}, [ + {name:'id', type: 'int'}, + {name:'icon'}, + {name:'title'}, + {name:'filename'}, + {name:'type'}, + {name:'tags'}, + {name:'url'}, + {name:'write_p'}, + {name:'size'}, + {name:'lastmodified'}] ); + + + var proxy = new Ext.data.HttpProxy( { + url : this.xmlhttpurl+ 'get-foldercontents' + } ); + + + var colModel = new Ext.grid.ColumnModel(cols); + + var dataModel = new Ext.data.Store({proxy: proxy, reader: reader, remoteSort: true}); + + var gridpanel = new Ext.grid.GridPanel( { + store: dataModel, + cm: colModel, + id:'filepanel', + ddGroup:'fileDD', + region:'center', + split:true, + autoScroll:true, + autoExpandColumn:'filename', + collapsible:true, + enableDragDrop:true, + width:250, + loadMask:true, + frame:false, + viewConfig: { + forceFit: false, + enableRowBody:true, + showPreview:true, + getRowClass: function(record,rowIndex,p,ds) { + var xf = Ext.util.Format; + if (record.data.tags!= "") { + p.body = "
    Tags: " + xf.ellipsis(xf.stripTags(record.data.tags), 200) + "
    "; + } else { + p.body = "
    "; } + return 'x-grid3-row-expanded'; } - ajaxfsobj.asyncCon.request({url:ajaxfsobj.xmlhttpurl+"addtag", - params: "object_id="+object_id+"&tags="+text+"&package_id="+ajaxfsobj.config.package_id, - method:"POST", - callback: callback, - scope: ajaxfsobj - }); } }); - if (document.getElementById("tagslist_"+object_id)) { - var prompt_text_el = YAHOO.util.Dom.getElementsByClassName('ext-mb-input', 'input','x-msg-box'); - prompt_text_el[0].value=document.getElementById("tagslist_"+object_id).innerHTML; - prompt_text_el[0].select(); - } + // listeners - } + gridpanel.on("rowdblclick",this.openItem,this,true); - // download archive function - this.downloadArchive = function() { - var node = this.filegrid.getSelectionModel().getSelected(); - var object_id = node.get("id"); - top.location.href="download-archive/?object_id="+object_id; - } + gridpanel.on("rowcontextmenu",this.showRowContext,this,true); - // generate a context bar - this.showContext = function(grid,i,e) { + return gridpanel; + }, + + // generate the contextbar for the file panel + showRowContext : function(grid,i,e) { + e.stopEvent(); - var dm = grid.getDataSource(); + var dm = grid.store; var record = dm.getAt(i); var object_type = record.get("type"); var recordid = record.get("id"); @@ -661,48 +573,48 @@ items: [ new Ext.menu.Item({ text: openitem_txt, - icon: "/resources/ajax-filestorage-ui/icons/page_white.png", - handler: this.itemDblClick.createDelegate(this,[grid, i, e],false) + icon: '/resources/ajaxhelper/icons/page_white.png', + handler: this.openItem.createDelegate(this,[grid, i, e],false) }), new Ext.menu.Item({ text: 'Tag', - icon: '/resources/ajax-filestorage-ui/icons/tag_blue.png', - handler: this.promptTag.createDelegate(this) + icon: '/resources/ajaxhelper/icons/tag_blue.png', + handler: this.tagFsitem.createDelegate(this,[grid, i, e],false) }), new Ext.menu.Item({ text: 'Views', - icon: '/resources/ajax-filestorage-ui/icons/camera.png', - handler: this.viewsRedirect.createDelegate(this) + icon: '/resources/ajaxhelper/icons/camera.png', + handler: this.redirectViews.createDelegate(this,[grid, i, e],false) }), new Ext.menu.Item({ text: acs_lang_text.deletefs || 'Delete', - icon: '/resources/ajax-filestorage-ui/icons/delete.png', - handler: this.confirmDel.createDelegate(this) + icon: '/resources/ajaxhelper/icons/delete.png', + handler: this.delItem.createDelegate(this,[grid,i,e],false) }), new Ext.menu.Item({ text: acs_lang_text.rename || 'Rename', - icon: '/resources/ajax-filestorage-ui/icons/page_edit.png', - handler: this.fileRename.createDelegate(this) + icon: '/resources/ajaxhelper/icons/page_edit.png', + handler: this.renameItem.createDelegate(this,[grid,i,e],false) }), new Ext.menu.Item({ text: acs_lang_text.linkaddress || 'Copy Link Address', - icon: '/resources/ajax-filestorage-ui/icons/page_copy.png', - handler: this.linkCopy.createDelegate(this) + icon: '/resources/ajaxhelper/icons/page_copy.png', + handler: this.copyLink.createDelegate(this,[grid,i,e],false) }), new Ext.menu.Item({ text: acs_lang_text.permissions || 'Permissions', - icon: '/resources/ajax-filestorage-ui/icons/group_key.png', - handler: this.permsRedirect.createDelegate(this) + icon: '/resources/ajaxhelper/icons/group_key.png', + handler: this.redirectPerms.createDelegate(this,[grid, i, e],false) }), new Ext.menu.Item({ text: acs_lang_text.properties || 'Properties', - icon: '/resources/ajax-filestorage-ui/icons/page_edit.png', - handler: this.propertiesRedirect.createDelegate(this) + icon: '/resources/ajaxhelper/icons/page_edit.png', + handler: this.redirectProperties.createDelegate(this,[grid, i, e],false) }), new Ext.menu.Item({ text: acs_lang_text.download_archive || 'Download archive', - icon: '/resources/ajax-filestorage-ui/icons/arrow_down.png', - handler: this.downloadArchive.createDelegate(this) + icon: '/resources/ajaxhelper/icons/arrow_down.png', + handler: this.downloadArchive.createDelegate(this,[recordid],false) }) ] }); @@ -734,155 +646,84 @@ this.contextmenu.items.items[8].hide(); } } - + var coords = e.getXY(); this.contextmenu.rowid = i; this.contextmenu.showAt([coords[0], coords[1]]); - } - // handle file upload - this.uploadFile = function(e) { + }, - if(document.getElementById("upload_file").value != "" && document.getElementById("filetitle").value != "") { + // load content of folder in file pane + // called from treepanel listener - var callback = { - success: function() { - }, upload: function() { - this.treepanel.getSelectionModel().getSelectedNode().loaded=false; - this.treepanel.getSelectionModel().getSelectedNode().fireEvent("click",this.treepanel.getSelectionModel().getSelectedNode()); - this.upldDialog.getEl().unmask(); - this.upldDialog.hide(); - }, failure: function() { - Ext.Msg.alert(acs_lang_text.error || "Error", acs_lang_text.upload_failed || "Upload failed, please try again later."); - }, scope: this - } + loadFoldercontents : function(node, e) { - var loading_msg = acs_lang_text.loading || "One moment. This may take a while depending on how large your upload is." - this.upldDialog.getEl().mask(" "+loading_msg); + // currently selected folder + this.currentfolder = node.id; - YAHOO.util.Connect.setForm("newfileform", true, true); + // get filepanel + var gridpanel = this.layout.findById('filepanel'); - var cObj = YAHOO.util.Connect.asyncRequest("POST", this.xmlhttpurl+"file-add", callback); - - } else { + // fetch the folder contents - Ext.Msg.alert(acs_lang_text.alert || "Alert", acs_lang_text.file_required || "Title and File to upload are required."); + gridpanel.store.baseParams['folder_id'] = node.id; + // gridpanel.store.baseParams['tag_id'] = ''; + // if the tree node is still loading, wait for it to expand before loading the grid + if(node.loading) { + node.on("expand", function() { this.store.load() }, gridpanel, {single:true}); + } else{ + gridpanel.store.load(); } - } + }, - // create the url - this.createUrl = function(e) { - if(document.getElementById("fsurl").value != "" && document.getElementById("fstitle").value != "") { - if (isURL(document.getElementById("fsurl").value)) { - var callback = { - success: function() { - this.treepanel.getSelectionModel().getSelectedNode().loaded=false; - this.treepanel.getSelectionModel().getSelectedNode().fireEvent("click",this.treepanel.getSelectionModel().getSelectedNode()); - this.createurlDialog.getEl().unmask(); - this.createurlDialog.hide(); - },failure: function() { - this.createurlDialog.getEl().unmask(); - Ext.Msg.alert(acs_lang_text.error || "Error",acs_lang_text.createurl_failed || "Create URL failed, please try again later."); - }, scope: this - } - - this.createurlDialog.getEl().mask(" One moment."); - - YAHOO.util.Connect.setForm("simple-add"); - - var cObj = YAHOO.util.Connect.asyncRequest("POST", this.xmlhttpurl+"url-add", callback); - } else { - Ext.Msg.alert(acs_lang_text.alert || "Alert", acs_lang_text.invalid_url || "URL is not a valid url."); - } - } else { + // executes an action depending on the type of fs item + // - folders : open the folder in the tree + // - file : download the file + // - url : open the url in a new window + openItem : function(grid,i,e) { - Ext.Msg.alert(acs_lang_text.alert || "Alert", acs_lang_text.invalid_url || "Title and URL are required."); - + var treepanel = this.layout.findById('treepanel'); + var dm = grid.store; + var record = dm.getAt(i); + if(record.get("type") == "folder") { + var node = treepanel.getNodeById(record.get("id")); + if(!node.parentNode.isExpanded()) { node.parentNode.expand() } + node.fireEvent("click",node); + node.expand(); + } else { + // this is a file, let the user download + window.open(record.get("url")); + window.focus(); } - } - // shows the create url dialog - this.showCreateUrldialog = function() { - if(!this.createurlDialog.buttons) { - this.createurlDialog.addButton({text:acs_lang_text.ok || 'Ok',icon:"/resources/ajax-filestorage-ui/icons/page_add.png",cls:"x-btn-text-icon"}, this.createUrl, this); - this.createurlDialog.addButton({text:acs_lang_text.cancel ||'Cancel',icon:"/resources/ajax-filestorage-ui/icons/cancel.png",cls:"x-btn-text-icon"}, this.createurlDialog.hide, this.createurlDialog); - } - this.createurlDialog.setTitle(acs_lang_text.createurl || "Create URL"); - this.createurlDialog.body.update("

    Title


    URL


    Description :

    "); - this.createurlDialog.body.setStyle("font","normal 12px tahoma, arial, helvetica, sans-serif"); - this.createurlDialog.body.setStyle("background-color","#ffffff"); - this.createurlDialog.body.setStyle("border","1px solid #e2e2e2"); - this.createurlDialog.body.setStyle("padding","3px"); - this.createurlDialog.show(); - } + }, - // shows the upload dialog, - // check if user has flash 8 or higher - // creates the upload form or - // shows the flash upload dialog - this.showUplddialog = function() { - this.upldDialog.setTitle(acs_lang_text.uploadfile || "Upload Files"); - if(checkFlashVersion() < 8) { - var msg1=acs_lang_text.file_to_upload || "File to upload"; - var msg2=acs_lang_text.file_title || "Title"; - var msg3=acs_lang_text.file_description || "Description"; - var msg4=acs_lang_text.multiple_files || "Multiple Files"; - var msg5=acs_lang_text.multiple_files_msg || "This is a ZIPfile containing multiple files."; - this.upldDialog.body.update("

    "+msg1+"


    "+msg2+"


    "+msg3+" :

    "+msg4+" :

    "+msg5+"

    "); - if(!this.upldDialog.buttons) { - this.upldDialog.addButton({text:acs_lang_text.upload || 'Upload',icon:"/resources/ajax-filestorage-ui/icons/page_add.png",cls:"x-btn-text-icon"}, this.uploadFile, this); - this.upldDialog.addButton({text:acs_lang_text.cancel || 'Cancel',icon:"/resources/ajax-filestorage-ui/icons/cancel.png",cls:"x-btn-text-icon"}, this.upldDialog.hide, this.upldDialog); + // deletes an fs item (folder, file or url) + delItem : function(grid,i,e) { + + var err_msg_txt = acs_lang_text.confirm_delete || "Are you sure you want to delete "; + var err_msg_txt2 = acs_lang_text.foldercontains || "This folder contains"; + var treepanel = this.layout.findById('treepanel'); + if(grid.id=="filepanel") { + var filepanel = grid; + if(filepanel.getSelectionModel().getCount()<=1) { + filepanel.getSelectionModel().selectRow(i); } - } else { - if(this.swfu == null) { - var err_msg_txt = acs_lang_text.upload_intro || "Click Browse to select a file to upload to the selected folder."; - this.upldDialog.body.update("
    "+err_msg_txt+"
    "); - var package_id = String(this.config.package_id); - var user_id = String(this.config.user_id); - var folder_id = String(this.currentfolder); - var max_file_size = String(this.config.max_file_size) || 5000000; - this.swfu = new SWFUpload({ - debug: false, - upload_target_url: "/ajaxfs2/xmlhttp/file-add-flash", - upload_params: {user_id:user_id,package_id:package_id}, - file_types : "*.*", - file_size_limit : max_file_size, - file_queue_limit : 3, - begin_upload_on_queue: false, - file_progress_handler : uploadProgress, - file_cancelled_handler : uploadCancel, - file_complete_handler : uploadComplete, - queue_complete_handler : uploadQueueComplete, - error_handler : uploadError, - flash_url : "/resources/ajax-filestorage-ui/swfupload/swfupload.swf" - }); - this.swfu.fileQueued = uploadStart.createDelegate(this.swfu,[this],true); - this.swfu.fileProgress = uploadProgress.createDelegate(this.swfu,[this],true); - this.swfu.fileComplete = uploadComplete.createDelegate(this.swfu,[this],true); - this.swfu.fileCancelled = uploadCancel.createDelegate(this.swfu,[this],true); - this.swfu.queueComplete = uploadQueueComplete.createDelegate(this.swfu,[this],true); - this.swfu.addSetting("progress_target", "fsuploadprogress"); - this.upldDialog.addButton({text:acs_lang_text.upload || 'Upload',disabled:true,icon:"/resources/ajax-filestorage-ui/icons/arrow_up.png",cls:"x-btn-text-icon"}, this.swfu.startUpload.createDelegate(this.swfu,[null,this],false), this); - this.upldDialog.addButton({text:acs_lang_text.browse || 'Browse',icon:"/resources/ajax-filestorage-ui/icons/page_add.png",cls:"x-btn-text-icon"}, this.swfu.browse, this.swfu); - this.upldDialog.addButton({text:acs_lang_text.close || 'Close',icon:"/resources/ajax-filestorage-ui/icons/cross.png",cls:"x-btn-text-icon"}, this.upldDialog.hide, this.upldDialog); - } + } else { + var filepanel = this.layout.findById('filepanel'); } - this.upldDialog.body.setStyle("font","normal 12px tahoma, arial, helvetica, sans-serif"); - this.upldDialog.body.setStyle("background-color","#ffffff"); - this.upldDialog.body.setStyle("border","1px solid #e2e2e2"); - this.upldDialog.body.setStyle("padding","3px"); - this.upldDialog.show(); - } + var selectedRows = filepanel.getSelectionModel().getSelections(); + var delfromtree = true; - // determine whether to delete from the jsonview or from the tree - this.confirmDel = function() { - var err_msg_txt = acs_lang_text.confirm_delete || "Are you sure you want to delete" - var err_msg_txt2 = acs_lang_text.foldercontains || "This folder contains" - // check if there is a selected file in the jsonview - var selectedRows = this.filegrid.getSelectionModel().getSelections(); + // build the warning message, we want the delete to be intuitive + // determine if we're deleting from tree panel or from file panel + if (selectedRows.length > 0) { - // ** delete from grid ** + + delfromtree = false; + + // ** delete item from grid ** if (selectedRows.length == 1) { var filetodel = selectedRows[0].get("title"); if(selectedRows[0].get("type") === "folder") { @@ -891,770 +732,920 @@ var msg = ""; } var msg = msg + err_msg_txt+" "+filetodel+" ?"; + var object_id = selectedRows[0].get("id"); } else { - var msg = err_msg_txt + ":

    " + var msg = err_msg_txt + ":

    "; + var object_id = []; for(var x=0; x" + selectedRows[x].get("title") + " "; if(selectedRows[x].get("type") === "folder") { msg=msg+"("+selectedRows[x].get("size")+")"; } msg=msg+"
    "; + object_id[x] = selectedRows[x].get("id"); } } - this.msgbox.confirm(acs_lang_text.confirm || 'Confirm', msg, this.delFsitems,this); + } else { - // ** delete from tree ** + + delfromtree = true; + + // ** delete item from tree (tree only shows folders) ** // we can't delete the root node - var selectednode = this.treepanel.getSelectionModel().getSelectedNode(); - var rootnode = this.treepanel.getRootNode(); + var selectednode = treepanel.getSelectionModel().getSelectedNode(); + var object_id = selectednode.attributes["id"]; + var rootnode = treepanel.getRootNode(); if(selectednode.attributes["id"] == rootnode.attributes["id"]) { Ext.Msg.alert(acs_lang_text.alert || "Alert",acs_lang_text.cant_del_root || "The root folder can not be deleted."); + return; } else { - // return a confirmation message - this.msgbox.confirm(acs_lang_text.confirm || 'Confirm', err_msg_txt+' '+selectednode.attributes["text"]+'?', this.delFolder,this); + // confirmation message + var msg = err_msg_txt+' '+selectednode.attributes["text"]+'?'; } + } - } - // delete one or more folder or files - this.delFsitems = function(choice) { + var doDelete = function(choice) { + if (choice === "yes") { + Ext.Ajax.request({ + url:this.xmlhttpurl+"delete-fsitem", + success: function(response) { + var resultObj = Ext.decode(response.responseText); + if(resultObj.success) { + if(delfromtree) { + var selectednode = treepanel.getSelectionModel().getSelectedNode(); + var parentnode = selectednode.parentNode; + parentnode.fireEvent("click",parentnode); + parentnode.removeChild(selectednode); + } else { + for(var x=0; x
    "+resultObj.error+""); + }, params: { object_id: object_id } + }); + } + } - // get the rows to delete - var selectedRows = this.filegrid.getSelectionModel().getSelections(); + Ext.MessageBox.confirm(acs_lang_text.confirm || 'Confirm',msg,doDelete,this); - // arrays for use later - var object_id = []; + }, - // get all node id's from json view into array - for(var x=0; x
    "+resultObj.error+""); } - // clear selections after delete - this.filegrid.getSelectionModel().clearSelections(); - } else { - Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt+"

    "+response.responseText+""); - } - this.filegrid.container.unmask(); - } + }, failure: function(response) { + var resultObj = Ext.decode(response.responseText); + Ext.Msg.alert(acs_lang_text.error || "Error",error_msg_txt + "

    "+resultObj.error+""); + }, params: { folder_id: currentTreeNode.attributes["id"] } + }); - var params = "object_id="+object_id - var url = this.xmlhttpurl+"delete"; + }, - if (choice === "yes") { - this.filegrid.container.mask('Deleting'); - this.asyncCon.request({url:url, - params: params, - method:"POST", - callback: callback, - scope: this - }); - } - } + createSwfObj : function() { - // deletes a folder - this.delFolder = function(choice) { + var ajaxfsobj = this; + var treepanel = ajaxfsobj.layout.findById('treepanel'); + var currentfolder = ajaxfsobj.currentfolder; - var selectednode = this.treepanel.getSelectionModel().getSelectedNode(); - var parentnode = selectednode.parentNode; - var id = selectednode.attributes["id"]; + if(this.swfu == null) { - var callback = function(option,success,response) { - var err_msg_txt = acs_lang_text.delete_error || "Sorry, there was an error trying to delete this item." - if(success) { - if (response.responseText != "1") { - Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt + "

    "+response.responseText+""); - } else { - parentnode.fireEvent("click",parentnode); - parentnode.removeChild(selectednode); + var package_id = String(this.config.package_id); + var user_id = String(this.config.user_id); + var folder_id = String(this.currentfolder); + var max_file_size = String(this.config.max_file_size); + + var uploadProgress = function (fileObj, bytesLoaded) { + try { + var percent = Math.ceil((bytesLoaded / fileObj.size) * 100) + var progress = new FileProgress(fileObj, this.getSetting("progress_target")); + progress.SetProgress(percent); + progress.SetStatus(acs_lang_text.uploading || "Uploading..."); + } catch (ex) { this.debugMessage(ex); } + } + + var uploadCancel = function(fileObj) { + try { + var progress = new FileProgress(fileObj, this.getSetting("progress_target")); + progress.SetCancelled(); + progress.SetStatus(acs_lang_text.uploadcancel || "Cancelled (This item will be removed shortly)"); + progress.ToggleCancel(false); + } - } else { - // delete didn't work, return error - Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt+"

    "+response.responseText+""); + catch (ex) { this.debugMessage(ex) } } - } - if (choice === "yes") { - this.asyncCon.request({url:this.xmlhttpurl+"delete", - params: "object_id="+id, - method:"POST", - callback: callback, - scope: this - }); - } + var uploadComplete = function(fileObj) { + try { + var progress = new FileProgress(fileObj, this.getSetting("progress_target")); + progress.SetComplete(); + progress.SetStatus(acs_lang_text.complete || "Complete."); + progress.ToggleCancel(false); + + } catch (ex) { this.debugMessage(ex); } + } - } + var uploadQueueComplete = function(fileidx) { + var currentTreeNode = treepanel.getNodeById(ajaxfsobj.currentfolder); + currentTreeNode.fireEvent("click",currentTreeNode); + } - // creates a new folder in the db - // inserts a blank folder in the ui ready for user to enter name - this.newFolder = function() { - - // get currently selected folder - var te = this.te; - var tree = this.treepanel; - var currentTreeNode = tree.getSelectionModel().getSelectedNode(); - currentTreeNode.expand(); - - var callback = function(option,success,response) { - var error_msg_txt = acs_lang_text.new_folder_error || "Sorry, there was an error trying to create your new folder."; - if(success) { - if (response.responseText) { - var result_obj = eval(response.responseText); - if(parseInt(result_obj[0].id) != 0) { - // create a new blank node on the currently selected one - var newnode = currentTreeNode.appendChild(new Ext.tree.TreeNode({text:result_obj[0].pretty_folder_name,id:result_obj[0].id,iconCls:'folder',singleClickExpand:true,attributes:{write_p:'t'}})); - tree.getSelectionModel().select(newnode); - newnode.loaded=true; - newnode.fireEvent("click",newnode); - setTimeout(function(){ - te.editNode = newnode; - te.startEdit(newnode.ui.textNode); - }, 10); - } else { - Ext.Msg.alert(acs_lang_text.error || "Error",error_msg_txt + "

    "+response.responseText+""); + var uploadError = function(error_code, fileObj, message) { + try { + if (error_code == SWFUpload.ERROR_CODE_QUEUE_LIMIT_EXCEEDED) { + Ext.Msg.alert(acs_lang_text.alert || "Alert","You have attempted to queue too many files.\n" + (message == 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file."))); + return; } + + var progress = new FileProgress(fileObj, this.getSetting("progress_target")); + progress.SetError(); + progress.ToggleCancel(false); + + switch(error_code) { + case SWFUpload.ERROR_CODE_HTTP_ERROR: + progress.SetStatus("Upload Error"); + this.debugMessage("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message); + break; + case SWFUpload.ERROR_CODE_MISSING_UPLOAD_TARGET: + progress.SetStatus("Configuration Error"); + this.debugMessage("Error Code: No backend file, File name: " + file.name + ", Message: " + message); + break; + case SWFUpload.ERROR_CODE_UPLOAD_FAILED: + progress.SetStatus("Upload Failed."); + this.debugMessage("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); + break; + case SWFUpload.ERROR_CODE_IO_ERROR: + progress.SetStatus("Server (IO) Error"); + this.debugMessage("Error Code: IO Error, File name: " + file.name + ", Message: " + message); + break; + case SWFUpload.ERROR_CODE_SECURITY_ERROR: + progress.SetStatus("Security Error"); + this.debugMessage("Error Code: Security Error, File name: " + file.name + ", Message: " + message); + break; + case SWFUpload.ERROR_CODE_FILE_EXCEEDS_SIZE_LIMIT: + progress.SetStatus("File is too big."); + this.debugMessage("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); + break; + case SWFUpload.ERROR_CODE_ZERO_BYTE_FILE: + progress.SetStatus("Cannot upload Zero Byte files."); + this.debugMessage("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); + break; + case SWFUpload.ERROR_CODE_UPLOAD_LIMIT_EXCEEDED: + progress.SetStatus("Upload limit exceeded."); + this.debugMessage("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); + break; + default: + progress.SetStatus("Unhandled Error"); + this.debugMessage("Error Code: " + error_code + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); + break; + } + } catch (ex) { + this.debugMessage(ex); } - } else { - Ext.Msg.alert(acs_lang_text.error || "Error",error_msg_txt + "

    "+response.responseText+""); } - } - this.asyncCon.request({url:this.xmlhttpurl+"newblankfolder", - params: "folder_id="+currentTreeNode.attributes["id"], - method:"POST", - callback: callback, - scope: this - }); - } + var uploadStart = function (fileObj) { + var upload_txt = acs_lang_text.for_upload_to || "for upload to"; + var zip_txt = acs_lang_text.zip_extracted || "Zip File (Will be extracted after upload)"; + try { + var folderid = ajaxfsobj.currentfolder; + var foldername = treepanel.getNodeById(folderid).text; + var progress = new FileProgress(fileObj, this.getSetting("progress_target")); + progress.SetStatus( upload_txt + " "+foldername+"
    Title: (optional)
    "+ zip_txt); + progress.ToggleCancel(true, this); + this.addFileParam(fileObj.id, "folder_id", folderid); + } catch (ex) { this.debugMessage(ex); } + } - // when a node item is double clicked - this.itemDblClick= function(grid,i,e) { - var dm = grid.getDataSource(); - var record = dm.getAt(i); - if(record.get("type") == "folder") { - var node = this.treepanel.getNodeById(record.get("id")); - if(!node.parentNode.isExpanded()) { node.parentNode.expand() } - node.fireEvent("click",node); - node.expand(); - } else { - // this is a file, let the user download - window.open(record.get("url")); - window.focus(); + // FIXME (SECURITY): we are getting the user_id from the config, + // since we're using flash there's the current session is not used when the upload is done + // we can't trust the config because malicious javascript might try to insert a different user_id + this.swfu = new SWFUpload({ + debug: false, + upload_target_url: this.xmlhttpurl + "add-file-flash", + upload_params: {user_id:user_id,package_id:package_id}, + file_types : "*.*", + file_size_limit : max_file_size, + file_queue_limit : 0, + file_upload_limit : 10, + begin_upload_on_queue: false, + file_queued_handler : uploadStart, + file_progress_handler : uploadProgress, + file_cancelled_handler : uploadCancel, + file_complete_handler : uploadComplete, + queue_complete_handler : uploadQueueComplete, + error_handler : uploadError, + flash_url : "/resources/ajax-filestorage-ui/swfupload/swfupload.swf" + }); + } - } + }, - // creates the file grid, if it's not yet created - this.createFileGrid = function() { - var cols = [{header: "", width: 50,sortable: true, dataIndex: 'icon'}, - {header: acs_lang_text.filename || "Filename", id:'filename', width: 200, sortable: true, dataIndex: 'title_and_name'}, - {header: acs_lang_text.size || "Size", sortable: true, dataIndex: 'size'}, - {header: acs_lang_text.lastmodified || "Last Modified", sortable: true, dataIndex: 'lastmodified'}]; + addFile : function() { - var colModel = new Ext.grid.ColumnModel(cols); - colModel.defaultSortable=true; + if(this.upldWindow == null) { - var reader = new Ext.data.JsonReader({totalProperty: 'total', root: 'foldercontents', id: 'id'}, [ - {name:'id', type: 'int'}, - {name:'icon'}, - {name:'title'}, - {name:'filename'}, - {name:'type'}, - {name:'tags'}, - {name:'url'}, - {name:'write_p'}, - {name:'title_and_name'}, - {name:'size'}, - {name:'lastmodified'}] ); + if (!this.config.multi_file_upload || checkFlashVersion() < 9 || Ext.isLinux) { + /*** Single File Upload *******/ - var proxy = new Ext.data.HttpProxy( { - url : this.xmlhttpurl+ 'foldercontents' - } ); + var msg1=acs_lang_text.file_to_upload || "File to upload"; + var msg2=acs_lang_text.file_title || "Title"; + var msg3=acs_lang_text.file_description || "Description"; + var msg4=acs_lang_text.multiple_files || "Multiple Files"; + var msg5=acs_lang_text.multiple_files_msg || "This is a ZIPfile containing multiple files."; + var modal = true; + var title = "Upload a File"; - var dataModel = new Ext.data.Store({proxy: proxy, reader: reader, remoteSort: true}); + var uploadBody = new Ext.Panel({ + id:'form_addfile', + align:'left', + frame:true, + html: "

    "+msg1+"


    "+msg2+"


    "+msg3+" :

    "+msg4+" :

    "+msg5+"

    " + }); + var uploadBtns = [{ + text: 'Upload', + handler: this.uploadOneFile.createDelegate(this), + icon:"/resources/ajaxhelper/icons/arrow_up.png", + cls:"x-btn-text-icon" + },{ + text: 'Close', + handler: function(){ + this.upldWindow.hide(); + }.createDelegate(this), + icon:"/resources/ajaxhelper/icons/cross.png", + cls:"x-btn-text-icon" + }] - this.filegrid = new Ext.grid.Grid('files',{ - ds: dataModel, - cm: colModel, - autoHeight: false, - autoWidth: true, - autoSizeColumns: false, - trackMouseOver: true, - autoExpandColumn: 'filename', - enableColumnMove: false, - enableColLock: false, - enableColumnHide: false, - loadMask: true, - monitorWindowResize: true, - enableDragDrop: true, - ddGroup:'fileDD' - }); + } else { - // grid listeners + /*** Multi File Upload *******/ - // Row Click - // when a grid row is clicked, change the highlight on the currently selected folder - // this is similar to windows explorer behavior - this.filegrid.on("rowclick",function() { - this.treepanel.getSelectionModel().getSelectedNode().getUI().removeClass("x-tree-selected"); - this.treepanel.getSelectionModel().getSelectedNode().getUI().addClass("x-tree-grayselected"); - }, this,true); + this.createSwfObj(); - // Row Double Click - this.filegrid.on("rowdblclick",this.itemDblClick,this,true); + var msg_txt = acs_lang_text.upload_intro || "Click Browse to select a file to upload to the selected folder on the tree."; + var modal = false; + var title = "Upload Files"; - // Row Right Click - this.filegrid.on("rowcontextmenu",this.showContext,this,true); + var uploadBody = new Ext.Panel({ + id:'form_multi_addfile', + autoScroll:true, + frame:true, + html: "
    "+msg_txt+"
    " + }); - // Sort Rows via Drag & Drop - var thegrid = this.filegrid; - var ajaxfsobj = this; - var ddrow = new Ext.dd.DropTarget(thegrid.container, { - ddGroup : 'fileDD', - copy:false, - notifyDrop : function(dd, e, data){ - var ds=thegrid.getDataSource(); - var sm=thegrid.getSelectionModel(); - var rows=sm.getSelections(); - if(dd.getDragData(e)) { - var cindex=dd.getDragData(e).rowIndex; - if(typeof(cindex) != "undefined") { - if (!this.copy){ - for(i = 0; i < rows.length; i++) { - ds.remove(ds.getById(rows[i].id)); - } - } - ds.insert(cindex,data.selections); - sm.clearSelections(); - } + uploadBody.on("render",function() { + this.swfu.addSetting("progress_target", "fsuploadprogress"); + },this); - // ** CSM SPECIFIC ** - // send an xmlhttp request to update the order_n of fs_objects - /* - var params = ""; - var dm = thegrid.getDataSource(); - for(var i = 0;i
    "+loading_msg); + + YAHOO.util.Connect.setForm("newfileform", true, true); + + var cObj = YAHOO.util.Connect.asyncRequest("POST", this.xmlhttpurl+"add-file", callback); + + } else { + + Ext.Msg.alert(acs_lang_text.alert || "Alert", acs_lang_text.file_required || "Title and File to upload are required."); + } + }, - // fetch the folder contents + // create add url dialog + addUrl : function() { - this.filegrid.getDataSource().baseParams['folder_id'] = node.id; - this.filegrid.getDataSource().baseParams['tag_id'] = ''; + if (this.createurlWindow == null) { - // if the tree node is still loading, wait for it to expand before loading the grid - if(node.loading) { - node.on("expand", function(){this.filegrid.getDataSource().load()}.createDelegate(this), true, {single:true}); - } else{ - this.filegrid.getDataSource().load(); + this.createurlWindow = new Ext.Window({ + id:'createurl-win', + layout:'fit', + width:400, + height:180, + title:'Create URL', + closeAction:'hide', + modal:true, + plain:true, + resizable:false, + items: new Ext.FormPanel({ + id:'form_create_url', + align:'left', + autoScroll:true, + closable:true, + layout:'form', + defaults: {width: 230}, + frame:true, + buttonAlign:'left', + items: [ + {xtype:'textfield',fieldLabel: 'Title',allowBlank:false,name:'fstitle',tabIndex:1}, + {xtype:'textfield',fieldLabel: 'URL',allowBlank:false,name:'fsurl',tabIndex:2}, + {xtype:'textfield',fieldLabel: 'Description',name:'fsdescription',tabIndex:3} + ] + }), buttons: [{ + text:'Submit', + handler: function() { + this.createurlWindow.findById('form_create_url').getForm().submit( { + url:this.xmlhttpurl+"add-url", + waitMsg:'One moment ....', + params: {package_id:this.config.package_id,folder_id:this.currentfolder}, + reset: true, + scope: this, + success: function(form,action) { + if(action.result) { + this.createurlWindow.hide(); + } else { + Ext.MessageBox.alert('Error','Sorry an error occured.
    '+action.result.error); + } + }, failure: function(form,action) { + if(action.result) { + Ext.MessageBox.alert('Error',action.result.error); + } + } + } ) + }.createDelegate(this), + icon:"/resources/ajaxhelper/icons/disk.png", + cls:"x-btn-text-icon" + },{ + text: 'Close', + handler: function(){ + this.createurlWindow.hide(); + }.createDelegate(this), + icon:"/resources/ajaxhelper/icons/cross.png", + cls:"x-btn-text-icon" + }] + }); + } - } - // get the root folder of this file storage instance - // and creates a root node for the Ext tree - this.renderTree = function() { + this.createurlWindow.show(); - var callback = function(option,success,response) { - if(success) { - rootfolderobj = eval('('+response.responseText+')'); + }, - // set the root node - this.rootfolder = new Ext.tree.AsyncTreeNode({ - text: rootfolderobj.text, - draggable:false, - id: rootfolderobj.id, - singeClickExpand: true, - attributes: rootfolderobj.attributes - }); + // rename a file or folder in the right panel + renameItem : function(grid,i,e) { - // ********** TOOLBAR ***************** + var filepanel = grid; + var treepanel = this.layout.findById('treepanel'); + var node = filepanel.store.getAt(i); + var nodeurl = node.get("url"); + var nodetype = node.get("type"); + var nodeid = node.get("id"); + var nodesubtitle = node.get("filename"); + var successRename = function(response) { + var err_msg_txt = acs_lang_text.an_error_occurred || "An error occurred"; + var err_msg_txt2 = acs_lang_text.reverted || "Your changes have been reverted"; + var resultObj = Ext.decode(response.responseText); + if (!resultObj.success) { + Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt + ":

    "+resultObj.error+"

    "+err_msg_txt2); + } else { - // if the current user has write, then we create the toolbar that allows - // uploading files, creating new folders and deleting - if (rootfolderobj.attributes["write_p"] == "t") { - // setup the toolbar on the header - this.toolbar = new Ext.Toolbar ("headerpanel"); - this.toolbar.addButton({text: acs_lang_text.newfolder || 'New Folder', icon: '/resources/ajax-filestorage-ui/icons/folder_add.png', cls : 'x-btn-text-icon', handler: this.newFolder.createDelegate(this), scope: this}); - this.toolbar.addButton({text: acs_lang_text.uploadfile || 'Upload Files', icon: '/resources/ajax-filestorage-ui/icons/add.png', cls : 'x-btn-text-icon', handler: this.showUplddialog.createDelegate(this), scope: this}); - if (create_url_p) { - this.toolbar.addButton({text: acs_lang_text.createurl || 'Create Url', icon: '/resources/ajax-filestorage-ui/icons/page_link.png', cls : 'x-btn-text-icon', handler: this.showCreateUrldialog.createDelegate(this), scope: this}); - } - this.toolbar.addButton({text: acs_lang_text.deletefs || 'Delete', icon: '/resources/ajax-filestorage-ui/icons/delete.png', cls : 'x-btn-text-icon', handler: this.confirmDel.createDelegate(this), scope: this}); + if(nodetype=="folder") { treepanel.getNodeById(nodeid).setText(resultObj.newname) } + + if(nodetype!="folder"&&nodesubtitle===" ") { + nodesubtitle = node.get("title"); + node.set("filename",nodesubtitle); } - this.toolbar.addButton({text: acs_lang_text.download_archive || 'Download Archive', icon: '/resources/ajax-filestorage-ui/icons/arrow_down.png', cls : 'x-btn-text-icon', handler: function(){top.location.href="download-archive/index?object_id="+rootfolderobj.id}.createDelegate(this),scrope:this}); - - // render the tree - this.treepanel.setRootNode(this.rootfolder); - this.treepanel.render(); + node.set("title",resultObj.newname); + node.commit(); + } + }; - // ********** OPEN INITIAL FOLDER ***************** + var handleRename = function(btn, text) { + if(btn=='ok') { - // recursive expand in case folder id is not on the first level - var asyncExpand = function(x) { - var node = this.treepanel.getNodeById(this.config.initOpenFolder); - if(!node) { - var x = x+1; - var nextnodeid = this.config.pathToFolder[x]; - var nextnode = this.treepanel.getNodeById(nextnodeid); - nextnode.on("expand",asyncExpand.createDelegate(this,[x]), this, {single:true}); - nextnode.expand(true); - } else { - node.select() - node.fireEvent("click",node); - } - } + if(text != '') { - // if we get an initOpenFolder config, - // expand the provided initOpenFolder id - var selectInitFolder = function() { - if(this.config.initOpenFolder) { - var initNode = this.treepanel.getNodeById(this.config.initOpenFolder); - if(initNode) { - initNode.expand(); - initNode.fireEvent("click",initNode) - } else { - // recursively expand based on the list of folder_ids in pathToFolder - var x = 1; - var nextnode = this.treepanel.getNodeById(this.config.pathToFolder[x]); - nextnode.on("expand",asyncExpand.createDelegate(this,[x]), this, {single:true}); - nextnode.expand(true); - } + if(text.length > 100) { + + Ext.Msg.alert(acs_lang_text.alert || "Alert",acs_lang_text.limitto100 || "Please limit your name to 100 characters or less."); + return false; + } else { - this.treepanel.fireEvent("click",this.rootfolder); + + Ext.Ajax.request({ + url:this.xmlhttpurl+"edit-name", + success: successRename, + failure: function(response) { + var resultObj = Ext.decode(response.responseText); + Ext.Msg.alert(acs_lang_text.error || "Error",error_msg_txt + "

    "+resultObj.error+""); + }, params: { newname:text,object_id:nodeid,type:nodetype,url:nodeurl} + }); + } - } - this.rootfolder.on("expand", selectInitFolder, this, {single:true}) + } else { - // expand and select the root folder - this.rootfolder.expand(); + Ext.Msg.alert(acs_lang_text.alert || "Alert",acs_lang_text.enter_new_name || "Please enter a new name."); + return false; - } else { - Ext.Msg.alert(acs_lang_text.error || "Error", acs_lang_text.tree_render_error || "Sorry, we encountered an error rendering the tree panel"); + } + } - } + }; - // check if we are passed a root folder_id - var params = "package_id="+this.config.package_id; - if (this.config.rootfolder) { - params = params + "&root_folder_id="+ this.config.rootfolder; - } - - this.asyncCon.request({url:this.xmlhttpurl+"getrootfolder", - params: params, - method:"POST", - callback: callback, - scope: this + Ext.Msg.show({ + title: acs_lang_text.rename || 'Rename', + prompt: true, + msg: acs_lang_text.enter_new_name || 'Please enter a new name for ... ', + value: node.get("title"), + buttons: Ext.Msg.OKCANCEL, + fn: handleRename.createDelegate(this) }); - } + var prompt_text_el = YAHOO.util.Dom.getElementsByClassName('ext-mb-input', 'input'); + prompt_text_el[0].select(); - // create and load the treepanel - this.loadTreepanel = function() { + }, - // create a div inside the left panel to create a tree - var folderEl = Ext.get('folderpanel').createChild({tag:'div',id:'folders'}); + // tag a file - // ******** create the tree ************** - this.treepanel = new Ext.tree.TreePanel('folders', { - animate: true, - loader: new Ext.tree.TreeLoader({ dataUrl:this.xmlhttpurl+'loadnodes', - baseParams: { package_id:this.config.package_id} - }), - enableDD:true, - ddGroup:'fileDD', - ddAppendOnly: true, - containerScroll: true, - rootVisible:true + tagFsitem : function(grid,i,e) { + + var filepanel = grid; + var node = filepanel.store.getAt(i); + var object_id = node.get("id"); + var taglist = node.get("tags"); + var package_id = this.config.package_id; + var tagcloudpanel = this.layout.findById("tagcloudpanel"); + var xmlhttpurl = this.xmlhttpurl; + var tagWindow = this.tagWindow; + + var savetags = function() { + + Ext.Ajax.request({ + url:this.xmlhttpurl+"add-tag", + success: function() { + node.data.tags = Ext.get('fstags').getValue(); + node.commit(); + tagcloudpanel.load({url:xmlhttpurl+'get-tagcloud',params:{package_id:package_id}}); + tagWindow.hide(); + }, failure: function(response) { + Ext.Msg.alert(acs_lang_text.error || "Error","Sorry, we encountered an error."); + }, params: { object_id:node.id,package_id:package_id,tags:Ext.get('fstags').getValue()} }); - // ******** folder rename ***************** - this.te = new Ext.tree.TreeEditor(this.treepanel, { - allowBlank:false, - blankText: acs_lang_text.folder_name_required || 'A folder name is required', - selectOnFocus:true - }); + }; - // check if user has premission to rename - this.te.on("beforestartedit", function(node,el,oldname) { - if (node.editNode.attributes.attributes.write_p == "t") { - return true; - } else { - Ext.Msg.alert(acs_lang_text.permission_denied || "Permission Denied", acs_lang_text.permission_denied || "Sorry, you do not have permission to rename this folder"); - return false; - } - }, this, true); + if(tagWindow == null) { - // reject if the folder name is already taken - this.te.on("beforecomplete",function(node,newval,oldval) { - var parent = node.editNode.parentNode; - var children = parent.childNodes; - for(x=0;x

    Enter or edit one or more tags. Use commas (,) to separate the tags:

    " + }); + + var tagBtns = [{ + text: 'Ok', + icon:"/resources/ajaxhelper/icons/disk.png", + cls:"x-btn-text-icon", + handler:savetags.createDelegate(this) + },{ + text: 'Cancel', + icon:"/resources/ajaxhelper/icons/cross.png", + cls:"x-btn-text-icon", + handler: function(){ + tagWindow.hide(); + }.createDelegate(this) + }]; - // send the update to server and validate - this.te.on("complete", function(node,newval,oldval) { - var callback = function(option,success,response) { - var err_msg_txt = acs_lang_text.an_error_occurred || "An error occurred"; - var err_msg_txt2 = acs_lang_text.reverted || "Your changes have been reverted"; - if (success) { - if (response.responseText != 1) { - Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt+":

    "+response.responseText+"

    "+err_msg_txt2); - node.editNode.setText(oldval); - } - } else { - // ajax failed, revert value - Ext.Msg.alert(acs_lang_text.error || "Error",err_msg_txt+":

    "+response.responseText+"

    "+err_msg_txt2); - node.editNode.setText(oldval); - } + tagWindow = new Ext.Window({ + id:'tag-win', + layout:'fit', + width:450, + height:300, + title:"Tags", + closeAction:'hide', + modal:true, + plain:true, + autoScroll:false, + resizable:false, + items: tagformBody, + buttons: tagBtns + }); + + } else { + + } + + tagWindow.show(); + this.initTagAutoComplete(); + }, + + initTagAutoComplete : function() { + var oAutoComp1DS = new YAHOO.widget.DS_JSArray(oAutoCompArr); + if(document.getElementById("fstags")) { + var oAutoComp1 = new YAHOO.widget.AutoComplete('fstags','oAutoCompContainer1', oAutoComp1DS); + oAutoComp1.animHoriz=false; + oAutoComp1.animVert=false; + oAutoComp1.queryDelay=0; + oAutoComp1.maxResultsDisplayed=10; + oAutoComp1.useIFrame=true; + oAutoComp1.delimChar=","; + oAutoComp1.allowBrowserAutocomplete=false; + oAutoComp1.typeAhead=true; + oAutoComp1.formatResult=function(oResultItem, sQuery) { + var sMarkup=oResultItem[0]; + return sMarkup; } - this.asyncCon.request({url:this.xmlhttpurl+"editname", - params: "newname="+newval+"&object_id="+node.editNode.id+"&type=folder", - method:"POST", - callback: callback, - scope: this + } + }, + + // download archive function + downloadArchive : function(object_id) { + if(object_id) { + top.location.href="download-archive/?object_id="+object_id; + } + }, + + // redirect to object views for a file + redirectViews : function(grid,i,e) { + var filepanel = grid; + var node = filepanel.store.getAt(i); + var object_id = node.get("id"); + window.open(window.location.protocol+"//"+window.location.hostname+"/o/"+object_id+"/info"); + window.focus(); + }, + + + // redirect to permissions + redirectPerms : function(grid,i,e) { + var filepanel = grid; + var node = filepanel.store.getAt(i); + var object_id = node.get("id"); + var newwindow = window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"permissions?object_id="+object_id+"&return_url="+window.location.pathname+"?package_id="+this.config.package_id+"&folder_id="+this.currentfolder); + newwindow.focus(); + }, + + + // redirect to file properties + redirectProperties : function(grid,i,e) { + var filepanel = grid; + var node = filepanel.store.getAt(i); + var object_id = node.get("id"); + var newwindow = window.open(window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"file?file_id="+object_id); + newwindow.focus(); + }, + + // generates a url to the currently selected file storage item + // if it's a file : download + // if it's a folder : append folder_id to the current url + copyLink : function(grid,i,e) { + var filepanel = grid; + var node = filepanel.store.getAt(i); + var nodetype = node.get("type"); + if (nodetype === "folder") { + // generate the url to a folder + var copytext = window.location.protocol+"//"+window.location.hostname+":"+window.location.port+this.config.package_url+"?package_id="+this.config.package_id+"&folder_id="+node.get("id"); + } else if (nodetype === "url") { + var copytext = node.get("url"); + } else { + var copytext = window.location.protocol+"//"+window.location.hostname+node.get("url"); + } + if(Ext.isIE) { + window.clipboardData.setData("text",copytext); + } else { + var copyprompt = Ext.Msg.show({ + title: acs_lang_text.linkaddress || 'Copy Link Address', + prompt: true, + msg: acs_lang_text.copyhighlighted || 'Copy the highlighted text to your clipboard.', + value: copytext, + buttons: Ext.Msg.OK }); - }, this, true); + var prompt_text_el = YAHOO.util.Dom.getElementsByClassName('ext-mb-input', 'input'); + prompt_text_el[0].select(); + } + } - // ********** CLICK ***************** +} - // assign a listener to listen for node clicks - // this will fire the proc to load the right panel - // to fetch the fs items in that folder - this.treepanel.on("click",this.loadFoldercontents,this,true) +/********** UTILS *********************/ - // ********** Grid Row DRAGDROP **************** +/* readCookie +read value of a cookie */ +function readCookie(name) { + var ca = document.cookie.split(';'); + var nameEQ = name + "="; + for(var i=0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0)==' ') { c = c.substring(1, c.length) } + if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length, c.length) } + } + return null; +} - // check if the file/folder can be dropped on a node +/* createCookie +used to maintain state, e.g. when login expires */ +function createCookie(name, value, days){ + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } else { var expires = "" } + document.cookie = name+"="+value+expires+"; path=/"; +} - this.treepanel.on("nodedragover",function(e){ - // DO NOT ALLOW DROP TO CURRENT FOLDER - // check if the id of target node to be dropped - // is the same as the currently selected tree node - if (e.target.id == this.treepanel.getSelectionModel().getSelectedNode().id) { - return false; +/* read query string +read the value of a querystring */ +function readQs(q) { + var query = window.location.search.substring(1); + var parms = query.split('&'); + for (var i=0; i 0) { + var key = parms[i].substring(0,pos); + var val = parms[i].substring(pos+1); + if (key == q) { + return val; } - // DO NOT ALLOW TO DROP A NODE TO ITSELF - // check if the id of any of the nodes to be dropped - // is the same as the id on the tree - if(e.source.dragData.selections) { - for (var x=0; x
    "+response.responseText+"

    "+err_msg_txt2); - error = true; - } - } else { - // ajax failed, revert value - Ext.Msg.alert(acs_lang_text.error || "Error", acs_lang_text.error_and_reverted || "An error occurred. Your changes have been reverted"); - error = true; - } - // if move encountered an error, revert the change - if (error) { - option.target.removeChild(option.thenode); - option.parent.appendChild(option.thenode); - option.parent.loaded=false; - option.parent.expand(); - } else { - option.target.loaded=false; - option.target.fireEvent("click",option.target); - option.target.expand(); - } - } - - var params = "file_ids="+draggedObj+"&folder_target_id="+target; - var url = this.xmlhttpurl+"move"; +// check if the string argument is a url +function isURL(argvalue) { - this.asyncCon.request({url:url, - params: params, - method:"POST", - callback: callback, - scope: this, - target: t, - parent: p, - thenode: n - }); + if (argvalue.indexOf(" ") != -1) + return false; + else if (argvalue.indexOf("http://") == -1) + return false; + else if (argvalue == "http://") + return false; + else if (argvalue.indexOf("http://") > 0) + return false; - } else { - - // we dropped a row from the grid - var folder_target_id = ddobj.target.id; - var file_ids = []; - for(var x=0;x 0) { + this.opacity -= reduce_opacity_by; + if (this.opacity < 0) this.opacity = 0; + + if (this.fileProgressWrapper.filters) { + try { + this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity; + } catch (e) { + // If it is not set initially, the browser will throw an error. This will set it if it is not set yet. + this.fileProgressWrapper.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + this.opacity + ')'; + } + } else { + this.fileProgressWrapper.style.opacity = this.opacity / 100; } - // ExtJs has not been loaded, do nothing } - // ** initialize ** + if (this.height > 0) { + this.height -= reduce_height_by; + if (this.height < 0) this.height = 0; - Ext.EventManager.onDocumentReady(this.initObj,this,true); + this.fileProgressWrapper.style.height = this.height + "px"; + } + + if (this.height > 0 || this.opacity > 0) { + var oSelf = this; + setTimeout(function() { oSelf.Disappear(); }, rate); + } else { + this.fileProgressWrapper.style.display = "none"; + } } \ No newline at end of file Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/resources/tree.css'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-blankfolder.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-blankfolder.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-blankfolder.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-blankfolder.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-blankfolder.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-blankfolder.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,63 @@ +ad_page_contract { + + Creates a new folder in the given folder_id + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2007-03-13 +} { + {folder_id:integer,notnull} +} + +# make sure user is logged in +set user_id [auth::require_login] + +# is this the root folder +set fslistinfo [fs::get_folder_package_and_root $folder_id] +if { $folder_id == [lindex $fslistinfo 1] } { + set parent_id $folder_id +} else { + set parent_id [fs::get_parent -item_id $folder_id] +} + +# check permissions on parent folder +# see if the user has write +if { ![permission::permission_p -no_cache \ + -party_id $user_id \ + -object_id $parent_id \ + -privilege "write"] } { + + ns_return 500 "text/html" "You do not have permission to create a folder" + ad_script_abort +} + +set description "" +set pretty_folder_name "New Folder" +set folder_name [string tolower [util_text_to_url -text $pretty_folder_name]] +set file_exists_count [db_string "count_existing" "select count(*) from cr_items where name like '$folder_name%' and parent_id=:folder_id"] +if { $file_exists_count != 0 } { + # NOTE : use a number from db_nextval to ensure uniqueness, otherwise, we may encounter problems when moving + set unique_id [db_nextval acs_object_id_seq] + append folder_name "-$unique_id" + append pretty_folder_name " ($file_exists_count)" +} + + +db_transaction { + + set new_folder_id [fs::new_folder \ + -name $folder_name \ + -pretty_name $pretty_folder_name \ + -parent_id $folder_id \ + -creation_user $user_id \ + -creation_ip [ad_conn peeraddr] \ + -description $description] + + set result "{\"success\":true,\"id\":\"$new_folder_id\",\"pretty_folder_name\":\"$pretty_folder_name\"}" + +} on_error { + + ns_return 500 "text/html" "{\"success\":false,\"error\":\"$errmsg\"}" + ad_script_abort + +} + Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file-flash.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file-flash.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file-flash.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,126 @@ +ad_page_contract { + + script to recieve the new file and insert it into the database + +} { + Filedata:trim,notnull + Filedata.tmpfile:tmpfile +} + +set query [ns_conn query] +set query_set [ns_parsequery $query] + +set folder_id [ns_set get $query_set "folder_id"] +if ![fs_folder_p $folder_id] { + ns_return 500 "text/html" "[_ file-storage.lt_The_specified_parent_]" + ad_script_abort +} + +set package_id [ns_set get $query_set "package_id"] +set user_id [ns_set get $query_set "user_id"] +set filetitle [ns_set get $query_set "filetitle"] +set filedescription [ns_set get $query_set "filedescription"] +set unpack_p [ns_set get $query_set "unpack_p"] + +ns_log notice "HAM : UPLOADING FILE : $folder_id : $Filedata : $Filedata.tmpfile : $package_id : $user_id***" + +# Get the ip +set creation_ip [ad_conn peeraddr] + +set action "" + +set result "" + +# Check for write permission on this folder +# ad_require_permission $folder_id write +if { ![permission::permission_p -object_id $folder_id -privilege "write" -party_id $user_id] } { + # ns_log notice "HAM : You don't have permission to add files to this folder" + ns_return 500 "text/html" "You don't have permission to add files to this folder." + ad_script_abort +} + +# Get the storage type +set indb_p [parameter::get -package_id $package_id -parameter StoreFilesInDatabaseP] + +set unpack_p [template::util::is_true $unpack_p] + +set unzip_binary [string trim [parameter::get -package_id $package_id -parameter UnzipBinary]] + +if { $unpack_p && ![empty_string_p $unzip_binary] && [file extension [template::util::file::get_property filename $Filedata]] eq ".zip" } { + + set path [ns_tmpnam] + file mkdir $path + + + catch { exec $unzip_binary -jd $path ${Filedata.tmpfile} } errmsg + + # More flexible parameter design could be: + # zip {unzip -jd {out_path} {in_file}} tar {tar xf {in_file} {out_path}} tgz {tar xzf {in_file} {out_path}} + + set upload_files [list] + set upload_tmpfiles [list] + + foreach file [glob -nocomplain "$path/*"] { + lappend upload_files [file tail $file] + lappend upload_tmpfiles $file + } + +} else { + set upload_files [list $Filedata] + set upload_tmpfiles [list ${Filedata.tmpfile}] +} + +db_transaction { + + foreach upload_file $upload_files tmpfile $upload_tmpfiles { + + set mime_type [cr_filename_to_mime_type -create $upload_file] + + # Get the filename part of the upload file + if { ![regexp {[^//\\]+$} $upload_file filename] } { + # no match + set filename $upload_file + } + + # Get the title + if { [empty_string_p $filetitle] || $unpack_p } { + set filetitle $filename + } + + set file_id [db_nextval "acs_object_id_seq"] + + fs::add_file \ + -name $filename \ + -item_id $file_id \ + -parent_id $folder_id \ + -tmp_filename $tmpfile\ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -title $filetitle \ + -description "" \ + -package_id $package_id \ + -mime_type $mime_type + + file delete $tmpfile + + # We know the user has write permission to this folder, but they may not have admin privileges. + # They should always be able to admin their own file by default, so they can delete it, control + # who can read it, etc. + + if { [string is false [permission::permission_p -party_id $user_id -object_id $folder_id -privilege admin]] } { + permission::grant -party_id $user_id -object_id $file_id -privilege admin + } + + # So we'll set the title from the filename in the next iteration + set filetitle {} + } + + +} on_error { + + ns_return 500 "text/html" $errmsg + ad_script_abort + +} + +ad_return_template "add-file" Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-file.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,130 @@ +ad_page_contract { + + script to recieve the new file and insert it into the database + +} { + folder_id:integer,notnull + upload_file:notnull,trim + upload_file.tmpfile:tmpfile + package_id:integer,notnull + {filetitle:trim ""} + filedescription + {unpack_p:boolean "f"} +} -validate { + valid_folder -requires {folder_id:integer} { + if ![fs_folder_p $folder_id] { + ns_return 500 "text/html" "[_ file-storage.lt_The_specified_parent_]" + ad_script_abort + } + } + max_size -requires {upload_file} { + set n_bytes [file size ${upload_file.tmpfile}] + set max_bytes [parameter::get -package_id $package_id -parameter "MaximumFileSize"] + # ns_log notice "HAM : $n_bytes : $max_bytes *" + if { $n_bytes > $max_bytes } { + ns_return 500 "text/html" [_ file-storage.lt_Your_file_is_larger_t_1 [list max_number_of_bytes [util_commify_number $max_bytes]]] + ad_script_abort + } + } +} + +# ns_log notice "HAM : UPLOADING FILE : $folder_id : $upload_file : $upload_file.tmpfile ***" + +# Get the user +set user_id [auth::require_login] + +# Get the ip +set creation_ip [ad_conn peeraddr] + +set action "" + +set result "" + +# Check for write permission on this folder +# ad_require_permission $folder_id write +if { ![permission::permission_p -object_id $folder_id -privilege "write"] } { + ns_return 500 "text/html" "You don't have permission to add files to this folder." + ad_script_abort +} + +# Get the storage type +set indb_p [parameter::get -package_id $package_id -parameter StoreFilesInDatabaseP] + +set unpack_p [template::util::is_true $unpack_p] +set unzip_binary [string trim [parameter::get -package_id $package_id -parameter UnzipBinary]] + +if { $unpack_p && ![empty_string_p $unzip_binary] && [file extension [template::util::file::get_property filename $upload_file]] eq ".zip" } { + + set path [ns_tmpnam] + file mkdir $path + + + catch { exec $unzip_binary -jd $path ${upload_file.tmpfile} } errmsg + + # More flexible parameter design could be: + # zip {unzip -jd {out_path} {in_file}} tar {tar xf {in_file} {out_path}} tgz {tar xzf {in_file} {out_path}} + + set upload_files [list] + set upload_tmpfiles [list] + + foreach file [glob -nocomplain "$path/*"] { + lappend upload_files [file tail $file] + lappend upload_tmpfiles $file + } + +} else { + set upload_files [list $upload_file] + set upload_tmpfiles [list ${upload_file.tmpfile}] +} + +db_transaction { + + foreach upload_file $upload_files tmpfile $upload_tmpfiles { + + set mime_type [cr_filename_to_mime_type -create $upload_file] + + # Get the filename part of the upload file + if { ![regexp {[^//\\]+$} $upload_file filename] } { + # no match + set filename $upload_file + } + + # Get the title + if { [empty_string_p $filetitle] || $unpack_p } { + set filetitle $filename + } + + set file_id [db_nextval "acs_object_id_seq"] + fs::add_file \ + -name $filename \ + -item_id $file_id \ + -parent_id $folder_id \ + -tmp_filename $tmpfile\ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -title $filetitle \ + -description "" \ + -package_id $package_id \ + -mime_type $mime_type + + file delete $tmpfile + + # We know the user has write permission to this folder, but they may not have admin privileges. + # They should always be able to admin their own file by default, so they can delete it, control + # who can read it, etc. + + if { [string is false [permission::permission_p -party_id $user_id -object_id $folder_id -privilege admin]] } { + permission::grant -party_id $user_id -object_id $file_id -privilege admin + } + + # So we'll set the title from the filename in the next iteration + set filetitle {} + } + + +} on_error { + + ns_return 500 "text/html" $errmsg + ad_script_abort + +} Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-tag.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-tag.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-tag.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-tag.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-tag.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-tag.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,56 @@ +ad_page_contract { + + Receives an object id and a comma separated list of categories. + Categorizes the object_id to the categories passed + If category exists, use it, otherwise create a new category + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2007-07-23 + +} { + package_id + object_id + tags +} + +# ns_log notice "ADDTAG : $object_id : $tags " + +set user_id [ad_conn user_id] +set result "{\"success\":true}" +set tree_id [parameter::get -parameter "CategoryTreeId"] + +db_dml "delmap" "delete from category_object_map where object_id = :object_id" + +foreach tag [split $tags ,] { + + set tag [string trim $tag] + + if { ![template::util::is_nil tag] } { + + set category_id [category::get_id [string tolower [string trim $tag]]] + + if { $category_id == "" } { + + # remove spaces and any html from tags + regsub -all {<.+?>} $tag "" tag + set tag [string tolower [string trim $tag]] + + if { [catch {set creation_ip [ad_conn peeraddr] } ] } { + set creation_ip "0.0.0.0" + } + + set category_id [category::add -tree_id $tree_id -name $tag -parent_id "" -user_id $user_id -creation_ip "0.0.0.0"] + category::map_object -object_id $object_id $category_id + + } else { + + # map object_id to category + category::map_object -object_id $object_id $category_id + + } + } +} + +# TODO : detect if we're using search, then reindex the item +# reindex for search +# search::queue -object_id $object_id -event "UPDATE" \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-url.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-url.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-url.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-url.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-url.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/add-url.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,39 @@ +ad_page_contract { + +Add a URL to the file storage instance + +} { + folder_id:integer,notnull + package_id:integer,notnull + fstitle:notnull,trim + fsdescription + fsurl:notnull,trim +} + +set user_id [ad_conn user_id] +set result "{\"success\":true}" + +# Check for write permission on this folder +# ad_require_permission $folder_id write +if { ![permission::permission_p -object_id $folder_id -privilege "write"] } { + + # ns_return 500 "text/html" "You don't have permission to create a url on this folder." + # ad_script_abort + set result "{\"success\":false,\"error\":\"You don't have permission to create a url on this folder.\"}" + +} else { + + set item_id [content_extlink::new -url $fsurl -label $fstitle -description $fsdescription -parent_id $folder_id] + + # Analogous as for files (see file-add-2) we know the user has write permission to this folder, + # but they may not have admin privileges. + # They should always be able to admin their own url (item) by default, so they can delete it, control + # who can read it, etc. + + if { [string is false [permission::permission_p -party_id $user_id -object_id $folder_id -privilege admin]] } { + permission::grant -party_id $user_id -object_id $item_id -privilege admin + } + + fs::do_notifications -folder_id $folder_id -filename $fsurl -item_id $item_id -action "new_url" + +} Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/addtag.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/addtag.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/copy.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/copy.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete-fsitem.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete-fsitem.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete-fsitem.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete-fsitem.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete-fsitem.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete-fsitem.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,51 @@ +ad_page_contract { + + Delete an fs item. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2007-06-03 + +} { + object_id:multiple +} + +set user_id [ad_conn user_id] + +set result "{\"success\":true}" +set fs_object_ids [split $object_id " "] +set viewing_user_id [ad_conn user_id] + +db_transaction { + + foreach fs_object_id $fs_object_ids { + + if { ![fs::object_p -object_id $fs_object_id]} { + set errmsg "Sorry, this object is not a File Storage Object." + db_abort_transaction + break; + } else { + # check if user has permission to delete the file/folder + if { [permission::permission_p -party_id $viewing_user_id -object_id $fs_object_id -privilege "delete"] } { + if { [fs::folder_p -object_id $fs_object_id] } { + fs::delete_folder -folder_id $fs_object_id -parent_id [fs::get_parent -item_id $fs_object_id] + # ns_log notice "HAM : delete folder *******" + } else { + fs::delete_file -item_id $fs_object_id + # ns_log notice "HAM : delete file *******" + } + } else { + set errmsg "You do not have permission to delete this file." + db_abort_transaction + break; + } + } + + } + +} on_error { + + ns_return 500 "text/html" "{\"success\":false,\"error\":\"$errmsg\"}" + ad_script_abort + +} + Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/delete.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/edit-name.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/edit-name.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/edit-name.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/edit-name.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/edit-name.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/edit-name.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,48 @@ +ad_page_contract { + + Accepts the object_id and a new name for the object. + Returns 1 if update is successful, should return an error message if not. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-05-07 +} { + newname + object_id + type + url:optional +} + +set user_id [ad_conn user_id] +set result "{\"success\":true,\"newname\":\"$newname\",\"type\":\"$type\",\"url\":\"$url\"}" + +# check permissions on parent folder +# see if the user has write +if { ![permission::permission_p -no_cache \ + -party_id $user_id \ + -object_id $object_id \ + -privilege "write"] } { + + ns_return 500 "text/html" "{\"success\":false,\"error\":\"You do not have permission to rename.\"}" + ad_script_abort +} + +# change the name of the give object_id +if { [exists_and_not_null newname] } { + # determine if this is a folder or file + db_transaction { + if { $type == "folder" } { + fs::rename_folder -folder_id $object_id -name $newname + } elseif { $type == "url" } { + content_extlink::edit -extlink_id $object_id -url $url -label $newname -description "" + } else { + set title $newname + set file_id $object_id + db_dml dbqd.file-storage.www.file-edit-2.edit_title {} + } + } on_error { + ns_return 500 "text/html" "{\"success\":false,\"error\":\"$errmsg\"}" + ad_script_abort + } +} else { + set result "{\"success\":false,\"error\":\"You must provide a new name\"}" +} \ No newline at end of file Fisheye: Tag 1.4 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/editname.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.4 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/editname.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/file-add-flash.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/file-add.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/file-add.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/foldercontents.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/foldercontents.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-foldercontents.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-foldercontents.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-foldercontents.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,5 @@ +{ "total": @counter@, "foldercontents":[ + +{"id":"@contents.object_id@","icon":"@contents.icon;noquote@","type":"@contents.type;noquote@",tags:"@contents.tags;noquote@","title":"@contents.title;noquote@","filename":"@contents.filename;noquote@","url":"@contents.download_url;noquote@","size":"@contents.content_size_pretty@","lastmodified":"@contents.last_modified_pretty@","write_p":@contents.write_p@} + +]} \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-foldercontents.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-foldercontents.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-foldercontents.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,186 @@ +ad_page_contract { + + Given the folder_id, this page will return JSON with + data of the contents of that folder + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2007-06-03 + +} { + folder_id:optional + tag_id:integer,optional + {sort "fs_objects.title"} + {dir "DESC"} +} + +# who's looking + +set viewing_user_id [ad_conn user_id] + +regsub "treenode" $folder_id "" folder_id + +# find out which file storage instance we are at +# so that we can get a path to prefix to the files + +set root_package_id [ajaxfs::get_root_folder -folder_id $folder_id] +set root_folder_id [fs::get_root_folder -package_id $root_package_id] + +set folder_name [lang::util::localize [fs::get_object_name -object_id $folder_id]] + +set fs_url [apm_package_url_from_id $root_package_id] +if {![exists_and_not_null fs_url]} { set fs_url "" } + +set folder_path "" +if {![string equal $root_folder_id $folder_id]} { + set folder_path [db_exec_plsql dbqd.file-storage.www.folder-chunk.get_folder_path {}] +} + +set counter 0 +set n_past_days 99999 + +# sorting ********** +set orderby "" +if { [exists_and_not_null sort] } { + if {$sort == "title"} { set sort "lower(fs_objects.title)" } + if {$sort == "size"} { set sort "fs_objects.content_size" } + if {$sort == "lastmodified"} { set sort "fs_objects.last_modified" } + set orderby "order by $sort $dir" +} + +if { [exists_and_not_null tag_id] } { + set query_name "select_folder_contents" + set query "select fs_objects.object_id, + fs_objects.mime_type, + fs_objects.name, + fs_objects.live_revision, + fs_objects.type, + fs_objects.pretty_type, + to_char(fs_objects.last_modified, 'YYYY-MM-DD HH24:MI:SS') as last_modified_ansi, + fs_objects.content_size, + fs_objects.url, + fs_objects.sort_key, + fs_objects.sort_key as sort_key_desc, + fs_objects.file_upload_name, + fs_objects.title, + case + when '$folder_path' is null + then fs_objects.file_upload_name + else '$folder_path' || '/' || fs_objects.file_upload_name + end as file_url, + case + when fs_objects.last_modified >= (now() - cast('$n_past_days days' as interval)) + then 1 + else 0 + end as new_p + from fs_objects + where fs_objects.object_id in (select object_id from category_object_map where category_id=$tag_id) + and exists (select 1 + from acs_object_party_privilege_map m + where m.object_id = fs_objects.object_id + and m.party_id = $viewing_user_id + and m.privilege = 'read') + $orderby" +} else { + set query_name dbqd.file-storage.www.folder-chunk.select_folder_contents + set query "" +} + + +db_multirow -extend { filename icon last_modified_pretty content_size_pretty download_url object_counter file_list_start file_list_end write_p tags} contents $query_name $query { + + # title of the file + + if { ![exists_and_not_null title] } { set title $name } + + # content size + + if {[string equal $type "folder"]} { + + set content_size_pretty [lc_numeric $content_size] + append content_size_pretty " [_ file-storage.items]" + + } else { + + if {$content_size < 1024} { + set content_size_pretty "[lc_numeric $content_size] [_ file-storage.bytes]" + } else { + set content_size_pretty "[lc_numeric [expr $content_size / 1024 ]] [_ file-storage.kb]" + } + + } + + # last modified + + set last_modified_pretty [lc_time_fmt $last_modified_ansi "%x %X"] + + # icon + + switch -- $type { + folder { + set icon "" + } + url { + set icon "" + set download_url $url + set content_size_pretty "" + } + "application/pdf" { + set icon "" + } + "application/vnd.ms-excel" { + set icon "" + } + "application/vnd.ms-powerpoint" { + set icon "" + } + "application/zip" { + set icon "" + } + "application/msword" { + set icon "" + } + "video/x-flv" { + set icon "" + } + "image/jpeg" { + set icon "" + } + "image/gif" { + set icon "" + } + default { + set icon "" + } + } + + # filename and download url + + set filename " " + + if { $type != "folder"} { + + if { ![exists_and_not_null download_url] } { + set download_url "${fs_url}download/${name}?[export_vars {{file_id $object_id}}]" + } + + set filename $name + + } else { + + set download_url "javascript:void(0)" + + } + + # get the tags for this fs item + set tag_list [db_list "get_categories" "select name from category_translations where locale='en_US' and category_id in (select category_id from category_object_map where object_id=:object_id)"] + if { [llength $tag_list] >0 } { + set tags [join $tag_list ","] + } else { + set tags "" + } + + if { [permission::permission_p -party_id $viewing_user_id -object_id $object_id -privilege "write"] == "t" } { set write_p "true" } else { set write_p "false" } + + incr counter + +} \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-tagcloud.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-tagcloud.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-tagcloud.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,8 @@ +
    + + + + +No tags found. + +
    \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-tagcloud.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-tagcloud.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/get-tagcloud.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,53 @@ +ad_page_contract { + + Generate a tagcloud + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2007-07-15 + +} { + package_id:integer +} + +# create a tagcloud from a given category_tree +set locale "en_US" + +# use the same tree_id as the bookmarks +# set tree_id [connections::category_tree_id] +set tree_id [parameter::get -parameter "CategoryTreeId"] + +set node_id [site_node::get_node_id_from_object_id -object_id $package_id] + +# determine if we are in an extranet or a dotfolio +set ancestor_subsite_id [site_node::closest_ancestor_package \ + -node_id $node_id \ + -package_key acs-subsite \ + -include_self] + +if { ![exists_and_not_null user_id] } { + set user_id [ad_conn user_id] +} + +# set subsite_p [myweb::subsite_p -ancestor_subsite_id $ancestor_subsite_id] +# set application_group_id [application_group::group_id_from_package_id -package_id $ancestor_subsite_id] +# set limit_clause { +# and m.object_id in (select p.object_id +# from acs_permissions_all p, fs_objects e +# where p.object_id = e.object_id +# and p.grantee_id = :application_group_id +# and p.privilege = 'read') +#} +# set limit_clause "and m.object_id in (select object_id from acs_objects where package_id = $package_id)" + +db_multirow -extend { url } connections connections [subst { +select c.category_id, t.name, count(*) as count, o.creation_user +from categories c, category_translations t, category_object_map m, acs_objects o +where c.category_id = t.category_id +and c.tree_id = :tree_id +and t.locale = :locale +and c.category_id = m.category_id +and c.category_id = o.object_id +group by t.name, o.creation_date, o.creation_user, c.category_id +order by t.name}] { + set url "javascript:void(0)" +} Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/getname.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/getname.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/getrootfolder.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/getrootfolder.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes-oracle.xql 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,31 @@ + + + + + + + oracle + 8.1.6 + + + + + select fs_objects.object_id, fs_objects.name, fs_objects.title, fs_objects.parent_id, + case + when fs_objects.type = 'url' + then ( select acs_permission.permission_p(fs_objects.object_id, :viewing_user_id, 'write') from dual) + else 't' + end as write_p + from fs_objects + where fs_objects.type='folder' + and fs_objects.parent_id = :node + and exists (select 1 + from acs_object_party_privilege_map m + where m.object_id = fs_objects.object_id + and m.party_id = :viewing_user_id + and m.privilege = 'read') order by fs_objects.title + + + + \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes-postgresql.xql 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,34 @@ + + + + + + + postgresql + 7.2 + + + + + select fs_objects.object_id, + fs_objects.name, + fs_objects.title, + fs_objects.parent_id, + case + when fs_objects.type = 'url' + then ( select acs_permission__permission_p(fs_objects.object_id, :viewing_user_id, 'write') from dual) + else 't' + end as write_p + from fs_objects + where fs_objects.type='folder' + and fs_objects.parent_id = :node + and exists (select 1 + from acs_object_party_privilege_map m + where m.object_id = fs_objects.object_id + and m.party_id = :viewing_user_id + and m.privilege = 'read') order by fs_objects.title + + + + \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +[{"text":"@treenodes.name@","id":"@treenodes.id;noquote@","iconCls":"folder","singleClickExpand":true,"attributes":{"write_p":"@treenodes.write_p@"}}] \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/load-treenodes.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,44 @@ +ad_page_contract { + + Returns a JSON structure suitable for building the nodes of a tree + for the ajax file storage ui. + Requires the package_id + + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2007-06-03 + +} { + package_id:integer,notnull + {node ""} +} + +# ns_log notice "ln called with package_id '$package_id' and node '$node'" + +set viewing_user_id [ad_conn user_id] + +# if node is empty, then get the rootfolder of the package_id + +if { ![exists_and_not_null node] } { + set node [fs::get_root_folder -package_id $package_id] +} + +db_multirow -extend { text id href cls leaf } "treenodes" "treenodes" { } { + + set child_count [db_string "count_children" "select count(*) from fs_objects where parent_id = :object_id and type='folder'"] + + if { [exists_and_not_null title] } { + set text $title + } else { + set text $name + } + + set id "$object_id" + set cls "folder" + set leaf "true" + + if { $child_count > 0 } { + set leaf "false" + } + +} \ No newline at end of file Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.4 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadnodes-oracle.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadnodes-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadnodes.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadnodes.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move-fsitem.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move-fsitem.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move-fsitem.adp 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move-fsitem.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move-fsitem.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move-fsitem.tcl 26 Nov 2007 12:52:45 -0000 1.1 @@ -0,0 +1,44 @@ +ad_page_contract { + + Allow an fs_item where file or folder to be moved to + a new target folder. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2007-06-03 + +} { + folder_target_id:integer,notnull + file_ids:multiple +} + +set user_id [ad_conn user_id] +set result "{\"success\":true}" + +# check permissions on parent folder +# see if the user has write +set parent_id [fs::get_parent -item_id $folder_target_id] +if { ![permission::permission_p -no_cache \ + -party_id $user_id \ + -object_id $parent_id \ + -privilege "write"] } { + + ns_return 500 "text/html" "{\"success\":false,\"error\":\"You do not have permission to rename.\"}" + ad_script_abort +} + +set file_id_list [split $file_ids " "] + +db_transaction { + + foreach file_id $file_id_list { + set parent_id $folder_target_id + set address [ad_conn peeraddr] + db_exec_plsql dbqd.file-storage.www.file-move-2.file_move {} + } + +} on_error { + + ns_return 500 "text/html" "{\"success\":false,\"error\":\"$errmsg\"}" + ad_script_abort + +} \ No newline at end of file Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/move.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/newblankfolder.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/newblankfolder.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/rename-fsitem.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/rename-fsitem.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/rename-fsitem.adp 26 Nov 2007 12:52:46 -0000 1.1 @@ -0,0 +1 @@ +@result;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/rename-fsitem.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/rename-fsitem.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/rename-fsitem.tcl 26 Nov 2007 12:52:46 -0000 1.1 @@ -0,0 +1,48 @@ +ad_page_contract { + + Accepts the object_id and a new name for the object. + Returns 1 if update is successful, should return an error message if not. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-05-07 +} { + newname + object_id + type + url:optional +} + +# make sure user is logged in +set user_id [auth::require_login] + +# check permissions on parent folder +# see if the user has write +if { ![permission::permission_p -no_cache \ + -party_id $user_id \ + -object_id $object_id \ + -privilege "write"] } { + + ns_return 500 "text/html" "You do not have permission to rename." + ad_script_abort +} + +set result "{\"success\":true }" + +# change the name of the give object_id +if { [exists_and_not_null newname] } { + # determine if this is a folder or file + db_transaction { + if { $type == "folder" } { + fs::rename_folder -folder_id $object_id -name $newname + } elseif { $type == "url" } { + content_extlink::edit -extlink_id $object_id -url $url -label $newname -description "" + } else { + set title $newname + set file_id $object_id + db_dml dbqd.file-storage.www.file-edit-2.edit_title {} + } + } on_error { + ns_return 500 "text/html" "{\"success\":false,\"error\":\"$errmsg\"}" + ad_script_abort + } +} \ No newline at end of file Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties-postgresql.xql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/sort-files.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/tagcloud.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/tagcloud.tcl'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/url-add.adp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/url-add.tcl'. Fisheye: No comparison available. Pass `N' to diff?