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 -N -r1.66.2.23 -r1.66.2.24
--- openacs-4/packages/acs-templating/acs-templating.info 4 Apr 2022 09:46:54 -0000 1.66.2.23
+++ openacs-4/packages/acs-templating/acs-templating.info 7 Apr 2022 12:38:36 -0000 1.66.2.24
@@ -9,7 +9,7 @@
f
t
-
+
OpenACS
Templating library.
2021-09-15
@@ -27,8 +27,9 @@
GPL version 2
3
-
+
+
Index: openacs-4/packages/acs-templating/tcl/style-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/Attic/style-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-templating/tcl/style-procs.tcl 7 Apr 2022 12:38:36 -0000 1.1.2.1
@@ -0,0 +1,110 @@
+ad_library {
+ Template style handling
+ @author Gustaf Neumann
+}
+
+ad_proc -private template::toolkit {-subsite_id} {
+
+ return the CSS toolkit empty for the current or given site.
+ Potentila result values are "" (undtermined) "bootstrap"
+ (for Bootstrap 3) and "bootstrap5" (for Bootstrap 5).
+
+} {
+ if { ![info exists subsite_id] } {
+ set subsite_id [ad_conn subsite_id]
+ }
+ set toolkit [parameter::get -parameter CSSToolkit -package_id $subsite_id]
+ if {$toolkit eq ""} {
+ #
+ # Derive the toolkit from the subsite theme
+ #
+ set theme [subsite::get_theme -subsite_id $subsite_id]
+ if {[string match *bootstrap5* $theme]} {
+ set toolkit bootstrap5
+ } elseif {[string match *bootstrap3* $theme]} {
+ set toolkit bootstrap
+ }
+ }
+ return $toolkit
+}
+
+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), and "bootstrap-icons" (usable for all themes).
+
+} {
+ if { ![info exists subsite_id] } {
+ set subsite_id [ad_conn subsite_id]
+ }
+ set iconset [parameter::get -parameter IconSet -package_id $subsite_id]
+
+ if {$iconset eq ""} {
+ #
+ # Derive the iconset from the template::toolkit.
+ #
+ if {[template::toolkit -subsite_id $subsite_id] eq "bootstrap"} {
+ #
+ # Bootstrap 3. Make this for backward compatibility the
+ # first choice.
+ #
+ set iconset "glyphicons"
+ } elseif {[apm_package_enabled_p "bootstrap-icons"]} {
+ #
+ # Bootstrap icons work with all toolkits
+ #
+ set iconset "bootstrap-icons"
+ } else {
+ set iconset "classic"
+ }
+ }
+ return $iconset
+}
+
+
+ad_proc -private ::template::icon {
+ -name:required
+ {-title ""}
+ -style
+ -class
+} {
+
+ Return a dict containing the HTML rendering and a potentially
+ needed command for the ADP code. The latter are necessary for
+ e.g. style loading.
+
+ The configuration of this method is performed via the Tcl dict
+ ::template::icon::map, which is set in tag-init.tcl
+
+} {
+ set styleAtt [expr {[info exists style] ? "style='$style'" : ""}]
+ set class [expr {[info exists class] ? " $class" : ""}]
+ set iconset [::template::iconset]
+ if {[dict exists $::template::icon::map $iconset $name]} {
+ set name [dict get $::template::icon::map $iconset $name]
+ }
+ if {[string range $name 0 0] eq "/"} {
+ set iconset default
+ }
+ set cmd ""
+ switch $iconset {
+ "glyphicons" {
+ set template {}
+ }
+ "bootstrap-icons" {
+ set cmd {template::head::add_css -href urn:ad:css:bootstrap-icons}
+ set template {}
+ }
+ default {
+ set template {}
+ }
+ }
+ return [list HTML [subst -nocommands $template] cmd $cmd]
+}
+
+# Local variables:
+# mode: tcl
+# tcl-indent-level: 4
+# indent-tabs-mode: nil
+# End:
Index: openacs-4/packages/acs-templating/tcl/tag-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/tag-init.tcl,v
diff -u -N -r1.49.2.15 -r1.49.2.16
--- openacs-4/packages/acs-templating/tcl/tag-init.tcl 30 Dec 2021 14:45:14 -0000 1.49.2.15
+++ openacs-4/packages/acs-templating/tcl/tag-init.tcl 7 Apr 2022 12:38:36 -0000 1.49.2.16
@@ -1035,6 +1035,68 @@
template::adp_append_code "append __adp_output {}"
}
+
+namespace eval ::template::icon {
+ set ::template::icon::map {
+ bootstrap-icons {
+ edit pencil-square
+ radio-checked check2-circle
+ radio-unchecked circle
+ checkbox-checked check2-square
+ checkbox-unchecked square
+ }
+ glyphicons {
+ edit pencil
+ radio-checked record
+ radio-unchecked /shared/images/radio.gif
+ checkbox-checked check
+ checkbox-unchecked unchecked
+ }
+ classic {
+ edit /shared/images/Edit16.gif
+ trash /shared/images/Delete16.gif
+ radio-checked /shared/images/radiochecked.gif
+ radio-unchecked /shared/images/radio.gif
+ checkbox-checked /shared/images/checkboxchecked.gif
+ checkbox-unchecked /shared/images/checkbox.gif
+ arrow-down /resources/acs-subsite/arrow-down.gif
+ arrow-up /resources/acs-subsite/arrow-up.gif
+ }
+ }
+}
+
+template::tag adp:icon { params } {
+ set d [::template::icon \
+ -name [ns_set iget $params name] \
+ -class [ns_set iget $params class] \
+ -style [ns_set iget $params style] \
+ -title [ns_set iget $params title]]
+ dict with d {
+ template::adp_append_string $HTML
+ if {$cmd ne ""} {
+ template::adp_append_code $cmd
+ }
+ }
+}
+
+template::tag adp:toggle_button { chunk params } {
+ #
+ # In case we need to determine the toolit upon every call, we have
+ # to reconsider (e.g. add the toolkit to the namespace for
+ # compiled code, like template::code::adp::...)
+ #
+ set data [expr {[template::toolkit] eq "bootstrap5" ? "data-bs" : "data"}]
+ append value \
+ "
+}
+
+
# Local variables:
# mode: tcl
# tcl-indent-level: 4