Revision: 1216
http://mrbs.svn.sourceforge.net/mrbs/?rev=1216&view=rev
Author: cimorrison
Date: 2009-10-07 15:20:21 +0000 (Wed, 07 Oct 2009)
Log Message:
-----------
- Added an mrbs_entity_decode() function
- Extended removal of entities in period names in mail messages to PHP4
and below.
Modified Paths:
--------------
mrbs/trunk/web/functions.inc
mrbs/trunk/web/functions_mail.inc
Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc 2009-10-06 22:38:04 UTC (rev 1215)
+++ mrbs/trunk/web/functions.inc 2009-10-07 15:20:21 UTC (rev 1216)
@@ -381,7 +381,7 @@
}
}
-// version of the standard PHP function nl2br that takes account of the fact
+// version of the standard PHP function nl2br() that takes account of the fact
// that the optional second parameter is only available from PHP 5.3.0 onwards.
function mrbs_nl2br($string)
{
@@ -395,6 +395,49 @@
}
}
+// Version of the standard PHP function html_entity_decode()
+// Although html_entity_decode() was introduced in PHP 4.3.0, support for
+// multi-byte character sets was only introduced in PHP 5.0.0.
+// So if we're running PHP5 or higher we'll use the standard
+// PHP function; otherwise we'll do the best we can. At the moment
+// we just replace with an ordinary space, which
+// should be sufficient in most MRBS circumstances. This could
+// always be extended later to do something more sophisticated if
+// necessary.
+function mrbs_entity_decode($string)
+{
+ $n_args = func_num_args();
+ if ($n_args > 1)
+ {
+ $quote_style = func_get_arg(1);
+ }
+ if ($n_args > 2)
+ {
+ $charset = func_get_arg(2);
+ }
+
+ if (function_exists('version_compare') && version_compare(PHP_VERSION,
'5.0.0', 'ge'))
+ {
+ switch ($n_args)
+ {
+ case 3:
+ $string = html_entity_decode($string, $quote_style, $charset);
+ break;
+ case 2:
+ $string = html_entity_decode($string, $quote_style);
+ break;
+ default:
+ $string = html_entity_decode($string);
+ break;
+ }
+ }
+ else
+ {
+ $string = str_replace(' ', ' ', $string);
+ }
+ return $string;
+}
+
// validates a comma separated list of email addresses
// returns FALSE if any one of them is invalid, otherwise TRUE
function validate_email_list($list)
Modified: mrbs/trunk/web/functions_mail.inc
===================================================================
--- mrbs/trunk/web/functions_mail.inc 2009-10-06 22:38:04 UTC (rev 1215)
+++ mrbs/trunk/web/functions_mail.inc 2009-10-07 15:20:21 UTC (rev 1216)
@@ -96,14 +96,7 @@
// As HTML entities and tags are allowed in period names, we need to
replace/strip
// them out before putting them in emails, which are sent as plain text
$mailperiod = $periods[$p_num];
- // Although html_entity_decode() was introduced in PHP 4.3.0, support for
- // multi-byte character sets was only introduced in PHP 5.0.0. So rather
than
- // trying to do anything complicated for PHP 4, we'll just do the decode if
- // we're running PHP 5 or higher. Sorry, PHP 4 users!
- if (function_exists('version_compare') && version_compare(PHP_VERSION,
'5.0.0', 'ge'))
- {
- $mailperiod = html_entity_decode($mailperiod, ENT_COMPAT,
get_mail_charset());
- }
+ $mailperiod = mrbs_entity_decode($mailperiod, ENT_COMPAT,
get_mail_charset());
$mailperiod = strip_tags($mailperiod);
return array($p_num, $mailperiod . strftime(", %A %d %B %Y",$t));
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits