Index: openacs-4/packages/xowiki/tcl/link-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/link-procs.tcl,v diff -u -r1.59 -r1.60 --- openacs-4/packages/xowiki/tcl/link-procs.tcl 26 Jan 2009 21:26:07 -0000 1.59 +++ openacs-4/packages/xowiki/tcl/link-procs.tcl 1 Feb 2009 16:25:16 -0000 1.60 @@ -39,7 +39,7 @@ # internal links # Class create Link -superclass BaseLink -parameter { - type name lang stripped_name page + {type link} name lang stripped_name page parent_id package_id } Link instproc folder_id args { Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.324 -r1.325 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 29 Jan 2009 15:05:18 -0000 1.324 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 1 Feb 2009 16:25:16 -0000 1.325 @@ -1108,7 +1108,30 @@ return [string map [list ">" > "<" < """ \" "&" & "&semicolon;" {;} ] $string] } - Page instproc anchor {arg} { + + Page instproc normalize_internal_link_name {name stripped_name lang} { + set anchor "" + set query "" + # remove anchor + regexp {^([^#]*)(\#|%23)(.*)$} $stripped_name _ stripped_name . anchor + # remove query part + regexp {^(.*)[?]([^?]+)$} $stripped_name _ stripped_name query + + + # if we have an empty stripped name, it is a link to the current + # page, maybe in a different language + if {$stripped_name eq ""} { + regexp {:([^:]+)$} $name _ stripped_name + } + + set normalized_name [[my package_id] normalize_name $stripped_name] + + if {$lang eq ""} {set lang [my lang]} + if {$name eq ""} {set name $lang:$normalized_name} + return [list name $name lang $lang normalized_name $normalized_name anchor $anchor] + } + + Page instproc create_link {arg} { #my msg [self args] set label $arg set link $arg @@ -1145,15 +1168,13 @@ -type localimage [list -label $label] \ -href $link eval [self]::link configure $options - return [[self]::link render] + return [self]::link } } } set l [ExternalLink new [list -label $label] -href $link] eval $l configure $options - set html [$l render] - $l destroy - return $html + return $l } set parent_id [$package_id folder_id] @@ -1167,8 +1188,8 @@ set lang "" set name file:$stripped_name } else { - # do we have a typed link? more than two chars... - if {[regexp {^([^:][^:][^:]+):((..):)?(.+)$} $link _ \ + # do we have a typed link? prefix has more than two chars... + if {[regexp {^([^:/?][^:/?][^:/?]+):((..):)?(.+)$} $link _ \ link_type _ lang stripped_name]} { set name file:$stripped_name } else { @@ -1202,33 +1223,35 @@ } } - set anchor "" - regexp {^([^#]*)(\#|%23)(.*)$} $stripped_name _ stripped_name . anchor + array set "" [my normalize_internal_link_name $name $stripped_name $lang] - #my msg name=$name,stripped_name=$stripped_name,link_type=$link_type,lang=$lang,a=$anchor - if {$stripped_name eq ""} {regexp {:([^:]+)$} [my name] _ stripped_name} + if {$label eq $arg} {set label $(normalized_name)} - set normalized_name [::$package_id normalize_name $stripped_name] - - if {$lang eq ""} {set lang [my lang]} - if {$name eq ""} {set name $lang:$normalized_name} - if {$label eq $arg} {set label $stripped_name} - Link create [self]::link \ -page [self] \ - -type $link_type [list -name $name] -lang $lang [list -anchor $anchor] \ - [list -stripped_name $normalized_name] [list -label $label] \ + -type $link_type [list -name $(name)] -lang $(lang) [list -anchor $(anchor)] \ + [list -stripped_name $(normalized_name)] [list -label $label] \ -parent_id $parent_id -package_id $package_id if {[catch {eval [self]::link configure $options} errorMsg]} { ns_log error "$errorMsg\n$::errorInfo" return "
$errorMsg
$errorMsg