[Fusionforge-commits] FusionForge branch master updated. 805c57c2bed10f8ffe92e3e9d4e42a047b8d658c

Alain Peyrat aljeux at fusionforge.org
Fri Nov 30 16:23:38 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  805c57c2bed10f8ffe92e3e9d4e42a047b8d658c (commit)
      from  314cb598beefc2351c360a7695473adec433a092 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 805c57c2bed10f8ffe92e3e9d4e42a047b8d658c
Author: Alain Peyrat <alain.peyrat at alcatel-lucent.com>
Date:   Fri Nov 30 16:23:24 2012 +0100

    block plugin: If user is editing HTML, keep HTML format by saying it's html

diff --git a/src/common/include/utils.php b/src/common/include/utils.php
index 704d5d3..97492b1 100644
--- a/src/common/include/utils.php
+++ b/src/common/include/utils.php
@@ -1704,6 +1704,9 @@ function util_sanitise_multiline_submission($text) {
 }
 
 
+function util_is_html($string) {
+	return (strip_tags(util_unconvert_htmlspecialchars($string)) != $string);
+}
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"
diff --git a/src/plugins/blocks/www/index.php b/src/plugins/blocks/www/index.php
index 5765ab0..5b32a7a 100644
--- a/src/plugins/blocks/www/index.php
+++ b/src/plugins/blocks/www/index.php
@@ -279,7 +279,7 @@ if ($type == 'admin') {
 
 	print _("Edit the block as you want. If you activate the HTML editor, you will be able to use WYSIWYG formatting (bold, colors...)");
 
-	print "<center>";
+	print '<div class="align-center">';
 	print "<p><b>$blocks[$name]</b> ($name)</p>";
 	print "<form action=\"/plugins/blocks/\" method=\"post\">";
 	print "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
@@ -303,6 +303,12 @@ if ($type == 'admin') {
 	$params['height'] = "500";
 	$params['group'] = $id;
 	$params['content'] = '<textarea name="body"  rows="20" cols="80">'.$body.'</textarea>';
+
+	if (util_is_html($body)) {
+		// If user is editing HTML, keep HTML format by saying it's html
+		$params['content'] = '<input type="hidden" name="_body_content_type" value="html" />'."\n".$params['content'];
+	}
+
 	plugin_hook_by_reference("text_editor", $params);
 	echo $params['content'];
 
@@ -310,7 +316,7 @@ if ($type == 'admin') {
 			_("Save") .
 			"\" />";
 	print "</form>";
-	print "</center>";
+	print "</div>";
 
 	print "<fieldset><legend>".
 			_("Tips").
@@ -326,7 +332,7 @@ if ($type == 'admin') {
 			"</li><li>".
 			"{boxBottom}".
 			_(": will create the end part of a box.").
-			"</li></ul><p /><ul><li>".
+			"</li></ul><ul><li>".
 			"{boxHeader}".
 			_(": will create a header before a text.").
 			"</li><li>{boxFooter}".
diff --git a/tests/unit/utils/UtilsTest.php b/tests/unit/utils/UtilsTest.php
index 5feb3af..be29cc8 100644
--- a/tests/unit/utils/UtilsTest.php
+++ b/tests/unit/utils/UtilsTest.php
@@ -121,4 +121,16 @@ class Utils_Tests extends PHPUnit_Framework_TestCase
 		$_REQUEST=array('no_arg' => 'BaD');
 		$this->assertEquals(getFilteredStringFromRequest('arg', '/^[a-z]+$/', 'default'), 'default');
 	}
+
+	public function testUtilIsHtml()
+	{
+		$this->assertFalse(util_is_html(''));
+		$this->assertFalse(util_is_html('This is a text.'));
+		$this->assertTrue(util_is_html('This is <strong>html</strong>'));
+		$this->assertFalse(util_is_html('Math: 4 > 3'));
+		$this->assertFalse(util_is_html('Math: "4" > 3'));
+		$this->assertTrue(util_is_html('Math: 4 > 3'));
+		$this->assertTrue(util_is_html('Mathétiques'));
+		$this->assertTrue(util_is_html('Math: "4" > 3'));
+	}
 }

-----------------------------------------------------------------------

Summary of changes:
 src/common/include/utils.php     |    3 +++
 src/plugins/blocks/www/index.php |   12 +++++++++---
 tests/unit/utils/UtilsTest.php   |   12 ++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list