Index: openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl,v diff -u -r1.25 -r1.26 --- openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl 11 Jan 2002 21:36:42 -0000 1.25 +++ openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl 16 Jan 2002 21:17:05 -0000 1.26 @@ -15,14 +15,21 @@ namespace eval fs_portlet { + ad_proc -private my_package_key { + } { + return "fs-portlet" + } + ad_proc -private my_name { } { - return "fs_portlet" + return "fs_portlet" } ad_proc -public get_pretty_name { } { - return "Documents" + return [ad_parameter \ + -package_id [apm_package_id_from_key [my_package_key]] \ + "pretty_name"] } ad_proc -public link { @@ -35,8 +42,8 @@ instance_id folder_id } { - Adds a fs PE to the given page with the community_id and - folder_id being opaque data in the portal configuration. + Adds a fs PE to the given page. If there's already and fs pe, + it appends the values to the pe's params. @return element_id The new element's id @param portal_id The page to add self to @@ -45,138 +52,16 @@ @author arjun@openforce.net @creation-date Sept 2001 } { - # Add some smarts to only add one portlet for now when it's - # added multiple times (ben) - # Find out if bboard already exists - set element_id_list \ - [portal::get_element_ids_by_ds $portal_id [my_name]] - - if {[llength $element_id_list] == 0} { - # Tell portal to add this element to the page - set element_id [portal::add_element $portal_id [my_name]] - # There is already a value for the param which must be overwritten - portal::set_element_param $element_id instance_id $instance_id - portal::set_element_param $element_id folder_id $folder_id - set package_id_list [list] - } else { - set element_id [lindex $element_id_list 0] - # There are existing values which should NOT be overwritten - portal::add_element_param_value \ - -element_id $element_id \ - -key instance_id \ - -value $instance_id - - portal::add_element_param_value \ - -element_id $element_id \ - -key folder_id \ - -value $folder_id - } - - return $element_id + return [portal::add_element_or_append_id -portal_id $portal_id \ + -portlet_name [my_name] \ + -value_id $folder_id \ + -key folder_id] } - ad_proc -public show { - cf - } { - Display the PE - - @return HTML string - @param cf A config array - @author arjun@openforce.net - @creation-date Sept 2001 - } { - - array set config $cf - - # things we need in the config folder_id - - # get user_id from the conn at this point - - set user_id [ad_conn user_id] - - # a big-time query from file-storage - set query " - select i.item_id as file_id, - r.title as name, - i.live_revision file_live_rev, - r.mime_type as type, - 1 as ordering_key, - 0 as num - from cr_items i, cr_revisions r, acs_objects o - where i.item_id = o.object_id - and i.live_revision = r.revision_id (+) - and i.parent_id = :my_folder_id - and acs_permission.permission_p(i.item_id, :user_id, 'read') = 't' - and i.content_type = 'content_revision' - UNION - select - i.item_id as file_id, - f.label as name, - 0, - 'Folder', - 0, - (select count(*) from cr_items where parent_id = i.item_id) as num - from cr_items i, cr_folders f - where i.item_id = f.folder_id - and i.parent_id = :my_folder_id - and acs_permission.permission_p(:my_folder_id, :user_id, 'read') = 't' order by ordering_key,name" - - set template "
$name | $type | " - if { $num > 1 || $num == 0 } { - append data "$num items | " - } else { - append data "$num item | " - } - } else { - set type "File" - append data "
$name | File | \[download\] | " - } - append template "\n$data\n" - } - } - - append template "