Index: openacs-4/packages/acs-templating/tcl/richtext-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/richtext-procs.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 6 May 2004 21:38:20 -0000 1.17 +++ openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 18 Mar 2005 18:10:39 -0000 1.18 @@ -161,7 +161,7 @@ } } -ad_proc -public template::widget::richtext { element_reference tag_attributes } { +ad_proc -public -deprecated template::widget::richtext_htmlarea { element_reference tag_attributes } { Implements the richtext widget, which offers rich text editing options. If the acs-templating.UseHtmlAreaForRichtextP parameter is set to true (1), this will use the htmlArea WYSIWYG editor widget. @@ -173,6 +173,8 @@
  • HTML = normal HTML. You can also parameterize the richtext widget with a 'htmlarea_p' attribute, which can be true or false, and which will override the parameter setting. + + @see template::widget::richtext } { upvar $element_reference element @@ -256,3 +258,93 @@ return $output } + + + +ad_proc -public template::widget::richtext { element_reference tag_attributes } { + Implements the richtext widget, which offers rich text editing options. + + This version supports the rte editor. + + + If the acs-templating.UseHtmlAreaForRichtextP parameter is set to true (1), this will use the htmlArea WYSIWYG editor widget. + Otherwise, it will use a normal textarea, with a drop-down to select a format. The available formats are: + + You can also parameterize the richtext widget with a 'htmlarea_p' attribute, which can be true or false, and which will override the parameter setting. + + Derived from the htmlarea richtext widget for htmlarea by lars@pinds.com + + modified for RTE http://www.kevinroth.com/ by davis@xarg.net +} { + + upvar $element_reference element + + if { [info exists element(html)] } { + array set attributes $element(html) + } + + array set attributes $tag_attributes + + if { [info exists element(value)] } { + set contents [template::util::richtext::get_property contents $element(value)] + set format [template::util::richtext::get_property format $element(value)] + } else { + set contents {} + set format {} + } + + if { [string equal $element(mode) "edit"] } { + + set attributes(id) "richtext__$element(form_id)__$element(id)" + + if { [exists_and_not_null element(htmlarea_p)] } { + set htmlarea_p [template::util::is_true $element(htmlarea_p)] + } else { + set htmlarea_p [parameter::get \ + -package_id [apm_package_id_from_key "acs-templating"] \ + -parameter "UseHtmlAreaForRichtextP" \ + -default 0] + } + + set output "[textarea_internal $element(id) attributes $contents]\n
    Format: [menu $element(id).format [template::util::richtext::format_options] {} {}]" + + if { $htmlarea_p } { + # Tell the blank-master to include the special stuff for htmlArea in the page header + global acs_blank_master__htmlareas + lappend acs_blank_master__htmlareas $element(form_id) + + + regsub -all "\n" $contents "\\n" contents + regsub -all "\r" $contents "" contents + # Beware: & means "repeat the string being replaced" + regsub -all "'" $contents "\\'" contents + + # What we are generating here is the call to write the richtext widget but we also + # need to pass what to generate in for browsers for which the richtext widget + # won't work but which do have js enabled should output since we need the + # format widget (this for Safari among some others) + set output "" + + } + # Spell-checker + array set spellcheck [template::util::spellcheck::spellcheck_properties -element_ref element] + if { $spellcheck(render_p) } { + append output " Spellcheck: [menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] $spellcheck(selected_option) attributes]" + } + } else { + # Display mode + if { [info exists element(value)] } { + append output [template::util::richtext::get_property html_value $element(value)] + append output "" + append output "" + } + } + + return $output +} +