Example #1
0
function print_editor_config($editorhidebuttons = '', $return = false)
{
    global $CFG;
    $str = "config.pageStyle = \"body {";
    if (!empty($CFG->editorbackgroundcolor)) {
        $str .= " background-color: {$CFG->editorbackgroundcolor};";
    }
    if (!empty($CFG->editorfontfamily)) {
        $str .= " font-family: {$CFG->editorfontfamily};";
    }
    if (!empty($CFG->editorfontsize)) {
        $str .= " font-size: {$CFG->editorfontsize};";
    }
    $str .= " }\";\n";
    $str .= "config.killWordOnPaste = ";
    $str .= empty($CFG->editorkillword) ? "false" : "true";
    $str .= ';' . "\n";
    $str .= 'config.fontname = {' . "\n";
    $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();
    $i = 1;
    // Counter is used to get rid of the last comma.
    foreach ($fontlist as $fontline) {
        if (!empty($fontline)) {
            if ($i > 1) {
                $str .= ',' . "\n";
            }
            list($fontkey, $fontvalue) = split(':', $fontline);
            $str .= '"' . $fontkey . "\":\t'" . $fontvalue . "'";
            $i++;
        }
    }
    $str .= '};';
    if (!empty($editorhidebuttons)) {
        $str .= "\nconfig.hideSomeButtons(\" " . $editorhidebuttons . " \");\n";
    } else {
        if (!empty($CFG->editorhidebuttons)) {
            $str .= "\nconfig.hideSomeButtons(\" " . $CFG->editorhidebuttons . " \");\n";
        }
    }
    if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
        $str .= print_speller_code($CFG->htmleditor, true);
    }
    if ($return) {
        return $str;
    }
    echo $str;
}
Example #2
0
/**
 * Prints out the HTML editor config.
 *
 * @uses $CFG
 */
function print_editor_config($editorhidebuttons = '')
{
    global $CFG;
    // print new config
    echo 'var config = new HTMLArea.Config();' . "\n";
    echo "config.pageStyle = \"body {";
    if (!empty($CFG->editorbackgroundcolor)) {
        echo " background-color: {$CFG->editorbackgroundcolor};";
    }
    if (!empty($CFG->editorfontfamily)) {
        echo " font-family: {$CFG->editorfontfamily};";
    }
    if (!empty($CFG->editorfontsize)) {
        echo " font-size: {$CFG->editorfontsize};";
    }
    echo " }\";\n";
    echo "config.killWordOnPaste = ";
    echo empty($CFG->editorkillword) ? "false" : "true";
    echo ';' . "\n";
    echo 'config.fontname = {' . "\n";
    $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array();
    $i = 1;
    // Counter is used to get rid of the last comma.
    foreach ($fontlist as $fontline) {
        if (!empty($fontline)) {
            if ($i > 1) {
                echo ',' . "\n";
            }
            list($fontkey, $fontvalue) = split(':', $fontline);
            echo '"' . $fontkey . "\":\t'" . $fontvalue . "'";
            $i++;
        }
    }
    echo '};';
    if (!empty($editorhidebuttons)) {
        echo "\nconfig.hideSomeButtons(\" " . $editorhidebuttons . " \");\n";
    } else {
        if (!empty($CFG->editorhidebuttons)) {
            echo "\nconfig.hideSomeButtons(\" " . $CFG->editorhidebuttons . " \");\n";
        }
    }
    if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) {
        print_speller_code($usehtmleditor = true);
    }
}