yf_form2_tinymce class| File | plugins/form2/classes/form2/yf_form2_tinymce.class.php |
|---|---|
| Use | _class('form2_tinymce', 'classes/form2/') |
| Property | Default | Description |
|---|---|---|
| None declared in this class. | ||
None without a leading underscore.
_ hooks and helpers; not routable as page actionspublic 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;
}