Index: openacs-4/packages/acs-templating/acs-templating.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/acs-templating.info,v diff -u -r1.69 -r1.70 --- openacs-4/packages/acs-templating/acs-templating.info 16 Oct 2024 09:21:21 -0000 1.69 +++ openacs-4/packages/acs-templating/acs-templating.info 24 Oct 2024 17:02:23 -0000 1.70 @@ -9,7 +9,7 @@ f t - + OpenACS Templating library. 2024-09-02 @@ -27,7 +27,7 @@ GPL version 2 3 - + @@ -52,6 +52,7 @@ + Index: openacs-4/packages/acs-templating/tcl/style-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/style-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-templating/tcl/style-procs.tcl 3 Sep 2024 15:37:35 -0000 1.2 +++ openacs-4/packages/acs-templating/tcl/style-procs.tcl 24 Oct 2024 17:02:23 -0000 1.3 @@ -23,20 +23,278 @@ set toolkit bootstrap5 } elseif {[string match *bootstrap3* $theme]} { set toolkit bootstrap + } elseif {[string match *w3css-theme* $theme]} { + set toolkit w3css } } return $toolkit } +namespace eval ::template { + nx::Object create ::template::CSS { + # + # CSS property manager. This class is used for agnostic handling + # of icons, CSS class names, or styling preferences of a + # subsite/instance. + # + :public object method clear {} { + # + # Clear the cached toolkit name, such that it is reloads the + # settings on the next initialize call. + # + unset -nocomplain :preferredCSSToolkit + } + :public object method toolkit {} { + # + # Return the preferred CSS toolkit + # + return ${:preferredCSSToolkit} + } + + :public object method icon_name {filename} { + # + # Return an icon name for the proved filename + # + # Default icon name + set iconName file + if {${:iconset} eq "bootstrap-icons"} { + switch [ad_file extension $filename] { + .doc - + .docx - + .odt - + .txt {set iconName "file-earmark-text"} + + .csv - + .ods - + .xls - + .xlsx {set iconName "file-earmark-spreadsheet"} + + .odp - + .ppt - + .pptx {set iconName "file-earmark-spreadsheet"} + + .pdf {set iconName "file-earmark-pdf"} + + .c - + .h - + .tcl {set iconName "file-earmark-code"} + + .css - + .html - + .java - + .js - + .json - + .py - + .sql {set iconName "filetype-[string range [ad_file extension $filename] 1 end]"} + + default { + switch -glob [ns_guesstype $filename] { + image/* {set iconName "file-earmark-image"} + video/* {set iconName "file-earmark-play"} + audio/* {set iconName "file-earmark-slides"} + default { + ns_log notice "not handled '[ad_file extension $filename] / [ns_guesstype $filename] of <$filename>" + } + } + } + } + } + return $iconName + } + + :public object method require_toolkit {{-css:switch} {-js:switch}} { + # + # Make sure that the preferred toolkit is loaded. Note that some + # combination won't match nicely, since e.g. the toolbar of a + # theme based on bootstrap5 is messed up, when the preferred + # toolkit is bootstrap3. .... so, we should have some default + # setting or fallbacks to handle such situations. + # + if {${:preferredCSSToolkit} eq "bootstrap5"} { + if {$css} {::template::head::add_css -href urn:ad:css:bootstrap5} + if {$js} {::template::head::add_javascript -src urn:ad:js:bootstrap5} + } elseif {${:preferredCSSToolkit} eq "bootstrap"} { + if {$css} {::template::head::add_css -href urn:ad:css:bootstrap3} + if {$js} {::template::head::add_javascript -src urn:ad:js:bootstrap3} + } else { + # YUI has many simple files, let the application decide what + # to be loaded. + } + } + + :public object method initialize {} { + # + # Initialize tailorization for CSS toolkits. The function reads + # the global apm package parameter and sets/resets accordingly + # (a) the default values (actually parameters) for the form + # field and (b) defines the toolkit specific CSS class name + # mapping. + # + # + # Loading optional, but universally present header files has do + # be performed per request... not sure this is the best place, + # since packages are as well initialized in the background. + # + if {[ns_conn isconnected] && [apm_package_enabled_p "bootstrap-icons"]} { + template::head::add_css -href urn:ad:css:bootstrap-icons + } + + set paramValue [parameter::get_global_value -package_key acs-templating \ + -parameter PreferredCSSToolkit \ + -default [parameter::get_global_value -package_key xowiki \ + -parameter PreferredCSSToolkit \ + -default default]] + # + # Check, if parameter value is compatible with the theme. In + # particular, a preferred toolkit of "bootstrap3" does not work + # when the theme is based on Bootstrap 5 and vice versa. When necessary, + # align the value. + # + if {$paramValue in {default bootstrap bootstrap5} && [ns_conn isconnected]} { + set theme [subsite::get_theme] + if {$paramValue in {bootstrap default} && [string match *bootstrap5* $theme]} { + set paramValue bootstrap5 + } elseif {$paramValue in {bootstrap5 default} && [string match *bootstrap3* $theme]} { + set paramValue bootstrap + } + if {$paramValue eq "default"} { + # For the time being, YUI is the default (deriving default + # toolkit from theme did not work, we have to assume that + # the fonts for Bootstrap 3 or 5 are not loaded for edit + # buttons, etc. + set paramValue yui + } + } + + # + # Just do initialization once + # + if {[info exists :preferredCSSToolkit] + && ${:preferredCSSToolkit} eq $paramValue + } { + return + } + # + # The code below is executed only on first initialization of the + # object or on changes of the preferredCSSToolkit. + # + set :preferredCSSToolkit $paramValue + set :iconset [template::iconset] + + if {${:preferredCSSToolkit} eq "bootstrap"} { + set :cssClasses { + btn-default btn-default + bulk-action "btn btn-default" + form-action "btn btn-default" + action "btn btn-default" + margin-form "" + card "panel panel-default" + card-header panel-heading + card-body panel-body + d-none hidden + text-warning text-warn + } + if {[info commands ::xowiki::formfield::FormField] ne ""} { + ::xowiki::formfield::FormField parameter [subst { + {CSSclass form-control} + {form_item_wrapper_CSSclass form-group} + {form_label_CSSclass ""} + {form_widget_CSSclass ""} + {form_button_CSSclass "[template::CSS class form-action]"} + {form_button_wrapper_CSSclass ""} + {form_help_text_CSSclass help-block} + }] + } + } elseif {${:preferredCSSToolkit} eq "bootstrap5"} { + set :cssClasses { + btn-default btn-outline-secondary + bulk-action "btn btn-outline-secondary btn-sm" + form-action "btn btn-outline-secondary btn-sm m-1" + action "btn btn-outline-secondary btn-sm m-1" + navbar-default navbar-light + navbar-right ms-auto + margin-form "" + cog gear + print printer + close btn-close + checkbox-inline form-check-inline + radio-inline form-check-inline + } + if {[info commands ::xowiki::formfield::FormField] ne ""} { + ::xowiki::formfield::FormField parameter [subst { + {CSSclass form-control} + {form_item_wrapper_CSSclass mb-3} + {form_label_CSSclass "form-label me-1"} + {form_widget_CSSclass ""} + {form_button_CSSclass "[template::CSS class form-action]"} + {form_button_wrapper_CSSclass ""} + {form_help_text_CSSclass form-text} + }] + ::xowiki::formfield::select parameter { + {CSSclass form-select} + } + ::xowiki::formfield::checkbox parameter { + {CSSclass form-check} + } + ::xowiki::formfield::radio parameter { + {CSSclass form-check} + } + ::xowiki::formfield::range parameter { + {CSSclass form-range} + } + } + } else { + set :cssClasses { + btn-default "" + margin-form margin-form + } + if {[info commands ::xowiki::formfield::FormField] ne ""} { + + ::xowiki::formfield::FormField parameter { + {CSSclass} + {form_label_CSSclass ""} + {form_widget_CSSclass form-widget} + {form_item_wrapper_CSSclass form-item-wrapper} + {form_button_CSSclass ""} + {form_button_wrapper_CSSclass form-button} + {form_help_text_CSSclass form-help-text} + } + ::xowiki::Form requireFormCSS + } + } + } + + :public object method class {name} { + # + # In case, a mapping for CSS classes is defined, return the + # mapping for the provided class name. Otherwise return the + # provided class name. + # + if {[dict exists ${:cssClasses} $name]} { + return [dict get ${:cssClasses} $name] + } else { + return $name + } + } + + :public object method classes {classNames} { + # + # Map a list of CSS class names + # + return [join [lmap class $classNames {:class $class}] " "] + } + } +} + ad_proc ::template::icon::name {-iconset name} { Return for the provided generic name the name in the specified or current iconset the name mapping. This function is necessary in boundary cases, where e.g. a display_template passes the generic name of the icon via template variables which have to be @-substituted before adp-tag resolution, which performs the - regular icon name mapping (otherwise, the tag resolver receives - e.g. ...name=@icon@...) + regular icon name mapping. Otherwise, the tag resolver receives, + e.g., ...name=@icon@... @param iconset @param name @@ -54,8 +312,8 @@ ad_proc -private template::iconset {-subsite_id} { Return the configured or derived icon set. Potential results are - "classic" (old-style gif/png images), "glyphicons" (Part of - Bootstrap 3), "fa-icons" (usable for all themes), and + "classic" (old-style gif/png images), "glyphicons" + (Part of Bootstrap 3), "fa-icons" (usable for all themes), and "bootstrap-icons" (usable for all themes). } { Index: openacs-4/packages/xowf/xowf.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/xowf.info,v diff -u -r1.13 -r1.14 --- openacs-4/packages/xowf/xowf.info 3 Sep 2024 15:37:54 -0000 1.13 +++ openacs-4/packages/xowf/xowf.info 24 Oct 2024 17:02:23 -0000 1.14 @@ -10,20 +10,20 @@ t xowf - + Gustaf Neumann XoWiki Content Flow - an XoWiki based workflow system implementing state-based behavior of wiki pages and forms 2024-09-02 WU Vienna BSD-Style 2 - + - + - + Index: openacs-4/packages/xowf/lib/inclass-exam.wf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/lib/inclass-exam.wf,v diff -u -r1.2 -r1.3 --- openacs-4/packages/xowf/lib/inclass-exam.wf 3 Sep 2024 15:37:54 -0000 1.2 +++ openacs-4/packages/xowf/lib/inclass-exam.wf 24 Oct 2024 17:02:23 -0000 1.3 @@ -233,7 +233,7 @@ set detail_link [$obj pretty_link -query m=question-summary] append text [subst { }] @@ -311,7 +311,7 @@ "created" { append extraAction "
" \ "#xowf.online-exam-try_out# " \ - "#xowf.testrun#" + "#xowf.testrun#" } "published" { append extraAction "
" \ @@ -494,7 +494,7 @@ set HTML "

#xowf.Participants#

$HTML" } set return_url [[$wf package_id] query_parameter local_return_url:localurl [:pretty_link]] - append HTML "

#xowiki.back#

\n" + append HTML "

#xowiki.back#

\n" :www-view $HTML @@ -544,7 +544,7 @@ set withGrades [expr {$gradingScheme ne "::xowf::test_item::grading::none"}] set return_url [:query_parameter local_return_url:localurl [:pretty_link]] - set backButtonHTML "

#xowiki.back#

\n" + set backButtonHTML "

#xowiki.back#

\n" set results [:AM get_exam_results -obj [self] results] if {[llength $results] eq 0} { @@ -601,9 +601,9 @@ set exportQuestionResultsURL [ad_return_url {{format csv} {onlygrades 0}}] set perParticipantURL [ns_conn url]?[::xo::update_query [ns_conn query] per-question 0] set buttonsHTML [subst {

-


+


#xowf.export_results_title# - + #xowf.exam_statistics_participant#

}] } else { @@ -635,20 +635,20 @@ $results] set exportGradesURL [ad_return_url {{format csv}}] set buttonsHTML [subst { -

+


#xowf.export_grades_title# - + #xowf.export_points_and_grades_title# }] } else { set buttonsHTML [subst { - + #xowf.export_points_title# }] } set perQuestionURL [ns_conn url]?[::xo::update_query [ns_conn query] per-question 1] append buttonsHTML [subst { - + #xowf.exam_statistics_question#

}] } @@ -696,7 +696,7 @@ if {!$as_student} { set return_url [:query_parameter local_return_url:localurl [:pretty_link]] - append HTML "

#xowiki.back#

\n" + append HTML "

#xowiki.back#

\n" } if {$do_stream} { @@ -888,7 +888,7 @@ set HTML "#xowiki.no_data#" } set return_url [:query_parameter local_return_url:localurl [:pretty_link]] - append HTML "

#xowiki.back#

\n" + append HTML "

#xowiki.back#

\n" :www-view $HTML } Index: openacs-4/packages/xowf/tcl/test-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/test-item-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/xowf/tcl/test-item-procs.tcl 23 Oct 2024 12:50:46 -0000 1.11 +++ openacs-4/packages/xowf/tcl/test-item-procs.tcl 24 Oct 2024 17:02:23 -0000 1.12 @@ -1444,7 +1444,7 @@ set viewHref "" set viewTitle "" } - set iconName [::xowiki::CSS icon_name $fileName] + set iconName [::template::CSS icon_name $fileName] subst [ns_trim -delimiter | { |
| @@ -2705,7 +2705,7 @@ var points = pointsInput.value; var pointsFormGroup = pointsInput.parentElement.parentElement; var percentage = ""; - let hiddenCSSclass = '[::xowiki::CSS class d-none]'; + let hiddenCSSclass = '[::template::CSS class d-none]'; if (points != "") { // @@ -3334,7 +3334,7 @@ -script "window.print();" return [ns_trim -delimiter | [subst { - | |[template::collect_body_scripts] @@ -3646,14 +3646,14 @@ foreach composite_grading_box $composite_grading_boxes { set composite_qn [$composite_grading_box getAttribute "data-question_name"] set parentNode [$composite_grading_box parentNode] - :dom class add $composite_grading_box {.} [::xowiki::CSS class d-none] + :dom class add $composite_grading_box {.} [::template::CSS class d-none] foreach grading_box [$parentNode selectNodes {div//div[contains(@class,'grading-box')]}] { set qn [$grading_box getAttribute data-question_name] regsub {^answer_} $qn ${composite_qn}_ new_qn #ns_log notice "CHILD of Composite: rename QN from $qn to $new_qn" $grading_box setAttribute data-question_name $new_qn $grading_box setAttribute id ${composite_qn}_[$grading_box getAttribute id] - :dom class remove $grading_box {.} [::xowiki::CSS class d-none] + :dom class remove $grading_box {.} [::template::CSS class d-none] # # The composite questions are prerendered and do not have # hint boxes, since we do not want to have even hidden in @@ -3716,7 +3716,7 @@ if {$noManualGrading} { :dom class add $grading_box {a[contains(@class,'manual-grade')]} \ - [::xowiki::CSS class d-none] + [::template::CSS class d-none] } # @@ -3750,7 +3750,7 @@ set percentage "" if {$achieved eq ""} { set warning [::template::icon \ - -class [xowiki::CSS class text-warning] \ + -class [template::CSS class text-warning] \ -name warn ] set pencil [::template::icon -name pencil] :dom node replaceXML $grading_box \ @@ -3779,7 +3779,7 @@ # # handling of legacy items # - set changes [expr {[::xowiki::CSS toolkit] eq "bootstrap" + set changes [expr {[::template::CSS toolkit] eq "bootstrap" ? {bs-toggle toggle bs-target target} : {toggle bs-toggle target bs-target}}] foreach node [$grading_box selectNodes {a[@class='manual-grade']}] { @@ -3811,10 +3811,10 @@ :dom node replace $grading_box {span[@class='comment']} {::html::t $comment} if {$comment eq ""} { :dom class add $grading_box {span[@class='feedback-label']} \ - [::xowiki::CSS class d-none] + [::template::CSS class d-none] } else { :dom class remove $grading_box {span[@class='feedback-label']} \ - [::xowiki::CSS class d-none] + [::template::CSS class d-none] } $grading_box setAttribute data-user_id [$submission creation_user] @@ -6747,11 +6747,11 @@ } if {$with_grading_box ne ""} { set question_name [:FL form_name_based_attribute_stem [$question_obj name]] - set hiddenCSSclass [expr {$with_grading_box eq "hidden" ? [::xowiki::CSS class d-none] : ""}] + set hiddenCSSclass [expr {$with_grading_box eq "hidden" ? [::template::CSS class d-none] : ""}] if {$with_grading_box eq "hidden"} { set question_name answer_$question_name } - set data_attribute [expr {[::xowiki::CSS toolkit] eq "bootstrap5" ? "data-bs" : "data"}] + set data_attribute [expr {[::template::CSS toolkit] eq "bootstrap5" ? "data-bs" : "data"}] append full_form [subst [ns_trim -delimiter | { |
@@ -7399,7 +7399,7 @@ return [ns_trim -delimiter | [subst { | [:question_info_block $obj] | $results_summary - |

#xowiki.back#

+ |

#xowiki.back#

}]] } Index: openacs-4/packages/xowiki/xowiki.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/xowiki.info,v diff -u -r1.181 -r1.182 --- openacs-4/packages/xowiki/xowiki.info 3 Sep 2024 15:37:55 -0000 1.181 +++ openacs-4/packages/xowiki/xowiki.info 24 Oct 2024 17:02:23 -0000 1.182 @@ -10,7 +10,7 @@ t xowiki - + Gustaf Neumann A xotcl-based enterprise wiki system with multiple object types 2024-09-02 @@ -55,12 +55,12 @@ BSD-Style 2 - + - + @@ -82,7 +82,6 @@ - 0} { - html::ul -class "nav navbar-nav [::xowiki::CSS class navbar-right]" { + html::ul -class "nav navbar-nav [::template::CSS class navbar-right]" { foreach entry $rightMenuEntries { $entry render } @@ -93,7 +93,7 @@ if {${:brand}} { lappend class "navbar-brand" } - set data_attribute [expr {[::xowiki::CSS toolkit] eq "bootstrap5" ? "data-bs" : "data"}] + set data_attribute [expr {[::template::CSS toolkit] eq "bootstrap5" ? "data-bs" : "data"}] html::a -href "\#" -class $class -$data_attribute-toggle "dropdown" { html::t ${:text} } @@ -402,7 +402,7 @@ } BootstrapCollapseButton instproc render {} { - switch [::xowiki::CSS toolkit] { + switch [::template::CSS toolkit] { "bootstrap" { template::add_script -src urn:ad:js:bootstrap3 ::html::button -type button -class "btn btn-xs" -data-toggle ${:toggle} -data-target "#${:id}" { @@ -578,7 +578,7 @@ foreach bulk_action $bulkactions { set id [::xowiki::Includelet html_id $bulk_action] html::li { - html::a -class [::xowiki::CSS class bulk-action] -rule button \ + html::a -class [::template::CSS class bulk-action] -rule button \ -title [$bulk_action tooltip] -href # \ -id $id { html::t [$bulk_action label] @@ -605,7 +605,7 @@ } BootstrapTableRenderer instproc render {} { - ::xowiki::CSS require_toolkit -css + ::template::CSS require_toolkit -css if {![nsf::is object [self]::__actions]} {:actions {}} if {![nsf::is object [self]::__bulkactions]} {:__bulkactions {}} @@ -700,9 +700,9 @@ @return HTML } { return [ns_trim -delimiter | [subst { - |
- |
$title
- |
$body
+ |
+ |
$title
+ |
$body
|
}]] } @@ -717,10 +717,10 @@ @return HTML } { # - set name [xowiki::CSS class $name] + set name [template::CSS class $name] set styleAtt [expr {[info exists style] ? "style='$style'" : ""}] set CSSclass [expr {[info exists CSSclass] ? " $CSSclass" : ""}] - switch [::xowiki::CSS toolkit] { + switch [::template::CSS toolkit] { "bootstrap" { return [subst {}] } @@ -748,7 +748,7 @@ if {$subtitle ne ""} { set subtitle [subst {}] } - if {[::xowiki::CSS toolkit] eq "bootstrap5"} { + if {[::template::CSS toolkit] eq "bootstrap5"} { set data_attribute "data-bs" ::security::csp::require img-src data: set close_button_label "" @@ -767,7 +767,7 @@ | #
@@ -294,7 +294,7 @@ # $content #
# #
#
Index: openacs-4/packages/xowiki/tcl/menu-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/menu-procs.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/xowiki/tcl/menu-procs.tcl 3 Sep 2024 15:37:55 -0000 1.20 +++ openacs-4/packages/xowiki/tcl/menu-procs.tcl 24 Oct 2024 17:02:23 -0000 1.21 @@ -609,7 +609,7 @@ } ::xowiki::MenuBar instproc render-preferred {} { - switch [::xowiki::CSS toolkit] { + switch [::template::CSS toolkit] { bootstrap - bootstrap5 {set menuBarRenderer render-bootstrap} default {set menuBarRenderer render-yui} 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.336 -r1.337 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 23 Oct 2024 12:14:49 -0000 1.336 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 24 Oct 2024 17:02:23 -0000 1.337 @@ -8,254 +8,19 @@ ::xo::library require -package xotcl-core 06-package-procs -namespace eval ::xowiki { - nx::Object create ::xowiki::CSS { - # - # CSS property manager. This class is used for agnostic handling - # of icons, CSS class names, or styling preferences of a - # subsite/instance. - # - :public object method clear {} { - # - # Clear the cached toolkit name, such that it is reloads the - # settings on the next initialize call. - # - unset -nocomplain :preferredCSSToolkit - } - :public object method toolkit {} { - # - # Return the preferred CSS toolkit - # - return ${:preferredCSSToolkit} - } - :public object method icon_name {filename} { - # - # Return an icon name for the proved filename - # - # Default icon name - set iconName file - if {${:iconset} eq "bootstrap-icons"} { - switch [ad_file extension $filename] { - .doc - - .docx - - .odt - - .txt {set iconName "file-earmark-text"} - - .csv - - .ods - - .xls - - .xlsx {set iconName "file-earmark-spreadsheet"} - - .odp - - .ppt - - .pptx {set iconName "file-earmark-spreadsheet"} - - .pdf {set iconName "file-earmark-pdf"} - - .c - - .h - - .tcl {set iconName "file-earmark-code"} - - .css - - .html - - .java - - .js - - .json - - .py - - .sql {set iconName "filetype-[string range [ad_file extension $filename] 1 end]"} - - default { - switch -glob [ns_guesstype $filename] { - image/* {set iconName "file-earmark-image"} - video/* {set iconName "file-earmark-play"} - audio/* {set iconName "file-earmark-slides"} - default { - ns_log notice "not handled '[ad_file extension $filename] / [ns_guesstype $filename] of <$filename>" - } - } - } - } - } - return $iconName - } - - :public object method require_toolkit {{-css:switch} {-js:switch}} { - # - # Make sure that the preferred toolkit is loaded. Not that some - # combination won't match nicely, since e.g. the toolbar of a - # theme based on bootstrap5 is messed up, when the preferred - # toolkit is bootstrap3. .... so, we should have some default - # setting or fallbacks to handle such situations. - # - if {${:preferredCSSToolkit} eq "bootstrap5"} { - if {$css} {::xo::Page requireCSS urn:ad:css:bootstrap5} - if {$js} {::xo::Page requireJS urn:ad:js:bootstrap5} - } elseif {${:preferredCSSToolkit} eq "bootstrap"} { - if {$css} {::xo::Page requireCSS urn:ad:css:bootstrap3} - if {$js} {::xo::Page requireJS urn:ad:js:bootstrap3} - } else { - # YUI has many simple files, let the application decide what - # to be loaded. - } - } - - :public object method initialize {} { - # - # Initialize tailorization for CSS toolkits. The function reads - # the global apm package parameter and sets/resets accordingly - # (a) the default values (actually parameters) for the form - # field and (b) defines the toolkit specific CSS class name - # mapping. - # - # - # Loading optional, but universally present header files has do - # be performed per request... not sure this is the best place, - # since packages are as well initialized in the background. - # - if {[ns_conn isconnected] && [apm_package_enabled_p "bootstrap-icons"]} { - template::head::add_css -href urn:ad:css:bootstrap-icons - } - - set paramValue [parameter::get_global_value -package_key xowiki \ - -parameter PreferredCSSToolkit \ - -default default] - # - # Check, if parameter value is compatible with the theme. In - # particular, a preferred toolkit of "bootstrap3" does not work - # when the theme is based on Bootstrap 5 and vice versa. When necessary, - # align the value. - # - if {$paramValue in {default bootstrap bootstrap5} && [ns_conn isconnected]} { - set theme [subsite::get_theme] - if {$paramValue in {bootstrap default} && [string match *bootstrap5* $theme]} { - set paramValue bootstrap5 - } elseif {$paramValue in {bootstrap5 default} && [string match *bootstrap3* $theme]} { - set paramValue bootstrap - } - if {$paramValue eq "default"} { - # For the time being, YUI is the default (deriving default - # toolkit from theme did not work, we have to assume that - # the fonts for Bootstrap 3 or 5 are not loaded for edit - # buttons, etc. - set paramValue yui - } - } - - # - # Just do initialization once - # - if {[info exists :preferredCSSToolkit] - && ${:preferredCSSToolkit} eq $paramValue - } { - return - } - # - # The code below is executed only on first initialization of the - # object or on changes of the preferredCSSToolkit. - # - set :preferredCSSToolkit $paramValue - set :iconset [template::iconset] - - if {${:preferredCSSToolkit} eq "bootstrap"} { - set :cssClasses { - btn-default btn-default - bulk-action "btn btn-default" - form-action "btn btn-default" - action "btn btn-default" - margin-form "" - card "panel panel-default" - card-header panel-heading - card-body panel-body - d-none hidden - text-warning text-warn - } - ::xowiki::formfield::FormField parameter [subst { - {CSSclass form-control} - {form_item_wrapper_CSSclass form-group} - {form_label_CSSclass ""} - {form_widget_CSSclass ""} - {form_button_CSSclass "[xowiki::CSS class form-action]"} - {form_button_wrapper_CSSclass ""} - {form_help_text_CSSclass help-block} - }] - } elseif {${:preferredCSSToolkit} eq "bootstrap5"} { - set :cssClasses { - btn-default btn-outline-secondary - bulk-action "btn btn-outline-secondary btn-sm" - form-action "btn btn-outline-secondary btn-sm m-1" - action "btn btn-outline-secondary btn-sm m-1" - navbar-default navbar-light - navbar-right ms-auto - margin-form "" - cog gear - print printer - close btn-close - checkbox-inline form-check-inline - radio-inline form-check-inline - } - ::xowiki::formfield::FormField parameter [subst { - {CSSclass form-control} - {form_item_wrapper_CSSclass mb-3} - {form_label_CSSclass "form-label me-1"} - {form_widget_CSSclass ""} - {form_button_CSSclass "[xowiki::CSS class form-action]"} - {form_button_wrapper_CSSclass ""} - {form_help_text_CSSclass form-text} - }] - ::xowiki::formfield::select parameter { - {CSSclass form-select} - } - ::xowiki::formfield::checkbox parameter { - {CSSclass form-check} - } - ::xowiki::formfield::radio parameter { - {CSSclass form-check} - } - ::xowiki::formfield::range parameter { - {CSSclass form-range} - } - } else { - ::xowiki::formfield::FormField parameter { - {CSSclass} - {form_label_CSSclass ""} - {form_widget_CSSclass form-widget} - {form_item_wrapper_CSSclass form-item-wrapper} - {form_button_CSSclass ""} - {form_button_wrapper_CSSclass form-button} - {form_help_text_CSSclass form-help-text} - } - set :cssClasses { - btn-default "" - margin-form margin-form - } - ::xowiki::Form requireFormCSS - } - } - - :public object method class {name} { - # - # In case, a mapping for CSS classes is defined, return the - # mapping for the provided class name. Otherwise return the - # provided class name. - # - if {[dict exists ${:cssClasses} $name]} { - return [dict get ${:cssClasses} $name] - } else { - return $name - } - } - - :public object method classes {classNames} { - # - # Map a list of CSS class names - # - return [join [lmap class $classNames {:class $class}] " "] - } +namespace eval ::xowiki { + ad_proc ::xowiki::CSS args { + Backward compatibility hook for ::xowiki::CSS + @see template::CSS + } { + ad_log_deprecated command xowiki::CSS template::CSS + uplevel [list ::template::CSS {*}$args] } } namespace eval ::xowiki { + ::xo::PackageMgr create ::xowiki::Package \ -superclass ::xo::Package \ -pretty_name "XoWiki" \ @@ -915,7 +680,7 @@ next :require_folder_object set :policy [:get_parameter -check_query_parameter false security_policy ::xowiki::policy1] - ::xowiki::CSS initialize + ::template::CSS initialize # # Call package instance initialization after full initialization # of the package with the value of the package parameter @@ -1526,7 +1291,7 @@ } set top_includelets ""; set content $error_msg; set folderhtml "" ::xo::cc set status_code $status_code - ::xo::Page requireCSS urn:ad:css:xowiki-[::xowiki::CSS toolkit] + ::xo::Page requireCSS urn:ad:css:xowiki-[::template::CSS toolkit] ${:id} return_page -adp $template_file -variables { context title index_link back_link error_msg top_includelets content folderhtml @@ -2623,7 +2388,7 @@ } Package proc -deprecated preferredCSSToolkit {} { - return [::xowiki::CSS toolkit] + return [::template::CSS toolkit] } Package instproc call {object:object method options} { Index: openacs-4/packages/xowiki/tcl/personal-notification-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/personal-notification-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/xowiki/tcl/personal-notification-procs.tcl 3 Sep 2024 15:37:55 -0000 1.2 +++ openacs-4/packages/xowiki/tcl/personal-notification-procs.tcl 24 Oct 2024 17:02:23 -0000 1.3 @@ -105,7 +105,7 @@ } { Create a bootstrap3/5-compatible modal dialog } { - if {[::xowiki::CSS toolkit] eq "bootstrap5"} { + if {[::template::CSS toolkit] eq "bootstrap5"} { set data_attribute "data-bs" set close_button_label "" set before_close "" @@ -129,7 +129,7 @@ foreach to_user_id $to_user_id { append input_fields [subst {}] } - set btnDefault [::xowiki::CSS class btn-default] + set btnDefault [::template::CSS class btn-default] return [list link [subst {