richtext::ckeditor4::initialize_widget (public)

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

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

Initialize an CKEditor 4 richtext editor widget.

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

Partial Call Graph (max 5 caller/called nodes):
%3 apm_package_id_from_key apm_package_id_from_key (public) export_vars export_vars (public) richtext::ckeditor4::initialize_widget richtext::ckeditor4::initialize_widget richtext::ckeditor4::initialize_widget->apm_package_id_from_key richtext::ckeditor4::initialize_widget->export_vars

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

        # Allow per default all CSS-classes, unless the user has specified
        # it differently
        if {![dict exists $options extraAllowedContent]} {
            dict set options extraAllowedContent {*(*)}
        }

        #
        # The richtext widget might be specified by "options {editor
        # ckeditor4}" or via the package parameter "RichTextEditor" of
        # acs-templating.
        #
        # The following options handled by the CKEditor integration
        # can be specified in the widget spec of the richtext widget:
        #
        #      plugins skin customConfig spellcheck
        #
        set ckOptionsList {}

        if {![dict exists $options spellcheck]} {
            set package_id [apm_package_id_from_key "richtext-ckeditor4"]
            dict set options spellcheck [parameter::get  -package_id $package_id  -parameter "SCAYT"  -default "false"]
        }
        # For the native spellchecker, one has to hold "ctrl" or "cmd"
        # with the right click.

        lappend ckOptionsList  "language: '[lang::conn::language]'"  "disableNativeSpellChecker: false"  "scayt_autoStartup: [dict get $options spellcheck]"

        #
        # Get the property "displayed_object_id" from the call-stack
        #
        for {set l 0} {$l < [info level]} {incr l} {
            set propVar __adp_properties(displayed_object_id)
            if {[uplevel #$l [list info exists $propVar]]} {
                set displayed_object_id [uplevel #$l [list set $propVar]]
                break
            }
        }
        if {[info exists displayed_object_id]} {
            #
            # If we have a displayed_object_id, configure it for the
            # plugins "filebrowser" and "uploadimage".
            #
            set image_upload_url [export_vars  -base $::richtext::ckeditor4::ckfinder_url/uploadimage {
                                          {object_id $displayed_object_id} {type Images}
                                      }]
            set file_upload_url [export_vars  -base $::richtext::ckeditor4::ckfinder_url/upload {
                                         {object_id $displayed_object_id} {type Files} {command QuickUpload}
                                     }]
            set file_browse_url [export_vars  -base $::richtext::ckeditor4::ckfinder_url/browse {
                                         {object_id $displayed_object_id} {type Files}
                                     }]
            lappend ckOptionsList  "imageUploadUrl: '$image_upload_url'"  "filebrowserBrowseUrl: '$file_browse_url'"  "filebrowserUploadUrl: '$file_upload_url'"  "filebrowserWindowWidth: '800'"  "filebrowserWindowHeight: '600'"
        }

        set plugins [split $::richtext::ckeditor4::standard_plugins ,]
        if {[dict exists $options plugins]} {
            lappend plugins {*}[split [dict get $options plugins] ,]
        }
        if {[llength $plugins] > 0} {
            lappend ckOptionsList "extraPlugins: '[join $plugins ,]'"
        }
        if {[dict exists $options skin]} {
            lappend ckOptionsList "skin: '[dict get $options skin]'"
        }
        if {[dict exists $options customConfig]} {
            lappend ckOptionsList  "customConfig: '[dict get $options customConfig]'"
        }
        if {[dict exists $options extraAllowedContent]} {
            lappend ckOptionsList  "extraAllowedContent: '[dict get $options extraAllowedContent]'"
        }

        set ckOptions [join $ckOptionsList ", "]
        ns_log debug "CKEditor 4: final ckOptions = $ckOptions"

        #
        # Add the configuration via body script
        #
        template::add_script -section body -script [subst {
            CKEDITOR.replace( '$text_id', {$ckOptions} );
        }]

        #
        # Load the editor and everything necessary to the current page.
        #
        ::richtext::ckeditor4::add_editor

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