Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -r1.279.2.7 -r1.279.2.8 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 17 Feb 2014 18:38:48 -0000 1.279.2.7 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 13 Mar 2014 12:36:03 -0000 1.279.2.8 @@ -1,9 +1,9 @@ ::xo::library doc { - XoWiki - package specific methods + XoWiki - package specific methods - @creation-date 2006-10-10 - @author Gustaf Neumann - @cvs-id $Id$ + @creation-date 2006-10-10 + @author Gustaf Neumann + @cvs-id $Id$ } namespace eval ::xowiki { @@ -13,8 +13,8 @@ -pretty_name "XoWiki" \ -package_key xowiki \ -parameter { - {folder_id 0} - {force_refresh_login false} + {folder_id 0} + {force_refresh_login false} } # {folder_id "[::xo::cc query_parameter folder_id 0]"} @@ -33,7 +33,7 @@ } elseif {$item_id} { set object_id $item_id } else { - error "Either item_id or revision_id must be provided" + error "Either item_id or revision_id must be provided" } return [::xo::dc get_value get_pid {select package_id from acs_objects where object_id = :object_id}] } @@ -49,14 +49,14 @@ when testing e.g. from the developer shell } { set package_id [my get_package_id_from_page_id \ - -item_id $item_id \ - -revision_id $revision_id] + -item_id $item_id \ + -revision_id $revision_id] ::xo::Package initialize \ - -export_vars false \ - -package_id $package_id \ - -init_url false -actual_query "" \ - -parameter $parameter \ - -user_id $user_id + -export_vars false \ + -package_id $package_id \ + -init_url false -actual_query "" \ + -parameter $parameter \ + -user_id $user_id set page [::xo::db::CrClass get_instance_from_db -item_id $item_id -revision_id $revision_id] ::$package_id set_url -url [$page pretty_link] return $page @@ -128,14 +128,14 @@ # TODO we should be able to get rid of this by using a canonical /folder/ in # case of potential conflicts, like for file.... - # check if we have a LANG - FOLDER "conflict" - set item_id [::xo::db::CrClass lookup -name $lang -parent_id [my folder_id]] - if {$item_id} { - my msg "We have a lang-folder 'conflict' (or a two-char folder) with folder: $lang" - set local_name $path - if {$default_lang eq ""} {set default_lang [my default_language]} - set lang $default_lang - } + # check if we have a LANG - FOLDER "conflict" + set item_id [::xo::db::CrClass lookup -name $lang -parent_id [my folder_id]] + if {$item_id} { + my msg "We have a lang-folder 'conflict' (or a two-char folder) with folder: $lang" + set local_name $path + if {$default_lang eq ""} {set default_lang [my default_language]} + set lang $default_lang + } } elseif {[regexp {^(file|image|swf|download/file|download/..|tag)/(.*)$} $path _ lang local_name]} { } else { @@ -164,12 +164,12 @@ foreach item_ref $inherit_folders { set folder [::xo::cc cache [list $package get_page_from_item_ref $item_ref]] if {$folder eq ""} { - my log "Error: Could not resolve parameter folder page '$item_ref' of FormPage [self]." + my log "Error: Could not resolve parameter folder page '$item_ref' of FormPage [self]." } else { - set item_id [::xo::db::CrClass lookup -name $name -parent_id [$folder item_id]] - if { $item_id != 0 } { - return $item_id - } + set item_id [::xo::db::CrClass lookup -name $name -parent_id [$folder item_id]] + if { $item_id != 0 } { + return $item_id + } } } return 0 @@ -183,31 +183,31 @@ # try without a prefix set p [my lookup -name $parent -parent_id $parent_id] if {$p == 0} { - # check if page is inherited - set p2 [my get_page_from_super -folder_id $parent_id $parent] - if { $p2 != 0 } { - set p $p2 - } + # check if page is inherited + set p2 [my get_page_from_super -folder_id $parent_id $parent] + if { $p2 != 0 } { + set p $p2 + } } if {$p == 0} { # content pages are stored with a lang prefix set p [my lookup -name ${lang}:$parent -parent_id $parent_id] #my log "check with prefix '${lang}:$parent' returned $p" - if {$p == 0 && $lang ne "en"} { - # try again with prefix "en" - set p [my lookup -name en:$parent -parent_id $parent_id] - #my log "check with en 'en:$parent' returned $p" - } + if {$p == 0 && $lang ne "en"} { + # try again with prefix "en" + set p [my lookup -name en:$parent -parent_id $parent_id] + #my log "check with en 'en:$parent' returned $p" + } } if {$p != 0} { if {[regexp {^([^/]+)/(.+)$} $local_name _ parent2 local_name2]} { set p2 [my get_parent_and_name -path $local_name -lang $lang -parent_id $p parent local_name] #my log "recursive call for '$local_name' parent_id=$p returned $p2" if {$p2 != 0} { - set p $p2 + set p $p2 } } } @@ -266,31 +266,31 @@ 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} { - #my 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 { - #my 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 [my get_page_from_name -parent_id $parent_id -assume_folder true -name $context_name] - if {$context_folder eq ""} { - my msg "my get_page_from_name -parent_id $parent_id -assume_folder true -name $context_name ==> EMPTY" - my msg "Cannot lookup '$context_name' in package folder $parent_id [$parent_id name]" - - set new_path [join [lrange $parts 0 $index] /] - set p2 [my get_parent_and_name -path [join [lrange $parts 0 $index] /] -lang "" -parent_id $parent_id parent local_name] - my msg "p2=$p2 new_path=$new_path '$local_name' ex=[nsf::object::exists $p2] [$p2 name]" - - } - my 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 - } + set context_name [lindex $parts $index] + if {1 && $parent_id in $folder_ids} { + #my 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 { + #my 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 [my get_page_from_name -parent_id $parent_id -assume_folder true -name $context_name] + if {$context_folder eq ""} { + my msg "my get_page_from_name -parent_id $parent_id -assume_folder true -name $context_name ==> EMPTY" + my msg "Cannot lookup '$context_name' in package folder $parent_id [$parent_id name]" + + set new_path [join [lrange $parts 0 $index] /] + set p2 [my get_parent_and_name -path [join [lrange $parts 0 $index] /] -lang "" -parent_id $parent_id parent local_name] + my msg "p2=$p2 new_path=$new_path '$local_name' ex=[nsf::object::exists $p2] [$p2 name]" + + } + my 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 + } } #my get_lang_and_name -name [$fo name] lang stripped_name @@ -299,26 +299,26 @@ 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} { - #my 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] - } - } - set target [$fo get_target_from_link_page] - set target_name [$target name] - #my msg "----- $path // target $target [$target name] package_id [$target package_id] path '$path'" - regsub "^$target_name/" $path "" path - #my msg "----> $path => [$fo name]/$path" + set pid [$fo package_id] + foreach id $ids { + if {[$id package_id] ne $pid} { + #my 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] + } + } + set target [$fo get_target_from_link_page] + set target_name [$target name] + #my msg "----- $path // target $target [$target name] package_id [$target package_id] path '$path'" + regsub "^$target_name/" $path "" path + #my msg "----> $path => [$fo name]/$path" } # prepend always the actual name set path [$fo name]/$path if {[my folder_id] == [$fo parent_id]} { - #my msg ".... my folder_id [my folder_id] == $fo parentid" - break + #my msg ".... my folder_id [my folder_id] == $fo parentid" + break } set parent_id [$fo parent_id] @@ -327,7 +327,7 @@ #my msg ====$path return $path } - + Package ad_instproc external_name { {-parent_id ""} @@ -403,13 +403,13 @@ set folder "" } else { if {$parent_id eq ""} { - ns_log notice "pretty_link of $name: you should consider to pass a parent_id to support folders" - set parent_id [my folder_id] + ns_log notice "pretty_link of $name: you should consider to pass a parent_id to support folders" + set parent_id [my folder_id] } set folder [my folder_path -parent_id $parent_id -folder_ids $folder_ids] set pkg [$parent_id package_id] if {![my isobject ::$pkg]} { - ::xowiki::Package initialize -package_id $pkg -init_url false -keep_cc true + ::xowiki::Package initialize -package_id $pkg -init_url false -keep_cc true } set package_prefix [$pkg get_parameter package_prefix [$pkg package_url]] } @@ -479,10 +479,10 @@ #my msg pp=$pp,page=$page-att=$attribute if {$page ne "" && [$page exists instance_attributes]} { - set __ia [$page set instance_attributes] - if {[dict exists $__ia $attribute]} { - set value [dict get $__ia $attribute] - } + set __ia [$page set instance_attributes] + if {[dict exists $__ia $attribute]} { + set value [dict get $__ia $attribute] + } } } } @@ -663,16 +663,16 @@ will be activated, the specified method of the object will be invoked. make_link checks in advance, wether the actual user has enough rights to invoke the method. If not, this method returns empty. - + @param Object The object to which the link refers to. If it is a package_id it will base \ to the root_url of the package_id. If it is a page, it will base to the page_url @param method Which method to use. This will be appended as "m=method" to the url. Examples for methods: -