[svn r10672] allows to use several fckeditors configs on the same page.

skala
Eric Marguin 19 years ago
parent 8594daf953
commit a35fa16470
  1. 23
      main/exercice/multiple_answer.class.php
  2. 6
      main/exercice/question.class.php
  3. 25
      main/exercice/unique_answer.class.php
  4. 158
      main/inc/lib/formvalidator/Element/html_editor.php

@ -59,6 +59,15 @@ class MultipleAnswer extends Question {
*/
function createAnswersForm ($form) {
global $fck_attribute;
$fck_attribute = array();
$fck_attribute['Width'] = '300px';
$fck_attribute['Height'] = '100px';
$fck_attribute['ToolbarSet'] = 'Small';
$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
@ -71,19 +80,19 @@ class MultipleAnswer extends Question {
<table cellpadding="0" cellspacing="5">
<tr bgcolor="#e6e6e6">
<td>
'.get_lang('Number').'
</td>
<td>
True
'.get_lang('True').'
</td>
<td>
Answer
'.get_lang('Answer').'
</td>
<td>
Comment
'.get_lang('Comment').'
</td>
<td>
Weighting
'.get_lang('Weighting').'
</td>
<td width="0"></td>
</tr>';
@ -120,8 +129,8 @@ class MultipleAnswer extends Question {
$puce->freeze();
$group[] = $puce;
$group[] = FormValidator :: createElement ('checkbox', 'correct['.$i.']', null, null, $i);
$group[] = FormValidator :: createElement ('textarea', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('textarea', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"');
$form -> addGroup($group, null, null, '</td><td width="0">');

@ -1,4 +1,4 @@
<?php // $Id: question.class.php 10594 2007-01-05 13:54:24Z elixir_inter $
<?php // $Id: question.class.php 10672 2007-01-11 10:40:16Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -762,9 +762,9 @@ abstract class Question
}
/**
* function which process the creation of answers
* function which process the creation of questions
* @param FormValidator $form the formvalidator instance
* @param Exercise $objExercise the objExercise number to display
* @param Exercise $objExercise the Exercise instance
*/
function processCreation ($form, $objExercise) {

@ -59,6 +59,14 @@ class UniqueAnswer extends Question {
*/
function createAnswersForm ($form) {
global $fck_attribute;
$fck_attribute = array();
$fck_attribute['Width'] = '300px';
$fck_attribute['Height'] = '100px';
$fck_attribute['ToolbarSet'] = 'Small';
$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
@ -72,19 +80,19 @@ class UniqueAnswer extends Question {
<table cellpadding="0" cellspacing="5">
<tr bgcolor="#e6e6e6">
<td>
'.get_lang('Number').'
</td>
<td>
True
'.get_lang('True').'
</td>
<td>
Answer
'.get_lang('Answer').'
</td>
<td>
Comment
'.get_lang('Comment').'
</td>
<td>
Weighting
'.get_lang('Weighting').'
</td>
<td width="0"></td>
</tr>';
@ -124,9 +132,10 @@ class UniqueAnswer extends Question {
$puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"');
$puce->freeze();
$group[] = $puce;
$group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i);
$group[] = FormValidator :: createElement ('textarea', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('textarea', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"');
$group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i);
$group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"');
$group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"');
$group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"');
$form -> addGroup($group, null, null, '</td><td width="0">');

@ -1,5 +1,5 @@
<?php
// $Id: html_editor.php 10649 2007-01-10 15:50:58Z elixir_julian $
// $Id: html_editor.php 10672 2007-01-11 10:40:16Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -32,6 +32,7 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
* Full page
*/
var $fullPage;
var $fck_editor;
/**
* Class constructor
* @param string HTML editor name/id
@ -40,63 +41,13 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
*/
function HTML_QuickForm_html_editor($elementName = null, $elementLabel = null, $attributes = null)
{
global $language_interface, $fck_attribute;
HTML_QuickForm_element :: HTML_QuickForm_element($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'html_editor';
$this->fullPage = false;
}
/**
* Check if the browser supports FCKeditor
*
* @access public
* @return boolean
*/
function browserSupported()
{
return FCKeditor :: IsCompatible();
}
/**
* Return the HTML editor in HTML
* @return string
*/
function toHtml()
{
$value = $this->getValue();
if ($this->fullPage)
{
if (strlen(trim($value)) == 0)
{
$value = '<html><head><title></title><style type="text/css" media="screen, projection">/*<![CDATA[*/body{font-family: arial, verdana, helvetica, sans-serif;font-size: 12px;}/*]]>*/</style></head><body></body></html>';
$this->setValue($value);
}
}
if ($this->_flagFrozen)
{
return $this->getFrozenHtml();
}
else
{
return $this->build_FCKeditor();
}
}
/**
* Returns the htmlarea content in HTML
*@return string
*/
function getFrozenHtml()
{
return $this->getValue();
}
/**
* Build this element using FCKeditor
*/
function build_FCKeditor()
{
global $language_interface, $fck_attribute;
if(! FCKeditor :: IsCompatible())
{
return parent::toHTML();
}
@ $editor_lang = Database :: get_language_isocode($language_interface);
$language_file = api_get_path(WEB_PATH).'/main/inc/lib/fckeditor/editor/lang/'.$editor_lang.'.js';
if (empty ($editor_lang) || !file_exists($language_file))
@ -105,15 +56,18 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
$editor_lang = 'en';
}
$name = $this->getAttribute('name');
$this -> fck_editor = new FCKeditor($name);
$this -> fck_editor->BasePath = api_get_path(WEB_PATH).'main/inc/lib/fckeditor/';
$fck_editor = new FCKeditor($name);
$fck_editor->BasePath = api_get_path(WEB_PATH).'main/inc/lib/fckeditor/';
$fck_editor->Width = $fck_attribute['Width'] ? $fck_attribute['Width'] : '990';
$fck_editor->Height = $fck_attribute['Height'] ? $fck_attribute['Height'] : '400';
$fck_editor->Value = $this->getValue();
$this -> fck_editor->Width = $fck_attribute['Width'] ? $fck_attribute['Width'] : '990';
$this -> fck_editor->Height = $fck_attribute['Height'] ? $fck_attribute['Height'] : '400';
//We get the optionnals config parameters in $fck_attribute array
$fck_editor->Config = $fck_attribute['Config'] ? $fck_attribute['Config'] : array();
$this -> fck_editor->Config = $fck_attribute['Config'] ? $fck_attribute['Config'] : array();
$TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE);
@ -136,7 +90,7 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
$result_sql=api_sql_query($sql);
$isocode_language=mysql_result($result_sql,0,0);
$fck_editor->Config['DefaultLanguage'] = $isocode_language;
$this -> fck_editor->Config['DefaultLanguage'] = $isocode_language;
if($_SESSION['_course']['path']!=''){
@ -146,34 +100,86 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
$upload_path = api_get_path(REL_PATH)."main/upload/";
}
$fck_editor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH)."main/inc/lib/fckeditor/myconfig.js";
$this -> fck_editor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH)."main/inc/lib/fckeditor/myconfig.js";
$fck_editor->ToolbarSet = $fck_attribute['ToolbarSet'] ;
$this -> fck_editor->ToolbarSet = $fck_attribute['ToolbarSet'] ;
$fck_editor->Config['LinkBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php&ServerPath=$upload_path";
$this -> fck_editor->Config['LinkBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php&ServerPath=$upload_path";
//for image
$fck_editor->Config['ImageBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$this -> fck_editor->Config['ImageBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$fck_editor->Config['ImageUploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Image&ServerPath=$upload_path" ;
$this -> fck_editor->Config['ImageUploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Image&ServerPath=$upload_path" ;
//for flash
$fck_editor->Config['FlashBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$this -> fck_editor->Config['FlashBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$fck_editor->Config['FlashUploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Flash&ServerPath=$upload_path" ;
$this -> fck_editor->Config['FlashUploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Flash&ServerPath=$upload_path" ;
//for MP3
$fck_editor->Config['MP3BrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=MP3&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$this -> fck_editor->Config['MP3BrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=MP3&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$fck_editor->Config['MP3UploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=MP3&ServerPath=$upload_path" ;
$this -> fck_editor->Config['MP3UploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=MP3&ServerPath=$upload_path" ;
//for other media
$fck_editor->Config['VideoBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Video&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$fck_editor->Config['VideoUploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Video&ServerPath=$upload_path" ;
$this -> fck_editor->Config['VideoBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Video&Connector=connectors/php/connector.php&ServerPath=$upload_path";
$result .=$fck_editor->CreateHtml();
$this -> fck_editor->Config['VideoUploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Video&ServerPath=$upload_path" ;
}
/**
* Check if the browser supports FCKeditor
*
* @access public
* @return boolean
*/
function browserSupported()
{
return FCKeditor :: IsCompatible();
}
/**
* Return the HTML editor in HTML
* @return string
*/
function toHtml()
{
$value = $this->getValue();
if ($this->fullPage)
{
if (strlen(trim($value)) == 0)
{
$value = '<html><head><title></title><style type="text/css" media="screen, projection">/*<![CDATA[*/body{font-family: arial, verdana, helvetica, sans-serif;font-size: 12px;}/*]]>*/</style></head><body></body></html>';
$this->setValue($value);
}
}
if ($this->_flagFrozen)
{
return $this->getFrozenHtml();
}
else
{
return $this->build_FCKeditor();
}
}
/**
* Returns the htmlarea content in HTML
*@return string
*/
function getFrozenHtml()
{
return $this->getValue();
}
/**
* Build this element using FCKeditor
*/
function build_FCKeditor()
{
if(! FCKeditor :: IsCompatible())
{
return parent::toHTML();
}
$this -> fck_editor->Value = $this->getValue();
$result .=$this -> fck_editor->CreateHtml();
//Add a link to open the allowed html tags window
//$result .= '<small><a href="#" onclick="MyWindow=window.open('."'".api_get_path(WEB_CODE_PATH)."help/allowed_html_tags.php?fullpage=". ($this->fullPage ? '1' : '0')."','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600,left=200,top=20'".'); return false;">'.get_lang('AllowedHTMLTags').'</a></small>';

Loading…
Cancel
Save