Html::initEditorSystem PHP Method

initEditorSystem() static public method

Init the Editor System to a textarea
static public initEditorSystem ( $name, $rand = '', $display = true ) : nothing
$name name of the html textarea to use
$rand rand of the html textarea to use (if empty no image paste system)(default '')
$display boolean display or get js script (true by default)
return nothing
    static function initEditorSystem($name, $rand = '', $display = true)
    {
        global $CFG_GLPI;
        $language = $_SESSION['glpilanguage'];
        if (!file_exists(GLPI_ROOT . "/lib/tiny_mce/langs/{$language}.js")) {
            $language = $CFG_GLPI["languages"][$_SESSION['glpilanguage']][2];
            if (!file_exists(GLPI_ROOT . "/lib/tiny_mce/langs/{$language}.js")) {
                $language = "en_GB";
            }
        }
        Html::scriptStart();
        $js = "tinyMCE.init({\n         language: '{$language}',\n         browser_spellcheck: true,\n         mode: 'exact',\n         elements: '{$name}',\n         relative_urls: false,\n         remove_script_host: false,\n         entity_encoding: 'raw',\n         menubar: false,\n         statusbar: false,\n         skin: 'light',\n         plugins: [\n            'table directionality searchreplace paste',\n            'tabfocus autoresize link image',\n            'code fullscreen'\n         ],\n         toolbar: 'styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code fullscreen',\n      });\n   ";
        if ($display) {
            echo Html::scriptBlock($js);
        } else {
            return Html::scriptBlock($js);
        }
    }

Usage Example

示例#1
0
 public function showForm($ID, $options = array())
 {
     if (!$this->isNewID($ID)) {
         $this->check($ID, READ);
     } else {
         $this->check(-1, UPDATE);
     }
     $options['colspan'] = 2;
     $options['target'] = Toolbox::getItemTypeFormURL(__CLASS__);
     $this->showFormHeader($options);
     echo '<table class="tab_cadre_fixe">';
     echo "<tr class='line0'><td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "</tr>";
     echo "<tr class='line1'><td>" . __('Content') . "</td>";
     echo "<td>";
     echo "<textarea name='comment' id ='comment' >" . $this->fields['comment'] . "</textarea>";
     Html::initEditorSystem('comment');
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
All Usage Examples Of Html::initEditorSystem
Html