Esempio n. 1
0
 function renderElement()
 {
     if ($this->wysiwyg) {
         $claro_editor = get_conf('claro_editor', 'tiny_mce');
         // $claro_editor is the directory name of the editor
         $incPath = get_path('rootSys') . 'claroline/editor/' . $claro_editor;
         $editorPath = get_path('url') . '/claroline/editor/';
         $webPath = $editorPath . $claro_editor;
         if (file_exists($incPath . '/editor.class.php')) {
             // include editor class
             include_once $incPath . '/editor.class.php';
             // editor instance
             // TODO fix option list
             $editor = new editor($this->name, $this->value, $this->rows, $this->cols, renderParams($this->optionList), $webPath);
             $html = $editor->getAdvancedEditor();
         } else {
             // force display of textarea as it will not be possible to display it in wysiwyg mode
             $this->useWysiwyg(false);
         }
     }
     if (!$this->wysiwyg) {
         $html = '<textarea' . ' id="form_' . $this->id . '"' . ' name="' . $this->name . '"' . ' ' . renderParams($this->optionList) . ' >' . claro_htmlspecialchars($this->value) . "\n" . '</textarea>' . "\n";
     }
     return $html;
 }
Esempio n. 2
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;
}