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.98 -r1.99 --- openacs-4/packages/xowiki/tcl/link-procs.tcl 30 Sep 2017 18:12:53 -0000 1.98 +++ openacs-4/packages/xowiki/tcl/link-procs.tcl 21 Oct 2017 17:06:24 -0000 1.99 @@ -17,20 +17,20 @@ BaseLink instproc built_in_target {} { # currently, we do not support named frames, which are mostly deprecated - return [expr {[my target] in {_blank _self _parent _top}}] + return [expr {[:target] in {_blank _self _parent _top}}] } BaseLink instproc anchor_atts {} { set atts {} - if {[my exists title]} {lappend atts "title='[string map [list ' {'}] [my title]]'"} - if {[my exists target] && [my built_in_target]} { - lappend atts "target='[my target]'" + if {[info exists :title]} {lappend atts "title='[string map [list ' {'}] [:title]]'"} + if {[info exists :target] && [:built_in_target]} { + lappend atts "target='[:target]'" } return [join $atts " "] } BaseLink instproc mk_css_class {{-additional ""} {-default ""}} { - set cls [expr {[my exists cssclass] ? [my cssclass] : $default}] + set cls [expr {[info exists :cssclass] ? [:cssclass] : $default}] if {$additional ne ""} { if {$cls eq ""} {set cls $additional} else {append cls " " $additional} } @@ -39,8 +39,8 @@ } BaseLink instproc mk_css_class_and_id {{-additional ""} {-default ""}} { - if {[my exists cssid]} {set id "id='[my cssid]'"} else {set id ""} - set cls [my mk_css_class -additional $additional -default $default] + if {[info exists :cssid]} {set id "id='[:cssid]'"} else {set id ""} + set cls [:mk_css_class -additional $additional -default $default] return [string trim "$cls $id"] } @@ -49,9 +49,8 @@ # Class create ExternalLink -superclass BaseLink ExternalLink instproc render {} { - my instvar href label - set css_atts [my mk_css_class_and_id -additional external] - return "$label " + set css_atts [:mk_css_class_and_id -additional external] + return "[ns_quotehtml ${:label}] " } # @@ -63,33 +62,31 @@ is_self_link } Link instproc init {} { - my instvar page name - set class [self class]::[my type] - if {[my isclass $class]} {my class $class} - if {![my exists name]} { - set name [string trimleft [my lang]:[my stripped_name] :] - } elseif {![my exists stripped_name]} { + set class [self class]::[:type] + if {[:isclass $class]} {:class $class} + if {![info exists :name]} { + set :name [string trimleft [:lang]:${:stripped_name} :] + } elseif {![info exists :stripped_name]} { # set stripped name and lang from provided name or to the default - my instvar stripped_name lang - if {![regexp {^(..):(.*)$} $name _ lang stripped_name]} { - set stripped_name $name; set lang "" + if {![regexp {^(..):(.*)$} ${:name} _ lang :stripped_name]} { + set :stripped_name ${:name}; set :lang "" } } - if {![my exists label]} {my label $name} - if {![my exists parent_id]} {my parent_id [$page parent_id]} - if {![my exists package_id]} {my package_id [$page package_id]} - #my msg "--L link has class [my info class] // $class // [my type] // [my parent_id]" + if {![info exists :label]} {set :label ${:name}} + if {![info exists :parent_id]} {set :parent_id [${:page} parent_id]} + if {![info exists :package_id]} {set :package_id [${:page} package_id]} + #my msg "--L link has class [:info class] // $class // [:type] // ${:parent_id}" } Link instproc link_name {-lang -stripped_name} { return $lang:$stripped_name } Link instproc resolve {} { - return [my item_id] + return ${:item_id} } Link instproc render_target {href label} { #ns_log notice render_target - set target [my target] + set target [:target] if {[info commands ::xowiki::template::$target] ne ""} { # # The target template exists. use the template @@ -100,8 +97,8 @@ # can be referenced multiple times. The link is included for # each occurrence. # - set item_id [my item_id] - set targetId [xowiki::Includelet html_id [my item_id]-$target] + set item_id ${:item_id} + set targetId [xowiki::Includelet html_id ${:item_id}-$target] set page [::xo::db::CrClass get_instance_from_db -item_id $item_id -revision_id 0] set content "Loading ..." set withBody true @@ -128,39 +125,37 @@ return $result } else { ns_log notice "xowiki::link: unknown target $target" - return "$label" + return "$label" } } Link instproc render_found {href label} { if {$href eq ""} { return "$label" - } elseif {[my exists target] && ![my built_in_target]} { - return [my render_target $href $label] + } elseif {[info exists :target] && ![:built_in_target]} { + return [:render_target $href $label] } else { - return "$label" + return "$label" } } Link instproc render_not_found {href label} { if {$href eq ""} { return \[$label\] } else { - return " $label" + return " $label" } } Link instproc pretty_link {item_id} { - my instvar package_id - return [::$package_id pretty_link -parent_id [my parent_id] -lang [my lang] \ - -anchor [my anchor] -query [my query] [my name]] + return [::${:package_id} pretty_link -parent_id ${:parent_id} -lang [:lang] \ + -anchor [:anchor] -query [:query] [:name]] } Link instproc new_link {} { - my instvar package_id form - set page [my page] - set nls_language [$page get_nls_language_from_lang [my lang]] - if {$form ne ""} { - return [$package_id make_form_link -form $form \ - -parent_id [my parent_id] \ - -name [my name] \ + set page [:page] + set nls_language [$page get_nls_language_from_lang [:lang]] + if {${:form} ne ""} { + return [${:package_id} make_form_link -form ${:form} \ + -parent_id ${:parent_id} \ + -name [:name] \ -nls_language $nls_language] } @@ -180,24 +175,23 @@ } return [$page new_link \ {*}[expr {[info exists object_type] ? [list -object_type $object_type] : {}}] \ - -name [my name] -title [my label] -parent_id [my parent_id] \ - -nls_language $nls_language $package_id] + -name [:name] -title [:label] -parent_id ${:parent_id} \ + -nls_language $nls_language ${:package_id}] } Link instproc render {} { - my instvar package_id - set page [my page] - set item_id [my resolve] + set page [:page] + set item_id [:resolve] if {$item_id} { - $page references resolved [list $item_id [my type]] - ::xowiki::Package require $package_id - if {![my exists href]} { - my set href [my pretty_link $item_id] + $page references resolved [list $item_id [:type]] + ::xowiki::Package require ${:package_id} + if {![info exists :href]} { + set :href [:pretty_link $item_id] } - my render_found [my set href] [my label] + :render_found ${:href} [:label] } else { - set new_link [my new_link] - set html [my render_not_found $new_link [my label]] + set new_link [:new_link] + set html [:render_not_found $new_link [:label]] $page references unresolved $html return $html } @@ -211,7 +205,7 @@ set package_id [site_node::get_children -node_id $a -package_key xowiki \ -filters [list name $name] -element package_id] if {$package_id ne ""} { - #my log "--LINK found package_id=$package_id [my isobject ::$package_id]" + #my log "--LINK found package_id=$package_id [:isobject ::$package_id]" ::xowiki::Package require $package_id return $package_id } @@ -236,8 +230,8 @@ # this can be used into templates as id to safely attach event # handlers to elements set timed_id [clock microseconds] - if {$with_link} {append result [subst [my link_template]]} - if {$with_body} {append result [subst [my body_template]]} + if {$with_link} {append result [subst [:link_template]]} + if {$with_body} {append result [subst [:body_template]]} return $result } @@ -349,9 +343,8 @@ return $stripped_name } ::xowiki::Link::folder instproc pretty_link {item_id} { - my instvar package_id - return [::$package_id pretty_link \ - -anchor [my anchor] -parent_id [my parent_id] -query [my query] [my name] ] + return [::${:package_id} pretty_link \ + -anchor [:anchor] -parent_id ${:parent_id} -query [:query] ${:name} ] } # @@ -361,27 +354,27 @@ return_only } ::xowiki::Link::language instproc render {} { - set page [my page] - my instvar lang name package_id - set item_id [my resolve] + set page [:page] + set item_id [:resolve] if {$item_id} { set image_css_class "found" - set link [$package_id pretty_link -lang $lang -parent_id [my parent_id] [my stripped_name]] + set link [${:package_id} pretty_link -lang ${:lang} -parent_id ${:parent_id} [:stripped_name]] } else { set image_css_class "undefined" set last_page_id [$page set item_id] set object_type [[$page info class] set object_type] - set link [$package_id make_link $package_id \ + set name ${:name} + set link [${:package_id} make_link ${:package_id} \ edit-new object_type name last_page_id] } - # my log "--lang_link=$link" - if {[my exists return_only] && [my return_only] ne $image_css_class} { + # :log "--lang_link=$link" + if {[info exists :return_only] && [:return_only] ne $image_css_class} { set link "" } if {$link ne ""} { $page lappend lang_links($image_css_class) \ - "$lang" + "${:lang}" } return "" } @@ -398,7 +391,7 @@ border border-width position top botton left right } ::xowiki::Link::image instproc resolve_href {href} { - set l [[my page] create_link $href] + set l [[:page] create_link $href] if {[$l istype ::xowiki::ExternalLink]} { set href [$l href] } else { @@ -408,25 +401,25 @@ return $href } ::xowiki::Link::image instproc render {} { - my instvar name package_id label - set page [my page] - set item_id [my resolve] - #my log "-- image resolve for $page returned $item_id (name=$name, label=$label)" + set page [:page] + set item_id [:resolve] + #my log "-- image resolve for $page returned $item_id (name=${:name}, label=${:label})" if {$item_id} { - set link [$package_id pretty_link -download true -query [my query] \ - -absolute [$page absolute_links] -parent_id [my parent_id] $name] + set link [${:package_id} pretty_link -download true -query [:query] \ + -absolute [$page absolute_links] -parent_id ${:parent_id} ${:name}] #my log "--l fully quali [$page absolute_links], link=$link" - $page references resolved [list $item_id [my type]] - my render_found $link $label + $page references resolved [list $item_id [:type]] + :render_found $link ${:label} } else { set last_page_id [$page set item_id] set object_type ::xowiki::File - set link [$package_id make_link $package_id edit-new object_type \ - [list parent_id [my parent_id]] \ - [list title [ad_html_to_text -no_format -- $label]] \ + set name ${:name} + set link [${:package_id} make_link ${:package_id} edit-new object_type \ + [list parent_id ${:parent_id}] \ + [list title [ad_html_to_text -no_format -- ${:label}]] \ [list return_url [::xo::cc url]] \ autoname name last_page_id] - set html [my render_not_found $link $label] + set html [:render_not_found $link ${:label}] $page references unresolved $html return $html } @@ -439,23 +432,23 @@ margin margin-left margin-right margin-top margin-bottom border border-width position top botton left right } { - if {[my exists $a]} { + if {[info exists :$a]} { if {$a eq "center"} {set pre "
"; set post "
"; continue} - append style "$a: [my set $a];" + append style "$a: [set :$a];" } } if {$style ne ""} {set style "style='$style'"} - if {[my exists geometry]} {append link "?geometry=[my set geometry]"} + if {[info exists :geometry]} {append link "?geometry=${:geometry}"} set label [string map [list ' "'"] $label] - if {[my exists href]} {set href [my set href]} {set href ""} - set cls [my mk_css_class_and_id -default [expr {$link ne "" ? "image" : "refused-link"}]] + if {[info exists :href]} {set href ${:href}} {set href ""} + set cls [:mk_css_class_and_id -default [expr {$link ne "" ? "image" : "refused-link"}]] if {$href ne ""} { - set href [my resolve_href $href] + set href [:resolve_href $href] if {[string match "java*" $href]} {set href .} - if {[my exists revision_id]} {append href ?revision_id=[my revision_id]} + if {[info exists :revision_id]} {append href ?revision_id=[:revision_id]} return "$pre[ns_quotehtml $label]$post" } else { - if {[my exists revision_id]} {append link ?revision_id=[my revision_id]} + if {[info exists :revision_id]} {append link ?revision_id=[:revision_id]} return "$pre[ns_quotehtml $label]$post" } } @@ -467,7 +460,7 @@ Class create ::xowiki::Link::localimage -superclass ::xowiki::Link::image ::xowiki::Link::localimage instproc render {} { - my render_found [my href] [my label] + :render_found [:href] [:label] } # @@ -484,25 +477,25 @@ width height align pluginspage pluginurl hidden href autostart loop volume controls controller mastersound starttime endtime } { - if {[my exists $f]} { - append embed_options "$f = '[my set $f]' " + if {[info exists :$f]} { + append embed_options "$f = '[set :$f]' " } } - if {[my exists extra_query_parameter]} { + if {[info exists :extra_query_parameter]} { set pairs {} - foreach {pair} [my extra_query_parameter] { + foreach {pair} [:extra_query_parameter] { lappend pairs [lindex $pair 0]=[ns_urlencode [lindex $pair 1]] } append internal_href ?[string map [list ' "'"] [join $pairs &]] - if {[my exists revision_id]} {append internal_href &revision_id=[my revision_id]} + if {[info exists :revision_id]} {append internal_href &revision_id=[:revision_id]} } else { - if {[my exists revision_id]} {append internal_href ?revision_id=[my revision_id]} + if {[info exists :revision_id]} {append internal_href ?revision_id=[:revision_id]} } if {![info exists embed_options]} { - return "$label " + return "$label " } else { set internal_href [string map [list %2e .] $internal_href] - return "" + return "" } } @@ -514,8 +507,8 @@ order } ::xowiki::Link::css instproc render_found {href label} { - if {[my exists order]} { - ::xo::Page requireCSS -order [my order] $href + if {[info exists :order]} { + ::xo::Page requireCSS -order [:order] $href } else { ::xo::Page requireCSS $href } @@ -542,19 +535,18 @@ ::xowiki::Link::swf instproc render_found {href label} { ::xo::Page requireJS /resources/xowiki/swfobject.js - my instvar package_id name - #set link [$package_id pretty_link -absolute true -siteurl http://localhost:8003 $name]/download.swf + #set link [${:package_id} pretty_link -absolute true -siteurl http://localhost:8003 ${:name}]/download.swf lassign {320 240 7} width height version - foreach a {width height version} {if {[my exists $a]} {set $a [my set $a]}} - set id [::xowiki::Includelet html_id [my item_id]] + foreach a {width height version} {if {[info exists :$a]} {set $a [set :$a]}} + set id [::xowiki::Includelet html_id ${:item_id}] set addParams "" foreach a {quality wmode align salign play loop menu scale} { - if {[my exists $a]} {append addParams "so.addParam('$a', '[my set $a]');\n"} + if {[info exists :$a]} {append addParams "so.addParam('$a', '[set :$a]');\n"} } return "
$label
" @@ -567,30 +559,30 @@ Class create ::xowiki::Link::glossary -superclass ::xowiki::Link ::xowiki::Link::glossary instproc resolve {} { # look for a package instance of xowiki, named "glossary" (the type) - set id [my lookup_xowiki_package_by_name [my type] \ - [site_node::get_node_id_from_object_id -object_id [my package_id]]] + set id [:lookup_xowiki_package_by_name [:type] \ + [site_node::get_node_id_from_object_id -object_id ${:package_id}]] #my log "--LINK glossary lookup returned package_id $id" if {$id > 0} { # set correct package id for rendering the link - my set package_id $id + set :package_id $id #my log "-- INITIALIZE $id" #::xowiki::Package initialize -package_id $id #my log "--u setting package_id to $id" # lookup the item from the found folder - return [::xo::db::CrClass lookup -name [my name] -parent_id [$id set parent_id]] + return [::xo::db::CrClass lookup -name [:name] -parent_id [$id set parent_id]] } - #my log "--LINK no page found [my name], [my lang], type=[my type]." + #my log "--LINK no page found [:name], [:lang], type=[:type]." return 0 } ::xowiki::Link::glossary instproc render_found {href label} { ::xo::Page requireJS "/resources/xowiki/get-http-object.js" ::xo::Page requireJS "/resources/xowiki/popup-handler.js" ::xo::Page requireJS "/resources/xowiki/overlib/overlib.js" - if {![my exists cssid]} {my cssid [::xowiki::Includelet html_id [self]]} + if {![info exists :cssid]} {my cssid [::xowiki::Includelet html_id [self]]} template::add_event_listener \ - -id [my cssid] \ + -id [:cssid] \ -script [subst {showInfo('[ns_quotehtml $href?master=0]','[ns_quotehtml $label]')}] - return "$label" + return "$label" } # @@ -599,18 +591,18 @@ # Class create LinkCache # LinkCache instproc resolve {} { - # set key link-[my type]-[my name]-[my parent_id] + # set key link-[:type]-[:name]-${:parent_id} # while {1} { # array set r [ns_cache eval xowiki_cache $key { # set id [next] # if {$id == 0 || $id eq ""} break ;# don't cache - # return [list item_id $id package_id [my package_id]] + # return [list item_id $id package_id ${:package_id}] # }] # break # } # if {![info exists r(item_id)]} {return 0} # # we have a valid item. Set the the package_id and return the item_id - # my package_id $r(package_id) + # :package_id $r(package_id) # return $r(item_id) # }