cvs: docweb /include docweb_language.class.php docweb_template.class.php init.inc.php
| From: | Sean Coates | Date: | Sun, 31 Oct 2004 04:49:39 +0000 |
| Subject: | cvs: docweb /include docweb_language.class.php docweb_template.class.php init.inc.php | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-379@lists.php.net to get a copy of this message | ||
sean Sun Oct 31 00:49:39 2004 EDT
Modified files:
/docweb/include docweb_language.class.php docweb_template.class.php
init.inc.php
Log:
added dynamic entity params
http://cvs.php.net/diff.php/docweb/include/docweb_language.class.php?r1=1.2&r2=1.3&ty=u
Index: docweb/include/docweb_language.class.php
diff -u docweb/include/docweb_language.class.php:1.2 docweb/include/docweb_language.class.php:1.3
--- docweb/include/docweb_language.class.php:1.2 Sat Oct 30 10:18:03 2004
+++ docweb/include/docweb_language.class.php Sun Oct 31 00:49:38 2004
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
| Authors: Sean Coates <sean@php.net> |
+----------------------------------------------------------------------+
-$Id: docweb_language.class.php,v 1.2 2004/10/30 14:18:03 vincent Exp $
+$Id: docweb_language.class.php,v 1.3 2004/10/31 04:49:38 sean Exp $
*/
/**
@@ -115,13 +115,29 @@
/**
* Gives a single entity's text
*
- * @param string $ent Entity to get
+ * @param string $ent Entity to get
+ * @param array $params Optional array of dynamic parameters
* @return mixed text associated with $ent, or FALSE on failure (not present)
*/
- function get($ent)
+ function get($ent, $params=FALSE)
{
+ $params = (array) $params;
+
+ static $paramEntMatchRegex = FALSE;
+ if (!$paramEntMatchRegex) {
+ $paramEntMatchRegex = '/&('. preg_quote(DOCWEB_PARAM_ENTITIY_PREFIX)
.'\..*?);/';
+ }
+
if ($this->entities) {
- return isset($this->entities[$ent]) ? stripslashes($this->entities[$ent]) :
FALSE;
+ $text = isset($this->entities[$ent]) ? stripslashes($this->entities[$ent]) :
FALSE;
+ preg_match_all($paramEntMatchRegex, $text, $matches);
+ for ($i=0; $i<count($matches[0]); $i++) {
+ $rep = substr($matches[1][$i], strlen(DOCWEB_PARAM_ENTITIY_PREFIX) + 1);
+ if (isset($params[$rep])) {
+ $text = str_replace($matches[0][$i], $params[$rep], $text);
+ }
+ }
+ return $text;
} else {
return FALSE;
}
http://cvs.php.net/diff.php/docweb/include/docweb_template.class.php?r1=1.2&r2=1.3&ty=u
Index: docweb/include/docweb_template.class.php
diff -u docweb/include/docweb_template.class.php:1.2 docweb/include/docweb_template.class.php:1.3
--- docweb/include/docweb_template.class.php:1.2 Sat Oct 30 23:54:09 2004
+++ docweb/include/docweb_template.class.php Sun Oct 31 00:49:38 2004
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
| Authors: Sean Coates <sean@php.net> |
+----------------------------------------------------------------------+
-$Id: docweb_template.class.php,v 1.2 2004/10/31 03:54:09 sean Exp $
+$Id: docweb_template.class.php,v 1.3 2004/10/31 04:49:38 sean Exp $
*/
/**
@@ -57,6 +57,8 @@
function __construct($filename)
{
$this->filename = $filename;
+ // always pass $Language
+ $this->params['Language'] =& $GLOBALS['Language'];
return TRUE;
}
http://cvs.php.net/diff.php/docweb/include/init.inc.php?r1=1.3&r2=1.4&ty=u
Index: docweb/include/init.inc.php
diff -u docweb/include/init.inc.php:1.3 docweb/include/init.inc.php:1.4
--- docweb/include/init.inc.php:1.3 Fri Oct 29 10:33:04 2004
+++ docweb/include/init.inc.php Sun Oct 31 00:49:38 2004
@@ -18,7 +18,7 @@
| Gabor Hojtsy <goba@php.net> |
| Sean Coates <sean@php.net> |
+----------------------------------------------------------------------+
-$Id: init.inc.php,v 1.3 2004/10/29 14:33:04 vincent Exp $
+$Id: init.inc.php,v 1.4 2004/10/31 04:49:38 sean Exp $
*/
error_reporting(E_ALL);
@@ -70,6 +70,7 @@
if ($inCli != true) {
// language & template constants
define('DOCWEB_ENTITIY_PREFIX', 'docweb');
+ define('DOCWEB_PARAM_ENTITIY_PREFIX', 'param');
// language engine
require_once('docweb_language.class.php');