Browse Source

[svn r21931] FS#2867 - The FCKEditor: Starting to use the new editor's configuration framework from the course hme page, the introduction section. Here (for example) the name of the toolbar is "hardcoded", this is inevitable. But width and height of the editor come from a configuration file, they can be tweaked by a non-programmer. Th shown manner avoids using the >global< variable $fck_attribute.

Ivan Tcholakov 15 years ago
parent
commit
27807e9717

+ 8 - 10
main/course_home/course_home.php

@@ -1,4 +1,4 @@
-<?php // $Id: course_home.php 19694 2009-04-09 21:45:33Z ivantcholakov $
+<?php // $Id: course_home.php 21931 2009-07-09 04:38:48Z ivantcholakov $
 
 /*
 ==============================================================================
@@ -179,15 +179,13 @@ $reqdate="&reqdate=$temps";
 	(editable by course admins)
 -----------------------------------------------------------
 */
-$fck_attribute['Width'] = '100%';
-$fck_attribute['Height'] = '300';
-$fck_attribute['ToolbarSet'] = 'Introduction';
-// A special case, some default settings do not fit. These settings should stay.
-$fck_attribute['Config']['CreateDocumentWebDir'] = api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/';
-$fck_attribute['Config']['CreateDocumentDir'] = 'document/';
-$fck_attribute['Config']['BaseHref'] = api_get_path('WEB_COURSE_PATH').api_get_course_path().'/';
-Display::display_introduction_section(TOOL_COURSE_HOMEPAGE);
-$fck_attribute = null; // Clearing this global variable immediatelly after it has been used.
+Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
+		'ToolbarSet' => 'Introduction',
+		'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/',
+		'CreateDocumentDir' => 'document/',
+		'BaseHref' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/'
+	)
+);
 
 /*
 -----------------------------------------------------------

+ 1 - 1
main/inc/introductionSection.inc.php

@@ -48,7 +48,7 @@ if (!empty ($GLOBALS["_cid"])) {
 $renderer =& $form->defaultRenderer();
 $renderer->setElementTemplate('<div style="width: 80%; margin: 0px auto; padding-bottom: 10px; ">{element}</div>');
 
-$form->add_html_editor('intro_content',null,null,false);
+$form->add_html_editor('intro_content', null, null, false, $editor_config);
 $form->addElement('style_submit_button', 'intro_cmdUpdate', get_lang('SaveIntroText'), 'class="save"');
 
 

+ 2 - 1
main/inc/lib/display.lib.php

@@ -91,10 +91,11 @@ class Display {
 	*
 	* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 	* @param string $tool These are the constants that are used for indicating the tools.
+	* @param array $editor_config Optional configuration settings for the online editor.
 	* @return $tool return a string array list with the "define" in main_api.lib 
 	* @return html code for adding an introduction
 	*/
-	public function display_introduction_section($tool)
+	public function display_introduction_section($tool, $editor_config = null)
 	{
 		$is_allowed_to_edit = api_is_allowed_to_edit();
 		$moduleId = $tool;

+ 2 - 2
main/inc/lib/fckeditor/toolbars/introduction.php

@@ -44,5 +44,5 @@ $config['ToolbarSets']['Maximized'] = array(
 
 // Here new width and height of the editor may be set.
 // Possible values, examples: 300 , '250' , '100%' , ...
-//$config['Width'] = '100%';
-//$config['Height'] = '300';
+$config['Width'] = '100%';
+$config['Height'] = '300';

+ 2 - 1
main/inc/lib/formvalidator/Element/html_editor.php

@@ -1,5 +1,5 @@
 <?php
-// $Id: html_editor.php 21910 2009-07-08 19:49:15Z ivantcholakov $
+// $Id: html_editor.php 21931 2009-07-09 04:38:48Z ivantcholakov $
 /*
 ==============================================================================
 	Dokeos - elearning and course management software
@@ -38,6 +38,7 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea
 	 * @param   string  HTML editor name/id
 	 * @param   string  HTML editor  label
 	 * @param   string  Attributes for the textarea
+	 * @param array $editor_config	Optional configuration settings for the online editor.
 	 */
 	function HTML_QuickForm_html_editor($elementName = null, $elementLabel = null, $attributes = null, $config = null)
 	{

+ 4 - 2
main/inc/lib/formvalidator/FormValidator.class.php

@@ -139,10 +139,12 @@ EOT;
 	 * @param string $label The label for the form-element
 	 * @param string $name The element name
 	 * @param boolean $required Is the form-element required (default=true)
+	 * @param boolean $full_page When it is true, the editor loads completed html code for a full page.
+	 * @param array $editor_config	Optional configuration settings for the online editor.
 	 */
-	function add_html_editor($name, $label, $required = true, $full_page = false)
+	function add_html_editor($name, $label, $required = true, $full_page = false, $config = null)
 	{
-		$this->addElement('html_editor',$name,$label,'rows="15" cols="80"');
+		$this->addElement('html_editor', $name, $label, 'rows="15" cols="80"', $config);
 		$this->applyFilter($name,'trim');
 		$html_type = STUDENT_HTML;
 		if(!empty($_SESSION['status']))