Author: boutell
Date: 2010-01-15 20:26:15 +0100 (Fri, 15 Jan 2010)
New Revision: 26690
Modified:
plugins/pkToolkitPlugin/trunk/lib/pkHtml.class.php
Log:
pkHtml::textToHtml is now a wrapper around the Text helper functions.
Email addresses are now converted to links just like URLs are.
Entities are still esscaped (the text helper functions don't do that by
themselves).
Modified: plugins/pkToolkitPlugin/trunk/lib/pkHtml.class.php
===================================================================
--- plugins/pkToolkitPlugin/trunk/lib/pkHtml.class.php 2010-01-15 19:00:05 UTC
(rev 26689)
+++ plugins/pkToolkitPlugin/trunk/lib/pkHtml.class.php 2010-01-15 19:26:15 UTC
(rev 26690)
@@ -526,16 +526,12 @@
$guid = pkGuid::generate();
$href = self::jsEscape("mailto:$u...@$domain");
$label = self::jsEscape(trim($label));
-
- return <<<EOM
-<a href='#' id='$guid'></a>
-<script type='text/javascript' charset='utf-8'>
- var e = document.getElementById('$guid');
- e.setAttribute('href', '$href');
- e.innerHTML = '$label';
-</script>
-EOM
-;
+ // ACHTUNG: this is carefully crafted to avoid introducing extra
whitespace
+ return "<a href='#' id='$guid'></a><script type='text/javascript'
charset='utf-8'>
+ var e = document.getElementById('$guid');
+ e.setAttribute('href', '$href');
+ e.innerHTML = '$label';
+ </script>";
}
// This is intentionally obscure for use in mailto: obfuscators.
@@ -554,17 +550,19 @@
/**
* Just the basics: escape entities, turn URLs into links, and turn newlines
into line breaks.
+ * Also turn email addresses into links (we don't obfuscate them here as
that makes them
+ * harder to manipulate some more, but check out pkHtml::obfuscateMailto).
*
+ * This function is now a wrapper around TextHelper, except for the entity
escape which is
+ * not included in simple_format_text for some reason
+ *
* @param string $text The text you want converted to basic HTML.
* @return string Text with carriage returns and anchor tags.
*/
static public function textToHtml($text)
{
- $text = htmlentities($text);
- $text = preg_replace(
- "/(http\:.*?)([\s\]\)\}]|$)/", "<a href=\"$1\">$1</a>$2", $text);
- $text = preg_replace("/\n/", "<br />\n", $text);
- return $text;
+ sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag',
'Text'));
+ return auto_link_text(simple_format_text(htmlentities($text)));
}
// For any given HTML, returns only the img tags. If
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.