Browse Source

Feature #2479 add insertHtml plugin to fckeditor, disabled by default, and clean myconfig

Juan Carlos Raña 14 years ago
parent
commit
3a63dd3647

+ 44 - 44
main/inc/lib/fckeditor/editor/plugins/insertHtml/fckplugin.js

@@ -1,44 +1,44 @@
-/*
- * Licensed under the terms of the GNU Lesser General Public License:
- * 		http://www.opensource.org/licenses/lgpl-license.php
- * 
- * File Name: fckplugin.js
- * 	Plugin to add some HTML, a single snippet; a choice from multiple snippets; or manually entered HTML
- * 
- * File Authors:
- * 		Paul Moers (http://www.saulmade.nl/FCKeditor/FCKPlugins.php)
- */
-
-	// insertHtmlObject constructor
-	var insertHtmlToolbarCommand = function()
-	{
-	}
-
-	// register the command
-	FCKCommands.RegisterCommand('insertHtml', new insertHtmlToolbarCommand());
-
-	// create the toolbar  button
-	var insertHtmlButton = new FCKToolbarButton('insertHtml', FCKConfig.insertHtml_buttonTooltip || FCKLang.inserHTML_buttonTooltip);
-	insertHtmlButton.IconPath = FCKPlugins.Items['insertHtml'].Path + 'images/toolbarIcon_default.gif'; // or pick any other in folder 'images'
-	FCKToolbarItems.RegisterItem('insertHtml', insertHtmlButton);
-
-	// manage the plugins' button behavior
-	insertHtmlToolbarCommand.prototype.GetState = function()
-	{
-		return FCK_TRISTATE_OFF;
-	}
-
-	// insertHtml's button click function
-	insertHtmlToolbarCommand.prototype.Execute = function()
-	{
-		if (FCKConfig.insertHtml_showDialog || !FCKConfig.insertHtml_snippets || (FCKConfig.insertHtml_snippets && !FCKConfig.insertHtml_snippets.length))
-		{
-			var dialog = new FCKDialogCommand('insertHtml', FCKLang.insertHtml_dialogTitle, FCKPlugins.Items['insertHtml'].Path + 'insertHtml.html', 200, 100);
-			dialog.Execute();
-		}
-		else
-		{
-			FCK.InsertHtml(FCKConfig.insertHtml_snippet);
-			FCK.EditorWindow.parent.FCKUndo.SaveUndoStep();
-		}
-	}
+/*
+ * Licensed under the terms of the GNU Lesser General Public License:
+ * 		http://www.opensource.org/licenses/lgpl-license.php
+ * 
+ * File Name: fckplugin.js
+ * 	Plugin to add some HTML, a single snippet; a choice from multiple snippets; or manually entered HTML
+ * 
+ * File Authors:
+ * 		Paul Moers (http://www.saulmade.nl/FCKeditor/FCKPlugins.php)
+ */
+
+	// insertHtmlObject constructor
+	var insertHtmlToolbarCommand = function()
+	{
+	}
+
+	// register the command
+	FCKCommands.RegisterCommand('insertHtml', new insertHtmlToolbarCommand());
+
+	// create the toolbar  button
+	var insertHtmlButton = new FCKToolbarButton('insertHtml', FCKConfig.insertHtml_buttonTooltip || FCKLang.inserHTML_buttonTooltip);
+	insertHtmlButton.IconPath = FCKPlugins.Items['insertHtml'].Path + 'images/toolbarIcon_default.gif'; // or pick any other in folder 'images'
+	FCKToolbarItems.RegisterItem('insertHtml', insertHtmlButton);
+
+	// manage the plugins' button behavior
+	insertHtmlToolbarCommand.prototype.GetState = function()
+	{
+		return FCK_TRISTATE_OFF;
+	}
+
+	// insertHtml's button click function
+	insertHtmlToolbarCommand.prototype.Execute = function()
+	{
+		if (FCKConfig.insertHtml_showDialog || !FCKConfig.insertHtml_snippets || (FCKConfig.insertHtml_snippets && !FCKConfig.insertHtml_snippets.length))
+		{
+			var dialog = new FCKDialogCommand('insertHtml', FCKLang.insertHtml_dialogTitle, FCKPlugins.Items['insertHtml'].Path + 'insertHtml.html', 200, 100);
+			dialog.Execute();
+		}
+		else
+		{
+			FCK.InsertHtml(FCKConfig.insertHtml_snippet);
+			FCK.EditorWindow.parent.FCKUndo.SaveUndoStep();
+		}
+	}

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/insertHtml/insertHtml.html

@@ -45,7 +45,7 @@
 		#insertHtmlTextArea
 		{
 			overflow: auto;
-			margin: 0px 10px 0px 0px;
+			margin: 0px 25px 40px 0px;
 		}
 		#insertHtmlTextArea,
 		{

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/insertHtml/insertHtml.js

@@ -72,7 +72,7 @@
 			}
 			else
 			{
-				//snippet = FCKConfig.insertHtml_snippets;//Chamilo replaced by below
+				//snippet = FCKConfig.insertHtml_snippets;//Chamilo replaced by below (by now)
 				snippet = "";//Insert your tex here
 			}
 			insertHtmlTextArea.value = snippet;

+ 30 - 10
main/inc/lib/fckeditor/myconfig.php

@@ -152,9 +152,7 @@ if ((api_get_setting('enabled_googlemaps') == 'true')) {
 if ((api_get_setting('math_mimetex') == 'true')) {
     $config['LoadPlugin'][] = 'mimetex';
 	// in your server configuration have to be done. The MimeTex executable file has to be installed, see the installation guide.
-	
-	//mimetex checking has been commented that in some system makes loading very slow	
-	
+		
 		// Some additional settings become active only when the 'mimetex' plugin has been enabled:
 		//
 		// The following setting determines whether MimeTeX executable file has been installed on the server or not. This file should be accessible
@@ -163,7 +161,7 @@ if ((api_get_setting('math_mimetex') == 'true')) {
 		// By default, the system tries to detect the MimeTeX executable file automatically.
 		// If you are sure that the MimeTeX executable has been correctly installed, you may set this option to boolean true value.
 		
-		//$config['MimetexExecutableInstalled'] = 'detect'; // 'detect' (default), true, false
+		$config['MimetexExecutableInstalled'] = 'true'; // 'detect' (default), true, false.
 		
 		// Sometimes detection fails (due to slow DNS service, security restrictions, ...). For better probability of success,
 		// the following methods for detection have been defined:
@@ -172,13 +170,13 @@ if ((api_get_setting('math_mimetex') == 'true')) {
 		// 'ip'             - detection is tried at ip address, for example http://192.168.0.1/cgi-bin/mimetex.cgi
 		// 'server_name'    - detection is tried at address based on server's name, for example http://mysite.com/cgi-bin/mimetex.cgi
 		
-		//if (IS_WINDOWS_OS) {
-			//$config['MimetexExecutableDetectionMethod'] = 'bootstrap_ip'; // 'bootstrap_ip' for better chance on Windows (no firewall blocking).
-		//} else {
-			//$config['MimetexExecutableDetectionMethod'] = 'server_name';
-		//}
+		if (IS_WINDOWS_OS) {
+			$config['MimetexExecutableDetectionMethod'] = 'bootstrap_ip'; // 'bootstrap_ip' for better chance on Windows (no firewall blocking).
+		} else {
+			$config['MimetexExecutableDetectionMethod'] = 'server_name';
+		}
 		// Timeout for MimeTeX executable file detection - keep this value as low as possible, especially on Windows servers.
-		//$config['MimetexExecutableDetectionTimeout'] = 0.05;
+		$config['MimetexExecutableDetectionTimeout'] = 0.05;
 }
 
 
@@ -206,6 +204,28 @@ if ((api_get_setting('enabled_imgmap') == 'true')) {
 // wikilink : Adds a dialog for inserting wiki-formatted links.
 $config['LoadPlugin'][] = 'wikilink';
 
+
+// insertHtml: Plugin for inserting HTML. A single preconfigured snippet; a choice from multiple preconfigured snippets; or manually entered HTML.
+if ((api_get_setting('enabled_insertHtml') == 'true')) {
+	$config['LoadPlugin'][] = 'insertHtml';
+}
+	// enter a single snippet (HMTL string) or multiple snippets to choose form (object of description string and HTML string pairs). Or leave empty if you want to show a dialog for the user to enter HTML manually (and not show any default HTML in the dialog textarea)
+	
+	//$config['insertHtml_snippets'] = { 'ArtGallery': '<embed width="475" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="FlashGallery/Art/ArtFlashGallery.swf" mediaType="flashGallery" bgcolor="#ffffff" allowfullscreen="true" flashvars="XMLFile=userfiles/image/ArtGallery/gallery.xml"></embed>', 'PhotoFlowGallery' : '<embed width="700" height="300" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="FlashGallery/PhotoFlow/PhotoFlowGallery.swf" mediaType="flashGallery" bgcolor="#ffffff" flashvars="XMLFile=userfiles/image/PhotoFlowGallery/gallery.xml"></embed>', 'StackPhotoGallery' : '<embed width="600" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="FlashGallery/StackPhoto/StackPhotoGallery.swf" mediaType="flashGallery" bgcolor="#ffffff" flashvars="XMLFile=userfiles/image/StackPhotoGallery/gallery.xml"></embed>', 'ZenGallery' : '<embed width="550" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="FlashGallery/Zen/ZenGallery.swf" mediaType="flashGallery" bgcolor="#ffffff" flashvars="XMLFile=userfiles/image/ZenGallery/gallery.xml"></embed>'};// TODO: this $config['insertHtml_snippets'] does not work. See also temporal hack around line 76 insertHtml.js
+			
+	// (if no snippets specified the dialog will show anyhow)
+	$config['insertHtml_showDialog'] = true;
+	
+	// specify a custom tooltip if you want this to appear when hovering the plugin's toolbar button (e.g. a description of the element being inserted). If no custom tooltip is set 'Insert HTML' will appear, and if available, translated into your language
+	$config['insertHtml_buttonTooltip'] = '';
+	
+	// show a textarea in the dialog? The first HTML set with $config['insertHtml_snippets'] will be shown in the textarea by default. If no snippets specified the textarea will show anyhow
+	$config['insertHtml_showTextarea']= false;
+	
+	// the size of the textarea in the dialog, in px
+	$config['insertHtml_textareaWidth'] = 400;
+	$config['insertHtml_textareaHeight'] = 300;
+
 /*
  * File manager.
  */

+ 36 - 25
main/inc/lib/fckeditor/toolbars/extended/wiki.php

@@ -3,40 +3,51 @@
 // See license terms in chamilo/documentation/license.txt
 
 // Training tools
-// Wiki
+// Documents
 
 // For more information: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options
 
+//NOTE: Does not include Replace because it is redundant, being in the same tab to Find
+//TODO: DocProps, asciimath don't run ok here. 
+
+// Hide/show SpellCheck buttom
+if ((api_get_setting('allow_spellcheck') == 'true')) {
+	$VSpellCheck='SpellCheck';
+}
+else{
+	$VSpellCheck='';	
+}
+
 // This is the visible toolbar set when the editor has "normal" size.
 $config['ToolbarSets']['Normal'] = array(
-	array('FitWindow','Save','NewPage','Templates','PageBreak','Preview','-','PasteText','-','Undo','Redo','-','SelectAll','-','Find'),
-	array('Wikilink','Link','Unlink','Anchor'),
-	array('Image','flvPlayer','Flash','EmbedMovies','YouTube','MP3','mimetex','asciimath'),
-	array('Table','Rule','Smiley','SpecialChar','googlemaps'),
-	array('FontFormat','FontName','FontSize'),
-	array('Bold','Italic','Underline'),
-	array('Subscript','Superscript','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','-','OrderedList','UnorderedList','-','Outdent','Indent','-','TextColor','BGColor'),
-	array('Source')
+	array('Save','NewPage','Templates','-','PasteText'),
+	array('Undo','Redo'),
+	array('Wikilink','Link','Image','flvPlayer','Table','mimetex'),
+	array('UnorderedList','OrderedList','Rule'),
+	array('JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'),
+	array('FontFormat','FontName','FontSize','Bold','Italic','Underline','TextColor','BGColor'),
+	array('FitWindow')
 );
 
 // This is the visible toolbar set when the editor is maximized.
 // If it has not been defined, then the toolbar set for the "normal" size is used.
+
 $config['ToolbarSets']['Maximized'] = array(
-	array('FitWindow','DocProps','-','Save','NewPage','Preview','-','Templates'),
-	array('Cut','Copy','Paste','PasteText','PasteWord','-','Print'),
-	array('Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'),
-	array('Link','Unlink','Anchor','Wikilink','Glossary'),
-	'/',
-	array('Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'),
-	array('OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'),
-	array('JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'),
-	array('Rule','SpecialChar','PageBreak'),
-	array('mimetex','asciimath','Image','imgmapPopup','Flash','MP3','EmbedMovies','flvPlayer','YouTube','googlemaps','Smiley'),
-	'/',
-	array('Style','FontFormat','FontName','FontSize'),
-	array('TextColor','BGColor'),
-	array('Table','TableInsertRowAfter','TableDeleteRows','TableInsertColumnAfter','TableDeleteColumns','TableInsertCellAfter','TableDeleteCells','TableMergeCells','TableHorizontalSplitCell','TableVerticalSplitCell','TableCellProp'),
-	array('ShowBlocks','Source')
+	array('Save','NewPage','Templates','-','Preview','Print'),
+	array('Cut','Copy','Paste','PasteText','PasteWord'),
+	array('Undo','Redo','-','SelectAll','Find','-','RemoveFormat'),
+	array('Wikilink','Link','Unlink','Anchor','Glossary'),
+	array('Image','imgmapPopup','flvPlayer','EmbedMovies','YouTube','Flash','MP3','googlemaps','Smiley','SpecialChar','insertHtml','mimetex','fckeditor_wiris_openFormulaEditor','fckeditor_wiris_openCAS'),
+'/',
+	array('Table','TableInsertRowAfter','TableDeleteRows','TableInsertColumnAfter','TableDeleteColumns','TableInsertCellAfter','TableDeleteCells','TableMergeCells','TableHorizontalSplitCell','TableVerticalSplitCell','TableCellProp','-','CreateDiv'),
+	array('UnorderedList','OrderedList','Rule','-','Outdent','Indent','Blockquote'),
+	array('JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'),	
+	array('Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript','-','TextColor','BGColor'),
+	array($VSpellCheck),	
+	array('Style','FontFormat','FontName','FontSize'),	
+	array('PageBreak','ShowBlocks','Source'),
+	array('FitWindow')
+	
 );
 
 // Sets whether the toolbar can be collapsed/expanded or not.
@@ -67,4 +78,4 @@ else{
 // Here new width and height of the editor may be set.
 // Possible values, examples: 300 , '250' , '100%' , ...
 //$config['Width'] = '100%';
-//$config['Height'] = '400';
+//$config['Height'] = '300';

+ 4 - 1
main/install/db_main.sql

@@ -780,6 +780,7 @@ VALUES
 ('pdf_export_watermark_enable',		NULL,'radio',		'Platform',	'false','PDFExportWatermarkEnableTitle',	'PDFExportWatermarkEnableComment',	'platform',NULL, 1),
 ('pdf_export_watermark_by_course',	NULL,'radio',		'Platform',	'false','PDFExportWatermarkByCourseTitle',	'PDFExportWatermarkByCourseComment','platform',NULL, 1),
 ('pdf_export_watermark_text',		NULL,'textfield',	'Platform',	'',		'PDFExportWatermarkTextTitle',		'PDFExportWatermarkTextComment',	'platform',NULL, 1),
+('enabled_insertHtml',NULL,'radio','Editor','false','EnabledInsertHtmlTitle','EnabledInsertHtmlComment',NULL,NULL, 0),
 ('chamilo_database_version', NULL, 'textfield', NULL, '1.8.8.13050', 'DokeosDatabaseVersion', '', NULL, NULL, 0);
 
 
@@ -1018,7 +1019,9 @@ VALUES
 ('pdf_export_watermark_enable','true','Yes'),
 ('pdf_export_watermark_enable','false','No'),
 ('pdf_export_watermark_by_course','true','Yes'),
-('pdf_export_watermark_by_course','false','No');
+('pdf_export_watermark_by_course','false','No'),
+('enabled_insertHtml','true','Yes'),
+('enabled_insertHtml','false','No');
 
 UNLOCK TABLES;
 

+ 7 - 0
main/install/migrate-db-1.8.7-1.8.8-pre.sql

@@ -86,6 +86,13 @@ ALTER TABLE personal_agenda ADD PRIMARY KEY (id);
 
 UPDATE settings_current SET selected_value='1' WHERE variable='more_buttons_maximized_mode';
 
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_insertHtml',NULL,'radio','Editor','false','EnabledInsertHtmlTitle','EnabledInsertHtmlComment',NULL,NULL, 0);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_insertHtml', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_insertHtml', 'false', 'No');
+
+
+
+
 -- xxSTATSxx
 ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
 -- xxUSERxx