richtext::xinha::initialize_widget (public)

 richtext::xinha::initialize_widget [ -form_id form_id ] \
    [ -text_id text_id ] [ -options options ]

Defined in packages/richtext-xinha/tcl/richtext-procs.tcl

Initialize an Xinha richtext editor widget.

Switches:
-form_id
(optional)
-text_id
(optional)
-options
(optional)

Partial Call Graph (max 5 caller/called nodes):
%3 _ _ (public) ad_conn ad_conn (public) lang::conn::language lang::conn::language (public) richtext::xinha::add_editor richtext::xinha::add_editor (public) template::element template::element (public) richtext::xinha::initialize_widget richtext::xinha::initialize_widget richtext::xinha::initialize_widget->_ richtext::xinha::initialize_widget->ad_conn richtext::xinha::initialize_widget->lang::conn::language richtext::xinha::initialize_widget->richtext::xinha::add_editor richtext::xinha::initialize_widget->template::element

Testcases:
No testcase defined.
Source code:
        ns_log debug "initialize XINHA instance with <$options>"

        # The richtext widget might be specified by "options {editor
        # xinha}" or via the package parameter "RichTextEditor" of
        # acs-templating.
        #
        # The following options can be specified in the widget spec of
        # the richtext widget:
        #
        #      editor plugins width height folder_id fs_package_id
        #
        if {[dict exists $options plugins]} {
            set plugins [dict get $options plugins]
        } else {
            set plugins $::richtext::xinha::standard_plugins
        }

        set xinha_plugins [list]
        set oacs_plugins [list]
        foreach e $plugins {
            if {$e in {OacsFs OacsAttach}} {
                lappend oacs_plugins '$e'
            } else {
                lappend xinha_plugins '$e'
            }
        }
        if {[llength $oacs_plugins] > 0} {
            lappend xinha_plugins  [subst {{ from: '/resources/richtext-xinha/openacs-plugins', load: \[[join $oacs_plugins ,]\] }}]
        }
        set xinha_plugins [join $xinha_plugins ,]

        set xinha_options ""
        foreach e {width height folder_id fs_package_id script_dir file_types attach_parent_id wiki_p} {
            if {[dict exists $options $e]} {
                append xinha_options "xinha_config.$e = '[dict get $options $e]';\n"
            }
        }

        # DAVEB find out if there is a key datatype in the form.
        # We look for a key element in the form and use it e.g. as the
        # possible parent_id of a potential attachment.
        if {[info exists ::af_key_name($form_id)]} {
            set key [template::element get_value $form_id $::af_key_name($form_id)]
            append xinha_options "xinha_config.key = '$key';\n"
        }

        #
        # Pass as well the actual package_id to xinha (for e.g. plugins)
        #
        append xinha_options "xinha_config.package_id = '[ad_conn package_id]';\n"

        if {[dict exists $options javascript]} {
            append xinha_options [dict get $options javascript] \n
        }

        set editor_ids '[join [list $text_id {*}$::acs_blank_master__htmlareas"','"]'

        #
        # Add the configuration via body script
        #
        set conf [subst {
            xinha_options =
            {
                _editor_lang: "[lang::conn::language]",
                xinha_editors:  \[ $editor_ids \],
                xinha_plugins:  \[ $xinha_plugins \],
                xinha_config: function(xinha_config)
                {
                    $xinha_options
                }
            }
        }]

        #
        # Load the editor and everything necessary to the current page.
        #
        ::richtext::xinha::add_editor -conf $conf

        #
        # do we need render_widgets?
        #
        return ""
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: