xowiki::Package instproc folder_path (public)
<instance of xowiki::Package> folder_path \ [ -parent_id parent_id ] [ -context_url context_url ] \ [ -folder_ids folder_ids ] [ -path_encode on|off ]
Defined in /var/www/openacs.org/packages/xowiki/tcl/package-procs.tcl
Construct a folder path from a hierarchy of xowiki objects. It is designed to work with linked objects, respecting logical and physical parent IDs. The result is URL encoded, unless path_encode is set to false.
- Switches:
- -parent_id (optional)
- -context_url (optional)
- -folder_ids (optional)
- -path_encode (optional, boolean, defaults to
"true"
)- Testcases:
- link_tests
Source code: # # Handle different parent_ids # if {$parent_id eq "" || $parent_id == ${:folder_id}} { return "" } # # The item might be in a folder along the folder path. So it # will be found by the object resolver. For the time being, we # do nothing more about this. # # if { $context_url ne {} } { set parts [split $context_url /] set index [expr {[llength $parts]-1}] } if { $context_url ne {} } { set context_id [:get_parent_and_name -path $context_url -lang "" -parent_id $parent_id parent local_name] #:msg "context_url $context_url folder_ids $folder_ids context_id $context_id" } set path "" set ids {} while {1} { lappend ids $parent_id set fo [::xo::db::CrClass get_instance_from_db -item_id $parent_id] if { $context_url ne {} } { set context_name [lindex $parts $index] if {1 && $parent_id in $folder_ids} { #:msg "---- parent $parent_id in $folder_ids" set context_id [::$context_id item_id] set fo [::xo::db::CrClass get_instance_from_db -item_id $context_id] } else { #:msg "context_url $context_url, parts $parts, context_name $context_name // parts $parts // index $index / folder $fo" if { [$fo name] ne $context_name } { set context_folder [:get_page_from_name -parent_id $parent_id -assume_folder true -name $context_name] if {$context_folder eq ""} { :msg "my get_page_from_name -parent_id $parent_id -assume_folder true -name $context_name ==> EMPTY" :msg "Cannot lookup '$context_name' in package folder $parent_id [::$parent_id name]" set new_path [join [lrange $parts 0 $index] /] set p2 [:get_parent_and_name -path [join [lrange $parts 0 $index] /] -lang "" -parent_id $parent_id parent local_name] :msg "p2=$p2 new_path=$new_path '$local_name' ex=[nsf::object::exists $p2] [$p2 name]" } :msg "context_name [$context_folder serialize]" set context_id [$context_folder item_id] set fo [::xo::db::CrClass get_instance_from_db -item_id $context_id] } incr index -1 } } #:get_lang_and_name -name [$fo name] lang stripped_name #set path $stripped_name/$path if {[$fo parent_id] < 0} break if {[$fo is_link_page]} { set pid [$fo package_id] foreach id $ids { if {[::$id package_id] ne $pid} { #:msg "SYMLINK ++++ have to fix package_id of $id from [::$id package_id] to $pid" $id set_resolve_context -package_id $pid -parent_id [::$id parent_id] } } if {0} { # # In some older versions, this code was necessary. Keep it # here as a reference, in case not all relevant cases were # covered by the tests # set target [$fo get_target_from_link_page] set target_name [$target name] #:msg "----- $path // target $target [$target name] package_id [$target package_id] path '$path'" set orig_path $path regsub "^$target_name/" $path "" path if {$orig_path ne $path} { :msg "----> orig <$orig_path> new <$path> => full [$fo name]/$path" } } } set name [$fo name] if {$path_encode} { set name [ad_urlencode_path $name] } # prepend always the actual folder name set path $name/$path if {${:folder_id} == [$fo parent_id]} { #:msg ".... :folder_id ${:folder_id} == $fo parentid" break } set parent_id [$fo parent_id] } #:msg ====$path return $pathXQL Not present: Generic, PostgreSQL, Oracle