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.37 -r1.38 --- openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 29 Jul 2008 22:04:14 -0000 1.37 +++ openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 25 Aug 2008 18:36:21 -0000 1.38 @@ -299,263 +299,261 @@ ad_proc -public template::widget::richtext { element_reference tag_attributes } { - Implements the richtext widget, which offers rich text editing options. + Implements the richtext widget, which offers rich text editing options. - This version supports the xinha editor. + This version supports the xinha 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: -
- The default editor in wysigwig mode is rte. In oder to use xinha, one - has to use 'editor xinha' in the options of the form field. The following - options for xinha may be specified: -
- GetHtml CharacterMap ContextMenu FullScreen - ListType TableOperations EditTag LangMarks Abbreviation --
- These options are used by the OacsFs plugin -
+ The default editor in wysigwig mode is rte. In oder to use xinha, one + has to use 'editor xinha' in the options of the form field. The following + options for xinha may be specified: +
+ GetHtml CharacterMap ContextMenu FullScreen + ListType TableOperations EditTag LangMarks Abbreviation ++
+ These options are used by the OacsFs plugin +
- {options {editor xinha plugins {OacsFs} height 350px javascript { - xinha_config.toolbar = [ - ['popupeditor', 'bold','italic','createlink','insertimage','separator'], - ['killword','removeformat'] ]; - }}} --
- text:richtext(richtext),nospell,optional - {label #xowiki.content#} - {options {editor xinha plugins OacsFs height 350px file_types %pdf%}} - {html {rows 15 cols 50 style {width: 100%}}} -+ the xinha widget and its plugins. The configure object is called xinha_config. + Example to use xinha with only a few controls: +
+ {options {editor xinha plugins {OacsFs} height 350px javascript { + xinha_config.toolbar = [ + ['popupeditor', 'bold','italic','createlink','insertimage','separator'], + ['killword','removeformat'] ]; + }}} ++
+ text:richtext(richtext),nospell,optional + {label #xowiki.content#} + {options {editor xinha plugins OacsFs height 350px file_types %pdf%}} + {html {rows 15 cols 50 style {width: 100%}}} +- Caveat: the three adp-files needed for the OpenACS file selector - (insert-image, insert-ilink and file-selector) - are currently part of the xowiki package, since acs-templating - is per default not mounted. This is hopefully only a temporal situation - and we find a better place. -
- Note that the rich-rext editor interacts with blank-master.tcl and - blank-master.adp. -
- Derived from the htmlarea richtext widget for htmlarea by lars@pinds.com
- modified for RTE http://www.kevinroth.com/ by davis@xarg.net
- xinha support by gustaf.neumann@wu-wien.ac.at
+ Caveat: the three adp-files needed for the OpenACS file selector
+ (insert-image, insert-ilink and file-selector)
+ are currently part of the xowiki package, since acs-templating
+ is per default not mounted. This is hopefully only a temporal situation
+ and we find a better place.
+
+ Note that the rich-rext editor interacts with blank-master.tcl and + blank-master.adp. +
+ Derived from the htmlarea richtext widget for htmlarea by lars@pinds.com
+ modified for RTE http://www.kevinroth.com/ by davis@xarg.net
+ xinha support by gustaf.neumann@wu-wien.ac.at
} {
- upvar $element_reference element
- set output ""
-
- if { [info exists element(html)] } {
- array set attributes $element(html)
- }
+ upvar $element_reference element
+ set output ""
+
+ if { [info exists element(html)] } {
+ array set attributes $element(html)
+ }
- array set attributes $tag_attributes
+ 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 { [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 {}
+ }
- array set options [expr {[info exists element(options)] ? $element(options) : ""}]
+ array set options [expr {[info exists element(options)] ? $element(options) : ""}]
- if { $element(mode) eq "edit" } {
- set attributes(id) $element(id)
- set package_id_templating [apm_package_id_from_key "acs-templating"]
+ if { $element(mode) eq "edit" } {
+ set attributes(id) $element(id)
+ set package_id_templating [apm_package_id_from_key "acs-templating"]
- set user_agent [string tolower [ns_set get [ns_conn headers] User-Agent]]
+ set user_agent [string tolower [ns_set get [ns_conn headers] User-Agent]]
- if {[string first "safari" $user_agent] != -1} {
- regexp {version/([0-9]+)[.]} $user_agent _ user_agent_version
- if {$user_agent_version < 3} {
- set element(htmlarea_p) false
- }
- } elseif {[string first "opera" $user_agent] != -1} {
- regexp {^[^/]+/([0-9]+)[.]} $user_agent _ user_agent_version
- if {$user_agent_version < 9} {
- set element(htmlarea_p) false
- }
- }
+ if {[string first "safari" $user_agent] != -1} {
+ regexp {version/([0-9]+)[.]} $user_agent _ user_agent_version
+ if {$user_agent_version < 3} {
+ set element(htmlarea_p) false
+ }
+ } elseif {[string first "opera" $user_agent] != -1} {
+ regexp {^[^/]+/([0-9]+)[.]} $user_agent _ user_agent_version
+ if {$user_agent_version < 9} {
+ set element(htmlarea_p) false
+ }
+ }
- 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 $package_id_templating \
- -parameter "UseHtmlAreaForRichtextP" \
- -default 0]
- }
+ 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 $package_id_templating \
+ -parameter "UseHtmlAreaForRichtextP" \
+ -default 0]
+ }
- set format_menu [menu $element(id).format [template::util::richtext::format_options] $format {}]
- set output [textarea_internal $element(id) attributes $contents]
+ set format_menu [menu $element(id).format [template::util::richtext::format_options] $format {}]
+ set output [textarea_internal $element(id) attributes $contents]
- if { $htmlarea_p } {
- # figure out, which rich text editor to use
- set richtextEditor [expr {[info exists options(editor)] ?
- $options(editor) : [parameter::get \
- -package_id $package_id_templating \
- -parameter "RichTextEditor" \
- -default "xinha"]}]
- # Tell the blank-master to include the special stuff
- # for the richtext widget in the page header
- set ::acs_blank_master($richtextEditor) 1
+ if { $htmlarea_p } {
+ # figure out, which rich text editor to use
+ set richtextEditor [expr {[info exists options(editor)] ?
+ $options(editor) : [parameter::get \
+ -package_id $package_id_templating \
+ -parameter "RichTextEditor" \
+ -default "xinha"]}]
+ # Tell the blank-master to include the special stuff
+ # for the richtext widget in the page header
+ set ::acs_blank_master($richtextEditor) 1
- if {$richtextEditor eq "xinha"} {
- append output "\n"
- append output "\n"
-
- # we have a xinha richtext widget, specified by "options {editor xinha}"
- # The following options are supported:
- # editor plugins width height folder_id fs_package_id
- #
- if {[info exists options(plugins)]} {
- set plugins $options(plugins)
- } else {
- set plugins [parameter::get \
- -package_id $package_id_templating \
- -parameter "XinhaDefaultPlugins" \
- -default ""]
+ if {$richtextEditor eq "xinha"} {
+ append output "\n"
+ append output "\n"
+
+ # we have a xinha richtext widget, specified by "options {editor xinha}"
+ # The following options are supported:
+ # editor plugins width height folder_id fs_package_id
+ #
+ if {[info exists options(plugins)]} {
+ set plugins $options(plugins)
+ } else {
+ set plugins [parameter::get \
+ -package_id $package_id_templating \
+ -parameter "XinhaDefaultPlugins" \
+ -default ""]
- # GetHtml CharacterMap ContextMenu FullScreen
- # ListType TableOperations EditTag LangMarks Abbreviation
- }
- set quoted [list]
- foreach e $plugins {lappend quoted '$e'}
- set ::acs_blank_master(xinha.plugins) [join $quoted ", "]
+ # GetHtml CharacterMap ContextMenu FullScreen
+ # ListType TableOperations EditTag LangMarks Abbreviation
+ }
+ set quoted [list]
+ foreach e $plugins {lappend quoted '$e'}
+ set ::acs_blank_master(xinha.plugins) [join $quoted ", "]
- set xinha_options ""
- foreach e {width height folder_id fs_package_id file_types attach_parent_id} {
- if {[info exists options($e)]} {
- append xinha_options "xinha_config.$e = '$options($e)';\n"
- }
- }
- # DAVEB add package_id
- append xinha_options "xinha_config.package_id = '[ad_conn package_id]';\n"
- # DAVEB find out if there is a key datatype in the form
+ set xinha_options ""
+ foreach e {width height folder_id fs_package_id file_types attach_parent_id} {
+ if {[info exists options($e)]} {
+ append xinha_options "xinha_config.$e = '$options($e)';\n"
+ }
+ }
+ # DAVEB add package_id
+ append xinha_options "xinha_config.package_id = '[ad_conn package_id]';\n"
+ # DAVEB find out if there is a key datatype in the form
- global af_key_name
- if {[info exists af_key_name(${element(form_id)})]} {
- append xinha_options "xinha_config.key = '[template::element get_value $element(form_id) $af_key_name(${element(form_id)})]';\n"
- }
- if {[info exists options(javascript)]} {
- append xinha_options $options(javascript) \n
- }
- set ::acs_blank_master(xinha.options) $xinha_options
- lappend ::acs_blank_master__htmlareas $attributes(id)
- } elseif {$richtextEditor eq "tinymce"} {
- append output "\n"
- append output "\n"
- lappend ::acs_blank_master__htmlareas $attributes(id)
-
- # get default configs
- set tinymce_default_config {
- {mode "exact" }
- {relative_urls "false"}
- {height "450px" }
- {width "100%"}
- {plugins "oacsimage,oacslink,style,layer,table,save,iespell,preview,zoom,media,searchreplace,print,contextmenu,paste,fullscreen,noneditable,visualchars,xhtmlxtras" }
- {browsers "msie,gecko,safari,opera" }
- {apply_source_formatting "true" }
- {paste_auto_cleanup_on_paste true}
- {paste_convert_headers_to_strong true}
- {fix_list_elements true}
- {fix_table_elements true}
- {theme_openacs_toolbar_location "top" }
- {theme_openacs_toolbar_align "left" }
- {theme_openacs_statusbar_location "bottom" }
- {theme_openacs_resizing true}
- {theme_openacs_disable "styleselect"}
- {theme_openacs_buttons1_add_before "save,separator"}
- {theme_openacs_buttons2_add "oacslink,separator,preview,separator,forecolor,backcolor"}
- {theme_openacs_buttons2_add_before "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator"}
- {theme_openacs_buttons3_add_before "tablecontrols,separator"}
- {theme_openacs_buttons3_add "iespell,media,separator,print,separator,fullscreen"}
- {extended_valid_elements "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"}}
- set tinymce_configs_list [parameter::get \
- -package_id [apm_package_id_from_key "acs-templating"] \
- -parameter "XinhaDefaultPlugins" \
- -default $tinymce_default_config]
- set pairslist [list]
- foreach config_pair $tinymce_configs_list {
- lappend pairslist "[lindex $config_pair 0]:\"[lindex $config_pair 1]\""
- }
- lappend pairslist "elements : \"[join $tinymce_elements ","]\""
- set tinymce_configs_js [join $pairslist ","]
- set ::acs_blank_master(tinymce.config) $timymce_configs_js
- }
- } else {
+ global af_key_name
+ if {[info exists af_key_name(${element(form_id)})]} {
+ append xinha_options "xinha_config.key = '[template::element get_value $element(form_id) $af_key_name(${element(form_id)})]';\n"
+ }
+ if {[info exists options(javascript)]} {
+ append xinha_options $options(javascript) \n
+ }
+ set ::acs_blank_master(xinha.options) $xinha_options
+ lappend ::acs_blank_master__htmlareas $attributes(id)
+ } elseif {$richtextEditor eq "tinymce"} {
+ append output "\n"
+ append output "\n"
+ lappend ::acs_blank_master__htmlareas $attributes(id)
+
+ # get default configs
+ set tinymce_default_config {
+ {mode "exact" }
+ {relative_urls "false"}
+ {height "450px" }
+ {width "100%"}
+ {plugins "oacsimage,oacslink,style,layer,table,save,iespell,preview,zoom,media,searchreplace,print,contextmenu,paste,fullscreen,noneditable,visualchars,xhtmlxtras" }
+ {browsers "msie,gecko,safari,opera" }
+ {apply_source_formatting "true" }
+ {paste_auto_cleanup_on_paste true}
+ {paste_convert_headers_to_strong true}
+ {fix_list_elements true}
+ {fix_table_elements true}
+ {theme_openacs_toolbar_location "top" }
+ {theme_openacs_toolbar_align "left" }
+ {theme_openacs_statusbar_location "bottom" }
+ {theme_openacs_resizing true}
+ {theme_openacs_disable "styleselect"}
+ {theme_openacs_buttons1_add_before "save,separator"}
+ {theme_openacs_buttons2_add "oacslink,separator,preview,separator,forecolor,backcolor"}
+ {theme_openacs_buttons2_add_before "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator"}
+ {theme_openacs_buttons3_add_before "tablecontrols,separator"}
+ {theme_openacs_buttons3_add "iespell,media,separator,print,separator,fullscreen"}
+ {extended_valid_elements "img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"}}
+ set tinymce_configs_list [parameter::get \
+ -package_id [apm_package_id_from_key "acs-templating"] \
+ -parameter "XinhaDefaultPlugins" \
+ -default $tinymce_default_config]
+ set pairslist [list]
+ foreach config_pair $tinymce_configs_list {
+ lappend pairslist "[lindex $config_pair 0]:\"[lindex $config_pair 1]\""
+ }
+ lappend pairslist "elements : \"[join $tinymce_elements ","]\""
+ set tinymce_configs_js [join $pairslist ","]
+ set ::acs_blank_master(tinymce.config) $timymce_configs_js
+ }
+ } else {
+ # Display mode
+ if { $element(mode) eq "display" && [info exists element(value)] } {
+ append output [template::util::richtext::get_property html_value $element(value)]
+ append output ""
+ append output ""
+ } else {
+ append output ""
+ }
+ append output "
[_ acs-templating.Format]: $format_menu"
+ }
+
+ # Spell-checker
+ array set spellcheck [template::util::spellcheck::spellcheck_properties \
+ -element_ref element]
+ if { $spellcheck(render_p) } {
+ append output " [_ acs-templating.Spellcheck]: " \
+ [menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] \
+ $spellcheck(selected_option) {}]
+ }
+ } else {
# Display mode
if { $element(mode) eq "display" && [info exists element(value)] } {
append output [template::util::richtext::get_property html_value $element(value)]
append output ""
append output ""
- } else {
- append output ""
- }
- append output "
[_ acs-templating.Format]: $format_menu"
+ }
}
-
- # Spell-checker
- array set spellcheck [template::util::spellcheck::spellcheck_properties \
- -element_ref element]
- if { $spellcheck(render_p) } {
- append output " [_ acs-templating.Spellcheck]: " \
- [menu "$element(id).spellcheck" [nsv_get spellchecker lang_options] \
- $spellcheck(selected_option) {}]
- }
- } else {
- # Display mode
- if { $element(mode) eq "display" && [info exists element(value)] } {
- append output [template::util::richtext::get_property html_value $element(value)]
- append output ""
- append output ""
- }
- }
-
- return $output
+
+ return $output
}
-
-