Date: 01/09/01
- Next message: uw: "[phplib-dev] cvs commit"
- Previous message: uw: "[phplib-dev] cvs commit"
- Next in thread: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: uw
Date: Wed Jan 10 00:19:52 2001
Modified files:
php-lib/php/ext/integratedtemplate.inc
php-lib/php/ext/integratedtemplateextension.inc
Log message:
Added functions to get informations on the variables of a template
Index: php-lib/php/ext/integratedtemplate.inc
diff -u php-lib/php/ext/integratedtemplate.inc:1.9 php-lib/php/ext/integratedtemplate.inc:1.10
--- php-lib/php/ext/integratedtemplate.inc:1.9 Mon Dec 11 14:12:12 2000
+++ php-lib/php/ext/integratedtemplate.inc Wed Jan 10 00:19:19 2001
@@ -90,7 +90,7 @@
* </code>
*
* <email protected> Ulf Wendel <uw <email protected>>
-* <email protected> $Id: integratedtemplate.inc,v 1.9 2000/12/11 13:12:12 uw Exp $
+* <email protected> $Id: integratedtemplate.inc,v 1.10 2001/01/09 23:19:19 uw Exp $
* <email protected> public
*/
class IntegratedTemplate {
@@ -665,7 +665,7 @@
} // end func setRoot
/**
- * Build a list of all variables within a block
+ * Build a list of all variables within of a block
*/
function buildBlockvariablelist() {
Index: php-lib/php/ext/integratedtemplateextension.inc
diff -u php-lib/php/ext/integratedtemplateextension.inc:1.5 php-lib/php/ext/integratedtemplateextension.inc:1.6
--- php-lib/php/ext/integratedtemplateextension.inc:1.5 Tue Jan 9 23:13:38 2001
+++ php-lib/php/ext/integratedtemplateextension.inc Wed Jan 10 00:19:20 2001
@@ -13,7 +13,7 @@
*
* <email protected> Ulf Wendel <uw <email protected>>
* <email protected> public
-* <email protected> $Id: integratedtemplateextension.inc,v 1.5 2001/01/09 22:13:38 uw Exp $
+* <email protected> $Id: integratedtemplateextension.inc,v 1.6 2001/01/09 23:19:20 uw Exp $
*/
class IntegratedTemplateExtension extends IntegratedTemplate {
@@ -93,8 +93,8 @@
*/
function IntegratedTemplateExtension($root = "") {
- $this->checkblocknameRegExp = "@".$this->blocknameRegExp."@";
- $this->functionRegExp = "@".$this->functionPrefix."(".$this->functionnameRegExp.")\s*\( <email protected>";
+ $this->checkblocknameRegExp = "@" . $this->blocknameRegExp . "@";
+ $this->functionRegExp = "@" . $this->functionPrefix . "(" . $this->functionnameRegExp . ")\s*\( <email protected>";
$this->IntegratedTemplate($root);
@@ -225,8 +225,8 @@
} else if ( count($parents) > 1 ) {
reset($parents);
- while (list($k, $parent)=each($parents))
- $msg.= "$parent, ";
+ while (list($k, $parent) = each($parents))
+ $msg .= "$parent, ";
$msg = substr($parent, -2);
$this->halt("The variable placeholder '$placeholder' must be unique, found in multiple blocks '$msg'.", __FILE__, __LINE__);
@@ -240,8 +240,8 @@
return false; // findBlocks() already throws an exception
$this->blockinner[$parents[0]][] = $blockname;
- $this->blocklist[$parents[0]] = preg_replace( "@".$this->openingDelimiter.$placeholder.$this->closingDelimiter."@",
- $this->openingDelimiter."__".$blockname."__".$this->closingDelimiter,
+ $this->blocklist[$parents[0]] = preg_replace( "@" . $this->openingDelimiter . $placeholder . $this->closingDelimiter . "@",
+ $this->openingDelimiter . "__" . $blockname . "__" . $this->closingDelimiter,
$this->blocklist[$parents[0]]
);
@@ -378,7 +378,7 @@
*/
function setFunctioncontent($functionID, $replacement) {
- $this->variableCache["__function".$functionID."__"] = $replacement;
+ $this->variableCache["__function" . $functionID . "__"] = $replacement;
} // end func setFunctioncontent
@@ -439,6 +439,7 @@
*
* <email protected> string
* <email protected> boolean
+ * <email protected> public
* <email protected> getBlocklist()
*/
function blockExists($blockname) {
@@ -446,6 +447,38 @@
} // end func blockExists
/**
+ * Returns a list of variables of a block.
+ *
+ * <email protected> string Blockname
+ * <email protected> array [varname => varname]
+ * <email protected> public
+ * <email protected> BlockvariableExists()
+ */
+ function getBlockvariables($block) {
+ if (!isset($this->blockvariables[$block]))
+ return array();
+
+ $variables = array();
+ foreach ($this->blockvariables as $variable => $v)
+ $variables[$variable] = $variable;
+
+ return $variables;
+ } // end func getBlockvariables
+
+ /**
+ * Checks wheter a block variable exists.
+ *
+ * <email protected> string Blockname
+ * <email protected> string Variablename
+ * <email protected> boolean
+ * <email protected> public
+ * <email protected> getBlockvariables()
+ */
+ function BlockvariableExists($block, $variable) {
+ return isset($this->blockvariables[$block][$variable]);
+ } // end func BlockvariableExists
+
+ /**
* Builds a functionlist from the template.
*/
function buildFunctionlist() {
@@ -463,14 +496,14 @@
$head = $this->getValue($template, ")");
$args = array();
- $this->template = str_replace($regs[0].$head.")", "{__function".$num."__}", $this->template);
- $template = str_replace($regs[0].$head.")", "{__function".$num."__}", $template);
+ $this->template = str_replace($regs[0] . $head . ")", "{__function" . $num . "__}", $this->template);
+ $template = str_replace($regs[0] . $head . ")", "{__function" . $num . "__}", $template);
while ("" != $head && $arg = $this->getValue($head, ",")) {
$args[] = trim($arg);
if ($arg == $head)
break;
- $head = substr($head, strlen($arg)+1);
+ $head = substr($head, strlen($arg) + 1);
}
$this->functions[$num++] = array(
@@ -483,7 +516,7 @@
function getValue($code, $delimiter) {
- if (""==$code)
+ if ("" == $code)
return "";
if (!is_array($delimiter))
@@ -499,11 +532,11 @@
} else {
- for ($i = 0; $i< $len; ++$i) {
+ for ($i = 0; $i < $len; ++$i) {
$char = $code[$i];
- if (('"' == $char || "'" == $char) && ($char == $enclosed_by || "" == $enclosed_by) && (0 == $i || ($i > 0 && "\\" != $code[$i-1]))) {
+ if (('"' == $char || "'" == $char) && ($char == $enclosed_by || "" == $enclosed_by) && (0 == $i || ($i > 0 && "\\" != $code[$i - 1]))) {
if (!$enclosed)
$enclosed_by = $char;
@@ -533,10 +566,10 @@
function deleteFromBlockvariablelist($block, $variables) {
if (!is_array($variables))
- $variables = array( $variables => true);
+ $variables = array($variables => true);
reset($this->blockvariables[$block]);
- while (list($k, $varname)=each($this->blockvariables[$block]))
+ while (list($k, $varname) = each($this->blockvariables[$block]))
if (isset($variables[$varname]))
unset($this->blockvariables[$block][$k]);
@@ -565,10 +598,10 @@
$parents = array();
reset($this->blocklist);
- while (list($blockname, $content)=each($this->blocklist)) {
+ while (list($blockname, $content) = each($this->blocklist)) {
reset($this->blockvariables[$blockname]);
- while (list($k, $varname)=each($this->blockvariables[$blockname]))
+ while (list($k, $varname) = each($this->blockvariables[$blockname]))
if ($variable == $varname)
$parents[] = $blockname;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>
- Next message: uw: "[phplib-dev] cvs commit"
- Previous message: uw: "[phplib-dev] cvs commit"
- Next in thread: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

