Index: openacs-4/packages/xowiki/tcl/includelet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/includelet-procs.tcl,v diff -u -r1.224 -r1.225 --- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 20 May 2018 11:01:57 -0000 1.224 +++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 11 Jun 2018 18:47:26 -0000 1.225 @@ -5,20 +5,21 @@ @author Gustaf Neumann @cvs-id $Id$ } + namespace eval ::xowiki::includelet { # # Define a meta-class for creating Includelet classes. # We use a meta-class for making it easier to define properties # on classes of includelets, which can be used without instantiating - # it. One can for example use the query from the page fragment + # it. One can for example use the query from the page fragment # cache the caching properties of the class. # Class create ::xowiki::IncludeletClass \ -superclass ::xotcl::Class \ -parameter { - {localized true} - {personalized true} - {cacheable false} + {localized true} + {personalized true} + {cacheable false} {aggregating false} } @@ -27,9 +28,9 @@ Class create ::xowiki::Includelet \ -superclass ::xo::Context \ -parameter { - {name ""} - {title ""} - {__decoration "portlet"} + {name ""} + {title ""} + {__decoration "portlet"} {parameter_declaration {}} {id} } @@ -50,8 +51,8 @@ ::xo::Page requireJS "//yui.yahooapis.com/$version/build/$path" security::csp::require script-src yui.yahooapis.com } - } - + } + ::xowiki::Includelet proc describe_includelets {includelet_classes} { #:log "--plc=$includelet_classes " foreach cl $includelet_classes { @@ -98,7 +99,7 @@ ::xowiki::Includelet proc js_name {name} { return ID[string map [list : _ # _] $name] } - + ::xowiki::Includelet proc js_encode {string} { string map [list \n \\n \" {\"} ' {\'}] $string } @@ -111,12 +112,12 @@ ::xowiki::Includelet proc html_id {name} { - # Construct a valid HTML id or name. + # Construct a valid HTML id or name. # For details, see http://www.w3.org/TR/html4/types.html # # For XOTcl object names, strip first the colons set name [string trimleft $name :] - + # make sure, the ID starts with characters if {![regexp {^[A-Za-z]} $name]} { set name id_$name @@ -150,9 +151,9 @@ } ::xowiki::Includelet proc locale_clause { - -revisions - -items - package_id + -revisions + -items + package_id locale } { set default_locale [$package_id default_locale] @@ -165,19 +166,19 @@ } #:msg "--L with_system_locale=$with_system_locale, locale=$locale, default_locale=$default_locale" - set locale_clause "" + set locale_clause "" if {$locale ne ""} { - set locale_clause " and $revisions.nls_language = '$locale'" + set locale_clause " and $revisions.nls_language = '$locale'" if {$with_system_locale} { set system_locale [lang::system::locale -package_id $package_id] #:msg "system_locale=$system_locale, default_locale=$default_locale" if {$system_locale ne $default_locale} { - set locale_clause " and ($revisions.nls_language = '$locale' + set locale_clause " and ($revisions.nls_language = '$locale' or $revisions.nls_language = '$system_locale' and not exists - (select 1 from cr_items i where i.name = '[string range $locale 0 1]:' || + (select 1 from cr_items i where i.name = '[string range $locale 0 1]:' || substring($items.name,4) and i.parent_id = $items.parent_id))" } - } + } } #:msg "--locale $locale, def=$default_locale sys=$system_locale, cl=$locale_clause locale_clause=$locale_clause" @@ -314,10 +315,10 @@ ::xowiki::Includelet instproc resolve_page_name {page_name} { return [${:__including_page} resolve_included_page_name $page_name] - } + } ::xowiki::Includelet instproc get_page_order {-source -ordered_pages -pages} { - # + # # first check, if we can load the page_order from the page # denoted by source # @@ -332,7 +333,7 @@ } } } - + # compute a list of ordered_pages from pages, if necessary if {[info exists ordered_pages]} { foreach {order page} $ordered_pages {set :page_order($page) $order} @@ -356,15 +357,15 @@ # It can be used to alter specified parameter from the user, # or to influence the rendering of a decoration (e.g. title etc.) } - + ::xowiki::Includelet instproc js_name {} { return [[self class] js_name [self]] } ::xowiki::Includelet instproc screen_name {user_id} { acs_user::get -user_id $user_id -array user return [expr {$user(screen_name) ne "" ? $user(screen_name) : $user(name)}] - } + } } namespace eval ::xowiki::includelet { @@ -384,7 +385,7 @@ namespace eval ::xowiki::includelet { ############################################################################# # Page Fragment Cache - # + # # The following mixin-class implements page fragment caching in the # xowiki-cache. Caching can be turned on for every # ::xowiki::IncludeletClass instance. @@ -398,7 +399,7 @@ Class create ::xowiki::includelet::page_fragment_cache -instproc render {} { set c [:info class] # - # Construct a key based on the class parameters and the + # Construct a key based on the class parameters and the # actual parameters # set key "PF-${:package_id}-" @@ -429,7 +430,7 @@ set data [next] if {$data ne ""} {ns_cache set xowiki_cache $key $data} } -} +} namespace eval ::xowiki::includelet { ############################################################################# # dotlrn style includelet decoration for includelets @@ -442,12 +443,12 @@ set id [expr {[info exists :id] ? "id='[:id]'" : ""}] set html [next] set localized_title [::xo::localize $title] - set link [expr {[string match "*:*" $name] ? - "[ns_quotehtml $localized_title]" : + set link [expr {[string match "*:*" $name] ? + "[ns_quotehtml $localized_title]" : $localized_title}] ::xo::render_localizer return [subst [[self class] set template]] - } -set template [expr {[apm_version_names_compare [ad_acs_version] 5.3.0] == 1 ? + } -set template [expr {[apm_version_names_compare [ad_acs_version] 5.3.0] == 1 ? {
[join $entries {, }]\n" : ""}] } @@ -1398,19 +1399,19 @@ }} id } - + my-tags instproc render {} { :get_parameters ::xo::Page requireJS urn:ad:js:get-http-object - + set p_link [${:__including_page} pretty_link] set return_url [::xo::cc url]?[::xo::cc actual_query] set weblog_page [$package_id get_parameter weblog_page weblog] set save_tag_link [$package_id make_link -link $p_link ${:__including_page} \ save-tags return_url] set popular_tags_link [$package_id make_link -link $p_link ${:__including_page} \ popular-tags] - + set :tags [lsort [::xowiki::Page get_tags -user_id [::xo::cc user_id] \ -item_id [${:__including_page} item_id] -package_id $package_id]] set entries [list] @@ -1445,7 +1446,7 @@ return $content } - + ::xowiki::IncludeletClass create my-categories \ -superclass ::xowiki::Includelet \ -parameter { @@ -1454,7 +1455,7 @@ {-summary 1} }} } - + my-categories instproc render {} { :get_parameters set content "" @@ -1503,10 +1504,10 @@ ::xowiki::IncludeletClass create my-general-comments \ -superclass ::xowiki::Includelet \ -parameter {{__decoration none}} - + my-general-comments instproc render {} { :get_parameters - set item_id [${:__including_page} item_id] + set item_id [${:__including_page} item_id] set gc_return_url [$package_id url] # # Even, if general_comments is turned on, don't offer the @@ -1528,7 +1529,7 @@ return "$gc_link" } } - + ::xowiki::IncludeletClass create digg \ -superclass ::xowiki::Includelet \ -parameter { @@ -1538,7 +1539,7 @@ {-url} }} } - + digg instproc render {} { :get_parameters set digg_link [export_vars -base "http://digg.com/submit" { @@ -1560,7 +1561,7 @@ {-url} }} } - + delicious instproc render {} { :get_parameters @@ -1590,7 +1591,7 @@ {-rssurl} }} } - + my-yahoo-publisher instproc render {} { :get_parameters @@ -1604,24 +1605,24 @@ # - # my-references lists the pages which are referring to the + # my-references lists the pages which are referring to the # including page # ::xowiki::IncludeletClass create my-references \ -superclass ::xowiki::Includelet \ -parameter {{__decoration none}} - + my-references instproc render {} { :get_parameters - set item_id [${:__including_page} item_id] + set item_id [${:__including_page} item_id] set refs [list] - # The same image might be linked both, as img or file on one page, + # The same image might be linked both, as img or file on one page, # so we need DISTINCT. xo::dc foreach -prepare integer get_references { SELECT DISTINCT page,ci.name,ci.parent_id,o.package_id as pid - from xowiki_references,cr_items ci,acs_objects o + from xowiki_references,cr_items ci,acs_objects o where reference = :item_id and ci.item_id = page and ci.item_id = o.object_id } { if {$pid eq ""} { @@ -1652,17 +1653,17 @@ } # - # my-refers lists the pages which are referred to by the + # my-refers lists the pages which are referred to by the # including page # ::xowiki::IncludeletClass create my-refers \ -superclass ::xowiki::Includelet \ -parameter {{__decoration none}} - + my-refers instproc render {} { :get_parameters - set item_id [${:__including_page} item_id] + set item_id [${:__including_page} item_id] set refs [list] ::xo::dc foreach get_refers "SELECT DISTINCT reference,ci.name,ci.parent_id,o.package_id as pid \ @@ -1722,8 +1723,8 @@ if {[::xo::cc user_id] == 0} { switch -- $show_anonymous { nothing {return ""} - all {set summary 0} - default {set summary 1} + all {set summary 0} + default {set summary 1} } } @@ -1739,7 +1740,7 @@ set select_users "user_id, to_char(max(time),'YYYY-MM-DD HH24:MI:SS') as max_time from xowiki_last_visited " } - # allow for caching prepared value. + # allow for caching prepared value. set since [::xo::dc interval $interval] set since_condition "time > TO_TIMESTAMP(:since,'YYYY-MM-DD HH24:MI:SS')" @@ -1769,7 +1770,7 @@ foreach value $values { lassign $value user_id time set seen($user_id) $time - + regexp {^([^.]+)[.]} $time _ time set pretty_time [util::age_pretty -timestamp_ansi $time \ -sysdate_ansi [clock_to_ansi [clock seconds]] \ @@ -1782,8 +1783,8 @@ } if {$output ne ""} {set output "