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.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/ajax-filestorage-ui.info 6 Nov 2006 13:15:56 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/ajax-filestorage-ui.info 25 Dec 2006 16:23:26 -0000 1.2 @@ -8,12 +8,12 @@ f ajaxfs - + Hamilton Chua 2006-06-01 Solutiongrove - + Index: openacs-4/packages/ajax-filestorage-ui/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/Attic/index.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/www/index.adp 20 Nov 2006 00:23:04 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/www/index.adp 25 Dec 2006 16:23:26 -0000 1.3 @@ -1,29 +1,49 @@ - -@page_title@ - +@doc_type;noquote@ + + + +@page_title@ + + + + + + + + + - - - + + - @js_sources;noquote@ - - - -Classic View - -
-
- -



No folders found.
-
-
-
File/FolderSizeLast Modified
-



Click on an item in the file tree to view its contents here.
-
+
+ +



No folders found.
+
+
+
Click a file to get more information
+
+
+
This item does not have any revisions
+
+
+
+ + + + + + + +
FilenameSizeTypeLast Modified
+
+

Click on an item in the file tree to view its contents here.
+
- - @js_script;noquote@ + + \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/Attic/index.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/index.tcl 6 Nov 2006 13:15:56 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/index.tcl 25 Dec 2006 16:23:26 -0000 1.2 @@ -3,9 +3,9 @@ ad_page_contract { Ajax Based File Manager using OpenACS File Storage and Yahoo's Tree View Control. - Optionally specify a the package_id of the file storage instance you wish to manage + Optionally specify a package_id of the file storage instance you wish to manage or optionally specify a folder_id in the query string to tell which folder to open - + @author Hamilton Chua (ham@solutiongrove.com) @creation-date 2006-02-04 } { @@ -15,11 +15,8 @@ # declare some variables set page_title "Ajax File Storage" +set doc_type { } -# load yahoo events sources -# this is needed for functions inside ajaxfs.js -set js_sources [ah::yui::js_sources -source "connection"] - # where is afs mounted set afs_url [afs::get_url] @@ -45,22 +42,24 @@ db_foreach "get_fs_instances" "" { # verify if the folder has contents - if { [db_string "countcontent" ""] > 0 } { + if { [db_string "countcontent" ""] > 0 } { + # loadDataForNode is a javascript function found in ajaxfs.js + # it is responsible for loading the child nodes when the current node is opened set dyn_load_script "loadDataForNode" } else { set dyn_load_script "" } # create the node - lappend nodes [list "$root_folder" "$instance_name" "$treevarname" "javascript:showFolderContents('${root_folder}',$treevarname)" "" "${dyn_load_script}"] + lappend nodes [list "$root_folder" "$instance_name" "$treevarname" "javascript:showFolderContents('${root_folder}',$treevarname,'name')" "" "${dyn_load_script}" "1"] incr count_folders } set js_script [ah::yui::create_tree -element "folders" \ -nodes $nodes \ - -varname "tree" \ + -varname $treevarname \ -css "/resources/ajax-filestorage-ui/tree.css" ] set js_script [ah::enclose_in_script -script $js_script] \ No newline at end of file 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.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.css 6 Nov 2006 13:15:56 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.css 25 Dec 2006 16:23:26 -0000 1.2 @@ -1,94 +1,61 @@ -div#page { - margin:0px; - padding:0px; +body {font:normal 9pt verdana; margin:0;padding:0;border:0px none;overflow:hidden;} +#header{ + border-bottom: 1px solid #083772; + padding:5px 4px; + color:#ffffff; + background: rgb(133, 174, 236) url(/resources/ajaxhelper/dojo-ajax/src/widget/templates/images/soriaAccordionSelected.gif); } - -div#toolbar { - background-color:#e2e2e2; - width:100%; - margin:0px 0px 3px 0px; - padding:0; - line-height:2.3; - height:40px; - border:thin solid #000000; +#footer{ + background: url(images/header-bar.gif) repeat-x bottom; + border-top: 1px solid #083772; + padding:2px 4px; + color:white; + font:normal 8pt arial,helvetica; } - -div#folders a:hover { color: #000000; } - -/* Folder Container */ -div#foldercontainer { - float:left; - width:28%; - padding:0px; - margin:0px; - border:thin solid #e2e2e2; +#folders, #files, #fileinfo { + padding:10px; } -div#folders { - height:500px; - overflow:auto; +#folders { + padding-top :0; + padding-left: 5px; } -/* File Container */ -div#filecontainer { - float:left; - width:70%; - padding:0px; - margin: 0 0 0 5px; +#files { + padding-top :0; } -div#files { - min-height:500px; +#content p { + margin:5px; } -div#helpstatus { - position:relative; - width:500px; - float:left; - margin-top:3px; - padding:1px; - opacity:0; - text-align:center; +#folders li { + padding:2px; + padding-left:10px; + background-image:url(images/bullet.gif); + background-position: -3px 6px; + background-repeat: no-repeat; + font-size:8pt; + display: block; } -div#trash { - position:relative; - width:40px; - float:right; - text-align:right; - padding:2px; +.ylayout-panel-north, .ylayout-panel-south, #content .ylayout-panel-center{ + border:0px none; } -div#upload { - position:relative; - width:40px; - float:right; - text-align:right; - padding:2px; +#content .ylayout-panel-south{ + border-top:1px solid #aca899; } -div#oldfsui { - position:relative; - width:40px; - text-align:right; - padding:2px; +#content .ylayout-panel-center{ + border-bottom:1px solid #aca899; } - -.subheader { - padding:2px; - margin:0px; - background-color:#e2e2e2; - height:20px; - border:thin solid #e2e2e2; +#fileheader { + padding: 3px; } - -.subheader td { - font-family:arial,verdana,helvetica; - font-size:12px; - font-weight:bold; +#fileheader td a { + font-size: 10px; + text-align: center; } - -.filemsg { - color:#e2e2e2; - font-weight:bold; - font-family:arial,verdana,helvetica; - font-size:12px; - text-align:center; +.statusmsg { + color: #cccccc; + text-align: center; + font-weight: bold; } - -.yellowbg { - background-color:yellow; -} +.folderselected { + background-color:blue; + color:white; +} \ 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.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.js 6 Nov 2006 13:15:56 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/resources/ajaxfs.js 25 Dec 2006 16:23:26 -0000 1.2 @@ -1,18 +1,108 @@ -function showFolderContents(folder_id,tree) { +/* loadJs +helper that executes anything that is between script tags + in a responseText returned by an ajax call */ +function loadJs(responseText) { + var re=/(?:.*<\/script>)|(?:([\S\s]*?)<\/script>)/ig; + var match; + while (match = re.exec(responseText)) { + var s0 = document.createElement("script"); + if (match[1]) + s0.src = match[1]; + else if (match[2]) + s0.text = match[2]; + else + continue; + document.getElementsByTagName("head")[0].appendChild(s0); + } +} + +/* trimString +helper to remove trailing and leading spaces from a string */ +function trimString (str) { + str = this != window? this : str; + return str.replace(/^\s+/g, '').replace(/\s+$/g, ''); +} + +/* editInPlace +dynamically make the properties_name element editable*/ + +function editInPlace (objid,namediv,controldiv,type) { + this.objid = objid + this.namediv = document.getElementById(namediv); + this.controldiv = document.getElementById(controldiv); + this.oldnamediv_value = this.namediv.innerHTML; + this.oldcontroldiv_value = this.controldiv.innerHTML; + this.form_textbox = 'edip_name'; + this.form_ok = 'edip_save'; + this.form_cancel = 'edip_cancel'; + this.type = type; + this.setvalues = function (nameval,controlval) { + this.namediv.innerHTML = nameval; + this.controldiv.innerHTML = controlval; + } + this.addListeners = function() { + thisobj =this; + YAHOO.util.Event.addListener(this.form_ok, "click", this.saveedit,thisobj); + YAHOO.util.Event.addListener(this.form_cancel, "click", this.canceledit,thisobj); + } + this.rmListeners = function() { + thisobj =this; + YAHOO.util.Event.removeListener(this.form_ok, "click", this.saveedit,thisobj); + YAHOO.util.Event.removeListener(this.form_cancel, "click", this.canceledit,thisobj); + } + this.createform = function() { + var editform = ""; + editform = editform + " "; + editform = editform + ""; + this.setvalues(editform,''); + document.getElementById('edip_name').select(); + this.addListeners(); + } + this.canceledit = function(el,obj) { + obj.rmListeners(); + obj.setvalues(obj.oldnamediv_value,obj.oldcontroldiv_value); + } + this.saveedit = function(el,obj) { + // save the new name + var postData ='type='+obj.type+'&object_id='+obj.objid+'&newname='+document.getElementById(obj.form_textbox).value; + var callback = { + success: function(o) { + obj.namediv.innerHTML=o.responseText; + obj.controldiv.innerHTML=obj.oldcontroldiv_value; + + // check if node exists in tree + if ( tree != 'undefined') { + var node = tree.getNodeByProperty('id',obj.objid); + // update node name + if ( node != null) { + document.getElementById(node.getLabelEl().id).innerHTML=o.responseText; + } + } + + }, argument: { thisobj:obj } + } + YAHOO.util.Connect.asyncRequest('POST', '/ajaxfs/xmlhttp/editname', callback, postData); + } + this.createform(); +} + +/* showFolderContents +Called when a folder is clicked, fetches all the files and folders in a node */ + +function showFolderContents(folder_id,tree,sort) { + // show 'loading...' - document.getElementById('files').innerHTML = '


Loading . . . . .
'; + document.getElementById('files').innerHTML = '


Loading . . . . .
'; // expand the tree on click var thenode = tree.getNodeByProperty('id',folder_id); // remove highlight from the last folder if ( document.getElementById('lastfolder').value != "" ) { if (tree.getNodeByProperty('id',document.getElementById('lastfolder').value) != null ) { - var oldnode = tree.getNodeByProperty('id',document.getElementById('lastfolder').value); - oldlabel = oldnode.getLabelEl(); - document.getElementById(oldlabel.id).style.backgroundColor='white'; - document.getElementById(oldlabel.id).style.color='black'; + var oldnode = tree.getNodeByProperty('id',document.getElementById('lastfolder').value); + YAHOO.util.Dom.removeClass(oldnode.getLabelEl().id,'folderselected'); } } @@ -22,16 +112,55 @@ // write this node's id to the hidden field document.getElementById('lastfolder').value = folder_id; + // let's highlight the new selected folder + var newnode = tree.getNodeByProperty('id',document.getElementById('lastfolder').value); + YAHOO.util.Dom.addClass(newnode.getLabelEl().id,'folderselected'); + + // empty the items in the fsList object_id + fileList.emptyItems(); + // fetch contents via ajax - var postData ='folder_id='+folder_id; + var postData ='folder_id='+folder_id+'&orderby='+sort; var callback = { - success: function(o) { + success: function(o) { document.getElementById('files').innerHTML=o.responseText; + loadJs(o.responseText); } } - YAHOO.util.Connect.asyncRequest('POST', '/ajaxfs/xmlhttp/showfoldercontents', callback, postData); + YAHOO.util.Connect.asyncRequest('POST', '/ajaxfs/xmlhttp/showfoldercontents', callback, postData); + + showProperties(folder_id,'folder'); } +/* showProperties +Populates the action and properties panel with more information and actions*/ + +function showProperties (object_id,type) { + + var southpanel = innerLayout.getRegion('south'); + southpanel.setActivePanel('properties'); + + // fetch contents of properites + var postData ='object_id='+object_id+'&type='+type; + var callback = { + success: function(o) { + loadJs(o.responseText); + document.getElementById('properties').innerHTML=o.responseText; + } + } + YAHOO.util.Connect.asyncRequest('POST', '/ajaxfs/xmlhttp/showproperties', callback, postData); + + if (type === "folder" ) { + southpanel.hidePanel('revisions'); + } else { + southpanel.unhidePanel('revisions'); + // TODO : use ajax to fetch revisions table of the object + } +} + +/* loadDataForNode +Dynamically loads the child nodes of a given parent node*/ + function loadDataForNode(node, onCompleteCallback) { var postData ='parentfolderid='+node.data.id; @@ -45,12 +174,139 @@ } } - YAHOO.util.Connect.asyncRequest('POST', '/ajaxfs/xmlhttp/loadchildnodes', callback, postData); + YAHOO.util.Connect.asyncRequest('POST', '/ajaxfs/xmlhttp/loadchildnodes', callback, postData); } +/* openfolder +Opens a node in the folder tree */ + function openfolder(object_id) { // get a reference to the node for the given object_id var thenode = tree.getNodeByProperty('id',object_id); thenode.parent.expand(); - showFolderContents(object_id,tree); -} \ No newline at end of file + showFolderContents(object_id,tree,'name'); +} + +/* ajaxFsLayout +Prototype Object to generate the layout */ + +var layout; +var innerLayout; + +ajaxFsLayout = function() { + return { + init : function() { + layout = new YAHOO.ext.BorderLayout(document.body, { + hideOnLayout: true, + north: { + split:false, + initialSize: 25, + titlebar: false + }, + west: { + split:true, + initialSize: 300, + titlebar: true, + collapsible: true, + minSize: 100, + maxSize: 400 + }, + center: { + autoScroll: false + } + }); + layout.beginUpdate(); + layout.add('north', new YAHOO.ext.ContentPanel('header', '')); + layout.add('west', new YAHOO.ext.ContentPanel('folders', {title: 'Folders', fitToFrame:true, closable:false})); + innerLayout = new YAHOO.ext.BorderLayout('content', { + south: { + split:true, + initialSize: 200, + minSize: 100, + maxSize: 400, + autoScroll:true, + collapsible:true, + titlebar: true + }, + center: { + autoScroll:true + } + }); + innerLayout.add('south', new YAHOO.ext.ContentPanel('revisions', {title: 'Revisions', closable: false})); + innerLayout.add('south', new YAHOO.ext.ContentPanel('properties', {title: 'Properties', closable: false})); + innerLayout.add('center', new YAHOO.ext.ContentPanel('filepane')); + layout.add('center', new YAHOO.ext.NestedLayoutPanel(innerLayout)); + layout.endUpdate(); + } + } +}(); +YAHOO.ext.EventManager.onDocumentReady(ajaxFsLayout.init, ajaxFsLayout, true); + +/* fsList +object that manages fsItem objects*/ + +function fsList() { + //properties + // array of fsItems + this.items = []; + //methods + // adds an fsItem to the array of items + this.push = function(obj) { + this.items.push(obj); + } + // retrieves an fsItem from array given the id + this.getItem = function(id) { + var x=0; + for (x=0;xtarget="blank" title="@title@"> - - @shortened_name@ - - - @shortened_title@
- - @file_upload_name@ - -
\ No newline at end of file +@newname;noquote@ \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/editname.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/editname.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/editname.tcl 6 Nov 2006 13:15:58 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/editname.tcl 25 Dec 2006 16:23:26 -0000 1.2 @@ -1,109 +1,21 @@ ad_page_contract { Accepts the object_id and changes it to newname - + @author Hamilton Chua (ham@solutiongrove.com) @creation-date May 7, 2006 } { newname object_id + type } -# get the folder_id from the object_id -set folder_id [db_string "getfolder" "select parent_id from fs_objects where object_id=:object_id"] - -# get the root folder -set root_package_id [afs::get_root_folder -folder_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_name [lang::util::localize [fs::get_object_name -object_id $folder_id]] -set folder_path "" - -if {![exists_and_not_null root_folder_id]} { - set root_folder_id [fs::get_root_folder -package_id $root_package_id] -} - -if {![string equal $root_folder_id $folder_id]} { - set folder_path [db_exec_plsql get_folder_path "select content_item__get_path(:folder_id, :root_folder_id)"] -} else { - set folder_path "" -} - -ns_log Notice "HAM : $folder_id : $root_folder_id, $folder_path, $fs_url" - # change the name of the give object_id -if { $newname != "Type New Name" } { - db_dml "rename_file" "update cr_revisions set title=:newname where revision_id=(select live_revision from cr_items where item_id=:object_id)" -} - -# get the info of the object -db_0or1row "getinfo" " - select fs_objects.object_id, - fs_objects.mime_type, - trim(fs_objects.name) as 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.file_upload_name, - case - when :folder_path is null - then fs_objects.file_upload_name - else :folder_path || '/' || fs_objects.file_upload_name - end as file_url, - trim(fs_objects.title) as title - from fs_objects where object_id = :object_id" - -switch -- $type { - folder { - set file_url "javascript:openfolder('${object_id}')" - } - url { - set file_url ${url} - } - "application/pdf" { - set file_url "${fs_url}view/${file_url}" - } - "application/vnd.ms-excel" { - set file_url "${fs_url}view/${file_url}" - } - "application/zip" { - set file_url "${fs_url}view/${file_url}" - } - "application/msword" { - set file_url "${fs_url}view/${file_url}" - } - "video/flv" { - set file_url "${fs_url}view/${file_url}" - } - default { - set file_url "${fs_url}view/${file_url}" - } -} - -set name [string trim $name] - -if { [string length $name] > 29 } { - set shortened_name [string range $name 0 29] - append shortened_name "..." -} else { - set shortened_name $name -} - -set title [string trim $title] - -if { [string length $title] > 29 } { - set shortened_title [string range $title 0 29] - append shortened_title "..." -} else { - set shortened_title $title -} - -set file_upload_name [string trim $file_upload_name] +if { [exists_and_not_null newname] } { + # determine if this is a folder or file + if { $type == "folder" } { + db_dml "rename_folder" "update cr_folders set label = :newname where folder_id = :object_id" + } else { + db_dml "rename_file" "update cr_revisions set title=:newname where revision_id=(select live_revision from cr_items where item_id=:object_id)" + } +} \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/loadchildnodes-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes-postgresql.xql 6 Nov 2006 13:15:58 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes-postgresql.xql 25 Dec 2006 16:23:26 -0000 1.2 @@ -12,7 +12,7 @@ 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') + and m.privilege = 'read') order by fs_objects.title Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/loadchildnodes.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes.tcl 9 Dec 2006 17:21:26 -0000 1.2 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/loadchildnodes.tcl 25 Dec 2006 16:23:26 -0000 1.3 @@ -1,7 +1,7 @@ ad_page_contract { Populates a parent node with its children. The folder id is passed to this via xmlhttp call. - + @author Hamilton Chua (ham@solutiongrove.com) @creation-date Feb 24, 2006 } { @@ -24,7 +24,7 @@ # verify if the folder has contents - if { [db_string "countcontent" ""] > 0 } { + if { [db_string "countcontent" ""] > 0 } { set dyn_load_script "loadDataForNode" } else { set dyn_load_script "" @@ -34,8 +34,8 @@ append script [ah::yui::create_tree_node -varname $object_id \ -label $name \ -treevarname "tree" \ - -href "javascript:showFolderContents('${object_id}',tree)" \ - -attach_to_node "$parentfolderid" \ + -href "javascript:showFolderContents('${object_id}',tree,'name')" \ + -attach_to_node $parentfolderid \ -dynamic_load $dyn_load_script ] } Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/showfoldercontents-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents-postgresql.xql 6 Nov 2006 13:15:58 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents-postgresql.xql 25 Dec 2006 16:23:26 -0000 1.2 @@ -38,7 +38,7 @@ where m.object_id = fs_objects.object_id and m.party_id = :viewing_user_id and m.privilege = 'read') - order by type + order by $orderby @@ -51,4 +51,4 @@ - + Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/showfoldercontents.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.adp 6 Nov 2006 13:15:58 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.adp 25 Dec 2006 16:23:26 -0000 1.2 @@ -1,32 +1,44 @@ -


This folder is empty.
+


This folder is empty.

- - +
+ - - - + + +
-
+
+
target="blank" title="@contents.name@@contents.title@"> @contents.shortened_name@ - @contents.shortened_title@
+ @contents.shortened_title@
@contents.file_upload_name@
-
[ Rename ]
@contents.content_size_pretty@@contents.last_modified_pretty@@contents.content_size_pretty@@contents.pretty_type@@contents.last_modified_pretty@
+ + +
\ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/showfoldercontents.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.tcl 6 Nov 2006 13:15:58 -0000 1.1 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showfoldercontents.tcl 25 Dec 2006 16:23:26 -0000 1.2 @@ -2,21 +2,19 @@ Populates the file container div with the contents of the passed folder id. This page is meant to be called via xmlhttp - + @author Hamilton Chua (ham@solutiongrove.com) @creation-date Feb 24, 2006 } { {folder_id:integer} {element ""} - {orderby "actions,asc"} + {orderby "type"} } #ns_log Notice "HAM : fetching $folder_id : $element" # TODO :refine permissions -# for now we just make sure it's an admin set viewing_user_id [ad_conn user_id] -set admin_p [permission::permission_p -party_id $viewing_user_id -object_id $folder_id -privilege "admin"] # get the root folder set root_package_id [afs::get_root_folder -folder_id $folder_id] @@ -96,43 +94,43 @@ folder { # set file_url "${fs_url}index?[export_vars {{folder_id $object_id}}]" set file_url "javascript:openfolder('${object_id}')" - set download_url $file_url - set icon "/resources/ajax-filestorage-ui/icons/folder.jpg" + set download_url $file_url + set icon "/resources/ajax-filestorage-ui/icons/folder.gif" } url { set icon "/resources/acs-subsite/url-button.gif" set file_url ${url} - set download_url $file_url + set download_url $file_url } "application/pdf" { set file_url "${fs_url}view/${file_url}" - set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" + set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" set icon "/resources/ajax-filestorage-ui/icons/pdf.gif" } "application/vnd.ms-excel" { set file_url "${fs_url}view/${file_url}" - set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" + set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" set icon "/resources/ajax-filestorage-ui/icons/excel.gif" } "application/zip" { set file_url "${fs_url}view/${file_url}" - set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" + set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" set icon "/resources/ajax-filestorage-ui/icons/zip.gif" } "application/msword" { set file_url "${fs_url}view/${file_url}" - set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" + set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" set icon "/resources/ajax-filestorage-ui/icons/word.gif" } - "video/x-flv" { - set file_url "${fs_url}view/${file_url}" - set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" - set icon "/resources/ajax-filestorage-ui/icons/flv.jpg" - } + "video/x-flv" { + set file_url "${fs_url}view/${file_url}" + set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" + set icon "/resources/ajax-filestorage-ui/icons/flv.jpg" + } default { set icon "/resources/ajax-filestorage-ui/icons/icon_html.gif" set file_url "${fs_url}view/${file_url}" - set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" + set download_url "${fs_url}download/?[export_vars {{file_id $object_id}}]" } } Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/showproperties-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties-postgresql.xql 25 Dec 2006 16:23:26 -0000 1.1 @@ -0,0 +1,33 @@ + + + + postgresql7.1 + + + + select fs_objects.object_id, + fs_objects.mime_type, + trim(fs_objects.name) as name, + fs_objects.live_revision, + fs_objects.type, + fs_objects.pretty_type, + fs_objects.parent_id, + 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.file_upload_name, + trim(fs_objects.title) as title, + 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.object_id = $object_id + + + + + + Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/showproperties.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties.adp 25 Dec 2006 16:23:27 -0000 1.1 @@ -0,0 +1,50 @@ + +
+ + + + + + +
+ + + + + + + + + +
+
+ + @name@ + + + @title@ + +
+ + + [ Rename ] + + +
Type :@pretty_type;noquote@
Size :@content_size_pretty;noquote@
Last Modified :@last_modified_pretty;noquote@
+
+ + Actions + +
  • Download an Archive of this folder +
  • Upload a new File to this folder +
  • Create a new folder here +
  • Delete this folder + + +
  • Download this file +
  • Upload a New Version of this file +
  • Delete this file + + +
  • +
    \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/Attic/showproperties.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/www/xmlhttp/showproperties.tcl 25 Dec 2006 16:23:27 -0000 1.1 @@ -0,0 +1,69 @@ +ad_page_contract { + + Retrieves the properties of a file or folder. + Shows actions that a user can perform for the given item + This page is meant to be called via xmlhttp + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-12-25 +} { + {object_id:integer} + {type "file"} +} + +set viewing_user_id [ad_conn user_id] +set found_obj [db_0or1row "select_one_file_object" {}] + +# ** try to get the path to this object_id ** + +# get the root folder from the parent of this object +set root_package_id [afs::get_root_folder -folder_id $parent_id] +set fs_url [apm_package_url_from_id $root_package_id] + +# ** properly format the values for display ** + +# last modified +set last_modified_ansi [lc_time_system_to_conn $last_modified_ansi] +set last_modified_pretty [lc_time_fmt $last_modified_ansi "%x %X"] + +# content size +if {[string equal $type "folder"]} { + set content_size_pretty [lc_numeric $content_size] + append content_size_pretty " [_ file-storage.items]" + set pretty_type "Folder" +} 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]" + } +} + +# customize icon +switch -- $type { + folder { + set icon "/resources/ajax-filestorage-ui/icons/folder.gif" + set download_url "${fs_url}/download-archive/index?object_id=${object_id}" + } + url { + set icon "/resources/acs-subsite/url-button.gif" + } + "application/pdf" { + set icon "/resources/ajax-filestorage-ui/icons/pdf.gif" + } + "application/vnd.ms-excel" { + set icon "/resources/ajax-filestorage-ui/icons/excel.gif" + } + "application/zip" { + set icon "/resources/ajax-filestorage-ui/icons/zip.gif" + } + "application/msword" { + set icon "/resources/ajax-filestorage-ui/icons/word.gif" + } + "video/x-flv" { + set icon "/resources/ajax-filestorage-ui/icons/flv.jpg" + } + default { + set icon "/resources/ajax-filestorage-ui/icons/icon_html.gif" + } +} \ No newline at end of file