Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -r1.239.2.6 -r1.239.2.7 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 11 Feb 2014 11:58:18 -0000 1.239.2.6 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 13 Mar 2014 13:00:00 -0000 1.239.2.7 @@ -1,9 +1,9 @@ ::xo::library doc { - XoWiki - form fields + XoWiki - form fields - @creation-date 2007-06-22 - @author Gustaf Neumann - @cvs-id $Id$ + @creation-date 2007-06-22 + @author Gustaf Neumann + @cvs-id $Id$ } namespace eval ::xowiki::formfield { @@ -90,12 +90,12 @@ # todo: we could speed this up by an index if needed foreach f [::xowiki::formfield::FormField info instances -closure] { if {[$f name] eq $name} { - if {![$f exists object]} { - my msg "strange, $f [$f name] was created without object but fits name" - return $f - } elseif {$object eq [$f object]} { - return $f - } + if {![$f exists object]} { + my msg "strange, $f [$f name] was created without object but fits name" + return $f + } elseif {$object eq [$f object]} { + return $f + } } } #my msg not-found-$object-$name @@ -122,7 +122,7 @@ } FormField instproc validation_check {validator_method value} { - return [my uplevel [list my $validator_method $value]] + return [my uplevel [list my $validator_method $value]] } FormField instproc validate {obj} { @@ -149,14 +149,14 @@ #my msg "++ [my name]: field-level validator exists '$validator_method' ? [expr {$proc_info ne {}}]" if {$proc_info ne ""} { # we have a slot checker, call it - #my msg "++ call-field level validator $validator_method '$value'" - set success [my validation_check $validator_method $value] + #my msg "++ call-field level validator $validator_method '$value'" + set success [my validation_check $validator_method $value] } if {$success == 1} { # the previous check was ok, check now for a validator on the # object level - set validator_method validate=$validator - set proc_info [$obj procsearch $validator_method] + set validator_method validate=$validator + set proc_info [$obj procsearch $validator_method] #my msg "++ [my name]: page-level validator exists ? [expr {$proc_info ne {}}]" if {$proc_info ne ""} { set success [$obj $validator_method $value] @@ -169,8 +169,8 @@ # a message key based on the class and the name of the validator. # set cl [namespace tail [lindex $proc_info 0]] - #my msg "__langPkg?[info exists __langPkg]" - if {![info exists __langPkg]} {set __langPkg "xowiki"} + #my msg "__langPkg?[info exists __langPkg]" + if {![info exists __langPkg]} {set __langPkg "xowiki"} return [_ $__langPkg.$cl-validate_$validator [list value $value errorMsg $errorMsg]] #return [::lang::message::lookup "" xowiki.$cl-validate_$validator %errorMsg% [list value $value errorMsg $errorMsg] 1] } @@ -194,7 +194,7 @@ if {$c eq "::xowiki::formfield::FormField"} break foreach s [$c info slots] { if {![$s exists default]} continue - set var [$s name] + set var [$s name] set key processed($var) if {[info exists $key]} continue my set $var [$s default] @@ -209,14 +209,14 @@ FormField proc interprete_condition {-package_id -object cond} { if {[::xo::cc info methods role=$cond] ne ""} { if {$cond eq "creator"} { - set success [::xo::cc role=$cond \ - -object $object \ - -user_id [::xo::cc user_id] \ - -package_id $package_id] + set success [::xo::cc role=$cond \ + -object $object \ + -user_id [::xo::cc user_id] \ + -package_id $package_id] } else { - set success [::xo::cc role=$cond \ - -user_id [::xo::cc user_id] \ - -package_id $package_id] + set success [::xo::cc role=$cond \ + -user_id [::xo::cc user_id] \ + -package_id $package_id] } } else { set success 0 @@ -229,9 +229,9 @@ FormField proc get_single_spec {-package_id -object string} { if {[regexp [my set cond_regexp] $string _ condition true_spec false_spec]} { if {[my interprete_condition -package_id $package_id -object $object $condition]} { - return [my get_single_spec -package_id $package_id -object $object $true_spec] + return [my get_single_spec -package_id $package_id -object $object $true_spec] } else { - return [my get_single_spec -package_id $package_id -object $object $false_spec] + return [my get_single_spec -package_id $package_id -object $object $false_spec] } } return $string @@ -301,7 +301,7 @@ set attribute [string range $s 0 $p-1] set value [string range $s $p+1 end] set definition_class [lindex [my procsearch $attribute] 0] - set method [my info methods $attribute] + set method [my info methods $attribute] if {[string match "::xotcl::*" $definition_class] || $method eq ""} { error [_ xowiki.error-form_constraint-unknown_attribute [list class [my info class] name [my name] entry $attribute]] } @@ -328,7 +328,7 @@ # into a recursive loop for richtext::wym (could be altered there as well). if {[my isclass ::xowiki::formfield::$s] && ![string match "*:*" $s]} { my class ::xowiki::formfield::$s - my remove_omit + my remove_omit if {$old_class ne [my info class]} { #my msg "[my name]: reset class from $old_class to [my info class]" my reset_parameter @@ -413,7 +413,7 @@ if {$help_text ne ""} { if {[string match "#*#" $help_text]} { - set internationalized [my localize $help_text] + set internationalized [my localize $help_text] append spec " {help_text {$internationalized}}" } else { append spec " {help_text {$help_text}}" @@ -471,12 +471,12 @@ set booleanAtts [list required readonly disabled multiple formnovalidate autofocus] foreach att $booleanAtts { if {[my exists $att] && [my set $att]} { - my set __#$att $att - lappend pairs [list __#$att $att] + my set __#$att $att + lappend pairs [list __#$att $att] } } ::html::input [my get_attributes type size maxlength id name value \ - pattern placeholder {*}$pairs] {} + pattern placeholder {*}$pairs] {} foreach att $booleanAtts { if {[my exists __#$att]} {my unset __#$att} } @@ -497,9 +497,9 @@ FormField instproc render_item {} { ::html::div -class [my form_item_wrapper_CSSclass] { if {[my error_msg] ne ""} { - set CSSclass form-label-error + set CSSclass form-label-error } else { - set CSSclass form-label + set CSSclass form-label } ::html::div -class $CSSclass { ::html::label -for [my id] { @@ -675,24 +675,24 @@ } set l [::xowiki::Link create new -destroy_on_cleanup \ - -page $object -type "image" -lang $(prefix) \ - [list -stripped_name $(stripped_name)] [list -label $label] \ - -parent_id $(parent_id) -item_id $(item_id)] + -page $object -type "image" -lang $(prefix) \ + [list -stripped_name $(stripped_name)] [list -label $label] \ + -parent_id $(parent_id) -item_id $(item_id)] if {[my istype file]} { set revision_id [my get_from_value $value revision_id] if {$revision_id ne ""} { - $l revision_id $revision_id + $l revision_id $revision_id } } foreach option { - href cssclass - float width height - padding padding-right padding-left padding-top padding-bottom - margin margin-left margin-right margin-top margin-bottom - border border-width position top botton left right - geometry + href cssclass + float width height + padding padding-right padding-left padding-top padding-bottom + margin margin-left margin-right margin-top margin-bottom + border border-width position top botton left right + geometry } { if {[my exists $option]} {$l set $option [my set $option]} } @@ -749,10 +749,10 @@ Class create file -superclass FormField \ -extend_slot validator virus \ -parameter { - {size 40} - {viruscheck true} - {sticky false} - link_label + {size 40} + {viruscheck true} + {sticky false} + link_label } file instproc check=virus {value} { if {[my viruscheck] && $value ne "" && [::xowiki::virus check [my set tmpfile]]} { @@ -785,7 +785,7 @@ if {$valueLength > 1 && $valueLength %2 == 0} { array set "" $value if {[info exists ($attribute)]} { - return $($attribute) + return $($attribute) } } return [lindex $raw 0] @@ -802,7 +802,7 @@ file instproc value {args} { if {[llength $args] == 0} { if {[my no_value_provided]} { - return [my get_old_value] + return [my get_old_value] } return [my set value] } @@ -826,7 +826,7 @@ set content_type [my set content-type] if {$content_type eq "application/octetstream" - || $content_type eq "application/force-download" + || $content_type eq "application/force-download" } { set content_type [::xowiki::guesstype $value] } @@ -875,10 +875,10 @@ array set "" [$object item_ref -default_lang [[my object] lang] -parent_id $(parent_id) $(name)] #my msg "pretty value name '$(stripped_name)'" set l [::xowiki::Link create new -destroy_on_cleanup \ - -page $object -type "file" -lang $(prefix) \ - [list -stripped_name $(stripped_name)] [list -label [my label]] \ - [list -extra_query_parameter [list [list filename [my get_from_value $v name $v]]]] \ - -parent_id $(parent_id) -item_id $(item_id)] + -page $object -type "file" -lang $(prefix) \ + [list -stripped_name $(stripped_name)] [list -label [my label]] \ + [list -extra_query_parameter [list [list filename [my get_from_value $v name $v]]]] \ + -parent_id $(parent_id) -item_id $(item_id)] return [$l render] } } @@ -897,7 +897,7 @@ append href ?filename=[ns_urlencode $fn] set revision_id [my get_from_value $value revision_id ""] if {$revision_id ne "" && [string is integer $revision_id]} { - append href &revision_id=$revision_id + append href &revision_id=$revision_id } } @@ -929,8 +929,8 @@ set disabled [expr {[my exists disabled] && [my disabled] ne "false"}] if {$value ne "" && !$disabled && ![my sticky] } { - ::html::input -type button -value clear \ - -onClick "document.getElementById('$id').value = ''; document.getElementById('__a$id').style.display = 'none';" + ::html::input -type button -value clear \ + -onClick "document.getElementById('$id').value = ''; document.getElementById('__a$id').style.display = 'none';" } } } @@ -973,8 +973,8 @@ # lead to maybe unexpected deletions of the form-page # if {[my cleanup]} { - set return_url [$package_id query_parameter "return_url" [$parent_id pretty_link]] - $package_id returnredirect [export_vars -base [$object pretty_link] [list {m delete} return_url]] + set return_url [$package_id query_parameter "return_url" [$parent_id pretty_link]] + $package_id returnredirect [export_vars -base [$object pretty_link] [list {m delete} return_url]] } } } @@ -1179,7 +1179,7 @@ } number instproc render_input {} { ::html::input [my get_attributes type id name value disabled {CSSclass class} min max step value \ - autofocus formnovalidate multiple pattern placeholder readonly required] {} + autofocus formnovalidate multiple pattern placeholder readonly required] {} } ########################################################### @@ -1197,7 +1197,7 @@ } range instproc render_input {} { ::html::input [my get_attributes type id name value disabled {CSSclass class} min max step value \ - autofocus formnovalidate multiple pattern placeholder readonly required] {} + autofocus formnovalidate multiple pattern placeholder readonly required] {} } @@ -1232,13 +1232,13 @@ if {$value ne ""} { if { [catch "lc_numeric $value [my format] [my locale]" result] } { util_user_message -message "[my label]: $result (locale=[my locale])" - #my msg [list lc_numeric $value [my format] [my locale]] - set converted_value $value + #my msg [list lc_numeric $value [my format] [my locale]] + set converted_value $value if {[catch {scan $value [my format] converted_value}]} { - return $value - } else { - return $converted_value - } + return $value + } else { + return $converted_value + } } return $result } @@ -1296,39 +1296,39 @@ my instvar object acs_user::get -user_id $v -array user if {[my with_photo]} { - set portrait_id [acs_user::get_portrait_id -user_id $v] - if {$portrait_id == 0} { - package require md5 - set md5 [string tolower [md5::Hex [md5::md5 -- $user(email)]]] - set src http://www.gravatar.com/avatar/$md5?size=[my photo_size]&d=mm - } else { - set src "/shared/portrait-bits.tcl?user_id=$v" - } - set photo "" - set photo_class "photo" + set portrait_id [acs_user::get_portrait_id -user_id $v] + if {$portrait_id == 0} { + package require md5 + set md5 [string tolower [md5::Hex [md5::md5 -- $user(email)]]] + set src http://www.gravatar.com/avatar/$md5?size=[my photo_size]&d=mm + } else { + set src "/shared/portrait-bits.tcl?user_id=$v" + } + set photo "" + set photo_class "photo" } else { - set photo "" - set photo_class "" + set photo "" + set photo_class "" } set date_field [::xowiki::FormPage get_table_form_fields \ - -base_item $object \ - -field_names _last_modified \ - -form_constraints ""] + -base_item $object \ + -field_names _last_modified \ + -form_constraints ""] set date [$date_field pretty_value [$object property _last_modified]] if {[my with_user_link]} { - set user_link_begin "" - set user_link_end "" + set user_link_begin "" + set user_link_end "" } else { - set user_link_begin "" - set user_link_end "" + set user_link_begin "" + set user_link_end "" } return [subst { -
$photo -

$user_link_begin$user(first_names) $user(last_name)$user_link_end

-

$date

-
+
$photo +

$user_link_begin$user(first_names) $user(last_name)$user_link_end

+

$date

+
}] } return "" @@ -1356,7 +1356,7 @@ Class create url -superclass text \ -extend_slot validator safe_url \ -parameter { - {link_label} + {link_label} } url instproc check=safe_url {value} { if {$value eq ""} {return 1} @@ -1462,7 +1462,7 @@ plugins folder_id script_dir - {displayMode standard} + {displayMode standard} width height {wiki false} @@ -1480,13 +1480,13 @@ set editor_class [self class]::$editor if {$editor ne "" && ![my hasclass $editor_class]} { if {![my isclass $editor_class]} { - set editors [list] - foreach c [::xowiki::formfield::richtext info subclass] { + set editors [list] + foreach c [::xowiki::formfield::richtext info subclass] { if {![$c exists editor_mixin]} continue - lappend editors [namespace tail $c] - } - error [_ xowiki.error-form_constraint-unknown_editor \ - [list name [my name] editor [my editor] editors $editors]] + lappend editors [namespace tail $c] + } + error [_ xowiki.error-form_constraint-unknown_editor \ + [list name [my name] editor [my editor] editors $editors]] } foreach m [my info mixin] {if {[$m exists editor_mixin]} {my mixin delete $m}} my mixin add $editor_class @@ -1538,9 +1538,9 @@ richtext instproc check=safe_html {value} { # don't check if the user has sufficient permissions on the package if {[::xo::cc permission \ - -object_id [::xo::cc package_id] \ - -privilege swa \ - -party_id [::xo::cc user_id]]} { + -object_id [::xo::cc package_id] \ + -privilege swa \ + -party_id [::xo::cc user_id]]} { set msg "" } else { set msg [ad_html_security_check $value] @@ -1603,36 +1603,36 @@ richtext::ckeditor instproc js_image_helper {} { ::xo::Page requireJS { function xowiki_image_callback(editor) { - $(editor.element.$.form).submit(function(e) { - calc_image_tags_to_wiki_image_links(this); - }); - editor.setData(calc_wiki_image_links_to_image_tags(editor.getData())); + $(editor.element.$.form).submit(function(e) { + calc_image_tags_to_wiki_image_links(this); + }); + editor.setData(calc_wiki_image_links_to_image_tags(editor.getData())); } function calc_image_tags_to_wiki_image_links (form) { - var calc = function() { - var wiki_link = $(this).attr('alt'); - $(this).replaceWith('[['+wiki_link+']]'); - } - $(form).find('iframe').each(function() { - $(this).contents().find('img[type="wikilink"]').each(calc); - }); - - $(form).find('textarea.ckeip').each(function() { - var contents = $('
'+this.value+'
'); - contents.find('img[type="wikilink"]').each(calc); - this.value = contents.html(); - }); - return true; + var calc = function() { + var wiki_link = $(this).attr('alt'); + $(this).replaceWith('[['+wiki_link+']]'); + } + $(form).find('iframe').each(function() { + $(this).contents().find('img[type="wikilink"]').each(calc); + }); + + $(form).find('textarea.ckeip').each(function() { + var contents = $('
'+this.value+'
'); + contents.find('img[type="wikilink"]').each(calc); + this.value = contents.html(); + }); + return true; } function calc_wiki_image_links_to_image_tags (data) { - var pathname = window.location.pathname; - pathname = pathname.substr(pathname.lastIndexOf("/")+1,pathname.length) - pathname = pathname.replace(/:/ig,"%3a"); - var regex_wikilink = new RegExp('(\\[\\[.SELF./image:)(.*?)(\\]\\])', 'g'); - data = data.replace(regex_wikilink,'.SELF./image:$2'); - return data + var pathname = window.location.pathname; + pathname = pathname.substr(pathname.lastIndexOf("/")+1,pathname.length) + pathname = pathname.replace(/:/ig,"%3a"); + var regex_wikilink = new RegExp('(\\[\\[.SELF./image:)(.*?)(\\]\\])', 'g'); + data = data.replace(regex_wikilink,'.SELF./image:$2'); + return data } } } @@ -1641,9 +1641,9 @@ set result [list] foreach fn $fileNames { if {[regexp {^[./]} $fn]} { - append result $fn + append result $fn } else { - append result "/resources/xowiki/$fn" + append result "/resources/xowiki/$fn" } } return $result @@ -1669,72 +1669,72 @@ #my extraPlugins {timestamp xowikiimage} if {"xowikiimage" in [my extraPlugins]} { - my js_image_helper - set ready_callback {xowiki_image_callback(e.editor);} + my js_image_helper + set ready_callback {xowiki_image_callback(e.editor);} } else { - set ready_callback "/*none*/;" + set ready_callback "/*none*/;" } set options [subst { - toolbar : '[my toolbar]', - uiColor: '[my uiColor]', - language: '[lang::conn::language]', - skin: '[my skin]', - startupMode: '[my mode]', - parent_id: '[[my object] item_id]', - package_url: '[$package_id package_url]', - extraPlugins: '[join [my extraPlugins] ,]', - contentsCss: '[my contentsCss]', - imageSelectorDialog: '[my imageSelectorDialog]', - ready_callback: '$ready_callback', - customConfig: '[my customConfig]' + toolbar : '[my toolbar]', + uiColor: '[my uiColor]', + language: '[lang::conn::language]', + skin: '[my skin]', + startupMode: '[my mode]', + parent_id: '[[my object] item_id]', + package_url: '[$package_id package_url]', + extraPlugins: '[join [my extraPlugins] ,]', + contentsCss: '[my contentsCss]', + imageSelectorDialog: '[my imageSelectorDialog]', + ready_callback: '$ready_callback', + customConfig: '[my customConfig]' }] if {[my templatesFiles] ne ""} { - append options " , templates_files: \['[join [my pathNames [my templatesFiles]] ',' ]' \]\n" + append options " , templates_files: \['[join [my pathNames [my templatesFiles]] ',' ]' \]\n" } if {[my templates] ne ""} { - append options " , templates: '[my templates]'\n" + append options " , templates: '[my templates]'\n" } #set parent [[[my object] package_id] get_page_from_item_or_revision_id [[my object] parent_id]];# ??? if {[my set displayMode] eq "inplace"} { if {[my value] eq ""} {my value " "} my render_richtext_as_div - if {[my inline]} { - set wrapper_class "" - } else { - set wrapper_class "form-item-wrapper" - my callback {$(this.element.$).closest('.form-widget').css('clear','both').css('display', 'block');} - my destroy_callback {$(this).closest('.form-widget').css('clear','none');} - } - set callback [my callback] - set destroy_callback [my destroy_callback] + if {[my inline]} { + set wrapper_class "" + } else { + set wrapper_class "form-item-wrapper" + my callback {$(this.element.$).closest('.form-widget').css('clear','both').css('display', 'block');} + my destroy_callback {$(this).closest('.form-widget').css('clear','none');} + } + set callback [my callback] + set destroy_callback [my destroy_callback] ::xo::Page requireJS "/resources/xowiki/ckeip.js" ::xo::Page requireJS [subst -nocommands { - \$(document).ready(function() { - \$( '\#$id' ).ckeip(function() { $callback }, { - name: '$name', - ckeditor_config: { - $options, - destroy_callback: function() { $destroy_callback } - }, - wrapper_class: '$wrapper_class' + \$(document).ready(function() { + \$( '\#$id' ).ckeip(function() { $callback }, { + name: '$name', + ckeditor_config: { + $options, + destroy_callback: function() { $destroy_callback } + }, + wrapper_class: '$wrapper_class' + }); }); - }); }] } else { - set callback [my callback] - ::xo::Page requireJS [subst -nocommands { - \$(document).ready(function() { - \$( '#$id' ).ckeditor(function() { $callback }, { - $options - }); + set callback [my callback] + ::xo::Page requireJS [subst -nocommands { + \$(document).ready(function() { + \$( '#$id' ).ckeditor(function() { $callback }, { + $options + }); CKEDITOR.instances['$id'].on('instanceReady',function(e) {$ready_callback}); - }); - }] - next + }); + }] + next } } } @@ -1783,48 +1783,48 @@ richtext::ckeditor4 instproc js_image_helper {} { ::xo::Page requireJS { function xowiki_image_callback(editor) { - if (typeof editor != "undefined") { - $(editor.element.$.form).submit(function(e) { - calc_image_tags_to_wiki_image_links(this); - }); - editor.setData(calc_wiki_image_links_to_image_tags(editor.getData())); - } + if (typeof editor != "undefined") { + $(editor.element.$.form).submit(function(e) { + calc_image_tags_to_wiki_image_links(this); + }); + editor.setData(calc_wiki_image_links_to_image_tags(editor.getData())); + } } function calc_image_tags_to_wiki_image_links (form) { - var calc = function() { - var wiki_link = $(this).attr('alt'); - $(this).replaceWith('[['+wiki_link+']]'); - } - $(form).find('iframe').each(function() { - $(this).contents().find('img[type="wikilink"]').each(calc); - }); + var calc = function() { + var wiki_link = $(this).attr('alt'); + $(this).replaceWith('[['+wiki_link+']]'); + } + $(form).find('iframe').each(function() { + $(this).contents().find('img[type="wikilink"]').each(calc); + }); - $(form).find('textarea.ckeip').each(function() { - var contents = $('
'+this.value+'
'); - contents.find('img[type="wikilink"]').each(calc); - this.value = contents.html(); - }); - return true; + $(form).find('textarea.ckeip').each(function() { + var contents = $('
'+this.value+'
'); + contents.find('img[type="wikilink"]').each(calc); + this.value = contents.html(); + }); + return true; } function calc_image_tags_to_wiki_image_links_inline (e) { - var data = $('
'+e.editor.getData()+'
'); - data.find('img[type="wikilink"]').each( function() { - var wiki_link = $(this).attr('alt'); - $(this).replaceWith('[['+wiki_link+']]'); - }); - document.getElementById(e.editor.config.textarea_id).innerHTML=data.html(); + var data = $('
'+e.editor.getData()+'
'); + data.find('img[type="wikilink"]').each( function() { + var wiki_link = $(this).attr('alt'); + $(this).replaceWith('[['+wiki_link+']]'); + }); + document.getElementById(e.editor.config.textarea_id).innerHTML=data.html(); } function calc_wiki_image_links_to_image_tags (data) { - var pathname = window.location.pathname; - pathname = pathname.substr(pathname.lastIndexOf("/")+1,pathname.length) - console.log('pathname' + pathname); - pathname = pathname.replace(/:/ig,"%3a"); - var regex_wikilink = new RegExp('(\\[\\[.SELF./image:)(.*?)(\\]\\])', 'g'); - data = data.replace(regex_wikilink,'.SELF./image:$2'); - return data + var pathname = window.location.pathname; + pathname = pathname.substr(pathname.lastIndexOf("/")+1,pathname.length) + console.log('pathname' + pathname); + pathname = pathname.replace(/:/ig,"%3a"); + var regex_wikilink = new RegExp('(\\[\\[.SELF./image:)(.*?)(\\]\\])', 'g'); + data = data.replace(regex_wikilink,'.SELF./image:$2'); + return data } } } @@ -1833,9 +1833,9 @@ set result [list] foreach fn $fileNames { if {[regexp {^[./]} $fn]} { - append result $fn + append result $fn } else { - append result "/resources/xowiki/$fn" + append result "/resources/xowiki/$fn" } } return $result @@ -1870,107 +1870,107 @@ if {[my set displayMode] eq "inline"} {my lappend extraPlugins sourcedialog} if {"xowikiimage" in [my extraPlugins]} { - my js_image_helper - set ready_callback {xowiki_image_callback(e.editor);} + my js_image_helper + set ready_callback {xowiki_image_callback(e.editor);} } else { - set ready_callback "/*none*/;" - set blur_callback "/*none*/;" + set ready_callback "/*none*/;" + set blur_callback "/*none*/;" } set options [subst { - toolbar : '[my toolbar]', - uiColor: '[my uiColor]', - language: '[lang::conn::language]', - skin: '[my skin]', - startupMode: '[my mode]', - parent_id: '[[my object] item_id]', - package_url: '[$package_id package_url]', - extraPlugins: '[join [my extraPlugins] ,]', - contentsCss: '[my contentsCss]', - imageSelectorDialog: '[my imageSelectorDialog]?parent_id=[[my object] item_id]', - ready_callback: '$ready_callback', - customConfig: '[my customConfig]', - allowedContent: true, - textarea_id: '[my set id]' + toolbar : '[my toolbar]', + uiColor: '[my uiColor]', + language: '[lang::conn::language]', + skin: '[my skin]', + startupMode: '[my mode]', + parent_id: '[[my object] item_id]', + package_url: '[$package_id package_url]', + extraPlugins: '[join [my extraPlugins] ,]', + contentsCss: '[my contentsCss]', + imageSelectorDialog: '[my imageSelectorDialog]?parent_id=[[my object] item_id]', + ready_callback: '$ready_callback', + customConfig: '[my customConfig]', + allowedContent: true, + textarea_id: '[my set id]' }] if {[my templatesFiles] ne ""} { - append options " , templates_files: \['[join [my pathNames [my templatesFiles]] ',' ]' \]\n" + append options " , templates_files: \['[join [my pathNames [my templatesFiles]] ',' ]' \]\n" } if {[my templates] ne ""} { - append options " , templates: '[my templates]'\n" + append options " , templates: '[my templates]'\n" } #set parent [[[my object] package_id] get_page_from_item_or_revision_id [[my object] parent_id]];# ??? if {[my set displayMode] eq "inplace"} { - if {!$is_repeat_template} { - set callback [my callback] - set destroy_callback [my destroy_callback] - - my lappend CSSclass ckeip - ::xo::Page requireJS "/resources/xowiki/ckeip.js" - - ::xo::Page requireJS [subst -nocommands { - function load_$id () { - \$( '\#$id' ).ckeip(function() { $callback }, { - name: '$name', - ckeditor_config: { - $options, - destroy_callback: function() { $destroy_callback } - } - }); - } - \$(document).ready(function() { - load_$id (); - } ); - }] - } - my render_richtext_as_div + if {!$is_repeat_template} { + set callback [my callback] + set destroy_callback [my destroy_callback] + + my lappend CSSclass ckeip + ::xo::Page requireJS "/resources/xowiki/ckeip.js" + + ::xo::Page requireJS [subst -nocommands { + function load_$id () { + \$( '\#$id' ).ckeip(function() { $callback }, { + name: '$name', + ckeditor_config: { + $options, + destroy_callback: function() { $destroy_callback } + } + }); + } + \$(document).ready(function() { + load_$id (); + } ); + }] + } + my render_richtext_as_div } elseif {[my set displayMode] eq "inline"} { - if {!$is_repeat_template} { - if {"xowikiimage" in [my extraPlugins]} { - set ready_callback "xowiki_image_callback(CKEDITOR.instances\['ckinline_$id'\]);" - set blur_callback "calc_image_tags_to_wiki_image_links_inline(e);" - } - - ::xo::Page requireJS [subst -nocommands { - function load_ckinline_$id () { - CKEDITOR.inline('ckinline_$id', { - on: { - blur: function(e) { - $blur_callback - } - }, - $options - }); - } - \$(document).ready(function() { - load_ckinline_$id (); - $ready_callback - }); - }] - } - my set style "display:none;" - next - ::html::div "id ckinline_[my set id] name [my set name] class xowiki-ckeditor contenteditable true" { - ::html::t -disableOutputEscaping [my value] - } + if {!$is_repeat_template} { + if {"xowikiimage" in [my extraPlugins]} { + set ready_callback "xowiki_image_callback(CKEDITOR.instances\['ckinline_$id'\]);" + set blur_callback "calc_image_tags_to_wiki_image_links_inline(e);" + } + + ::xo::Page requireJS [subst -nocommands { + function load_ckinline_$id () { + CKEDITOR.inline('ckinline_$id', { + on: { + blur: function(e) { + $blur_callback + } + }, + $options + }); + } + \$(document).ready(function() { + load_ckinline_$id (); + $ready_callback + }); + }] + } + my set style "display:none;" + next + ::html::div "id ckinline_[my set id] name [my set name] class xowiki-ckeditor contenteditable true" { + ::html::t -disableOutputEscaping [my value] + } } else { - if {!$is_repeat_template} { - set callback [my callback] - ::xo::Page requireJS [subst -nocommands { - function load_$id () { - \$( '#$id' ).ckeditor(function() { $callback }, { - $options - }); - } - \$(document).ready(function() { - load_$id (); - CKEDITOR.instances['$id'].on('instanceReady',function(e) {$ready_callback}); - }); - }] - } - next + if {!$is_repeat_template} { + set callback [my callback] + ::xo::Page requireJS [subst -nocommands { + function load_$id () { + \$( '#$id' ).ckeditor(function() { $callback }, { + $options + }); + } + \$(document).ready(function() { + load_$id (); + CKEDITOR.instances['$id'].on('instanceReady',function(e) {$ready_callback}); + }); + }] + } + next } } } @@ -2003,18 +2003,18 @@ ::xo::Page requireJS "/resources/xowiki/wymeditor/jquery.wymeditor.pack.js" set postinit "" foreach plugin {hovertools resizable fullscreen embed} { - if {$plugin in [my plugins]} { - switch -- $plugin { - embed {} - resizable { - ::xo::Page requireJS "/resources/xowiki/jquery/jquery.ui.js" - ::xo::Page requireJS "/resources/xowiki/jquery/jquery.ui.resizable.js" - append postinit "wym.${plugin}();\n" - } - default {append postinit "wym.${plugin}();\n"} - } - ::xo::Page requireJS "/resources/xowiki/wymeditor/plugins/$plugin/jquery.wymeditor.$plugin.js" - } + if {$plugin in [my plugins]} { + switch -- $plugin { + embed {} + resizable { + ::xo::Page requireJS "/resources/xowiki/jquery/jquery.ui.js" + ::xo::Page requireJS "/resources/xowiki/jquery/jquery.ui.resizable.js" + append postinit "wym.${plugin}();\n" + } + default {append postinit "wym.${plugin}();\n"} + } + ::xo::Page requireJS "/resources/xowiki/wymeditor/plugins/$plugin/jquery.wymeditor.$plugin.js" + } } regsub -all {[.:]} [my id] {\\\\&} JID @@ -2037,7 +2037,7 @@ lappend config $postInit } if {$config ne ""} { - set config \{[join $config ,]\} + set config \{[join $config ,]\} } ::xo::Page requireJS [subst -nocommand -nobackslash { jQuery(function() { @@ -2067,11 +2067,11 @@ richtext::xinha instproc initialize {} { switch -- [my set displayMode] { inplace { - ::xo::Page requireJS "/resources/xowiki/xinha-inplace.js" - if {![info exists ::__xinha_inplace_init_done]} { - template::add_body_handler -event onload -script "xinha.inplace.init();" - set ::__xinha_inplace_init_done 1 - } + ::xo::Page requireJS "/resources/xowiki/xinha-inplace.js" + if {![info exists ::__xinha_inplace_init_done]} { + template::add_body_handler -event onload -script "xinha.inplace.init();" + set ::__xinha_inplace_init_done 1 + } } inline { error "inline is not supported for xinha"} } @@ -2094,10 +2094,10 @@ if {![my exists wiki_p]} {my set wiki_p 1} if {[my set slim]} { my lappend options javascript { - xinha_config.toolbar = [['popupeditor', 'formatblock', 'bold','italic','createlink','insertimage'], - ['separator','insertorderedlist','insertunorderedlist','outdent','indent'], - ['separator','killword','removeformat','htmlmode'] - ]; + xinha_config.toolbar = [['popupeditor', 'formatblock', 'bold','italic','createlink','insertimage'], + ['separator','insertorderedlist','insertunorderedlist','outdent','indent'], + ['separator','killword','removeformat','htmlmode'] + ]; } } } @@ -2129,7 +2129,7 @@ lappend ::acs_blank_master__htmlareas [my id] if {[my set displayMode] eq "inplace"} { - ::html::div [my get_attributes id name {CSSclass class} disabled] { + ::html::div [my get_attributes id name {CSSclass class} disabled] { set href \# set onclick "xinha.inplace.openEditor('[my id]');return false;" ::html::a -style "float: right;" -class edit-item-button -href $href -onclick $onclick { @@ -2138,13 +2138,13 @@ ::html::div -id "[my id]__CONTENT__" { ::html::t -disableOutputEscaping [my value] } - } - my set hiddenid [my id]__HIDDEN__ - my set type hidden - ::html::input [my get_attributes {hiddenid id} name type value] {} + } + my set hiddenid [my id]__HIDDEN__ + my set type hidden + ::html::input [my get_attributes {hiddenid id} name type value] {} } else { - #::html::div [my get_attributes id name cols rows style {CSSclass class} disabled] {} - next + #::html::div [my get_attributes id name cols rows style {CSSclass class} disabled] {} + next } } } @@ -2348,12 +2348,12 @@ set atts [my get_attributes disabled] lappend atts value $rep #my msg "lsearch {[my value]} $rep ==> [lsearch [my value] $rep]" - if {$rep in [my value]} { + if {$rep in [my value]} { lappend atts selected on } ::html::option $atts {::html::t $label} ::html::t \n - }} + }} } @@ -2555,7 +2555,7 @@ set package_path [::$package_id package_path] if {[llength $package_path] > 0} { foreach p $package_path { - lappend from_package_ids [$p id] + lappend from_package_ids [$p id] } } lappend from_package_ids $package_id @@ -2565,7 +2565,7 @@ -publish_status ready \ -h_where [array get wc] \ -package_id $package_id \ - -from_package_ids $from_package_ids] + -from_package_ids $from_package_ids] set options [list] foreach i [$items children] { @@ -2683,8 +2683,8 @@ if {[llength $args] == 0} {return [my set value]} else { set v [lindex $args 0] if {$v eq ""} {return [my set value ""]} else { - # round to 5 minutes - my set value [lindex [my options] [expr {($v + 2) / 5}] 1] + # round to 5 minutes + my set value [lindex [my options] [expr {($v + 2) / 5}] 1] } } } @@ -2895,8 +2895,8 @@ # resetting esp. the item-id is dangerous. Therefore we reset it immediately after the rendering # $item_id set_resolve_context \ - -package_id [$object package_id] -parent_id [$object parent_id] \ - -item_id [$object item_id] + -package_id [$object package_id] -parent_id [$object parent_id] \ + -item_id [$object item_id] set html [$item_id render] #my msg "reset resolve-context" $item_id reset_resolve_context @@ -2933,10 +2933,10 @@ foreach c [my components] { set error [$c validate [self]] if {$error ne ""} { - set msg "[$c label]: $error" - my uplevel [list set errorMsg $msg] - #util_user_message -message "Error in compound field [$c name]: $error" - return 0 + set msg "[$c label]: $error" + my uplevel [list set errorMsg $msg] + #util_user_message -message "Error in compound field [$c name]: $error" + return 0 } } return 1 @@ -2969,8 +2969,8 @@ CompoundField instproc same_value {v1 v2} { if {$v1 eq $v2} {return 1} foreach {n1 value1} $v1 {n2 value2} $v2 { - set f [my set component_index($n1)] - if {![$f same_value $value1 $value2]} { return 0 } + set f [my set component_index($n1)] + if {![$f same_value $value1 $value2]} { return 0 } } return 1 } @@ -2992,7 +2992,7 @@ foreach c [my components] { set result [$c validate $obj] if {$result ne ""} { - return $result + return $result } } return "" @@ -3067,7 +3067,7 @@ foreach e $args { append component_name .$e if {![$sub exists component_index($component_name)]} { - return 0 + return 0 } set sub [$sub set component_index($component_name)] } @@ -3109,7 +3109,7 @@ # # Render content within in a fieldset, but with labels etc. # - html::fieldset [my get_attributes id {CSSclass class}] { + html::fieldset [my get_attributes id {CSSclass class}] { foreach c [my components] { $c render } } } @@ -3265,16 +3265,16 @@ date instproc set_compound_value {value} { #my msg "[my name] original value '[my value]' // passed='$value' disa?[my exists disabled]" # if {$value eq ""} {return} - if { $value eq {} } { - # We need to reset component values so that - # instances of this class can be used as flyweight - # objects. Otherwise, we get side-effects when - # we render the input widget. - foreach c [my components] { - $c value "" - } - return + if { $value eq {} } { + # We need to reset component values so that + # instances of this class can be used as flyweight + # objects. Otherwise, we get side-effects when + # we render the input widget. + foreach c [my components] { + $c value "" } + return + } set value [::xo::db::tcl_date $value tz] #my msg "transformed value '$value'" if {$value ne ""} { @@ -3293,13 +3293,13 @@ foreach c [my components] { if {[$c istype ::xowiki::formfield::label]} continue if {$ticks ne ""} { - set value_part [clock format $ticks -format [$c set code]] - if {[$c set trim_zeros]} { - set value_part [string trimleft $value_part 0] - if {$value_part eq ""} {set value_part 0} - } + set value_part [clock format $ticks -format [$c set code]] + if {[$c set trim_zeros]} { + set value_part [string trimleft $value_part 0] + if {$value_part eq ""} {set value_part 0} + } } else { - set value_part "" + set value_part "" } #my msg "ticks=$ticks $c value $value_part" $c value $value_part @@ -3338,8 +3338,8 @@ } date instproc same_value {v1 v2} { - if {$v1 eq $v2} {return 1} - return 0 + if {$v1 eq $v2} {return 1} + return 0 } date instproc pretty_value {v} { @@ -3407,23 +3407,23 @@ my instvar t_img_url f_img_url CSSclass set title [expr {[my exists __render_help_text_as_title_attr] ? [my set help_text] : ""}] ::html::img \ - -title $title \ - -class $CSSclass \ - -src [expr {[my value] ? $t_img_url : $f_img_url}] \ - -onclick "toggle_img_boolean(this,'$t_img_url','$f_img_url')" + -title $title \ + -class $CSSclass \ + -src [expr {[my value] ? $t_img_url : $f_img_url}] \ + -onclick "toggle_img_boolean(this,'$t_img_url','$f_img_url')" ::html::input -type hidden -name [my name] -value [my value] ::xo::Page requireJS { function toggle_img_boolean (element,t_img_url,f_img_url) { - var input = $(element).next(); - var state = input.val()== "t"; - if (state) { - input.val('f'); - $(element).attr('src',f_img_url); - } else { - input.val('t'); - $(element).attr('src',t_img_url); - } + var input = $(element).next(); + var state = input.val()== "t"; + if (state) { + input.val('f'); + $(element).attr('src',f_img_url); + } else { + input.val('t'); + $(element).attr('src',t_img_url); + } } } } @@ -3502,7 +3502,7 @@ my create_components [subst { {summary {richtext,required,editor=wym,height=150px,label=#xowiki.event-title_of_event#}} {dtstart {date,required,format=DD_MONTH_YYYY_#xowiki.event-hour_prefix#_HH24_MI, - default=now,label=#xowiki.event-start_of_event#,display_format=%Q_%X}} + default=now,label=#xowiki.event-start_of_event#,display_format=%Q_%X}} {dtend date,format=$dtend_format,default=now,label=#xowiki.event-end_of_event#,display_format=$dtend_display_format} {location text,label=#xowiki.event-location#} }] @@ -3547,7 +3547,7 @@ if {$location_val ne ""} { set location_label [$location label] if {[regexp {^#(.+)#$} $location_label _ msg_key]} { - set location_label [lang::message::lookup [my locale] $msg_key] + set location_label [lang::message::lookup [my locale] $msg_key] } set location_txt "$location_label: $location_val" }