yf_form2_tinymce class

Fileplugins/form2/classes/form2/yf_form2_tinymce.class.php
Use_class('form2_tinymce', 'classes/form2/')

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 1

None without a leading underscore.

Methods starting with _ hooks and helpers; not routable as page actions

_tinymce_html

public function _tinymce_html($extra = [], $replace = [], $form = null)

Embedding tinymce editor (http://www.tinymce.com/).

    public function _tinymce_html($extra = [], $replace = [], $form = null)
    {
        $body = null;
        if ( ! is_array($extra)) {
            return '';
        }
        $params = $extra['tinymce'];
        if ( ! is_array($params)) {
            $params = [];
        }
        if ($form->_tinymce_scripts_included) {
            return '';
        }
        $web_path = '';
        if (conf('tinymce::use_submodule')) {
            $path = $params['tinymce_path'] ? $params['tinymce_path'] : 'tinymce/tiny_mce.js';
            $fs_path = PROJECT_PATH . $path;
            $web_path = WEB_PATH . $path;
            if ( ! file_exists($fs_path)) {
                return '';
            }
            js($fs_path);
        } else {
            js('tinymce');
        }
        $content_id = $extra['id'] ? $extra['id'] : 'content_editable';
        $hidden_id = $params['hidden_id'] ? $params['hidden_id'] : '';

        js('
			tinymce.init({
			    selector: "#' . $content_id . '", //"textarea",
//			    plugins: [
//			        "advlist autolink lists link image charmap print preview anchor",
// 					"searchreplace visualblocks code fullscreen",
//					"insertdatetime media table contextmenu paste moxiemanager"
//				],
				toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
			});
		');

        // Avoid including tinymce scripts several times on same page
        $form->_tinymce_scripts_included = true;

        return null;
    }