cvs: docweb /include docweb_template.class.php
| From: | Sean Coates | Date: | Sun, 31 Oct 2004 03:54:10 +0000 |
| Subject: | cvs: docweb /include docweb_template.class.php | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-378@lists.php.net to get a copy of this message | ||
sean Sat Oct 30 23:54:10 2004 EDT
Modified files:
/docweb/include docweb_template.class.php
Log:
nested entity support
http://cvs.php.net/diff.php/docweb/include/docweb_template.class.php?r1=1.1&r2=1.2&ty=u
Index: docweb/include/docweb_template.class.php
diff -u docweb/include/docweb_template.class.php:1.1 docweb/include/docweb_template.class.php:1.2
--- docweb/include/docweb_template.class.php:1.1 Wed Oct 27 12:43:01 2004
+++ docweb/include/docweb_template.class.php Sat Oct 30 23:54:09 2004
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
| Authors: Sean Coates <sean@php.net> |
+----------------------------------------------------------------------+
-$Id: docweb_template.class.php,v 1.1 2004/10/27 16:43:01 sean Exp $
+$Id: docweb_template.class.php,v 1.2 2004/10/31 03:54:09 sean Exp $
*/
/**
@@ -148,13 +148,25 @@
{
$Language =& $GLOBALS['Language'];
- $entMatchRegex = '/&('. preg_quote(DOCWEB_ENTITIY_PREFIX)
.'\..*?);/';
+ static $entMatchRegex = FALSE;
+ if (!$entMatchRegex) {
+ $entMatchRegex = '/&('. preg_quote(DOCWEB_ENTITIY_PREFIX)
.'\..*?);/';
+ }
+
preg_match_all($entMatchRegex, $text, $matches);
+ $replaceCounter = 0;
for ($i=0; $i<count($matches[0]); $i++) {
if ($rep = $Language->get($matches[1][$i])) {
- $text = str_replace($matches[0][$i], $rep, $text);
+ $text = str_replace($matches[0][$i], $rep, $text);
+ $replaceCounter++;
}
}
+
+ // recurse, if there were replacements, and there are possibly more
+ if ($replaceCounter && preg_match($entMatchRegex, $text)) {
+ $text = $this->replace_entities($text);
+ }
+
return $text;
}
}