Esempio n. 1
0
/**
* Insert a Wysiwyg editor inside a form instead of a textarea
* A standard textarea is displayed if the Wysiwyg editor is disabled or if
* the user's browser have no activated javascript support
*
* @param string $name content for name attribute in textarea tag
* @param string $content optional content previously inserted into    the    area
* @param int     $rows optional    textarea rows
* @param int    $cols optional    textarea columns
* @param string $optAttrib    optional - additionnal tag attributes
*                                       (wrap, class, ...)
* @return string html output for standard textarea or Wysiwyg editor
*
* @author Hugues Peeters <*****@*****.**>
* @author Sebastien Piraux <*****@*****.**>
*/
function claro_html_textarea_editor($name, $content = '', $rows = 20, $cols = 80, $optAttrib = '', $type = 'advanced')
{
    if (!get_conf('claro_editor')) {
        $claro_editor = 'tiny_mce';
    } else {
        $claro_editor = get_conf('claro_editor');
    }
    $possibleTypeList = array('advanced', 'simple');
    if (!in_array($type, $possibleTypeList)) {
        $type = 'advanced';
    }
    $returnString = '';
    // $claro_editor is the directory name of the editor
    $incPath = get_path('rootSys') . 'claroline/editor/' . $claro_editor;
    $editorPath = get_conf('urlAppend') . '/claroline/editor/';
    $webPath = $editorPath . $claro_editor;
    $isSafariOn_iPhone = preg_match("!Mobile/.*?Safari/.*?!", $_SERVER['HTTP_USER_AGENT']);
    if (!$isSafariOn_iPhone && file_exists($incPath . '/editor.class.php')) {
        // include editor class
        include_once $incPath . '/editor.class.php';
        // editor instance
        $editor = new editor($name, $content, $rows, $cols, $optAttrib, $webPath);
        if ($type == 'advanced') {
            $returnString .= $editor->getAdvancedEditor();
        } else {
            $returnString .= $editor->getSimpleEditor();
        }
    } else {
        // if the editor class doesn't exists we cannot rely on it to display
        // the standard textarea
        $returnString .= '<textarea ' . 'id="' . $name . '" ' . 'name="' . $name . '" ' . 'style="width:100%" ' . 'rows="' . $rows . '" ' . 'cols="' . $cols . '" ' . $optAttrib . ' >' . claro_htmlspecialchars($content) . '</textarea>' . "\n";
    }
    return $returnString;
}